cola Report for GDS3326

Date: 2019-12-25 20:43:24 CET, cola version: 1.3.2

Document is loading...


Summary

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

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

The call of run_all_consensus_partition_methods() was:

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

Dimension of the input matrix:

mat = get_matrix(res_list)
dim(mat)
#> [1] 51941    59

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 2 1.000 0.995 0.998 **
SD:mclust 6 1.000 0.976 0.982 ** 5
SD:NMF 2 1.000 0.983 0.993 **
CV:hclust 6 1.000 0.966 0.986 ** 2
CV:mclust 6 1.000 0.990 0.995 ** 5
MAD:skmeans 4 1.000 0.964 0.977 ** 2,3
MAD:mclust 6 1.000 0.988 0.993 ** 2,3,4,5
ATC:hclust 2 1.000 0.978 0.990 **
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:NMF 3 0.999 0.977 0.987 ** 2
MAD:pam 6 0.990 0.961 0.984 ** 2,3,4,5
ATC:mclust 6 0.976 0.920 0.965 ** 2,4,5
MAD:hclust 6 0.947 0.966 0.964 * 5
ATC:pam 6 0.946 0.946 0.971 * 2,4
SD:pam 6 0.946 0.962 0.985 * 2,4
CV:pam 6 0.946 0.977 0.991 * 2
CV:NMF 6 0.940 0.934 0.941 * 2,5
CV:skmeans 5 0.933 0.918 0.930 * 2,3,4
ATC:skmeans 6 0.910 0.925 0.939 * 2,3,4
MAD:NMF 4 0.905 0.893 0.947 * 3
SD:skmeans 6 0.901 0.940 0.928 * 2,3,4
SD:kmeans 5 0.672 0.812 0.739
MAD:kmeans 2 0.369 0.872 0.894
CV:kmeans 2 0.327 0.913 0.884

**: 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.473 0.524   0.524
#> CV:NMF      2 0.930           0.957       0.979          0.495 0.499   0.499
#> MAD:NMF     2 0.829           0.893       0.957          0.504 0.493   0.493
#> ATC:NMF     2 1.000           0.986       0.994          0.441 0.556   0.556
#> SD:skmeans  2 1.000           1.000       1.000          0.484 0.516   0.516
#> CV:skmeans  2 1.000           0.955       0.981          0.502 0.499   0.499
#> MAD:skmeans 2 1.000           0.991       0.995          0.508 0.493   0.493
#> ATC:skmeans 2 1.000           0.958       0.983          0.476 0.516   0.516
#> SD:mclust   2 0.364           0.375       0.756          0.306 0.691   0.691
#> CV:mclust   2 0.483           0.955       0.921          0.427 0.524   0.524
#> MAD:mclust  2 1.000           0.997       0.998          0.477 0.524   0.524
#> ATC:mclust  2 1.000           0.998       0.999          0.497 0.503   0.503
#> SD:kmeans   2 0.380           0.938       0.901          0.389 0.544   0.544
#> CV:kmeans   2 0.327           0.913       0.884          0.378 0.544   0.544
#> MAD:kmeans  2 0.369           0.872       0.894          0.447 0.544   0.544
#> ATC:kmeans  2 1.000           1.000       1.000          0.445 0.556   0.556
#> SD:pam      2 1.000           0.997       0.999          0.432 0.569   0.569
#> CV:pam      2 0.964           0.973       0.987          0.408 0.598   0.598
#> MAD:pam     2 1.000           0.968       0.986          0.453 0.556   0.556
#> ATC:pam     2 1.000           1.000       1.000          0.432 0.569   0.569
#> SD:hclust   2 1.000           0.995       0.998          0.126 0.871   0.871
#> CV:hclust   2 1.000           1.000       1.000          0.129 0.871   0.871
#> MAD:hclust  2 0.484           0.946       0.887          0.417 0.509   0.509
#> ATC:hclust  2 1.000           0.978       0.990          0.461 0.534   0.534
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.695           0.776       0.857          0.214 0.958   0.920
#> CV:NMF      3 0.649           0.759       0.852          0.247 0.777   0.580
#> MAD:NMF     3 0.947           0.937       0.975          0.303 0.802   0.617
#> ATC:NMF     3 0.999           0.977       0.987          0.342 0.837   0.711
#> SD:skmeans  3 1.000           0.997       0.997          0.368 0.779   0.589
#> CV:skmeans  3 1.000           0.976       0.989          0.319 0.737   0.521
#> MAD:skmeans 3 1.000           0.980       0.991          0.302 0.787   0.593
#> ATC:skmeans 3 0.967           0.897       0.963          0.267 0.849   0.714
#> SD:mclust   3 0.658           0.786       0.880          0.922 0.633   0.512
#> CV:mclust   3 0.775           0.909       0.936          0.334 0.640   0.459
#> MAD:mclust  3 1.000           0.973       0.980          0.353 0.833   0.681
#> ATC:mclust  3 0.881           0.934       0.957          0.335 0.710   0.482
#> SD:kmeans   3 0.657           0.752       0.837          0.451 0.839   0.714
#> CV:kmeans   3 0.586           0.728       0.810          0.526 1.000   1.000
#> MAD:kmeans  3 0.599           0.871       0.876          0.394 0.784   0.608
#> ATC:kmeans  3 0.763           0.931       0.935          0.372 0.797   0.638
#> SD:pam      3 0.840           0.948       0.943          0.268 0.861   0.755
#> CV:pam      3 0.736           0.893       0.937          0.319 0.823   0.714
#> MAD:pam     3 1.000           0.957       0.984          0.384 0.825   0.685
#> ATC:pam     3 0.828           0.936       0.949          0.302 0.861   0.755
#> SD:hclust   3 0.482           0.884       0.923          2.753 0.649   0.598
#> CV:hclust   3 0.477           0.809       0.786          2.586 0.562   0.497
#> MAD:hclust  3 0.843           0.942       0.935          0.455 0.874   0.752
#> ATC:hclust  3 0.781           0.865       0.932          0.142 0.953   0.912
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.661           0.854       0.893         0.1966 0.771   0.551
#> CV:NMF      4 0.897           0.925       0.952         0.1261 0.964   0.894
#> MAD:NMF     4 0.905           0.893       0.947         0.0749 0.930   0.803
#> ATC:NMF     4 0.721           0.691       0.801         0.1519 0.891   0.743
#> SD:skmeans  4 0.906           0.942       0.949         0.1061 0.886   0.679
#> CV:skmeans  4 0.939           0.961       0.970         0.1146 0.886   0.679
#> MAD:skmeans 4 1.000           0.964       0.977         0.1068 0.908   0.739
#> ATC:skmeans 4 0.915           0.934       0.964         0.1297 0.878   0.698
#> SD:mclust   4 0.855           0.838       0.908         0.1925 0.795   0.574
#> CV:mclust   4 0.855           0.897       0.927         0.2457 0.742   0.482
#> MAD:mclust  4 1.000           0.961       0.981         0.1298 0.863   0.641
#> ATC:mclust  4 0.912           0.889       0.942         0.0970 0.947   0.837
#> SD:kmeans   4 0.664           0.664       0.809         0.1709 0.944   0.867
#> CV:kmeans   4 0.621           0.622       0.759         0.1738 0.683   0.452
#> MAD:kmeans  4 0.659           0.690       0.766         0.1295 0.932   0.809
#> ATC:kmeans  4 0.774           0.766       0.842         0.1428 0.959   0.889
#> SD:pam      4 1.000           0.985       0.995         0.1370 0.942   0.865
#> CV:pam      4 0.675           0.748       0.888         0.1824 0.891   0.771
#> MAD:pam     4 1.000           0.975       0.992         0.0811 0.915   0.783
#> ATC:pam     4 1.000           0.989       0.990         0.0997 0.947   0.879
#> SD:hclust   4 0.595           0.856       0.897         0.2667 0.881   0.771
#> CV:hclust   4 0.752           0.810       0.869         0.3843 0.765   0.546
#> MAD:hclust  4 0.807           0.932       0.924         0.1559 0.897   0.731
#> ATC:hclust  4 0.793           0.865       0.914         0.2029 0.841   0.683
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.825           0.832       0.905         0.0745 0.819   0.518
#> CV:NMF      5 0.912           0.908       0.944         0.0909 0.846   0.561
#> MAD:NMF     5 0.896           0.919       0.944         0.0603 0.868   0.609
#> ATC:NMF     5 0.836           0.902       0.906         0.0881 0.866   0.625
#> SD:skmeans  5 0.895           0.936       0.932         0.0424 0.967   0.872
#> CV:skmeans  5 0.933           0.918       0.930         0.0398 0.965   0.866
#> MAD:skmeans 5 0.886           0.842       0.887         0.0477 0.933   0.763
#> ATC:skmeans 5 1.000           0.970       0.983         0.0504 0.991   0.968
#> SD:mclust   5 0.996           0.971       0.985         0.0809 0.899   0.690
#> CV:mclust   5 1.000           0.999       0.999         0.0705 0.949   0.824
#> MAD:mclust  5 1.000           0.979       0.984         0.0571 0.915   0.708
#> ATC:mclust  5 0.961           0.889       0.959         0.0469 0.948   0.813
#> SD:kmeans   5 0.672           0.812       0.739         0.1024 0.777   0.465
#> CV:kmeans   5 0.670           0.771       0.837         0.0924 0.891   0.662
#> MAD:kmeans  5 0.737           0.739       0.783         0.0792 0.939   0.806
#> ATC:kmeans  5 0.721           0.624       0.764         0.0806 0.890   0.682
#> SD:pam      5 0.842           0.883       0.934         0.1254 0.881   0.697
#> CV:pam      5 0.744           0.802       0.855         0.1476 0.762   0.440
#> MAD:pam     5 0.990           0.957       0.983         0.0943 0.925   0.770
#> ATC:pam     5 0.837           0.861       0.909         0.2401 0.840   0.586
#> SD:hclust   5 0.757           0.852       0.922         0.1361 0.881   0.715
#> CV:hclust   5 0.887           0.897       0.942         0.1016 0.949   0.860
#> MAD:hclust  5 0.935           0.944       0.964         0.0648 0.974   0.908
#> ATC:hclust  5 0.799           0.855       0.912         0.0542 0.991   0.974
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.882           0.897       0.919         0.0573 0.942   0.781
#> CV:NMF      6 0.940           0.934       0.941         0.0396 0.972   0.883
#> MAD:NMF     6 0.836           0.806       0.872         0.0642 0.971   0.882
#> ATC:NMF     6 0.921           0.880       0.906         0.0309 1.000   1.000
#> SD:skmeans  6 0.901           0.940       0.928         0.0456 0.981   0.919
#> CV:skmeans  6 0.894           0.937       0.936         0.0405 0.981   0.919
#> MAD:skmeans 6 0.829           0.855       0.904         0.0468 0.984   0.931
#> ATC:skmeans 6 0.910           0.925       0.939         0.0351 0.974   0.910
#> SD:mclust   6 1.000           0.976       0.982         0.0431 0.971   0.881
#> CV:mclust   6 1.000           0.990       0.995         0.0374 0.971   0.881
#> MAD:mclust  6 1.000           0.988       0.993         0.0249 0.982   0.923
#> ATC:mclust  6 0.976           0.920       0.965         0.0263 0.970   0.873
#> SD:kmeans   6 0.756           0.912       0.879         0.0638 0.971   0.881
#> CV:kmeans   6 0.852           0.894       0.868         0.0614 0.964   0.854
#> MAD:kmeans  6 0.795           0.764       0.782         0.0456 0.936   0.766
#> ATC:kmeans  6 0.736           0.843       0.772         0.0462 0.869   0.520
#> SD:pam      6 0.946           0.962       0.985         0.1178 0.915   0.709
#> CV:pam      6 0.946           0.977       0.991         0.0755 0.981   0.919
#> MAD:pam     6 0.990           0.961       0.984         0.0444 0.967   0.873
#> ATC:pam     6 0.946           0.946       0.971         0.0875 0.937   0.720
#> SD:hclust   6 0.833           0.636       0.801         0.1121 0.791   0.483
#> CV:hclust   6 1.000           0.966       0.986         0.1131 0.897   0.673
#> MAD:hclust  6 0.947           0.966       0.964         0.0420 0.963   0.853
#> ATC:hclust  6 0.817           0.878       0.875         0.0771 0.888   0.677

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 time(p) k
#> SD:NMF      59  0.4110 2
#> CV:NMF      59  0.7866 2
#> MAD:NMF     55  0.9514 2
#> ATC:NMF     59  0.9587 2
#> SD:skmeans  59  0.5430 2
#> CV:skmeans  57  0.7910 2
#> MAD:skmeans 59  0.9973 2
#> ATC:skmeans 58  0.9791 2
#> SD:mclust   23      NA 2
#> CV:mclust   59  0.8004 2
#> MAD:mclust  59  0.8004 2
#> ATC:mclust  59  0.9802 2
#> SD:kmeans   59  0.4467 2
#> CV:kmeans   59  0.6547 2
#> MAD:kmeans  59  0.7950 2
#> ATC:kmeans  59  0.9587 2
#> SD:pam      59  0.9705 2
#> CV:pam      59  0.7530 2
#> MAD:pam     58  0.9821 2
#> ATC:pam     59  0.9705 2
#> SD:hclust   59  0.0997 2
#> CV:hclust   59  0.0997 2
#> MAD:hclust  59  0.9982 2
#> ATC:hclust  59  0.9786 2
test_to_known_factors(res_list, k = 3)
#>              n time(p) k
#> SD:NMF      57   0.327 3
#> CV:NMF      49   0.999 3
#> MAD:NMF     58   0.982 3
#> ATC:NMF     59   0.997 3
#> SD:skmeans  59   0.669 3
#> CV:skmeans  59   0.669 3
#> MAD:skmeans 59   0.953 3
#> ATC:skmeans 55   0.994 3
#> SD:mclust   54   0.305 3
#> CV:mclust   59   0.377 3
#> MAD:mclust  59   0.976 3
#> ATC:mclust  57   0.993 3
#> SD:kmeans   48   0.857 3
#> CV:kmeans   59   0.655 3
#> MAD:kmeans  58   0.951 3
#> ATC:kmeans  59   0.988 3
#> SD:pam      57   0.976 3
#> CV:pam      57   0.965 3
#> MAD:pam     58   0.995 3
#> ATC:pam     58   0.995 3
#> SD:hclust   55   0.341 3
#> CV:hclust   53   0.396 3
#> MAD:hclust  59   1.000 3
#> ATC:hclust  59   0.996 3
test_to_known_factors(res_list, k = 4)
#>              n time(p) k
#> SD:NMF      58   0.693 4
#> CV:NMF      59   0.678 4
#> MAD:NMF     56   0.650 4
#> ATC:NMF     45   0.989 4
#> SD:skmeans  59   0.983 4
#> CV:skmeans  59   0.983 4
#> MAD:skmeans 59   1.000 4
#> ATC:skmeans 59   0.999 4
#> SD:mclust   57   0.611 4
#> CV:mclust   55   0.643 4
#> MAD:mclust  58   1.000 4
#> ATC:mclust  59   0.979 4
#> SD:kmeans   48   0.661 4
#> CV:kmeans   46   0.999 4
#> MAD:kmeans  46   0.985 4
#> ATC:kmeans  52   1.000 4
#> SD:pam      59   0.629 4
#> CV:pam      50   0.821 4
#> MAD:pam     58   0.998 4
#> ATC:pam     59   0.999 4
#> SD:hclust   55   0.535 4
#> CV:hclust   53   0.585 4
#> MAD:hclust  59   1.000 4
#> ATC:hclust  52   0.990 4
test_to_known_factors(res_list, k = 5)
#>              n time(p) k
#> SD:NMF      54   0.831 5
#> CV:NMF      58   0.870 5
#> MAD:NMF     58   0.631 5
#> ATC:NMF     58   1.000 5
#> SD:skmeans  59   0.992 5
#> CV:skmeans  58   0.987 5
#> MAD:skmeans 56   1.000 5
#> ATC:skmeans 59   0.987 5
#> SD:mclust   59   0.856 5
#> CV:mclust   59   0.856 5
#> MAD:mclust  59   0.999 5
#> ATC:mclust  54   0.999 5
#> SD:kmeans   58   0.872 5
#> CV:kmeans   44   0.656 5
#> MAD:kmeans  55   1.000 5
#> ATC:kmeans  51   1.000 5
#> SD:pam      56   0.741 5
#> CV:pam      53   1.000 5
#> MAD:pam     58   0.998 5
#> ATC:pam     58   0.974 5
#> SD:hclust   53   0.817 5
#> CV:hclust   59   0.780 5
#> MAD:hclust  59   0.877 5
#> ATC:hclust  56   0.989 5
test_to_known_factors(res_list, k = 6)
#>              n time(p) k
#> SD:NMF      57   0.929 6
#> CV:NMF      59   0.945 6
#> MAD:NMF     56   0.863 6
#> ATC:NMF     56   0.999 6
#> SD:skmeans  59   0.945 6
#> CV:skmeans  58   0.935 6
#> MAD:skmeans 58   0.927 6
#> ATC:skmeans 57   0.834 6
#> SD:mclust   59   0.939 6
#> CV:mclust   59   0.939 6
#> MAD:mclust  59   0.986 6
#> ATC:mclust  57   0.908 6
#> SD:kmeans   59   0.939 6
#> CV:kmeans   59   0.939 6
#> MAD:kmeans  57   0.775 6
#> ATC:kmeans  56   0.947 6
#> SD:pam      59   0.939 6
#> CV:pam      59   0.939 6
#> MAD:pam     59   0.658 6
#> ATC:pam     59   0.966 6
#> SD:hclust   52   0.915 6
#> CV:hclust   57   0.931 6
#> MAD:hclust  59   0.965 6
#> ATC:hclust  55   0.998 6

Results for each method


SD:hclust**

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

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

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

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

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.995       0.998          0.126 0.871   0.871
#> 3 3 0.482           0.884       0.923          2.753 0.649   0.598
#> 4 4 0.595           0.856       0.897          0.267 0.881   0.771
#> 5 5 0.757           0.852       0.922          0.136 0.881   0.715
#> 6 6 0.833           0.636       0.801          0.112 0.791   0.483

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
#> GSM155448     1   0.000      1.000 1.000 0.000
#> GSM155452     1   0.000      1.000 1.000 0.000
#> GSM155455     1   0.000      1.000 1.000 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000
#> GSM155483     1   0.000      1.000 1.000 0.000
#> GSM155487     2   0.552      0.853 0.128 0.872
#> GSM155491     1   0.000      1.000 1.000 0.000
#> GSM155495     1   0.000      1.000 1.000 0.000
#> GSM155499     1   0.000      1.000 1.000 0.000
#> GSM155503     1   0.000      1.000 1.000 0.000
#> GSM155449     1   0.000      1.000 1.000 0.000
#> GSM155456     1   0.000      1.000 1.000 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000
#> GSM155484     1   0.000      1.000 1.000 0.000
#> GSM155488     1   0.000      1.000 1.000 0.000
#> GSM155492     1   0.000      1.000 1.000 0.000
#> GSM155496     1   0.000      1.000 1.000 0.000
#> GSM155500     1   0.000      1.000 1.000 0.000
#> GSM155504     1   0.000      1.000 1.000 0.000
#> GSM155450     1   0.000      1.000 1.000 0.000
#> GSM155453     1   0.000      1.000 1.000 0.000
#> GSM155457     1   0.000      1.000 1.000 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000
#> GSM155485     1   0.000      1.000 1.000 0.000
#> GSM155489     1   0.000      1.000 1.000 0.000
#> GSM155493     1   0.000      1.000 1.000 0.000
#> GSM155497     1   0.000      1.000 1.000 0.000
#> GSM155501     1   0.000      1.000 1.000 0.000
#> GSM155505     1   0.000      1.000 1.000 0.000
#> GSM155451     1   0.000      1.000 1.000 0.000
#> GSM155454     1   0.000      1.000 1.000 0.000
#> GSM155458     1   0.000      1.000 1.000 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000
#> GSM155478     2   0.000      0.957 0.000 1.000
#> GSM155482     2   0.000      0.957 0.000 1.000
#> GSM155486     1   0.000      1.000 1.000 0.000
#> GSM155490     2   0.000      0.957 0.000 1.000
#> GSM155494     1   0.000      1.000 1.000 0.000
#> GSM155498     1   0.000      1.000 1.000 0.000
#> GSM155502     1   0.000      1.000 1.000 0.000
#> GSM155506     1   0.000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM155448     2   0.362      1.000 0.136 0.864 0.000
#> GSM155452     2   0.362      1.000 0.136 0.864 0.000
#> GSM155455     1   0.608      0.244 0.612 0.388 0.000
#> GSM155459     1   0.000      0.926 1.000 0.000 0.000
#> GSM155463     1   0.000      0.926 1.000 0.000 0.000
#> GSM155467     1   0.000      0.926 1.000 0.000 0.000
#> GSM155471     1   0.000      0.926 1.000 0.000 0.000
#> GSM155475     1   0.000      0.926 1.000 0.000 0.000
#> GSM155479     1   0.000      0.926 1.000 0.000 0.000
#> GSM155483     1   0.000      0.926 1.000 0.000 0.000
#> GSM155487     3   0.375      0.768 0.120 0.008 0.872
#> GSM155491     1   0.362      0.806 0.864 0.136 0.000
#> GSM155495     1   0.000      0.926 1.000 0.000 0.000
#> GSM155499     2   0.362      1.000 0.136 0.864 0.000
#> GSM155503     2   0.362      1.000 0.136 0.864 0.000
#> GSM155449     2   0.362      1.000 0.136 0.864 0.000
#> GSM155456     1   0.608      0.244 0.612 0.388 0.000
#> GSM155460     1   0.000      0.926 1.000 0.000 0.000
#> GSM155464     1   0.000      0.926 1.000 0.000 0.000
#> GSM155468     1   0.000      0.926 1.000 0.000 0.000
#> GSM155472     1   0.000      0.926 1.000 0.000 0.000
#> GSM155476     1   0.000      0.926 1.000 0.000 0.000
#> GSM155480     1   0.000      0.926 1.000 0.000 0.000
#> GSM155484     1   0.000      0.926 1.000 0.000 0.000
#> GSM155488     1   0.000      0.926 1.000 0.000 0.000
#> GSM155492     1   0.362      0.806 0.864 0.136 0.000
#> GSM155496     1   0.000      0.926 1.000 0.000 0.000
#> GSM155500     2   0.362      1.000 0.136 0.864 0.000
#> GSM155504     2   0.362      1.000 0.136 0.864 0.000
#> GSM155450     2   0.362      1.000 0.136 0.864 0.000
#> GSM155453     2   0.362      1.000 0.136 0.864 0.000
#> GSM155457     1   0.608      0.244 0.612 0.388 0.000
#> GSM155461     1   0.000      0.926 1.000 0.000 0.000
#> GSM155465     1   0.000      0.926 1.000 0.000 0.000
#> GSM155469     1   0.000      0.926 1.000 0.000 0.000
#> GSM155473     1   0.000      0.926 1.000 0.000 0.000
#> GSM155477     1   0.000      0.926 1.000 0.000 0.000
#> GSM155481     1   0.000      0.926 1.000 0.000 0.000
#> GSM155485     1   0.000      0.926 1.000 0.000 0.000
#> GSM155489     1   0.000      0.926 1.000 0.000 0.000
#> GSM155493     1   0.362      0.806 0.864 0.136 0.000
#> GSM155497     1   0.362      0.806 0.864 0.136 0.000
#> GSM155501     2   0.362      1.000 0.136 0.864 0.000
#> GSM155505     2   0.362      1.000 0.136 0.864 0.000
#> GSM155451     2   0.362      1.000 0.136 0.864 0.000
#> GSM155454     2   0.362      1.000 0.136 0.864 0.000
#> GSM155458     1   0.608      0.244 0.612 0.388 0.000
#> GSM155462     1   0.000      0.926 1.000 0.000 0.000
#> GSM155466     1   0.000      0.926 1.000 0.000 0.000
#> GSM155470     1   0.000      0.926 1.000 0.000 0.000
#> GSM155474     1   0.000      0.926 1.000 0.000 0.000
#> GSM155478     3   0.000      0.933 0.000 0.000 1.000
#> GSM155482     3   0.000      0.933 0.000 0.000 1.000
#> GSM155486     1   0.000      0.926 1.000 0.000 0.000
#> GSM155490     3   0.000      0.933 0.000 0.000 1.000
#> GSM155494     1   0.362      0.806 0.864 0.136 0.000
#> GSM155498     1   0.362      0.806 0.864 0.136 0.000
#> GSM155502     2   0.362      1.000 0.136 0.864 0.000
#> GSM155506     2   0.362      1.000 0.136 0.864 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1   p2    p3    p4
#> GSM155448     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155452     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155455     1   0.485      0.376 0.600 0.40 0.000 0.000
#> GSM155459     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155463     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155467     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155471     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155475     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155479     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155483     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155487     4   0.298      0.863 0.000 0.12 0.008 0.872
#> GSM155491     3   0.317      1.000 0.160 0.00 0.840 0.000
#> GSM155495     1   0.369      0.662 0.792 0.00 0.208 0.000
#> GSM155499     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155503     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155449     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155456     1   0.485      0.376 0.600 0.40 0.000 0.000
#> GSM155460     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155464     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155468     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155472     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155476     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155480     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155484     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155488     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155492     3   0.317      1.000 0.160 0.00 0.840 0.000
#> GSM155496     1   0.369      0.662 0.792 0.00 0.208 0.000
#> GSM155500     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155504     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155450     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155453     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155457     1   0.485      0.376 0.600 0.40 0.000 0.000
#> GSM155461     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155465     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155469     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155473     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155477     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155481     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155485     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155489     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155493     3   0.317      1.000 0.160 0.00 0.840 0.000
#> GSM155497     3   0.317      1.000 0.160 0.00 0.840 0.000
#> GSM155501     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155505     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155451     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155454     2   0.265      0.801 0.120 0.88 0.000 0.000
#> GSM155458     1   0.485      0.376 0.600 0.40 0.000 0.000
#> GSM155462     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155466     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155470     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155474     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155478     4   0.000      0.955 0.000 0.00 0.000 1.000
#> GSM155482     4   0.000      0.955 0.000 0.00 0.000 1.000
#> GSM155486     1   0.000      0.922 1.000 0.00 0.000 0.000
#> GSM155490     4   0.000      0.955 0.000 0.00 0.000 1.000
#> GSM155494     3   0.317      1.000 0.160 0.00 0.840 0.000
#> GSM155498     3   0.317      1.000 0.160 0.00 0.840 0.000
#> GSM155502     2   0.317      0.819 0.000 0.84 0.160 0.000
#> GSM155506     2   0.317      0.819 0.000 0.84 0.160 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
#> GSM155448     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155452     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155455     4   0.430      0.345 0.484 0.000 0.000 0.516 0.000
#> GSM155459     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155483     1   0.242      0.849 0.868 0.000 0.000 0.132 0.000
#> GSM155487     5   0.238      0.854 0.000 0.128 0.000 0.000 0.872
#> GSM155491     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155495     1   0.569      0.443 0.580 0.000 0.316 0.104 0.000
#> GSM155499     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155503     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155449     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155456     4   0.430      0.345 0.484 0.000 0.000 0.516 0.000
#> GSM155460     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155484     1   0.242      0.849 0.868 0.000 0.000 0.132 0.000
#> GSM155488     1   0.242      0.849 0.868 0.000 0.000 0.132 0.000
#> GSM155492     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155496     1   0.569      0.443 0.580 0.000 0.316 0.104 0.000
#> GSM155500     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155450     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155453     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155457     4   0.430      0.345 0.484 0.000 0.000 0.516 0.000
#> GSM155461     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155485     1   0.242      0.849 0.868 0.000 0.000 0.132 0.000
#> GSM155489     1   0.242      0.849 0.868 0.000 0.000 0.132 0.000
#> GSM155493     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155505     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155451     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155454     4   0.242      0.655 0.000 0.132 0.000 0.868 0.000
#> GSM155458     4   0.430      0.345 0.484 0.000 0.000 0.516 0.000
#> GSM155462     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.936 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5   0.000      0.953 0.000 0.000 0.000 0.000 1.000
#> GSM155482     5   0.000      0.953 0.000 0.000 0.000 0.000 1.000
#> GSM155486     1   0.242      0.849 0.868 0.000 0.000 0.132 0.000
#> GSM155490     5   0.000      0.953 0.000 0.000 0.000 0.000 1.000
#> GSM155494     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155506     2   0.000      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
#> GSM155448     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155452     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155455     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155459     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155463     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155467     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155471     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155475     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155479     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155483     5   0.282      0.884 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM155487     6   0.452      0.807 0.000 0.128 0.000 0.000 0.168 0.704
#> GSM155491     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     5   0.472      0.554 0.068 0.000 0.316 0.000 0.616 0.000
#> GSM155499     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155503     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155449     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155456     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155460     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155464     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155468     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155472     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155476     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155480     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155484     5   0.282      0.884 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM155488     5   0.282      0.884 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM155492     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155496     5   0.472      0.554 0.068 0.000 0.316 0.000 0.616 0.000
#> GSM155500     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155504     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155450     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155453     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155457     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155461     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155465     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155469     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155473     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155477     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155481     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155485     5   0.282      0.884 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM155489     5   0.282      0.884 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM155493     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155497     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155451     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155454     1   0.459     -0.329 0.484 0.000 0.000 0.480 0.036 0.000
#> GSM155458     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155462     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155466     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155470     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155474     1   0.387      0.544 0.516 0.000 0.000 0.484 0.000 0.000
#> GSM155478     6   0.000      0.895 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155482     6   0.000      0.895 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155486     5   0.282      0.884 0.204 0.000 0.000 0.000 0.796 0.000
#> GSM155490     6   0.253      0.878 0.000 0.000 0.000 0.000 0.168 0.832
#> GSM155494     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2   0.000      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-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 time(p) k
#> SD:hclust 59  0.0997 2
#> SD:hclust 55  0.3414 3
#> SD:hclust 55  0.5353 4
#> SD:hclust 53  0.8168 5
#> SD:hclust 52  0.9150 6

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


SD:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.380           0.938       0.901         0.3887 0.544   0.544
#> 3 3 0.657           0.752       0.837         0.4512 0.839   0.714
#> 4 4 0.664           0.664       0.809         0.1709 0.944   0.867
#> 5 5 0.672           0.812       0.739         0.1024 0.777   0.465
#> 6 6 0.756           0.912       0.879         0.0638 0.971   0.881

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

suggest_best_k(res)
#> [1] 5

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM155448     2  0.8267      0.963 0.260 0.740
#> GSM155452     2  0.8267      0.963 0.260 0.740
#> GSM155455     2  0.8608      0.933 0.284 0.716
#> GSM155459     1  0.0000      0.959 1.000 0.000
#> GSM155463     1  0.0000      0.959 1.000 0.000
#> GSM155467     1  0.0000      0.959 1.000 0.000
#> GSM155471     1  0.0000      0.959 1.000 0.000
#> GSM155475     1  0.0000      0.959 1.000 0.000
#> GSM155479     1  0.0000      0.959 1.000 0.000
#> GSM155483     1  0.0672      0.956 0.992 0.008
#> GSM155487     2  0.5629      0.867 0.132 0.868
#> GSM155491     1  0.5946      0.848 0.856 0.144
#> GSM155495     1  0.5737      0.854 0.864 0.136
#> GSM155499     2  0.8267      0.963 0.260 0.740
#> GSM155503     2  0.8267      0.963 0.260 0.740
#> GSM155449     2  0.8267      0.963 0.260 0.740
#> GSM155456     1  0.0000      0.959 1.000 0.000
#> GSM155460     1  0.0000      0.959 1.000 0.000
#> GSM155464     1  0.0000      0.959 1.000 0.000
#> GSM155468     1  0.0000      0.959 1.000 0.000
#> GSM155472     1  0.0000      0.959 1.000 0.000
#> GSM155476     1  0.0000      0.959 1.000 0.000
#> GSM155480     1  0.0000      0.959 1.000 0.000
#> GSM155484     1  0.0672      0.956 0.992 0.008
#> GSM155488     1  0.0000      0.959 1.000 0.000
#> GSM155492     1  0.5946      0.848 0.856 0.144
#> GSM155496     1  0.5842      0.851 0.860 0.140
#> GSM155500     2  0.8267      0.963 0.260 0.740
#> GSM155504     2  0.8267      0.963 0.260 0.740
#> GSM155450     2  0.8267      0.963 0.260 0.740
#> GSM155453     2  0.8267      0.963 0.260 0.740
#> GSM155457     1  0.0000      0.959 1.000 0.000
#> GSM155461     1  0.0000      0.959 1.000 0.000
#> GSM155465     1  0.0000      0.959 1.000 0.000
#> GSM155469     1  0.0000      0.959 1.000 0.000
#> GSM155473     1  0.0000      0.959 1.000 0.000
#> GSM155477     1  0.0000      0.959 1.000 0.000
#> GSM155481     1  0.0000      0.959 1.000 0.000
#> GSM155485     1  0.0672      0.956 0.992 0.008
#> GSM155489     1  0.0672      0.956 0.992 0.008
#> GSM155493     1  0.5946      0.848 0.856 0.144
#> GSM155497     1  0.5946      0.848 0.856 0.144
#> GSM155501     2  0.8267      0.963 0.260 0.740
#> GSM155505     2  0.8267      0.963 0.260 0.740
#> GSM155451     2  0.8267      0.963 0.260 0.740
#> GSM155454     2  0.8267      0.963 0.260 0.740
#> GSM155458     1  0.0000      0.959 1.000 0.000
#> GSM155462     1  0.0000      0.959 1.000 0.000
#> GSM155466     1  0.0000      0.959 1.000 0.000
#> GSM155470     1  0.0000      0.959 1.000 0.000
#> GSM155474     1  0.0000      0.959 1.000 0.000
#> GSM155478     2  0.5629      0.867 0.132 0.868
#> GSM155482     2  0.5629      0.867 0.132 0.868
#> GSM155486     1  0.0672      0.956 0.992 0.008
#> GSM155490     2  0.5629      0.867 0.132 0.868
#> GSM155494     1  0.5946      0.848 0.856 0.144
#> GSM155498     1  0.5946      0.848 0.856 0.144
#> GSM155502     2  0.8267      0.963 0.260 0.740
#> GSM155506     2  0.8267      0.963 0.260 0.740

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM155448     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155452     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155455     1   0.951     0.0256 0.484 0.296 0.220
#> GSM155459     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155463     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155467     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155471     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155475     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155479     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155483     1   0.435     0.4758 0.816 0.000 0.184
#> GSM155487     2   0.546     0.7086 0.000 0.712 0.288
#> GSM155491     3   0.630     0.9938 0.480 0.000 0.520
#> GSM155495     1   0.543    -0.0734 0.716 0.000 0.284
#> GSM155499     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155503     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155449     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155456     1   0.475     0.4785 0.784 0.000 0.216
#> GSM155460     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155464     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155468     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155472     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155476     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155480     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155484     1   0.435     0.4758 0.816 0.000 0.184
#> GSM155488     1   0.540     0.4433 0.792 0.028 0.180
#> GSM155492     3   0.630     0.9938 0.480 0.000 0.520
#> GSM155496     3   0.631     0.9616 0.496 0.000 0.504
#> GSM155500     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155504     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155450     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155453     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155457     1   0.475     0.4785 0.784 0.000 0.216
#> GSM155461     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155465     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155469     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155473     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155477     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155481     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155485     1   0.429     0.4867 0.820 0.000 0.180
#> GSM155489     1   0.435     0.4758 0.816 0.000 0.184
#> GSM155493     3   0.630     0.9938 0.480 0.000 0.520
#> GSM155497     3   0.630     0.9938 0.480 0.000 0.520
#> GSM155501     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155505     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155451     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155454     2   0.601     0.8262 0.032 0.748 0.220
#> GSM155458     1   0.826     0.2419 0.632 0.152 0.216
#> GSM155462     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155466     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155470     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155474     1   0.000     0.8179 1.000 0.000 0.000
#> GSM155478     2   0.568     0.6949 0.000 0.684 0.316
#> GSM155482     2   0.568     0.6949 0.000 0.684 0.316
#> GSM155486     1   0.435     0.4758 0.816 0.000 0.184
#> GSM155490     2   0.562     0.6941 0.000 0.692 0.308
#> GSM155494     3   0.630     0.9938 0.480 0.000 0.520
#> GSM155498     3   0.630     0.9938 0.480 0.000 0.520
#> GSM155502     2   0.129     0.8608 0.032 0.968 0.000
#> GSM155506     2   0.129     0.8608 0.032 0.968 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155452     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155455     4  0.8328     -0.243 0.264 0.296 0.020 0.420
#> GSM155459     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155463     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155467     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155475     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155479     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155483     1  0.7524      0.268 0.552 0.012 0.240 0.196
#> GSM155487     4  0.7419      0.693 0.000 0.396 0.168 0.436
#> GSM155491     3  0.3764      0.995 0.216 0.000 0.784 0.000
#> GSM155495     1  0.6882      0.156 0.548 0.000 0.328 0.124
#> GSM155499     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155503     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155449     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155456     1  0.5487      0.336 0.580 0.000 0.020 0.400
#> GSM155460     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155464     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155468     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155484     1  0.7524      0.268 0.552 0.012 0.240 0.196
#> GSM155488     1  0.8921      0.153 0.476 0.096 0.232 0.196
#> GSM155492     3  0.3764      0.995 0.216 0.000 0.784 0.000
#> GSM155496     3  0.3610      0.974 0.200 0.000 0.800 0.000
#> GSM155500     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155504     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155450     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155453     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155457     1  0.5508      0.324 0.572 0.000 0.020 0.408
#> GSM155461     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155465     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155469     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155477     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155485     1  0.7524      0.268 0.552 0.012 0.240 0.196
#> GSM155489     1  0.7524      0.268 0.552 0.012 0.240 0.196
#> GSM155493     3  0.3764      0.995 0.216 0.000 0.784 0.000
#> GSM155497     3  0.3945      0.994 0.216 0.000 0.780 0.004
#> GSM155501     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155505     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155451     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155454     2  0.4888      0.623 0.000 0.588 0.000 0.412
#> GSM155458     1  0.5928      0.300 0.560 0.012 0.020 0.408
#> GSM155462     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155466     1  0.0707      0.801 0.980 0.000 0.000 0.020
#> GSM155470     1  0.0000      0.805 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0188      0.804 0.996 0.000 0.000 0.004
#> GSM155478     4  0.7770      0.699 0.012 0.376 0.164 0.448
#> GSM155482     4  0.7770      0.699 0.012 0.376 0.164 0.448
#> GSM155486     1  0.7524      0.268 0.552 0.012 0.240 0.196
#> GSM155490     4  0.7419      0.693 0.000 0.396 0.168 0.436
#> GSM155494     3  0.3764      0.995 0.216 0.000 0.784 0.000
#> GSM155498     3  0.3945      0.994 0.216 0.000 0.780 0.004
#> GSM155502     2  0.0000      0.635 0.000 1.000 0.000 0.000
#> GSM155506     2  0.0000      0.635 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
#> GSM155448     4  0.4165      0.736 0.000 0.320 0.008 0.672 0.000
#> GSM155452     4  0.4165      0.736 0.000 0.320 0.008 0.672 0.000
#> GSM155455     4  0.7015      0.641 0.152 0.112 0.052 0.632 0.052
#> GSM155459     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155463     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155467     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155471     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155479     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155483     3  0.5350      0.533 0.292 0.024 0.644 0.000 0.040
#> GSM155487     5  0.3928      0.976 0.000 0.296 0.000 0.004 0.700
#> GSM155491     3  0.7908      0.544 0.120 0.000 0.452 0.224 0.204
#> GSM155495     3  0.3814      0.539 0.276 0.000 0.720 0.000 0.004
#> GSM155499     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155449     4  0.4165      0.736 0.000 0.320 0.008 0.672 0.000
#> GSM155456     4  0.5980      0.547 0.280 0.000 0.052 0.616 0.052
#> GSM155460     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155464     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155468     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155476     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155480     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155484     3  0.5350      0.533 0.292 0.024 0.644 0.000 0.040
#> GSM155488     3  0.6178      0.456 0.244 0.096 0.620 0.000 0.040
#> GSM155492     3  0.7908      0.544 0.120 0.000 0.452 0.224 0.204
#> GSM155496     3  0.7806      0.537 0.108 0.000 0.464 0.220 0.208
#> GSM155500     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155450     4  0.3895      0.739 0.000 0.320 0.000 0.680 0.000
#> GSM155453     4  0.3895      0.739 0.000 0.320 0.000 0.680 0.000
#> GSM155457     4  0.5918      0.561 0.268 0.000 0.052 0.628 0.052
#> GSM155461     1  0.1934      0.946 0.932 0.000 0.008 0.020 0.040
#> GSM155465     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155469     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155481     1  0.0162      0.967 0.996 0.000 0.000 0.004 0.000
#> GSM155485     3  0.5350      0.533 0.292 0.024 0.644 0.000 0.040
#> GSM155489     3  0.5350      0.533 0.292 0.024 0.644 0.000 0.040
#> GSM155493     3  0.7908      0.544 0.120 0.000 0.452 0.224 0.204
#> GSM155497     3  0.7925      0.543 0.120 0.000 0.448 0.228 0.204
#> GSM155501     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155451     4  0.3895      0.739 0.000 0.320 0.000 0.680 0.000
#> GSM155454     4  0.3895      0.739 0.000 0.320 0.000 0.680 0.000
#> GSM155458     4  0.5918      0.561 0.268 0.000 0.052 0.628 0.052
#> GSM155462     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155466     1  0.2027      0.944 0.928 0.000 0.008 0.024 0.040
#> GSM155470     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.968 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5  0.4865      0.976 0.004 0.284 0.008 0.028 0.676
#> GSM155482     5  0.4865      0.976 0.004 0.284 0.008 0.028 0.676
#> GSM155486     3  0.5350      0.533 0.292 0.024 0.644 0.000 0.040
#> GSM155490     5  0.3928      0.976 0.000 0.296 0.000 0.004 0.700
#> GSM155494     3  0.7908      0.544 0.120 0.000 0.452 0.224 0.204
#> GSM155498     3  0.7925      0.543 0.120 0.000 0.448 0.228 0.204
#> GSM155502     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155506     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
#> GSM155448     4  0.3946      0.786 0.000 0.228 0.004 0.736 0.028 0.004
#> GSM155452     4  0.3946      0.786 0.000 0.228 0.004 0.736 0.028 0.004
#> GSM155455     4  0.5205      0.660 0.060 0.020 0.016 0.732 0.136 0.036
#> GSM155459     1  0.2919      0.905 0.872 0.000 0.000 0.044 0.044 0.040
#> GSM155463     1  0.2985      0.905 0.868 0.000 0.000 0.044 0.048 0.040
#> GSM155467     1  0.0000      0.939 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0405      0.939 0.988 0.000 0.000 0.008 0.004 0.000
#> GSM155475     1  0.0779      0.935 0.976 0.000 0.000 0.008 0.008 0.008
#> GSM155479     1  0.0881      0.933 0.972 0.000 0.000 0.008 0.012 0.008
#> GSM155483     5  0.4469      0.974 0.128 0.012 0.124 0.000 0.736 0.000
#> GSM155487     6  0.4100      0.954 0.000 0.092 0.020 0.028 0.056 0.804
#> GSM155491     3  0.1007      0.988 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155495     5  0.4822      0.933 0.120 0.000 0.156 0.012 0.708 0.004
#> GSM155499     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155503     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155449     4  0.3946      0.786 0.000 0.228 0.004 0.736 0.028 0.004
#> GSM155456     4  0.5159      0.633 0.088 0.000 0.016 0.712 0.148 0.036
#> GSM155460     1  0.2919      0.905 0.872 0.000 0.000 0.044 0.044 0.040
#> GSM155464     1  0.2985      0.905 0.868 0.000 0.000 0.044 0.048 0.040
#> GSM155468     1  0.0260      0.939 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM155472     1  0.0984      0.936 0.968 0.000 0.000 0.008 0.012 0.012
#> GSM155476     1  0.0881      0.934 0.972 0.000 0.000 0.008 0.012 0.008
#> GSM155480     1  0.0976      0.933 0.968 0.000 0.000 0.008 0.016 0.008
#> GSM155484     5  0.4469      0.974 0.128 0.012 0.124 0.000 0.736 0.000
#> GSM155488     5  0.4698      0.889 0.128 0.080 0.052 0.000 0.740 0.000
#> GSM155492     3  0.1007      0.988 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155496     3  0.1842      0.971 0.036 0.000 0.932 0.012 0.008 0.012
#> GSM155500     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155504     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155450     4  0.2996      0.795 0.000 0.228 0.000 0.772 0.000 0.000
#> GSM155453     4  0.2996      0.795 0.000 0.228 0.000 0.772 0.000 0.000
#> GSM155457     4  0.5063      0.641 0.080 0.000 0.016 0.720 0.148 0.036
#> GSM155461     1  0.2851      0.905 0.876 0.000 0.000 0.040 0.044 0.040
#> GSM155465     1  0.2985      0.905 0.868 0.000 0.000 0.044 0.048 0.040
#> GSM155469     1  0.0405      0.939 0.988 0.000 0.000 0.004 0.008 0.000
#> GSM155473     1  0.0405      0.939 0.988 0.000 0.000 0.008 0.004 0.000
#> GSM155477     1  0.0779      0.935 0.976 0.000 0.000 0.008 0.008 0.008
#> GSM155481     1  0.0881      0.933 0.972 0.000 0.000 0.008 0.012 0.008
#> GSM155485     5  0.4469      0.974 0.128 0.012 0.124 0.000 0.736 0.000
#> GSM155489     5  0.4469      0.974 0.128 0.012 0.124 0.000 0.736 0.000
#> GSM155493     3  0.1007      0.988 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155497     3  0.1862      0.980 0.044 0.000 0.928 0.008 0.004 0.016
#> GSM155501     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155505     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155451     4  0.2996      0.795 0.000 0.228 0.000 0.772 0.000 0.000
#> GSM155454     4  0.2996      0.795 0.000 0.228 0.000 0.772 0.000 0.000
#> GSM155458     4  0.5027      0.643 0.080 0.000 0.016 0.724 0.144 0.036
#> GSM155462     1  0.2919      0.905 0.872 0.000 0.000 0.044 0.044 0.040
#> GSM155466     1  0.2985      0.905 0.868 0.000 0.000 0.044 0.048 0.040
#> GSM155470     1  0.0405      0.939 0.988 0.000 0.000 0.004 0.008 0.000
#> GSM155474     1  0.0405      0.939 0.988 0.000 0.000 0.008 0.004 0.000
#> GSM155478     6  0.2269      0.955 0.012 0.080 0.000 0.000 0.012 0.896
#> GSM155482     6  0.2269      0.955 0.012 0.080 0.000 0.000 0.012 0.896
#> GSM155486     5  0.4469      0.974 0.128 0.012 0.124 0.000 0.736 0.000
#> GSM155490     6  0.4120      0.954 0.000 0.092 0.024 0.028 0.052 0.804
#> GSM155494     3  0.1007      0.988 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155498     3  0.1862      0.980 0.044 0.000 0.928 0.008 0.004 0.016
#> GSM155502     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM155506     2  0.0146      0.996 0.000 0.996 0.000 0.000 0.004 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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 time(p) k
#> SD:kmeans 59   0.447 2
#> SD:kmeans 48   0.857 3
#> SD:kmeans 48   0.661 4
#> SD:kmeans 58   0.872 5
#> SD:kmeans 59   0.939 6

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


SD:skmeans*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-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           1.000       1.000         0.4844 0.516   0.516
#> 3 3 1.000           0.997       0.997         0.3683 0.779   0.589
#> 4 4 0.906           0.942       0.949         0.1061 0.886   0.679
#> 5 5 0.895           0.936       0.932         0.0424 0.967   0.872
#> 6 6 0.901           0.940       0.928         0.0456 0.981   0.919

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM155448     2       0          1  0  1
#> GSM155452     2       0          1  0  1
#> GSM155455     2       0          1  0  1
#> GSM155459     1       0          1  1  0
#> GSM155463     1       0          1  1  0
#> GSM155467     1       0          1  1  0
#> GSM155471     1       0          1  1  0
#> GSM155475     1       0          1  1  0
#> GSM155479     1       0          1  1  0
#> GSM155483     1       0          1  1  0
#> GSM155487     2       0          1  0  1
#> GSM155491     1       0          1  1  0
#> GSM155495     1       0          1  1  0
#> GSM155499     2       0          1  0  1
#> GSM155503     2       0          1  0  1
#> GSM155449     2       0          1  0  1
#> GSM155456     1       0          1  1  0
#> GSM155460     1       0          1  1  0
#> GSM155464     1       0          1  1  0
#> GSM155468     1       0          1  1  0
#> GSM155472     1       0          1  1  0
#> GSM155476     1       0          1  1  0
#> GSM155480     1       0          1  1  0
#> GSM155484     1       0          1  1  0
#> GSM155488     2       0          1  0  1
#> GSM155492     1       0          1  1  0
#> GSM155496     1       0          1  1  0
#> GSM155500     2       0          1  0  1
#> GSM155504     2       0          1  0  1
#> GSM155450     2       0          1  0  1
#> GSM155453     2       0          1  0  1
#> GSM155457     2       0          1  0  1
#> GSM155461     1       0          1  1  0
#> GSM155465     1       0          1  1  0
#> GSM155469     1       0          1  1  0
#> GSM155473     1       0          1  1  0
#> GSM155477     1       0          1  1  0
#> GSM155481     1       0          1  1  0
#> GSM155485     1       0          1  1  0
#> GSM155489     1       0          1  1  0
#> GSM155493     1       0          1  1  0
#> GSM155497     1       0          1  1  0
#> GSM155501     2       0          1  0  1
#> GSM155505     2       0          1  0  1
#> GSM155451     2       0          1  0  1
#> GSM155454     2       0          1  0  1
#> GSM155458     2       0          1  0  1
#> GSM155462     1       0          1  1  0
#> GSM155466     1       0          1  1  0
#> GSM155470     1       0          1  1  0
#> GSM155474     1       0          1  1  0
#> GSM155478     2       0          1  0  1
#> GSM155482     2       0          1  0  1
#> GSM155486     1       0          1  1  0
#> GSM155490     2       0          1  0  1
#> GSM155494     1       0          1  1  0
#> GSM155498     1       0          1  1  0
#> GSM155502     2       0          1  0  1
#> GSM155506     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
#> GSM155448     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155452     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155455     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155459     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155483     3  0.0000      0.994 0.000 0.000 1.000
#> GSM155487     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155491     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155495     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155499     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155503     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155449     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155456     1  0.0424      0.992 0.992 0.008 0.000
#> GSM155460     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155472     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155476     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155484     3  0.0000      0.994 0.000 0.000 1.000
#> GSM155488     3  0.0000      0.994 0.000 0.000 1.000
#> GSM155492     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155496     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155500     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155504     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155450     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155453     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155457     1  0.0592      0.988 0.988 0.012 0.000
#> GSM155461     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155485     3  0.0000      0.994 0.000 0.000 1.000
#> GSM155489     3  0.0000      0.994 0.000 0.000 1.000
#> GSM155493     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155497     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155501     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155505     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155451     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155454     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155458     2  0.0000      0.996 0.000 1.000 0.000
#> GSM155462     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.999 1.000 0.000 0.000
#> GSM155478     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155482     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155486     3  0.0000      0.994 0.000 0.000 1.000
#> GSM155490     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155494     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155498     3  0.0424      0.996 0.008 0.000 0.992
#> GSM155502     2  0.0424      0.997 0.000 0.992 0.008
#> GSM155506     2  0.0424      0.997 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
#> GSM155448     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155452     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155455     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155459     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155483     3   0.309      0.933 0.000 0.052 0.888 0.060
#> GSM155487     2   0.000      0.855 0.000 1.000 0.000 0.000
#> GSM155491     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155495     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155499     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155503     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155449     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155456     4   0.380      0.676 0.220 0.000 0.000 0.780
#> GSM155460     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155472     1   0.139      0.954 0.952 0.048 0.000 0.000
#> GSM155476     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155484     3   0.309      0.933 0.000 0.052 0.888 0.060
#> GSM155488     2   0.529      0.625 0.000 0.724 0.216 0.060
#> GSM155492     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155496     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155500     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155504     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155450     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155453     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155457     4   0.215      0.849 0.088 0.000 0.000 0.912
#> GSM155461     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155485     3   0.309      0.933 0.000 0.052 0.888 0.060
#> GSM155489     3   0.309      0.933 0.000 0.052 0.888 0.060
#> GSM155493     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155497     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155501     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155505     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155451     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155454     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155458     4   0.164      0.950 0.000 0.060 0.000 0.940
#> GSM155462     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155478     2   0.000      0.855 0.000 1.000 0.000 0.000
#> GSM155482     2   0.000      0.855 0.000 1.000 0.000 0.000
#> GSM155486     3   0.309      0.933 0.000 0.052 0.888 0.060
#> GSM155490     2   0.000      0.855 0.000 1.000 0.000 0.000
#> GSM155494     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155498     3   0.000      0.960 0.000 0.000 1.000 0.000
#> GSM155502     2   0.317      0.904 0.000 0.840 0.000 0.160
#> GSM155506     2   0.317      0.904 0.000 0.840 0.000 0.160

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM155448     4  0.0324      0.963 0.000 0.004 0.000 0.992 0.004
#> GSM155452     4  0.0000      0.968 0.000 0.000 0.000 1.000 0.000
#> GSM155455     4  0.0609      0.961 0.000 0.000 0.000 0.980 0.020
#> GSM155459     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155463     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155467     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155479     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155483     5  0.3480      0.923 0.000 0.000 0.248 0.000 0.752
#> GSM155487     2  0.0000      0.710 0.000 1.000 0.000 0.000 0.000
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155495     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155499     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155503     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155449     4  0.0324      0.963 0.000 0.004 0.000 0.992 0.004
#> GSM155456     4  0.2824      0.807 0.116 0.000 0.000 0.864 0.020
#> GSM155460     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155464     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155468     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.1952      0.912 0.912 0.084 0.000 0.000 0.004
#> GSM155476     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155480     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155484     5  0.3480      0.923 0.000 0.000 0.248 0.000 0.752
#> GSM155488     5  0.1012      0.645 0.000 0.012 0.020 0.000 0.968
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155500     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155504     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155450     4  0.0000      0.968 0.000 0.000 0.000 1.000 0.000
#> GSM155453     4  0.0000      0.968 0.000 0.000 0.000 1.000 0.000
#> GSM155457     4  0.1568      0.925 0.036 0.000 0.000 0.944 0.020
#> GSM155461     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155465     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155469     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155481     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155485     5  0.3480      0.923 0.000 0.000 0.248 0.000 0.752
#> GSM155489     5  0.3480      0.923 0.000 0.000 0.248 0.000 0.752
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155505     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155451     4  0.0000      0.968 0.000 0.000 0.000 1.000 0.000
#> GSM155454     4  0.0000      0.968 0.000 0.000 0.000 1.000 0.000
#> GSM155458     4  0.0609      0.961 0.000 0.000 0.000 0.980 0.020
#> GSM155462     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155466     1  0.0162      0.993 0.996 0.000 0.000 0.000 0.004
#> GSM155470     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155478     2  0.0162      0.708 0.000 0.996 0.000 0.000 0.004
#> GSM155482     2  0.0162      0.708 0.000 0.996 0.000 0.000 0.004
#> GSM155486     5  0.3480      0.923 0.000 0.000 0.248 0.000 0.752
#> GSM155490     2  0.0162      0.708 0.000 0.996 0.000 0.000 0.004
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244
#> GSM155506     2  0.5628      0.864 0.000 0.624 0.000 0.132 0.244

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM155448     4  0.1501      0.932 0.000 0.076 0.000 0.924 0.000 0.000
#> GSM155452     4  0.1007      0.948 0.000 0.044 0.000 0.956 0.000 0.000
#> GSM155455     4  0.1826      0.919 0.000 0.004 0.000 0.924 0.020 0.052
#> GSM155459     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155463     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155467     1  0.0260      0.906 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155471     1  0.0858      0.904 0.968 0.000 0.000 0.004 0.000 0.028
#> GSM155475     1  0.1364      0.896 0.944 0.000 0.000 0.004 0.004 0.048
#> GSM155479     1  0.1226      0.899 0.952 0.000 0.000 0.004 0.004 0.040
#> GSM155483     5  0.1285      0.985 0.000 0.004 0.052 0.000 0.944 0.000
#> GSM155487     6  0.3050      1.000 0.000 0.236 0.000 0.000 0.000 0.764
#> GSM155491     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     3  0.0547      0.979 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM155499     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155503     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155449     4  0.1501      0.932 0.000 0.076 0.000 0.924 0.000 0.000
#> GSM155456     4  0.2039      0.908 0.012 0.000 0.000 0.916 0.020 0.052
#> GSM155460     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155464     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155468     1  0.0777      0.905 0.972 0.000 0.000 0.000 0.004 0.024
#> GSM155472     1  0.3043      0.759 0.796 0.000 0.000 0.004 0.004 0.196
#> GSM155476     1  0.1226      0.899 0.952 0.000 0.000 0.004 0.004 0.040
#> GSM155480     1  0.1226      0.899 0.952 0.000 0.000 0.004 0.004 0.040
#> GSM155484     5  0.1285      0.985 0.000 0.004 0.052 0.000 0.944 0.000
#> GSM155488     5  0.1204      0.922 0.000 0.056 0.000 0.000 0.944 0.000
#> GSM155492     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155496     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155500     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155504     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155450     4  0.1007      0.948 0.000 0.044 0.000 0.956 0.000 0.000
#> GSM155453     4  0.1007      0.948 0.000 0.044 0.000 0.956 0.000 0.000
#> GSM155457     4  0.1938      0.911 0.008 0.000 0.000 0.920 0.020 0.052
#> GSM155461     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155465     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155469     1  0.0777      0.905 0.972 0.000 0.000 0.000 0.004 0.024
#> GSM155473     1  0.0858      0.904 0.968 0.000 0.000 0.004 0.000 0.028
#> GSM155477     1  0.1226      0.899 0.952 0.000 0.000 0.004 0.004 0.040
#> GSM155481     1  0.1226      0.899 0.952 0.000 0.000 0.004 0.004 0.040
#> GSM155485     5  0.1285      0.985 0.000 0.004 0.052 0.000 0.944 0.000
#> GSM155489     5  0.1285      0.985 0.000 0.004 0.052 0.000 0.944 0.000
#> GSM155493     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155497     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155505     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155451     4  0.1141      0.946 0.000 0.052 0.000 0.948 0.000 0.000
#> GSM155454     4  0.1007      0.948 0.000 0.044 0.000 0.956 0.000 0.000
#> GSM155458     4  0.1826      0.919 0.000 0.004 0.000 0.924 0.020 0.052
#> GSM155462     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155466     1  0.3333      0.867 0.820 0.012 0.000 0.000 0.032 0.136
#> GSM155470     1  0.0777      0.905 0.972 0.000 0.000 0.000 0.004 0.024
#> GSM155474     1  0.0858      0.904 0.968 0.000 0.000 0.004 0.000 0.028
#> GSM155478     6  0.3050      1.000 0.000 0.236 0.000 0.000 0.000 0.764
#> GSM155482     6  0.3050      1.000 0.000 0.236 0.000 0.000 0.000 0.764
#> GSM155486     5  0.1285      0.985 0.000 0.004 0.052 0.000 0.944 0.000
#> GSM155490     6  0.3050      1.000 0.000 0.236 0.000 0.000 0.000 0.764
#> GSM155494     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3  0.0000      0.997 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2  0.0363      1.000 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM155506     2  0.0363      1.000 0.000 0.988 0.000 0.012 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-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 time(p) k
#> SD:skmeans 59   0.543 2
#> SD:skmeans 59   0.669 3
#> SD:skmeans 59   0.983 4
#> SD:skmeans 59   0.992 5
#> SD:skmeans 59   0.945 6

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


SD:pam*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-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.997       0.999          0.432 0.569   0.569
#> 3 3 0.840           0.948       0.943          0.268 0.861   0.755
#> 4 4 1.000           0.985       0.995          0.137 0.942   0.865
#> 5 5 0.842           0.883       0.934          0.125 0.881   0.697
#> 6 6 0.946           0.962       0.985          0.118 0.915   0.709

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

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 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
#> GSM155448     2  0.0000      0.998 0.000 1.000
#> GSM155452     2  0.1843      0.971 0.028 0.972
#> GSM155455     1  0.0000      0.999 1.000 0.000
#> GSM155459     1  0.0000      0.999 1.000 0.000
#> GSM155463     1  0.0000      0.999 1.000 0.000
#> GSM155467     1  0.0000      0.999 1.000 0.000
#> GSM155471     1  0.0000      0.999 1.000 0.000
#> GSM155475     1  0.0000      0.999 1.000 0.000
#> GSM155479     1  0.0000      0.999 1.000 0.000
#> GSM155483     1  0.0000      0.999 1.000 0.000
#> GSM155487     2  0.0000      0.998 0.000 1.000
#> GSM155491     1  0.0000      0.999 1.000 0.000
#> GSM155495     1  0.0000      0.999 1.000 0.000
#> GSM155499     2  0.0000      0.998 0.000 1.000
#> GSM155503     2  0.0000      0.998 0.000 1.000
#> GSM155449     2  0.0000      0.998 0.000 1.000
#> GSM155456     1  0.0000      0.999 1.000 0.000
#> GSM155460     1  0.0000      0.999 1.000 0.000
#> GSM155464     1  0.0000      0.999 1.000 0.000
#> GSM155468     1  0.0000      0.999 1.000 0.000
#> GSM155472     1  0.0000      0.999 1.000 0.000
#> GSM155476     1  0.0000      0.999 1.000 0.000
#> GSM155480     1  0.0000      0.999 1.000 0.000
#> GSM155484     1  0.0000      0.999 1.000 0.000
#> GSM155488     2  0.0000      0.998 0.000 1.000
#> GSM155492     1  0.0000      0.999 1.000 0.000
#> GSM155496     1  0.0000      0.999 1.000 0.000
#> GSM155500     2  0.0000      0.998 0.000 1.000
#> GSM155504     2  0.0000      0.998 0.000 1.000
#> GSM155450     2  0.0000      0.998 0.000 1.000
#> GSM155453     2  0.0000      0.998 0.000 1.000
#> GSM155457     1  0.0000      0.999 1.000 0.000
#> GSM155461     1  0.0000      0.999 1.000 0.000
#> GSM155465     1  0.0000      0.999 1.000 0.000
#> GSM155469     1  0.0000      0.999 1.000 0.000
#> GSM155473     1  0.0000      0.999 1.000 0.000
#> GSM155477     1  0.0000      0.999 1.000 0.000
#> GSM155481     1  0.0000      0.999 1.000 0.000
#> GSM155485     1  0.0000      0.999 1.000 0.000
#> GSM155489     1  0.0000      0.999 1.000 0.000
#> GSM155493     1  0.0000      0.999 1.000 0.000
#> GSM155497     1  0.0000      0.999 1.000 0.000
#> GSM155501     2  0.0000      0.998 0.000 1.000
#> GSM155505     2  0.0000      0.998 0.000 1.000
#> GSM155451     2  0.0000      0.998 0.000 1.000
#> GSM155454     2  0.0000      0.998 0.000 1.000
#> GSM155458     1  0.0000      0.999 1.000 0.000
#> GSM155462     1  0.0000      0.999 1.000 0.000
#> GSM155466     1  0.0000      0.999 1.000 0.000
#> GSM155470     1  0.0000      0.999 1.000 0.000
#> GSM155474     1  0.0000      0.999 1.000 0.000
#> GSM155478     1  0.0938      0.988 0.988 0.012
#> GSM155482     1  0.2236      0.963 0.964 0.036
#> GSM155486     1  0.0000      0.999 1.000 0.000
#> GSM155490     2  0.0000      0.998 0.000 1.000
#> GSM155494     1  0.0000      0.999 1.000 0.000
#> GSM155498     1  0.0000      0.999 1.000 0.000
#> GSM155502     2  0.0000      0.998 0.000 1.000
#> GSM155506     2  0.0000      0.998 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
#> GSM155448     2   0.000      0.967 0.000 1.000 0.000
#> GSM155452     2   0.000      0.967 0.000 1.000 0.000
#> GSM155455     1   0.000      0.972 1.000 0.000 0.000
#> GSM155459     1   0.000      0.972 1.000 0.000 0.000
#> GSM155463     1   0.000      0.972 1.000 0.000 0.000
#> GSM155467     1   0.000      0.972 1.000 0.000 0.000
#> GSM155471     1   0.000      0.972 1.000 0.000 0.000
#> GSM155475     1   0.000      0.972 1.000 0.000 0.000
#> GSM155479     1   0.000      0.972 1.000 0.000 0.000
#> GSM155483     1   0.000      0.972 1.000 0.000 0.000
#> GSM155487     2   0.556      0.718 0.000 0.700 0.300
#> GSM155491     3   0.556      1.000 0.300 0.000 0.700
#> GSM155495     1   0.103      0.940 0.976 0.000 0.024
#> GSM155499     2   0.000      0.967 0.000 1.000 0.000
#> GSM155503     2   0.000      0.967 0.000 1.000 0.000
#> GSM155449     2   0.116      0.935 0.028 0.972 0.000
#> GSM155456     1   0.000      0.972 1.000 0.000 0.000
#> GSM155460     1   0.000      0.972 1.000 0.000 0.000
#> GSM155464     1   0.000      0.972 1.000 0.000 0.000
#> GSM155468     1   0.000      0.972 1.000 0.000 0.000
#> GSM155472     1   0.000      0.972 1.000 0.000 0.000
#> GSM155476     1   0.000      0.972 1.000 0.000 0.000
#> GSM155480     1   0.000      0.972 1.000 0.000 0.000
#> GSM155484     1   0.000      0.972 1.000 0.000 0.000
#> GSM155488     2   0.000      0.967 0.000 1.000 0.000
#> GSM155492     3   0.556      1.000 0.300 0.000 0.700
#> GSM155496     3   0.556      1.000 0.300 0.000 0.700
#> GSM155500     2   0.000      0.967 0.000 1.000 0.000
#> GSM155504     2   0.000      0.967 0.000 1.000 0.000
#> GSM155450     2   0.000      0.967 0.000 1.000 0.000
#> GSM155453     2   0.000      0.967 0.000 1.000 0.000
#> GSM155457     1   0.000      0.972 1.000 0.000 0.000
#> GSM155461     1   0.000      0.972 1.000 0.000 0.000
#> GSM155465     1   0.000      0.972 1.000 0.000 0.000
#> GSM155469     1   0.000      0.972 1.000 0.000 0.000
#> GSM155473     1   0.000      0.972 1.000 0.000 0.000
#> GSM155477     1   0.000      0.972 1.000 0.000 0.000
#> GSM155481     1   0.000      0.972 1.000 0.000 0.000
#> GSM155485     1   0.000      0.972 1.000 0.000 0.000
#> GSM155489     1   0.000      0.972 1.000 0.000 0.000
#> GSM155493     3   0.556      1.000 0.300 0.000 0.700
#> GSM155497     3   0.556      1.000 0.300 0.000 0.700
#> GSM155501     2   0.000      0.967 0.000 1.000 0.000
#> GSM155505     2   0.000      0.967 0.000 1.000 0.000
#> GSM155451     2   0.000      0.967 0.000 1.000 0.000
#> GSM155454     2   0.000      0.967 0.000 1.000 0.000
#> GSM155458     1   0.000      0.972 1.000 0.000 0.000
#> GSM155462     1   0.000      0.972 1.000 0.000 0.000
#> GSM155466     1   0.000      0.972 1.000 0.000 0.000
#> GSM155470     1   0.000      0.972 1.000 0.000 0.000
#> GSM155474     1   0.000      0.972 1.000 0.000 0.000
#> GSM155478     1   0.556      0.495 0.700 0.000 0.300
#> GSM155482     1   0.556      0.495 0.700 0.000 0.300
#> GSM155486     1   0.000      0.972 1.000 0.000 0.000
#> GSM155490     2   0.556      0.718 0.000 0.700 0.300
#> GSM155494     3   0.556      1.000 0.300 0.000 0.700
#> GSM155498     3   0.556      1.000 0.300 0.000 0.700
#> GSM155502     2   0.000      0.967 0.000 1.000 0.000
#> GSM155506     2   0.000      0.967 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
#> GSM155448     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155452     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155455     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155459     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155483     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155487     4  0.4222      0.626 0.000 0.272 0.000 0.728
#> GSM155491     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM155495     1  0.1118      0.961 0.964 0.000 0.036 0.000
#> GSM155499     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155449     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155456     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155460     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155484     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155488     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155492     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM155496     3  0.0336      0.985 0.008 0.000 0.992 0.000
#> GSM155500     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155450     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155453     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155457     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155461     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155485     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155489     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155493     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM155497     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM155501     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155451     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155454     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155458     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155462     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155478     4  0.0000      0.875 0.000 0.000 0.000 1.000
#> GSM155482     4  0.0000      0.875 0.000 0.000 0.000 1.000
#> GSM155486     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM155490     4  0.0000      0.875 0.000 0.000 0.000 1.000
#> GSM155494     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM155498     3  0.0000      0.997 0.000 0.000 1.000 0.000
#> GSM155502     2  0.0000      1.000 0.000 1.000 0.000 0.000
#> GSM155506     2  0.0000      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
#> GSM155448     4   0.260      0.736 0.000 0.148 0.000 0.852 0.000
#> GSM155452     4   0.260      0.736 0.000 0.148 0.000 0.852 0.000
#> GSM155455     4   0.260      0.637 0.148 0.000 0.000 0.852 0.000
#> GSM155459     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155483     1   0.260      0.854 0.852 0.000 0.000 0.148 0.000
#> GSM155487     5   0.364      0.622 0.000 0.272 0.000 0.000 0.728
#> GSM155491     3   0.000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM155495     1   0.368      0.812 0.808 0.000 0.044 0.148 0.000
#> GSM155499     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155503     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155449     4   0.260      0.736 0.000 0.148 0.000 0.852 0.000
#> GSM155456     4   0.426      0.412 0.440 0.000 0.000 0.560 0.000
#> GSM155460     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155484     1   0.260      0.854 0.852 0.000 0.000 0.148 0.000
#> GSM155488     2   0.260      0.767 0.000 0.852 0.000 0.148 0.000
#> GSM155492     3   0.000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3   0.029      0.985 0.008 0.000 0.992 0.000 0.000
#> GSM155500     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155450     4   0.260      0.736 0.000 0.148 0.000 0.852 0.000
#> GSM155453     4   0.260      0.736 0.000 0.148 0.000 0.852 0.000
#> GSM155457     4   0.426      0.412 0.440 0.000 0.000 0.560 0.000
#> GSM155461     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155485     1   0.260      0.854 0.852 0.000 0.000 0.148 0.000
#> GSM155489     1   0.260      0.854 0.852 0.000 0.000 0.148 0.000
#> GSM155493     3   0.000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3   0.000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155505     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155451     4   0.307      0.694 0.000 0.196 0.000 0.804 0.000
#> GSM155454     4   0.260      0.736 0.000 0.148 0.000 0.852 0.000
#> GSM155458     4   0.426      0.412 0.440 0.000 0.000 0.560 0.000
#> GSM155462     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.962 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5   0.000      0.899 0.000 0.000 0.000 0.000 1.000
#> GSM155482     5   0.000      0.899 0.000 0.000 0.000 0.000 1.000
#> GSM155486     1   0.260      0.854 0.852 0.000 0.000 0.148 0.000
#> GSM155490     5   0.000      0.899 0.000 0.000 0.000 0.000 1.000
#> GSM155494     3   0.000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3   0.000      0.998 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2   0.000      0.973 0.000 1.000 0.000 0.000 0.000
#> GSM155506     2   0.000      0.973 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
#> GSM155448     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155452     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155455     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155483     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155487     6   0.327      0.626 0.000 0.272 0.000 0.000 0.000 0.728
#> GSM155491     3   0.000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155499     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155503     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155449     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155456     4   0.256      0.777 0.172 0.000 0.000 0.828 0.000 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155484     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155488     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155492     3   0.000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155496     3   0.159      0.910 0.004 0.000 0.924 0.000 0.072 0.000
#> GSM155500     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155504     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155450     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155453     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155457     4   0.256      0.777 0.172 0.000 0.000 0.828 0.000 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155485     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155489     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155493     3   0.000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155497     3   0.000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155451     4   0.107      0.875 0.000 0.048 0.000 0.952 0.000 0.000
#> GSM155454     4   0.000      0.913 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM155458     4   0.256      0.777 0.172 0.000 0.000 0.828 0.000 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155478     6   0.000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155482     6   0.000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155486     5   0.000      1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155490     6   0.000      0.902 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155494     3   0.000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3   0.000      0.986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2   0.000      1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2   0.000      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-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 time(p) k
#> SD:pam 59   0.971 2
#> SD:pam 57   0.976 3
#> SD:pam 59   0.629 4
#> SD:pam 56   0.741 5
#> SD:pam 59   0.939 6

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


SD:mclust**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.364           0.375       0.756         0.3060 0.691   0.691
#> 3 3 0.658           0.786       0.880         0.9216 0.633   0.512
#> 4 4 0.855           0.838       0.908         0.1925 0.795   0.574
#> 5 5 0.996           0.971       0.985         0.0809 0.899   0.690
#> 6 6 1.000           0.976       0.982         0.0431 0.971   0.881

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

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

There is also optional best \(k\) = 5 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
#> GSM155448     1   0.978      0.218 0.588 0.412
#> GSM155452     1   0.978      0.218 0.588 0.412
#> GSM155455     1   0.966      0.251 0.608 0.392
#> GSM155459     1   0.000      0.595 1.000 0.000
#> GSM155463     1   0.000      0.595 1.000 0.000
#> GSM155467     1   0.000      0.595 1.000 0.000
#> GSM155471     1   0.000      0.595 1.000 0.000
#> GSM155475     1   0.000      0.595 1.000 0.000
#> GSM155479     1   0.000      0.595 1.000 0.000
#> GSM155483     1   0.975      0.229 0.592 0.408
#> GSM155487     2   0.000      0.447 0.000 1.000
#> GSM155491     1   0.980      0.200 0.584 0.416
#> GSM155495     1   0.975      0.229 0.592 0.408
#> GSM155499     2   1.000      0.250 0.488 0.512
#> GSM155503     2   1.000      0.239 0.492 0.508
#> GSM155449     1   0.978      0.218 0.588 0.412
#> GSM155456     1   0.644      0.504 0.836 0.164
#> GSM155460     1   0.000      0.595 1.000 0.000
#> GSM155464     1   0.000      0.595 1.000 0.000
#> GSM155468     1   0.000      0.595 1.000 0.000
#> GSM155472     1   0.653      0.401 0.832 0.168
#> GSM155476     1   0.000      0.595 1.000 0.000
#> GSM155480     1   0.000      0.595 1.000 0.000
#> GSM155484     1   0.975      0.229 0.592 0.408
#> GSM155488     1   0.975      0.229 0.592 0.408
#> GSM155492     1   0.980      0.200 0.584 0.416
#> GSM155496     1   0.990      0.141 0.560 0.440
#> GSM155500     2   1.000      0.250 0.488 0.512
#> GSM155504     2   1.000      0.239 0.492 0.508
#> GSM155450     1   0.978      0.218 0.588 0.412
#> GSM155453     1   0.978      0.218 0.588 0.412
#> GSM155457     1   0.653      0.501 0.832 0.168
#> GSM155461     1   0.000      0.595 1.000 0.000
#> GSM155465     1   0.000      0.595 1.000 0.000
#> GSM155469     1   0.000      0.595 1.000 0.000
#> GSM155473     1   0.000      0.595 1.000 0.000
#> GSM155477     1   0.000      0.595 1.000 0.000
#> GSM155481     1   0.000      0.595 1.000 0.000
#> GSM155485     1   0.975      0.229 0.592 0.408
#> GSM155489     1   0.975      0.229 0.592 0.408
#> GSM155493     1   0.980      0.200 0.584 0.416
#> GSM155497     1   0.980      0.200 0.584 0.416
#> GSM155501     1   1.000     -0.258 0.504 0.496
#> GSM155505     2   1.000      0.250 0.488 0.512
#> GSM155451     1   0.978      0.218 0.588 0.412
#> GSM155454     1   0.978      0.218 0.588 0.412
#> GSM155458     1   0.966      0.251 0.608 0.392
#> GSM155462     1   0.000      0.595 1.000 0.000
#> GSM155466     1   0.000      0.595 1.000 0.000
#> GSM155470     1   0.000      0.595 1.000 0.000
#> GSM155474     1   0.000      0.595 1.000 0.000
#> GSM155478     2   0.000      0.447 0.000 1.000
#> GSM155482     2   0.000      0.447 0.000 1.000
#> GSM155486     1   0.975      0.229 0.592 0.408
#> GSM155490     2   0.000      0.447 0.000 1.000
#> GSM155494     1   0.980      0.200 0.584 0.416
#> GSM155498     1   0.980      0.200 0.584 0.416
#> GSM155502     2   1.000      0.239 0.492 0.508
#> GSM155506     2   1.000      0.239 0.492 0.508

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM155448     1  0.9527      0.304 0.464 0.204 0.332
#> GSM155452     1  0.9014      0.494 0.560 0.208 0.232
#> GSM155455     1  0.4233      0.778 0.836 0.160 0.004
#> GSM155459     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155467     1  0.0892      0.862 0.980 0.000 0.020
#> GSM155471     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155475     1  0.1031      0.860 0.976 0.000 0.024
#> GSM155479     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155483     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155487     2  0.1289      1.000 0.000 0.968 0.032
#> GSM155491     3  0.2796      0.802 0.092 0.000 0.908
#> GSM155495     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155499     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155503     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155449     1  0.9009      0.495 0.560 0.204 0.236
#> GSM155456     1  0.4233      0.778 0.836 0.160 0.004
#> GSM155460     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155468     1  0.0892      0.862 0.980 0.000 0.020
#> GSM155472     1  0.1525      0.855 0.964 0.032 0.004
#> GSM155476     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155484     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155488     3  0.1129      0.828 0.020 0.004 0.976
#> GSM155492     3  0.1964      0.819 0.056 0.000 0.944
#> GSM155496     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155500     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155504     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155450     1  0.8907      0.507 0.568 0.248 0.184
#> GSM155453     1  0.8937      0.502 0.564 0.252 0.184
#> GSM155457     1  0.4233      0.778 0.836 0.160 0.004
#> GSM155461     1  0.1031      0.860 0.976 0.000 0.024
#> GSM155465     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155485     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155489     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155493     3  0.2625      0.806 0.084 0.000 0.916
#> GSM155497     3  0.2878      0.798 0.096 0.000 0.904
#> GSM155501     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155505     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155451     1  0.8985      0.498 0.564 0.220 0.216
#> GSM155454     1  0.8889      0.494 0.560 0.276 0.164
#> GSM155458     1  0.4233      0.778 0.836 0.160 0.004
#> GSM155462     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.868 1.000 0.000 0.000
#> GSM155478     2  0.1289      1.000 0.000 0.968 0.032
#> GSM155482     2  0.1289      1.000 0.000 0.968 0.032
#> GSM155486     3  0.1031      0.830 0.024 0.000 0.976
#> GSM155490     2  0.1289      1.000 0.000 0.968 0.032
#> GSM155494     3  0.2796      0.802 0.092 0.000 0.908
#> GSM155498     3  0.3192      0.786 0.112 0.000 0.888
#> GSM155502     3  0.5465      0.685 0.000 0.288 0.712
#> GSM155506     3  0.5465      0.685 0.000 0.288 0.712

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3   p4
#> GSM155448     2  0.4868      0.241 0.012 0.684 0.304 0.00
#> GSM155452     2  0.1284      0.615 0.012 0.964 0.024 0.00
#> GSM155455     1  0.4564      0.576 0.672 0.328 0.000 0.00
#> GSM155459     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155463     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155467     1  0.1022      0.912 0.968 0.000 0.032 0.00
#> GSM155471     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155475     1  0.1022      0.912 0.968 0.000 0.032 0.00
#> GSM155479     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155483     3  0.0000      0.947 0.000 0.000 1.000 0.00
#> GSM155487     4  0.4277      1.000 0.000 0.280 0.000 0.72
#> GSM155491     3  0.1940      0.923 0.076 0.000 0.924 0.00
#> GSM155495     3  0.0469      0.946 0.000 0.012 0.988 0.00
#> GSM155499     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155503     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155449     2  0.4844      0.247 0.012 0.688 0.300 0.00
#> GSM155456     1  0.4431      0.616 0.696 0.304 0.000 0.00
#> GSM155460     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155464     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155468     1  0.0921      0.915 0.972 0.000 0.028 0.00
#> GSM155472     1  0.3852      0.755 0.808 0.180 0.012 0.00
#> GSM155476     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155480     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155484     3  0.0469      0.946 0.000 0.012 0.988 0.00
#> GSM155488     3  0.0469      0.946 0.000 0.012 0.988 0.00
#> GSM155492     3  0.1211      0.938 0.040 0.000 0.960 0.00
#> GSM155496     3  0.0188      0.947 0.004 0.000 0.996 0.00
#> GSM155500     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155504     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155450     2  0.0469      0.633 0.012 0.988 0.000 0.00
#> GSM155453     2  0.0469      0.633 0.012 0.988 0.000 0.00
#> GSM155457     1  0.4431      0.616 0.696 0.304 0.000 0.00
#> GSM155461     1  0.1022      0.912 0.968 0.000 0.032 0.00
#> GSM155465     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155469     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155473     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155477     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155481     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155485     3  0.0000      0.947 0.000 0.000 1.000 0.00
#> GSM155489     3  0.0469      0.946 0.000 0.012 0.988 0.00
#> GSM155493     3  0.1867      0.926 0.072 0.000 0.928 0.00
#> GSM155497     3  0.1940      0.923 0.076 0.000 0.924 0.00
#> GSM155501     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155505     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155451     2  0.0469      0.633 0.012 0.988 0.000 0.00
#> GSM155454     2  0.0469      0.633 0.012 0.988 0.000 0.00
#> GSM155458     1  0.4431      0.616 0.696 0.304 0.000 0.00
#> GSM155462     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155466     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155470     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155474     1  0.0000      0.931 1.000 0.000 0.000 0.00
#> GSM155478     4  0.4277      1.000 0.000 0.280 0.000 0.72
#> GSM155482     4  0.4277      1.000 0.000 0.280 0.000 0.72
#> GSM155486     3  0.0469      0.946 0.000 0.012 0.988 0.00
#> GSM155490     4  0.4277      1.000 0.000 0.280 0.000 0.72
#> GSM155494     3  0.1940      0.923 0.076 0.000 0.924 0.00
#> GSM155498     3  0.2149      0.914 0.088 0.000 0.912 0.00
#> GSM155502     2  0.5308      0.758 0.000 0.684 0.036 0.28
#> GSM155506     2  0.5308      0.758 0.000 0.684 0.036 0.28

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM155448     4  0.1956      0.902 0.000 0.008 0.076 0.916  0
#> GSM155452     4  0.0404      0.970 0.000 0.000 0.012 0.988  0
#> GSM155455     4  0.0609      0.968 0.020 0.000 0.000 0.980  0
#> GSM155459     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155463     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155467     1  0.0703      0.967 0.976 0.000 0.024 0.000  0
#> GSM155471     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155475     1  0.0963      0.957 0.964 0.000 0.036 0.000  0
#> GSM155479     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155483     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155487     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM155491     3  0.1478      0.939 0.064 0.000 0.936 0.000  0
#> GSM155495     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155499     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155503     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155449     4  0.1082      0.955 0.000 0.008 0.028 0.964  0
#> GSM155456     4  0.0609      0.968 0.020 0.000 0.000 0.980  0
#> GSM155460     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155464     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155468     1  0.0798      0.969 0.976 0.000 0.016 0.008  0
#> GSM155472     1  0.3011      0.829 0.844 0.000 0.016 0.140  0
#> GSM155476     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155480     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155484     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155488     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155492     3  0.0703      0.958 0.024 0.000 0.976 0.000  0
#> GSM155496     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155500     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155504     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155450     4  0.0000      0.971 0.000 0.000 0.000 1.000  0
#> GSM155453     4  0.0000      0.971 0.000 0.000 0.000 1.000  0
#> GSM155457     4  0.0609      0.968 0.020 0.000 0.000 0.980  0
#> GSM155461     1  0.0963      0.957 0.964 0.000 0.036 0.000  0
#> GSM155465     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155469     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155473     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155477     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155481     1  0.1341      0.934 0.944 0.000 0.000 0.056  0
#> GSM155485     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155489     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155493     3  0.1341      0.944 0.056 0.000 0.944 0.000  0
#> GSM155497     3  0.1478      0.939 0.064 0.000 0.936 0.000  0
#> GSM155501     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155505     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155451     4  0.0404      0.970 0.000 0.000 0.012 0.988  0
#> GSM155454     4  0.0000      0.971 0.000 0.000 0.000 1.000  0
#> GSM155458     4  0.0609      0.968 0.020 0.000 0.000 0.980  0
#> GSM155462     1  0.0162      0.980 0.996 0.000 0.000 0.004  0
#> GSM155466     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155470     1  0.0000      0.982 1.000 0.000 0.000 0.000  0
#> GSM155474     1  0.0290      0.978 0.992 0.000 0.000 0.008  0
#> GSM155478     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM155482     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM155486     3  0.0000      0.964 0.000 0.000 1.000 0.000  0
#> GSM155490     5  0.0000      1.000 0.000 0.000 0.000 0.000  1
#> GSM155494     3  0.1478      0.939 0.064 0.000 0.936 0.000  0
#> GSM155498     3  0.1544      0.935 0.068 0.000 0.932 0.000  0
#> GSM155502     2  0.0000      1.000 0.000 1.000 0.000 0.000  0
#> GSM155506     2  0.0000      1.000 0.000 1.000 0.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5 p6
#> GSM155448     4  0.0146      0.985 0.000  0 0.000 0.996 0.004  0
#> GSM155452     4  0.0363      0.986 0.000  0 0.012 0.988 0.000  0
#> GSM155455     4  0.0632      0.981 0.000  0 0.024 0.976 0.000  0
#> GSM155459     1  0.0260      0.974 0.992  0 0.008 0.000 0.000  0
#> GSM155463     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155467     1  0.1556      0.929 0.920  0 0.080 0.000 0.000  0
#> GSM155471     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155475     1  0.1714      0.920 0.908  0 0.092 0.000 0.000  0
#> GSM155479     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155483     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155487     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155491     3  0.0972      0.955 0.008  0 0.964 0.000 0.028  0
#> GSM155495     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155499     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155503     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155449     4  0.0146      0.985 0.000  0 0.000 0.996 0.004  0
#> GSM155456     4  0.0632      0.981 0.000  0 0.024 0.976 0.000  0
#> GSM155460     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155464     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155468     1  0.1556      0.929 0.920  0 0.080 0.000 0.000  0
#> GSM155472     1  0.1913      0.922 0.908  0 0.080 0.012 0.000  0
#> GSM155476     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155480     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155484     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155488     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155492     3  0.1757      0.928 0.008  0 0.916 0.000 0.076  0
#> GSM155496     3  0.2762      0.797 0.000  0 0.804 0.000 0.196  0
#> GSM155500     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155504     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155450     4  0.0363      0.986 0.000  0 0.012 0.988 0.000  0
#> GSM155453     4  0.0363      0.986 0.000  0 0.012 0.988 0.000  0
#> GSM155457     4  0.0632      0.981 0.000  0 0.024 0.976 0.000  0
#> GSM155461     1  0.1714      0.920 0.908  0 0.092 0.000 0.000  0
#> GSM155465     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155469     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155473     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155477     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155481     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155485     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155489     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155493     3  0.0972      0.955 0.008  0 0.964 0.000 0.028  0
#> GSM155497     3  0.0972      0.955 0.008  0 0.964 0.000 0.028  0
#> GSM155501     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155505     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155451     4  0.0363      0.986 0.000  0 0.012 0.988 0.000  0
#> GSM155454     4  0.0363      0.986 0.000  0 0.012 0.988 0.000  0
#> GSM155458     4  0.0632      0.981 0.000  0 0.024 0.976 0.000  0
#> GSM155462     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155466     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155470     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155474     1  0.0000      0.979 1.000  0 0.000 0.000 0.000  0
#> GSM155478     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155482     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155486     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155490     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155494     3  0.0972      0.955 0.008  0 0.964 0.000 0.028  0
#> GSM155498     3  0.1257      0.945 0.020  0 0.952 0.000 0.028  0
#> GSM155502     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155506     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0

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 time(p) k
#> SD:mclust 23      NA 2
#> SD:mclust 54   0.305 3
#> SD:mclust 57   0.611 4
#> SD:mclust 59   0.856 5
#> SD:mclust 59   0.939 6

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


SD:NMF**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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.4730 0.524   0.524
#> 3 3 0.695           0.776       0.857         0.2141 0.958   0.920
#> 4 4 0.661           0.854       0.893         0.1966 0.771   0.551
#> 5 5 0.825           0.832       0.905         0.0745 0.819   0.518
#> 6 6 0.882           0.897       0.919         0.0573 0.942   0.781

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
#> GSM155448     2  0.0000      0.982 0.000 1.000
#> GSM155452     2  0.0000      0.982 0.000 1.000
#> GSM155455     2  0.0672      0.975 0.008 0.992
#> GSM155459     1  0.0000      0.999 1.000 0.000
#> GSM155463     1  0.0000      0.999 1.000 0.000
#> GSM155467     1  0.0000      0.999 1.000 0.000
#> GSM155471     1  0.0000      0.999 1.000 0.000
#> GSM155475     1  0.0000      0.999 1.000 0.000
#> GSM155479     1  0.0000      0.999 1.000 0.000
#> GSM155483     1  0.0000      0.999 1.000 0.000
#> GSM155487     2  0.0000      0.982 0.000 1.000
#> GSM155491     1  0.0000      0.999 1.000 0.000
#> GSM155495     1  0.0000      0.999 1.000 0.000
#> GSM155499     2  0.0000      0.982 0.000 1.000
#> GSM155503     2  0.0000      0.982 0.000 1.000
#> GSM155449     2  0.0000      0.982 0.000 1.000
#> GSM155456     1  0.0000      0.999 1.000 0.000
#> GSM155460     1  0.0000      0.999 1.000 0.000
#> GSM155464     1  0.0000      0.999 1.000 0.000
#> GSM155468     1  0.0000      0.999 1.000 0.000
#> GSM155472     1  0.0000      0.999 1.000 0.000
#> GSM155476     1  0.0000      0.999 1.000 0.000
#> GSM155480     1  0.0000      0.999 1.000 0.000
#> GSM155484     1  0.0000      0.999 1.000 0.000
#> GSM155488     2  0.2603      0.942 0.044 0.956
#> GSM155492     1  0.0000      0.999 1.000 0.000
#> GSM155496     1  0.0000      0.999 1.000 0.000
#> GSM155500     2  0.0000      0.982 0.000 1.000
#> GSM155504     2  0.0000      0.982 0.000 1.000
#> GSM155450     2  0.0000      0.982 0.000 1.000
#> GSM155453     2  0.0000      0.982 0.000 1.000
#> GSM155457     1  0.0376      0.995 0.996 0.004
#> GSM155461     1  0.0000      0.999 1.000 0.000
#> GSM155465     1  0.0000      0.999 1.000 0.000
#> GSM155469     1  0.0000      0.999 1.000 0.000
#> GSM155473     1  0.0000      0.999 1.000 0.000
#> GSM155477     1  0.0000      0.999 1.000 0.000
#> GSM155481     1  0.0000      0.999 1.000 0.000
#> GSM155485     1  0.0000      0.999 1.000 0.000
#> GSM155489     1  0.2236      0.962 0.964 0.036
#> GSM155493     1  0.0000      0.999 1.000 0.000
#> GSM155497     1  0.0000      0.999 1.000 0.000
#> GSM155501     2  0.0000      0.982 0.000 1.000
#> GSM155505     2  0.0000      0.982 0.000 1.000
#> GSM155451     2  0.0000      0.982 0.000 1.000
#> GSM155454     2  0.0000      0.982 0.000 1.000
#> GSM155458     2  0.9170      0.507 0.332 0.668
#> GSM155462     1  0.0000      0.999 1.000 0.000
#> GSM155466     1  0.0000      0.999 1.000 0.000
#> GSM155470     1  0.0000      0.999 1.000 0.000
#> GSM155474     1  0.0000      0.999 1.000 0.000
#> GSM155478     2  0.0000      0.982 0.000 1.000
#> GSM155482     2  0.0000      0.982 0.000 1.000
#> GSM155486     1  0.0938      0.987 0.988 0.012
#> GSM155490     2  0.0000      0.982 0.000 1.000
#> GSM155494     1  0.0000      0.999 1.000 0.000
#> GSM155498     1  0.0000      0.999 1.000 0.000
#> GSM155502     2  0.0000      0.982 0.000 1.000
#> GSM155506     2  0.0000      0.982 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
#> GSM155448     2  0.0747      0.840 0.000 0.984 0.016
#> GSM155452     2  0.1753      0.810 0.000 0.952 0.048
#> GSM155455     2  0.5926      0.282 0.000 0.644 0.356
#> GSM155459     1  0.5591      0.840 0.696 0.000 0.304
#> GSM155463     1  0.5810      0.842 0.664 0.000 0.336
#> GSM155467     1  0.5810      0.842 0.664 0.000 0.336
#> GSM155471     1  0.5810      0.842 0.664 0.000 0.336
#> GSM155475     1  0.5706      0.843 0.680 0.000 0.320
#> GSM155479     1  0.5785      0.843 0.668 0.000 0.332
#> GSM155483     1  0.0747      0.714 0.984 0.016 0.000
#> GSM155487     3  0.5926      0.853 0.000 0.356 0.644
#> GSM155491     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155495     1  0.0747      0.707 0.984 0.000 0.016
#> GSM155499     2  0.1289      0.842 0.000 0.968 0.032
#> GSM155503     2  0.1643      0.836 0.000 0.956 0.044
#> GSM155449     2  0.0747      0.840 0.000 0.984 0.016
#> GSM155456     1  0.9074      0.690 0.500 0.148 0.352
#> GSM155460     1  0.5706      0.843 0.680 0.000 0.320
#> GSM155464     1  0.5785      0.843 0.668 0.000 0.332
#> GSM155468     1  0.5882      0.839 0.652 0.000 0.348
#> GSM155472     1  0.5988      0.829 0.632 0.000 0.368
#> GSM155476     1  0.5948      0.833 0.640 0.000 0.360
#> GSM155480     1  0.5926      0.835 0.644 0.000 0.356
#> GSM155484     1  0.2982      0.668 0.920 0.056 0.024
#> GSM155488     2  0.4602      0.694 0.040 0.852 0.108
#> GSM155492     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155496     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155500     2  0.1411      0.842 0.000 0.964 0.036
#> GSM155504     2  0.1860      0.827 0.000 0.948 0.052
#> GSM155450     2  0.1643      0.815 0.000 0.956 0.044
#> GSM155453     2  0.0892      0.837 0.000 0.980 0.020
#> GSM155457     1  0.9736      0.558 0.416 0.228 0.356
#> GSM155461     1  0.5706      0.843 0.680 0.000 0.320
#> GSM155465     1  0.5733      0.843 0.676 0.000 0.324
#> GSM155469     1  0.5882      0.838 0.652 0.000 0.348
#> GSM155473     1  0.5733      0.843 0.676 0.000 0.324
#> GSM155477     1  0.5810      0.842 0.664 0.000 0.336
#> GSM155481     1  0.5785      0.843 0.668 0.000 0.332
#> GSM155485     1  0.2297      0.713 0.944 0.036 0.020
#> GSM155489     1  0.5426      0.535 0.820 0.088 0.092
#> GSM155493     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155497     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155501     2  0.1411      0.842 0.000 0.964 0.036
#> GSM155505     2  0.1411      0.842 0.000 0.964 0.036
#> GSM155451     2  0.0747      0.840 0.000 0.984 0.016
#> GSM155454     2  0.0747      0.840 0.000 0.984 0.016
#> GSM155458     2  0.8472      0.127 0.100 0.540 0.360
#> GSM155462     1  0.5591      0.840 0.696 0.000 0.304
#> GSM155466     1  0.5760      0.843 0.672 0.000 0.328
#> GSM155470     1  0.5835      0.841 0.660 0.000 0.340
#> GSM155474     1  0.5810      0.842 0.664 0.000 0.336
#> GSM155478     3  0.5461      0.838 0.008 0.244 0.748
#> GSM155482     3  0.5763      0.879 0.008 0.276 0.716
#> GSM155486     1  0.4095      0.623 0.880 0.056 0.064
#> GSM155490     3  0.6205      0.872 0.008 0.336 0.656
#> GSM155494     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155498     1  0.0000      0.719 1.000 0.000 0.000
#> GSM155502     2  0.1643      0.836 0.000 0.956 0.044
#> GSM155506     2  0.1411      0.842 0.000 0.964 0.036

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     2  0.2549      0.860 0.004 0.916 0.056 0.024
#> GSM155452     2  0.6332      0.728 0.136 0.712 0.120 0.032
#> GSM155455     1  0.7046      0.495 0.640 0.208 0.120 0.032
#> GSM155459     1  0.2704      0.852 0.876 0.000 0.124 0.000
#> GSM155463     1  0.0817      0.897 0.976 0.000 0.024 0.000
#> GSM155467     1  0.2081      0.881 0.916 0.000 0.084 0.000
#> GSM155471     1  0.0188      0.895 0.996 0.000 0.004 0.000
#> GSM155475     1  0.2704      0.852 0.876 0.000 0.124 0.000
#> GSM155479     1  0.2149      0.879 0.912 0.000 0.088 0.000
#> GSM155483     3  0.4446      0.844 0.196 0.028 0.776 0.000
#> GSM155487     4  0.1022      1.000 0.000 0.032 0.000 0.968
#> GSM155491     3  0.2973      0.888 0.144 0.000 0.856 0.000
#> GSM155495     3  0.3198      0.866 0.080 0.040 0.880 0.000
#> GSM155499     2  0.0524      0.877 0.000 0.988 0.004 0.008
#> GSM155503     2  0.0804      0.876 0.000 0.980 0.012 0.008
#> GSM155449     2  0.4524      0.829 0.048 0.828 0.096 0.028
#> GSM155456     1  0.4226      0.765 0.832 0.020 0.120 0.028
#> GSM155460     1  0.2281      0.874 0.904 0.000 0.096 0.000
#> GSM155464     1  0.0817      0.897 0.976 0.000 0.024 0.000
#> GSM155468     1  0.0000      0.894 1.000 0.000 0.000 0.000
#> GSM155472     1  0.2741      0.820 0.892 0.000 0.012 0.096
#> GSM155476     1  0.0524      0.889 0.988 0.004 0.008 0.000
#> GSM155480     1  0.1302      0.870 0.956 0.000 0.044 0.000
#> GSM155484     3  0.5690      0.787 0.116 0.168 0.716 0.000
#> GSM155488     2  0.2658      0.813 0.004 0.904 0.080 0.012
#> GSM155492     3  0.2814      0.893 0.132 0.000 0.868 0.000
#> GSM155496     3  0.2831      0.890 0.120 0.004 0.876 0.000
#> GSM155500     2  0.0672      0.877 0.000 0.984 0.008 0.008
#> GSM155504     2  0.1151      0.870 0.000 0.968 0.024 0.008
#> GSM155450     2  0.6283      0.734 0.132 0.716 0.120 0.032
#> GSM155453     2  0.5915      0.765 0.104 0.744 0.120 0.032
#> GSM155457     1  0.4801      0.743 0.808 0.040 0.120 0.032
#> GSM155461     1  0.2704      0.852 0.876 0.000 0.124 0.000
#> GSM155465     1  0.2081      0.881 0.916 0.000 0.084 0.000
#> GSM155469     1  0.0000      0.894 1.000 0.000 0.000 0.000
#> GSM155473     1  0.1637      0.891 0.940 0.000 0.060 0.000
#> GSM155477     1  0.1474      0.893 0.948 0.000 0.052 0.000
#> GSM155481     1  0.0921      0.897 0.972 0.000 0.028 0.000
#> GSM155485     3  0.5719      0.811 0.176 0.112 0.712 0.000
#> GSM155489     3  0.5517      0.632 0.040 0.272 0.684 0.004
#> GSM155493     3  0.2814      0.893 0.132 0.000 0.868 0.000
#> GSM155497     3  0.2814      0.893 0.132 0.000 0.868 0.000
#> GSM155501     2  0.0927      0.874 0.000 0.976 0.016 0.008
#> GSM155505     2  0.0672      0.877 0.000 0.984 0.008 0.008
#> GSM155451     2  0.4331      0.835 0.048 0.840 0.084 0.028
#> GSM155454     2  0.4115      0.833 0.016 0.836 0.120 0.028
#> GSM155458     1  0.5857      0.672 0.748 0.100 0.120 0.032
#> GSM155462     1  0.2704      0.852 0.876 0.000 0.124 0.000
#> GSM155466     1  0.1637      0.891 0.940 0.000 0.060 0.000
#> GSM155470     1  0.0188      0.892 0.996 0.000 0.004 0.000
#> GSM155474     1  0.0000      0.894 1.000 0.000 0.000 0.000
#> GSM155478     4  0.1022      1.000 0.000 0.032 0.000 0.968
#> GSM155482     4  0.1022      1.000 0.000 0.032 0.000 0.968
#> GSM155486     3  0.5412      0.787 0.096 0.168 0.736 0.000
#> GSM155490     4  0.1022      1.000 0.000 0.032 0.000 0.968
#> GSM155494     3  0.2868      0.892 0.136 0.000 0.864 0.000
#> GSM155498     3  0.3024      0.885 0.148 0.000 0.852 0.000
#> GSM155502     2  0.0927      0.874 0.000 0.976 0.016 0.008
#> GSM155506     2  0.0672      0.877 0.000 0.984 0.008 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
#> GSM155448     4  0.4451      0.458 0.000 0.492 0.004 0.504 0.000
#> GSM155452     4  0.2574      0.792 0.000 0.112 0.012 0.876 0.000
#> GSM155455     4  0.2127      0.793 0.000 0.108 0.000 0.892 0.000
#> GSM155459     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0404      0.915 0.988 0.012 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155483     1  0.5008      0.611 0.708 0.140 0.152 0.000 0.000
#> GSM155487     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155491     3  0.1197      0.987 0.048 0.000 0.952 0.000 0.000
#> GSM155495     3  0.1012      0.954 0.020 0.012 0.968 0.000 0.000
#> GSM155499     2  0.0510      0.868 0.000 0.984 0.016 0.000 0.000
#> GSM155503     2  0.0162      0.872 0.000 0.996 0.004 0.000 0.000
#> GSM155449     4  0.4249      0.581 0.000 0.432 0.000 0.568 0.000
#> GSM155456     4  0.2674      0.680 0.140 0.004 0.000 0.856 0.000
#> GSM155460     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0609      0.910 0.980 0.020 0.000 0.000 0.000
#> GSM155472     1  0.5773      0.438 0.616 0.000 0.000 0.216 0.168
#> GSM155476     1  0.1124      0.897 0.960 0.036 0.004 0.000 0.000
#> GSM155480     1  0.1124      0.897 0.960 0.036 0.004 0.000 0.000
#> GSM155484     1  0.6282      0.158 0.496 0.340 0.164 0.000 0.000
#> GSM155488     2  0.2377      0.773 0.000 0.872 0.128 0.000 0.000
#> GSM155492     3  0.1121      0.988 0.044 0.000 0.956 0.000 0.000
#> GSM155496     3  0.1430      0.980 0.052 0.004 0.944 0.000 0.000
#> GSM155500     2  0.0000      0.873 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      0.873 0.000 1.000 0.000 0.000 0.000
#> GSM155450     4  0.2516      0.802 0.000 0.140 0.000 0.860 0.000
#> GSM155453     4  0.2516      0.802 0.000 0.140 0.000 0.860 0.000
#> GSM155457     4  0.2629      0.684 0.136 0.004 0.000 0.860 0.000
#> GSM155461     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.1205      0.893 0.956 0.040 0.004 0.000 0.000
#> GSM155473     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155485     1  0.5967      0.315 0.556 0.308 0.136 0.000 0.000
#> GSM155489     2  0.3922      0.719 0.040 0.780 0.180 0.000 0.000
#> GSM155493     3  0.1121      0.988 0.044 0.000 0.956 0.000 0.000
#> GSM155497     3  0.1282      0.988 0.044 0.000 0.952 0.004 0.000
#> GSM155501     2  0.0162      0.873 0.000 0.996 0.004 0.000 0.000
#> GSM155505     2  0.0162      0.873 0.000 0.996 0.004 0.000 0.000
#> GSM155451     4  0.3949      0.706 0.000 0.332 0.000 0.668 0.000
#> GSM155454     4  0.4150      0.644 0.000 0.388 0.000 0.612 0.000
#> GSM155458     4  0.2984      0.792 0.032 0.108 0.000 0.860 0.000
#> GSM155462     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.921 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155482     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155486     2  0.6610      0.236 0.280 0.460 0.260 0.000 0.000
#> GSM155490     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155494     3  0.1282      0.988 0.044 0.000 0.952 0.004 0.000
#> GSM155498     3  0.1357      0.986 0.048 0.000 0.948 0.004 0.000
#> GSM155502     2  0.0162      0.873 0.000 0.996 0.004 0.000 0.000
#> GSM155506     2  0.0703      0.864 0.000 0.976 0.024 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
#> GSM155448     4  0.4867      0.570 0.004 0.304 0.028 0.636 0.028 0.00
#> GSM155452     4  0.1536      0.860 0.000 0.016 0.004 0.940 0.040 0.00
#> GSM155455     4  0.0862      0.863 0.008 0.016 0.000 0.972 0.004 0.00
#> GSM155459     1  0.0632      0.963 0.976 0.000 0.000 0.000 0.024 0.00
#> GSM155463     1  0.0692      0.963 0.976 0.000 0.004 0.000 0.020 0.00
#> GSM155467     1  0.0146      0.966 0.996 0.000 0.004 0.000 0.000 0.00
#> GSM155471     1  0.0520      0.965 0.984 0.000 0.000 0.008 0.008 0.00
#> GSM155475     1  0.0551      0.966 0.984 0.000 0.004 0.004 0.008 0.00
#> GSM155479     1  0.1196      0.952 0.952 0.000 0.000 0.008 0.040 0.00
#> GSM155483     5  0.5356      0.789 0.184 0.008 0.168 0.004 0.636 0.00
#> GSM155487     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM155491     3  0.0458      0.931 0.000 0.000 0.984 0.000 0.016 0.00
#> GSM155495     3  0.2871      0.731 0.000 0.004 0.804 0.000 0.192 0.00
#> GSM155499     2  0.0717      0.979 0.000 0.976 0.000 0.016 0.008 0.00
#> GSM155503     2  0.0363      0.986 0.000 0.988 0.000 0.000 0.012 0.00
#> GSM155449     4  0.4415      0.370 0.004 0.420 0.000 0.556 0.020 0.00
#> GSM155456     4  0.1812      0.812 0.080 0.000 0.000 0.912 0.008 0.00
#> GSM155460     1  0.0713      0.962 0.972 0.000 0.000 0.000 0.028 0.00
#> GSM155464     1  0.0858      0.959 0.968 0.000 0.004 0.000 0.028 0.00
#> GSM155468     1  0.0603      0.965 0.980 0.000 0.004 0.000 0.016 0.00
#> GSM155472     1  0.3606      0.768 0.800 0.000 0.000 0.052 0.008 0.14
#> GSM155476     1  0.1785      0.933 0.928 0.016 0.000 0.008 0.048 0.00
#> GSM155480     1  0.0891      0.962 0.968 0.000 0.000 0.008 0.024 0.00
#> GSM155484     5  0.5554      0.821 0.144 0.032 0.172 0.004 0.648 0.00
#> GSM155488     5  0.4708      0.351 0.008 0.356 0.040 0.000 0.596 0.00
#> GSM155492     3  0.0865      0.929 0.000 0.000 0.964 0.000 0.036 0.00
#> GSM155496     3  0.1267      0.915 0.000 0.000 0.940 0.000 0.060 0.00
#> GSM155500     2  0.0291      0.987 0.000 0.992 0.000 0.004 0.004 0.00
#> GSM155504     2  0.0547      0.983 0.000 0.980 0.000 0.000 0.020 0.00
#> GSM155450     4  0.1434      0.867 0.000 0.048 0.000 0.940 0.012 0.00
#> GSM155453     4  0.1265      0.867 0.000 0.044 0.000 0.948 0.008 0.00
#> GSM155457     4  0.1265      0.846 0.044 0.000 0.000 0.948 0.008 0.00
#> GSM155461     1  0.0692      0.963 0.976 0.000 0.004 0.000 0.020 0.00
#> GSM155465     1  0.0692      0.964 0.976 0.000 0.004 0.000 0.020 0.00
#> GSM155469     1  0.0405      0.966 0.988 0.000 0.004 0.000 0.008 0.00
#> GSM155473     1  0.0653      0.965 0.980 0.000 0.004 0.012 0.004 0.00
#> GSM155477     1  0.0547      0.964 0.980 0.000 0.000 0.000 0.020 0.00
#> GSM155481     1  0.0820      0.962 0.972 0.000 0.000 0.012 0.016 0.00
#> GSM155485     5  0.5439      0.812 0.164 0.020 0.164 0.004 0.648 0.00
#> GSM155489     5  0.5017      0.738 0.048 0.072 0.184 0.000 0.696 0.00
#> GSM155493     3  0.0790      0.930 0.000 0.000 0.968 0.000 0.032 0.00
#> GSM155497     3  0.1075      0.904 0.000 0.000 0.952 0.000 0.048 0.00
#> GSM155501     2  0.0146      0.987 0.000 0.996 0.000 0.000 0.004 0.00
#> GSM155505     2  0.0520      0.983 0.000 0.984 0.000 0.008 0.008 0.00
#> GSM155451     4  0.1967      0.856 0.000 0.084 0.000 0.904 0.012 0.00
#> GSM155454     4  0.2812      0.838 0.000 0.048 0.000 0.856 0.096 0.00
#> GSM155458     4  0.1036      0.858 0.024 0.008 0.000 0.964 0.004 0.00
#> GSM155462     1  0.1387      0.928 0.932 0.000 0.000 0.000 0.068 0.00
#> GSM155466     1  0.0603      0.964 0.980 0.000 0.004 0.000 0.016 0.00
#> GSM155470     1  0.0603      0.964 0.980 0.000 0.000 0.004 0.016 0.00
#> GSM155474     1  0.0622      0.964 0.980 0.000 0.000 0.012 0.008 0.00
#> GSM155478     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM155482     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM155486     5  0.5574      0.809 0.116 0.040 0.192 0.004 0.648 0.00
#> GSM155490     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.00
#> GSM155494     3  0.0260      0.928 0.000 0.000 0.992 0.000 0.008 0.00
#> GSM155498     3  0.0865      0.912 0.000 0.000 0.964 0.000 0.036 0.00
#> GSM155502     2  0.0000      0.988 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM155506     2  0.0260      0.988 0.000 0.992 0.000 0.000 0.008 0.00

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 time(p) k
#> SD:NMF 59   0.411 2
#> SD:NMF 57   0.327 3
#> SD:NMF 58   0.693 4
#> SD:NMF 54   0.831 5
#> SD:NMF 57   0.929 6

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


CV:hclust**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-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 1.000           1.000       1.000          0.129 0.871   0.871
#> 3 3 0.477           0.809       0.786          2.586 0.562   0.497
#> 4 4 0.752           0.810       0.869          0.384 0.765   0.546
#> 5 5 0.887           0.897       0.942          0.102 0.949   0.860
#> 6 6 1.000           0.966       0.986          0.113 0.897   0.673

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

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

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
#> GSM155448     1       0          1  1  0
#> GSM155452     1       0          1  1  0
#> GSM155455     1       0          1  1  0
#> GSM155459     1       0          1  1  0
#> GSM155463     1       0          1  1  0
#> GSM155467     1       0          1  1  0
#> GSM155471     1       0          1  1  0
#> GSM155475     1       0          1  1  0
#> GSM155479     1       0          1  1  0
#> GSM155483     1       0          1  1  0
#> GSM155487     2       0          1  0  1
#> GSM155491     1       0          1  1  0
#> GSM155495     1       0          1  1  0
#> GSM155499     1       0          1  1  0
#> GSM155503     1       0          1  1  0
#> GSM155449     1       0          1  1  0
#> GSM155456     1       0          1  1  0
#> GSM155460     1       0          1  1  0
#> GSM155464     1       0          1  1  0
#> GSM155468     1       0          1  1  0
#> GSM155472     1       0          1  1  0
#> GSM155476     1       0          1  1  0
#> GSM155480     1       0          1  1  0
#> GSM155484     1       0          1  1  0
#> GSM155488     1       0          1  1  0
#> GSM155492     1       0          1  1  0
#> GSM155496     1       0          1  1  0
#> GSM155500     1       0          1  1  0
#> GSM155504     1       0          1  1  0
#> GSM155450     1       0          1  1  0
#> GSM155453     1       0          1  1  0
#> GSM155457     1       0          1  1  0
#> GSM155461     1       0          1  1  0
#> GSM155465     1       0          1  1  0
#> GSM155469     1       0          1  1  0
#> GSM155473     1       0          1  1  0
#> GSM155477     1       0          1  1  0
#> GSM155481     1       0          1  1  0
#> GSM155485     1       0          1  1  0
#> GSM155489     1       0          1  1  0
#> GSM155493     1       0          1  1  0
#> GSM155497     1       0          1  1  0
#> GSM155501     1       0          1  1  0
#> GSM155505     1       0          1  1  0
#> GSM155451     1       0          1  1  0
#> GSM155454     1       0          1  1  0
#> GSM155458     1       0          1  1  0
#> GSM155462     1       0          1  1  0
#> GSM155466     1       0          1  1  0
#> GSM155470     1       0          1  1  0
#> GSM155474     1       0          1  1  0
#> GSM155478     2       0          1  0  1
#> GSM155482     2       0          1  0  1
#> GSM155486     1       0          1  1  0
#> GSM155490     2       0          1  0  1
#> GSM155494     1       0          1  1  0
#> GSM155498     1       0          1  1  0
#> GSM155502     1       0          1  1  0
#> GSM155506     1       0          1  1  0

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM155448     2  0.0237      0.888 0.004 0.996  0
#> GSM155452     2  0.0237      0.888 0.004 0.996  0
#> GSM155455     2  0.0237      0.888 0.004 0.996  0
#> GSM155459     1  0.5859      0.872 0.656 0.344  0
#> GSM155463     1  0.5859      0.872 0.656 0.344  0
#> GSM155467     1  0.5859      0.872 0.656 0.344  0
#> GSM155471     1  0.5859      0.872 0.656 0.344  0
#> GSM155475     1  0.5859      0.872 0.656 0.344  0
#> GSM155479     1  0.5859      0.872 0.656 0.344  0
#> GSM155483     2  0.5431      0.451 0.284 0.716  0
#> GSM155487     3  0.0000      1.000 0.000 0.000  1
#> GSM155491     1  0.0000      0.538 1.000 0.000  0
#> GSM155495     1  0.5835      0.869 0.660 0.340  0
#> GSM155499     2  0.0000      0.886 0.000 1.000  0
#> GSM155503     2  0.0000      0.886 0.000 1.000  0
#> GSM155449     2  0.0237      0.888 0.004 0.996  0
#> GSM155456     2  0.0237      0.888 0.004 0.996  0
#> GSM155460     1  0.5859      0.872 0.656 0.344  0
#> GSM155464     1  0.5859      0.872 0.656 0.344  0
#> GSM155468     1  0.5859      0.872 0.656 0.344  0
#> GSM155472     1  0.5859      0.872 0.656 0.344  0
#> GSM155476     1  0.5859      0.872 0.656 0.344  0
#> GSM155480     1  0.5859      0.872 0.656 0.344  0
#> GSM155484     2  0.5431      0.451 0.284 0.716  0
#> GSM155488     2  0.5431      0.451 0.284 0.716  0
#> GSM155492     1  0.0000      0.538 1.000 0.000  0
#> GSM155496     1  0.5835      0.869 0.660 0.340  0
#> GSM155500     2  0.0000      0.886 0.000 1.000  0
#> GSM155504     2  0.0000      0.886 0.000 1.000  0
#> GSM155450     2  0.0237      0.888 0.004 0.996  0
#> GSM155453     2  0.0237      0.888 0.004 0.996  0
#> GSM155457     2  0.0237      0.888 0.004 0.996  0
#> GSM155461     1  0.5859      0.872 0.656 0.344  0
#> GSM155465     1  0.5859      0.872 0.656 0.344  0
#> GSM155469     1  0.5859      0.872 0.656 0.344  0
#> GSM155473     1  0.5859      0.872 0.656 0.344  0
#> GSM155477     1  0.5859      0.872 0.656 0.344  0
#> GSM155481     1  0.5859      0.872 0.656 0.344  0
#> GSM155485     2  0.5431      0.451 0.284 0.716  0
#> GSM155489     2  0.5431      0.451 0.284 0.716  0
#> GSM155493     1  0.0000      0.538 1.000 0.000  0
#> GSM155497     1  0.0000      0.538 1.000 0.000  0
#> GSM155501     2  0.0000      0.886 0.000 1.000  0
#> GSM155505     2  0.0000      0.886 0.000 1.000  0
#> GSM155451     2  0.0237      0.888 0.004 0.996  0
#> GSM155454     2  0.0237      0.888 0.004 0.996  0
#> GSM155458     2  0.0237      0.888 0.004 0.996  0
#> GSM155462     1  0.5859      0.872 0.656 0.344  0
#> GSM155466     1  0.5859      0.872 0.656 0.344  0
#> GSM155470     1  0.5859      0.872 0.656 0.344  0
#> GSM155474     1  0.5859      0.872 0.656 0.344  0
#> GSM155478     3  0.0000      1.000 0.000 0.000  1
#> GSM155482     3  0.0000      1.000 0.000 0.000  1
#> GSM155486     2  0.5431      0.451 0.284 0.716  0
#> GSM155490     3  0.0000      1.000 0.000 0.000  1
#> GSM155494     1  0.0000      0.538 1.000 0.000  0
#> GSM155498     1  0.0000      0.538 1.000 0.000  0
#> GSM155502     2  0.0000      0.886 0.000 1.000  0
#> GSM155506     2  0.0000      0.886 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM155448     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155452     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155455     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155459     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155463     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155467     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155471     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155475     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155479     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155483     1   0.495      0.459 0.620 0.376 0.004  0
#> GSM155487     4   0.000      1.000 0.000 0.000 0.000  1
#> GSM155491     3   0.000      1.000 0.000 0.000 1.000  0
#> GSM155495     1   0.488      0.816 0.592 0.000 0.408  0
#> GSM155499     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155503     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155449     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155456     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155460     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155464     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155468     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155472     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155476     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155480     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155484     1   0.495      0.459 0.620 0.376 0.004  0
#> GSM155488     1   0.495      0.459 0.620 0.376 0.004  0
#> GSM155492     3   0.000      1.000 0.000 0.000 1.000  0
#> GSM155496     1   0.488      0.816 0.592 0.000 0.408  0
#> GSM155500     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155504     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155450     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155453     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155457     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155461     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155465     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155469     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155473     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155477     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155481     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155485     1   0.495      0.459 0.620 0.376 0.004  0
#> GSM155489     1   0.495      0.459 0.620 0.376 0.004  0
#> GSM155493     3   0.000      1.000 0.000 0.000 1.000  0
#> GSM155497     3   0.000      1.000 0.000 0.000 1.000  0
#> GSM155501     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155505     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155451     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155454     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155458     2   0.480      0.801 0.384 0.616 0.000  0
#> GSM155462     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155466     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155470     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155474     1   0.478      0.858 0.624 0.000 0.376  0
#> GSM155478     4   0.000      1.000 0.000 0.000 0.000  1
#> GSM155482     4   0.000      1.000 0.000 0.000 0.000  1
#> GSM155486     1   0.495      0.459 0.620 0.376 0.004  0
#> GSM155490     4   0.000      1.000 0.000 0.000 0.000  1
#> GSM155494     3   0.000      1.000 0.000 0.000 1.000  0
#> GSM155498     3   0.000      1.000 0.000 0.000 1.000  0
#> GSM155502     2   0.000      0.718 0.000 1.000 0.000  0
#> GSM155506     2   0.000      0.718 0.000 1.000 0.000  0

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3 p4 p5
#> GSM155448     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155452     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155455     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155459     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155463     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155467     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155471     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155475     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155479     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155483     1   0.535      0.563 0.624 0.292 0.084  0  0
#> GSM155487     5   0.000      1.000 0.000 0.000 0.000  0  1
#> GSM155491     3   0.179      1.000 0.084 0.000 0.916  0  0
#> GSM155495     1   0.391      0.519 0.676 0.000 0.324  0  0
#> GSM155499     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155503     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155449     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155456     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155460     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155464     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155468     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155472     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155476     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155480     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155484     1   0.535      0.563 0.624 0.292 0.084  0  0
#> GSM155488     1   0.535      0.563 0.624 0.292 0.084  0  0
#> GSM155492     3   0.179      1.000 0.084 0.000 0.916  0  0
#> GSM155496     1   0.391      0.519 0.676 0.000 0.324  0  0
#> GSM155500     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155504     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155450     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155453     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155457     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155461     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155465     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155469     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155473     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155477     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155481     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155485     1   0.535      0.563 0.624 0.292 0.084  0  0
#> GSM155489     1   0.535      0.563 0.624 0.292 0.084  0  0
#> GSM155493     3   0.179      1.000 0.084 0.000 0.916  0  0
#> GSM155497     3   0.179      1.000 0.084 0.000 0.916  0  0
#> GSM155501     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155505     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155451     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155454     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155458     4   0.000      1.000 0.000 0.000 0.000  1  0
#> GSM155462     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155466     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155470     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155474     1   0.000      0.888 1.000 0.000 0.000  0  0
#> GSM155478     5   0.000      1.000 0.000 0.000 0.000  0  1
#> GSM155482     5   0.000      1.000 0.000 0.000 0.000  0  1
#> GSM155486     1   0.535      0.563 0.624 0.292 0.084  0  0
#> GSM155490     5   0.000      1.000 0.000 0.000 0.000  0  1
#> GSM155494     3   0.179      1.000 0.084 0.000 0.916  0  0
#> GSM155498     3   0.179      1.000 0.084 0.000 0.916  0  0
#> GSM155502     2   0.000      1.000 0.000 1.000 0.000  0  0
#> GSM155506     2   0.000      1.000 0.000 1.000 0.000  0  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1 p2    p3 p4    p5 p6
#> GSM155448     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155452     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155455     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155459     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155463     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155467     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155471     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155475     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155479     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155483     5   0.000      0.867  0  0 0.000  0 1.000  0
#> GSM155487     6   0.000      1.000  0  0 0.000  0 0.000  1
#> GSM155491     3   0.000      1.000  0  0 1.000  0 0.000  0
#> GSM155495     5   0.377      0.409  0  0 0.408  0 0.592  0
#> GSM155499     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155503     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155449     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155456     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155460     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155464     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155468     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155472     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155476     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155480     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155484     5   0.000      0.867  0  0 0.000  0 1.000  0
#> GSM155488     5   0.000      0.867  0  0 0.000  0 1.000  0
#> GSM155492     3   0.000      1.000  0  0 1.000  0 0.000  0
#> GSM155496     5   0.377      0.409  0  0 0.408  0 0.592  0
#> GSM155500     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155504     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155450     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155453     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155457     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155461     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155465     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155469     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155473     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155477     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155481     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155485     5   0.000      0.867  0  0 0.000  0 1.000  0
#> GSM155489     5   0.000      0.867  0  0 0.000  0 1.000  0
#> GSM155493     3   0.000      1.000  0  0 1.000  0 0.000  0
#> GSM155497     3   0.000      1.000  0  0 1.000  0 0.000  0
#> GSM155501     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155505     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155451     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155454     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155458     4   0.000      1.000  0  0 0.000  1 0.000  0
#> GSM155462     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155466     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155470     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155474     1   0.000      1.000  1  0 0.000  0 0.000  0
#> GSM155478     6   0.000      1.000  0  0 0.000  0 0.000  1
#> GSM155482     6   0.000      1.000  0  0 0.000  0 0.000  1
#> GSM155486     5   0.000      0.867  0  0 0.000  0 1.000  0
#> GSM155490     6   0.000      1.000  0  0 0.000  0 0.000  1
#> GSM155494     3   0.000      1.000  0  0 1.000  0 0.000  0
#> GSM155498     3   0.000      1.000  0  0 1.000  0 0.000  0
#> GSM155502     2   0.000      1.000  0  1 0.000  0 0.000  0
#> GSM155506     2   0.000      1.000  0  1 0.000  0 0.000  0

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 time(p) k
#> CV:hclust 59  0.0997 2
#> CV:hclust 53  0.3959 3
#> CV:hclust 53  0.5847 4
#> CV:hclust 59  0.7798 5
#> CV:hclust 57  0.9314 6

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


CV:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.327           0.913       0.884         0.3778 0.544   0.544
#> 3 3 0.586           0.728       0.810         0.5262 1.000   1.000
#> 4 4 0.621           0.622       0.759         0.1738 0.683   0.452
#> 5 5 0.670           0.771       0.837         0.0924 0.891   0.662
#> 6 6 0.852           0.894       0.868         0.0614 0.964   0.854

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
#> GSM155448     2  0.9087      0.913 0.324 0.676
#> GSM155452     2  0.9286      0.888 0.344 0.656
#> GSM155455     1  0.0376      0.945 0.996 0.004
#> GSM155459     1  0.0000      0.947 1.000 0.000
#> GSM155463     1  0.0000      0.947 1.000 0.000
#> GSM155467     1  0.0000      0.947 1.000 0.000
#> GSM155471     1  0.0000      0.947 1.000 0.000
#> GSM155475     1  0.0000      0.947 1.000 0.000
#> GSM155479     1  0.0000      0.947 1.000 0.000
#> GSM155483     1  0.5059      0.866 0.888 0.112
#> GSM155487     2  0.5294      0.793 0.120 0.880
#> GSM155491     1  0.5519      0.857 0.872 0.128
#> GSM155495     1  0.4562      0.883 0.904 0.096
#> GSM155499     2  0.8813      0.935 0.300 0.700
#> GSM155503     2  0.8813      0.935 0.300 0.700
#> GSM155449     2  0.9087      0.913 0.324 0.676
#> GSM155456     1  0.0376      0.945 0.996 0.004
#> GSM155460     1  0.0000      0.947 1.000 0.000
#> GSM155464     1  0.0000      0.947 1.000 0.000
#> GSM155468     1  0.0000      0.947 1.000 0.000
#> GSM155472     1  0.0000      0.947 1.000 0.000
#> GSM155476     1  0.0000      0.947 1.000 0.000
#> GSM155480     1  0.0000      0.947 1.000 0.000
#> GSM155484     1  0.5059      0.866 0.888 0.112
#> GSM155488     2  0.8909      0.925 0.308 0.692
#> GSM155492     1  0.5519      0.857 0.872 0.128
#> GSM155496     1  0.5519      0.857 0.872 0.128
#> GSM155500     2  0.8813      0.935 0.300 0.700
#> GSM155504     2  0.8813      0.935 0.300 0.700
#> GSM155450     2  0.8813      0.933 0.300 0.700
#> GSM155453     2  0.8813      0.933 0.300 0.700
#> GSM155457     1  0.0376      0.945 0.996 0.004
#> GSM155461     1  0.0000      0.947 1.000 0.000
#> GSM155465     1  0.0000      0.947 1.000 0.000
#> GSM155469     1  0.0000      0.947 1.000 0.000
#> GSM155473     1  0.0000      0.947 1.000 0.000
#> GSM155477     1  0.0000      0.947 1.000 0.000
#> GSM155481     1  0.0000      0.947 1.000 0.000
#> GSM155485     1  0.5059      0.866 0.888 0.112
#> GSM155489     1  0.5059      0.866 0.888 0.112
#> GSM155493     1  0.5519      0.857 0.872 0.128
#> GSM155497     1  0.5519      0.857 0.872 0.128
#> GSM155501     2  0.8813      0.935 0.300 0.700
#> GSM155505     2  0.8813      0.935 0.300 0.700
#> GSM155451     2  0.8763      0.934 0.296 0.704
#> GSM155454     2  0.8813      0.933 0.300 0.700
#> GSM155458     1  0.0376      0.945 0.996 0.004
#> GSM155462     1  0.0000      0.947 1.000 0.000
#> GSM155466     1  0.0000      0.947 1.000 0.000
#> GSM155470     1  0.0000      0.947 1.000 0.000
#> GSM155474     1  0.0000      0.947 1.000 0.000
#> GSM155478     2  0.6801      0.789 0.180 0.820
#> GSM155482     2  0.6801      0.789 0.180 0.820
#> GSM155486     1  0.5059      0.866 0.888 0.112
#> GSM155490     2  0.5294      0.793 0.120 0.880
#> GSM155494     1  0.5519      0.857 0.872 0.128
#> GSM155498     1  0.5519      0.857 0.872 0.128
#> GSM155502     2  0.8813      0.935 0.300 0.700
#> GSM155506     2  0.8813      0.935 0.300 0.700

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2 p3
#> GSM155448     2   0.677      0.782 0.032 0.664 NA
#> GSM155452     2   0.677      0.782 0.032 0.664 NA
#> GSM155455     1   0.677      0.506 0.664 0.032 NA
#> GSM155459     1   0.000      0.815 1.000 0.000 NA
#> GSM155463     1   0.000      0.815 1.000 0.000 NA
#> GSM155467     1   0.000      0.815 1.000 0.000 NA
#> GSM155471     1   0.000      0.815 1.000 0.000 NA
#> GSM155475     1   0.000      0.815 1.000 0.000 NA
#> GSM155479     1   0.000      0.815 1.000 0.000 NA
#> GSM155483     1   0.856      0.572 0.608 0.208 NA
#> GSM155487     2   0.525      0.721 0.000 0.736 NA
#> GSM155491     1   0.666      0.575 0.528 0.008 NA
#> GSM155495     1   0.706      0.563 0.516 0.020 NA
#> GSM155499     2   0.103      0.834 0.024 0.976 NA
#> GSM155503     2   0.103      0.834 0.024 0.976 NA
#> GSM155449     2   0.677      0.782 0.032 0.664 NA
#> GSM155456     1   0.556      0.562 0.700 0.000 NA
#> GSM155460     1   0.000      0.815 1.000 0.000 NA
#> GSM155464     1   0.000      0.815 1.000 0.000 NA
#> GSM155468     1   0.000      0.815 1.000 0.000 NA
#> GSM155472     1   0.000      0.815 1.000 0.000 NA
#> GSM155476     1   0.000      0.815 1.000 0.000 NA
#> GSM155480     1   0.000      0.815 1.000 0.000 NA
#> GSM155484     1   0.856      0.572 0.608 0.208 NA
#> GSM155488     2   0.379      0.800 0.060 0.892 NA
#> GSM155492     1   0.666      0.575 0.528 0.008 NA
#> GSM155496     1   0.667      0.572 0.524 0.008 NA
#> GSM155500     2   0.103      0.834 0.024 0.976 NA
#> GSM155504     2   0.103      0.834 0.024 0.976 NA
#> GSM155450     2   0.666      0.784 0.028 0.668 NA
#> GSM155453     2   0.666      0.784 0.028 0.668 NA
#> GSM155457     1   0.556      0.562 0.700 0.000 NA
#> GSM155461     1   0.000      0.815 1.000 0.000 NA
#> GSM155465     1   0.000      0.815 1.000 0.000 NA
#> GSM155469     1   0.000      0.815 1.000 0.000 NA
#> GSM155473     1   0.000      0.815 1.000 0.000 NA
#> GSM155477     1   0.000      0.815 1.000 0.000 NA
#> GSM155481     1   0.000      0.815 1.000 0.000 NA
#> GSM155485     1   0.856      0.572 0.608 0.208 NA
#> GSM155489     1   0.881      0.531 0.580 0.236 NA
#> GSM155493     1   0.666      0.575 0.528 0.008 NA
#> GSM155497     1   0.666      0.575 0.528 0.008 NA
#> GSM155501     2   0.103      0.834 0.024 0.976 NA
#> GSM155505     2   0.103      0.834 0.024 0.976 NA
#> GSM155451     2   0.666      0.784 0.028 0.668 NA
#> GSM155454     2   0.654      0.784 0.024 0.672 NA
#> GSM155458     1   0.556      0.562 0.700 0.000 NA
#> GSM155462     1   0.000      0.815 1.000 0.000 NA
#> GSM155466     1   0.000      0.815 1.000 0.000 NA
#> GSM155470     1   0.000      0.815 1.000 0.000 NA
#> GSM155474     1   0.000      0.815 1.000 0.000 NA
#> GSM155478     2   0.947      0.502 0.208 0.484 NA
#> GSM155482     2   0.947      0.502 0.208 0.484 NA
#> GSM155486     1   0.856      0.572 0.608 0.208 NA
#> GSM155490     2   0.525      0.721 0.000 0.736 NA
#> GSM155494     1   0.666      0.575 0.528 0.008 NA
#> GSM155498     1   0.666      0.575 0.528 0.008 NA
#> GSM155502     2   0.103      0.834 0.024 0.976 NA
#> GSM155506     2   0.103      0.834 0.024 0.976 NA

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     4   0.540      0.631 0.012 0.384 0.004 0.600
#> GSM155452     4   0.540      0.631 0.012 0.384 0.004 0.600
#> GSM155455     4   0.584      0.477 0.400 0.000 0.036 0.564
#> GSM155459     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155483     1   0.973     -0.138 0.352 0.260 0.224 0.164
#> GSM155487     3   0.528     -0.298 0.000 0.464 0.528 0.008
#> GSM155491     3   0.803      0.639 0.252 0.008 0.428 0.312
#> GSM155495     3   0.813      0.601 0.232 0.012 0.392 0.364
#> GSM155499     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155503     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155449     4   0.540      0.631 0.012 0.384 0.004 0.600
#> GSM155456     4   0.585      0.472 0.404 0.000 0.036 0.560
#> GSM155460     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155484     1   0.973     -0.138 0.352 0.260 0.224 0.164
#> GSM155488     2   0.614      0.613 0.028 0.724 0.132 0.116
#> GSM155492     3   0.803      0.639 0.252 0.008 0.428 0.312
#> GSM155496     3   0.800      0.637 0.244 0.008 0.432 0.316
#> GSM155500     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155504     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155450     4   0.523      0.632 0.012 0.384 0.000 0.604
#> GSM155453     4   0.523      0.632 0.012 0.384 0.000 0.604
#> GSM155457     4   0.585      0.472 0.404 0.000 0.036 0.560
#> GSM155461     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155485     1   0.973     -0.138 0.352 0.260 0.224 0.164
#> GSM155489     1   0.975     -0.152 0.344 0.268 0.224 0.164
#> GSM155493     3   0.803      0.639 0.252 0.008 0.428 0.312
#> GSM155497     3   0.803      0.639 0.252 0.008 0.428 0.312
#> GSM155501     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155505     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155451     4   0.523      0.632 0.012 0.384 0.000 0.604
#> GSM155454     4   0.523      0.632 0.012 0.384 0.000 0.604
#> GSM155458     4   0.585      0.472 0.404 0.000 0.036 0.560
#> GSM155462     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.846 1.000 0.000 0.000 0.000
#> GSM155478     3   0.829     -0.120 0.096 0.316 0.500 0.088
#> GSM155482     3   0.829     -0.120 0.096 0.316 0.500 0.088
#> GSM155486     1   0.973     -0.138 0.352 0.260 0.224 0.164
#> GSM155490     3   0.528     -0.298 0.000 0.464 0.528 0.008
#> GSM155494     3   0.803      0.639 0.252 0.008 0.428 0.312
#> GSM155498     3   0.792      0.634 0.256 0.004 0.428 0.312
#> GSM155502     2   0.000      0.955 0.000 1.000 0.000 0.000
#> GSM155506     2   0.000      0.955 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
#> GSM155448     4  0.0613      0.818 0.000 0.004 0.008 0.984 0.004
#> GSM155452     4  0.0613      0.818 0.000 0.004 0.008 0.984 0.004
#> GSM155455     4  0.5806      0.682 0.192 0.008 0.048 0.688 0.064
#> GSM155459     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155463     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155467     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155475     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155479     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155483     2  0.8418      0.173 0.172 0.348 0.232 0.000 0.248
#> GSM155487     5  0.4025      0.851 0.000 0.292 0.000 0.008 0.700
#> GSM155491     3  0.2020      0.931 0.100 0.000 0.900 0.000 0.000
#> GSM155495     3  0.6884      0.494 0.068 0.156 0.580 0.000 0.196
#> GSM155499     2  0.3177      0.495 0.000 0.792 0.000 0.208 0.000
#> GSM155503     2  0.3455      0.495 0.000 0.784 0.008 0.208 0.000
#> GSM155449     4  0.0613      0.818 0.000 0.004 0.008 0.984 0.004
#> GSM155456     4  0.5806      0.682 0.192 0.008 0.048 0.688 0.064
#> GSM155460     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155464     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155468     1  0.0162      0.983 0.996 0.000 0.000 0.000 0.004
#> GSM155472     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155476     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155480     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155484     2  0.8418      0.173 0.172 0.348 0.232 0.000 0.248
#> GSM155488     2  0.5629      0.265 0.004 0.664 0.044 0.040 0.248
#> GSM155492     3  0.2020      0.931 0.100 0.000 0.900 0.000 0.000
#> GSM155496     3  0.1768      0.898 0.072 0.000 0.924 0.000 0.004
#> GSM155500     2  0.3177      0.495 0.000 0.792 0.000 0.208 0.000
#> GSM155504     2  0.3455      0.495 0.000 0.784 0.008 0.208 0.000
#> GSM155450     4  0.0162      0.821 0.000 0.004 0.000 0.996 0.000
#> GSM155453     4  0.0162      0.821 0.000 0.004 0.000 0.996 0.000
#> GSM155457     4  0.5806      0.682 0.192 0.008 0.048 0.688 0.064
#> GSM155461     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155465     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155469     1  0.0162      0.983 0.996 0.000 0.000 0.000 0.004
#> GSM155473     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155477     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155481     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155485     2  0.8418      0.173 0.172 0.348 0.232 0.000 0.248
#> GSM155489     2  0.8400      0.174 0.168 0.352 0.232 0.000 0.248
#> GSM155493     3  0.2020      0.931 0.100 0.000 0.900 0.000 0.000
#> GSM155497     3  0.2179      0.930 0.100 0.004 0.896 0.000 0.000
#> GSM155501     2  0.3177      0.495 0.000 0.792 0.000 0.208 0.000
#> GSM155505     2  0.3455      0.495 0.000 0.784 0.008 0.208 0.000
#> GSM155451     4  0.0162      0.821 0.000 0.004 0.000 0.996 0.000
#> GSM155454     4  0.0162      0.821 0.000 0.004 0.000 0.996 0.000
#> GSM155458     4  0.5806      0.682 0.192 0.008 0.048 0.688 0.064
#> GSM155462     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155466     1  0.1124      0.974 0.960 0.004 0.000 0.000 0.036
#> GSM155470     1  0.0162      0.983 0.996 0.000 0.000 0.000 0.004
#> GSM155474     1  0.0162      0.983 0.996 0.000 0.000 0.004 0.000
#> GSM155478     5  0.5102      0.862 0.076 0.148 0.000 0.036 0.740
#> GSM155482     5  0.5102      0.862 0.076 0.148 0.000 0.036 0.740
#> GSM155486     2  0.8418      0.173 0.172 0.348 0.232 0.000 0.248
#> GSM155490     5  0.4253      0.851 0.000 0.284 0.008 0.008 0.700
#> GSM155494     3  0.2020      0.931 0.100 0.000 0.900 0.000 0.000
#> GSM155498     3  0.2179      0.930 0.100 0.004 0.896 0.000 0.000
#> GSM155502     2  0.3177      0.495 0.000 0.792 0.000 0.208 0.000
#> GSM155506     2  0.3455      0.495 0.000 0.784 0.008 0.208 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
#> GSM155448     4  0.1057      0.861 0.004 0.012 0.004 0.968 0.008 0.004
#> GSM155452     4  0.1387      0.860 0.004 0.012 0.008 0.956 0.008 0.012
#> GSM155455     4  0.5327      0.758 0.080 0.000 0.016 0.696 0.164 0.044
#> GSM155459     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155463     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155467     1  0.0291      0.911 0.992 0.004 0.000 0.000 0.004 0.000
#> GSM155471     1  0.0951      0.910 0.968 0.000 0.000 0.008 0.020 0.004
#> GSM155475     1  0.1261      0.907 0.956 0.004 0.000 0.008 0.028 0.004
#> GSM155479     1  0.1413      0.904 0.948 0.004 0.000 0.008 0.036 0.004
#> GSM155483     5  0.5762      0.891 0.068 0.104 0.180 0.004 0.644 0.000
#> GSM155487     6  0.3579      0.935 0.000 0.120 0.008 0.000 0.064 0.808
#> GSM155491     3  0.1007      0.983 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155495     5  0.4622      0.603 0.016 0.012 0.356 0.000 0.608 0.008
#> GSM155499     2  0.2308      0.985 0.000 0.896 0.012 0.076 0.016 0.000
#> GSM155503     2  0.1501      0.985 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM155449     4  0.1057      0.861 0.004 0.012 0.004 0.968 0.008 0.004
#> GSM155456     4  0.5468      0.749 0.084 0.000 0.016 0.680 0.176 0.044
#> GSM155460     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155464     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155468     1  0.0717      0.910 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM155472     1  0.1413      0.905 0.948 0.004 0.000 0.008 0.036 0.004
#> GSM155476     1  0.1338      0.906 0.952 0.004 0.000 0.008 0.032 0.004
#> GSM155480     1  0.1413      0.904 0.948 0.004 0.000 0.008 0.036 0.004
#> GSM155484     5  0.5762      0.891 0.068 0.104 0.180 0.004 0.644 0.000
#> GSM155488     5  0.3940      0.546 0.008 0.336 0.000 0.004 0.652 0.000
#> GSM155492     3  0.1007      0.983 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155496     3  0.1870      0.918 0.012 0.012 0.932 0.000 0.032 0.012
#> GSM155500     2  0.2308      0.985 0.000 0.896 0.012 0.076 0.016 0.000
#> GSM155504     2  0.1501      0.985 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM155450     4  0.0458      0.862 0.000 0.016 0.000 0.984 0.000 0.000
#> GSM155453     4  0.0862      0.862 0.000 0.016 0.004 0.972 0.000 0.008
#> GSM155457     4  0.5468      0.749 0.084 0.000 0.016 0.680 0.176 0.044
#> GSM155461     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155465     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155469     1  0.0717      0.910 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM155473     1  0.0951      0.910 0.968 0.000 0.000 0.008 0.020 0.004
#> GSM155477     1  0.1338      0.906 0.952 0.004 0.000 0.008 0.032 0.004
#> GSM155481     1  0.1413      0.904 0.948 0.004 0.000 0.008 0.036 0.004
#> GSM155485     5  0.5762      0.891 0.068 0.104 0.180 0.004 0.644 0.000
#> GSM155489     5  0.5841      0.888 0.068 0.112 0.180 0.004 0.636 0.000
#> GSM155493     3  0.1007      0.983 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155497     3  0.1367      0.980 0.044 0.000 0.944 0.000 0.000 0.012
#> GSM155501     2  0.2308      0.985 0.000 0.896 0.012 0.076 0.016 0.000
#> GSM155505     2  0.1501      0.985 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM155451     4  0.0458      0.862 0.000 0.016 0.000 0.984 0.000 0.000
#> GSM155454     4  0.0862      0.862 0.000 0.016 0.004 0.972 0.000 0.008
#> GSM155458     4  0.5358      0.757 0.080 0.000 0.016 0.692 0.168 0.044
#> GSM155462     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155466     1  0.3624      0.867 0.824 0.028 0.000 0.004 0.100 0.044
#> GSM155470     1  0.0717      0.910 0.976 0.000 0.000 0.000 0.016 0.008
#> GSM155474     1  0.0951      0.910 0.968 0.000 0.000 0.008 0.020 0.004
#> GSM155478     6  0.2589      0.935 0.028 0.056 0.000 0.004 0.020 0.892
#> GSM155482     6  0.2589      0.935 0.028 0.056 0.000 0.004 0.020 0.892
#> GSM155486     5  0.5762      0.891 0.068 0.104 0.180 0.004 0.644 0.000
#> GSM155490     6  0.3579      0.935 0.000 0.120 0.008 0.000 0.064 0.808
#> GSM155494     3  0.1007      0.983 0.044 0.000 0.956 0.000 0.000 0.000
#> GSM155498     3  0.1367      0.980 0.044 0.000 0.944 0.000 0.000 0.012
#> GSM155502     2  0.2308      0.985 0.000 0.896 0.012 0.076 0.016 0.000
#> GSM155506     2  0.1501      0.985 0.000 0.924 0.000 0.076 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-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 time(p) k
#> CV:kmeans 59   0.655 2
#> CV:kmeans 59   0.655 3
#> CV:kmeans 46   0.999 4
#> CV:kmeans 44   0.656 5
#> CV:kmeans 59   0.939 6

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


CV:skmeans*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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-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           0.955       0.981         0.5016 0.499   0.499
#> 3 3 1.000           0.976       0.989         0.3189 0.737   0.521
#> 4 4 0.939           0.961       0.970         0.1146 0.886   0.679
#> 5 5 0.933           0.918       0.930         0.0398 0.965   0.866
#> 6 6 0.894           0.937       0.936         0.0405 0.981   0.919

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 3 4

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM155448     2  0.0000      0.977 0.000 1.000
#> GSM155452     2  0.0000      0.977 0.000 1.000
#> GSM155455     1  0.9323      0.476 0.652 0.348
#> GSM155459     1  0.0000      0.982 1.000 0.000
#> GSM155463     1  0.0000      0.982 1.000 0.000
#> GSM155467     1  0.0000      0.982 1.000 0.000
#> GSM155471     1  0.0000      0.982 1.000 0.000
#> GSM155475     1  0.0000      0.982 1.000 0.000
#> GSM155479     1  0.0000      0.982 1.000 0.000
#> GSM155483     2  0.2778      0.943 0.048 0.952
#> GSM155487     2  0.0000      0.977 0.000 1.000
#> GSM155491     1  0.0000      0.982 1.000 0.000
#> GSM155495     2  0.9427      0.451 0.360 0.640
#> GSM155499     2  0.0000      0.977 0.000 1.000
#> GSM155503     2  0.0000      0.977 0.000 1.000
#> GSM155449     2  0.0000      0.977 0.000 1.000
#> GSM155456     1  0.0000      0.982 1.000 0.000
#> GSM155460     1  0.0000      0.982 1.000 0.000
#> GSM155464     1  0.0000      0.982 1.000 0.000
#> GSM155468     1  0.0000      0.982 1.000 0.000
#> GSM155472     1  0.0000      0.982 1.000 0.000
#> GSM155476     1  0.0000      0.982 1.000 0.000
#> GSM155480     1  0.0000      0.982 1.000 0.000
#> GSM155484     2  0.2778      0.943 0.048 0.952
#> GSM155488     2  0.0000      0.977 0.000 1.000
#> GSM155492     1  0.0000      0.982 1.000 0.000
#> GSM155496     1  0.0000      0.982 1.000 0.000
#> GSM155500     2  0.0000      0.977 0.000 1.000
#> GSM155504     2  0.0000      0.977 0.000 1.000
#> GSM155450     2  0.0000      0.977 0.000 1.000
#> GSM155453     2  0.0000      0.977 0.000 1.000
#> GSM155457     1  0.0000      0.982 1.000 0.000
#> GSM155461     1  0.0000      0.982 1.000 0.000
#> GSM155465     1  0.0000      0.982 1.000 0.000
#> GSM155469     1  0.0000      0.982 1.000 0.000
#> GSM155473     1  0.0000      0.982 1.000 0.000
#> GSM155477     1  0.0000      0.982 1.000 0.000
#> GSM155481     1  0.0000      0.982 1.000 0.000
#> GSM155485     2  0.2778      0.943 0.048 0.952
#> GSM155489     2  0.0938      0.969 0.012 0.988
#> GSM155493     1  0.0000      0.982 1.000 0.000
#> GSM155497     1  0.0000      0.982 1.000 0.000
#> GSM155501     2  0.0000      0.977 0.000 1.000
#> GSM155505     2  0.0000      0.977 0.000 1.000
#> GSM155451     2  0.0000      0.977 0.000 1.000
#> GSM155454     2  0.0000      0.977 0.000 1.000
#> GSM155458     1  0.7528      0.726 0.784 0.216
#> GSM155462     1  0.0000      0.982 1.000 0.000
#> GSM155466     1  0.0000      0.982 1.000 0.000
#> GSM155470     1  0.0000      0.982 1.000 0.000
#> GSM155474     1  0.0000      0.982 1.000 0.000
#> GSM155478     2  0.0000      0.977 0.000 1.000
#> GSM155482     2  0.0000      0.977 0.000 1.000
#> GSM155486     2  0.2778      0.943 0.048 0.952
#> GSM155490     2  0.0000      0.977 0.000 1.000
#> GSM155494     1  0.0000      0.982 1.000 0.000
#> GSM155498     1  0.0000      0.982 1.000 0.000
#> GSM155502     2  0.0000      0.977 0.000 1.000
#> GSM155506     2  0.0000      0.977 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
#> GSM155448     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155452     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155455     2  0.3644      0.842 0.124 0.872 0.004
#> GSM155459     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155463     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155467     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155471     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155475     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155479     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155483     3  0.0237      0.987 0.000 0.004 0.996
#> GSM155487     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155491     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155495     3  0.0237      0.987 0.000 0.004 0.996
#> GSM155499     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155503     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155449     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155456     1  0.0237      0.996 0.996 0.000 0.004
#> GSM155460     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155464     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155468     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155472     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155476     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155480     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155484     3  0.0237      0.987 0.000 0.004 0.996
#> GSM155488     3  0.3816      0.833 0.000 0.148 0.852
#> GSM155492     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155496     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155500     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155504     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155450     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155453     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155457     1  0.0237      0.996 0.996 0.000 0.004
#> GSM155461     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155465     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155469     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155473     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155477     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155481     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155485     3  0.0237      0.987 0.000 0.004 0.996
#> GSM155489     3  0.0237      0.987 0.000 0.004 0.996
#> GSM155493     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155497     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155501     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155451     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155454     2  0.0237      0.973 0.000 0.996 0.004
#> GSM155458     2  0.5690      0.606 0.288 0.708 0.004
#> GSM155462     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155466     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155470     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155474     1  0.0000      1.000 1.000 0.000 0.000
#> GSM155478     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155482     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155486     3  0.0237      0.987 0.000 0.004 0.996
#> GSM155490     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155494     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155498     3  0.0000      0.987 0.000 0.000 1.000
#> GSM155502     2  0.0000      0.974 0.000 1.000 0.000
#> GSM155506     2  0.0000      0.974 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
#> GSM155448     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155452     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155455     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155459     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155483     3  0.3837      0.824 0.000 0.224 0.776 0.000
#> GSM155487     2  0.0592      0.967 0.000 0.984 0.000 0.016
#> GSM155491     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155495     3  0.0592      0.901 0.000 0.016 0.984 0.000
#> GSM155499     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155503     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155449     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155456     4  0.1557      0.929 0.056 0.000 0.000 0.944
#> GSM155460     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0336      0.992 0.992 0.008 0.000 0.000
#> GSM155476     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155484     3  0.3837      0.824 0.000 0.224 0.776 0.000
#> GSM155488     2  0.0657      0.951 0.000 0.984 0.012 0.004
#> GSM155492     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155496     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155500     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155504     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155450     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155453     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155457     4  0.1557      0.929 0.056 0.000 0.000 0.944
#> GSM155461     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155485     3  0.3837      0.824 0.000 0.224 0.776 0.000
#> GSM155489     3  0.3837      0.824 0.000 0.224 0.776 0.000
#> GSM155493     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155497     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155501     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155505     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155451     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155454     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155458     4  0.0000      0.985 0.000 0.000 0.000 1.000
#> GSM155462     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      1.000 1.000 0.000 0.000 0.000
#> GSM155478     2  0.0927      0.964 0.008 0.976 0.000 0.016
#> GSM155482     2  0.0927      0.964 0.008 0.976 0.000 0.016
#> GSM155486     3  0.3837      0.824 0.000 0.224 0.776 0.000
#> GSM155490     2  0.0592      0.967 0.000 0.984 0.000 0.016
#> GSM155494     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155498     3  0.0000      0.904 0.000 0.000 1.000 0.000
#> GSM155502     2  0.1557      0.980 0.000 0.944 0.000 0.056
#> GSM155506     2  0.1557      0.980 0.000 0.944 0.000 0.056

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM155448     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155452     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155455     4  0.0290      0.986 0.000 0.000 0.008 0.992 0.000
#> GSM155459     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155471     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155475     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155479     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155483     5  0.0000      0.860 0.000 0.000 0.000 0.000 1.000
#> GSM155487     2  0.3171      0.719 0.000 0.816 0.176 0.000 0.008
#> GSM155491     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155495     5  0.4210     -0.109 0.000 0.000 0.412 0.000 0.588
#> GSM155499     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155503     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155449     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155456     4  0.1168      0.953 0.032 0.000 0.008 0.960 0.000
#> GSM155460     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.1992      0.927 0.924 0.032 0.044 0.000 0.000
#> GSM155476     1  0.0324      0.992 0.992 0.004 0.004 0.000 0.000
#> GSM155480     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155484     5  0.0000      0.860 0.000 0.000 0.000 0.000 1.000
#> GSM155488     5  0.3003      0.622 0.000 0.188 0.000 0.000 0.812
#> GSM155492     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155496     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155500     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155504     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155450     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155453     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155457     4  0.1168      0.953 0.032 0.000 0.008 0.960 0.000
#> GSM155461     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155477     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155481     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155485     5  0.0000      0.860 0.000 0.000 0.000 0.000 1.000
#> GSM155489     5  0.0000      0.860 0.000 0.000 0.000 0.000 1.000
#> GSM155493     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155497     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155501     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155505     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155451     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155454     4  0.0000      0.988 0.000 0.000 0.000 1.000 0.000
#> GSM155458     4  0.0290      0.986 0.000 0.000 0.008 0.992 0.000
#> GSM155462     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.995 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0162      0.995 0.996 0.000 0.004 0.000 0.000
#> GSM155478     2  0.3048      0.716 0.000 0.820 0.176 0.000 0.004
#> GSM155482     2  0.3048      0.716 0.000 0.820 0.176 0.000 0.004
#> GSM155486     5  0.0000      0.860 0.000 0.000 0.000 0.000 1.000
#> GSM155490     2  0.3171      0.719 0.000 0.816 0.176 0.000 0.008
#> GSM155494     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155498     3  0.3003      1.000 0.000 0.000 0.812 0.000 0.188
#> GSM155502     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148
#> GSM155506     2  0.3452      0.859 0.000 0.820 0.000 0.032 0.148

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM155448     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155452     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155455     4  0.2039      0.937 0.000 0.000 0.000 0.904 0.020 0.076
#> GSM155459     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155463     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155467     1  0.0146      0.927 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155471     1  0.0603      0.926 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM155475     1  0.1152      0.919 0.952 0.000 0.000 0.000 0.004 0.044
#> GSM155479     1  0.1429      0.917 0.940 0.000 0.000 0.004 0.004 0.052
#> GSM155483     5  0.1341      0.918 0.000 0.024 0.028 0.000 0.948 0.000
#> GSM155487     6  0.2969      0.992 0.000 0.224 0.000 0.000 0.000 0.776
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     5  0.3797      0.320 0.000 0.000 0.420 0.000 0.580 0.000
#> GSM155499     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155503     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155449     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155456     4  0.2182      0.935 0.004 0.000 0.000 0.900 0.020 0.076
#> GSM155460     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155464     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155468     1  0.0603      0.927 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM155472     1  0.2902      0.782 0.800 0.000 0.000 0.000 0.004 0.196
#> GSM155476     1  0.1493      0.916 0.936 0.000 0.000 0.004 0.004 0.056
#> GSM155480     1  0.1429      0.917 0.940 0.000 0.000 0.004 0.004 0.052
#> GSM155484     5  0.1341      0.918 0.000 0.024 0.028 0.000 0.948 0.000
#> GSM155488     5  0.1141      0.887 0.000 0.052 0.000 0.000 0.948 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155500     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155504     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155450     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155453     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155457     4  0.2182      0.935 0.004 0.000 0.000 0.900 0.020 0.076
#> GSM155461     1  0.2554      0.903 0.876 0.004 0.000 0.000 0.028 0.092
#> GSM155465     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155469     1  0.0603      0.927 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM155473     1  0.0603      0.926 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM155477     1  0.1493      0.916 0.936 0.000 0.000 0.004 0.004 0.056
#> GSM155481     1  0.1364      0.918 0.944 0.000 0.000 0.004 0.004 0.048
#> GSM155485     5  0.1341      0.918 0.000 0.024 0.028 0.000 0.948 0.000
#> GSM155489     5  0.1341      0.918 0.000 0.024 0.028 0.000 0.948 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155505     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155451     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155454     4  0.0146      0.965 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM155458     4  0.2039      0.937 0.000 0.000 0.000 0.904 0.020 0.076
#> GSM155462     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155466     1  0.2697      0.904 0.872 0.004 0.000 0.004 0.028 0.092
#> GSM155470     1  0.0603      0.927 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM155474     1  0.0603      0.926 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM155478     6  0.2912      0.992 0.000 0.216 0.000 0.000 0.000 0.784
#> GSM155482     6  0.2912      0.992 0.000 0.216 0.000 0.000 0.000 0.784
#> GSM155486     5  0.1341      0.918 0.000 0.024 0.028 0.000 0.948 0.000
#> GSM155490     6  0.2969      0.992 0.000 0.224 0.000 0.000 0.000 0.776
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155506     2  0.0146      1.000 0.000 0.996 0.000 0.004 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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 time(p) k
#> CV:skmeans 57   0.791 2
#> CV:skmeans 59   0.669 3
#> CV:skmeans 59   0.983 4
#> CV:skmeans 58   0.987 5
#> CV:skmeans 58   0.935 6

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


CV:pam*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.964           0.973       0.987         0.4077 0.598   0.598
#> 3 3 0.736           0.893       0.937         0.3195 0.823   0.714
#> 4 4 0.675           0.748       0.888         0.1824 0.891   0.771
#> 5 5 0.744           0.802       0.855         0.1476 0.762   0.440
#> 6 6 0.946           0.977       0.991         0.0755 0.981   0.919

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

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

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
#> GSM155448     1  0.7056      0.769 0.808 0.192
#> GSM155452     1  0.5059      0.874 0.888 0.112
#> GSM155455     1  0.0000      0.987 1.000 0.000
#> GSM155459     1  0.0000      0.987 1.000 0.000
#> GSM155463     1  0.0000      0.987 1.000 0.000
#> GSM155467     1  0.0000      0.987 1.000 0.000
#> GSM155471     1  0.0000      0.987 1.000 0.000
#> GSM155475     1  0.0000      0.987 1.000 0.000
#> GSM155479     1  0.0000      0.987 1.000 0.000
#> GSM155483     1  0.0000      0.987 1.000 0.000
#> GSM155487     2  0.0000      0.986 0.000 1.000
#> GSM155491     1  0.0000      0.987 1.000 0.000
#> GSM155495     1  0.0000      0.987 1.000 0.000
#> GSM155499     2  0.0000      0.986 0.000 1.000
#> GSM155503     2  0.0000      0.986 0.000 1.000
#> GSM155449     1  0.0672      0.980 0.992 0.008
#> GSM155456     1  0.0000      0.987 1.000 0.000
#> GSM155460     1  0.0000      0.987 1.000 0.000
#> GSM155464     1  0.0000      0.987 1.000 0.000
#> GSM155468     1  0.0000      0.987 1.000 0.000
#> GSM155472     1  0.0000      0.987 1.000 0.000
#> GSM155476     1  0.0000      0.987 1.000 0.000
#> GSM155480     1  0.0000      0.987 1.000 0.000
#> GSM155484     1  0.3879      0.914 0.924 0.076
#> GSM155488     2  0.0000      0.986 0.000 1.000
#> GSM155492     1  0.0000      0.987 1.000 0.000
#> GSM155496     1  0.0000      0.987 1.000 0.000
#> GSM155500     2  0.0000      0.986 0.000 1.000
#> GSM155504     2  0.0000      0.986 0.000 1.000
#> GSM155450     2  0.0000      0.986 0.000 1.000
#> GSM155453     2  0.0000      0.986 0.000 1.000
#> GSM155457     1  0.0000      0.987 1.000 0.000
#> GSM155461     1  0.0000      0.987 1.000 0.000
#> GSM155465     1  0.0000      0.987 1.000 0.000
#> GSM155469     1  0.0000      0.987 1.000 0.000
#> GSM155473     1  0.0000      0.987 1.000 0.000
#> GSM155477     1  0.0000      0.987 1.000 0.000
#> GSM155481     1  0.0000      0.987 1.000 0.000
#> GSM155485     1  0.0000      0.987 1.000 0.000
#> GSM155489     2  0.7219      0.748 0.200 0.800
#> GSM155493     1  0.0000      0.987 1.000 0.000
#> GSM155497     1  0.0000      0.987 1.000 0.000
#> GSM155501     2  0.0000      0.986 0.000 1.000
#> GSM155505     2  0.0000      0.986 0.000 1.000
#> GSM155451     2  0.0000      0.986 0.000 1.000
#> GSM155454     2  0.0000      0.986 0.000 1.000
#> GSM155458     1  0.0000      0.987 1.000 0.000
#> GSM155462     1  0.0000      0.987 1.000 0.000
#> GSM155466     1  0.0000      0.987 1.000 0.000
#> GSM155470     1  0.0000      0.987 1.000 0.000
#> GSM155474     1  0.0000      0.987 1.000 0.000
#> GSM155478     1  0.0000      0.987 1.000 0.000
#> GSM155482     1  0.0000      0.987 1.000 0.000
#> GSM155486     1  0.6247      0.817 0.844 0.156
#> GSM155490     2  0.0000      0.986 0.000 1.000
#> GSM155494     1  0.0000      0.987 1.000 0.000
#> GSM155498     1  0.0000      0.987 1.000 0.000
#> GSM155502     2  0.0000      0.986 0.000 1.000
#> GSM155506     2  0.0000      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
#> GSM155448     1  0.4504      0.697 0.804 0.196 0.000
#> GSM155452     1  0.6037      0.700 0.788 0.112 0.100
#> GSM155455     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155459     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155483     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155487     2  0.4555      0.812 0.000 0.800 0.200
#> GSM155491     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155495     1  0.6260     -0.168 0.552 0.000 0.448
#> GSM155499     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155503     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155449     1  0.0424      0.931 0.992 0.008 0.000
#> GSM155456     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155460     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155472     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155476     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155484     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155488     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155492     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155496     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155500     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155504     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155450     2  0.4178      0.708 0.172 0.828 0.000
#> GSM155453     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155457     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155461     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155485     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155489     1  0.8626      0.196 0.580 0.280 0.140
#> GSM155493     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155497     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155501     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155451     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155454     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155458     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155462     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.939 1.000 0.000 0.000
#> GSM155478     1  0.4555      0.714 0.800 0.000 0.200
#> GSM155482     1  0.4555      0.714 0.800 0.000 0.200
#> GSM155486     1  0.1753      0.889 0.952 0.000 0.048
#> GSM155490     2  0.4555      0.812 0.000 0.800 0.200
#> GSM155494     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155498     3  0.4555      1.000 0.200 0.000 0.800
#> GSM155502     2  0.0000      0.956 0.000 1.000 0.000
#> GSM155506     2  0.0000      0.956 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
#> GSM155448     1   0.612      0.462 0.676 0.192 0.000 0.132
#> GSM155452     1   0.522      0.625 0.756 0.112 0.000 0.132
#> GSM155455     1   0.281      0.787 0.868 0.000 0.000 0.132
#> GSM155459     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155483     1   0.450      0.511 0.684 0.316 0.000 0.000
#> GSM155487     4   0.281      0.194 0.000 0.132 0.000 0.868
#> GSM155491     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155495     3   0.711      0.369 0.152 0.316 0.532 0.000
#> GSM155499     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155503     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155449     1   0.314      0.778 0.860 0.008 0.000 0.132
#> GSM155456     1   0.281      0.787 0.868 0.000 0.000 0.132
#> GSM155460     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155484     1   0.450      0.511 0.684 0.316 0.000 0.000
#> GSM155488     2   0.000      0.480 0.000 1.000 0.000 0.000
#> GSM155492     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155496     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155500     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155504     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155450     2   0.697      0.514 0.140 0.552 0.000 0.308
#> GSM155453     2   0.496      0.744 0.000 0.552 0.000 0.448
#> GSM155457     1   0.281      0.787 0.868 0.000 0.000 0.132
#> GSM155461     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155485     1   0.450      0.511 0.684 0.316 0.000 0.000
#> GSM155489     2   0.713     -0.202 0.320 0.528 0.152 0.000
#> GSM155493     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155497     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155501     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155505     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155451     2   0.496      0.744 0.000 0.552 0.000 0.448
#> GSM155454     2   0.496      0.744 0.000 0.552 0.000 0.448
#> GSM155458     1   0.281      0.787 0.868 0.000 0.000 0.132
#> GSM155462     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.891 1.000 0.000 0.000 0.000
#> GSM155478     4   0.496      0.401 0.448 0.000 0.000 0.552
#> GSM155482     4   0.496      0.401 0.448 0.000 0.000 0.552
#> GSM155486     1   0.583      0.419 0.632 0.316 0.052 0.000
#> GSM155490     4   0.281      0.194 0.000 0.132 0.000 0.868
#> GSM155494     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155498     3   0.000      0.927 0.000 0.000 1.000 0.000
#> GSM155502     2   0.450      0.809 0.000 0.684 0.000 0.316
#> GSM155506     2   0.450      0.809 0.000 0.684 0.000 0.316

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM155448     4   0.293      0.815 0.180 0.000 0.000 0.820 0.000
#> GSM155452     4   0.293      0.815 0.180 0.000 0.000 0.820 0.000
#> GSM155455     4   0.293      0.815 0.180 0.000 0.000 0.820 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155483     5   0.420      0.681 0.408 0.000 0.000 0.000 0.592
#> GSM155487     2   0.000      0.389 0.000 1.000 0.000 0.000 0.000
#> GSM155491     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155495     5   0.483      0.189 0.028 0.000 0.380 0.000 0.592
#> GSM155499     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155503     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155449     4   0.293      0.815 0.180 0.000 0.000 0.820 0.000
#> GSM155456     4   0.384      0.708 0.308 0.000 0.000 0.692 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155484     5   0.420      0.681 0.408 0.000 0.000 0.000 0.592
#> GSM155488     5   0.000      0.186 0.000 0.000 0.000 0.000 1.000
#> GSM155492     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155500     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155504     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155450     4   0.000      0.724 0.000 0.000 0.000 1.000 0.000
#> GSM155453     4   0.000      0.724 0.000 0.000 0.000 1.000 0.000
#> GSM155457     4   0.384      0.708 0.308 0.000 0.000 0.692 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155485     5   0.420      0.681 0.408 0.000 0.000 0.000 0.592
#> GSM155489     5   0.512      0.598 0.168 0.000 0.136 0.000 0.696
#> GSM155493     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155505     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155451     4   0.000      0.724 0.000 0.000 0.000 1.000 0.000
#> GSM155454     4   0.000      0.724 0.000 0.000 0.000 1.000 0.000
#> GSM155458     4   0.384      0.708 0.308 0.000 0.000 0.692 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155478     2   0.421     -0.063 0.412 0.588 0.000 0.000 0.000
#> GSM155482     2   0.421     -0.063 0.412 0.588 0.000 0.000 0.000
#> GSM155486     5   0.517      0.708 0.356 0.000 0.052 0.000 0.592
#> GSM155490     2   0.000      0.389 0.000 1.000 0.000 0.000 0.000
#> GSM155494     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3   0.000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408
#> GSM155506     2   0.646      0.709 0.000 0.412 0.000 0.180 0.408

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4 p5    p6
#> GSM155448     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155452     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155455     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155483     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155487     6   0.249      0.804 0.000 0.164  0 0.000  0 0.836
#> GSM155491     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155495     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155499     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155503     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155449     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155456     4   0.214      0.837 0.128 0.000  0 0.872  0 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155484     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155488     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155492     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155496     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155500     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155504     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155450     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155453     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155457     4   0.214      0.837 0.128 0.000  0 0.872  0 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155485     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155489     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155493     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155497     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155501     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155505     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155451     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155454     4   0.000      0.941 0.000 0.000  0 1.000  0 0.000
#> GSM155458     4   0.214      0.837 0.128 0.000  0 0.872  0 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000  0 0.000  0 0.000
#> GSM155478     6   0.000      0.942 0.000 0.000  0 0.000  0 1.000
#> GSM155482     6   0.000      0.942 0.000 0.000  0 0.000  0 1.000
#> GSM155486     5   0.000      1.000 0.000 0.000  0 0.000  1 0.000
#> GSM155490     6   0.000      0.942 0.000 0.000  0 0.000  0 1.000
#> GSM155494     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155498     3   0.000      1.000 0.000 0.000  1 0.000  0 0.000
#> GSM155502     2   0.000      1.000 0.000 1.000  0 0.000  0 0.000
#> GSM155506     2   0.000      1.000 0.000 1.000  0 0.000  0 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 time(p) k
#> CV:pam 59   0.753 2
#> CV:pam 57   0.965 3
#> CV:pam 50   0.821 4
#> CV:pam 53   1.000 5
#> CV:pam 59   0.939 6

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


CV:mclust**

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

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

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

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

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

collect_plots(res)

plot of chunk CV-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.483           0.955       0.921         0.4271 0.524   0.524
#> 3 3 0.775           0.909       0.936         0.3344 0.640   0.459
#> 4 4 0.855           0.897       0.927         0.2457 0.742   0.482
#> 5 5 1.000           0.999       0.999         0.0705 0.949   0.824
#> 6 6 1.000           0.990       0.995         0.0374 0.971   0.881

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

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

There is also optional best \(k\) = 5 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
#> GSM155448     2   0.118      0.966 0.016 0.984
#> GSM155452     2   0.118      0.966 0.016 0.984
#> GSM155455     2   0.242      0.947 0.040 0.960
#> GSM155459     1   0.605      0.988 0.852 0.148
#> GSM155463     1   0.605      0.988 0.852 0.148
#> GSM155467     1   0.605      0.988 0.852 0.148
#> GSM155471     1   0.605      0.988 0.852 0.148
#> GSM155475     1   0.605      0.988 0.852 0.148
#> GSM155479     1   0.605      0.988 0.852 0.148
#> GSM155483     2   0.118      0.966 0.016 0.984
#> GSM155487     2   0.605      0.822 0.148 0.852
#> GSM155491     2   0.118      0.966 0.016 0.984
#> GSM155495     2   0.118      0.966 0.016 0.984
#> GSM155499     2   0.000      0.960 0.000 1.000
#> GSM155503     2   0.000      0.960 0.000 1.000
#> GSM155449     2   0.118      0.966 0.016 0.984
#> GSM155456     2   0.563      0.831 0.132 0.868
#> GSM155460     1   0.605      0.988 0.852 0.148
#> GSM155464     1   0.605      0.988 0.852 0.148
#> GSM155468     1   0.605      0.988 0.852 0.148
#> GSM155472     1   0.634      0.715 0.840 0.160
#> GSM155476     1   0.605      0.988 0.852 0.148
#> GSM155480     1   0.605      0.988 0.852 0.148
#> GSM155484     2   0.118      0.966 0.016 0.984
#> GSM155488     2   0.118      0.966 0.016 0.984
#> GSM155492     2   0.118      0.966 0.016 0.984
#> GSM155496     2   0.118      0.966 0.016 0.984
#> GSM155500     2   0.000      0.960 0.000 1.000
#> GSM155504     2   0.000      0.960 0.000 1.000
#> GSM155450     2   0.118      0.966 0.016 0.984
#> GSM155453     2   0.118      0.966 0.016 0.984
#> GSM155457     2   0.402      0.902 0.080 0.920
#> GSM155461     1   0.605      0.988 0.852 0.148
#> GSM155465     1   0.605      0.988 0.852 0.148
#> GSM155469     1   0.605      0.988 0.852 0.148
#> GSM155473     1   0.605      0.988 0.852 0.148
#> GSM155477     1   0.605      0.988 0.852 0.148
#> GSM155481     1   0.605      0.988 0.852 0.148
#> GSM155485     2   0.118      0.966 0.016 0.984
#> GSM155489     2   0.118      0.966 0.016 0.984
#> GSM155493     2   0.118      0.966 0.016 0.984
#> GSM155497     2   0.118      0.966 0.016 0.984
#> GSM155501     2   0.000      0.960 0.000 1.000
#> GSM155505     2   0.000      0.960 0.000 1.000
#> GSM155451     2   0.118      0.966 0.016 0.984
#> GSM155454     2   0.118      0.966 0.016 0.984
#> GSM155458     2   0.242      0.947 0.040 0.960
#> GSM155462     1   0.605      0.988 0.852 0.148
#> GSM155466     1   0.605      0.988 0.852 0.148
#> GSM155470     1   0.605      0.988 0.852 0.148
#> GSM155474     1   0.605      0.988 0.852 0.148
#> GSM155478     2   0.605      0.822 0.148 0.852
#> GSM155482     2   0.605      0.822 0.148 0.852
#> GSM155486     2   0.118      0.966 0.016 0.984
#> GSM155490     2   0.605      0.822 0.148 0.852
#> GSM155494     2   0.118      0.966 0.016 0.984
#> GSM155498     2   0.118      0.966 0.016 0.984
#> GSM155502     2   0.000      0.960 0.000 1.000
#> GSM155506     2   0.000      0.960 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
#> GSM155448     1  0.5426      0.838 0.820 0.092 0.088
#> GSM155452     1  0.5426      0.838 0.820 0.092 0.088
#> GSM155455     1  0.5346      0.841 0.824 0.088 0.088
#> GSM155459     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155483     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155487     2  0.2796      1.000 0.000 0.908 0.092
#> GSM155491     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155495     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155499     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155503     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155449     1  0.5426      0.838 0.820 0.092 0.088
#> GSM155456     1  0.5346      0.841 0.824 0.088 0.088
#> GSM155460     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155472     1  0.0747      0.920 0.984 0.016 0.000
#> GSM155476     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155484     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155488     3  0.0237      0.930 0.000 0.004 0.996
#> GSM155492     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155496     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155500     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155504     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155450     1  0.5426      0.838 0.820 0.092 0.088
#> GSM155453     1  0.5426      0.838 0.820 0.092 0.088
#> GSM155457     1  0.5346      0.841 0.824 0.088 0.088
#> GSM155461     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155485     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155489     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155493     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155497     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155501     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155505     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155451     1  0.5426      0.838 0.820 0.092 0.088
#> GSM155454     1  0.6510      0.770 0.756 0.156 0.088
#> GSM155458     1  0.5346      0.841 0.824 0.088 0.088
#> GSM155462     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.927 1.000 0.000 0.000
#> GSM155478     2  0.2796      1.000 0.000 0.908 0.092
#> GSM155482     2  0.2796      1.000 0.000 0.908 0.092
#> GSM155486     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155490     2  0.2796      1.000 0.000 0.908 0.092
#> GSM155494     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155498     3  0.0000      0.932 0.000 0.000 1.000
#> GSM155502     3  0.4121      0.877 0.000 0.168 0.832
#> GSM155506     3  0.4121      0.877 0.000 0.168 0.832

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155452     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155455     2  0.7627      0.496 0.272 0.472 0.000 0.256
#> GSM155459     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155483     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155487     4  0.2149      1.000 0.000 0.000 0.088 0.912
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155495     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155499     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155503     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155449     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155456     2  0.7627      0.496 0.272 0.472 0.000 0.256
#> GSM155460     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155472     1  0.1302      0.947 0.956 0.000 0.000 0.044
#> GSM155476     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155484     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155488     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155500     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155504     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155450     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155453     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155457     2  0.7627      0.496 0.272 0.472 0.000 0.256
#> GSM155461     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155485     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155489     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155501     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155505     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155451     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155454     2  0.4164      0.735 0.000 0.736 0.000 0.264
#> GSM155458     2  0.7627      0.496 0.272 0.472 0.000 0.256
#> GSM155462     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.998 1.000 0.000 0.000 0.000
#> GSM155478     4  0.2149      1.000 0.000 0.000 0.088 0.912
#> GSM155482     4  0.2149      1.000 0.000 0.000 0.088 0.912
#> GSM155486     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155490     4  0.2149      1.000 0.000 0.000 0.088 0.912
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000 0.000
#> GSM155502     2  0.0817      0.735 0.000 0.976 0.024 0.000
#> GSM155506     2  0.0817      0.735 0.000 0.976 0.024 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1 p2 p3    p4 p5
#> GSM155448     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155452     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155455     4  0.0162      0.996 0.004  0  0 0.996  0
#> GSM155459     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155463     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155467     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155471     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155475     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155479     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155483     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155487     5  0.0000      1.000 0.000  0  0 0.000  1
#> GSM155491     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155495     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155499     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155503     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155449     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155456     4  0.0162      0.996 0.004  0  0 0.996  0
#> GSM155460     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155464     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155468     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155472     1  0.0404      0.988 0.988  0  0 0.012  0
#> GSM155476     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155480     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155484     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155488     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155492     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155496     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155500     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155504     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155450     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155453     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155457     4  0.0162      0.996 0.004  0  0 0.996  0
#> GSM155461     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155465     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155469     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155473     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155477     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155481     1  0.0162      0.995 0.996  0  0 0.004  0
#> GSM155485     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155489     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155493     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155497     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155501     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155505     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155451     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155454     4  0.0000      0.998 0.000  0  0 1.000  0
#> GSM155458     4  0.0162      0.996 0.004  0  0 0.996  0
#> GSM155462     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155466     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155470     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155474     1  0.0000      0.999 1.000  0  0 0.000  0
#> GSM155478     5  0.0000      1.000 0.000  0  0 0.000  1
#> GSM155482     5  0.0000      1.000 0.000  0  0 0.000  1
#> GSM155486     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155490     5  0.0000      1.000 0.000  0  0 0.000  1
#> GSM155494     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155498     3  0.0000      1.000 0.000  0  1 0.000  0
#> GSM155502     2  0.0000      1.000 0.000  1  0 0.000  0
#> GSM155506     2  0.0000      1.000 0.000  1  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1 p2    p3    p4    p5 p6
#> GSM155448     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155452     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155455     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155459     1  0.0146      0.996 0.996  0 0.000 0.004 0.000  0
#> GSM155463     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155467     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155471     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155475     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155479     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155483     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155487     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155491     3  0.0000      0.949 0.000  0 1.000 0.000 0.000  0
#> GSM155495     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155499     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155503     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155449     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155456     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155460     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155464     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155468     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155472     1  0.0260      0.991 0.992  0 0.000 0.008 0.000  0
#> GSM155476     1  0.0146      0.996 0.996  0 0.000 0.004 0.000  0
#> GSM155480     1  0.0146      0.996 0.996  0 0.000 0.004 0.000  0
#> GSM155484     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155488     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155492     3  0.2003      0.878 0.000  0 0.884 0.000 0.116  0
#> GSM155496     3  0.2378      0.844 0.000  0 0.848 0.000 0.152  0
#> GSM155500     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155504     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155450     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155453     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155457     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155461     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155465     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155469     1  0.0146      0.996 0.996  0 0.000 0.004 0.000  0
#> GSM155473     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155477     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155481     1  0.0146      0.996 0.996  0 0.000 0.004 0.000  0
#> GSM155485     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155489     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155493     3  0.0000      0.949 0.000  0 1.000 0.000 0.000  0
#> GSM155497     3  0.0000      0.949 0.000  0 1.000 0.000 0.000  0
#> GSM155501     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155505     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155451     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155454     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155458     4  0.0000      1.000 0.000  0 0.000 1.000 0.000  0
#> GSM155462     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155466     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155470     1  0.0146      0.996 0.996  0 0.000 0.004 0.000  0
#> GSM155474     1  0.0000      0.998 1.000  0 0.000 0.000 0.000  0
#> GSM155478     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155482     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155486     5  0.0000      1.000 0.000  0 0.000 0.000 1.000  0
#> GSM155490     6  0.0000      1.000 0.000  0 0.000 0.000 0.000  1
#> GSM155494     3  0.0000      0.949 0.000  0 1.000 0.000 0.000  0
#> GSM155498     3  0.0000      0.949 0.000  0 1.000 0.000 0.000  0
#> GSM155502     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0
#> GSM155506     2  0.0000      1.000 0.000  1 0.000 0.000 0.000  0

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 time(p) k
#> CV:mclust 59   0.800 2
#> CV:mclust 59   0.377 3
#> CV:mclust 55   0.643 4
#> CV:mclust 59   0.856 5
#> CV:mclust 59   0.939 6

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


CV:NMF*

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

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

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

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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.930           0.957       0.979         0.4947 0.499   0.499
#> 3 3 0.649           0.759       0.852         0.2466 0.777   0.580
#> 4 4 0.897           0.925       0.952         0.1261 0.964   0.894
#> 5 5 0.912           0.908       0.944         0.0909 0.846   0.561
#> 6 6 0.940           0.934       0.941         0.0396 0.972   0.883

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

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

There is also optional best \(k\) = 2 5 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
#> GSM155448     2  0.0000      0.953 0.000 1.000
#> GSM155452     2  0.0000      0.953 0.000 1.000
#> GSM155455     1  0.2423      0.957 0.960 0.040
#> GSM155459     1  0.0000      0.998 1.000 0.000
#> GSM155463     1  0.0000      0.998 1.000 0.000
#> GSM155467     1  0.0000      0.998 1.000 0.000
#> GSM155471     1  0.0000      0.998 1.000 0.000
#> GSM155475     1  0.0000      0.998 1.000 0.000
#> GSM155479     1  0.0000      0.998 1.000 0.000
#> GSM155483     2  0.9427      0.502 0.360 0.640
#> GSM155487     2  0.0000      0.953 0.000 1.000
#> GSM155491     1  0.0000      0.998 1.000 0.000
#> GSM155495     2  0.7602      0.751 0.220 0.780
#> GSM155499     2  0.0000      0.953 0.000 1.000
#> GSM155503     2  0.0000      0.953 0.000 1.000
#> GSM155449     2  0.0000      0.953 0.000 1.000
#> GSM155456     1  0.0000      0.998 1.000 0.000
#> GSM155460     1  0.0000      0.998 1.000 0.000
#> GSM155464     1  0.0000      0.998 1.000 0.000
#> GSM155468     1  0.0000      0.998 1.000 0.000
#> GSM155472     1  0.0000      0.998 1.000 0.000
#> GSM155476     1  0.0000      0.998 1.000 0.000
#> GSM155480     1  0.0000      0.998 1.000 0.000
#> GSM155484     2  0.6887      0.795 0.184 0.816
#> GSM155488     2  0.0000      0.953 0.000 1.000
#> GSM155492     1  0.0000      0.998 1.000 0.000
#> GSM155496     1  0.2043      0.965 0.968 0.032
#> GSM155500     2  0.0000      0.953 0.000 1.000
#> GSM155504     2  0.0000      0.953 0.000 1.000
#> GSM155450     2  0.0000      0.953 0.000 1.000
#> GSM155453     2  0.0000      0.953 0.000 1.000
#> GSM155457     1  0.0000      0.998 1.000 0.000
#> GSM155461     1  0.0000      0.998 1.000 0.000
#> GSM155465     1  0.0000      0.998 1.000 0.000
#> GSM155469     1  0.0000      0.998 1.000 0.000
#> GSM155473     1  0.0000      0.998 1.000 0.000
#> GSM155477     1  0.0000      0.998 1.000 0.000
#> GSM155481     1  0.0000      0.998 1.000 0.000
#> GSM155485     2  0.7883      0.728 0.236 0.764
#> GSM155489     2  0.0000      0.953 0.000 1.000
#> GSM155493     1  0.0000      0.998 1.000 0.000
#> GSM155497     1  0.0000      0.998 1.000 0.000
#> GSM155501     2  0.0000      0.953 0.000 1.000
#> GSM155505     2  0.0000      0.953 0.000 1.000
#> GSM155451     2  0.0000      0.953 0.000 1.000
#> GSM155454     2  0.0000      0.953 0.000 1.000
#> GSM155458     1  0.0000      0.998 1.000 0.000
#> GSM155462     1  0.0000      0.998 1.000 0.000
#> GSM155466     1  0.0000      0.998 1.000 0.000
#> GSM155470     1  0.0000      0.998 1.000 0.000
#> GSM155474     1  0.0000      0.998 1.000 0.000
#> GSM155478     2  0.0672      0.948 0.008 0.992
#> GSM155482     2  0.0672      0.948 0.008 0.992
#> GSM155486     2  0.6048      0.833 0.148 0.852
#> GSM155490     2  0.0376      0.951 0.004 0.996
#> GSM155494     1  0.0000      0.998 1.000 0.000
#> GSM155498     1  0.0000      0.998 1.000 0.000
#> GSM155502     2  0.0000      0.953 0.000 1.000
#> GSM155506     2  0.0000      0.953 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
#> GSM155448     2  0.0000      0.903 0.000 1.000 0.000
#> GSM155452     2  0.1182      0.889 0.012 0.976 0.012
#> GSM155455     1  0.5858      0.597 0.740 0.240 0.020
#> GSM155459     1  0.0237      0.947 0.996 0.000 0.004
#> GSM155463     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155483     3  0.8614      0.607 0.228 0.172 0.600
#> GSM155487     2  0.6274      0.440 0.000 0.544 0.456
#> GSM155491     3  0.6286      0.443 0.464 0.000 0.536
#> GSM155495     3  0.8009      0.504 0.100 0.276 0.624
#> GSM155499     2  0.1411      0.905 0.000 0.964 0.036
#> GSM155503     2  0.1529      0.904 0.000 0.960 0.040
#> GSM155449     2  0.0592      0.899 0.000 0.988 0.012
#> GSM155456     1  0.2486      0.889 0.932 0.060 0.008
#> GSM155460     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155468     1  0.0829      0.940 0.984 0.004 0.012
#> GSM155472     1  0.4485      0.777 0.844 0.020 0.136
#> GSM155476     1  0.1182      0.934 0.976 0.012 0.012
#> GSM155480     1  0.0829      0.940 0.984 0.004 0.012
#> GSM155484     3  0.7104      0.382 0.032 0.360 0.608
#> GSM155488     2  0.4235      0.735 0.000 0.824 0.176
#> GSM155492     3  0.6416      0.571 0.376 0.008 0.616
#> GSM155496     3  0.6398      0.573 0.372 0.008 0.620
#> GSM155500     2  0.1289      0.906 0.000 0.968 0.032
#> GSM155504     2  0.1529      0.904 0.000 0.960 0.040
#> GSM155450     2  0.0592      0.899 0.000 0.988 0.012
#> GSM155453     2  0.0424      0.900 0.000 0.992 0.008
#> GSM155457     1  0.3989      0.806 0.864 0.124 0.012
#> GSM155461     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155469     1  0.0424      0.945 0.992 0.000 0.008
#> GSM155473     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155485     3  0.8230      0.426 0.088 0.348 0.564
#> GSM155489     3  0.6079      0.311 0.000 0.388 0.612
#> GSM155493     3  0.6282      0.563 0.384 0.004 0.612
#> GSM155497     3  0.6079      0.558 0.388 0.000 0.612
#> GSM155501     2  0.1529      0.904 0.000 0.960 0.040
#> GSM155505     2  0.0892      0.906 0.000 0.980 0.020
#> GSM155451     2  0.0747      0.897 0.000 0.984 0.016
#> GSM155454     2  0.0747      0.905 0.000 0.984 0.016
#> GSM155458     1  0.5551      0.652 0.768 0.212 0.020
#> GSM155462     1  0.0237      0.947 0.996 0.000 0.004
#> GSM155466     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.950 1.000 0.000 0.000
#> GSM155478     3  0.9539     -0.116 0.204 0.336 0.460
#> GSM155482     3  0.9479     -0.139 0.192 0.348 0.460
#> GSM155486     3  0.6975      0.384 0.028 0.356 0.616
#> GSM155490     2  0.6280      0.438 0.000 0.540 0.460
#> GSM155494     3  0.6140      0.538 0.404 0.000 0.596
#> GSM155498     3  0.6302      0.409 0.480 0.000 0.520
#> GSM155502     2  0.1529      0.904 0.000 0.960 0.040
#> GSM155506     2  0.1529      0.904 0.000 0.960 0.040

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     2  0.1124      0.918 0.012 0.972 0.004 0.012
#> GSM155452     2  0.2161      0.891 0.048 0.932 0.004 0.016
#> GSM155455     1  0.3829      0.804 0.828 0.152 0.004 0.016
#> GSM155459     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155463     1  0.0707      0.953 0.980 0.000 0.020 0.000
#> GSM155467     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155471     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM155475     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155479     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155483     3  0.1888      0.911 0.000 0.044 0.940 0.016
#> GSM155487     4  0.0592      0.988 0.000 0.016 0.000 0.984
#> GSM155491     3  0.1474      0.895 0.052 0.000 0.948 0.000
#> GSM155495     3  0.0336      0.925 0.000 0.008 0.992 0.000
#> GSM155499     2  0.1888      0.933 0.000 0.940 0.044 0.016
#> GSM155503     2  0.2142      0.929 0.000 0.928 0.056 0.016
#> GSM155449     2  0.1471      0.912 0.024 0.960 0.004 0.012
#> GSM155456     1  0.2457      0.892 0.912 0.076 0.004 0.008
#> GSM155460     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155464     1  0.0336      0.952 0.992 0.000 0.008 0.000
#> GSM155468     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM155472     1  0.1716      0.922 0.936 0.000 0.000 0.064
#> GSM155476     1  0.0469      0.946 0.988 0.012 0.000 0.000
#> GSM155480     1  0.0336      0.948 0.992 0.008 0.000 0.000
#> GSM155484     3  0.2450      0.896 0.000 0.072 0.912 0.016
#> GSM155488     2  0.3390      0.849 0.000 0.852 0.132 0.016
#> GSM155492     3  0.0592      0.925 0.016 0.000 0.984 0.000
#> GSM155496     3  0.0188      0.926 0.004 0.000 0.996 0.000
#> GSM155500     2  0.1975      0.932 0.000 0.936 0.048 0.016
#> GSM155504     2  0.2142      0.929 0.000 0.928 0.056 0.016
#> GSM155450     2  0.2075      0.895 0.044 0.936 0.004 0.016
#> GSM155453     2  0.1985      0.899 0.040 0.940 0.004 0.016
#> GSM155457     1  0.3350      0.846 0.864 0.116 0.004 0.016
#> GSM155461     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155465     1  0.1211      0.951 0.960 0.000 0.040 0.000
#> GSM155469     1  0.0000      0.951 1.000 0.000 0.000 0.000
#> GSM155473     1  0.1211      0.951 0.960 0.000 0.040 0.000
#> GSM155477     1  0.1022      0.952 0.968 0.000 0.032 0.000
#> GSM155481     1  0.0469      0.953 0.988 0.000 0.012 0.000
#> GSM155485     3  0.3335      0.837 0.000 0.128 0.856 0.016
#> GSM155489     3  0.2593      0.889 0.000 0.080 0.904 0.016
#> GSM155493     3  0.0592      0.925 0.016 0.000 0.984 0.000
#> GSM155497     3  0.0895      0.923 0.020 0.000 0.976 0.004
#> GSM155501     2  0.2060      0.931 0.000 0.932 0.052 0.016
#> GSM155505     2  0.1610      0.932 0.000 0.952 0.032 0.016
#> GSM155451     2  0.1114      0.918 0.016 0.972 0.004 0.008
#> GSM155454     2  0.0376      0.923 0.000 0.992 0.004 0.004
#> GSM155458     1  0.3730      0.814 0.836 0.144 0.004 0.016
#> GSM155462     1  0.1302      0.950 0.956 0.000 0.044 0.000
#> GSM155466     1  0.1118      0.952 0.964 0.000 0.036 0.000
#> GSM155470     1  0.0188      0.950 0.996 0.000 0.000 0.004
#> GSM155474     1  0.0188      0.950 0.996 0.000 0.000 0.004
#> GSM155478     4  0.0376      0.990 0.004 0.004 0.000 0.992
#> GSM155482     4  0.0376      0.990 0.004 0.004 0.000 0.992
#> GSM155486     3  0.2450      0.896 0.000 0.072 0.912 0.016
#> GSM155490     4  0.0592      0.988 0.000 0.016 0.000 0.984
#> GSM155494     3  0.1022      0.915 0.032 0.000 0.968 0.000
#> GSM155498     3  0.1743      0.889 0.056 0.000 0.940 0.004
#> GSM155502     2  0.2060      0.931 0.000 0.932 0.052 0.016
#> GSM155506     2  0.2060      0.931 0.000 0.932 0.052 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
#> GSM155448     4  0.3424      0.814 0.000 0.240 0.000 0.760 0.000
#> GSM155452     4  0.0609      0.844 0.000 0.020 0.000 0.980 0.000
#> GSM155455     4  0.1502      0.864 0.004 0.056 0.000 0.940 0.000
#> GSM155459     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0290      0.971 0.992 0.008 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155483     2  0.5588      0.543 0.104 0.604 0.292 0.000 0.000
#> GSM155487     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155491     3  0.0510      0.977 0.016 0.000 0.984 0.000 0.000
#> GSM155495     3  0.0963      0.947 0.000 0.036 0.964 0.000 0.000
#> GSM155499     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155503     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155449     4  0.2813      0.858 0.000 0.168 0.000 0.832 0.000
#> GSM155456     4  0.1608      0.810 0.072 0.000 0.000 0.928 0.000
#> GSM155460     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0290      0.971 0.992 0.008 0.000 0.000 0.000
#> GSM155472     1  0.6092      0.313 0.564 0.000 0.000 0.180 0.256
#> GSM155476     1  0.0703      0.957 0.976 0.024 0.000 0.000 0.000
#> GSM155480     1  0.0510      0.965 0.984 0.016 0.000 0.000 0.000
#> GSM155484     2  0.3772      0.798 0.036 0.792 0.172 0.000 0.000
#> GSM155488     2  0.0963      0.890 0.000 0.964 0.036 0.000 0.000
#> GSM155492     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000
#> GSM155500     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155504     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155450     4  0.1908      0.874 0.000 0.092 0.000 0.908 0.000
#> GSM155453     4  0.2280      0.873 0.000 0.120 0.000 0.880 0.000
#> GSM155457     4  0.1956      0.814 0.076 0.008 0.000 0.916 0.000
#> GSM155461     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0510      0.965 0.984 0.016 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155485     2  0.3115      0.839 0.036 0.852 0.112 0.000 0.000
#> GSM155489     2  0.2561      0.840 0.000 0.856 0.144 0.000 0.000
#> GSM155493     3  0.0162      0.985 0.004 0.000 0.996 0.000 0.000
#> GSM155497     3  0.0324      0.984 0.004 0.000 0.992 0.004 0.000
#> GSM155501     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155505     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155451     4  0.3480      0.809 0.000 0.248 0.000 0.752 0.000
#> GSM155454     4  0.3999      0.668 0.000 0.344 0.000 0.656 0.000
#> GSM155458     4  0.2077      0.873 0.008 0.084 0.000 0.908 0.000
#> GSM155462     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.976 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155482     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155486     2  0.3724      0.778 0.020 0.776 0.204 0.000 0.000
#> GSM155490     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155494     3  0.0162      0.985 0.004 0.000 0.996 0.000 0.000
#> GSM155498     3  0.0671      0.976 0.016 0.000 0.980 0.004 0.000
#> GSM155502     2  0.0162      0.901 0.000 0.996 0.000 0.004 0.000
#> GSM155506     2  0.0162      0.901 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
#> GSM155448     4  0.2617      0.895 0.004 0.080 0.000 0.876 0.040 0.000
#> GSM155452     4  0.0806      0.940 0.000 0.000 0.008 0.972 0.020 0.000
#> GSM155455     4  0.0405      0.946 0.004 0.008 0.000 0.988 0.000 0.000
#> GSM155459     1  0.1155      0.959 0.956 0.000 0.004 0.004 0.036 0.000
#> GSM155463     1  0.0777      0.964 0.972 0.000 0.004 0.000 0.024 0.000
#> GSM155467     1  0.0291      0.969 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM155471     1  0.0146      0.969 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM155475     1  0.0603      0.967 0.980 0.000 0.004 0.000 0.016 0.000
#> GSM155479     1  0.0692      0.967 0.976 0.000 0.000 0.004 0.020 0.000
#> GSM155483     5  0.4063      0.862 0.020 0.052 0.160 0.000 0.768 0.000
#> GSM155487     6  0.0146      0.998 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM155491     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     3  0.3629      0.554 0.000 0.012 0.712 0.000 0.276 0.000
#> GSM155499     2  0.0777      0.972 0.000 0.972 0.000 0.024 0.004 0.000
#> GSM155503     2  0.0520      0.989 0.000 0.984 0.000 0.008 0.008 0.000
#> GSM155449     4  0.3204      0.837 0.004 0.144 0.000 0.820 0.032 0.000
#> GSM155456     4  0.0777      0.935 0.024 0.000 0.000 0.972 0.004 0.000
#> GSM155460     1  0.1082      0.960 0.956 0.000 0.004 0.000 0.040 0.000
#> GSM155464     1  0.0777      0.964 0.972 0.000 0.004 0.000 0.024 0.000
#> GSM155468     1  0.0291      0.969 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM155472     1  0.3991      0.731 0.764 0.000 0.000 0.044 0.016 0.176
#> GSM155476     1  0.1350      0.956 0.952 0.020 0.000 0.008 0.020 0.000
#> GSM155480     1  0.0692      0.967 0.976 0.000 0.000 0.004 0.020 0.000
#> GSM155484     5  0.4093      0.902 0.008 0.088 0.140 0.000 0.764 0.000
#> GSM155488     5  0.3912      0.600 0.000 0.340 0.012 0.000 0.648 0.000
#> GSM155492     3  0.0547      0.929 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM155496     3  0.1349      0.907 0.004 0.000 0.940 0.000 0.056 0.000
#> GSM155500     2  0.0260      0.992 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM155504     2  0.0405      0.987 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM155450     4  0.0767      0.946 0.004 0.012 0.000 0.976 0.008 0.000
#> GSM155453     4  0.1138      0.943 0.000 0.012 0.004 0.960 0.024 0.000
#> GSM155457     4  0.0603      0.941 0.016 0.000 0.000 0.980 0.004 0.000
#> GSM155461     1  0.0603      0.968 0.980 0.000 0.004 0.000 0.016 0.000
#> GSM155465     1  0.0692      0.966 0.976 0.000 0.004 0.000 0.020 0.000
#> GSM155469     1  0.0146      0.969 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM155473     1  0.0291      0.969 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM155477     1  0.0692      0.967 0.976 0.000 0.000 0.004 0.020 0.000
#> GSM155481     1  0.0622      0.967 0.980 0.000 0.000 0.008 0.012 0.000
#> GSM155485     5  0.4002      0.902 0.004 0.096 0.132 0.000 0.768 0.000
#> GSM155489     5  0.4279      0.881 0.000 0.128 0.140 0.000 0.732 0.000
#> GSM155493     3  0.0632      0.927 0.000 0.000 0.976 0.000 0.024 0.000
#> GSM155497     3  0.0547      0.924 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM155501     2  0.0146      0.990 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM155505     2  0.0260      0.992 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM155451     4  0.1268      0.940 0.004 0.036 0.000 0.952 0.008 0.000
#> GSM155454     4  0.2306      0.893 0.000 0.016 0.004 0.888 0.092 0.000
#> GSM155458     4  0.0520      0.946 0.008 0.008 0.000 0.984 0.000 0.000
#> GSM155462     1  0.1956      0.921 0.908 0.000 0.008 0.004 0.080 0.000
#> GSM155466     1  0.0692      0.966 0.976 0.000 0.004 0.000 0.020 0.000
#> GSM155470     1  0.0436      0.969 0.988 0.000 0.004 0.004 0.004 0.000
#> GSM155474     1  0.0405      0.969 0.988 0.000 0.004 0.000 0.008 0.000
#> GSM155478     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155482     6  0.0000      0.998 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155486     5  0.4141      0.902 0.008 0.092 0.140 0.000 0.760 0.000
#> GSM155490     6  0.0146      0.998 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM155494     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3  0.0547      0.921 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM155502     2  0.0260      0.992 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM155506     2  0.0405      0.991 0.000 0.988 0.000 0.008 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-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 time(p) k
#> CV:NMF 59   0.787 2
#> CV:NMF 49   0.999 3
#> CV:NMF 59   0.678 4
#> CV:NMF 58   0.870 5
#> CV:NMF 59   0.945 6

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


MAD:hclust*

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 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.484           0.946       0.887         0.4167 0.509   0.509
#> 3 3 0.843           0.942       0.935         0.4546 0.874   0.752
#> 4 4 0.807           0.932       0.924         0.1559 0.897   0.731
#> 5 5 0.935           0.944       0.964         0.0648 0.974   0.908
#> 6 6 0.947           0.966       0.964         0.0420 0.963   0.853

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

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

There is also optional best \(k\) = 5 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
#> GSM155448     2  0.0376      0.962 0.004 0.996
#> GSM155452     2  0.0376      0.962 0.004 0.996
#> GSM155455     2  0.3733      0.904 0.072 0.928
#> GSM155459     1  0.7376      0.975 0.792 0.208
#> GSM155463     1  0.7376      0.975 0.792 0.208
#> GSM155467     1  0.7376      0.975 0.792 0.208
#> GSM155471     1  0.7376      0.975 0.792 0.208
#> GSM155475     1  0.7376      0.975 0.792 0.208
#> GSM155479     1  0.7376      0.975 0.792 0.208
#> GSM155483     2  0.0000      0.962 0.000 1.000
#> GSM155487     2  0.7056      0.749 0.192 0.808
#> GSM155491     2  0.2423      0.944 0.040 0.960
#> GSM155495     2  0.2423      0.944 0.040 0.960
#> GSM155499     2  0.0000      0.962 0.000 1.000
#> GSM155503     2  0.0000      0.962 0.000 1.000
#> GSM155449     2  0.0376      0.962 0.004 0.996
#> GSM155456     2  0.3733      0.904 0.072 0.928
#> GSM155460     1  0.7376      0.975 0.792 0.208
#> GSM155464     1  0.7376      0.975 0.792 0.208
#> GSM155468     1  0.7376      0.975 0.792 0.208
#> GSM155472     1  0.7376      0.975 0.792 0.208
#> GSM155476     1  0.7376      0.975 0.792 0.208
#> GSM155480     1  0.7376      0.975 0.792 0.208
#> GSM155484     2  0.0000      0.962 0.000 1.000
#> GSM155488     2  0.0000      0.962 0.000 1.000
#> GSM155492     2  0.2423      0.944 0.040 0.960
#> GSM155496     2  0.2423      0.944 0.040 0.960
#> GSM155500     2  0.0000      0.962 0.000 1.000
#> GSM155504     2  0.0000      0.962 0.000 1.000
#> GSM155450     2  0.0376      0.962 0.004 0.996
#> GSM155453     2  0.0376      0.962 0.004 0.996
#> GSM155457     2  0.3733      0.904 0.072 0.928
#> GSM155461     1  0.7376      0.975 0.792 0.208
#> GSM155465     1  0.7376      0.975 0.792 0.208
#> GSM155469     1  0.7376      0.975 0.792 0.208
#> GSM155473     1  0.7376      0.975 0.792 0.208
#> GSM155477     1  0.7376      0.975 0.792 0.208
#> GSM155481     1  0.7376      0.975 0.792 0.208
#> GSM155485     2  0.0000      0.962 0.000 1.000
#> GSM155489     2  0.0000      0.962 0.000 1.000
#> GSM155493     2  0.2423      0.944 0.040 0.960
#> GSM155497     2  0.2423      0.944 0.040 0.960
#> GSM155501     2  0.0000      0.962 0.000 1.000
#> GSM155505     2  0.0000      0.962 0.000 1.000
#> GSM155451     2  0.0376      0.962 0.004 0.996
#> GSM155454     2  0.0376      0.962 0.004 0.996
#> GSM155458     2  0.3733      0.904 0.072 0.928
#> GSM155462     1  0.7376      0.975 0.792 0.208
#> GSM155466     1  0.7376      0.975 0.792 0.208
#> GSM155470     1  0.7376      0.975 0.792 0.208
#> GSM155474     1  0.7376      0.975 0.792 0.208
#> GSM155478     1  0.2423      0.737 0.960 0.040
#> GSM155482     1  0.2423      0.737 0.960 0.040
#> GSM155486     2  0.0000      0.962 0.000 1.000
#> GSM155490     2  0.7056      0.749 0.192 0.808
#> GSM155494     2  0.2423      0.944 0.040 0.960
#> GSM155498     2  0.2423      0.944 0.040 0.960
#> GSM155502     2  0.0000      0.962 0.000 1.000
#> GSM155506     2  0.0000      0.962 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
#> GSM155448     2   0.118      0.947 0.012 0.976 0.012
#> GSM155452     2   0.118      0.947 0.012 0.976 0.012
#> GSM155455     2   0.312      0.901 0.080 0.908 0.012
#> GSM155459     1   0.000      0.971 1.000 0.000 0.000
#> GSM155463     1   0.000      0.971 1.000 0.000 0.000
#> GSM155467     1   0.000      0.971 1.000 0.000 0.000
#> GSM155471     1   0.000      0.971 1.000 0.000 0.000
#> GSM155475     1   0.000      0.971 1.000 0.000 0.000
#> GSM155479     1   0.000      0.971 1.000 0.000 0.000
#> GSM155483     2   0.186      0.934 0.000 0.948 0.052
#> GSM155487     2   0.529      0.743 0.000 0.732 0.268
#> GSM155491     3   0.510      1.000 0.248 0.000 0.752
#> GSM155495     3   0.510      1.000 0.248 0.000 0.752
#> GSM155499     2   0.000      0.948 0.000 1.000 0.000
#> GSM155503     2   0.000      0.948 0.000 1.000 0.000
#> GSM155449     2   0.118      0.947 0.012 0.976 0.012
#> GSM155456     2   0.312      0.901 0.080 0.908 0.012
#> GSM155460     1   0.000      0.971 1.000 0.000 0.000
#> GSM155464     1   0.000      0.971 1.000 0.000 0.000
#> GSM155468     1   0.000      0.971 1.000 0.000 0.000
#> GSM155472     1   0.000      0.971 1.000 0.000 0.000
#> GSM155476     1   0.000      0.971 1.000 0.000 0.000
#> GSM155480     1   0.000      0.971 1.000 0.000 0.000
#> GSM155484     2   0.186      0.934 0.000 0.948 0.052
#> GSM155488     2   0.186      0.934 0.000 0.948 0.052
#> GSM155492     3   0.510      1.000 0.248 0.000 0.752
#> GSM155496     3   0.510      1.000 0.248 0.000 0.752
#> GSM155500     2   0.000      0.948 0.000 1.000 0.000
#> GSM155504     2   0.000      0.948 0.000 1.000 0.000
#> GSM155450     2   0.118      0.947 0.012 0.976 0.012
#> GSM155453     2   0.118      0.947 0.012 0.976 0.012
#> GSM155457     2   0.312      0.901 0.080 0.908 0.012
#> GSM155461     1   0.000      0.971 1.000 0.000 0.000
#> GSM155465     1   0.000      0.971 1.000 0.000 0.000
#> GSM155469     1   0.000      0.971 1.000 0.000 0.000
#> GSM155473     1   0.000      0.971 1.000 0.000 0.000
#> GSM155477     1   0.000      0.971 1.000 0.000 0.000
#> GSM155481     1   0.000      0.971 1.000 0.000 0.000
#> GSM155485     2   0.186      0.934 0.000 0.948 0.052
#> GSM155489     2   0.186      0.934 0.000 0.948 0.052
#> GSM155493     3   0.510      1.000 0.248 0.000 0.752
#> GSM155497     3   0.510      1.000 0.248 0.000 0.752
#> GSM155501     2   0.000      0.948 0.000 1.000 0.000
#> GSM155505     2   0.000      0.948 0.000 1.000 0.000
#> GSM155451     2   0.118      0.947 0.012 0.976 0.012
#> GSM155454     2   0.118      0.947 0.012 0.976 0.012
#> GSM155458     2   0.312      0.901 0.080 0.908 0.012
#> GSM155462     1   0.000      0.971 1.000 0.000 0.000
#> GSM155466     1   0.000      0.971 1.000 0.000 0.000
#> GSM155470     1   0.000      0.971 1.000 0.000 0.000
#> GSM155474     1   0.000      0.971 1.000 0.000 0.000
#> GSM155478     1   0.510      0.653 0.752 0.000 0.248
#> GSM155482     1   0.510      0.653 0.752 0.000 0.248
#> GSM155486     2   0.186      0.934 0.000 0.948 0.052
#> GSM155490     2   0.529      0.743 0.000 0.732 0.268
#> GSM155494     3   0.510      1.000 0.248 0.000 0.752
#> GSM155498     3   0.510      1.000 0.248 0.000 0.752
#> GSM155502     2   0.000      0.948 0.000 1.000 0.000
#> GSM155506     2   0.000      0.948 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
#> GSM155448     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155452     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155455     4   0.179      0.928 0.068 0.000 0.000 0.932
#> GSM155459     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155483     2   0.000      0.883 0.000 1.000 0.000 0.000
#> GSM155487     2   0.376      0.748 0.000 0.784 0.216 0.000
#> GSM155491     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155495     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155499     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155503     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155449     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155456     4   0.179      0.928 0.068 0.000 0.000 0.932
#> GSM155460     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155484     2   0.000      0.883 0.000 1.000 0.000 0.000
#> GSM155488     2   0.000      0.883 0.000 1.000 0.000 0.000
#> GSM155492     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155496     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155500     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155504     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155450     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155453     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155457     4   0.179      0.928 0.068 0.000 0.000 0.932
#> GSM155461     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155485     2   0.000      0.883 0.000 1.000 0.000 0.000
#> GSM155489     2   0.000      0.883 0.000 1.000 0.000 0.000
#> GSM155493     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155497     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155501     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155505     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155451     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155454     4   0.000      0.960 0.000 0.000 0.000 1.000
#> GSM155458     4   0.179      0.928 0.068 0.000 0.000 0.932
#> GSM155462     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.971 1.000 0.000 0.000 0.000
#> GSM155478     1   0.404      0.653 0.752 0.000 0.248 0.000
#> GSM155482     1   0.404      0.653 0.752 0.000 0.248 0.000
#> GSM155486     2   0.000      0.883 0.000 1.000 0.000 0.000
#> GSM155490     2   0.376      0.748 0.000 0.784 0.216 0.000
#> GSM155494     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155498     3   0.404      1.000 0.248 0.000 0.752 0.000
#> GSM155502     2   0.317      0.886 0.000 0.840 0.000 0.160
#> GSM155506     2   0.317      0.886 0.000 0.840 0.000 0.160

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> GSM155448     4  0.0404      0.942 0.000 0.000  0 0.988 0.012
#> GSM155452     4  0.0404      0.942 0.000 0.000  0 0.988 0.012
#> GSM155455     4  0.1544      0.911 0.068 0.000  0 0.932 0.000
#> GSM155459     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155463     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155467     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155471     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155475     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155479     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155483     2  0.0000      0.858 0.000 1.000  0 0.000 0.000
#> GSM155487     2  0.3242      0.650 0.000 0.784  0 0.000 0.216
#> GSM155491     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155495     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155499     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155503     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155449     4  0.0404      0.942 0.000 0.000  0 0.988 0.012
#> GSM155456     4  0.1544      0.911 0.068 0.000  0 0.932 0.000
#> GSM155460     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155464     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155468     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155472     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155476     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155480     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155484     2  0.0000      0.858 0.000 1.000  0 0.000 0.000
#> GSM155488     2  0.0000      0.858 0.000 1.000  0 0.000 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155500     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155504     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155450     4  0.0000      0.947 0.000 0.000  0 1.000 0.000
#> GSM155453     4  0.0000      0.947 0.000 0.000  0 1.000 0.000
#> GSM155457     4  0.1544      0.911 0.068 0.000  0 0.932 0.000
#> GSM155461     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155465     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155469     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155473     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155477     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155481     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155485     2  0.0000      0.858 0.000 1.000  0 0.000 0.000
#> GSM155489     2  0.0000      0.858 0.000 1.000  0 0.000 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155501     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155505     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155451     4  0.0000      0.947 0.000 0.000  0 1.000 0.000
#> GSM155454     4  0.0000      0.947 0.000 0.000  0 1.000 0.000
#> GSM155458     4  0.1544      0.911 0.068 0.000  0 0.932 0.000
#> GSM155462     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155466     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155470     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155474     1  0.0000      1.000 1.000 0.000  0 0.000 0.000
#> GSM155478     5  0.0404      1.000 0.012 0.000  0 0.000 0.988
#> GSM155482     5  0.0404      1.000 0.012 0.000  0 0.000 0.988
#> GSM155486     2  0.0000      0.858 0.000 1.000  0 0.000 0.000
#> GSM155490     2  0.3242      0.650 0.000 0.784  0 0.000 0.216
#> GSM155494     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155502     2  0.2997      0.874 0.000 0.840  0 0.148 0.012
#> GSM155506     2  0.2997      0.874 0.000 0.840  0 0.148 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4    p5    p6
#> GSM155448     4  0.2378      0.887 0.000 0.152  0 0.848 0.000 0.000
#> GSM155452     4  0.2378      0.887 0.000 0.152  0 0.848 0.000 0.000
#> GSM155455     4  0.0458      0.909 0.016 0.000  0 0.984 0.000 0.000
#> GSM155459     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155463     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155467     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155471     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155475     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155479     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155483     5  0.2823      0.918 0.000 0.204  0 0.000 0.796 0.000
#> GSM155487     5  0.1180      0.722 0.000 0.012  0 0.016 0.960 0.012
#> GSM155491     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155495     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155499     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155449     4  0.2378      0.887 0.000 0.152  0 0.848 0.000 0.000
#> GSM155456     4  0.0458      0.909 0.016 0.000  0 0.984 0.000 0.000
#> GSM155460     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155464     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155468     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155472     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155476     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155480     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155484     5  0.2823      0.918 0.000 0.204  0 0.000 0.796 0.000
#> GSM155488     5  0.2823      0.918 0.000 0.204  0 0.000 0.796 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155500     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155450     4  0.1501      0.931 0.000 0.076  0 0.924 0.000 0.000
#> GSM155453     4  0.1501      0.931 0.000 0.076  0 0.924 0.000 0.000
#> GSM155457     4  0.0458      0.909 0.016 0.000  0 0.984 0.000 0.000
#> GSM155461     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155465     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155469     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155473     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155477     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155481     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155485     5  0.2823      0.918 0.000 0.204  0 0.000 0.796 0.000
#> GSM155489     5  0.2823      0.918 0.000 0.204  0 0.000 0.796 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155501     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155451     4  0.1501      0.931 0.000 0.076  0 0.924 0.000 0.000
#> GSM155454     4  0.1501      0.931 0.000 0.076  0 0.924 0.000 0.000
#> GSM155458     4  0.0458      0.909 0.016 0.000  0 0.984 0.000 0.000
#> GSM155462     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155466     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155470     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155474     1  0.0000      1.000 1.000 0.000  0 0.000 0.000 0.000
#> GSM155478     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> GSM155482     6  0.0000      1.000 0.000 0.000  0 0.000 0.000 1.000
#> GSM155486     5  0.2823      0.918 0.000 0.204  0 0.000 0.796 0.000
#> GSM155490     5  0.1180      0.722 0.000 0.012  0 0.016 0.960 0.012
#> GSM155494     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155502     2  0.0000      1.000 0.000 1.000  0 0.000 0.000 0.000
#> GSM155506     2  0.0000      1.000 0.000 1.000  0 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-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 time(p) k
#> MAD:hclust 59   0.998 2
#> MAD:hclust 59   1.000 3
#> MAD:hclust 59   1.000 4
#> MAD:hclust 59   0.877 5
#> MAD:hclust 59   0.965 6

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


MAD:kmeans

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.369           0.872       0.894         0.4468 0.544   0.544
#> 3 3 0.599           0.871       0.876         0.3941 0.784   0.608
#> 4 4 0.659           0.690       0.766         0.1295 0.932   0.809
#> 5 5 0.737           0.739       0.783         0.0792 0.939   0.806
#> 6 6 0.795           0.764       0.782         0.0456 0.936   0.766

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
#> GSM155448     2  0.5408      0.967 0.124 0.876
#> GSM155452     2  0.5408      0.967 0.124 0.876
#> GSM155455     2  0.8713      0.762 0.292 0.708
#> GSM155459     1  0.0000      0.891 1.000 0.000
#> GSM155463     1  0.0000      0.891 1.000 0.000
#> GSM155467     1  0.0000      0.891 1.000 0.000
#> GSM155471     1  0.0000      0.891 1.000 0.000
#> GSM155475     1  0.0000      0.891 1.000 0.000
#> GSM155479     1  0.0000      0.891 1.000 0.000
#> GSM155483     1  0.7883      0.777 0.764 0.236
#> GSM155487     2  0.3879      0.928 0.076 0.924
#> GSM155491     1  0.8327      0.771 0.736 0.264
#> GSM155495     1  0.8327      0.771 0.736 0.264
#> GSM155499     2  0.5408      0.967 0.124 0.876
#> GSM155503     2  0.5408      0.967 0.124 0.876
#> GSM155449     2  0.5408      0.967 0.124 0.876
#> GSM155456     1  0.0000      0.891 1.000 0.000
#> GSM155460     1  0.0000      0.891 1.000 0.000
#> GSM155464     1  0.0000      0.891 1.000 0.000
#> GSM155468     1  0.0000      0.891 1.000 0.000
#> GSM155472     1  0.0000      0.891 1.000 0.000
#> GSM155476     1  0.0000      0.891 1.000 0.000
#> GSM155480     1  0.0000      0.891 1.000 0.000
#> GSM155484     1  0.8443      0.743 0.728 0.272
#> GSM155488     2  0.3431      0.903 0.064 0.936
#> GSM155492     1  0.8327      0.771 0.736 0.264
#> GSM155496     1  0.8327      0.771 0.736 0.264
#> GSM155500     2  0.5408      0.967 0.124 0.876
#> GSM155504     2  0.5408      0.967 0.124 0.876
#> GSM155450     2  0.5408      0.967 0.124 0.876
#> GSM155453     2  0.5408      0.967 0.124 0.876
#> GSM155457     1  0.0376      0.889 0.996 0.004
#> GSM155461     1  0.0000      0.891 1.000 0.000
#> GSM155465     1  0.0000      0.891 1.000 0.000
#> GSM155469     1  0.0000      0.891 1.000 0.000
#> GSM155473     1  0.0000      0.891 1.000 0.000
#> GSM155477     1  0.0000      0.891 1.000 0.000
#> GSM155481     1  0.0000      0.891 1.000 0.000
#> GSM155485     1  0.8443      0.743 0.728 0.272
#> GSM155489     1  0.9087      0.667 0.676 0.324
#> GSM155493     1  0.8327      0.771 0.736 0.264
#> GSM155497     1  0.8327      0.771 0.736 0.264
#> GSM155501     2  0.5408      0.967 0.124 0.876
#> GSM155505     2  0.5408      0.967 0.124 0.876
#> GSM155451     2  0.5408      0.967 0.124 0.876
#> GSM155454     2  0.5408      0.967 0.124 0.876
#> GSM155458     2  0.8713      0.762 0.292 0.708
#> GSM155462     1  0.0000      0.891 1.000 0.000
#> GSM155466     1  0.0000      0.891 1.000 0.000
#> GSM155470     1  0.0000      0.891 1.000 0.000
#> GSM155474     1  0.0000      0.891 1.000 0.000
#> GSM155478     1  0.6712      0.725 0.824 0.176
#> GSM155482     1  0.6712      0.725 0.824 0.176
#> GSM155486     1  0.8443      0.743 0.728 0.272
#> GSM155490     2  0.3879      0.928 0.076 0.924
#> GSM155494     1  0.8327      0.771 0.736 0.264
#> GSM155498     1  0.8327      0.771 0.736 0.264
#> GSM155502     2  0.5408      0.967 0.124 0.876
#> GSM155506     2  0.5408      0.967 0.124 0.876

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM155448     2   0.369      0.849 0.016 0.884 0.100
#> GSM155452     2   0.369      0.849 0.016 0.884 0.100
#> GSM155455     2   0.721      0.666 0.192 0.708 0.100
#> GSM155459     1   0.000      0.961 1.000 0.000 0.000
#> GSM155463     1   0.000      0.961 1.000 0.000 0.000
#> GSM155467     1   0.000      0.961 1.000 0.000 0.000
#> GSM155471     1   0.000      0.961 1.000 0.000 0.000
#> GSM155475     1   0.000      0.961 1.000 0.000 0.000
#> GSM155479     1   0.000      0.961 1.000 0.000 0.000
#> GSM155483     3   0.723      0.854 0.188 0.104 0.708
#> GSM155487     2   0.304      0.849 0.000 0.896 0.104
#> GSM155491     3   0.568      0.884 0.236 0.016 0.748
#> GSM155495     3   0.512      0.876 0.188 0.016 0.796
#> GSM155499     2   0.377      0.860 0.016 0.880 0.104
#> GSM155503     2   0.377      0.860 0.016 0.880 0.104
#> GSM155449     2   0.369      0.849 0.016 0.884 0.100
#> GSM155456     1   0.589      0.739 0.796 0.104 0.100
#> GSM155460     1   0.000      0.961 1.000 0.000 0.000
#> GSM155464     1   0.000      0.961 1.000 0.000 0.000
#> GSM155468     1   0.000      0.961 1.000 0.000 0.000
#> GSM155472     1   0.000      0.961 1.000 0.000 0.000
#> GSM155476     1   0.000      0.961 1.000 0.000 0.000
#> GSM155480     1   0.000      0.961 1.000 0.000 0.000
#> GSM155484     3   0.723      0.854 0.188 0.104 0.708
#> GSM155488     3   0.649      0.106 0.004 0.456 0.540
#> GSM155492     3   0.568      0.884 0.236 0.016 0.748
#> GSM155496     3   0.568      0.884 0.236 0.016 0.748
#> GSM155500     2   0.377      0.860 0.016 0.880 0.104
#> GSM155504     2   0.377      0.860 0.016 0.880 0.104
#> GSM155450     2   0.369      0.849 0.016 0.884 0.100
#> GSM155453     2   0.369      0.849 0.016 0.884 0.100
#> GSM155457     1   0.596      0.735 0.792 0.108 0.100
#> GSM155461     1   0.000      0.961 1.000 0.000 0.000
#> GSM155465     1   0.000      0.961 1.000 0.000 0.000
#> GSM155469     1   0.000      0.961 1.000 0.000 0.000
#> GSM155473     1   0.000      0.961 1.000 0.000 0.000
#> GSM155477     1   0.000      0.961 1.000 0.000 0.000
#> GSM155481     1   0.000      0.961 1.000 0.000 0.000
#> GSM155485     3   0.723      0.854 0.188 0.104 0.708
#> GSM155489     3   0.734      0.804 0.144 0.148 0.708
#> GSM155493     3   0.568      0.884 0.236 0.016 0.748
#> GSM155497     3   0.568      0.884 0.236 0.016 0.748
#> GSM155501     2   0.377      0.860 0.016 0.880 0.104
#> GSM155505     2   0.377      0.860 0.016 0.880 0.104
#> GSM155451     2   0.369      0.849 0.016 0.884 0.100
#> GSM155454     2   0.369      0.849 0.016 0.884 0.100
#> GSM155458     2   0.721      0.666 0.192 0.708 0.100
#> GSM155462     1   0.000      0.961 1.000 0.000 0.000
#> GSM155466     1   0.000      0.961 1.000 0.000 0.000
#> GSM155470     1   0.000      0.961 1.000 0.000 0.000
#> GSM155474     1   0.000      0.961 1.000 0.000 0.000
#> GSM155478     1   0.559      0.778 0.808 0.068 0.124
#> GSM155482     1   0.559      0.778 0.808 0.068 0.124
#> GSM155486     3   0.723      0.854 0.188 0.104 0.708
#> GSM155490     2   0.460      0.787 0.000 0.796 0.204
#> GSM155494     3   0.568      0.884 0.236 0.016 0.748
#> GSM155498     3   0.568      0.884 0.236 0.016 0.748
#> GSM155502     2   0.377      0.860 0.016 0.880 0.104
#> GSM155506     2   0.377      0.860 0.016 0.880 0.104

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155452     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155455     4  0.7866      0.462 0.144 0.284 0.036 0.536
#> GSM155459     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155463     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155467     1  0.0188      0.899 0.996 0.000 0.000 0.004
#> GSM155471     1  0.0336      0.899 0.992 0.000 0.000 0.008
#> GSM155475     1  0.0817      0.896 0.976 0.000 0.000 0.024
#> GSM155479     1  0.0921      0.895 0.972 0.000 0.000 0.028
#> GSM155483     3  0.8054      0.774 0.076 0.160 0.580 0.184
#> GSM155487     2  0.1510      0.634 0.000 0.956 0.016 0.028
#> GSM155491     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155495     3  0.4452      0.849 0.080 0.048 0.836 0.036
#> GSM155499     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155503     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155449     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155456     4  0.5894      0.589 0.428 0.000 0.036 0.536
#> GSM155460     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155464     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155468     1  0.0000      0.899 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0779      0.896 0.980 0.000 0.004 0.016
#> GSM155476     1  0.0817      0.896 0.976 0.000 0.000 0.024
#> GSM155480     1  0.0921      0.895 0.972 0.000 0.000 0.028
#> GSM155484     3  0.8054      0.774 0.076 0.160 0.580 0.184
#> GSM155488     2  0.7268     -0.187 0.000 0.516 0.312 0.172
#> GSM155492     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155496     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155500     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155504     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155450     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155453     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155457     4  0.6058      0.596 0.424 0.004 0.036 0.536
#> GSM155461     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155465     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155469     1  0.0000      0.899 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0336      0.899 0.992 0.000 0.000 0.008
#> GSM155477     1  0.0817      0.896 0.976 0.000 0.000 0.024
#> GSM155481     1  0.0921      0.895 0.972 0.000 0.000 0.028
#> GSM155485     3  0.8054      0.774 0.076 0.160 0.580 0.184
#> GSM155489     3  0.7711      0.721 0.036 0.200 0.580 0.184
#> GSM155493     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155497     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155501     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155505     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155451     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155454     2  0.4985      0.306 0.000 0.532 0.000 0.468
#> GSM155458     4  0.7885      0.472 0.148 0.280 0.036 0.536
#> GSM155462     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155466     1  0.2473      0.873 0.908 0.000 0.012 0.080
#> GSM155470     1  0.0000      0.899 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0336      0.899 0.992 0.000 0.000 0.008
#> GSM155478     1  0.7060      0.153 0.544 0.016 0.088 0.352
#> GSM155482     1  0.7060      0.153 0.544 0.016 0.088 0.352
#> GSM155486     3  0.8054      0.774 0.076 0.160 0.580 0.184
#> GSM155490     2  0.6607      0.234 0.000 0.516 0.084 0.400
#> GSM155494     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155498     3  0.3266      0.860 0.108 0.024 0.868 0.000
#> GSM155502     2  0.0336      0.657 0.000 0.992 0.008 0.000
#> GSM155506     2  0.0336      0.657 0.000 0.992 0.008 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
#> GSM155448     4  0.0162     0.7699 0.000 0.000 0.004 0.996 0.000
#> GSM155452     4  0.0162     0.7699 0.000 0.000 0.004 0.996 0.000
#> GSM155455     4  0.5945     0.6632 0.092 0.028 0.008 0.664 0.208
#> GSM155459     1  0.3700     0.7966 0.752 0.008 0.000 0.000 0.240
#> GSM155463     1  0.3480     0.7969 0.752 0.000 0.000 0.000 0.248
#> GSM155467     1  0.0566     0.8530 0.984 0.012 0.000 0.000 0.004
#> GSM155471     1  0.0000     0.8544 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0963     0.8509 0.964 0.036 0.000 0.000 0.000
#> GSM155479     1  0.1357     0.8473 0.948 0.048 0.000 0.000 0.004
#> GSM155483     3  0.6856     0.5959 0.004 0.220 0.444 0.004 0.328
#> GSM155487     2  0.4538     0.8326 0.000 0.636 0.012 0.348 0.004
#> GSM155491     3  0.0404     0.7717 0.012 0.000 0.988 0.000 0.000
#> GSM155495     3  0.3266     0.7491 0.008 0.032 0.852 0.000 0.108
#> GSM155499     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155503     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155449     4  0.0162     0.7699 0.000 0.000 0.004 0.996 0.000
#> GSM155456     4  0.6969     0.5745 0.208 0.028 0.008 0.548 0.208
#> GSM155460     1  0.3508     0.7958 0.748 0.000 0.000 0.000 0.252
#> GSM155464     1  0.3480     0.7969 0.752 0.000 0.000 0.000 0.248
#> GSM155468     1  0.0609     0.8540 0.980 0.000 0.000 0.000 0.020
#> GSM155472     1  0.1549     0.8490 0.944 0.040 0.000 0.000 0.016
#> GSM155476     1  0.1484     0.8462 0.944 0.048 0.000 0.000 0.008
#> GSM155480     1  0.1484     0.8462 0.944 0.048 0.000 0.000 0.008
#> GSM155484     3  0.6856     0.5959 0.004 0.220 0.444 0.004 0.328
#> GSM155488     2  0.6234     0.0669 0.000 0.540 0.132 0.008 0.320
#> GSM155492     3  0.0404     0.7717 0.012 0.000 0.988 0.000 0.000
#> GSM155496     3  0.0693     0.7714 0.012 0.008 0.980 0.000 0.000
#> GSM155500     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155504     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155450     4  0.0000     0.7702 0.000 0.000 0.000 1.000 0.000
#> GSM155453     4  0.0000     0.7702 0.000 0.000 0.000 1.000 0.000
#> GSM155457     4  0.6969     0.5745 0.208 0.028 0.008 0.548 0.208
#> GSM155461     1  0.3700     0.7966 0.752 0.008 0.000 0.000 0.240
#> GSM155465     1  0.3480     0.7969 0.752 0.000 0.000 0.000 0.248
#> GSM155469     1  0.0609     0.8540 0.980 0.000 0.000 0.000 0.020
#> GSM155473     1  0.0000     0.8544 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.1484     0.8462 0.944 0.048 0.000 0.000 0.008
#> GSM155481     1  0.1357     0.8473 0.948 0.048 0.000 0.000 0.004
#> GSM155485     3  0.6856     0.5959 0.004 0.220 0.444 0.004 0.328
#> GSM155489     3  0.6865     0.5929 0.004 0.224 0.444 0.004 0.324
#> GSM155493     3  0.0404     0.7717 0.012 0.000 0.988 0.000 0.000
#> GSM155497     3  0.1413     0.7704 0.012 0.020 0.956 0.000 0.012
#> GSM155501     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155505     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155451     4  0.0000     0.7702 0.000 0.000 0.000 1.000 0.000
#> GSM155454     4  0.0000     0.7702 0.000 0.000 0.000 1.000 0.000
#> GSM155458     4  0.5945     0.6632 0.092 0.028 0.008 0.664 0.208
#> GSM155462     1  0.3700     0.7966 0.752 0.008 0.000 0.000 0.240
#> GSM155466     1  0.3480     0.7969 0.752 0.000 0.000 0.000 0.248
#> GSM155470     1  0.0609     0.8540 0.980 0.000 0.000 0.000 0.020
#> GSM155474     1  0.0000     0.8544 1.000 0.000 0.000 0.000 0.000
#> GSM155478     1  0.7475     0.2559 0.376 0.232 0.000 0.040 0.352
#> GSM155482     1  0.7475     0.2559 0.376 0.232 0.000 0.040 0.352
#> GSM155486     3  0.6856     0.5959 0.004 0.220 0.444 0.004 0.328
#> GSM155490     2  0.5064     0.1706 0.000 0.552 0.004 0.028 0.416
#> GSM155494     3  0.1095     0.7709 0.012 0.008 0.968 0.000 0.012
#> GSM155498     3  0.1413     0.7704 0.012 0.020 0.956 0.000 0.012
#> GSM155502     2  0.4430     0.8447 0.000 0.628 0.012 0.360 0.000
#> GSM155506     2  0.4430     0.8447 0.000 0.628 0.012 0.360 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
#> GSM155448     4  0.6696      0.750 0.000 0.272 0.000 0.492 0.148 0.088
#> GSM155452     4  0.6696      0.750 0.000 0.272 0.000 0.492 0.148 0.088
#> GSM155455     4  0.1152      0.579 0.004 0.044 0.000 0.952 0.000 0.000
#> GSM155459     1  0.1850      0.576 0.924 0.000 0.000 0.008 0.016 0.052
#> GSM155463     1  0.1757      0.578 0.928 0.000 0.000 0.008 0.012 0.052
#> GSM155467     1  0.5685      0.753 0.628 0.000 0.004 0.072 0.232 0.064
#> GSM155471     1  0.5500      0.754 0.636 0.000 0.000 0.068 0.232 0.064
#> GSM155475     1  0.6102      0.738 0.576 0.000 0.004 0.072 0.260 0.088
#> GSM155479     1  0.6184      0.735 0.568 0.000 0.004 0.072 0.260 0.096
#> GSM155483     5  0.5510      0.849 0.012 0.080 0.344 0.008 0.556 0.000
#> GSM155487     2  0.1176      0.948 0.000 0.956 0.000 0.024 0.020 0.000
#> GSM155491     3  0.0520      0.928 0.008 0.008 0.984 0.000 0.000 0.000
#> GSM155495     3  0.4057      0.494 0.008 0.008 0.740 0.008 0.224 0.012
#> GSM155499     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155503     2  0.0260      0.990 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM155449     4  0.6696      0.750 0.000 0.272 0.000 0.492 0.148 0.088
#> GSM155456     4  0.0937      0.526 0.040 0.000 0.000 0.960 0.000 0.000
#> GSM155460     1  0.1850      0.576 0.924 0.000 0.000 0.008 0.016 0.052
#> GSM155464     1  0.1757      0.578 0.928 0.000 0.000 0.008 0.012 0.052
#> GSM155468     1  0.5610      0.754 0.636 0.000 0.004 0.072 0.228 0.060
#> GSM155472     1  0.6184      0.736 0.568 0.000 0.004 0.072 0.260 0.096
#> GSM155476     1  0.6184      0.735 0.568 0.000 0.004 0.072 0.260 0.096
#> GSM155480     1  0.6184      0.735 0.568 0.000 0.004 0.072 0.260 0.096
#> GSM155484     5  0.5510      0.849 0.012 0.080 0.344 0.008 0.556 0.000
#> GSM155488     5  0.4847      0.363 0.000 0.404 0.036 0.012 0.548 0.000
#> GSM155492     3  0.0520      0.928 0.008 0.008 0.984 0.000 0.000 0.000
#> GSM155496     3  0.1140      0.924 0.008 0.008 0.964 0.008 0.000 0.012
#> GSM155500     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155504     2  0.0260      0.990 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM155450     4  0.6577      0.763 0.000 0.272 0.008 0.528 0.084 0.108
#> GSM155453     4  0.6577      0.763 0.000 0.272 0.008 0.528 0.084 0.108
#> GSM155457     4  0.0937      0.526 0.040 0.000 0.000 0.960 0.000 0.000
#> GSM155461     1  0.1850      0.576 0.924 0.000 0.000 0.008 0.016 0.052
#> GSM155465     1  0.1757      0.578 0.928 0.000 0.000 0.008 0.012 0.052
#> GSM155469     1  0.5610      0.754 0.636 0.000 0.004 0.072 0.228 0.060
#> GSM155473     1  0.5500      0.754 0.636 0.000 0.000 0.068 0.232 0.064
#> GSM155477     1  0.6184      0.735 0.568 0.000 0.004 0.072 0.260 0.096
#> GSM155481     1  0.6184      0.735 0.568 0.000 0.004 0.072 0.260 0.096
#> GSM155485     5  0.5510      0.849 0.012 0.080 0.344 0.008 0.556 0.000
#> GSM155489     5  0.5379      0.830 0.000 0.092 0.336 0.012 0.560 0.000
#> GSM155493     3  0.0520      0.928 0.008 0.008 0.984 0.000 0.000 0.000
#> GSM155497     3  0.1780      0.917 0.008 0.008 0.932 0.008 0.000 0.044
#> GSM155501     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2  0.0260      0.990 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM155451     4  0.6577      0.763 0.000 0.272 0.008 0.528 0.084 0.108
#> GSM155454     4  0.6577      0.763 0.000 0.272 0.008 0.528 0.084 0.108
#> GSM155458     4  0.1010      0.572 0.004 0.036 0.000 0.960 0.000 0.000
#> GSM155462     1  0.1850      0.576 0.924 0.000 0.000 0.008 0.016 0.052
#> GSM155466     1  0.1757      0.578 0.928 0.000 0.000 0.008 0.012 0.052
#> GSM155470     1  0.5610      0.754 0.636 0.000 0.004 0.072 0.228 0.060
#> GSM155474     1  0.5500      0.754 0.636 0.000 0.000 0.068 0.232 0.064
#> GSM155478     6  0.4211      0.808 0.128 0.000 0.000 0.092 0.016 0.764
#> GSM155482     6  0.4211      0.808 0.128 0.000 0.000 0.092 0.016 0.764
#> GSM155486     5  0.5510      0.849 0.012 0.080 0.344 0.008 0.556 0.000
#> GSM155490     6  0.5608      0.527 0.000 0.132 0.000 0.060 0.156 0.652
#> GSM155494     3  0.1210      0.924 0.008 0.008 0.960 0.004 0.000 0.020
#> GSM155498     3  0.1780      0.917 0.008 0.008 0.932 0.008 0.000 0.044
#> GSM155502     2  0.0000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2  0.0260      0.990 0.000 0.992 0.000 0.000 0.008 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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 time(p) k
#> MAD:kmeans 59   0.795 2
#> MAD:kmeans 58   0.951 3
#> MAD:kmeans 46   0.985 4
#> MAD:kmeans 55   1.000 5
#> MAD:kmeans 57   0.775 6

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


MAD:skmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-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.991       0.995         0.5076 0.493   0.493
#> 3 3 1.000           0.980       0.991         0.3019 0.787   0.593
#> 4 4 1.000           0.964       0.977         0.1068 0.908   0.739
#> 5 5 0.886           0.842       0.887         0.0477 0.933   0.763
#> 6 6 0.829           0.855       0.904         0.0468 0.984   0.931

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
#> GSM155448     2  0.0000      0.992 0.000 1.000
#> GSM155452     2  0.0000      0.992 0.000 1.000
#> GSM155455     1  0.2043      0.969 0.968 0.032
#> GSM155459     1  0.0000      0.997 1.000 0.000
#> GSM155463     1  0.0000      0.997 1.000 0.000
#> GSM155467     1  0.0000      0.997 1.000 0.000
#> GSM155471     1  0.0000      0.997 1.000 0.000
#> GSM155475     1  0.0000      0.997 1.000 0.000
#> GSM155479     1  0.0000      0.997 1.000 0.000
#> GSM155483     2  0.0000      0.992 0.000 1.000
#> GSM155487     2  0.0000      0.992 0.000 1.000
#> GSM155491     2  0.2043      0.974 0.032 0.968
#> GSM155495     2  0.0000      0.992 0.000 1.000
#> GSM155499     2  0.0000      0.992 0.000 1.000
#> GSM155503     2  0.0000      0.992 0.000 1.000
#> GSM155449     2  0.0000      0.992 0.000 1.000
#> GSM155456     1  0.0000      0.997 1.000 0.000
#> GSM155460     1  0.0000      0.997 1.000 0.000
#> GSM155464     1  0.0000      0.997 1.000 0.000
#> GSM155468     1  0.0000      0.997 1.000 0.000
#> GSM155472     1  0.0000      0.997 1.000 0.000
#> GSM155476     1  0.0000      0.997 1.000 0.000
#> GSM155480     1  0.0000      0.997 1.000 0.000
#> GSM155484     2  0.0000      0.992 0.000 1.000
#> GSM155488     2  0.0000      0.992 0.000 1.000
#> GSM155492     2  0.2043      0.974 0.032 0.968
#> GSM155496     2  0.2043      0.974 0.032 0.968
#> GSM155500     2  0.0000      0.992 0.000 1.000
#> GSM155504     2  0.0000      0.992 0.000 1.000
#> GSM155450     2  0.0000      0.992 0.000 1.000
#> GSM155453     2  0.0000      0.992 0.000 1.000
#> GSM155457     1  0.0672      0.991 0.992 0.008
#> GSM155461     1  0.0000      0.997 1.000 0.000
#> GSM155465     1  0.0000      0.997 1.000 0.000
#> GSM155469     1  0.0000      0.997 1.000 0.000
#> GSM155473     1  0.0000      0.997 1.000 0.000
#> GSM155477     1  0.0000      0.997 1.000 0.000
#> GSM155481     1  0.0000      0.997 1.000 0.000
#> GSM155485     2  0.0000      0.992 0.000 1.000
#> GSM155489     2  0.0000      0.992 0.000 1.000
#> GSM155493     2  0.2043      0.974 0.032 0.968
#> GSM155497     2  0.2043      0.974 0.032 0.968
#> GSM155501     2  0.0000      0.992 0.000 1.000
#> GSM155505     2  0.0000      0.992 0.000 1.000
#> GSM155451     2  0.0000      0.992 0.000 1.000
#> GSM155454     2  0.0000      0.992 0.000 1.000
#> GSM155458     1  0.2043      0.969 0.968 0.032
#> GSM155462     1  0.0000      0.997 1.000 0.000
#> GSM155466     1  0.0000      0.997 1.000 0.000
#> GSM155470     1  0.0000      0.997 1.000 0.000
#> GSM155474     1  0.0000      0.997 1.000 0.000
#> GSM155478     1  0.0000      0.997 1.000 0.000
#> GSM155482     1  0.0000      0.997 1.000 0.000
#> GSM155486     2  0.0000      0.992 0.000 1.000
#> GSM155490     2  0.0000      0.992 0.000 1.000
#> GSM155494     2  0.2043      0.974 0.032 0.968
#> GSM155498     2  0.2043      0.974 0.032 0.968
#> GSM155502     2  0.0000      0.992 0.000 1.000
#> GSM155506     2  0.0000      0.992 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
#> GSM155448     2   0.000      0.987 0.000 1.000  0
#> GSM155452     2   0.000      0.987 0.000 1.000  0
#> GSM155455     2   0.000      0.987 0.000 1.000  0
#> GSM155459     1   0.000      0.987 1.000 0.000  0
#> GSM155463     1   0.000      0.987 1.000 0.000  0
#> GSM155467     1   0.000      0.987 1.000 0.000  0
#> GSM155471     1   0.000      0.987 1.000 0.000  0
#> GSM155475     1   0.000      0.987 1.000 0.000  0
#> GSM155479     1   0.000      0.987 1.000 0.000  0
#> GSM155483     3   0.000      1.000 0.000 0.000  1
#> GSM155487     2   0.000      0.987 0.000 1.000  0
#> GSM155491     3   0.000      1.000 0.000 0.000  1
#> GSM155495     3   0.000      1.000 0.000 0.000  1
#> GSM155499     2   0.000      0.987 0.000 1.000  0
#> GSM155503     2   0.000      0.987 0.000 1.000  0
#> GSM155449     2   0.000      0.987 0.000 1.000  0
#> GSM155456     1   0.000      0.987 1.000 0.000  0
#> GSM155460     1   0.000      0.987 1.000 0.000  0
#> GSM155464     1   0.000      0.987 1.000 0.000  0
#> GSM155468     1   0.000      0.987 1.000 0.000  0
#> GSM155472     1   0.000      0.987 1.000 0.000  0
#> GSM155476     1   0.000      0.987 1.000 0.000  0
#> GSM155480     1   0.000      0.987 1.000 0.000  0
#> GSM155484     3   0.000      1.000 0.000 0.000  1
#> GSM155488     3   0.000      1.000 0.000 0.000  1
#> GSM155492     3   0.000      1.000 0.000 0.000  1
#> GSM155496     3   0.000      1.000 0.000 0.000  1
#> GSM155500     2   0.000      0.987 0.000 1.000  0
#> GSM155504     2   0.000      0.987 0.000 1.000  0
#> GSM155450     2   0.000      0.987 0.000 1.000  0
#> GSM155453     2   0.000      0.987 0.000 1.000  0
#> GSM155457     2   0.475      0.726 0.216 0.784  0
#> GSM155461     1   0.000      0.987 1.000 0.000  0
#> GSM155465     1   0.000      0.987 1.000 0.000  0
#> GSM155469     1   0.000      0.987 1.000 0.000  0
#> GSM155473     1   0.000      0.987 1.000 0.000  0
#> GSM155477     1   0.000      0.987 1.000 0.000  0
#> GSM155481     1   0.000      0.987 1.000 0.000  0
#> GSM155485     3   0.000      1.000 0.000 0.000  1
#> GSM155489     3   0.000      1.000 0.000 0.000  1
#> GSM155493     3   0.000      1.000 0.000 0.000  1
#> GSM155497     3   0.000      1.000 0.000 0.000  1
#> GSM155501     2   0.000      0.987 0.000 1.000  0
#> GSM155505     2   0.000      0.987 0.000 1.000  0
#> GSM155451     2   0.000      0.987 0.000 1.000  0
#> GSM155454     2   0.000      0.987 0.000 1.000  0
#> GSM155458     2   0.000      0.987 0.000 1.000  0
#> GSM155462     1   0.000      0.987 1.000 0.000  0
#> GSM155466     1   0.000      0.987 1.000 0.000  0
#> GSM155470     1   0.000      0.987 1.000 0.000  0
#> GSM155474     1   0.000      0.987 1.000 0.000  0
#> GSM155478     1   0.382      0.831 0.852 0.148  0
#> GSM155482     1   0.382      0.831 0.852 0.148  0
#> GSM155486     3   0.000      1.000 0.000 0.000  1
#> GSM155490     2   0.000      0.987 0.000 1.000  0
#> GSM155494     3   0.000      1.000 0.000 0.000  1
#> GSM155498     3   0.000      1.000 0.000 0.000  1
#> GSM155502     2   0.000      0.987 0.000 1.000  0
#> GSM155506     2   0.000      0.987 0.000 1.000  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette   p1    p2    p3    p4
#> GSM155448     4  0.1302      0.973 0.00 0.044 0.000 0.956
#> GSM155452     4  0.0921      0.983 0.00 0.028 0.000 0.972
#> GSM155455     4  0.0000      0.974 0.00 0.000 0.000 1.000
#> GSM155459     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155483     3  0.1637      0.962 0.00 0.060 0.940 0.000
#> GSM155487     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155491     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155495     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155499     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155503     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155449     4  0.1302      0.973 0.00 0.044 0.000 0.956
#> GSM155456     4  0.0707      0.954 0.02 0.000 0.000 0.980
#> GSM155460     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155484     3  0.1637      0.962 0.00 0.060 0.940 0.000
#> GSM155488     2  0.0921      0.948 0.00 0.972 0.028 0.000
#> GSM155492     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155496     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155500     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155504     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155450     4  0.0921      0.983 0.00 0.028 0.000 0.972
#> GSM155453     4  0.0921      0.983 0.00 0.028 0.000 0.972
#> GSM155457     4  0.0000      0.974 0.00 0.000 0.000 1.000
#> GSM155461     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155485     3  0.1637      0.962 0.00 0.060 0.940 0.000
#> GSM155489     3  0.1637      0.962 0.00 0.060 0.940 0.000
#> GSM155493     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155497     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155501     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155505     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155451     4  0.0921      0.983 0.00 0.028 0.000 0.972
#> GSM155454     4  0.0921      0.983 0.00 0.028 0.000 0.972
#> GSM155458     4  0.0000      0.974 0.00 0.000 0.000 1.000
#> GSM155462     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.974 1.00 0.000 0.000 0.000
#> GSM155478     1  0.5256      0.613 0.70 0.260 0.000 0.040
#> GSM155482     1  0.5256      0.613 0.70 0.260 0.000 0.040
#> GSM155486     3  0.1637      0.962 0.00 0.060 0.940 0.000
#> GSM155490     2  0.0000      0.976 0.00 1.000 0.000 0.000
#> GSM155494     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155498     3  0.0000      0.977 0.00 0.000 1.000 0.000
#> GSM155502     2  0.0707      0.992 0.00 0.980 0.000 0.020
#> GSM155506     2  0.0707      0.992 0.00 0.980 0.000 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
#> GSM155448     4  0.1671      0.953 0.000 0.076 0.000 0.924 0.000
#> GSM155452     4  0.1478      0.958 0.000 0.064 0.000 0.936 0.000
#> GSM155455     4  0.0609      0.931 0.000 0.000 0.020 0.980 0.000
#> GSM155459     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155463     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155467     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0162      0.952 0.996 0.000 0.004 0.000 0.000
#> GSM155475     1  0.1952      0.925 0.912 0.004 0.084 0.000 0.000
#> GSM155479     1  0.2068      0.921 0.904 0.004 0.092 0.000 0.000
#> GSM155483     5  0.0000      0.853 0.000 0.000 0.000 0.000 1.000
#> GSM155487     2  0.1952      0.869 0.000 0.912 0.084 0.004 0.000
#> GSM155491     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155495     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155499     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155503     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155449     4  0.1671      0.953 0.000 0.076 0.000 0.924 0.000
#> GSM155456     4  0.1568      0.893 0.036 0.000 0.020 0.944 0.000
#> GSM155460     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155464     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155468     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.2068      0.921 0.904 0.004 0.092 0.000 0.000
#> GSM155476     1  0.2068      0.921 0.904 0.004 0.092 0.000 0.000
#> GSM155480     1  0.2068      0.921 0.904 0.004 0.092 0.000 0.000
#> GSM155484     5  0.0000      0.853 0.000 0.000 0.000 0.000 1.000
#> GSM155488     5  0.4150      0.223 0.000 0.388 0.000 0.000 0.612
#> GSM155492     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155496     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155500     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155504     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155450     4  0.1478      0.958 0.000 0.064 0.000 0.936 0.000
#> GSM155453     4  0.1478      0.958 0.000 0.064 0.000 0.936 0.000
#> GSM155457     4  0.0609      0.931 0.000 0.000 0.020 0.980 0.000
#> GSM155461     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155465     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155469     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0162      0.952 0.996 0.000 0.004 0.000 0.000
#> GSM155477     1  0.2068      0.921 0.904 0.004 0.092 0.000 0.000
#> GSM155481     1  0.2068      0.921 0.904 0.004 0.092 0.000 0.000
#> GSM155485     5  0.0000      0.853 0.000 0.000 0.000 0.000 1.000
#> GSM155489     5  0.0000      0.853 0.000 0.000 0.000 0.000 1.000
#> GSM155493     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155497     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155501     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155505     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155451     4  0.1544      0.957 0.000 0.068 0.000 0.932 0.000
#> GSM155454     4  0.1608      0.955 0.000 0.072 0.000 0.928 0.000
#> GSM155458     4  0.0609      0.931 0.000 0.000 0.020 0.980 0.000
#> GSM155462     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155466     1  0.1121      0.945 0.956 0.000 0.044 0.000 0.000
#> GSM155470     1  0.0000      0.952 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0162      0.952 0.996 0.000 0.004 0.000 0.000
#> GSM155478     3  0.7800     -0.135 0.328 0.272 0.340 0.060 0.000
#> GSM155482     3  0.7800     -0.135 0.328 0.272 0.340 0.060 0.000
#> GSM155486     5  0.0000      0.853 0.000 0.000 0.000 0.000 1.000
#> GSM155490     2  0.4877      0.643 0.000 0.692 0.236 0.000 0.072
#> GSM155494     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155498     3  0.4161      0.656 0.000 0.000 0.608 0.000 0.392
#> GSM155502     2  0.0963      0.953 0.000 0.964 0.000 0.036 0.000
#> GSM155506     2  0.0963      0.953 0.000 0.964 0.000 0.036 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
#> GSM155448     4  0.2320      0.890 0.000 0.132 0.000 0.864 0.000 0.004
#> GSM155452     4  0.2003      0.901 0.000 0.116 0.000 0.884 0.000 0.000
#> GSM155455     4  0.2474      0.827 0.000 0.004 0.000 0.884 0.032 0.080
#> GSM155459     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155463     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155467     1  0.0363      0.834 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM155471     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155475     1  0.3201      0.731 0.780 0.000 0.000 0.000 0.012 0.208
#> GSM155479     1  0.3287      0.723 0.768 0.000 0.000 0.000 0.012 0.220
#> GSM155483     5  0.1753      0.973 0.000 0.004 0.084 0.000 0.912 0.000
#> GSM155487     2  0.3198      0.575 0.000 0.740 0.000 0.000 0.000 0.260
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155499     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155449     4  0.2320      0.890 0.000 0.132 0.000 0.864 0.000 0.004
#> GSM155456     4  0.2474      0.824 0.004 0.000 0.000 0.884 0.032 0.080
#> GSM155460     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155464     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155468     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155472     1  0.3470      0.697 0.740 0.000 0.000 0.000 0.012 0.248
#> GSM155476     1  0.3470      0.697 0.740 0.000 0.000 0.000 0.012 0.248
#> GSM155480     1  0.3445      0.701 0.744 0.000 0.000 0.000 0.012 0.244
#> GSM155484     5  0.1753      0.973 0.000 0.004 0.084 0.000 0.912 0.000
#> GSM155488     5  0.1663      0.859 0.000 0.088 0.000 0.000 0.912 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155500     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155450     4  0.1957      0.901 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM155453     4  0.1957      0.901 0.000 0.112 0.000 0.888 0.000 0.000
#> GSM155457     4  0.2474      0.824 0.004 0.000 0.000 0.884 0.032 0.080
#> GSM155461     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155465     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155469     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155473     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155477     1  0.3470      0.697 0.740 0.000 0.000 0.000 0.012 0.248
#> GSM155481     1  0.3287      0.723 0.768 0.000 0.000 0.000 0.012 0.220
#> GSM155485     5  0.1753      0.973 0.000 0.004 0.084 0.000 0.912 0.000
#> GSM155489     5  0.1753      0.973 0.000 0.004 0.084 0.000 0.912 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155451     4  0.2003      0.901 0.000 0.116 0.000 0.884 0.000 0.000
#> GSM155454     4  0.2003      0.901 0.000 0.116 0.000 0.884 0.000 0.000
#> GSM155458     4  0.2474      0.827 0.000 0.004 0.000 0.884 0.032 0.080
#> GSM155462     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155466     1  0.2889      0.808 0.856 0.000 0.000 0.004 0.044 0.096
#> GSM155470     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155474     1  0.0260      0.835 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155478     6  0.2100      0.720 0.112 0.004 0.000 0.000 0.000 0.884
#> GSM155482     6  0.2100      0.720 0.112 0.004 0.000 0.000 0.000 0.884
#> GSM155486     5  0.1753      0.973 0.000 0.004 0.084 0.000 0.912 0.000
#> GSM155490     6  0.4437      0.127 0.000 0.392 0.000 0.000 0.032 0.576
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2  0.0000      0.961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2  0.0000      0.961 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-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 time(p) k
#> MAD:skmeans 59   0.997 2
#> MAD:skmeans 59   0.953 3
#> MAD:skmeans 59   1.000 4
#> MAD:skmeans 56   1.000 5
#> MAD:skmeans 58   0.927 6

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


MAD:pam**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 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.00           0.968       0.986         0.4534 0.556   0.556
#> 3 3  1.00           0.957       0.984         0.3835 0.825   0.685
#> 4 4  1.00           0.975       0.992         0.0811 0.915   0.783
#> 5 5  0.99           0.957       0.983         0.0943 0.925   0.770
#> 6 6  0.99           0.961       0.984         0.0444 0.967   0.873

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

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

There is also optional best \(k\) = 2 3 4 5 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
#> GSM155448     2  0.0000      1.000 0.000 1.000
#> GSM155452     2  0.0000      1.000 0.000 1.000
#> GSM155455     1  0.0376      0.976 0.996 0.004
#> GSM155459     1  0.0000      0.979 1.000 0.000
#> GSM155463     1  0.0000      0.979 1.000 0.000
#> GSM155467     1  0.0000      0.979 1.000 0.000
#> GSM155471     1  0.0000      0.979 1.000 0.000
#> GSM155475     1  0.0000      0.979 1.000 0.000
#> GSM155479     1  0.0000      0.979 1.000 0.000
#> GSM155483     1  0.0000      0.979 1.000 0.000
#> GSM155487     2  0.0000      1.000 0.000 1.000
#> GSM155491     1  0.0000      0.979 1.000 0.000
#> GSM155495     1  0.7056      0.767 0.808 0.192
#> GSM155499     2  0.0000      1.000 0.000 1.000
#> GSM155503     2  0.0000      1.000 0.000 1.000
#> GSM155449     2  0.0000      1.000 0.000 1.000
#> GSM155456     1  0.0000      0.979 1.000 0.000
#> GSM155460     1  0.0000      0.979 1.000 0.000
#> GSM155464     1  0.0000      0.979 1.000 0.000
#> GSM155468     1  0.0000      0.979 1.000 0.000
#> GSM155472     1  0.0000      0.979 1.000 0.000
#> GSM155476     1  0.0000      0.979 1.000 0.000
#> GSM155480     1  0.0000      0.979 1.000 0.000
#> GSM155484     1  0.7528      0.732 0.784 0.216
#> GSM155488     2  0.0000      1.000 0.000 1.000
#> GSM155492     1  0.0000      0.979 1.000 0.000
#> GSM155496     1  0.0000      0.979 1.000 0.000
#> GSM155500     2  0.0000      1.000 0.000 1.000
#> GSM155504     2  0.0000      1.000 0.000 1.000
#> GSM155450     2  0.0000      1.000 0.000 1.000
#> GSM155453     2  0.0000      1.000 0.000 1.000
#> GSM155457     1  0.0000      0.979 1.000 0.000
#> GSM155461     1  0.0000      0.979 1.000 0.000
#> GSM155465     1  0.0000      0.979 1.000 0.000
#> GSM155469     1  0.0000      0.979 1.000 0.000
#> GSM155473     1  0.0000      0.979 1.000 0.000
#> GSM155477     1  0.0000      0.979 1.000 0.000
#> GSM155481     1  0.0000      0.979 1.000 0.000
#> GSM155485     1  0.0000      0.979 1.000 0.000
#> GSM155489     2  0.0000      1.000 0.000 1.000
#> GSM155493     1  0.0000      0.979 1.000 0.000
#> GSM155497     1  0.0000      0.979 1.000 0.000
#> GSM155501     2  0.0000      1.000 0.000 1.000
#> GSM155505     2  0.0000      1.000 0.000 1.000
#> GSM155451     2  0.0000      1.000 0.000 1.000
#> GSM155454     2  0.0000      1.000 0.000 1.000
#> GSM155458     1  0.0000      0.979 1.000 0.000
#> GSM155462     1  0.0000      0.979 1.000 0.000
#> GSM155466     1  0.0000      0.979 1.000 0.000
#> GSM155470     1  0.0000      0.979 1.000 0.000
#> GSM155474     1  0.0000      0.979 1.000 0.000
#> GSM155478     1  0.0000      0.979 1.000 0.000
#> GSM155482     1  0.0000      0.979 1.000 0.000
#> GSM155486     1  0.9635      0.393 0.612 0.388
#> GSM155490     2  0.0000      1.000 0.000 1.000
#> GSM155494     1  0.0000      0.979 1.000 0.000
#> GSM155498     1  0.0000      0.979 1.000 0.000
#> GSM155502     2  0.0000      1.000 0.000 1.000
#> GSM155506     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
#> GSM155448     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155452     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155455     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155459     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155463     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155467     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155471     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155475     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155479     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155483     1  0.5591     0.5796 0.696 0.000 0.304
#> GSM155487     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155491     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155495     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155499     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155503     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155449     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155456     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155460     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155464     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155468     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155472     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155476     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155480     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155484     3  0.0237     0.9950 0.004 0.000 0.996
#> GSM155488     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155492     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155496     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155500     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155504     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155450     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155453     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155457     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155461     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155465     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155469     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155473     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155477     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155481     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155485     1  0.4399     0.7709 0.812 0.000 0.188
#> GSM155489     2  0.6299     0.0989 0.000 0.524 0.476
#> GSM155493     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155497     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155501     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155505     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155451     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155454     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155458     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155462     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155466     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155470     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155474     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155478     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155482     1  0.0000     0.9829 1.000 0.000 0.000
#> GSM155486     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155490     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155494     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155498     3  0.0000     0.9994 0.000 0.000 1.000
#> GSM155502     2  0.0000     0.9732 0.000 1.000 0.000
#> GSM155506     2  0.0000     0.9732 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
#> GSM155448     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155452     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155455     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155459     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155463     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155467     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155471     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155475     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155479     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155483     4  0.0000      0.914  0 0.00 0.000 1.000
#> GSM155487     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155491     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155495     4  0.0188      0.911  0 0.00 0.004 0.996
#> GSM155499     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155503     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155449     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155456     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155460     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155464     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155468     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155472     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155476     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155480     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155484     4  0.0000      0.914  0 0.00 0.000 1.000
#> GSM155488     4  0.0000      0.914  0 0.00 0.000 1.000
#> GSM155492     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155496     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155500     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155504     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155450     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155453     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155457     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155461     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155465     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155469     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155473     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155477     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155481     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155485     4  0.0000      0.914  0 0.00 0.000 1.000
#> GSM155489     4  0.0000      0.914  0 0.00 0.000 1.000
#> GSM155493     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155497     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155501     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155505     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155451     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155454     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155458     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155462     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155466     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155470     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155474     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155478     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155482     1  0.0000      1.000  1 0.00 0.000 0.000
#> GSM155486     4  0.0000      0.914  0 0.00 0.000 1.000
#> GSM155490     4  0.4977      0.149  0 0.46 0.000 0.540
#> GSM155494     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155498     3  0.0000      1.000  0 0.00 1.000 0.000
#> GSM155502     2  0.0000      1.000  0 1.00 0.000 0.000
#> GSM155506     2  0.0000      1.000  0 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
#> GSM155448     4  0.2179      0.881 0.00 0.112 0.000 0.888 0.000
#> GSM155452     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155455     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155459     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155483     5  0.0000      0.928 0.00 0.000 0.000 0.000 1.000
#> GSM155487     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155491     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155495     5  0.0162      0.925 0.00 0.000 0.004 0.000 0.996
#> GSM155499     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155449     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155456     1  0.2929      0.794 0.82 0.000 0.000 0.180 0.000
#> GSM155460     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155484     5  0.0000      0.928 0.00 0.000 0.000 0.000 1.000
#> GSM155488     5  0.0000      0.928 0.00 0.000 0.000 0.000 1.000
#> GSM155492     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155500     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155450     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155453     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155457     1  0.2929      0.794 0.82 0.000 0.000 0.180 0.000
#> GSM155461     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155485     5  0.0000      0.928 0.00 0.000 0.000 0.000 1.000
#> GSM155489     5  0.0000      0.928 0.00 0.000 0.000 0.000 1.000
#> GSM155493     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155501     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155451     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155454     4  0.1965      0.898 0.00 0.096 0.000 0.904 0.000
#> GSM155458     4  0.0000      0.971 0.00 0.000 0.000 1.000 0.000
#> GSM155462     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155478     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155482     1  0.0000      0.985 1.00 0.000 0.000 0.000 0.000
#> GSM155486     5  0.0000      0.928 0.00 0.000 0.000 0.000 1.000
#> GSM155490     5  0.4287      0.148 0.00 0.460 0.000 0.000 0.540
#> GSM155494     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.00 0.000 1.000 0.000 0.000
#> GSM155502     2  0.0000      1.000 0.00 1.000 0.000 0.000 0.000
#> GSM155506     2  0.0000      1.000 0.00 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
#> GSM155448     4  0.2730      0.756 0.0 0.192 0.000 0.808 0.000  0
#> GSM155452     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155455     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155459     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155463     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155467     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155471     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155475     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155479     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155483     5  0.0000      0.999 0.0 0.000 0.000 0.000 1.000  0
#> GSM155487     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155491     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155495     5  0.0146      0.995 0.0 0.000 0.004 0.000 0.996  0
#> GSM155499     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155503     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155449     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155456     1  0.3409      0.600 0.7 0.000 0.000 0.300 0.000  0
#> GSM155460     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155464     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155468     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155472     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155476     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155480     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155484     5  0.0000      0.999 0.0 0.000 0.000 0.000 1.000  0
#> GSM155488     5  0.0000      0.999 0.0 0.000 0.000 0.000 1.000  0
#> GSM155492     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155496     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155500     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155504     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155450     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155453     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155457     1  0.3409      0.600 0.7 0.000 0.000 0.300 0.000  0
#> GSM155461     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155465     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155469     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155473     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155477     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155481     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155485     5  0.0000      0.999 0.0 0.000 0.000 0.000 1.000  0
#> GSM155489     5  0.0000      0.999 0.0 0.000 0.000 0.000 1.000  0
#> GSM155493     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155497     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155501     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155505     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155451     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155454     4  0.2597      0.777 0.0 0.176 0.000 0.824 0.000  0
#> GSM155458     4  0.0000      0.941 0.0 0.000 0.000 1.000 0.000  0
#> GSM155462     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155466     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155470     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155474     1  0.0000      0.971 1.0 0.000 0.000 0.000 0.000  0
#> GSM155478     6  0.0000      1.000 0.0 0.000 0.000 0.000 0.000  1
#> GSM155482     6  0.0000      1.000 0.0 0.000 0.000 0.000 0.000  1
#> GSM155486     5  0.0000      0.999 0.0 0.000 0.000 0.000 1.000  0
#> GSM155490     6  0.0000      1.000 0.0 0.000 0.000 0.000 0.000  1
#> GSM155494     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155498     3  0.0000      1.000 0.0 0.000 1.000 0.000 0.000  0
#> GSM155502     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0
#> GSM155506     2  0.0000      1.000 0.0 1.000 0.000 0.000 0.000  0

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 time(p) k
#> MAD:pam 58   0.982 2
#> MAD:pam 58   0.995 3
#> MAD:pam 58   0.998 4
#> MAD:pam 58   0.998 5
#> MAD:pam 59   0.658 6

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


MAD:mclust**

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

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

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

res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#>   On a matrix with 51941 rows and 59 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 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 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           0.997       0.998         0.4770 0.524   0.524
#> 3 3     1           0.973       0.980         0.3529 0.833   0.681
#> 4 4     1           0.961       0.981         0.1298 0.863   0.641
#> 5 5     1           0.979       0.984         0.0571 0.915   0.708
#> 6 6     1           0.988       0.993         0.0249 0.982   0.923

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

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

There is also optional best \(k\) = 2 3 4 5 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
#> GSM155448     2   0.000      0.997 0.000 1.000
#> GSM155452     2   0.000      0.997 0.000 1.000
#> GSM155455     2   0.000      0.997 0.000 1.000
#> GSM155459     1   0.000      1.000 1.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000
#> GSM155483     2   0.000      0.997 0.000 1.000
#> GSM155487     2   0.000      0.997 0.000 1.000
#> GSM155491     2   0.000      0.997 0.000 1.000
#> GSM155495     2   0.000      0.997 0.000 1.000
#> GSM155499     2   0.000      0.997 0.000 1.000
#> GSM155503     2   0.000      0.997 0.000 1.000
#> GSM155449     2   0.000      0.997 0.000 1.000
#> GSM155456     2   0.000      0.997 0.000 1.000
#> GSM155460     1   0.000      1.000 1.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000
#> GSM155484     2   0.000      0.997 0.000 1.000
#> GSM155488     2   0.000      0.997 0.000 1.000
#> GSM155492     2   0.000      0.997 0.000 1.000
#> GSM155496     2   0.000      0.997 0.000 1.000
#> GSM155500     2   0.000      0.997 0.000 1.000
#> GSM155504     2   0.000      0.997 0.000 1.000
#> GSM155450     2   0.000      0.997 0.000 1.000
#> GSM155453     2   0.000      0.997 0.000 1.000
#> GSM155457     2   0.000      0.997 0.000 1.000
#> GSM155461     1   0.000      1.000 1.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000
#> GSM155485     2   0.000      0.997 0.000 1.000
#> GSM155489     2   0.000      0.997 0.000 1.000
#> GSM155493     2   0.000      0.997 0.000 1.000
#> GSM155497     2   0.000      0.997 0.000 1.000
#> GSM155501     2   0.000      0.997 0.000 1.000
#> GSM155505     2   0.000      0.997 0.000 1.000
#> GSM155451     2   0.000      0.997 0.000 1.000
#> GSM155454     2   0.000      0.997 0.000 1.000
#> GSM155458     2   0.000      0.997 0.000 1.000
#> GSM155462     1   0.000      1.000 1.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000
#> GSM155478     2   0.278      0.951 0.048 0.952
#> GSM155482     2   0.278      0.951 0.048 0.952
#> GSM155486     2   0.000      0.997 0.000 1.000
#> GSM155490     2   0.000      0.997 0.000 1.000
#> GSM155494     2   0.000      0.997 0.000 1.000
#> GSM155498     2   0.000      0.997 0.000 1.000
#> GSM155502     2   0.000      0.997 0.000 1.000
#> GSM155506     2   0.000      0.997 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
#> GSM155448     2   0.000      1.000 0.000 1.000 0.000
#> GSM155452     2   0.000      1.000 0.000 1.000 0.000
#> GSM155455     2   0.000      1.000 0.000 1.000 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000 0.000
#> GSM155483     3   0.000      0.952 0.000 0.000 1.000
#> GSM155487     3   0.263      0.939 0.000 0.084 0.916
#> GSM155491     3   0.000      0.952 0.000 0.000 1.000
#> GSM155495     3   0.000      0.952 0.000 0.000 1.000
#> GSM155499     3   0.263      0.939 0.000 0.084 0.916
#> GSM155503     3   0.263      0.939 0.000 0.084 0.916
#> GSM155449     2   0.000      1.000 0.000 1.000 0.000
#> GSM155456     2   0.000      1.000 0.000 1.000 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000 0.000
#> GSM155484     3   0.000      0.952 0.000 0.000 1.000
#> GSM155488     3   0.000      0.952 0.000 0.000 1.000
#> GSM155492     3   0.000      0.952 0.000 0.000 1.000
#> GSM155496     3   0.000      0.952 0.000 0.000 1.000
#> GSM155500     3   0.263      0.939 0.000 0.084 0.916
#> GSM155504     3   0.263      0.939 0.000 0.084 0.916
#> GSM155450     2   0.000      1.000 0.000 1.000 0.000
#> GSM155453     2   0.000      1.000 0.000 1.000 0.000
#> GSM155457     2   0.000      1.000 0.000 1.000 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000 0.000
#> GSM155485     3   0.000      0.952 0.000 0.000 1.000
#> GSM155489     3   0.000      0.952 0.000 0.000 1.000
#> GSM155493     3   0.000      0.952 0.000 0.000 1.000
#> GSM155497     3   0.000      0.952 0.000 0.000 1.000
#> GSM155501     3   0.263      0.939 0.000 0.084 0.916
#> GSM155505     3   0.263      0.939 0.000 0.084 0.916
#> GSM155451     2   0.000      1.000 0.000 1.000 0.000
#> GSM155454     2   0.000      1.000 0.000 1.000 0.000
#> GSM155458     2   0.000      1.000 0.000 1.000 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000 0.000
#> GSM155478     3   0.550      0.849 0.096 0.088 0.816
#> GSM155482     3   0.550      0.849 0.096 0.088 0.816
#> GSM155486     3   0.000      0.952 0.000 0.000 1.000
#> GSM155490     3   0.263      0.939 0.000 0.084 0.916
#> GSM155494     3   0.000      0.952 0.000 0.000 1.000
#> GSM155498     3   0.000      0.952 0.000 0.000 1.000
#> GSM155502     3   0.263      0.939 0.000 0.084 0.916
#> GSM155506     3   0.263      0.939 0.000 0.084 0.916

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155452     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155455     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155459     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155483     3  0.1302      0.955 0.000 0.044 0.956 0.000
#> GSM155487     2  0.0000      0.947 0.000 1.000 0.000 0.000
#> GSM155491     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155495     3  0.1302      0.955 0.000 0.044 0.956 0.000
#> GSM155499     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155503     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155449     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155456     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155460     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155484     3  0.1302      0.955 0.000 0.044 0.956 0.000
#> GSM155488     2  0.2149      0.866 0.000 0.912 0.088 0.000
#> GSM155492     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155496     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155500     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155504     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155450     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155453     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155457     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155461     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155485     3  0.1302      0.955 0.000 0.044 0.956 0.000
#> GSM155489     3  0.3764      0.744 0.000 0.216 0.784 0.000
#> GSM155493     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155497     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155501     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155505     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155451     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155454     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155458     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155462     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155478     1  0.2149      0.909 0.912 0.088 0.000 0.000
#> GSM155482     1  0.2149      0.909 0.912 0.088 0.000 0.000
#> GSM155486     3  0.1302      0.955 0.000 0.044 0.956 0.000
#> GSM155490     2  0.4776      0.368 0.000 0.624 0.376 0.000
#> GSM155494     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155498     3  0.0000      0.961 0.000 0.000 1.000 0.000
#> GSM155502     2  0.0188      0.949 0.000 0.996 0.000 0.004
#> GSM155506     2  0.0188      0.949 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
#> GSM155448     4  0.0162      0.996 0.000 0.004 0.000 0.996 0.000
#> GSM155452     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155455     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155459     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155483     5  0.1851      0.931 0.000 0.000 0.088 0.000 0.912
#> GSM155487     5  0.3336      0.663 0.000 0.228 0.000 0.000 0.772
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155495     5  0.1908      0.928 0.000 0.000 0.092 0.000 0.908
#> GSM155499     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155449     4  0.0162      0.996 0.000 0.004 0.000 0.996 0.000
#> GSM155456     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155460     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155484     5  0.1851      0.931 0.000 0.000 0.088 0.000 0.912
#> GSM155488     5  0.1851      0.931 0.000 0.000 0.088 0.000 0.912
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155500     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155450     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155453     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155457     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155461     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155485     5  0.1851      0.931 0.000 0.000 0.088 0.000 0.912
#> GSM155489     5  0.1851      0.931 0.000 0.000 0.088 0.000 0.912
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155451     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155454     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155458     4  0.0000      0.999 0.000 0.000 0.000 1.000 0.000
#> GSM155462     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5  0.1270      0.868 0.052 0.000 0.000 0.000 0.948
#> GSM155482     5  0.1270      0.868 0.052 0.000 0.000 0.000 0.948
#> GSM155486     5  0.1851      0.931 0.000 0.000 0.088 0.000 0.912
#> GSM155490     5  0.0290      0.890 0.000 0.008 0.000 0.000 0.992
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2  0.0000      1.000 0.000 1.000 0.000 0.000 0.000
#> GSM155506     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
#> GSM155448     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155452     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155455     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155459     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155463     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155467     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155471     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155475     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155479     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155483     5  0.0000      0.997 0.000 0.000 0.000  0 1.000 0.000
#> GSM155487     6  0.1802      0.891 0.000 0.072 0.000  0 0.012 0.916
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155495     5  0.0363      0.986 0.000 0.000 0.012  0 0.988 0.000
#> GSM155499     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155449     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155456     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155460     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155464     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155468     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155472     1  0.1007      0.958 0.956 0.000 0.000  0 0.000 0.044
#> GSM155476     1  0.0458      0.984 0.984 0.000 0.000  0 0.000 0.016
#> GSM155480     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155484     5  0.0000      0.997 0.000 0.000 0.000  0 1.000 0.000
#> GSM155488     6  0.2697      0.793 0.000 0.000 0.000  0 0.188 0.812
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155500     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155450     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155453     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155457     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155461     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155465     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155469     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155473     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155477     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155481     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155485     5  0.0000      0.997 0.000 0.000 0.000  0 1.000 0.000
#> GSM155489     5  0.0000      0.997 0.000 0.000 0.000  0 1.000 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155501     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155451     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155454     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155458     4  0.0000      1.000 0.000 0.000 0.000  1 0.000 0.000
#> GSM155462     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155466     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155470     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155474     1  0.0000      0.997 1.000 0.000 0.000  0 0.000 0.000
#> GSM155478     6  0.0000      0.921 0.000 0.000 0.000  0 0.000 1.000
#> GSM155482     6  0.0000      0.921 0.000 0.000 0.000  0 0.000 1.000
#> GSM155486     5  0.0000      0.997 0.000 0.000 0.000  0 1.000 0.000
#> GSM155490     6  0.1075      0.915 0.000 0.000 0.000  0 0.048 0.952
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000  0 0.000 0.000
#> GSM155502     2  0.0000      1.000 0.000 1.000 0.000  0 0.000 0.000
#> GSM155506     2  0.0000      1.000 0.000 1.000 0.000  0 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 time(p) k
#> MAD:mclust 59   0.800 2
#> MAD:mclust 59   0.976 3
#> MAD:mclust 58   1.000 4
#> MAD:mclust 59   0.999 5
#> MAD:mclust 59   0.986 6

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


MAD:NMF*

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

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

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

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

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.829           0.893       0.957         0.5043 0.493   0.493
#> 3 3 0.947           0.937       0.975         0.3029 0.802   0.617
#> 4 4 0.905           0.893       0.947         0.0749 0.930   0.803
#> 5 5 0.896           0.919       0.944         0.0603 0.868   0.609
#> 6 6 0.836           0.806       0.872         0.0642 0.971   0.882

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM155448     2  0.0000     0.9373 0.000 1.000
#> GSM155452     2  0.0000     0.9373 0.000 1.000
#> GSM155455     2  0.0000     0.9373 0.000 1.000
#> GSM155459     1  0.0000     0.9687 1.000 0.000
#> GSM155463     1  0.0000     0.9687 1.000 0.000
#> GSM155467     1  0.0000     0.9687 1.000 0.000
#> GSM155471     1  0.0000     0.9687 1.000 0.000
#> GSM155475     1  0.0000     0.9687 1.000 0.000
#> GSM155479     1  0.0000     0.9687 1.000 0.000
#> GSM155483     2  0.9896     0.2525 0.440 0.560
#> GSM155487     2  0.0000     0.9373 0.000 1.000
#> GSM155491     1  0.6531     0.7772 0.832 0.168
#> GSM155495     2  0.0000     0.9373 0.000 1.000
#> GSM155499     2  0.0000     0.9373 0.000 1.000
#> GSM155503     2  0.0000     0.9373 0.000 1.000
#> GSM155449     2  0.0000     0.9373 0.000 1.000
#> GSM155456     1  0.0376     0.9652 0.996 0.004
#> GSM155460     1  0.0000     0.9687 1.000 0.000
#> GSM155464     1  0.0000     0.9687 1.000 0.000
#> GSM155468     1  0.0000     0.9687 1.000 0.000
#> GSM155472     1  0.0000     0.9687 1.000 0.000
#> GSM155476     1  0.0000     0.9687 1.000 0.000
#> GSM155480     1  0.0000     0.9687 1.000 0.000
#> GSM155484     2  0.1414     0.9251 0.020 0.980
#> GSM155488     2  0.0000     0.9373 0.000 1.000
#> GSM155492     2  0.9460     0.4530 0.364 0.636
#> GSM155496     2  0.6148     0.7988 0.152 0.848
#> GSM155500     2  0.0000     0.9373 0.000 1.000
#> GSM155504     2  0.0000     0.9373 0.000 1.000
#> GSM155450     2  0.0000     0.9373 0.000 1.000
#> GSM155453     2  0.0000     0.9373 0.000 1.000
#> GSM155457     1  0.8207     0.6354 0.744 0.256
#> GSM155461     1  0.0000     0.9687 1.000 0.000
#> GSM155465     1  0.0000     0.9687 1.000 0.000
#> GSM155469     1  0.0000     0.9687 1.000 0.000
#> GSM155473     1  0.0000     0.9687 1.000 0.000
#> GSM155477     1  0.0000     0.9687 1.000 0.000
#> GSM155481     1  0.0000     0.9687 1.000 0.000
#> GSM155485     2  0.1184     0.9278 0.016 0.984
#> GSM155489     2  0.0000     0.9373 0.000 1.000
#> GSM155493     2  0.9996     0.0866 0.488 0.512
#> GSM155497     2  0.0000     0.9373 0.000 1.000
#> GSM155501     2  0.0000     0.9373 0.000 1.000
#> GSM155505     2  0.0000     0.9373 0.000 1.000
#> GSM155451     2  0.0000     0.9373 0.000 1.000
#> GSM155454     2  0.0000     0.9373 0.000 1.000
#> GSM155458     2  0.2603     0.9058 0.044 0.956
#> GSM155462     1  0.0000     0.9687 1.000 0.000
#> GSM155466     1  0.0000     0.9687 1.000 0.000
#> GSM155470     1  0.0000     0.9687 1.000 0.000
#> GSM155474     1  0.0000     0.9687 1.000 0.000
#> GSM155478     1  0.0000     0.9687 1.000 0.000
#> GSM155482     1  0.0000     0.9687 1.000 0.000
#> GSM155486     2  0.0672     0.9328 0.008 0.992
#> GSM155490     2  0.0000     0.9373 0.000 1.000
#> GSM155494     2  0.8081     0.6719 0.248 0.752
#> GSM155498     1  0.9209     0.4610 0.664 0.336
#> GSM155502     2  0.0000     0.9373 0.000 1.000
#> GSM155506     2  0.0000     0.9373 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
#> GSM155448     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155452     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155455     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155459     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155483     3  0.0424      0.991 0.008 0.000 0.992
#> GSM155487     2  0.2261      0.889 0.000 0.932 0.068
#> GSM155491     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155495     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155499     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155503     2  0.0237      0.946 0.000 0.996 0.004
#> GSM155449     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155456     1  0.3816      0.831 0.852 0.148 0.000
#> GSM155460     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155472     1  0.0237      0.972 0.996 0.004 0.000
#> GSM155476     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155484     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155488     2  0.5363      0.604 0.000 0.724 0.276
#> GSM155492     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155496     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155500     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155504     2  0.0237      0.946 0.000 0.996 0.004
#> GSM155450     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155453     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155457     2  0.6307     -0.013 0.488 0.512 0.000
#> GSM155461     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155485     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155489     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155493     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155497     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155501     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155451     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155454     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155458     2  0.2448      0.875 0.076 0.924 0.000
#> GSM155462     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.976 1.000 0.000 0.000
#> GSM155478     1  0.4346      0.784 0.816 0.184 0.000
#> GSM155482     1  0.4654      0.750 0.792 0.208 0.000
#> GSM155486     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155490     2  0.0424      0.943 0.000 0.992 0.008
#> GSM155494     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155498     3  0.0000      0.999 0.000 0.000 1.000
#> GSM155502     2  0.0000      0.948 0.000 1.000 0.000
#> GSM155506     2  0.0000      0.948 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
#> GSM155448     2  0.0336      0.869 0.000 0.992 0.000 0.008
#> GSM155452     2  0.0592      0.862 0.000 0.984 0.000 0.016
#> GSM155455     2  0.0779      0.860 0.004 0.980 0.000 0.016
#> GSM155459     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155483     3  0.0779      0.945 0.016 0.000 0.980 0.004
#> GSM155487     4  0.4422      0.519 0.000 0.256 0.008 0.736
#> GSM155491     3  0.0336      0.950 0.008 0.000 0.992 0.000
#> GSM155495     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM155499     2  0.4070      0.843 0.000 0.824 0.044 0.132
#> GSM155503     2  0.4234      0.837 0.000 0.816 0.052 0.132
#> GSM155449     2  0.0188      0.869 0.000 0.996 0.000 0.004
#> GSM155456     1  0.5237      0.387 0.628 0.356 0.000 0.016
#> GSM155460     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155484     3  0.0804      0.949 0.000 0.008 0.980 0.012
#> GSM155488     3  0.6229      0.466 0.000 0.204 0.664 0.132
#> GSM155492     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM155496     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM155500     2  0.3999      0.842 0.000 0.824 0.036 0.140
#> GSM155504     2  0.4234      0.837 0.000 0.816 0.052 0.132
#> GSM155450     2  0.0592      0.862 0.000 0.984 0.000 0.016
#> GSM155453     2  0.0336      0.866 0.000 0.992 0.000 0.008
#> GSM155457     2  0.4630      0.461 0.252 0.732 0.000 0.016
#> GSM155461     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155485     3  0.1059      0.943 0.000 0.012 0.972 0.016
#> GSM155489     3  0.1182      0.939 0.000 0.016 0.968 0.016
#> GSM155493     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM155497     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM155501     2  0.4123      0.841 0.000 0.820 0.044 0.136
#> GSM155505     2  0.3479      0.843 0.000 0.840 0.012 0.148
#> GSM155451     2  0.0000      0.868 0.000 1.000 0.000 0.000
#> GSM155454     2  0.0336      0.868 0.000 0.992 0.008 0.000
#> GSM155458     2  0.0779      0.860 0.004 0.980 0.000 0.016
#> GSM155462     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.979 1.000 0.000 0.000 0.000
#> GSM155478     4  0.2593      0.823 0.104 0.004 0.000 0.892
#> GSM155482     4  0.2593      0.823 0.104 0.004 0.000 0.892
#> GSM155486     3  0.0804      0.949 0.000 0.008 0.980 0.012
#> GSM155490     4  0.0707      0.795 0.000 0.020 0.000 0.980
#> GSM155494     3  0.0000      0.956 0.000 0.000 1.000 0.000
#> GSM155498     3  0.0188      0.953 0.004 0.000 0.996 0.000
#> GSM155502     2  0.4070      0.843 0.000 0.824 0.044 0.132
#> GSM155506     2  0.4070      0.843 0.000 0.824 0.044 0.132

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM155448     4  0.2966      0.840 0.000 0.184 0.000 0.816 0.000
#> GSM155452     4  0.0963      0.905 0.000 0.036 0.000 0.964 0.000
#> GSM155455     4  0.0000      0.892 0.000 0.000 0.000 1.000 0.000
#> GSM155459     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155483     2  0.5747      0.323 0.088 0.504 0.408 0.000 0.000
#> GSM155487     2  0.2865      0.785 0.000 0.856 0.008 0.004 0.132
#> GSM155491     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155495     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155499     2  0.1908      0.861 0.000 0.908 0.000 0.092 0.000
#> GSM155503     2  0.1851      0.864 0.000 0.912 0.000 0.088 0.000
#> GSM155449     4  0.2852      0.853 0.000 0.172 0.000 0.828 0.000
#> GSM155456     4  0.0510      0.879 0.016 0.000 0.000 0.984 0.000
#> GSM155460     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.2595      0.878 0.888 0.000 0.000 0.080 0.032
#> GSM155476     1  0.0865      0.969 0.972 0.004 0.000 0.000 0.024
#> GSM155480     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155484     2  0.3949      0.662 0.004 0.696 0.300 0.000 0.000
#> GSM155488     2  0.1965      0.834 0.000 0.904 0.096 0.000 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155500     2  0.1851      0.864 0.000 0.912 0.000 0.088 0.000
#> GSM155504     2  0.1851      0.864 0.000 0.912 0.000 0.088 0.000
#> GSM155450     4  0.1197      0.906 0.000 0.048 0.000 0.952 0.000
#> GSM155453     4  0.1908      0.901 0.000 0.092 0.000 0.908 0.000
#> GSM155457     4  0.0162      0.892 0.004 0.000 0.000 0.996 0.000
#> GSM155461     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155485     2  0.2798      0.814 0.008 0.852 0.140 0.000 0.000
#> GSM155489     2  0.2516      0.817 0.000 0.860 0.140 0.000 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2  0.1851      0.864 0.000 0.912 0.000 0.088 0.000
#> GSM155505     2  0.1851      0.864 0.000 0.912 0.000 0.088 0.000
#> GSM155451     4  0.2179      0.894 0.000 0.112 0.000 0.888 0.000
#> GSM155454     4  0.2773      0.860 0.000 0.164 0.000 0.836 0.000
#> GSM155458     4  0.0162      0.892 0.004 0.000 0.000 0.996 0.000
#> GSM155462     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.993 1.000 0.000 0.000 0.000 0.000
#> GSM155478     5  0.0000      0.996 0.000 0.000 0.000 0.000 1.000
#> GSM155482     5  0.0000      0.996 0.000 0.000 0.000 0.000 1.000
#> GSM155486     2  0.3857      0.648 0.000 0.688 0.312 0.000 0.000
#> GSM155490     5  0.0290      0.991 0.000 0.008 0.000 0.000 0.992
#> GSM155494     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2  0.1851      0.864 0.000 0.912 0.000 0.088 0.000
#> GSM155506     2  0.1851      0.864 0.000 0.912 0.000 0.088 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
#> GSM155448     4  0.5086     0.6078 0.000 0.276 0.004 0.616 0.104 0.000
#> GSM155452     4  0.1789     0.8804 0.000 0.032 0.000 0.924 0.044 0.000
#> GSM155455     4  0.0260     0.8870 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM155459     1  0.3647     0.7117 0.640 0.000 0.000 0.000 0.360 0.000
#> GSM155463     1  0.3634     0.7134 0.644 0.000 0.000 0.000 0.356 0.000
#> GSM155467     1  0.0000     0.8399 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0363     0.8407 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM155475     1  0.0363     0.8375 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM155479     1  0.0632     0.8338 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM155483     5  0.4806     0.7522 0.036 0.108 0.132 0.000 0.724 0.000
#> GSM155487     2  0.5612     0.0113 0.000 0.520 0.000 0.000 0.308 0.172
#> GSM155491     3  0.0146     0.9784 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM155495     3  0.1267     0.9414 0.000 0.000 0.940 0.000 0.060 0.000
#> GSM155499     2  0.0862     0.8527 0.000 0.972 0.004 0.016 0.008 0.000
#> GSM155503     2  0.0603     0.8527 0.000 0.980 0.000 0.016 0.004 0.000
#> GSM155449     4  0.5054     0.5175 0.000 0.336 0.000 0.572 0.092 0.000
#> GSM155456     4  0.0520     0.8810 0.008 0.000 0.000 0.984 0.008 0.000
#> GSM155460     1  0.3659     0.7069 0.636 0.000 0.000 0.000 0.364 0.000
#> GSM155464     1  0.3659     0.7068 0.636 0.000 0.000 0.000 0.364 0.000
#> GSM155468     1  0.1219     0.8387 0.948 0.004 0.000 0.000 0.048 0.000
#> GSM155472     1  0.2136     0.7968 0.908 0.000 0.000 0.016 0.012 0.064
#> GSM155476     1  0.1401     0.8218 0.948 0.020 0.000 0.000 0.028 0.004
#> GSM155480     1  0.0972     0.8302 0.964 0.008 0.000 0.000 0.028 0.000
#> GSM155484     5  0.4933     0.8226 0.012 0.188 0.120 0.000 0.680 0.000
#> GSM155488     2  0.4388    -0.0436 0.000 0.572 0.028 0.000 0.400 0.000
#> GSM155492     3  0.0146     0.9784 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM155496     3  0.0937     0.9598 0.000 0.000 0.960 0.000 0.040 0.000
#> GSM155500     2  0.0603     0.8527 0.000 0.980 0.000 0.016 0.004 0.000
#> GSM155504     2  0.1245     0.8467 0.000 0.952 0.000 0.016 0.032 0.000
#> GSM155450     4  0.0790     0.8906 0.000 0.032 0.000 0.968 0.000 0.000
#> GSM155453     4  0.1049     0.8906 0.000 0.032 0.000 0.960 0.008 0.000
#> GSM155457     4  0.0520     0.8810 0.008 0.000 0.000 0.984 0.008 0.000
#> GSM155461     1  0.3547     0.7289 0.668 0.000 0.000 0.000 0.332 0.000
#> GSM155465     1  0.3647     0.7103 0.640 0.000 0.000 0.000 0.360 0.000
#> GSM155469     1  0.1075     0.8385 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM155473     1  0.0260     0.8403 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM155477     1  0.0363     0.8375 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM155481     1  0.0458     0.8363 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM155485     5  0.4945     0.8236 0.012 0.220 0.100 0.000 0.668 0.000
#> GSM155489     5  0.5527     0.4266 0.000 0.408 0.132 0.000 0.460 0.000
#> GSM155493     3  0.0405     0.9790 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM155497     3  0.0458     0.9771 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM155501     2  0.1088     0.8503 0.000 0.960 0.000 0.016 0.024 0.000
#> GSM155505     2  0.0717     0.8455 0.000 0.976 0.000 0.016 0.008 0.000
#> GSM155451     4  0.1411     0.8831 0.000 0.060 0.000 0.936 0.004 0.000
#> GSM155454     4  0.2263     0.8642 0.000 0.056 0.000 0.896 0.048 0.000
#> GSM155458     4  0.0260     0.8870 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM155462     1  0.3830     0.6902 0.620 0.000 0.004 0.000 0.376 0.000
#> GSM155466     1  0.3607     0.7188 0.652 0.000 0.000 0.000 0.348 0.000
#> GSM155470     1  0.1204     0.8372 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM155474     1  0.0260     0.8403 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM155478     6  0.0000     0.9951 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155482     6  0.0000     0.9951 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM155486     5  0.5076     0.8128 0.004 0.236 0.124 0.000 0.636 0.000
#> GSM155490     6  0.0405     0.9902 0.000 0.004 0.000 0.000 0.008 0.988
#> GSM155494     3  0.0405     0.9789 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM155498     3  0.0551     0.9732 0.004 0.000 0.984 0.000 0.008 0.004
#> GSM155502     2  0.1168     0.8491 0.000 0.956 0.000 0.016 0.028 0.000
#> GSM155506     2  0.0603     0.8511 0.000 0.980 0.004 0.016 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-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 time(p) k
#> MAD:NMF 55   0.951 2
#> MAD:NMF 58   0.982 3
#> MAD:NMF 56   0.650 4
#> MAD:NMF 58   0.631 5
#> MAD:NMF 56   0.863 6

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


ATC:hclust**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.978       0.990         0.4605 0.534   0.534
#> 3 3 0.781           0.865       0.932         0.1423 0.953   0.912
#> 4 4 0.793           0.865       0.914         0.2029 0.841   0.683
#> 5 5 0.799           0.855       0.912         0.0542 0.991   0.974
#> 6 6 0.817           0.878       0.875         0.0771 0.888   0.677

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
#> GSM155448     1   0.000      1.000 1.000 0.000
#> GSM155452     1   0.000      1.000 1.000 0.000
#> GSM155455     1   0.000      1.000 1.000 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000
#> GSM155483     2   0.000      0.971 0.000 1.000
#> GSM155487     2   0.000      0.971 0.000 1.000
#> GSM155491     1   0.000      1.000 1.000 0.000
#> GSM155495     2   0.000      0.971 0.000 1.000
#> GSM155499     2   0.000      0.971 0.000 1.000
#> GSM155503     2   0.000      0.971 0.000 1.000
#> GSM155449     1   0.000      1.000 1.000 0.000
#> GSM155456     1   0.000      1.000 1.000 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000
#> GSM155484     2   0.000      0.971 0.000 1.000
#> GSM155488     2   0.000      0.971 0.000 1.000
#> GSM155492     1   0.000      1.000 1.000 0.000
#> GSM155496     2   0.000      0.971 0.000 1.000
#> GSM155500     2   0.000      0.971 0.000 1.000
#> GSM155504     2   0.000      0.971 0.000 1.000
#> GSM155450     1   0.000      1.000 1.000 0.000
#> GSM155453     2   0.866      0.616 0.288 0.712
#> GSM155457     1   0.000      1.000 1.000 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000
#> GSM155485     2   0.000      0.971 0.000 1.000
#> GSM155489     2   0.000      0.971 0.000 1.000
#> GSM155493     1   0.000      1.000 1.000 0.000
#> GSM155497     1   0.000      1.000 1.000 0.000
#> GSM155501     2   0.000      0.971 0.000 1.000
#> GSM155505     2   0.000      0.971 0.000 1.000
#> GSM155451     2   0.866      0.616 0.288 0.712
#> GSM155454     2   0.000      0.971 0.000 1.000
#> GSM155458     1   0.000      1.000 1.000 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000
#> GSM155478     1   0.000      1.000 1.000 0.000
#> GSM155482     1   0.000      1.000 1.000 0.000
#> GSM155486     2   0.000      0.971 0.000 1.000
#> GSM155490     2   0.000      0.971 0.000 1.000
#> GSM155494     1   0.000      1.000 1.000 0.000
#> GSM155498     1   0.000      1.000 1.000 0.000
#> GSM155502     2   0.000      0.971 0.000 1.000
#> GSM155506     2   0.000      0.971 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
#> GSM155448     1  0.0237      0.961 0.996 0.000 0.004
#> GSM155452     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155455     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155459     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155483     2  0.5785      0.568 0.000 0.668 0.332
#> GSM155487     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155491     1  0.4555      0.785 0.800 0.000 0.200
#> GSM155495     3  0.4555      0.661 0.000 0.200 0.800
#> GSM155499     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155503     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155449     1  0.0237      0.961 0.996 0.000 0.004
#> GSM155456     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155460     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155472     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155476     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155484     2  0.5785      0.568 0.000 0.668 0.332
#> GSM155488     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155492     1  0.4555      0.785 0.800 0.000 0.200
#> GSM155496     3  0.4555      0.661 0.000 0.200 0.800
#> GSM155500     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155504     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155450     1  0.0237      0.961 0.996 0.000 0.004
#> GSM155453     3  0.5431      0.626 0.284 0.000 0.716
#> GSM155457     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155461     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155485     2  0.5785      0.568 0.000 0.668 0.332
#> GSM155489     2  0.5785      0.568 0.000 0.668 0.332
#> GSM155493     1  0.4555      0.785 0.800 0.000 0.200
#> GSM155497     1  0.4555      0.785 0.800 0.000 0.200
#> GSM155501     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155451     3  0.5431      0.626 0.284 0.000 0.716
#> GSM155454     3  0.4555      0.661 0.000 0.200 0.800
#> GSM155458     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155462     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155478     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155482     1  0.0000      0.964 1.000 0.000 0.000
#> GSM155486     2  0.5785      0.568 0.000 0.668 0.332
#> GSM155490     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155494     1  0.4555      0.785 0.800 0.000 0.200
#> GSM155498     1  0.4555      0.785 0.800 0.000 0.200
#> GSM155502     2  0.0000      0.857 0.000 1.000 0.000
#> GSM155506     2  0.0000      0.857 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
#> GSM155448     1   0.281      0.867 0.868 0.000 0.132 0.000
#> GSM155452     1   0.139      0.925 0.952 0.000 0.048 0.000
#> GSM155455     1   0.253      0.886 0.888 0.000 0.112 0.000
#> GSM155459     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155483     4   0.499      0.450 0.000 0.468 0.000 0.532
#> GSM155487     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155491     3   0.139      0.905 0.048 0.000 0.952 0.000
#> GSM155495     4   0.000      0.541 0.000 0.000 0.000 1.000
#> GSM155499     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155503     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155449     1   0.281      0.867 0.868 0.000 0.132 0.000
#> GSM155456     1   0.253      0.886 0.888 0.000 0.112 0.000
#> GSM155460     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155484     4   0.499      0.450 0.000 0.468 0.000 0.532
#> GSM155488     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155492     3   0.139      0.905 0.048 0.000 0.952 0.000
#> GSM155496     4   0.000      0.541 0.000 0.000 0.000 1.000
#> GSM155500     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155504     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155450     1   0.281      0.867 0.868 0.000 0.132 0.000
#> GSM155453     4   0.563      0.331 0.196 0.000 0.092 0.712
#> GSM155457     1   0.253      0.886 0.888 0.000 0.112 0.000
#> GSM155461     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155485     4   0.499      0.450 0.000 0.468 0.000 0.532
#> GSM155489     4   0.499      0.450 0.000 0.468 0.000 0.532
#> GSM155493     3   0.139      0.905 0.048 0.000 0.952 0.000
#> GSM155497     3   0.307      0.807 0.152 0.000 0.848 0.000
#> GSM155501     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155505     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155451     4   0.563      0.331 0.196 0.000 0.092 0.712
#> GSM155454     4   0.000      0.541 0.000 0.000 0.000 1.000
#> GSM155458     1   0.253      0.886 0.888 0.000 0.112 0.000
#> GSM155462     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155478     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155482     1   0.000      0.967 1.000 0.000 0.000 0.000
#> GSM155486     4   0.499      0.450 0.000 0.468 0.000 0.532
#> GSM155490     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155494     3   0.139      0.905 0.048 0.000 0.952 0.000
#> GSM155498     3   0.307      0.807 0.152 0.000 0.848 0.000
#> GSM155502     2   0.000      1.000 0.000 1.000 0.000 0.000
#> GSM155506     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
#> GSM155448     1   0.566      0.542 0.632 0.000 0.164 0.204 0.000
#> GSM155452     1   0.311      0.775 0.800 0.200 0.000 0.000 0.000
#> GSM155455     1   0.265      0.827 0.848 0.000 0.152 0.000 0.000
#> GSM155459     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155483     5   0.000      0.621 0.000 0.000 0.000 0.000 1.000
#> GSM155487     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155491     3   0.000      0.882 0.000 0.000 1.000 0.000 0.000
#> GSM155495     5   0.429      0.366 0.000 0.000 0.000 0.468 0.532
#> GSM155499     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155503     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155449     1   0.566      0.542 0.632 0.000 0.164 0.204 0.000
#> GSM155456     1   0.265      0.827 0.848 0.000 0.152 0.000 0.000
#> GSM155460     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155476     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155484     5   0.000      0.621 0.000 0.000 0.000 0.000 1.000
#> GSM155488     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155492     3   0.000      0.882 0.000 0.000 1.000 0.000 0.000
#> GSM155496     5   0.429      0.366 0.000 0.000 0.000 0.468 0.532
#> GSM155500     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155504     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155450     1   0.566      0.542 0.632 0.000 0.164 0.204 0.000
#> GSM155453     4   0.504      1.000 0.000 0.236 0.084 0.680 0.000
#> GSM155457     1   0.265      0.827 0.848 0.000 0.152 0.000 0.000
#> GSM155461     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155485     5   0.000      0.621 0.000 0.000 0.000 0.000 1.000
#> GSM155489     5   0.000      0.621 0.000 0.000 0.000 0.000 1.000
#> GSM155493     3   0.000      0.882 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3   0.337      0.763 0.000 0.232 0.768 0.000 0.000
#> GSM155501     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155505     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155451     4   0.504      1.000 0.000 0.236 0.084 0.680 0.000
#> GSM155454     5   0.429      0.366 0.000 0.000 0.000 0.468 0.532
#> GSM155458     1   0.265      0.827 0.848 0.000 0.152 0.000 0.000
#> GSM155462     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155478     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155482     1   0.000      0.937 1.000 0.000 0.000 0.000 0.000
#> GSM155486     5   0.000      0.621 0.000 0.000 0.000 0.000 1.000
#> GSM155490     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155494     3   0.000      0.882 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3   0.337      0.763 0.000 0.232 0.768 0.000 0.000
#> GSM155502     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468
#> GSM155506     2   0.429      1.000 0.000 0.532 0.000 0.000 0.468

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM155448     4   0.393      0.695 0.248 0.000 0.000 0.716 0.000 0.036
#> GSM155452     4   0.809      0.476 0.212 0.120 0.080 0.420 0.000 0.168
#> GSM155455     4   0.381      0.790 0.428 0.000 0.000 0.572 0.000 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155483     5   0.000      0.623 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155487     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155491     3   0.156      0.839 0.000 0.000 0.920 0.080 0.000 0.000
#> GSM155495     5   0.656      0.436 0.000 0.176 0.000 0.208 0.532 0.084
#> GSM155499     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155503     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155449     4   0.393      0.695 0.248 0.000 0.000 0.716 0.000 0.036
#> GSM155456     4   0.381      0.790 0.428 0.000 0.000 0.572 0.000 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155484     5   0.000      0.623 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155488     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155492     3   0.156      0.839 0.000 0.000 0.920 0.080 0.000 0.000
#> GSM155496     5   0.656      0.436 0.000 0.176 0.000 0.208 0.532 0.084
#> GSM155500     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155504     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155450     4   0.393      0.695 0.248 0.000 0.000 0.716 0.000 0.036
#> GSM155453     6   0.315      1.000 0.000 0.000 0.000 0.252 0.000 0.748
#> GSM155457     4   0.381      0.790 0.428 0.000 0.000 0.572 0.000 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155485     5   0.000      0.623 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155489     5   0.000      0.623 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155493     3   0.156      0.839 0.000 0.000 0.920 0.080 0.000 0.000
#> GSM155497     3   0.423      0.648 0.000 0.292 0.668 0.040 0.000 0.000
#> GSM155501     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155505     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155451     6   0.315      1.000 0.000 0.000 0.000 0.252 0.000 0.748
#> GSM155454     5   0.656      0.436 0.000 0.176 0.000 0.208 0.532 0.084
#> GSM155458     4   0.381      0.790 0.428 0.000 0.000 0.572 0.000 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155478     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155482     1   0.000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155486     5   0.000      0.623 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155490     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155494     3   0.156      0.839 0.000 0.000 0.920 0.080 0.000 0.000
#> GSM155498     3   0.423      0.648 0.000 0.292 0.668 0.040 0.000 0.000
#> GSM155502     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 0.000
#> GSM155506     2   0.386      1.000 0.000 0.532 0.000 0.000 0.468 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 time(p) k
#> ATC:hclust 59   0.979 2
#> ATC:hclust 59   0.996 3
#> ATC:hclust 52   0.990 4
#> ATC:hclust 56   0.989 5
#> ATC:hclust 55   0.998 6

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


ATC:kmeans**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4447 0.556   0.556
#> 3 3 0.763           0.931       0.935         0.3719 0.797   0.638
#> 4 4 0.774           0.766       0.842         0.1428 0.959   0.889
#> 5 5 0.721           0.624       0.764         0.0806 0.890   0.682
#> 6 6 0.736           0.843       0.772         0.0462 0.869   0.520

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
#> GSM155448     1       0          1  1  0
#> GSM155452     1       0          1  1  0
#> GSM155455     1       0          1  1  0
#> GSM155459     1       0          1  1  0
#> GSM155463     1       0          1  1  0
#> GSM155467     1       0          1  1  0
#> GSM155471     1       0          1  1  0
#> GSM155475     1       0          1  1  0
#> GSM155479     1       0          1  1  0
#> GSM155483     2       0          1  0  1
#> GSM155487     2       0          1  0  1
#> GSM155491     1       0          1  1  0
#> GSM155495     2       0          1  0  1
#> GSM155499     2       0          1  0  1
#> GSM155503     2       0          1  0  1
#> GSM155449     1       0          1  1  0
#> GSM155456     1       0          1  1  0
#> GSM155460     1       0          1  1  0
#> GSM155464     1       0          1  1  0
#> GSM155468     1       0          1  1  0
#> GSM155472     1       0          1  1  0
#> GSM155476     1       0          1  1  0
#> GSM155480     1       0          1  1  0
#> GSM155484     2       0          1  0  1
#> GSM155488     2       0          1  0  1
#> GSM155492     1       0          1  1  0
#> GSM155496     2       0          1  0  1
#> GSM155500     2       0          1  0  1
#> GSM155504     2       0          1  0  1
#> GSM155450     1       0          1  1  0
#> GSM155453     1       0          1  1  0
#> GSM155457     1       0          1  1  0
#> GSM155461     1       0          1  1  0
#> GSM155465     1       0          1  1  0
#> GSM155469     1       0          1  1  0
#> GSM155473     1       0          1  1  0
#> GSM155477     1       0          1  1  0
#> GSM155481     1       0          1  1  0
#> GSM155485     2       0          1  0  1
#> GSM155489     2       0          1  0  1
#> GSM155493     1       0          1  1  0
#> GSM155497     1       0          1  1  0
#> GSM155501     2       0          1  0  1
#> GSM155505     2       0          1  0  1
#> GSM155451     1       0          1  1  0
#> GSM155454     2       0          1  0  1
#> GSM155458     1       0          1  1  0
#> GSM155462     1       0          1  1  0
#> GSM155466     1       0          1  1  0
#> GSM155470     1       0          1  1  0
#> GSM155474     1       0          1  1  0
#> GSM155478     1       0          1  1  0
#> GSM155482     1       0          1  1  0
#> GSM155486     2       0          1  0  1
#> GSM155490     2       0          1  0  1
#> GSM155494     1       0          1  1  0
#> GSM155498     1       0          1  1  0
#> GSM155502     2       0          1  0  1
#> GSM155506     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
#> GSM155448     3  0.5497      0.837 0.292 0.000 0.708
#> GSM155452     1  0.0237      0.989 0.996 0.000 0.004
#> GSM155455     1  0.0237      0.989 0.996 0.000 0.004
#> GSM155459     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155483     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155487     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155491     3  0.4605      0.887 0.204 0.000 0.796
#> GSM155495     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155499     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155503     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155449     3  0.5497      0.837 0.292 0.000 0.708
#> GSM155456     1  0.0237      0.989 0.996 0.000 0.004
#> GSM155460     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155472     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155476     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155484     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155488     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155492     3  0.3412      0.849 0.124 0.000 0.876
#> GSM155496     3  0.0000      0.706 0.000 0.000 1.000
#> GSM155500     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155504     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155450     3  0.5497      0.837 0.292 0.000 0.708
#> GSM155453     3  0.0000      0.706 0.000 0.000 1.000
#> GSM155457     1  0.0237      0.989 0.996 0.000 0.004
#> GSM155461     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155485     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155489     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155493     3  0.3412      0.849 0.124 0.000 0.876
#> GSM155497     3  0.4605      0.887 0.204 0.000 0.796
#> GSM155501     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155451     3  0.5497      0.837 0.292 0.000 0.708
#> GSM155454     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155458     1  0.3686      0.786 0.860 0.000 0.140
#> GSM155462     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155478     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155482     1  0.0000      0.993 1.000 0.000 0.000
#> GSM155486     2  0.4605      0.877 0.000 0.796 0.204
#> GSM155490     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155494     3  0.4605      0.887 0.204 0.000 0.796
#> GSM155498     3  0.4605      0.887 0.204 0.000 0.796
#> GSM155502     2  0.0000      0.926 0.000 1.000 0.000
#> GSM155506     2  0.0000      0.926 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
#> GSM155448     4  0.6077     0.5565 0.044 0.000 0.460 0.496
#> GSM155452     1  0.6164     0.4110 0.644 0.000 0.092 0.264
#> GSM155455     1  0.6162     0.4248 0.620 0.000 0.076 0.304
#> GSM155459     1  0.0336     0.8705 0.992 0.000 0.000 0.008
#> GSM155463     1  0.2973     0.8538 0.856 0.000 0.000 0.144
#> GSM155467     1  0.2973     0.8538 0.856 0.000 0.000 0.144
#> GSM155471     1  0.2921     0.8547 0.860 0.000 0.000 0.140
#> GSM155475     1  0.0336     0.8705 0.992 0.000 0.000 0.008
#> GSM155479     1  0.0188     0.8712 0.996 0.000 0.000 0.004
#> GSM155483     2  0.4500     0.7745 0.000 0.684 0.000 0.316
#> GSM155487     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155491     3  0.0000     0.9377 0.000 0.000 1.000 0.000
#> GSM155495     2  0.4564     0.7660 0.000 0.672 0.000 0.328
#> GSM155499     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155503     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155449     4  0.6050     0.5494 0.044 0.000 0.432 0.524
#> GSM155456     1  0.6162     0.4248 0.620 0.000 0.076 0.304
#> GSM155460     1  0.0336     0.8705 0.992 0.000 0.000 0.008
#> GSM155464     1  0.2973     0.8538 0.856 0.000 0.000 0.144
#> GSM155468     1  0.2973     0.8538 0.856 0.000 0.000 0.144
#> GSM155472     1  0.2973     0.8538 0.856 0.000 0.000 0.144
#> GSM155476     1  0.2868     0.8553 0.864 0.000 0.000 0.136
#> GSM155480     1  0.2868     0.8553 0.864 0.000 0.000 0.136
#> GSM155484     2  0.4500     0.7745 0.000 0.684 0.000 0.316
#> GSM155488     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155492     3  0.1867     0.8937 0.000 0.000 0.928 0.072
#> GSM155496     4  0.4916    -0.1820 0.000 0.000 0.424 0.576
#> GSM155500     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155504     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155450     4  0.6077     0.5565 0.044 0.000 0.460 0.496
#> GSM155453     4  0.4948     0.4712 0.000 0.000 0.440 0.560
#> GSM155457     1  0.6162     0.4248 0.620 0.000 0.076 0.304
#> GSM155461     1  0.0000     0.8716 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0336     0.8705 0.992 0.000 0.000 0.008
#> GSM155469     1  0.2973     0.8538 0.856 0.000 0.000 0.144
#> GSM155473     1  0.0000     0.8716 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0188     0.8712 0.996 0.000 0.000 0.004
#> GSM155481     1  0.0188     0.8712 0.996 0.000 0.000 0.004
#> GSM155485     2  0.4500     0.7745 0.000 0.684 0.000 0.316
#> GSM155489     2  0.4500     0.7745 0.000 0.684 0.000 0.316
#> GSM155493     3  0.1867     0.8937 0.000 0.000 0.928 0.072
#> GSM155497     3  0.0657     0.9284 0.012 0.000 0.984 0.004
#> GSM155501     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155505     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155451     4  0.5912     0.5461 0.036 0.000 0.440 0.524
#> GSM155454     2  0.4992     0.5983 0.000 0.524 0.000 0.476
#> GSM155458     4  0.7207    -0.0072 0.376 0.000 0.144 0.480
#> GSM155462     1  0.0336     0.8705 0.992 0.000 0.000 0.008
#> GSM155466     1  0.0336     0.8705 0.992 0.000 0.000 0.008
#> GSM155470     1  0.0188     0.8712 0.996 0.000 0.000 0.004
#> GSM155474     1  0.0000     0.8716 1.000 0.000 0.000 0.000
#> GSM155478     1  0.3172     0.8456 0.840 0.000 0.000 0.160
#> GSM155482     1  0.3172     0.8456 0.840 0.000 0.000 0.160
#> GSM155486     2  0.4500     0.7745 0.000 0.684 0.000 0.316
#> GSM155490     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155494     3  0.0000     0.9377 0.000 0.000 1.000 0.000
#> GSM155498     3  0.0657     0.9284 0.012 0.000 0.984 0.004
#> GSM155502     2  0.0000     0.8681 0.000 1.000 0.000 0.000
#> GSM155506     2  0.0000     0.8681 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
#> GSM155448     4  0.4404      0.640 0.008 0.080 0.136 0.776 0.000
#> GSM155452     1  0.4967     -0.223 0.540 0.008 0.016 0.436 0.000
#> GSM155455     4  0.4046      0.555 0.296 0.000 0.008 0.696 0.000
#> GSM155459     1  0.0162      0.763 0.996 0.000 0.004 0.000 0.000
#> GSM155463     1  0.5941      0.675 0.608 0.164 0.004 0.224 0.000
#> GSM155467     1  0.5792      0.675 0.612 0.164 0.000 0.224 0.000
#> GSM155471     1  0.5714      0.682 0.624 0.164 0.000 0.212 0.000
#> GSM155475     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155483     5  0.0000      0.521 0.000 0.000 0.000 0.000 1.000
#> GSM155487     5  0.5576     -0.914 0.000 0.472 0.024 0.028 0.476
#> GSM155491     3  0.1544      0.951 0.000 0.000 0.932 0.068 0.000
#> GSM155495     5  0.2674      0.491 0.000 0.140 0.000 0.004 0.856
#> GSM155499     2  0.4300      0.998 0.000 0.524 0.000 0.000 0.476
#> GSM155503     2  0.4300      0.998 0.000 0.524 0.000 0.000 0.476
#> GSM155449     4  0.3831      0.645 0.008 0.044 0.136 0.812 0.000
#> GSM155456     4  0.4046      0.555 0.296 0.000 0.008 0.696 0.000
#> GSM155460     1  0.0162      0.763 0.996 0.000 0.004 0.000 0.000
#> GSM155464     1  0.5941      0.675 0.608 0.164 0.004 0.224 0.000
#> GSM155468     1  0.5816      0.672 0.608 0.164 0.000 0.228 0.000
#> GSM155472     1  0.5792      0.675 0.612 0.164 0.000 0.224 0.000
#> GSM155476     1  0.5379      0.699 0.668 0.164 0.000 0.168 0.000
#> GSM155480     1  0.5379      0.699 0.668 0.164 0.000 0.168 0.000
#> GSM155484     5  0.0000      0.521 0.000 0.000 0.000 0.000 1.000
#> GSM155488     5  0.5576     -0.914 0.000 0.472 0.024 0.028 0.476
#> GSM155492     3  0.2795      0.908 0.000 0.056 0.880 0.064 0.000
#> GSM155496     5  0.7467      0.104 0.000 0.260 0.156 0.088 0.496
#> GSM155500     2  0.4446      0.994 0.000 0.520 0.000 0.004 0.476
#> GSM155504     2  0.4300      0.998 0.000 0.524 0.000 0.000 0.476
#> GSM155450     4  0.4404      0.640 0.008 0.080 0.136 0.776 0.000
#> GSM155453     4  0.5895      0.447 0.000 0.260 0.152 0.588 0.000
#> GSM155457     4  0.4046      0.555 0.296 0.000 0.008 0.696 0.000
#> GSM155461     1  0.0162      0.763 0.996 0.000 0.004 0.000 0.000
#> GSM155465     1  0.0162      0.763 0.996 0.000 0.004 0.000 0.000
#> GSM155469     1  0.5816      0.672 0.608 0.164 0.000 0.228 0.000
#> GSM155473     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155485     5  0.0000      0.521 0.000 0.000 0.000 0.000 1.000
#> GSM155489     5  0.0000      0.521 0.000 0.000 0.000 0.000 1.000
#> GSM155493     3  0.2795      0.908 0.000 0.056 0.880 0.064 0.000
#> GSM155497     3  0.2006      0.948 0.000 0.012 0.916 0.072 0.000
#> GSM155501     2  0.4300      0.998 0.000 0.524 0.000 0.000 0.476
#> GSM155505     2  0.4446      0.994 0.000 0.520 0.000 0.004 0.476
#> GSM155451     4  0.4926      0.571 0.000 0.132 0.152 0.716 0.000
#> GSM155454     5  0.5312      0.422 0.000 0.248 0.016 0.064 0.672
#> GSM155458     4  0.2986      0.642 0.084 0.020 0.020 0.876 0.000
#> GSM155462     1  0.0162      0.763 0.996 0.000 0.004 0.000 0.000
#> GSM155466     1  0.0162      0.763 0.996 0.000 0.004 0.000 0.000
#> GSM155470     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.764 1.000 0.000 0.000 0.000 0.000
#> GSM155478     1  0.6592      0.619 0.544 0.196 0.016 0.244 0.000
#> GSM155482     1  0.6592      0.619 0.544 0.196 0.016 0.244 0.000
#> GSM155486     5  0.0000      0.521 0.000 0.000 0.000 0.000 1.000
#> GSM155490     5  0.5644     -0.912 0.000 0.468 0.024 0.032 0.476
#> GSM155494     3  0.1544      0.951 0.000 0.000 0.932 0.068 0.000
#> GSM155498     3  0.2006      0.948 0.000 0.012 0.916 0.072 0.000
#> GSM155502     2  0.4300      0.998 0.000 0.524 0.000 0.000 0.476
#> GSM155506     2  0.4300      0.998 0.000 0.524 0.000 0.000 0.476

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM155448     4  0.3049      0.676 0.004 0.000 0.104 0.844 0.000 0.048
#> GSM155452     4  0.6267      0.319 0.424 0.000 0.016 0.432 0.028 0.100
#> GSM155455     4  0.5353      0.680 0.152 0.000 0.012 0.644 0.004 0.188
#> GSM155459     1  0.0547      0.981 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM155463     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155467     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155471     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155475     1  0.0260      0.984 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM155479     1  0.0146      0.987 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155483     5  0.3464      0.795 0.000 0.312 0.000 0.000 0.688 0.000
#> GSM155487     2  0.3385      0.799 0.000 0.788 0.000 0.032 0.000 0.180
#> GSM155491     3  0.1082      0.907 0.000 0.000 0.956 0.040 0.000 0.004
#> GSM155495     5  0.2869      0.735 0.000 0.148 0.000 0.000 0.832 0.020
#> GSM155499     2  0.0922      0.915 0.000 0.968 0.004 0.024 0.000 0.004
#> GSM155503     2  0.0000      0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155449     4  0.3112      0.677 0.004 0.000 0.104 0.840 0.000 0.052
#> GSM155456     4  0.5353      0.680 0.152 0.000 0.012 0.644 0.004 0.188
#> GSM155460     1  0.0547      0.981 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM155464     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155468     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155472     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155476     6  0.3868      0.898 0.496 0.000 0.000 0.000 0.000 0.504
#> GSM155480     6  0.3868      0.898 0.496 0.000 0.000 0.000 0.000 0.504
#> GSM155484     5  0.3464      0.795 0.000 0.312 0.000 0.000 0.688 0.000
#> GSM155488     2  0.4202      0.759 0.000 0.752 0.000 0.032 0.036 0.180
#> GSM155492     3  0.3133      0.853 0.000 0.000 0.856 0.072 0.040 0.032
#> GSM155496     5  0.5778      0.381 0.000 0.000 0.112 0.120 0.648 0.120
#> GSM155500     2  0.0146      0.922 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM155504     2  0.0000      0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155450     4  0.3049      0.676 0.004 0.000 0.104 0.844 0.000 0.048
#> GSM155453     4  0.5874      0.396 0.000 0.000 0.116 0.620 0.192 0.072
#> GSM155457     4  0.5353      0.680 0.152 0.000 0.012 0.644 0.004 0.188
#> GSM155461     1  0.0260      0.987 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM155465     1  0.0363      0.986 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM155469     6  0.3851      0.947 0.460 0.000 0.000 0.000 0.000 0.540
#> GSM155473     1  0.0146      0.987 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155477     1  0.0146      0.987 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155481     1  0.0000      0.987 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155485     5  0.3464      0.795 0.000 0.312 0.000 0.000 0.688 0.000
#> GSM155489     5  0.3464      0.795 0.000 0.312 0.000 0.000 0.688 0.000
#> GSM155493     3  0.3133      0.853 0.000 0.000 0.856 0.072 0.040 0.032
#> GSM155497     3  0.2731      0.889 0.000 0.000 0.876 0.068 0.012 0.044
#> GSM155501     2  0.0000      0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2  0.0146      0.922 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM155451     4  0.3684      0.595 0.004 0.000 0.112 0.816 0.024 0.044
#> GSM155454     5  0.5168      0.642 0.000 0.104 0.008 0.076 0.720 0.092
#> GSM155458     4  0.4147      0.693 0.044 0.000 0.016 0.744 0.000 0.196
#> GSM155462     1  0.0363      0.986 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM155466     1  0.0363      0.986 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM155470     1  0.0146      0.987 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155474     1  0.0146      0.987 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155478     6  0.5450      0.829 0.412 0.000 0.004 0.012 0.072 0.500
#> GSM155482     6  0.5450      0.829 0.412 0.000 0.004 0.012 0.072 0.500
#> GSM155486     5  0.3464      0.795 0.000 0.312 0.000 0.000 0.688 0.000
#> GSM155490     2  0.3248      0.808 0.000 0.804 0.000 0.032 0.000 0.164
#> GSM155494     3  0.0937      0.907 0.000 0.000 0.960 0.040 0.000 0.000
#> GSM155498     3  0.2731      0.889 0.000 0.000 0.876 0.068 0.012 0.044
#> GSM155502     2  0.0000      0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2  0.0922      0.915 0.000 0.968 0.004 0.024 0.000 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-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 time(p) k
#> ATC:kmeans 59   0.959 2
#> ATC:kmeans 59   0.988 3
#> ATC:kmeans 52   1.000 4
#> ATC:kmeans 51   1.000 5
#> ATC:kmeans 56   0.947 6

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


ATC:skmeans*

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.958       0.983         0.4757 0.516   0.516
#> 3 3 0.967           0.897       0.963         0.2673 0.849   0.714
#> 4 4 0.915           0.934       0.964         0.1297 0.878   0.698
#> 5 5 1.000           0.970       0.983         0.0504 0.991   0.968
#> 6 6 0.910           0.925       0.939         0.0351 0.974   0.910

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM155448     1   0.000      1.000 1.000 0.000
#> GSM155452     1   0.000      1.000 1.000 0.000
#> GSM155455     1   0.000      1.000 1.000 0.000
#> GSM155459     1   0.000      1.000 1.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000
#> GSM155483     2   0.000      0.955 0.000 1.000
#> GSM155487     2   0.000      0.955 0.000 1.000
#> GSM155491     1   0.000      1.000 1.000 0.000
#> GSM155495     2   0.000      0.955 0.000 1.000
#> GSM155499     2   0.000      0.955 0.000 1.000
#> GSM155503     2   0.000      0.955 0.000 1.000
#> GSM155449     1   0.000      1.000 1.000 0.000
#> GSM155456     1   0.000      1.000 1.000 0.000
#> GSM155460     1   0.000      1.000 1.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000
#> GSM155484     2   0.000      0.955 0.000 1.000
#> GSM155488     2   0.000      0.955 0.000 1.000
#> GSM155492     2   1.000      0.100 0.488 0.512
#> GSM155496     2   0.000      0.955 0.000 1.000
#> GSM155500     2   0.000      0.955 0.000 1.000
#> GSM155504     2   0.000      0.955 0.000 1.000
#> GSM155450     1   0.000      1.000 1.000 0.000
#> GSM155453     2   0.000      0.955 0.000 1.000
#> GSM155457     1   0.000      1.000 1.000 0.000
#> GSM155461     1   0.000      1.000 1.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000
#> GSM155485     2   0.000      0.955 0.000 1.000
#> GSM155489     2   0.000      0.955 0.000 1.000
#> GSM155493     2   0.697      0.764 0.188 0.812
#> GSM155497     1   0.000      1.000 1.000 0.000
#> GSM155501     2   0.000      0.955 0.000 1.000
#> GSM155505     2   0.000      0.955 0.000 1.000
#> GSM155451     2   0.891      0.577 0.308 0.692
#> GSM155454     2   0.000      0.955 0.000 1.000
#> GSM155458     1   0.000      1.000 1.000 0.000
#> GSM155462     1   0.000      1.000 1.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000
#> GSM155478     1   0.000      1.000 1.000 0.000
#> GSM155482     1   0.000      1.000 1.000 0.000
#> GSM155486     2   0.000      0.955 0.000 1.000
#> GSM155490     2   0.000      0.955 0.000 1.000
#> GSM155494     1   0.000      1.000 1.000 0.000
#> GSM155498     1   0.000      1.000 1.000 0.000
#> GSM155502     2   0.000      0.955 0.000 1.000
#> GSM155506     2   0.000      0.955 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
#> GSM155448     3  0.6309      0.123 0.496 0.000 0.504
#> GSM155452     1  0.0424      0.971 0.992 0.000 0.008
#> GSM155455     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155459     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155463     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155475     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155479     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155483     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155487     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155491     3  0.0000      0.792 0.000 0.000 1.000
#> GSM155495     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155499     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155503     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155449     1  0.6308     -0.207 0.508 0.000 0.492
#> GSM155456     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155460     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155464     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155472     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155476     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155484     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155488     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155492     3  0.0000      0.792 0.000 0.000 1.000
#> GSM155496     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155500     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155504     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155450     3  0.6309      0.123 0.496 0.000 0.504
#> GSM155453     2  0.4346      0.755 0.000 0.816 0.184
#> GSM155457     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155461     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155465     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155469     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155473     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155477     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155481     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155485     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155489     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155493     3  0.0000      0.792 0.000 0.000 1.000
#> GSM155497     3  0.0000      0.792 0.000 0.000 1.000
#> GSM155501     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155451     3  0.8363      0.191 0.084 0.412 0.504
#> GSM155454     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155458     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155462     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155466     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155470     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155474     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155478     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155482     1  0.0000      0.980 1.000 0.000 0.000
#> GSM155486     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155490     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155494     3  0.0000      0.792 0.000 0.000 1.000
#> GSM155498     3  0.0000      0.792 0.000 0.000 1.000
#> GSM155502     2  0.0000      0.989 0.000 1.000 0.000
#> GSM155506     2  0.0000      0.989 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
#> GSM155448     4   0.000      0.617 0.000 0.000  0 1.000
#> GSM155452     4   0.487      0.620 0.404 0.000  0 0.596
#> GSM155455     4   0.487      0.620 0.404 0.000  0 0.596
#> GSM155459     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155483     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155487     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155491     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM155495     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155499     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155503     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155449     4   0.000      0.617 0.000 0.000  0 1.000
#> GSM155456     4   0.487      0.620 0.404 0.000  0 0.596
#> GSM155460     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155484     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155488     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155492     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM155496     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155500     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155504     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155450     4   0.000      0.617 0.000 0.000  0 1.000
#> GSM155453     4   0.208      0.549 0.000 0.084  0 0.916
#> GSM155457     4   0.487      0.620 0.404 0.000  0 0.596
#> GSM155461     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155485     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155489     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155493     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM155497     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM155501     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155505     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155451     4   0.000      0.617 0.000 0.000  0 1.000
#> GSM155454     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155458     4   0.487      0.620 0.404 0.000  0 0.596
#> GSM155462     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155478     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155482     1   0.000      1.000 1.000 0.000  0 0.000
#> GSM155486     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155490     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155494     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM155498     3   0.000      1.000 0.000 0.000  1 0.000
#> GSM155502     2   0.000      1.000 0.000 1.000  0 0.000
#> GSM155506     2   0.000      1.000 0.000 1.000  0 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
#> GSM155448     4  0.3561      0.716 0.000 0.000  0 0.740 0.260
#> GSM155452     4  0.0162      0.869 0.004 0.000  0 0.996 0.000
#> GSM155455     4  0.0162      0.869 0.004 0.000  0 0.996 0.000
#> GSM155459     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155463     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155467     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155471     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155475     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155479     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155483     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155487     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155491     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155495     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155499     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155503     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155449     4  0.3242      0.755 0.000 0.000  0 0.784 0.216
#> GSM155456     4  0.0162      0.869 0.004 0.000  0 0.996 0.000
#> GSM155460     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155464     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155468     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155472     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155476     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155480     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155484     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155488     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155496     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> GSM155500     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155504     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155450     4  0.3895      0.635 0.000 0.000  0 0.680 0.320
#> GSM155453     5  0.0703      0.987 0.000 0.000  0 0.024 0.976
#> GSM155457     4  0.0162      0.869 0.004 0.000  0 0.996 0.000
#> GSM155461     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155465     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155469     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155473     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155477     1  0.0000      0.995 1.000 0.000  0 0.000 0.000
#> GSM155481     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155485     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155489     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155501     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155505     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155451     5  0.0963      0.987 0.000 0.000  0 0.036 0.964
#> GSM155454     2  0.0162      0.996 0.000 0.996  0 0.000 0.004
#> GSM155458     4  0.0162      0.869 0.004 0.000  0 0.996 0.000
#> GSM155462     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155466     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155470     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155474     1  0.0162      0.995 0.996 0.000  0 0.004 0.000
#> GSM155478     1  0.1106      0.965 0.964 0.000  0 0.012 0.024
#> GSM155482     1  0.1106      0.965 0.964 0.000  0 0.012 0.024
#> GSM155486     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155490     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155494     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155502     2  0.0000      1.000 0.000 1.000  0 0.000 0.000
#> GSM155506     2  0.0000      1.000 0.000 1.000  0 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
#> GSM155448     4  0.5087      0.484 0.000 0.000 0.000 0.560 0.348 0.092
#> GSM155452     4  0.0260      0.796 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM155455     4  0.0260      0.796 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM155459     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155467     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155471     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155483     2  0.2260      0.901 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM155487     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155491     3  0.0146      0.994 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM155495     2  0.2562      0.883 0.000 0.828 0.000 0.000 0.000 0.172
#> GSM155499     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155449     4  0.4845      0.564 0.000 0.000 0.000 0.628 0.280 0.092
#> GSM155456     4  0.0260      0.796 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM155460     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155468     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155472     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155476     1  0.0260      0.989 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155480     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155484     2  0.2260      0.901 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM155488     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155492     3  0.0458      0.990 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM155496     2  0.3266      0.795 0.000 0.728 0.000 0.000 0.000 0.272
#> GSM155500     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155450     4  0.5104      0.448 0.000 0.000 0.000 0.540 0.372 0.088
#> GSM155453     5  0.1152      0.963 0.000 0.000 0.000 0.004 0.952 0.044
#> GSM155457     4  0.0260      0.796 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM155461     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0146      0.994 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155473     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155485     2  0.2260      0.901 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM155489     2  0.2260      0.901 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM155493     3  0.0458      0.990 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM155497     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155451     5  0.0146      0.963 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM155454     2  0.2631      0.875 0.000 0.820 0.000 0.000 0.000 0.180
#> GSM155458     4  0.0260      0.796 0.008 0.000 0.000 0.992 0.000 0.000
#> GSM155462     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155478     6  0.3907      1.000 0.408 0.000 0.000 0.000 0.004 0.588
#> GSM155482     6  0.3907      1.000 0.408 0.000 0.000 0.000 0.004 0.588
#> GSM155486     2  0.2260      0.901 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM155490     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155494     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3  0.0000      0.994 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2  0.0000      0.932 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-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 time(p) k
#> ATC:skmeans 58   0.979 2
#> ATC:skmeans 55   0.994 3
#> ATC:skmeans 59   0.999 4
#> ATC:skmeans 59   0.987 5
#> ATC:skmeans 57   0.834 6

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


ATC:pam*

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4319 0.569   0.569
#> 3 3 0.828           0.936       0.949         0.3016 0.861   0.755
#> 4 4 1.000           0.989       0.990         0.0997 0.947   0.879
#> 5 5 0.837           0.861       0.909         0.2401 0.840   0.586
#> 6 6 0.946           0.946       0.971         0.0875 0.937   0.720

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

suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 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
#> GSM155448     1       0          1  1  0
#> GSM155452     1       0          1  1  0
#> GSM155455     1       0          1  1  0
#> GSM155459     1       0          1  1  0
#> GSM155463     1       0          1  1  0
#> GSM155467     1       0          1  1  0
#> GSM155471     1       0          1  1  0
#> GSM155475     1       0          1  1  0
#> GSM155479     1       0          1  1  0
#> GSM155483     2       0          1  0  1
#> GSM155487     2       0          1  0  1
#> GSM155491     1       0          1  1  0
#> GSM155495     2       0          1  0  1
#> GSM155499     2       0          1  0  1
#> GSM155503     2       0          1  0  1
#> GSM155449     1       0          1  1  0
#> GSM155456     1       0          1  1  0
#> GSM155460     1       0          1  1  0
#> GSM155464     1       0          1  1  0
#> GSM155468     1       0          1  1  0
#> GSM155472     1       0          1  1  0
#> GSM155476     1       0          1  1  0
#> GSM155480     1       0          1  1  0
#> GSM155484     2       0          1  0  1
#> GSM155488     2       0          1  0  1
#> GSM155492     1       0          1  1  0
#> GSM155496     1       0          1  1  0
#> GSM155500     2       0          1  0  1
#> GSM155504     2       0          1  0  1
#> GSM155450     1       0          1  1  0
#> GSM155453     1       0          1  1  0
#> GSM155457     1       0          1  1  0
#> GSM155461     1       0          1  1  0
#> GSM155465     1       0          1  1  0
#> GSM155469     1       0          1  1  0
#> GSM155473     1       0          1  1  0
#> GSM155477     1       0          1  1  0
#> GSM155481     1       0          1  1  0
#> GSM155485     2       0          1  0  1
#> GSM155489     2       0          1  0  1
#> GSM155493     1       0          1  1  0
#> GSM155497     1       0          1  1  0
#> GSM155501     2       0          1  0  1
#> GSM155505     2       0          1  0  1
#> GSM155451     1       0          1  1  0
#> GSM155454     2       0          1  0  1
#> GSM155458     1       0          1  1  0
#> GSM155462     1       0          1  1  0
#> GSM155466     1       0          1  1  0
#> GSM155470     1       0          1  1  0
#> GSM155474     1       0          1  1  0
#> GSM155478     1       0          1  1  0
#> GSM155482     1       0          1  1  0
#> GSM155486     2       0          1  0  1
#> GSM155490     2       0          1  0  1
#> GSM155494     1       0          1  1  0
#> GSM155498     1       0          1  1  0
#> GSM155502     2       0          1  0  1
#> GSM155506     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
#> GSM155448     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155452     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155455     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155459     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155463     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155467     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155471     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155475     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155479     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155483     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155487     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155491     3   0.455     0.9520 0.200 0.0 0.800
#> GSM155495     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155499     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155503     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155449     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155456     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155460     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155464     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155468     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155472     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155476     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155480     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155484     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155488     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155492     3   0.455     0.9520 0.200 0.0 0.800
#> GSM155496     3   0.000     0.6696 0.000 0.0 1.000
#> GSM155500     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155504     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155450     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155453     1   0.615     0.0186 0.592 0.0 0.408
#> GSM155457     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155461     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155465     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155469     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155473     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155477     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155481     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155485     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155489     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155493     3   0.455     0.9520 0.200 0.0 0.800
#> GSM155497     3   0.455     0.9520 0.200 0.0 0.800
#> GSM155501     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155505     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155451     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155454     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155458     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155462     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155466     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155470     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155474     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155478     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155482     1   0.000     0.9848 1.000 0.0 0.000
#> GSM155486     2   0.455     0.8774 0.000 0.8 0.200
#> GSM155490     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155494     3   0.455     0.9520 0.200 0.0 0.800
#> GSM155498     3   0.455     0.9520 0.200 0.0 0.800
#> GSM155502     2   0.000     0.9252 0.000 1.0 0.000
#> GSM155506     2   0.000     0.9252 0.000 1.0 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155452     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155455     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155459     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155483     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155487     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155491     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155495     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155499     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155503     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155449     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155456     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155460     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155472     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155476     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155484     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155488     2  0.2149      0.901 0.000 0.912 0.088 0.000
#> GSM155492     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155496     3  0.0817      0.967 0.000 0.000 0.976 0.024
#> GSM155500     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155504     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155450     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155453     1  0.1792      0.943 0.932 0.000 0.068 0.000
#> GSM155457     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155461     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155485     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155489     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155493     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155497     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155501     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155505     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155451     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155454     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155458     1  0.0817      0.982 0.976 0.000 0.024 0.000
#> GSM155462     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155478     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155482     1  0.0000      0.992 1.000 0.000 0.000 0.000
#> GSM155486     3  0.0817      0.995 0.000 0.024 0.976 0.000
#> GSM155490     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155494     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155498     4  0.0000      1.000 0.000 0.000 0.000 1.000
#> GSM155502     2  0.0000      0.991 0.000 1.000 0.000 0.000
#> GSM155506     2  0.0000      0.991 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
#> GSM155448     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155452     1   0.000      0.345 1.000 0.000  0 0.000 0.000
#> GSM155455     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155459     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155463     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155467     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155471     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155475     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155479     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155483     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155487     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155491     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155495     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155499     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155503     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155449     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155456     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155460     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155464     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155468     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155472     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155476     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155480     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155484     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155488     2   0.207      0.883 0.000 0.896  0 0.000 0.104
#> GSM155492     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155496     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155500     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155504     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155450     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155453     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155457     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155461     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155465     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155469     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155473     1   0.430      0.811 0.512 0.000  0 0.488 0.000
#> GSM155477     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155481     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155485     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155489     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155493     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155497     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155501     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155505     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155451     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155454     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155458     4   0.418      0.683 0.400 0.000  0 0.600 0.000
#> GSM155462     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155466     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155470     1   0.418      0.940 0.600 0.000  0 0.400 0.000
#> GSM155474     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155478     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155482     4   0.000      0.696 0.000 0.000  0 1.000 0.000
#> GSM155486     5   0.000      1.000 0.000 0.000  0 0.000 1.000
#> GSM155490     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155494     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155498     3   0.000      1.000 0.000 0.000  1 0.000 0.000
#> GSM155502     2   0.000      0.989 0.000 1.000  0 0.000 0.000
#> GSM155506     2   0.000      0.989 0.000 1.000  0 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
#> GSM155448     4  0.0000      0.847 0.000 0.000  0 1.000 0.000 0.000
#> GSM155452     1  0.0146      0.943 0.996 0.000  0 0.004 0.000 0.000
#> GSM155455     4  0.3266      0.756 0.000 0.000  0 0.728 0.000 0.272
#> GSM155459     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155463     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155467     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155471     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155475     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155479     1  0.3076      0.719 0.760 0.000  0 0.000 0.000 0.240
#> GSM155483     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155487     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155491     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155495     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155499     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155503     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155449     4  0.0000      0.847 0.000 0.000  0 1.000 0.000 0.000
#> GSM155456     4  0.3266      0.756 0.000 0.000  0 0.728 0.000 0.272
#> GSM155460     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155464     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155468     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155472     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155476     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155480     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155484     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155488     2  0.1863      0.883 0.000 0.896  0 0.000 0.104 0.000
#> GSM155492     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155496     5  0.0260      0.992 0.000 0.000  0 0.008 0.992 0.000
#> GSM155500     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155504     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155450     4  0.0000      0.847 0.000 0.000  0 1.000 0.000 0.000
#> GSM155453     4  0.0000      0.847 0.000 0.000  0 1.000 0.000 0.000
#> GSM155457     4  0.3266      0.756 0.000 0.000  0 0.728 0.000 0.272
#> GSM155461     1  0.0146      0.943 0.996 0.000  0 0.000 0.000 0.004
#> GSM155465     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155469     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155473     1  0.0458      0.936 0.984 0.000  0 0.000 0.000 0.016
#> GSM155477     1  0.3076      0.719 0.760 0.000  0 0.000 0.000 0.240
#> GSM155481     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155485     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155489     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155493     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155497     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155501     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155505     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155451     4  0.0000      0.847 0.000 0.000  0 1.000 0.000 0.000
#> GSM155454     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155458     4  0.2597      0.816 0.000 0.000  0 0.824 0.000 0.176
#> GSM155462     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.945 1.000 0.000  0 0.000 0.000 0.000
#> GSM155470     1  0.1267      0.901 0.940 0.000  0 0.000 0.000 0.060
#> GSM155474     6  0.0547      0.974 0.020 0.000  0 0.000 0.000 0.980
#> GSM155478     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155482     6  0.0000      0.998 0.000 0.000  0 0.000 0.000 1.000
#> GSM155486     5  0.0000      0.999 0.000 0.000  0 0.000 1.000 0.000
#> GSM155490     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155494     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155498     3  0.0000      1.000 0.000 0.000  1 0.000 0.000 0.000
#> GSM155502     2  0.0000      0.989 0.000 1.000  0 0.000 0.000 0.000
#> GSM155506     2  0.0000      0.989 0.000 1.000  0 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 time(p) k
#> ATC:pam 59   0.971 2
#> ATC:pam 58   0.995 3
#> ATC:pam 59   0.999 4
#> ATC:pam 58   0.974 5
#> ATC:pam 59   0.966 6

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


ATC:mclust**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.4972 0.503   0.503
#> 3 3 0.881           0.934       0.957         0.3351 0.710   0.482
#> 4 4 0.912           0.889       0.942         0.0970 0.947   0.837
#> 5 5 0.961           0.889       0.959         0.0469 0.948   0.813
#> 6 6 0.976           0.920       0.965         0.0263 0.970   0.873

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

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

There is also optional best \(k\) = 2 4 5 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
#> GSM155448     1  0.0672      0.994 0.992 0.008
#> GSM155452     1  0.0672      0.994 0.992 0.008
#> GSM155455     1  0.0672      0.994 0.992 0.008
#> GSM155459     1  0.0000      0.997 1.000 0.000
#> GSM155463     1  0.0000      0.997 1.000 0.000
#> GSM155467     1  0.0000      0.997 1.000 0.000
#> GSM155471     1  0.0000      0.997 1.000 0.000
#> GSM155475     1  0.0000      0.997 1.000 0.000
#> GSM155479     1  0.0000      0.997 1.000 0.000
#> GSM155483     2  0.0000      1.000 0.000 1.000
#> GSM155487     2  0.0000      1.000 0.000 1.000
#> GSM155491     2  0.0000      1.000 0.000 1.000
#> GSM155495     2  0.0000      1.000 0.000 1.000
#> GSM155499     2  0.0000      1.000 0.000 1.000
#> GSM155503     2  0.0000      1.000 0.000 1.000
#> GSM155449     1  0.0672      0.994 0.992 0.008
#> GSM155456     1  0.0672      0.994 0.992 0.008
#> GSM155460     1  0.0000      0.997 1.000 0.000
#> GSM155464     1  0.0000      0.997 1.000 0.000
#> GSM155468     1  0.0000      0.997 1.000 0.000
#> GSM155472     1  0.0000      0.997 1.000 0.000
#> GSM155476     1  0.0000      0.997 1.000 0.000
#> GSM155480     1  0.0000      0.997 1.000 0.000
#> GSM155484     2  0.0000      1.000 0.000 1.000
#> GSM155488     2  0.0000      1.000 0.000 1.000
#> GSM155492     2  0.0000      1.000 0.000 1.000
#> GSM155496     2  0.0000      1.000 0.000 1.000
#> GSM155500     2  0.0000      1.000 0.000 1.000
#> GSM155504     2  0.0000      1.000 0.000 1.000
#> GSM155450     1  0.0672      0.994 0.992 0.008
#> GSM155453     1  0.0672      0.994 0.992 0.008
#> GSM155457     1  0.0672      0.994 0.992 0.008
#> GSM155461     1  0.0000      0.997 1.000 0.000
#> GSM155465     1  0.0000      0.997 1.000 0.000
#> GSM155469     1  0.0000      0.997 1.000 0.000
#> GSM155473     1  0.0000      0.997 1.000 0.000
#> GSM155477     1  0.0000      0.997 1.000 0.000
#> GSM155481     1  0.0000      0.997 1.000 0.000
#> GSM155485     2  0.0000      1.000 0.000 1.000
#> GSM155489     2  0.0000      1.000 0.000 1.000
#> GSM155493     2  0.0000      1.000 0.000 1.000
#> GSM155497     2  0.0000      1.000 0.000 1.000
#> GSM155501     2  0.0000      1.000 0.000 1.000
#> GSM155505     2  0.0000      1.000 0.000 1.000
#> GSM155451     1  0.0672      0.994 0.992 0.008
#> GSM155454     2  0.0000      1.000 0.000 1.000
#> GSM155458     1  0.0672      0.994 0.992 0.008
#> GSM155462     1  0.0000      0.997 1.000 0.000
#> GSM155466     1  0.0000      0.997 1.000 0.000
#> GSM155470     1  0.0000      0.997 1.000 0.000
#> GSM155474     1  0.0000      0.997 1.000 0.000
#> GSM155478     1  0.0376      0.996 0.996 0.004
#> GSM155482     1  0.0376      0.996 0.996 0.004
#> GSM155486     2  0.0000      1.000 0.000 1.000
#> GSM155490     2  0.0000      1.000 0.000 1.000
#> GSM155494     2  0.0000      1.000 0.000 1.000
#> GSM155498     2  0.0000      1.000 0.000 1.000
#> GSM155502     2  0.0000      1.000 0.000 1.000
#> GSM155506     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
#> GSM155448     3   0.196      0.929 0.056 0.000 0.944
#> GSM155452     3   0.196      0.929 0.056 0.000 0.944
#> GSM155455     3   0.196      0.929 0.056 0.000 0.944
#> GSM155459     1   0.000      1.000 1.000 0.000 0.000
#> GSM155463     1   0.000      1.000 1.000 0.000 0.000
#> GSM155467     1   0.000      1.000 1.000 0.000 0.000
#> GSM155471     1   0.000      1.000 1.000 0.000 0.000
#> GSM155475     1   0.000      1.000 1.000 0.000 0.000
#> GSM155479     1   0.000      1.000 1.000 0.000 0.000
#> GSM155483     2   0.406      0.896 0.000 0.836 0.164
#> GSM155487     2   0.000      0.931 0.000 1.000 0.000
#> GSM155491     3   0.000      0.913 0.000 0.000 1.000
#> GSM155495     2   0.406      0.896 0.000 0.836 0.164
#> GSM155499     2   0.000      0.931 0.000 1.000 0.000
#> GSM155503     2   0.000      0.931 0.000 1.000 0.000
#> GSM155449     3   0.196      0.929 0.056 0.000 0.944
#> GSM155456     3   0.196      0.929 0.056 0.000 0.944
#> GSM155460     1   0.000      1.000 1.000 0.000 0.000
#> GSM155464     1   0.000      1.000 1.000 0.000 0.000
#> GSM155468     1   0.000      1.000 1.000 0.000 0.000
#> GSM155472     1   0.000      1.000 1.000 0.000 0.000
#> GSM155476     1   0.000      1.000 1.000 0.000 0.000
#> GSM155480     1   0.000      1.000 1.000 0.000 0.000
#> GSM155484     2   0.406      0.896 0.000 0.836 0.164
#> GSM155488     2   0.312      0.907 0.000 0.892 0.108
#> GSM155492     3   0.000      0.913 0.000 0.000 1.000
#> GSM155496     3   0.000      0.913 0.000 0.000 1.000
#> GSM155500     2   0.000      0.931 0.000 1.000 0.000
#> GSM155504     2   0.000      0.931 0.000 1.000 0.000
#> GSM155450     3   0.196      0.929 0.056 0.000 0.944
#> GSM155453     3   0.196      0.929 0.056 0.000 0.944
#> GSM155457     3   0.196      0.929 0.056 0.000 0.944
#> GSM155461     1   0.000      1.000 1.000 0.000 0.000
#> GSM155465     1   0.000      1.000 1.000 0.000 0.000
#> GSM155469     1   0.000      1.000 1.000 0.000 0.000
#> GSM155473     1   0.000      1.000 1.000 0.000 0.000
#> GSM155477     1   0.000      1.000 1.000 0.000 0.000
#> GSM155481     1   0.000      1.000 1.000 0.000 0.000
#> GSM155485     2   0.406      0.896 0.000 0.836 0.164
#> GSM155489     2   0.406      0.896 0.000 0.836 0.164
#> GSM155493     3   0.000      0.913 0.000 0.000 1.000
#> GSM155497     3   0.000      0.913 0.000 0.000 1.000
#> GSM155501     2   0.000      0.931 0.000 1.000 0.000
#> GSM155505     2   0.000      0.931 0.000 1.000 0.000
#> GSM155451     3   0.196      0.929 0.056 0.000 0.944
#> GSM155454     3   0.196      0.896 0.000 0.056 0.944
#> GSM155458     3   0.196      0.929 0.056 0.000 0.944
#> GSM155462     1   0.000      1.000 1.000 0.000 0.000
#> GSM155466     1   0.000      1.000 1.000 0.000 0.000
#> GSM155470     1   0.000      1.000 1.000 0.000 0.000
#> GSM155474     1   0.000      1.000 1.000 0.000 0.000
#> GSM155478     3   0.604      0.483 0.380 0.000 0.620
#> GSM155482     3   0.604      0.483 0.380 0.000 0.620
#> GSM155486     2   0.406      0.896 0.000 0.836 0.164
#> GSM155490     2   0.226      0.920 0.000 0.932 0.068
#> GSM155494     3   0.000      0.913 0.000 0.000 1.000
#> GSM155498     3   0.000      0.913 0.000 0.000 1.000
#> GSM155502     2   0.000      0.931 0.000 1.000 0.000
#> GSM155506     2   0.000      0.931 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
#> GSM155448     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155452     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155455     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155459     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155463     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155467     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155471     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155475     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155479     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155483     2   0.470      0.646 0.000 0.644 0.356 0.000
#> GSM155487     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155491     3   0.000      0.981 0.000 0.000 1.000 0.000
#> GSM155495     2   0.470      0.646 0.000 0.644 0.356 0.000
#> GSM155499     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155503     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155449     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155456     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155460     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155464     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155468     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155472     1   0.102      0.964 0.968 0.000 0.000 0.032
#> GSM155476     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155480     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155484     2   0.470      0.646 0.000 0.644 0.356 0.000
#> GSM155488     2   0.425      0.701 0.000 0.724 0.276 0.000
#> GSM155492     3   0.000      0.981 0.000 0.000 1.000 0.000
#> GSM155496     3   0.215      0.872 0.000 0.088 0.912 0.000
#> GSM155500     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155504     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155450     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155453     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155457     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155461     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155465     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155469     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155473     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155477     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155481     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155485     2   0.470      0.646 0.000 0.644 0.356 0.000
#> GSM155489     2   0.470      0.646 0.000 0.644 0.356 0.000
#> GSM155493     3   0.000      0.981 0.000 0.000 1.000 0.000
#> GSM155497     3   0.000      0.981 0.000 0.000 1.000 0.000
#> GSM155501     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155505     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155451     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155454     4   0.387      0.694 0.000 0.228 0.000 0.772
#> GSM155458     4   0.000      0.911 0.000 0.000 0.000 1.000
#> GSM155462     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155466     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155470     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155474     1   0.000      0.998 1.000 0.000 0.000 0.000
#> GSM155478     4   0.443      0.596 0.304 0.000 0.000 0.696
#> GSM155482     4   0.443      0.596 0.304 0.000 0.000 0.696
#> GSM155486     2   0.470      0.646 0.000 0.644 0.356 0.000
#> GSM155490     2   0.130      0.808 0.000 0.956 0.044 0.000
#> GSM155494     3   0.000      0.981 0.000 0.000 1.000 0.000
#> GSM155498     3   0.000      0.981 0.000 0.000 1.000 0.000
#> GSM155502     2   0.000      0.819 0.000 1.000 0.000 0.000
#> GSM155506     2   0.000      0.819 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
#> GSM155448     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155452     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155455     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155459     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155483     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155487     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155491     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000
#> GSM155495     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155499     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155449     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155456     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155460     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.0404      0.986 0.988 0.000 0.000 0.012 0.000
#> GSM155476     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155484     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155488     2  0.4273      0.247 0.000 0.552 0.000 0.000 0.448
#> GSM155492     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000
#> GSM155496     3  0.4171      0.334 0.000 0.000 0.604 0.000 0.396
#> GSM155500     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155450     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155453     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155457     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155461     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155481     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155485     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155489     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155493     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000
#> GSM155497     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000
#> GSM155501     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155451     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155454     2  0.4210      0.300 0.000 0.588 0.000 0.412 0.000
#> GSM155458     4  0.0000      0.890 0.000 0.000 0.000 1.000 0.000
#> GSM155462     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM155478     4  0.4262      0.286 0.440 0.000 0.000 0.560 0.000
#> GSM155482     4  0.4219      0.349 0.416 0.000 0.000 0.584 0.000
#> GSM155486     5  0.0000      1.000 0.000 0.000 0.000 0.000 1.000
#> GSM155490     2  0.3913      0.525 0.000 0.676 0.000 0.000 0.324
#> GSM155494     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000
#> GSM155498     3  0.0000      0.931 0.000 0.000 1.000 0.000 0.000
#> GSM155502     2  0.0000      0.882 0.000 1.000 0.000 0.000 0.000
#> GSM155506     2  0.0000      0.882 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
#> GSM155448     4  0.0260      0.935 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM155452     4  0.0713      0.938 0.000 0.000 0.000 0.972 0.000 0.028
#> GSM155455     4  0.2135      0.913 0.000 0.000 0.000 0.872 0.000 0.128
#> GSM155459     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155463     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155467     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155471     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155475     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155479     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155483     5  0.0000      0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155487     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155491     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155495     5  0.0000      0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155499     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155449     4  0.0790      0.938 0.000 0.000 0.000 0.968 0.000 0.032
#> GSM155456     4  0.2135      0.913 0.000 0.000 0.000 0.872 0.000 0.128
#> GSM155460     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155464     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155468     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155472     1  0.0547      0.980 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM155476     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155480     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155484     5  0.0000      0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155488     5  0.3390      0.578 0.000 0.296 0.000 0.000 0.704 0.000
#> GSM155492     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155496     3  0.2996      0.680 0.000 0.000 0.772 0.000 0.228 0.000
#> GSM155500     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155504     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155450     4  0.0260      0.935 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM155453     4  0.0260      0.935 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM155457     4  0.2135      0.913 0.000 0.000 0.000 0.872 0.000 0.128
#> GSM155461     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155465     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155469     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155473     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155477     1  0.0146      0.995 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM155481     1  0.0260      0.992 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM155485     5  0.0000      0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155489     5  0.0000      0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155493     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155497     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155501     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155505     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155451     4  0.0260      0.935 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM155454     2  0.3782      0.314 0.000 0.588 0.000 0.412 0.000 0.000
#> GSM155458     4  0.1957      0.920 0.000 0.000 0.000 0.888 0.000 0.112
#> GSM155462     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155466     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155470     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155474     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM155478     6  0.0937      0.980 0.040 0.000 0.000 0.000 0.000 0.960
#> GSM155482     6  0.0713      0.980 0.028 0.000 0.000 0.000 0.000 0.972
#> GSM155486     5  0.0000      0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM155490     5  0.3851      0.234 0.000 0.460 0.000 0.000 0.540 0.000
#> GSM155494     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155498     3  0.0000      0.952 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM155502     2  0.0000      0.942 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM155506     2  0.0000      0.942 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-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 time(p) k
#> ATC:mclust 59   0.980 2
#> ATC:mclust 57   0.993 3
#> ATC:mclust 59   0.979 4
#> ATC:mclust 54   0.999 5
#> ATC:mclust 57   0.908 6

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


ATC:NMF**

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

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

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

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

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.986       0.994         0.4410 0.556   0.556
#> 3 3 0.999           0.977       0.987         0.3419 0.837   0.711
#> 4 4 0.721           0.691       0.801         0.1519 0.891   0.743
#> 5 5 0.836           0.902       0.906         0.0881 0.866   0.625
#> 6 6 0.921           0.880       0.906         0.0309 1.000   1.000

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
#> GSM155448     1   0.000      0.999 1.000 0.000
#> GSM155452     1   0.000      0.999 1.000 0.000
#> GSM155455     1   0.000      0.999 1.000 0.000
#> GSM155459     1   0.000      0.999 1.000 0.000
#> GSM155463     1   0.000      0.999 1.000 0.000
#> GSM155467     1   0.000      0.999 1.000 0.000
#> GSM155471     1   0.000      0.999 1.000 0.000
#> GSM155475     1   0.000      0.999 1.000 0.000
#> GSM155479     1   0.000      0.999 1.000 0.000
#> GSM155483     2   0.000      0.982 0.000 1.000
#> GSM155487     2   0.000      0.982 0.000 1.000
#> GSM155491     1   0.000      0.999 1.000 0.000
#> GSM155495     2   0.000      0.982 0.000 1.000
#> GSM155499     2   0.000      0.982 0.000 1.000
#> GSM155503     2   0.000      0.982 0.000 1.000
#> GSM155449     1   0.000      0.999 1.000 0.000
#> GSM155456     1   0.000      0.999 1.000 0.000
#> GSM155460     1   0.000      0.999 1.000 0.000
#> GSM155464     1   0.000      0.999 1.000 0.000
#> GSM155468     1   0.000      0.999 1.000 0.000
#> GSM155472     1   0.000      0.999 1.000 0.000
#> GSM155476     1   0.000      0.999 1.000 0.000
#> GSM155480     1   0.000      0.999 1.000 0.000
#> GSM155484     2   0.000      0.982 0.000 1.000
#> GSM155488     2   0.000      0.982 0.000 1.000
#> GSM155492     1   0.000      0.999 1.000 0.000
#> GSM155496     2   0.900      0.537 0.316 0.684
#> GSM155500     2   0.000      0.982 0.000 1.000
#> GSM155504     2   0.000      0.982 0.000 1.000
#> GSM155450     1   0.000      0.999 1.000 0.000
#> GSM155453     1   0.204      0.966 0.968 0.032
#> GSM155457     1   0.000      0.999 1.000 0.000
#> GSM155461     1   0.000      0.999 1.000 0.000
#> GSM155465     1   0.000      0.999 1.000 0.000
#> GSM155469     1   0.000      0.999 1.000 0.000
#> GSM155473     1   0.000      0.999 1.000 0.000
#> GSM155477     1   0.000      0.999 1.000 0.000
#> GSM155481     1   0.000      0.999 1.000 0.000
#> GSM155485     2   0.000      0.982 0.000 1.000
#> GSM155489     2   0.000      0.982 0.000 1.000
#> GSM155493     1   0.000      0.999 1.000 0.000
#> GSM155497     1   0.000      0.999 1.000 0.000
#> GSM155501     2   0.000      0.982 0.000 1.000
#> GSM155505     2   0.000      0.982 0.000 1.000
#> GSM155451     1   0.000      0.999 1.000 0.000
#> GSM155454     2   0.000      0.982 0.000 1.000
#> GSM155458     1   0.000      0.999 1.000 0.000
#> GSM155462     1   0.000      0.999 1.000 0.000
#> GSM155466     1   0.000      0.999 1.000 0.000
#> GSM155470     1   0.000      0.999 1.000 0.000
#> GSM155474     1   0.000      0.999 1.000 0.000
#> GSM155478     1   0.000      0.999 1.000 0.000
#> GSM155482     1   0.000      0.999 1.000 0.000
#> GSM155486     2   0.000      0.982 0.000 1.000
#> GSM155490     2   0.000      0.982 0.000 1.000
#> GSM155494     1   0.000      0.999 1.000 0.000
#> GSM155498     1   0.000      0.999 1.000 0.000
#> GSM155502     2   0.000      0.982 0.000 1.000
#> GSM155506     2   0.000      0.982 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
#> GSM155448     1  0.0892      0.984 0.980 0.000 0.020
#> GSM155452     1  0.0424      0.995 0.992 0.000 0.008
#> GSM155455     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155459     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155463     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155467     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155471     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155475     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155479     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155483     2  0.1289      0.954 0.000 0.968 0.032
#> GSM155487     2  0.0237      0.970 0.000 0.996 0.004
#> GSM155491     3  0.0237      0.978 0.004 0.000 0.996
#> GSM155495     3  0.1163      0.958 0.000 0.028 0.972
#> GSM155499     2  0.0237      0.970 0.000 0.996 0.004
#> GSM155503     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155449     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155456     1  0.0424      0.995 0.992 0.000 0.008
#> GSM155460     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155464     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155468     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155472     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155476     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155480     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155484     2  0.0237      0.970 0.000 0.996 0.004
#> GSM155488     2  0.0237      0.970 0.000 0.996 0.004
#> GSM155492     3  0.0000      0.978 0.000 0.000 1.000
#> GSM155496     3  0.0000      0.978 0.000 0.000 1.000
#> GSM155500     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155504     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155450     1  0.0424      0.995 0.992 0.000 0.008
#> GSM155453     3  0.4399      0.864 0.044 0.092 0.864
#> GSM155457     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155461     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155465     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155469     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155473     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155477     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155481     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155485     2  0.2448      0.919 0.000 0.924 0.076
#> GSM155489     2  0.3340      0.876 0.000 0.880 0.120
#> GSM155493     3  0.0000      0.978 0.000 0.000 1.000
#> GSM155497     3  0.0237      0.978 0.004 0.000 0.996
#> GSM155501     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155505     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155451     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155454     2  0.4931      0.721 0.000 0.768 0.232
#> GSM155458     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155462     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155466     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155470     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155474     1  0.0237      0.997 0.996 0.000 0.004
#> GSM155478     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155482     1  0.0000      0.997 1.000 0.000 0.000
#> GSM155486     2  0.0424      0.968 0.000 0.992 0.008
#> GSM155490     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155494     3  0.0237      0.978 0.004 0.000 0.996
#> GSM155498     3  0.0237      0.978 0.004 0.000 0.996
#> GSM155502     2  0.0000      0.970 0.000 1.000 0.000
#> GSM155506     2  0.0237      0.970 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM155448     4  0.7875     0.2658 0.316 0.000 0.296 0.388
#> GSM155452     4  0.7846     0.3042 0.300 0.000 0.296 0.404
#> GSM155455     1  0.7899    -0.2253 0.364 0.000 0.296 0.340
#> GSM155459     1  0.0336     0.8470 0.992 0.000 0.008 0.000
#> GSM155463     1  0.1211     0.8390 0.960 0.000 0.040 0.000
#> GSM155467     1  0.1716     0.8218 0.936 0.000 0.064 0.000
#> GSM155471     1  0.1211     0.8390 0.960 0.000 0.040 0.000
#> GSM155475     1  0.0336     0.8470 0.992 0.000 0.008 0.000
#> GSM155479     1  0.0592     0.8474 0.984 0.000 0.016 0.000
#> GSM155483     3  0.7566     0.8834 0.000 0.320 0.468 0.212
#> GSM155487     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155491     4  0.0817     0.5072 0.000 0.000 0.024 0.976
#> GSM155495     3  0.7575     0.7100 0.000 0.200 0.444 0.356
#> GSM155499     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155503     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155449     1  0.7769    -0.0148 0.432 0.000 0.296 0.272
#> GSM155456     1  0.7547     0.1448 0.488 0.000 0.276 0.236
#> GSM155460     1  0.0336     0.8470 0.992 0.000 0.008 0.000
#> GSM155464     1  0.1118     0.8409 0.964 0.000 0.036 0.000
#> GSM155468     1  0.1302     0.8366 0.956 0.000 0.044 0.000
#> GSM155472     1  0.0000     0.8485 1.000 0.000 0.000 0.000
#> GSM155476     1  0.0817     0.8454 0.976 0.000 0.024 0.000
#> GSM155480     1  0.1022     0.8425 0.968 0.000 0.032 0.000
#> GSM155484     3  0.6887     0.7394 0.000 0.444 0.452 0.104
#> GSM155488     2  0.0188     0.9681 0.000 0.996 0.004 0.000
#> GSM155492     4  0.2589     0.4117 0.000 0.000 0.116 0.884
#> GSM155496     4  0.4855    -0.2461 0.000 0.000 0.400 0.600
#> GSM155500     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155504     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155450     4  0.7828     0.3200 0.292 0.000 0.296 0.412
#> GSM155453     4  0.7407     0.4725 0.176 0.004 0.296 0.524
#> GSM155457     1  0.6876     0.3432 0.572 0.000 0.288 0.140
#> GSM155461     1  0.0707     0.8466 0.980 0.000 0.020 0.000
#> GSM155465     1  0.0188     0.8480 0.996 0.000 0.004 0.000
#> GSM155469     1  0.1211     0.8390 0.960 0.000 0.040 0.000
#> GSM155473     1  0.0188     0.8480 0.996 0.000 0.004 0.000
#> GSM155477     1  0.0592     0.8474 0.984 0.000 0.016 0.000
#> GSM155481     1  0.0336     0.8484 0.992 0.000 0.008 0.000
#> GSM155485     3  0.7620     0.8822 0.000 0.316 0.460 0.224
#> GSM155489     3  0.7638     0.8833 0.000 0.332 0.448 0.220
#> GSM155493     4  0.2973     0.3662 0.000 0.000 0.144 0.856
#> GSM155497     4  0.0188     0.5173 0.000 0.000 0.004 0.996
#> GSM155501     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155505     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155451     1  0.7782    -0.0278 0.428 0.000 0.296 0.276
#> GSM155454     2  0.4292     0.6780 0.000 0.820 0.080 0.100
#> GSM155458     1  0.7439     0.1840 0.500 0.000 0.296 0.204
#> GSM155462     1  0.0336     0.8470 0.992 0.000 0.008 0.000
#> GSM155466     1  0.0188     0.8487 0.996 0.000 0.004 0.000
#> GSM155470     1  0.0000     0.8485 1.000 0.000 0.000 0.000
#> GSM155474     1  0.0000     0.8485 1.000 0.000 0.000 0.000
#> GSM155478     1  0.1867     0.8080 0.928 0.000 0.072 0.000
#> GSM155482     1  0.2921     0.7531 0.860 0.000 0.140 0.000
#> GSM155486     3  0.7365     0.8292 0.000 0.400 0.440 0.160
#> GSM155490     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155494     4  0.1302     0.4927 0.000 0.000 0.044 0.956
#> GSM155498     4  0.0000     0.5170 0.000 0.000 0.000 1.000
#> GSM155502     2  0.0000     0.9727 0.000 1.000 0.000 0.000
#> GSM155506     2  0.0188     0.9683 0.000 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM155448     4  0.1701      0.895 0.048 0.000 0.016 0.936 0.000
#> GSM155452     4  0.3543      0.841 0.060 0.000 0.112 0.828 0.000
#> GSM155455     4  0.2889      0.896 0.084 0.000 0.044 0.872 0.000
#> GSM155459     1  0.1372      0.960 0.956 0.000 0.016 0.004 0.024
#> GSM155463     1  0.0798      0.965 0.976 0.000 0.008 0.000 0.016
#> GSM155467     1  0.1087      0.962 0.968 0.000 0.008 0.008 0.016
#> GSM155471     1  0.0960      0.965 0.972 0.000 0.008 0.004 0.016
#> GSM155475     1  0.1267      0.961 0.960 0.000 0.012 0.004 0.024
#> GSM155479     1  0.0740      0.967 0.980 0.000 0.008 0.008 0.004
#> GSM155483     5  0.4487      0.871 0.000 0.104 0.140 0.000 0.756
#> GSM155487     2  0.0324      0.981 0.000 0.992 0.004 0.004 0.000
#> GSM155491     3  0.2960      0.841 0.008 0.000 0.876 0.080 0.036
#> GSM155495     5  0.4958      0.801 0.000 0.084 0.224 0.000 0.692
#> GSM155499     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM155503     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM155449     4  0.1956      0.903 0.076 0.000 0.008 0.916 0.000
#> GSM155456     4  0.3354      0.860 0.140 0.000 0.024 0.832 0.004
#> GSM155460     1  0.1074      0.964 0.968 0.000 0.012 0.004 0.016
#> GSM155464     1  0.0693      0.966 0.980 0.000 0.008 0.000 0.012
#> GSM155468     1  0.0798      0.965 0.976 0.000 0.008 0.000 0.016
#> GSM155472     1  0.0162      0.968 0.996 0.000 0.000 0.004 0.000
#> GSM155476     1  0.1074      0.964 0.968 0.000 0.012 0.004 0.016
#> GSM155480     1  0.0290      0.968 0.992 0.000 0.000 0.000 0.008
#> GSM155484     5  0.4844      0.827 0.000 0.172 0.108 0.000 0.720
#> GSM155488     2  0.1341      0.933 0.000 0.944 0.000 0.000 0.056
#> GSM155492     3  0.4352      0.697 0.000 0.000 0.720 0.036 0.244
#> GSM155496     5  0.4321      0.421 0.000 0.000 0.396 0.004 0.600
#> GSM155500     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM155504     2  0.0162      0.983 0.000 0.996 0.004 0.000 0.000
#> GSM155450     4  0.1626      0.892 0.044 0.000 0.016 0.940 0.000
#> GSM155453     4  0.2235      0.876 0.032 0.004 0.040 0.920 0.004
#> GSM155457     4  0.2873      0.876 0.120 0.000 0.020 0.860 0.000
#> GSM155461     1  0.0727      0.967 0.980 0.000 0.004 0.004 0.012
#> GSM155465     1  0.0671      0.967 0.980 0.000 0.016 0.004 0.000
#> GSM155469     1  0.0798      0.965 0.976 0.000 0.008 0.000 0.016
#> GSM155473     1  0.0324      0.968 0.992 0.000 0.004 0.004 0.000
#> GSM155477     1  0.1306      0.961 0.960 0.000 0.016 0.008 0.016
#> GSM155481     1  0.0324      0.969 0.992 0.000 0.004 0.004 0.000
#> GSM155485     5  0.4636      0.874 0.000 0.124 0.132 0.000 0.744
#> GSM155489     5  0.4819      0.873 0.000 0.112 0.148 0.004 0.736
#> GSM155493     3  0.4326      0.660 0.000 0.000 0.708 0.028 0.264
#> GSM155497     3  0.2748      0.834 0.008 0.000 0.880 0.096 0.016
#> GSM155501     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM155505     2  0.0162      0.983 0.000 0.996 0.004 0.000 0.000
#> GSM155451     4  0.2407      0.898 0.088 0.000 0.012 0.896 0.004
#> GSM155454     4  0.5412      0.596 0.000 0.216 0.020 0.684 0.080
#> GSM155458     4  0.2358      0.895 0.104 0.000 0.008 0.888 0.000
#> GSM155462     1  0.1471      0.959 0.952 0.000 0.020 0.004 0.024
#> GSM155466     1  0.0566      0.968 0.984 0.000 0.004 0.000 0.012
#> GSM155470     1  0.0451      0.968 0.988 0.000 0.008 0.000 0.004
#> GSM155474     1  0.0162      0.968 0.996 0.000 0.000 0.004 0.000
#> GSM155478     1  0.4220      0.843 0.816 0.000 0.056 0.064 0.064
#> GSM155482     1  0.4091      0.811 0.804 0.000 0.020 0.132 0.044
#> GSM155486     5  0.4801      0.861 0.000 0.148 0.124 0.000 0.728
#> GSM155490     2  0.2418      0.919 0.000 0.912 0.044 0.020 0.024
#> GSM155494     3  0.3911      0.830 0.004 0.000 0.812 0.084 0.100
#> GSM155498     3  0.2408      0.823 0.008 0.000 0.892 0.096 0.004
#> GSM155502     2  0.0000      0.984 0.000 1.000 0.000 0.000 0.000
#> GSM155506     2  0.0290      0.979 0.000 0.992 0.000 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM155448     4  0.1078      0.951 0.008 0.000 0.016 0.964 0.000 NA
#> GSM155452     4  0.2384      0.907 0.032 0.000 0.084 0.884 0.000 NA
#> GSM155455     4  0.1787      0.944 0.032 0.000 0.020 0.932 0.000 NA
#> GSM155459     1  0.0862      0.946 0.972 0.000 0.016 0.008 0.000 NA
#> GSM155463     1  0.0692      0.946 0.976 0.000 0.020 0.000 0.000 NA
#> GSM155467     1  0.0891      0.944 0.968 0.000 0.024 0.000 0.000 NA
#> GSM155471     1  0.1036      0.943 0.964 0.000 0.024 0.008 0.000 NA
#> GSM155475     1  0.0862      0.946 0.972 0.000 0.016 0.004 0.000 NA
#> GSM155479     1  0.0806      0.945 0.972 0.000 0.020 0.000 0.000 NA
#> GSM155483     5  0.1075      0.843 0.000 0.048 0.000 0.000 0.952 NA
#> GSM155487     2  0.2611      0.857 0.000 0.864 0.000 0.008 0.012 NA
#> GSM155491     3  0.3762      0.884 0.004 0.000 0.760 0.020 0.208 NA
#> GSM155495     5  0.4472      0.734 0.000 0.132 0.052 0.000 0.756 NA
#> GSM155499     2  0.1686      0.896 0.000 0.924 0.000 0.012 0.000 NA
#> GSM155503     2  0.0000      0.927 0.000 1.000 0.000 0.000 0.000 NA
#> GSM155449     4  0.0951      0.950 0.008 0.000 0.004 0.968 0.000 NA
#> GSM155456     4  0.2068      0.928 0.048 0.000 0.016 0.916 0.000 NA
#> GSM155460     1  0.0870      0.946 0.972 0.000 0.012 0.012 0.000 NA
#> GSM155464     1  0.0622      0.948 0.980 0.000 0.012 0.000 0.000 NA
#> GSM155468     1  0.0692      0.946 0.976 0.000 0.020 0.000 0.000 NA
#> GSM155472     1  0.0717      0.946 0.976 0.000 0.000 0.008 0.000 NA
#> GSM155476     1  0.1148      0.943 0.960 0.000 0.020 0.004 0.000 NA
#> GSM155480     1  0.0260      0.949 0.992 0.000 0.008 0.000 0.000 NA
#> GSM155484     5  0.2333      0.813 0.000 0.120 0.004 0.000 0.872 NA
#> GSM155488     2  0.2412      0.852 0.000 0.880 0.000 0.000 0.092 NA
#> GSM155492     3  0.3515      0.816 0.000 0.000 0.676 0.000 0.324 NA
#> GSM155496     5  0.4823      0.214 0.000 0.004 0.300 0.004 0.632 NA
#> GSM155500     2  0.0260      0.925 0.000 0.992 0.000 0.000 0.000 NA
#> GSM155504     2  0.0146      0.926 0.000 0.996 0.000 0.000 0.000 NA
#> GSM155450     4  0.1015      0.952 0.012 0.000 0.004 0.968 0.004 NA
#> GSM155453     4  0.1515      0.940 0.000 0.000 0.020 0.944 0.008 NA
#> GSM155457     4  0.1794      0.945 0.028 0.000 0.024 0.932 0.000 NA
#> GSM155461     1  0.0405      0.948 0.988 0.000 0.008 0.004 0.000 NA
#> GSM155465     1  0.1173      0.943 0.960 0.000 0.016 0.016 0.000 NA
#> GSM155469     1  0.0603      0.947 0.980 0.000 0.016 0.000 0.000 NA
#> GSM155473     1  0.0665      0.949 0.980 0.000 0.008 0.004 0.000 NA
#> GSM155477     1  0.1003      0.944 0.964 0.000 0.020 0.000 0.000 NA
#> GSM155481     1  0.0622      0.949 0.980 0.000 0.012 0.000 0.000 NA
#> GSM155485     5  0.1267      0.851 0.000 0.060 0.000 0.000 0.940 NA
#> GSM155489     5  0.1387      0.852 0.000 0.068 0.000 0.000 0.932 NA
#> GSM155493     3  0.3758      0.817 0.000 0.000 0.668 0.008 0.324 NA
#> GSM155497     3  0.3604      0.864 0.004 0.000 0.796 0.032 0.160 NA
#> GSM155501     2  0.0000      0.927 0.000 1.000 0.000 0.000 0.000 NA
#> GSM155505     2  0.0260      0.926 0.000 0.992 0.000 0.000 0.000 NA
#> GSM155451     4  0.0984      0.950 0.008 0.000 0.012 0.968 0.000 NA
#> GSM155454     4  0.3170      0.880 0.000 0.072 0.008 0.860 0.028 NA
#> GSM155458     4  0.0909      0.951 0.020 0.000 0.000 0.968 0.000 NA
#> GSM155462     1  0.0964      0.947 0.968 0.000 0.016 0.004 0.000 NA
#> GSM155466     1  0.0767      0.948 0.976 0.000 0.012 0.004 0.000 NA
#> GSM155470     1  0.0520      0.949 0.984 0.000 0.008 0.000 0.000 NA
#> GSM155474     1  0.0405      0.949 0.988 0.000 0.000 0.004 0.000 NA
#> GSM155478     1  0.4693      0.486 0.564 0.000 0.004 0.040 0.000 NA
#> GSM155482     1  0.5031      0.430 0.528 0.000 0.004 0.064 0.000 NA
#> GSM155486     5  0.1908      0.845 0.000 0.096 0.000 0.000 0.900 NA
#> GSM155490     2  0.4205      0.526 0.000 0.564 0.000 0.000 0.016 NA
#> GSM155494     3  0.3705      0.882 0.004 0.000 0.740 0.020 0.236 NA
#> GSM155498     3  0.3416      0.847 0.004 0.000 0.816 0.032 0.140 NA
#> GSM155502     2  0.0000      0.927 0.000 1.000 0.000 0.000 0.000 NA
#> GSM155506     2  0.0692      0.921 0.000 0.976 0.000 0.004 0.000 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

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

test_to_known_factors(res)
#>          n time(p) k
#> ATC:NMF 59   0.959 2
#> ATC:NMF 59   0.997 3
#> ATC:NMF 45   0.989 4
#> ATC:NMF 58   1.000 5
#> ATC:NMF 56   0.999 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