cola Report for GDS3459

Date: 2019-12-25 20:45:01 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 21163 rows and 56 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] 21163    56

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:NMF 3 1.000 0.969 0.986 ** 2
CV:NMF 3 1.000 0.980 0.990 ** 2
MAD:hclust 3 1.000 0.972 0.985 ** 2
MAD:kmeans 3 1.000 0.936 0.956 **
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:mclust 5 1.000 0.965 0.983 ** 2,4
ATC:NMF 3 1.000 0.965 0.986 **
MAD:NMF 3 0.975 0.927 0.974 ** 2
MAD:pam 6 0.964 0.924 0.960 ** 2,3,5
SD:hclust 4 0.952 0.924 0.961 ** 2,3
ATC:hclust 6 0.941 0.882 0.948 * 2,3
ATC:skmeans 6 0.938 0.788 0.902 * 2,3,4
MAD:mclust 6 0.935 0.858 0.928 * 2,5
CV:skmeans 5 0.928 0.871 0.930 * 2,3,4
SD:skmeans 5 0.923 0.777 0.907 * 2,3,4
ATC:pam 6 0.920 0.807 0.919 * 2,3
SD:pam 6 0.917 0.868 0.909 * 2,3,5
CV:mclust 6 0.917 0.869 0.930 * 2,5
MAD:skmeans 5 0.916 0.881 0.936 * 2,3,4
SD:mclust 5 0.912 0.865 0.936 * 2
CV:pam 6 0.904 0.869 0.889 * 2,3,5
CV:hclust 3 0.869 0.953 0.975
SD:kmeans 3 0.741 0.958 0.943
CV:kmeans 3 0.726 0.976 0.935

**: 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.998       0.999          0.432 0.569   0.569
#> CV:NMF      2 1.000           1.000       1.000          0.431 0.569   0.569
#> MAD:NMF     2 0.963           0.982       0.991          0.456 0.544   0.544
#> ATC:NMF     2 0.889           0.913       0.965          0.489 0.514   0.514
#> SD:skmeans  2 1.000           1.000       1.000          0.431 0.569   0.569
#> CV:skmeans  2 1.000           1.000       1.000          0.431 0.569   0.569
#> MAD:skmeans 2 1.000           1.000       1.000          0.431 0.569   0.569
#> ATC:skmeans 2 1.000           0.978       0.992          0.437 0.569   0.569
#> SD:mclust   2 1.000           1.000       1.000          0.431 0.569   0.569
#> CV:mclust   2 1.000           1.000       1.000          0.431 0.569   0.569
#> MAD:mclust  2 1.000           1.000       1.000          0.431 0.569   0.569
#> ATC:mclust  2 1.000           1.000       1.000          0.431 0.569   0.569
#> SD:kmeans   2 0.584           0.915       0.939          0.443 0.569   0.569
#> CV:kmeans   2 0.584           0.946       0.960          0.440 0.569   0.569
#> MAD:kmeans  2 0.616           0.936       0.949          0.439 0.569   0.569
#> ATC:kmeans  2 1.000           1.000       1.000          0.431 0.569   0.569
#> SD:pam      2 1.000           1.000       1.000          0.431 0.569   0.569
#> CV:pam      2 1.000           1.000       1.000          0.431 0.569   0.569
#> MAD:pam     2 1.000           1.000       1.000          0.431 0.569   0.569
#> ATC:pam     2 1.000           1.000       1.000          0.431 0.569   0.569
#> SD:hclust   2 1.000           0.977       0.989          0.371 0.618   0.618
#> CV:hclust   2 0.795           0.950       0.973          0.381 0.618   0.618
#> MAD:hclust  2 1.000           0.970       0.985          0.392 0.618   0.618
#> ATC:hclust  2 1.000           0.988       0.987          0.431 0.569   0.569
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 1.000           0.969       0.986          0.557 0.761   0.580
#> CV:NMF      3 1.000           0.980       0.990          0.557 0.761   0.580
#> MAD:NMF     3 0.975           0.927       0.974          0.477 0.731   0.527
#> ATC:NMF     3 1.000           0.965       0.986          0.377 0.706   0.481
#> SD:skmeans  3 1.000           0.978       0.989          0.568 0.753   0.567
#> CV:skmeans  3 1.000           0.974       0.988          0.568 0.753   0.567
#> MAD:skmeans 3 1.000           0.971       0.987          0.570 0.753   0.567
#> ATC:skmeans 3 1.000           0.947       0.978          0.547 0.755   0.569
#> SD:mclust   3 0.790           0.830       0.923          0.536 0.773   0.601
#> CV:mclust   3 0.766           0.788       0.910          0.527 0.781   0.615
#> MAD:mclust  3 0.819           0.893       0.937          0.514 0.766   0.590
#> ATC:mclust  3 0.811           0.963       0.964          0.535 0.761   0.580
#> SD:kmeans   3 0.741           0.958       0.943          0.461 0.761   0.580
#> CV:kmeans   3 0.726           0.976       0.935          0.460 0.761   0.580
#> MAD:kmeans  3 1.000           0.936       0.956          0.499 0.766   0.590
#> ATC:kmeans  3 0.733           0.986       0.942          0.485 0.761   0.580
#> SD:pam      3 1.000           0.993       0.997          0.539 0.766   0.590
#> CV:pam      3 1.000           0.985       0.994          0.537 0.766   0.590
#> MAD:pam     3 1.000           0.996       0.998          0.540 0.766   0.590
#> ATC:pam     3 1.000           1.000       1.000          0.542 0.766   0.590
#> SD:hclust   3 1.000           0.976       0.989          0.760 0.724   0.554
#> CV:hclust   3 0.869           0.953       0.975          0.719 0.724   0.554
#> MAD:hclust  3 1.000           0.972       0.985          0.686 0.724   0.554
#> ATC:hclust  3 1.000           0.985       0.989          0.552 0.761   0.580
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.755           0.681       0.829         0.1145 0.871   0.639
#> CV:NMF      4 0.777           0.730       0.838         0.1145 0.927   0.783
#> MAD:NMF     4 0.778           0.752       0.873         0.1144 0.899   0.699
#> ATC:NMF     4 0.811           0.707       0.856         0.0934 0.911   0.737
#> SD:skmeans  4 0.964           0.930       0.972         0.1077 0.899   0.700
#> CV:skmeans  4 0.937           0.897       0.961         0.1103 0.899   0.700
#> MAD:skmeans 4 0.959           0.947       0.976         0.1093 0.910   0.730
#> ATC:skmeans 4 0.965           0.967       0.980         0.1059 0.921   0.759
#> SD:mclust   4 0.890           0.899       0.943         0.1186 0.862   0.633
#> CV:mclust   4 0.891           0.918       0.959         0.1182 0.875   0.666
#> MAD:mclust  4 0.829           0.771       0.908         0.1390 0.845   0.580
#> ATC:mclust  4 0.970           0.926       0.969         0.1247 0.894   0.692
#> SD:kmeans   4 0.779           0.787       0.857         0.1245 0.917   0.753
#> CV:kmeans   4 0.765           0.702       0.846         0.1276 0.966   0.898
#> MAD:kmeans  4 0.782           0.799       0.849         0.1123 0.903   0.714
#> ATC:kmeans  4 0.773           0.663       0.783         0.1211 0.951   0.851
#> SD:pam      4 0.848           0.762       0.906         0.1300 0.860   0.611
#> CV:pam      4 0.868           0.857       0.923         0.1279 0.876   0.655
#> MAD:pam     4 0.788           0.770       0.888         0.1322 0.850   0.588
#> ATC:pam     4 0.888           0.831       0.923         0.1381 0.909   0.729
#> SD:hclust   4 0.952           0.924       0.961         0.1440 0.906   0.727
#> CV:hclust   4 0.864           0.805       0.889         0.1368 0.918   0.761
#> MAD:hclust  4 0.860           0.791       0.887         0.1246 0.906   0.727
#> ATC:hclust  4 0.870           0.896       0.868         0.0961 0.914   0.741
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.725           0.625       0.770         0.0319 0.963   0.860
#> CV:NMF      5 0.708           0.595       0.789         0.0414 0.953   0.829
#> MAD:NMF     5 0.703           0.527       0.783         0.0247 0.951   0.819
#> ATC:NMF     5 0.762           0.709       0.815         0.0547 0.906   0.664
#> SD:skmeans  5 0.923           0.777       0.907         0.0466 0.924   0.719
#> CV:skmeans  5 0.928           0.871       0.930         0.0479 0.955   0.822
#> MAD:skmeans 5 0.916           0.881       0.936         0.0478 0.952   0.812
#> ATC:skmeans 5 0.894           0.766       0.873         0.0435 0.984   0.939
#> SD:mclust   5 0.912           0.865       0.936         0.0606 0.924   0.730
#> CV:mclust   5 0.910           0.851       0.932         0.0718 0.911   0.689
#> MAD:mclust  5 0.917           0.905       0.945         0.0601 0.912   0.676
#> ATC:mclust  5 1.000           0.965       0.983         0.0674 0.892   0.618
#> SD:kmeans   5 0.713           0.585       0.788         0.0673 0.951   0.820
#> CV:kmeans   5 0.732           0.743       0.800         0.0680 0.932   0.783
#> MAD:kmeans  5 0.734           0.651       0.804         0.0679 0.949   0.801
#> ATC:kmeans  5 0.753           0.659       0.782         0.0793 0.902   0.679
#> SD:pam      5 0.925           0.891       0.953         0.0605 0.936   0.751
#> CV:pam      5 0.926           0.904       0.955         0.0651 0.916   0.692
#> MAD:pam     5 0.919           0.852       0.943         0.0627 0.942   0.770
#> ATC:pam     5 0.829           0.798       0.885         0.0467 0.946   0.788
#> SD:hclust   5 0.892           0.820       0.913         0.0464 0.975   0.898
#> CV:hclust   5 0.860           0.684       0.857         0.0513 0.957   0.841
#> MAD:hclust  5 0.834           0.884       0.912         0.0564 0.961   0.843
#> ATC:hclust  5 0.841           0.893       0.930         0.0573 0.953   0.820
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.709           0.610       0.741         0.0371 0.946   0.787
#> CV:NMF      6 0.692           0.586       0.710         0.0401 0.945   0.786
#> MAD:NMF     6 0.692           0.501       0.687         0.0407 0.869   0.565
#> ATC:NMF     6 0.750           0.707       0.822         0.0320 0.967   0.848
#> SD:skmeans  6 0.866           0.759       0.877         0.0347 0.949   0.781
#> CV:skmeans  6 0.854           0.789       0.869         0.0348 0.986   0.932
#> MAD:skmeans 6 0.834           0.626       0.821         0.0391 0.972   0.872
#> ATC:skmeans 6 0.938           0.788       0.902         0.0359 0.933   0.733
#> SD:mclust   6 0.889           0.805       0.903         0.0384 0.946   0.759
#> CV:mclust   6 0.917           0.869       0.930         0.0340 0.955   0.797
#> MAD:mclust  6 0.935           0.858       0.928         0.0403 0.944   0.744
#> ATC:mclust  6 0.888           0.939       0.947         0.0270 0.971   0.860
#> SD:kmeans   6 0.709           0.696       0.771         0.0483 0.901   0.598
#> CV:kmeans   6 0.703           0.626       0.753         0.0519 0.902   0.629
#> MAD:kmeans  6 0.730           0.713       0.775         0.0438 0.915   0.633
#> ATC:kmeans  6 0.762           0.657       0.775         0.0478 0.926   0.714
#> SD:pam      6 0.917           0.868       0.909         0.0296 0.969   0.850
#> CV:pam      6 0.904           0.869       0.889         0.0307 0.968   0.846
#> MAD:pam     6 0.964           0.924       0.960         0.0271 0.968   0.846
#> ATC:pam     6 0.920           0.807       0.919         0.0482 0.961   0.815
#> SD:hclust   6 0.854           0.790       0.868         0.0438 0.982   0.920
#> CV:hclust   6 0.848           0.847       0.894         0.0418 0.937   0.737
#> MAD:hclust  6 0.834           0.832       0.864         0.0434 0.953   0.777
#> ATC:hclust  6 0.941           0.882       0.948         0.0422 0.969   0.862

Following heatmap plots the partition for each combination of methods and the lightness correspond to the silhouette scores for samples in each method. On top the consensus subgroup is inferred from all methods by taking the mean silhouette scores as weight.

collect_stats(res_list, k = 2)

plot of chunk tab-collect-stats-from-consensus-partition-list-1

collect_stats(res_list, k = 3)

plot of chunk tab-collect-stats-from-consensus-partition-list-2

collect_stats(res_list, k = 4)

plot of chunk tab-collect-stats-from-consensus-partition-list-3

collect_stats(res_list, k = 5)

plot of chunk tab-collect-stats-from-consensus-partition-list-4

collect_stats(res_list, k = 6)

plot of chunk tab-collect-stats-from-consensus-partition-list-5

Partition from all methods

Collect partitions from all methods:

collect_classes(res_list, k = 2)

plot of chunk tab-collect-classes-from-consensus-partition-list-1

collect_classes(res_list, k = 3)

plot of chunk tab-collect-classes-from-consensus-partition-list-2

collect_classes(res_list, k = 4)

plot of chunk tab-collect-classes-from-consensus-partition-list-3

collect_classes(res_list, k = 5)

plot of chunk tab-collect-classes-from-consensus-partition-list-4

collect_classes(res_list, k = 6)

plot of chunk tab-collect-classes-from-consensus-partition-list-5

Top rows overlap

Overlap of top rows from different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-1

top_rows_overlap(res_list, top_n = 2000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-2

top_rows_overlap(res_list, top_n = 3000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-3

top_rows_overlap(res_list, top_n = 4000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-4

top_rows_overlap(res_list, top_n = 5000, method = "euler")

plot of chunk tab-top-rows-overlap-by-euler-5

Also visualize the correspondance of rankings between different top-row methods:

top_rows_overlap(res_list, top_n = 1000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-1

top_rows_overlap(res_list, top_n = 2000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-2

top_rows_overlap(res_list, top_n = 3000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-3

top_rows_overlap(res_list, top_n = 4000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-4

top_rows_overlap(res_list, top_n = 5000, method = "correspondance")

plot of chunk tab-top-rows-overlap-by-correspondance-5

Heatmaps of the top rows:

top_rows_heatmap(res_list, top_n = 1000)

plot of chunk tab-top-rows-heatmap-1

top_rows_heatmap(res_list, top_n = 2000)

plot of chunk tab-top-rows-heatmap-2

top_rows_heatmap(res_list, top_n = 3000)

plot of chunk tab-top-rows-heatmap-3

top_rows_heatmap(res_list, top_n = 4000)

plot of chunk tab-top-rows-heatmap-4

top_rows_heatmap(res_list, top_n = 5000)

plot of chunk tab-top-rows-heatmap-5

Test to known annotations

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

test_to_known_factors(res_list, k = 2)
#>              n disease.state(p) tissue(p) k
#> SD:NMF      56         5.06e-01  5.82e-11 2
#> CV:NMF      56         5.06e-01  5.82e-11 2
#> MAD:NMF     56         1.39e-01  2.28e-09 2
#> ATC:NMF     54         4.98e-02  4.31e-07 2
#> SD:skmeans  56         5.06e-01  5.82e-11 2
#> CV:skmeans  56         5.06e-01  5.82e-11 2
#> MAD:skmeans 56         5.06e-01  5.82e-11 2
#> ATC:skmeans 55         4.16e-01  9.18e-11 2
#> SD:mclust   56         5.06e-01  5.82e-11 2
#> CV:mclust   56         5.06e-01  5.82e-11 2
#> MAD:mclust  56         5.06e-01  5.82e-11 2
#> ATC:mclust  56         5.06e-01  5.82e-11 2
#> SD:kmeans   56         5.06e-01  5.82e-11 2
#> CV:kmeans   56         5.06e-01  5.82e-11 2
#> MAD:kmeans  56         5.06e-01  5.82e-11 2
#> ATC:kmeans  56         5.06e-01  5.82e-11 2
#> SD:pam      56         5.06e-01  5.82e-11 2
#> CV:pam      56         5.06e-01  5.82e-11 2
#> MAD:pam     56         5.06e-01  5.82e-11 2
#> ATC:pam     56         5.06e-01  5.82e-11 2
#> SD:hclust   55         1.64e-04  4.80e-03 2
#> CV:hclust   56         6.76e-05  2.37e-03 2
#> MAD:hclust  56         6.76e-05  2.37e-03 2
#> ATC:hclust  56         5.06e-01  5.82e-11 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) tissue(p) k
#> SD:NMF      56         0.001210  7.06e-11 3
#> CV:NMF      56         0.001210  7.06e-11 3
#> MAD:NMF     53         0.002548  2.23e-10 3
#> ATC:NMF     55         0.003610  9.94e-10 3
#> SD:skmeans  56         0.010546  4.13e-10 3
#> CV:skmeans  56         0.010546  4.13e-10 3
#> MAD:skmeans 56         0.010546  4.13e-10 3
#> ATC:skmeans 53         0.016952  1.59e-09 3
#> SD:mclust   54         0.001785  9.10e-10 3
#> CV:mclust   45         0.000879  3.07e-09 3
#> MAD:mclust  55         0.004148  8.30e-10 3
#> ATC:mclust  56         0.001443  3.53e-10 3
#> SD:kmeans   55         0.000726  1.84e-10 3
#> CV:kmeans   56         0.001210  7.06e-11 3
#> MAD:kmeans  54         0.000847  7.20e-10 3
#> ATC:kmeans  56         0.001443  3.53e-10 3
#> SD:pam      56         0.000528  2.02e-10 3
#> CV:pam      56         0.000528  2.02e-10 3
#> MAD:pam     56         0.000528  2.02e-10 3
#> ATC:pam     56         0.000515  2.02e-10 3
#> SD:hclust   55         0.000406  2.72e-10 3
#> CV:hclust   56         0.000185  1.01e-10 3
#> MAD:hclust  56         0.000185  1.01e-10 3
#> ATC:hclust  56         0.013479  9.47e-10 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) tissue(p) k
#> SD:NMF      43         2.38e-03  1.86e-08 4
#> CV:NMF      48         2.37e-04  3.83e-10 4
#> MAD:NMF     48         1.23e-03  2.40e-09 4
#> ATC:NMF     42         5.28e-01  5.06e-07 4
#> SD:skmeans  54         5.64e-04  1.63e-09 4
#> CV:skmeans  53         1.06e-04  3.97e-09 4
#> MAD:skmeans 55         3.01e-04  1.65e-09 4
#> ATC:skmeans 56         4.57e-04  1.41e-09 4
#> SD:mclust   55         7.84e-05  2.32e-11 4
#> CV:mclust   53         9.94e-05  1.11e-10 4
#> MAD:mclust  48         7.93e-04  2.70e-10 4
#> ATC:mclust  53         3.94e-03  6.91e-10 4
#> SD:kmeans   52         1.58e-04  7.49e-10 4
#> CV:kmeans   47         4.03e-03  1.20e-09 4
#> MAD:kmeans  52         1.31e-04  2.07e-09 4
#> ATC:kmeans  45         2.72e-03  1.01e-07 4
#> SD:pam      44         1.16e-03  2.46e-08 4
#> CV:pam      55         2.50e-05  6.20e-11 4
#> MAD:pam     48         2.88e-04  9.55e-09 4
#> ATC:pam     49         1.22e-03  1.01e-08 4
#> SD:hclust   55         1.69e-05  3.96e-10 4
#> CV:hclust   53         7.35e-05  3.44e-10 4
#> MAD:hclust  49         5.14e-05  4.77e-08 4
#> ATC:hclust  54         1.88e-02  9.34e-09 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) tissue(p) k
#> SD:NMF      40         2.93e-01  1.53e-07 5
#> CV:NMF      40         1.61e-02  4.65e-08 5
#> MAD:NMF     31         4.67e-01  4.77e-06 5
#> ATC:NMF     50         2.02e-02  8.77e-08 5
#> SD:skmeans  51         4.61e-04  2.90e-09 5
#> CV:skmeans  52         2.62e-04  1.42e-08 5
#> MAD:skmeans 53         1.27e-04  6.91e-09 5
#> ATC:skmeans 42         3.02e-03  2.24e-07 5
#> SD:mclust   53         1.78e-03  2.07e-10 5
#> CV:mclust   51         5.42e-04  2.99e-09 5
#> MAD:mclust  56         5.03e-05  4.55e-09 5
#> ATC:mclust  56         5.22e-06  2.70e-09 5
#> SD:kmeans   45         1.67e-04  1.34e-06 5
#> CV:kmeans   51         1.14e-04  4.53e-09 5
#> MAD:kmeans  46         9.45e-05  2.01e-07 5
#> ATC:kmeans  45         6.13e-06  6.01e-08 5
#> SD:pam      54         2.00e-03  8.34e-10 5
#> CV:pam      54         2.00e-03  8.34e-10 5
#> MAD:pam     51         8.28e-05  3.04e-09 5
#> ATC:pam     51         8.03e-03  1.46e-08 5
#> SD:hclust   50         4.03e-04  2.30e-08 5
#> CV:hclust   47         2.81e-04  6.63e-08 5
#> MAD:hclust  55         1.36e-04  1.95e-09 5
#> ATC:hclust  54         3.59e-02  7.70e-08 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) tissue(p) k
#> SD:NMF      42         3.55e-03  1.73e-07 6
#> CV:NMF      38         3.15e-01  1.34e-06 6
#> MAD:NMF     27         4.05e-01  1.55e-04 6
#> ATC:NMF     50         2.10e-02  1.72e-07 6
#> SD:skmeans  47         8.91e-04  3.29e-08 6
#> CV:skmeans  51         2.07e-03  1.77e-08 6
#> MAD:skmeans 42         3.87e-04  2.30e-07 6
#> ATC:skmeans 52         2.37e-04  1.45e-08 6
#> SD:mclust   52         1.96e-02  2.76e-09 6
#> CV:mclust   54         5.03e-05  5.16e-09 6
#> MAD:mclust  52         1.36e-02  9.86e-09 6
#> ATC:mclust  56         1.31e-04  1.27e-09 6
#> SD:kmeans   47         2.57e-04  4.79e-07 6
#> CV:kmeans   45         9.66e-05  3.82e-07 6
#> MAD:kmeans  51         6.20e-05  2.23e-07 6
#> ATC:kmeans  45         1.02e-04  7.85e-08 6
#> SD:pam      54         5.84e-03  9.31e-10 6
#> CV:pam      55         8.10e-04  6.32e-09 6
#> MAD:pam     55         8.10e-04  6.32e-09 6
#> ATC:pam     49         4.98e-04  2.14e-07 6
#> SD:hclust   54         1.33e-04  5.28e-09 6
#> CV:hclust   54         9.44e-04  3.56e-09 6
#> MAD:hclust  54         2.83e-05  3.10e-08 6
#> ATC:hclust  53         4.66e-03  7.90e-08 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 21163 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.977       0.989         0.3710 0.618   0.618
#> 3 3 1.000           0.976       0.989         0.7604 0.724   0.554
#> 4 4 0.952           0.924       0.961         0.1440 0.906   0.727
#> 5 5 0.892           0.820       0.913         0.0464 0.975   0.898
#> 6 6 0.854           0.790       0.868         0.0438 0.982   0.920

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
#> GSM329660     1  0.0000      1.000 1.000 0.000
#> GSM329663     1  0.0000      1.000 1.000 0.000
#> GSM329664     1  0.0000      1.000 1.000 0.000
#> GSM329666     1  0.0000      1.000 1.000 0.000
#> GSM329667     1  0.0000      1.000 1.000 0.000
#> GSM329670     1  0.0000      1.000 1.000 0.000
#> GSM329672     1  0.0000      1.000 1.000 0.000
#> GSM329674     1  0.0000      1.000 1.000 0.000
#> GSM329661     2  0.0000      0.955 0.000 1.000
#> GSM329669     1  0.0000      1.000 1.000 0.000
#> GSM329662     1  0.0000      1.000 1.000 0.000
#> GSM329665     1  0.0000      1.000 1.000 0.000
#> GSM329668     1  0.0000      1.000 1.000 0.000
#> GSM329671     1  0.0000      1.000 1.000 0.000
#> GSM329673     1  0.0000      1.000 1.000 0.000
#> GSM329675     1  0.0000      1.000 1.000 0.000
#> GSM329676     1  0.0000      1.000 1.000 0.000
#> GSM329677     2  0.3274      0.922 0.060 0.940
#> GSM329679     1  0.0000      1.000 1.000 0.000
#> GSM329681     2  0.0000      0.955 0.000 1.000
#> GSM329683     2  0.0000      0.955 0.000 1.000
#> GSM329686     2  0.0000      0.955 0.000 1.000
#> GSM329689     2  0.0000      0.955 0.000 1.000
#> GSM329678     2  0.9358      0.492 0.352 0.648
#> GSM329680     2  0.0000      0.955 0.000 1.000
#> GSM329685     2  0.0000      0.955 0.000 1.000
#> GSM329688     2  0.0000      0.955 0.000 1.000
#> GSM329691     2  0.0000      0.955 0.000 1.000
#> GSM329682     1  0.0000      1.000 1.000 0.000
#> GSM329684     1  0.0000      1.000 1.000 0.000
#> GSM329687     1  0.0000      1.000 1.000 0.000
#> GSM329690     1  0.0000      1.000 1.000 0.000
#> GSM329692     1  0.0000      1.000 1.000 0.000
#> GSM329694     1  0.0376      0.996 0.996 0.004
#> GSM329697     1  0.0000      1.000 1.000 0.000
#> GSM329700     1  0.0000      1.000 1.000 0.000
#> GSM329703     1  0.0000      1.000 1.000 0.000
#> GSM329704     1  0.0376      0.996 0.996 0.004
#> GSM329707     2  0.3274      0.922 0.060 0.940
#> GSM329709     1  0.0000      1.000 1.000 0.000
#> GSM329711     1  0.0000      1.000 1.000 0.000
#> GSM329714     1  0.0000      1.000 1.000 0.000
#> GSM329693     1  0.0000      1.000 1.000 0.000
#> GSM329696     1  0.0000      1.000 1.000 0.000
#> GSM329699     1  0.0000      1.000 1.000 0.000
#> GSM329702     1  0.0000      1.000 1.000 0.000
#> GSM329706     2  0.5178      0.870 0.116 0.884
#> GSM329708     2  0.0000      0.955 0.000 1.000
#> GSM329710     1  0.0000      1.000 1.000 0.000
#> GSM329713     1  0.0000      1.000 1.000 0.000
#> GSM329695     1  0.0000      1.000 1.000 0.000
#> GSM329698     1  0.0000      1.000 1.000 0.000
#> GSM329701     1  0.0000      1.000 1.000 0.000
#> GSM329705     1  0.0000      1.000 1.000 0.000
#> GSM329712     1  0.0000      1.000 1.000 0.000
#> GSM329715     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM329660     2  0.0000      1.000  0 1.000 0.000
#> GSM329663     2  0.0000      1.000  0 1.000 0.000
#> GSM329664     2  0.0000      1.000  0 1.000 0.000
#> GSM329666     2  0.0000      1.000  0 1.000 0.000
#> GSM329667     2  0.0000      1.000  0 1.000 0.000
#> GSM329670     2  0.0000      1.000  0 1.000 0.000
#> GSM329672     2  0.0000      1.000  0 1.000 0.000
#> GSM329674     2  0.0000      1.000  0 1.000 0.000
#> GSM329661     3  0.0000      0.949  0 0.000 1.000
#> GSM329669     2  0.0000      1.000  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.2066      0.916  0 0.060 0.940
#> GSM329679     2  0.0000      1.000  0 1.000 0.000
#> GSM329681     3  0.0000      0.949  0 0.000 1.000
#> GSM329683     3  0.0000      0.949  0 0.000 1.000
#> GSM329686     3  0.0000      0.949  0 0.000 1.000
#> GSM329689     3  0.0000      0.949  0 0.000 1.000
#> GSM329678     3  0.5905      0.496  0 0.352 0.648
#> GSM329680     3  0.0000      0.949  0 0.000 1.000
#> GSM329685     3  0.0000      0.949  0 0.000 1.000
#> GSM329688     3  0.0000      0.949  0 0.000 1.000
#> GSM329691     3  0.0000      0.949  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     2  0.0000      1.000  0 1.000 0.000
#> GSM329694     2  0.0237      0.996  0 0.996 0.004
#> GSM329697     2  0.0000      1.000  0 1.000 0.000
#> GSM329700     2  0.0000      1.000  0 1.000 0.000
#> GSM329703     2  0.0000      1.000  0 1.000 0.000
#> GSM329704     2  0.0237      0.996  0 0.996 0.004
#> GSM329707     3  0.2066      0.916  0 0.060 0.940
#> GSM329709     2  0.0000      1.000  0 1.000 0.000
#> GSM329711     2  0.0000      1.000  0 1.000 0.000
#> GSM329714     2  0.0000      1.000  0 1.000 0.000
#> GSM329693     2  0.0000      1.000  0 1.000 0.000
#> GSM329696     2  0.0000      1.000  0 1.000 0.000
#> GSM329699     2  0.0000      1.000  0 1.000 0.000
#> GSM329702     2  0.0000      1.000  0 1.000 0.000
#> GSM329706     3  0.3267      0.867  0 0.116 0.884
#> GSM329708     3  0.0000      0.949  0 0.000 1.000
#> GSM329710     2  0.0000      1.000  0 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      1.000  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0817      0.975  0 0.976 0.000 0.024
#> GSM329663     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329664     2  0.0817      0.958  0 0.976 0.000 0.024
#> GSM329666     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329667     2  0.0707      0.960  0 0.980 0.000 0.020
#> GSM329670     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329672     2  0.0817      0.960  0 0.976 0.000 0.024
#> GSM329674     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329661     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329669     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.1716      0.919  0 0.000 0.936 0.064
#> GSM329679     2  0.0817      0.960  0 0.976 0.000 0.024
#> GSM329681     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329678     3  0.4697      0.513  0 0.000 0.644 0.356
#> GSM329680     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0336      0.850  0 0.008 0.000 0.992
#> GSM329694     4  0.4898      0.331  0 0.416 0.000 0.584
#> GSM329697     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329700     4  0.4605      0.568  0 0.336 0.000 0.664
#> GSM329703     4  0.0336      0.850  0 0.008 0.000 0.992
#> GSM329704     2  0.2216      0.887  0 0.908 0.000 0.092
#> GSM329707     3  0.1716      0.919  0 0.000 0.936 0.064
#> GSM329709     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329711     2  0.1211      0.966  0 0.960 0.000 0.040
#> GSM329714     4  0.4605      0.568  0 0.336 0.000 0.664
#> GSM329693     4  0.0336      0.850  0 0.008 0.000 0.992
#> GSM329696     4  0.0336      0.850  0 0.008 0.000 0.992
#> GSM329699     4  0.0336      0.850  0 0.008 0.000 0.992
#> GSM329702     2  0.0707      0.977  0 0.980 0.000 0.020
#> GSM329706     3  0.2647      0.869  0 0.000 0.880 0.120
#> GSM329708     3  0.0000      0.954  0 0.000 1.000 0.000
#> GSM329710     4  0.0336      0.850  0 0.008 0.000 0.992
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.1211      0.966  0 0.960 0.000 0.040
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     2  0.0451      0.862  0 0.988 0.000 0.004 0.008
#> GSM329663     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329664     5  0.3752      0.948  0 0.292 0.000 0.000 0.708
#> GSM329666     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329667     5  0.3774      0.946  0 0.296 0.000 0.000 0.704
#> GSM329670     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.4552     -0.463  0 0.524 0.000 0.008 0.468
#> GSM329674     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329661     3  0.2732      0.846  0 0.000 0.840 0.000 0.160
#> GSM329669     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     3  0.2516      0.839  0 0.000 0.860 0.000 0.140
#> GSM329679     2  0.4552     -0.463  0 0.524 0.000 0.008 0.468
#> GSM329681     3  0.3074      0.850  0 0.000 0.804 0.000 0.196
#> GSM329683     3  0.3074      0.850  0 0.000 0.804 0.000 0.196
#> GSM329686     3  0.0000      0.879  0 0.000 1.000 0.000 0.000
#> GSM329689     3  0.3074      0.850  0 0.000 0.804 0.000 0.196
#> GSM329678     3  0.5990      0.455  0 0.000 0.568 0.280 0.152
#> GSM329680     3  0.0000      0.879  0 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.879  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.879  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.879  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.0510      0.814  0 0.000 0.000 0.984 0.016
#> GSM329694     4  0.4268      0.195  0 0.000 0.000 0.556 0.444
#> GSM329697     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329700     4  0.3966      0.435  0 0.336 0.000 0.664 0.000
#> GSM329703     4  0.0000      0.818  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.4552      0.905  0 0.264 0.000 0.040 0.696
#> GSM329707     3  0.2516      0.839  0 0.000 0.860 0.000 0.140
#> GSM329709     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329711     2  0.0794      0.845  0 0.972 0.000 0.028 0.000
#> GSM329714     4  0.3966      0.435  0 0.336 0.000 0.664 0.000
#> GSM329693     4  0.0000      0.818  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.818  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.818  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0000      0.871  0 1.000 0.000 0.000 0.000
#> GSM329706     3  0.3723      0.801  0 0.000 0.804 0.044 0.152
#> GSM329708     3  0.2732      0.846  0 0.000 0.840 0.000 0.160
#> GSM329710     4  0.0510      0.814  0 0.000 0.000 0.984 0.016
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     2  0.0794      0.845  0 0.972 0.000 0.028 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     2  0.0935      0.955 0.000 0.964 0.000 0.004 0.032 NA
#> GSM329663     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329664     5  0.0146      0.756 0.000 0.000 0.000 0.000 0.996 NA
#> GSM329666     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329667     5  0.0000      0.757 0.000 0.000 0.000 0.000 1.000 NA
#> GSM329670     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329672     5  0.3833      0.611 0.000 0.344 0.000 0.008 0.648 NA
#> GSM329674     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329661     3  0.3634      0.693 0.000 0.000 0.644 0.000 0.000 NA
#> GSM329669     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329662     1  0.0146      0.856 0.996 0.000 0.000 0.000 0.000 NA
#> GSM329665     1  0.0000      0.857 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329668     1  0.0000      0.857 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329671     1  0.3823      0.679 0.564 0.000 0.000 0.000 0.000 NA
#> GSM329673     1  0.0146      0.856 0.996 0.000 0.000 0.000 0.000 NA
#> GSM329675     1  0.0547      0.849 0.980 0.000 0.000 0.000 0.000 NA
#> GSM329676     1  0.0000      0.857 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329677     3  0.2562      0.755 0.000 0.000 0.828 0.000 0.000 NA
#> GSM329679     5  0.3833      0.611 0.000 0.344 0.000 0.008 0.648 NA
#> GSM329681     3  0.3756      0.705 0.000 0.000 0.600 0.000 0.000 NA
#> GSM329683     3  0.3756      0.705 0.000 0.000 0.600 0.000 0.000 NA
#> GSM329686     3  0.0000      0.796 0.000 0.000 1.000 0.000 0.000 NA
#> GSM329689     3  0.3756      0.705 0.000 0.000 0.600 0.000 0.000 NA
#> GSM329678     3  0.5381      0.432 0.000 0.000 0.568 0.280 0.000 NA
#> GSM329680     3  0.0000      0.796 0.000 0.000 1.000 0.000 0.000 NA
#> GSM329685     3  0.0000      0.796 0.000 0.000 1.000 0.000 0.000 NA
#> GSM329688     3  0.0000      0.796 0.000 0.000 1.000 0.000 0.000 NA
#> GSM329691     3  0.0000      0.796 0.000 0.000 1.000 0.000 0.000 NA
#> GSM329682     1  0.0000      0.857 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329684     1  0.0547      0.849 0.980 0.000 0.000 0.000 0.000 NA
#> GSM329687     1  0.0547      0.857 0.980 0.000 0.000 0.000 0.000 NA
#> GSM329690     1  0.3823      0.679 0.564 0.000 0.000 0.000 0.000 NA
#> GSM329692     4  0.0458      0.816 0.000 0.000 0.000 0.984 0.000 NA
#> GSM329694     4  0.4475      0.132 0.000 0.000 0.000 0.556 0.412 NA
#> GSM329697     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329700     4  0.3684      0.530 0.000 0.332 0.000 0.664 0.004 NA
#> GSM329703     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000 NA
#> GSM329704     5  0.1720      0.732 0.000 0.000 0.000 0.040 0.928 NA
#> GSM329707     3  0.2562      0.755 0.000 0.000 0.828 0.000 0.000 NA
#> GSM329709     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329711     2  0.0713      0.966 0.000 0.972 0.000 0.028 0.000 NA
#> GSM329714     4  0.3684      0.530 0.000 0.332 0.000 0.664 0.004 NA
#> GSM329693     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000 NA
#> GSM329696     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000 NA
#> GSM329699     4  0.0000      0.821 0.000 0.000 0.000 1.000 0.000 NA
#> GSM329702     2  0.0000      0.989 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329706     3  0.3344      0.731 0.000 0.000 0.804 0.044 0.000 NA
#> GSM329708     3  0.3634      0.693 0.000 0.000 0.644 0.000 0.000 NA
#> GSM329710     4  0.0458      0.816 0.000 0.000 0.000 0.984 0.000 NA
#> GSM329713     1  0.3823      0.679 0.564 0.000 0.000 0.000 0.000 NA
#> GSM329695     1  0.3823      0.679 0.564 0.000 0.000 0.000 0.000 NA
#> GSM329698     1  0.2941      0.805 0.780 0.000 0.000 0.000 0.000 NA
#> GSM329701     1  0.2941      0.805 0.780 0.000 0.000 0.000 0.000 NA
#> GSM329705     1  0.0547      0.857 0.980 0.000 0.000 0.000 0.000 NA
#> GSM329712     2  0.0713      0.966 0.000 0.972 0.000 0.028 0.000 NA
#> GSM329715     1  0.2941      0.805 0.780 0.000 0.000 0.000 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-SD-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) tissue(p) k
#> SD:hclust 55         1.64e-04  4.80e-03 2
#> SD:hclust 55         4.06e-04  2.72e-10 3
#> SD:hclust 55         1.69e-05  3.96e-10 4
#> SD:hclust 50         4.03e-04  2.30e-08 5
#> SD:hclust 54         1.33e-04  5.28e-09 6

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


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

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.584           0.915       0.939         0.4431 0.569   0.569
#> 3 3 0.741           0.958       0.943         0.4607 0.761   0.580
#> 4 4 0.779           0.787       0.857         0.1245 0.917   0.753
#> 5 5 0.713           0.585       0.788         0.0673 0.951   0.820
#> 6 6 0.709           0.696       0.771         0.0483 0.901   0.598

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM329660     2   0.738      0.847 0.208 0.792
#> GSM329663     2   0.738      0.847 0.208 0.792
#> GSM329664     2   0.000      0.901 0.000 1.000
#> GSM329666     2   0.738      0.847 0.208 0.792
#> GSM329667     2   0.730      0.848 0.204 0.796
#> GSM329670     2   0.738      0.847 0.208 0.792
#> GSM329672     2   0.738      0.847 0.208 0.792
#> GSM329674     2   0.738      0.847 0.208 0.792
#> GSM329661     2   0.000      0.901 0.000 1.000
#> GSM329669     2   0.738      0.847 0.208 0.792
#> GSM329662     1   0.000      1.000 1.000 0.000
#> GSM329665     1   0.000      1.000 1.000 0.000
#> GSM329668     1   0.000      1.000 1.000 0.000
#> GSM329671     1   0.000      1.000 1.000 0.000
#> GSM329673     1   0.000      1.000 1.000 0.000
#> GSM329675     1   0.000      1.000 1.000 0.000
#> GSM329676     1   0.000      1.000 1.000 0.000
#> GSM329677     2   0.000      0.901 0.000 1.000
#> GSM329679     2   0.738      0.847 0.208 0.792
#> GSM329681     2   0.000      0.901 0.000 1.000
#> GSM329683     2   0.000      0.901 0.000 1.000
#> GSM329686     2   0.000      0.901 0.000 1.000
#> GSM329689     2   0.000      0.901 0.000 1.000
#> GSM329678     2   0.000      0.901 0.000 1.000
#> GSM329680     2   0.000      0.901 0.000 1.000
#> GSM329685     2   0.000      0.901 0.000 1.000
#> GSM329688     2   0.000      0.901 0.000 1.000
#> GSM329691     2   0.000      0.901 0.000 1.000
#> GSM329682     1   0.000      1.000 1.000 0.000
#> GSM329684     1   0.000      1.000 1.000 0.000
#> GSM329687     1   0.000      1.000 1.000 0.000
#> GSM329690     1   0.000      1.000 1.000 0.000
#> GSM329692     2   0.000      0.901 0.000 1.000
#> GSM329694     2   0.000      0.901 0.000 1.000
#> GSM329697     2   0.738      0.847 0.208 0.792
#> GSM329700     2   0.738      0.847 0.208 0.792
#> GSM329703     2   0.224      0.896 0.036 0.964
#> GSM329704     2   0.000      0.901 0.000 1.000
#> GSM329707     2   0.000      0.901 0.000 1.000
#> GSM329709     2   0.738      0.847 0.208 0.792
#> GSM329711     2   0.738      0.847 0.208 0.792
#> GSM329714     2   0.738      0.847 0.208 0.792
#> GSM329693     2   0.224      0.896 0.036 0.964
#> GSM329696     2   0.224      0.896 0.036 0.964
#> GSM329699     2   0.000      0.901 0.000 1.000
#> GSM329702     2   0.738      0.847 0.208 0.792
#> GSM329706     2   0.000      0.901 0.000 1.000
#> GSM329708     2   0.000      0.901 0.000 1.000
#> GSM329710     2   0.000      0.901 0.000 1.000
#> GSM329713     1   0.000      1.000 1.000 0.000
#> GSM329695     1   0.000      1.000 1.000 0.000
#> GSM329698     1   0.000      1.000 1.000 0.000
#> GSM329701     1   0.000      1.000 1.000 0.000
#> GSM329705     1   0.000      1.000 1.000 0.000
#> GSM329712     2   0.738      0.847 0.208 0.792
#> GSM329715     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
#> GSM329660     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329663     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329664     2  0.3192      0.857 0.000 0.888 0.112
#> GSM329666     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329667     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329670     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329672     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329674     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329661     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329669     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329662     1  0.2878      0.956 0.904 0.000 0.096
#> GSM329665     1  0.1163      0.965 0.972 0.000 0.028
#> GSM329668     1  0.0892      0.966 0.980 0.000 0.020
#> GSM329671     1  0.0747      0.964 0.984 0.000 0.016
#> GSM329673     1  0.2878      0.956 0.904 0.000 0.096
#> GSM329675     1  0.2878      0.956 0.904 0.000 0.096
#> GSM329676     1  0.2878      0.956 0.904 0.000 0.096
#> GSM329677     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329679     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329681     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329683     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329686     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329689     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329678     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329680     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329685     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329688     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329691     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329682     1  0.2261      0.960 0.932 0.000 0.068
#> GSM329684     1  0.2878      0.956 0.904 0.000 0.096
#> GSM329687     1  0.2878      0.956 0.904 0.000 0.096
#> GSM329690     1  0.0747      0.964 0.984 0.000 0.016
#> GSM329692     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329694     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329697     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329700     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329703     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329704     2  0.3192      0.857 0.000 0.888 0.112
#> GSM329707     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329709     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329711     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329714     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329693     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329696     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329699     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329702     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329706     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329708     3  0.3192      0.971 0.000 0.112 0.888
#> GSM329710     3  0.6308      0.257 0.000 0.492 0.508
#> GSM329713     1  0.0592      0.965 0.988 0.000 0.012
#> GSM329695     1  0.0592      0.965 0.988 0.000 0.012
#> GSM329698     1  0.0592      0.965 0.988 0.000 0.012
#> GSM329701     1  0.0592      0.965 0.988 0.000 0.012
#> GSM329705     1  0.0000      0.966 1.000 0.000 0.000
#> GSM329712     2  0.0000      0.988 0.000 1.000 0.000
#> GSM329715     1  0.0592      0.965 0.988 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM329660     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329663     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329664     2  0.4030     0.6708 0.000 0.836 0.092 0.072
#> GSM329666     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329667     2  0.1792     0.8150 0.000 0.932 0.000 0.068
#> GSM329670     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329672     2  0.0188     0.8810 0.000 0.996 0.000 0.004
#> GSM329674     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329661     3  0.3367     0.8608 0.000 0.028 0.864 0.108
#> GSM329669     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329662     1  0.3726     0.8707 0.788 0.000 0.000 0.212
#> GSM329665     1  0.1211     0.8968 0.960 0.000 0.000 0.040
#> GSM329668     1  0.1389     0.8972 0.952 0.000 0.000 0.048
#> GSM329671     1  0.2149     0.8869 0.912 0.000 0.000 0.088
#> GSM329673     1  0.3649     0.8714 0.796 0.000 0.000 0.204
#> GSM329675     1  0.3726     0.8700 0.788 0.000 0.000 0.212
#> GSM329676     1  0.3649     0.8723 0.796 0.000 0.000 0.204
#> GSM329677     3  0.2546     0.8793 0.000 0.028 0.912 0.060
#> GSM329679     2  0.0188     0.8810 0.000 0.996 0.000 0.004
#> GSM329681     3  0.2032     0.8998 0.000 0.028 0.936 0.036
#> GSM329683     3  0.1388     0.9062 0.000 0.028 0.960 0.012
#> GSM329686     3  0.0921     0.9070 0.000 0.028 0.972 0.000
#> GSM329689     3  0.1388     0.9062 0.000 0.028 0.960 0.012
#> GSM329678     3  0.5764     0.1957 0.000 0.028 0.520 0.452
#> GSM329680     3  0.1109     0.9069 0.000 0.028 0.968 0.004
#> GSM329685     3  0.0921     0.9070 0.000 0.028 0.972 0.000
#> GSM329688     3  0.0921     0.9070 0.000 0.028 0.972 0.000
#> GSM329691     3  0.0921     0.9070 0.000 0.028 0.972 0.000
#> GSM329682     1  0.3123     0.8812 0.844 0.000 0.000 0.156
#> GSM329684     1  0.3726     0.8700 0.788 0.000 0.000 0.212
#> GSM329687     1  0.3486     0.8747 0.812 0.000 0.000 0.188
#> GSM329690     1  0.2843     0.8839 0.892 0.000 0.020 0.088
#> GSM329692     4  0.5460     0.0432 0.000 0.028 0.340 0.632
#> GSM329694     4  0.4955     0.6763 0.000 0.444 0.000 0.556
#> GSM329697     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329700     2  0.2345     0.7744 0.000 0.900 0.000 0.100
#> GSM329703     4  0.4992     0.6861 0.000 0.476 0.000 0.524
#> GSM329704     2  0.5842     0.3723 0.000 0.688 0.092 0.220
#> GSM329707     3  0.2915     0.8790 0.000 0.028 0.892 0.080
#> GSM329709     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329711     2  0.2081     0.7987 0.000 0.916 0.000 0.084
#> GSM329714     2  0.4855    -0.3490 0.000 0.600 0.000 0.400
#> GSM329693     4  0.4992     0.6861 0.000 0.476 0.000 0.524
#> GSM329696     4  0.4992     0.6861 0.000 0.476 0.000 0.524
#> GSM329699     4  0.4989     0.6876 0.000 0.472 0.000 0.528
#> GSM329702     2  0.0000     0.8832 0.000 1.000 0.000 0.000
#> GSM329706     3  0.5300     0.6010 0.000 0.028 0.664 0.308
#> GSM329708     3  0.3367     0.8608 0.000 0.028 0.864 0.108
#> GSM329710     4  0.6586     0.5077 0.000 0.184 0.184 0.632
#> GSM329713     1  0.2773     0.8857 0.900 0.000 0.028 0.072
#> GSM329695     1  0.2773     0.8857 0.900 0.000 0.028 0.072
#> GSM329698     1  0.2773     0.8857 0.900 0.000 0.028 0.072
#> GSM329701     1  0.1940     0.8887 0.924 0.000 0.000 0.076
#> GSM329705     1  0.0000     0.8967 1.000 0.000 0.000 0.000
#> GSM329712     2  0.2081     0.7987 0.000 0.916 0.000 0.084
#> GSM329715     1  0.1940     0.8887 0.924 0.000 0.000 0.076

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.2011      0.838 0.000 0.908 0.000 0.004 0.088
#> GSM329663     2  0.1357      0.847 0.000 0.948 0.000 0.004 0.048
#> GSM329664     2  0.5733      0.528 0.000 0.552 0.044 0.024 0.380
#> GSM329666     2  0.1121      0.856 0.000 0.956 0.000 0.000 0.044
#> GSM329667     2  0.4339      0.692 0.000 0.684 0.000 0.020 0.296
#> GSM329670     2  0.0566      0.847 0.000 0.984 0.000 0.004 0.012
#> GSM329672     2  0.2471      0.834 0.000 0.864 0.000 0.000 0.136
#> GSM329674     2  0.1121      0.856 0.000 0.956 0.000 0.000 0.044
#> GSM329661     3  0.4129      0.836 0.000 0.016 0.808 0.076 0.100
#> GSM329669     2  0.0162      0.847 0.000 0.996 0.000 0.004 0.000
#> GSM329662     1  0.4307     -0.929 0.504 0.000 0.000 0.000 0.496
#> GSM329665     1  0.3612      0.322 0.800 0.000 0.000 0.028 0.172
#> GSM329668     1  0.4210      0.223 0.756 0.000 0.004 0.036 0.204
#> GSM329671     1  0.1492      0.516 0.948 0.000 0.008 0.040 0.004
#> GSM329673     1  0.4451     -0.938 0.504 0.000 0.000 0.004 0.492
#> GSM329675     5  0.4706      1.000 0.488 0.000 0.008 0.004 0.500
#> GSM329676     1  0.4287     -0.830 0.540 0.000 0.000 0.000 0.460
#> GSM329677     3  0.4391      0.749 0.000 0.016 0.744 0.024 0.216
#> GSM329679     2  0.2471      0.834 0.000 0.864 0.000 0.000 0.136
#> GSM329681     3  0.2937      0.869 0.000 0.016 0.884 0.060 0.040
#> GSM329683     3  0.1974      0.880 0.000 0.016 0.932 0.016 0.036
#> GSM329686     3  0.0510      0.884 0.000 0.016 0.984 0.000 0.000
#> GSM329689     3  0.1891      0.881 0.000 0.016 0.936 0.016 0.032
#> GSM329678     4  0.4169      0.574 0.000 0.016 0.256 0.724 0.004
#> GSM329680     3  0.1018      0.883 0.000 0.016 0.968 0.016 0.000
#> GSM329685     3  0.0510      0.884 0.000 0.016 0.984 0.000 0.000
#> GSM329688     3  0.0510      0.884 0.000 0.016 0.984 0.000 0.000
#> GSM329691     3  0.0510      0.884 0.000 0.016 0.984 0.000 0.000
#> GSM329682     1  0.4171     -0.653 0.604 0.000 0.000 0.000 0.396
#> GSM329684     5  0.4706      1.000 0.488 0.000 0.008 0.004 0.500
#> GSM329687     1  0.4256     -0.774 0.564 0.000 0.000 0.000 0.436
#> GSM329690     1  0.2517      0.509 0.884 0.000 0.008 0.104 0.004
#> GSM329692     4  0.3463      0.680 0.000 0.016 0.128 0.836 0.020
#> GSM329694     4  0.4627      0.787 0.000 0.188 0.000 0.732 0.080
#> GSM329697     2  0.1121      0.856 0.000 0.956 0.000 0.000 0.044
#> GSM329700     2  0.3389      0.758 0.000 0.836 0.000 0.116 0.048
#> GSM329703     4  0.3305      0.817 0.000 0.224 0.000 0.776 0.000
#> GSM329704     2  0.7227      0.242 0.000 0.416 0.044 0.160 0.380
#> GSM329707     3  0.5048      0.737 0.000 0.016 0.676 0.040 0.268
#> GSM329709     2  0.1121      0.856 0.000 0.956 0.000 0.000 0.044
#> GSM329711     2  0.1965      0.791 0.000 0.904 0.000 0.096 0.000
#> GSM329714     4  0.5440      0.472 0.000 0.396 0.000 0.540 0.064
#> GSM329693     4  0.3305      0.817 0.000 0.224 0.000 0.776 0.000
#> GSM329696     4  0.3305      0.817 0.000 0.224 0.000 0.776 0.000
#> GSM329699     4  0.3398      0.818 0.000 0.216 0.000 0.780 0.004
#> GSM329702     2  0.1121      0.856 0.000 0.956 0.000 0.000 0.044
#> GSM329706     3  0.6794      0.412 0.000 0.016 0.508 0.240 0.236
#> GSM329708     3  0.4129      0.836 0.000 0.016 0.808 0.076 0.100
#> GSM329710     4  0.3568      0.748 0.000 0.064 0.080 0.844 0.012
#> GSM329713     1  0.1732      0.519 0.920 0.000 0.000 0.080 0.000
#> GSM329695     1  0.1732      0.519 0.920 0.000 0.000 0.080 0.000
#> GSM329698     1  0.1732      0.519 0.920 0.000 0.000 0.080 0.000
#> GSM329701     1  0.0324      0.527 0.992 0.000 0.004 0.004 0.000
#> GSM329705     1  0.2377      0.404 0.872 0.000 0.000 0.000 0.128
#> GSM329712     2  0.1965      0.791 0.000 0.904 0.000 0.096 0.000
#> GSM329715     1  0.0162      0.526 0.996 0.000 0.004 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM329660     2  0.4426     0.7783 0.000 0.748 0.000 0.020 0.100 0.132
#> GSM329663     2  0.3893     0.7760 0.000 0.764 0.000 0.000 0.080 0.156
#> GSM329664     5  0.4045     0.4667 0.000 0.268 0.036 0.000 0.696 0.000
#> GSM329666     2  0.0713     0.8370 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM329667     5  0.4933    -0.0689 0.000 0.432 0.000 0.000 0.504 0.064
#> GSM329670     2  0.3027     0.7984 0.000 0.824 0.000 0.000 0.028 0.148
#> GSM329672     2  0.2431     0.8002 0.000 0.860 0.000 0.000 0.132 0.008
#> GSM329674     2  0.0713     0.8370 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM329661     3  0.4471     0.8017 0.000 0.000 0.756 0.040 0.080 0.124
#> GSM329669     2  0.1556     0.8271 0.000 0.920 0.000 0.000 0.000 0.080
#> GSM329662     1  0.1049     0.7261 0.960 0.000 0.000 0.000 0.032 0.008
#> GSM329665     1  0.3984    -0.0929 0.648 0.000 0.000 0.000 0.016 0.336
#> GSM329668     1  0.4546     0.1083 0.660 0.000 0.000 0.012 0.040 0.288
#> GSM329671     6  0.5144     0.7900 0.404 0.000 0.000 0.028 0.036 0.532
#> GSM329673     1  0.1007     0.7250 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM329675     1  0.1765     0.7018 0.904 0.000 0.000 0.000 0.096 0.000
#> GSM329676     1  0.0508     0.7247 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM329677     5  0.4439     0.2891 0.000 0.000 0.432 0.000 0.540 0.028
#> GSM329679     2  0.2431     0.8002 0.000 0.860 0.000 0.000 0.132 0.008
#> GSM329681     3  0.3256     0.8656 0.000 0.000 0.840 0.016 0.048 0.096
#> GSM329683     3  0.2750     0.8763 0.000 0.000 0.868 0.004 0.048 0.080
#> GSM329686     3  0.0146     0.8937 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM329689     3  0.2789     0.8739 0.000 0.000 0.864 0.004 0.044 0.088
#> GSM329678     4  0.3820     0.6327 0.000 0.000 0.204 0.756 0.008 0.032
#> GSM329680     3  0.0748     0.8852 0.000 0.000 0.976 0.004 0.004 0.016
#> GSM329685     3  0.0146     0.8937 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM329688     3  0.0146     0.8937 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM329691     3  0.0146     0.8937 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM329682     1  0.1672     0.6999 0.932 0.000 0.000 0.004 0.016 0.048
#> GSM329684     1  0.1765     0.7018 0.904 0.000 0.000 0.000 0.096 0.000
#> GSM329687     1  0.0993     0.7192 0.964 0.000 0.000 0.000 0.012 0.024
#> GSM329690     6  0.5785     0.8238 0.364 0.000 0.000 0.048 0.068 0.520
#> GSM329692     4  0.2696     0.7474 0.000 0.000 0.076 0.872 0.004 0.048
#> GSM329694     4  0.4126     0.7875 0.000 0.084 0.000 0.784 0.100 0.032
#> GSM329697     2  0.0713     0.8370 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM329700     2  0.6024     0.6355 0.000 0.604 0.000 0.152 0.068 0.176
#> GSM329703     4  0.2146     0.8379 0.000 0.116 0.000 0.880 0.000 0.004
#> GSM329704     5  0.4867     0.5237 0.000 0.204 0.036 0.064 0.696 0.000
#> GSM329707     5  0.4763     0.3097 0.000 0.000 0.372 0.004 0.576 0.048
#> GSM329709     2  0.0713     0.8370 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM329711     2  0.3955     0.7561 0.000 0.772 0.000 0.132 0.004 0.092
#> GSM329714     4  0.6752     0.3434 0.000 0.252 0.000 0.492 0.088 0.168
#> GSM329693     4  0.2146     0.8379 0.000 0.116 0.000 0.880 0.000 0.004
#> GSM329696     4  0.2003     0.8380 0.000 0.116 0.000 0.884 0.000 0.000
#> GSM329699     4  0.2243     0.8377 0.000 0.112 0.000 0.880 0.004 0.004
#> GSM329702     2  0.0713     0.8370 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM329706     5  0.6105     0.4370 0.000 0.000 0.268 0.164 0.536 0.032
#> GSM329708     3  0.4471     0.8017 0.000 0.000 0.756 0.040 0.080 0.124
#> GSM329710     4  0.2851     0.7959 0.000 0.044 0.032 0.880 0.004 0.040
#> GSM329713     6  0.5507     0.8477 0.376 0.000 0.000 0.048 0.044 0.532
#> GSM329695     6  0.5507     0.8477 0.376 0.000 0.000 0.048 0.044 0.532
#> GSM329698     6  0.5329     0.8479 0.376 0.000 0.000 0.032 0.048 0.544
#> GSM329701     6  0.3817     0.8072 0.432 0.000 0.000 0.000 0.000 0.568
#> GSM329705     1  0.3911    -0.2240 0.624 0.000 0.000 0.000 0.008 0.368
#> GSM329712     2  0.3955     0.7561 0.000 0.772 0.000 0.132 0.004 0.092
#> GSM329715     6  0.3961     0.7936 0.440 0.000 0.000 0.000 0.004 0.556

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) tissue(p) k
#> SD:kmeans 56         0.505684  5.82e-11 2
#> SD:kmeans 55         0.000726  1.84e-10 3
#> SD:kmeans 52         0.000158  7.49e-10 4
#> SD:kmeans 45         0.000167  1.34e-06 5
#> SD:kmeans 47         0.000257  4.79e-07 6

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


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 21163 rows and 56 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 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-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.4311 0.569   0.569
#> 3 3 1.000           0.978       0.989         0.5683 0.753   0.567
#> 4 4 0.964           0.930       0.972         0.1077 0.899   0.700
#> 5 5 0.923           0.777       0.907         0.0466 0.924   0.719
#> 6 6 0.866           0.759       0.877         0.0347 0.949   0.781

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2   0.000      1.000  0 1.000 0.000
#> GSM329663     2   0.000      1.000  0 1.000 0.000
#> GSM329664     3   0.435      0.795  0 0.184 0.816
#> GSM329666     2   0.000      1.000  0 1.000 0.000
#> GSM329667     2   0.000      1.000  0 1.000 0.000
#> GSM329670     2   0.000      1.000  0 1.000 0.000
#> GSM329672     2   0.000      1.000  0 1.000 0.000
#> GSM329674     2   0.000      1.000  0 1.000 0.000
#> GSM329661     3   0.000      0.965  0 0.000 1.000
#> GSM329669     2   0.000      1.000  0 1.000 0.000
#> GSM329662     1   0.000      1.000  1 0.000 0.000
#> GSM329665     1   0.000      1.000  1 0.000 0.000
#> GSM329668     1   0.000      1.000  1 0.000 0.000
#> GSM329671     1   0.000      1.000  1 0.000 0.000
#> GSM329673     1   0.000      1.000  1 0.000 0.000
#> GSM329675     1   0.000      1.000  1 0.000 0.000
#> GSM329676     1   0.000      1.000  1 0.000 0.000
#> GSM329677     3   0.000      0.965  0 0.000 1.000
#> GSM329679     2   0.000      1.000  0 1.000 0.000
#> GSM329681     3   0.000      0.965  0 0.000 1.000
#> GSM329683     3   0.000      0.965  0 0.000 1.000
#> GSM329686     3   0.000      0.965  0 0.000 1.000
#> GSM329689     3   0.000      0.965  0 0.000 1.000
#> GSM329678     3   0.000      0.965  0 0.000 1.000
#> GSM329680     3   0.000      0.965  0 0.000 1.000
#> GSM329685     3   0.000      0.965  0 0.000 1.000
#> GSM329688     3   0.000      0.965  0 0.000 1.000
#> GSM329691     3   0.000      0.965  0 0.000 1.000
#> GSM329682     1   0.000      1.000  1 0.000 0.000
#> GSM329684     1   0.000      1.000  1 0.000 0.000
#> GSM329687     1   0.000      1.000  1 0.000 0.000
#> GSM329690     1   0.000      1.000  1 0.000 0.000
#> GSM329692     3   0.000      0.965  0 0.000 1.000
#> GSM329694     3   0.480      0.748  0 0.220 0.780
#> GSM329697     2   0.000      1.000  0 1.000 0.000
#> GSM329700     2   0.000      1.000  0 1.000 0.000
#> GSM329703     2   0.000      1.000  0 1.000 0.000
#> GSM329704     3   0.455      0.776  0 0.200 0.800
#> GSM329707     3   0.000      0.965  0 0.000 1.000
#> GSM329709     2   0.000      1.000  0 1.000 0.000
#> GSM329711     2   0.000      1.000  0 1.000 0.000
#> GSM329714     2   0.000      1.000  0 1.000 0.000
#> GSM329693     2   0.000      1.000  0 1.000 0.000
#> GSM329696     2   0.000      1.000  0 1.000 0.000
#> GSM329699     2   0.000      1.000  0 1.000 0.000
#> GSM329702     2   0.000      1.000  0 1.000 0.000
#> GSM329706     3   0.000      0.965  0 0.000 1.000
#> GSM329708     3   0.000      0.965  0 0.000 1.000
#> GSM329710     3   0.000      0.965  0 0.000 1.000
#> GSM329713     1   0.000      1.000  1 0.000 0.000
#> GSM329695     1   0.000      1.000  1 0.000 0.000
#> GSM329698     1   0.000      1.000  1 0.000 0.000
#> GSM329701     1   0.000      1.000  1 0.000 0.000
#> GSM329705     1   0.000      1.000  1 0.000 0.000
#> GSM329712     2   0.000      1.000  0 1.000 0.000
#> GSM329715     1   0.000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329663     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329664     3  0.3870      0.727  0 0.208 0.788 0.004
#> GSM329666     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329667     2  0.0188      0.977  0 0.996 0.000 0.004
#> GSM329670     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329672     2  0.0188      0.977  0 0.996 0.000 0.004
#> GSM329674     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329669     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329679     2  0.0188      0.977  0 0.996 0.000 0.004
#> GSM329681     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329678     4  0.4955      0.148  0 0.000 0.444 0.556
#> GSM329680     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0707      0.882  0 0.000 0.020 0.980
#> GSM329694     4  0.0672      0.885  0 0.008 0.008 0.984
#> GSM329697     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329700     2  0.3764      0.721  0 0.784 0.000 0.216
#> GSM329703     4  0.0188      0.891  0 0.004 0.000 0.996
#> GSM329704     3  0.3908      0.721  0 0.212 0.784 0.004
#> GSM329707     3  0.0188      0.957  0 0.000 0.996 0.004
#> GSM329709     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329711     2  0.0921      0.959  0 0.972 0.000 0.028
#> GSM329714     4  0.4564      0.441  0 0.328 0.000 0.672
#> GSM329693     4  0.0188      0.891  0 0.004 0.000 0.996
#> GSM329696     4  0.0188      0.891  0 0.004 0.000 0.996
#> GSM329699     4  0.0188      0.891  0 0.004 0.000 0.996
#> GSM329702     2  0.0000      0.979  0 1.000 0.000 0.000
#> GSM329706     3  0.0707      0.944  0 0.000 0.980 0.020
#> GSM329708     3  0.0000      0.960  0 0.000 1.000 0.000
#> GSM329710     4  0.0188      0.890  0 0.000 0.004 0.996
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.0921      0.959  0 0.972 0.000 0.028
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.0703     0.9518 0.000 0.976 0.000 0.000 0.024
#> GSM329663     2  0.0404     0.9548 0.000 0.988 0.000 0.000 0.012
#> GSM329664     5  0.1498     0.6412 0.000 0.008 0.016 0.024 0.952
#> GSM329666     2  0.0290     0.9565 0.000 0.992 0.000 0.000 0.008
#> GSM329667     5  0.2230     0.5542 0.000 0.116 0.000 0.000 0.884
#> GSM329670     2  0.0510     0.9544 0.000 0.984 0.000 0.000 0.016
#> GSM329672     2  0.1341     0.9314 0.000 0.944 0.000 0.000 0.056
#> GSM329674     2  0.0290     0.9565 0.000 0.992 0.000 0.000 0.008
#> GSM329661     3  0.4450     0.7006 0.000 0.000 0.508 0.488 0.004
#> GSM329669     2  0.0609     0.9522 0.000 0.980 0.000 0.000 0.020
#> GSM329662     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329665     1  0.0000     0.9941 1.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000     0.9941 1.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0404     0.9922 0.988 0.000 0.000 0.000 0.012
#> GSM329673     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329675     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329676     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329677     5  0.6417     0.2357 0.000 0.000 0.172 0.404 0.424
#> GSM329679     2  0.1341     0.9314 0.000 0.944 0.000 0.000 0.056
#> GSM329681     3  0.4450     0.7006 0.000 0.000 0.508 0.488 0.004
#> GSM329683     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329686     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329689     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329678     3  0.0162     0.0423 0.000 0.000 0.996 0.000 0.004
#> GSM329680     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329685     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329688     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329691     3  0.4561     0.7022 0.000 0.000 0.504 0.488 0.008
#> GSM329682     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329684     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329687     1  0.0162     0.9939 0.996 0.000 0.000 0.000 0.004
#> GSM329690     1  0.0404     0.9922 0.988 0.000 0.000 0.000 0.012
#> GSM329692     3  0.4781    -0.8294 0.000 0.000 0.552 0.428 0.020
#> GSM329694     3  0.6685    -0.6763 0.000 0.000 0.436 0.280 0.284
#> GSM329697     2  0.0290     0.9565 0.000 0.992 0.000 0.000 0.008
#> GSM329700     2  0.3445     0.8265 0.000 0.824 0.000 0.140 0.036
#> GSM329703     4  0.4305     0.8993 0.000 0.000 0.488 0.512 0.000
#> GSM329704     5  0.1498     0.6412 0.000 0.008 0.016 0.024 0.952
#> GSM329707     5  0.5474     0.5280 0.000 0.000 0.076 0.348 0.576
#> GSM329709     2  0.0290     0.9565 0.000 0.992 0.000 0.000 0.008
#> GSM329711     2  0.2331     0.9028 0.000 0.900 0.000 0.080 0.020
#> GSM329714     4  0.6799     0.3953 0.000 0.332 0.128 0.504 0.036
#> GSM329693     4  0.4305     0.8993 0.000 0.000 0.488 0.512 0.000
#> GSM329696     4  0.4305     0.8993 0.000 0.000 0.488 0.512 0.000
#> GSM329699     4  0.4305     0.8993 0.000 0.000 0.488 0.512 0.000
#> GSM329702     2  0.0290     0.9565 0.000 0.992 0.000 0.000 0.008
#> GSM329706     5  0.5916     0.5032 0.000 0.000 0.120 0.336 0.544
#> GSM329708     3  0.4305     0.6976 0.000 0.000 0.512 0.488 0.000
#> GSM329710     4  0.4307     0.8936 0.000 0.000 0.496 0.504 0.000
#> GSM329713     1  0.0404     0.9922 0.988 0.000 0.000 0.000 0.012
#> GSM329695     1  0.0404     0.9922 0.988 0.000 0.000 0.000 0.012
#> GSM329698     1  0.0404     0.9922 0.988 0.000 0.000 0.000 0.012
#> GSM329701     1  0.0404     0.9922 0.988 0.000 0.000 0.000 0.012
#> GSM329705     1  0.0000     0.9941 1.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.2331     0.9028 0.000 0.900 0.000 0.080 0.020
#> GSM329715     1  0.0290     0.9930 0.992 0.000 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
#> GSM329660     2  0.3175      0.605 0.000 0.744 0.000 0.000 0.000 0.256
#> GSM329663     2  0.3499      0.411 0.000 0.680 0.000 0.000 0.000 0.320
#> GSM329664     5  0.0146      0.670 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM329666     2  0.0000      0.784 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.3790      0.479 0.000 0.156 0.000 0.000 0.772 0.072
#> GSM329670     2  0.3531      0.405 0.000 0.672 0.000 0.000 0.000 0.328
#> GSM329672     2  0.0622      0.775 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM329674     2  0.0000      0.784 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.0632      0.920 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM329669     2  0.2969      0.635 0.000 0.776 0.000 0.000 0.000 0.224
#> GSM329662     1  0.1501      0.936 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM329665     1  0.0547      0.946 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM329668     1  0.0260      0.946 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM329671     1  0.1267      0.939 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM329673     1  0.1501      0.936 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM329675     1  0.1501      0.936 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM329676     1  0.1501      0.936 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM329677     3  0.3867     -0.260 0.000 0.000 0.512 0.000 0.488 0.000
#> GSM329679     2  0.0622      0.775 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM329681     3  0.0713      0.918 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM329683     3  0.0363      0.925 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM329686     3  0.0000      0.927 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.0363      0.925 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM329678     4  0.4482      0.401 0.000 0.000 0.384 0.580 0.000 0.036
#> GSM329680     3  0.0000      0.927 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000      0.927 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.927 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.927 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.1007      0.943 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM329684     1  0.1501      0.936 0.924 0.000 0.000 0.000 0.000 0.076
#> GSM329687     1  0.1444      0.937 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM329690     1  0.1327      0.938 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM329692     4  0.4540      0.625 0.000 0.000 0.036 0.632 0.008 0.324
#> GSM329694     4  0.5738      0.486 0.000 0.000 0.000 0.496 0.192 0.312
#> GSM329697     2  0.0000      0.784 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6  0.5165      0.641 0.000 0.228 0.000 0.156 0.000 0.616
#> GSM329703     4  0.0000      0.739 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.0146      0.670 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM329707     5  0.4045      0.537 0.000 0.000 0.312 0.000 0.664 0.024
#> GSM329709     2  0.0000      0.784 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     2  0.5005      0.375 0.000 0.628 0.000 0.124 0.000 0.248
#> GSM329714     6  0.4732      0.661 0.000 0.068 0.000 0.320 0.000 0.612
#> GSM329693     4  0.0000      0.739 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000      0.739 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.739 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000      0.784 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.4507      0.438 0.000 0.000 0.372 0.020 0.596 0.012
#> GSM329708     3  0.0713      0.918 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM329710     4  0.2994      0.698 0.000 0.000 0.000 0.788 0.004 0.208
#> GSM329713     1  0.1327      0.938 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM329695     1  0.1327      0.938 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM329698     1  0.1327      0.938 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM329701     1  0.1267      0.939 0.940 0.000 0.000 0.000 0.000 0.060
#> GSM329705     1  0.0547      0.946 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM329712     2  0.5005      0.375 0.000 0.628 0.000 0.124 0.000 0.248
#> GSM329715     1  0.0937      0.943 0.960 0.000 0.000 0.000 0.000 0.040

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> SD:skmeans 56         0.505684  5.82e-11 2
#> SD:skmeans 56         0.010546  4.13e-10 3
#> SD:skmeans 54         0.000564  1.63e-09 4
#> SD:skmeans 51         0.000461  2.90e-09 5
#> SD:skmeans 47         0.000891  3.29e-08 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 21163 rows and 56 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           1.000       1.000         0.4311 0.569   0.569
#> 3 3 1.000           0.993       0.997         0.5391 0.766   0.590
#> 4 4 0.848           0.762       0.906         0.1300 0.860   0.611
#> 5 5 0.925           0.891       0.953         0.0605 0.936   0.751
#> 6 6 0.917           0.868       0.909         0.0296 0.969   0.850

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 5

There is also optional best \(k\) = 2 3 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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2   0.000      1.000  0 1.000 0.000
#> GSM329663     2   0.000      1.000  0 1.000 0.000
#> GSM329664     2   0.000      1.000  0 1.000 0.000
#> GSM329666     2   0.000      1.000  0 1.000 0.000
#> GSM329667     2   0.000      1.000  0 1.000 0.000
#> GSM329670     2   0.000      1.000  0 1.000 0.000
#> GSM329672     2   0.000      1.000  0 1.000 0.000
#> GSM329674     2   0.000      1.000  0 1.000 0.000
#> GSM329661     3   0.000      0.986  0 0.000 1.000
#> GSM329669     2   0.000      1.000  0 1.000 0.000
#> GSM329662     1   0.000      1.000  1 0.000 0.000
#> GSM329665     1   0.000      1.000  1 0.000 0.000
#> GSM329668     1   0.000      1.000  1 0.000 0.000
#> GSM329671     1   0.000      1.000  1 0.000 0.000
#> GSM329673     1   0.000      1.000  1 0.000 0.000
#> GSM329675     1   0.000      1.000  1 0.000 0.000
#> GSM329676     1   0.000      1.000  1 0.000 0.000
#> GSM329677     3   0.000      0.986  0 0.000 1.000
#> GSM329679     2   0.000      1.000  0 1.000 0.000
#> GSM329681     3   0.000      0.986  0 0.000 1.000
#> GSM329683     3   0.000      0.986  0 0.000 1.000
#> GSM329686     3   0.000      0.986  0 0.000 1.000
#> GSM329689     3   0.000      0.986  0 0.000 1.000
#> GSM329678     3   0.000      0.986  0 0.000 1.000
#> GSM329680     3   0.000      0.986  0 0.000 1.000
#> GSM329685     3   0.000      0.986  0 0.000 1.000
#> GSM329688     3   0.000      0.986  0 0.000 1.000
#> GSM329691     3   0.000      0.986  0 0.000 1.000
#> GSM329682     1   0.000      1.000  1 0.000 0.000
#> GSM329684     1   0.000      1.000  1 0.000 0.000
#> GSM329687     1   0.000      1.000  1 0.000 0.000
#> GSM329690     1   0.000      1.000  1 0.000 0.000
#> GSM329692     3   0.341      0.861  0 0.124 0.876
#> GSM329694     2   0.000      1.000  0 1.000 0.000
#> GSM329697     2   0.000      1.000  0 1.000 0.000
#> GSM329700     2   0.000      1.000  0 1.000 0.000
#> GSM329703     2   0.000      1.000  0 1.000 0.000
#> GSM329704     2   0.000      1.000  0 1.000 0.000
#> GSM329707     3   0.186      0.940  0 0.052 0.948
#> GSM329709     2   0.000      1.000  0 1.000 0.000
#> GSM329711     2   0.000      1.000  0 1.000 0.000
#> GSM329714     2   0.000      1.000  0 1.000 0.000
#> GSM329693     2   0.000      1.000  0 1.000 0.000
#> GSM329696     2   0.000      1.000  0 1.000 0.000
#> GSM329699     2   0.000      1.000  0 1.000 0.000
#> GSM329702     2   0.000      1.000  0 1.000 0.000
#> GSM329706     3   0.000      0.986  0 0.000 1.000
#> GSM329708     3   0.000      0.986  0 0.000 1.000
#> GSM329710     2   0.000      1.000  0 1.000 0.000
#> GSM329713     1   0.000      1.000  1 0.000 0.000
#> GSM329695     1   0.000      1.000  1 0.000 0.000
#> GSM329698     1   0.000      1.000  1 0.000 0.000
#> GSM329701     1   0.000      1.000  1 0.000 0.000
#> GSM329705     1   0.000      1.000  1 0.000 0.000
#> GSM329712     2   0.000      1.000  0 1.000 0.000
#> GSM329715     1   0.000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329663     2  0.1022      0.801  0 0.968 0.000 0.032
#> GSM329664     4  0.4843      0.259  0 0.396 0.000 0.604
#> GSM329666     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329667     2  0.4866      0.228  0 0.596 0.000 0.404
#> GSM329670     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329672     2  0.4866      0.228  0 0.596 0.000 0.404
#> GSM329674     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329669     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.4661      0.462  0 0.000 0.652 0.348
#> GSM329679     2  0.4866      0.228  0 0.596 0.000 0.404
#> GSM329681     3  0.3764      0.679  0 0.000 0.784 0.216
#> GSM329683     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329678     4  0.0000      0.628  0 0.000 0.000 1.000
#> GSM329680     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.628  0 0.000 0.000 1.000
#> GSM329694     4  0.4843      0.259  0 0.396 0.000 0.604
#> GSM329697     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329700     2  0.3610      0.516  0 0.800 0.000 0.200
#> GSM329703     4  0.4866      0.370  0 0.404 0.000 0.596
#> GSM329704     4  0.4843      0.259  0 0.396 0.000 0.604
#> GSM329707     4  0.6391      0.352  0 0.304 0.092 0.604
#> GSM329709     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329711     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329714     4  0.4746      0.407  0 0.368 0.000 0.632
#> GSM329693     4  0.4866      0.370  0 0.404 0.000 0.596
#> GSM329696     4  0.4866      0.370  0 0.404 0.000 0.596
#> GSM329699     4  0.0336      0.629  0 0.008 0.000 0.992
#> GSM329702     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329706     4  0.2081      0.595  0 0.000 0.084 0.916
#> GSM329708     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329710     4  0.0336      0.629  0 0.008 0.000 0.992
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.0000      0.835  0 1.000 0.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     5  0.3274      0.690  0 0.220 0.000 0.000 0.780
#> GSM329663     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329664     5  0.0290      0.850  0 0.008 0.000 0.000 0.992
#> GSM329666     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329667     5  0.3242      0.695  0 0.216 0.000 0.000 0.784
#> GSM329670     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.0794      0.907  0 0.972 0.000 0.000 0.028
#> GSM329674     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329661     3  0.0290      0.946  0 0.000 0.992 0.000 0.008
#> GSM329669     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     5  0.1478      0.805  0 0.000 0.064 0.000 0.936
#> GSM329679     2  0.2690      0.767  0 0.844 0.000 0.000 0.156
#> GSM329681     3  0.3305      0.754  0 0.000 0.776 0.000 0.224
#> GSM329683     3  0.0290      0.946  0 0.000 0.992 0.000 0.008
#> GSM329686     3  0.0000      0.948  0 0.000 1.000 0.000 0.000
#> GSM329689     3  0.3242      0.764  0 0.000 0.784 0.000 0.216
#> GSM329678     4  0.2127      0.852  0 0.000 0.000 0.892 0.108
#> GSM329680     3  0.0000      0.948  0 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.948  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.948  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.948  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     5  0.4256      0.121  0 0.000 0.000 0.436 0.564
#> GSM329694     5  0.0290      0.850  0 0.008 0.000 0.000 0.992
#> GSM329697     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329700     2  0.4283      0.211  0 0.544 0.000 0.456 0.000
#> GSM329703     4  0.0000      0.937  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.0290      0.850  0 0.008 0.000 0.000 0.992
#> GSM329707     5  0.0000      0.846  0 0.000 0.000 0.000 1.000
#> GSM329709     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329711     2  0.1965      0.868  0 0.904 0.000 0.096 0.000
#> GSM329714     4  0.3628      0.714  0 0.012 0.000 0.772 0.216
#> GSM329693     4  0.0000      0.937  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.937  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.937  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0000      0.924  0 1.000 0.000 0.000 0.000
#> GSM329706     5  0.0609      0.842  0 0.000 0.000 0.020 0.980
#> GSM329708     3  0.0000      0.948  0 0.000 1.000 0.000 0.000
#> GSM329710     4  0.0000      0.937  0 0.000 0.000 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     2  0.2020      0.865  0 0.900 0.000 0.100 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     6  0.4923     0.7298 0.000 0.172 0.000 0.000 0.172 0.656
#> GSM329663     2  0.0632     0.8992 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM329664     5  0.0000     0.8231 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329666     2  0.0000     0.9094 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.0000     0.8231 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329670     2  0.0000     0.9094 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329672     2  0.2378     0.7559 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM329674     2  0.0000     0.9094 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.3515     0.7747 0.000 0.000 0.676 0.000 0.000 0.324
#> GSM329669     6  0.3756     0.8293 0.000 0.400 0.000 0.000 0.000 0.600
#> GSM329662     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0146     0.9957 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329673     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329677     5  0.4725     0.5275 0.000 0.000 0.064 0.000 0.604 0.332
#> GSM329679     2  0.3101     0.6132 0.000 0.756 0.000 0.000 0.244 0.000
#> GSM329681     3  0.3547     0.7714 0.000 0.000 0.668 0.000 0.000 0.332
#> GSM329683     3  0.3547     0.7714 0.000 0.000 0.668 0.000 0.000 0.332
#> GSM329686     3  0.0000     0.8613 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.3547     0.7714 0.000 0.000 0.668 0.000 0.000 0.332
#> GSM329678     4  0.0260     0.9308 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM329680     3  0.0000     0.8613 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000     0.8613 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000     0.8613 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000     0.8613 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0363     0.9925 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329692     5  0.4739     0.0262 0.000 0.000 0.000 0.436 0.516 0.048
#> GSM329694     5  0.0000     0.8231 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329697     2  0.0632     0.8992 0.000 0.976 0.000 0.000 0.024 0.000
#> GSM329700     6  0.4342     0.8810 0.000 0.308 0.000 0.008 0.028 0.656
#> GSM329703     4  0.0000     0.9368 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.0000     0.8231 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329707     5  0.2996     0.7033 0.000 0.000 0.000 0.000 0.772 0.228
#> GSM329709     2  0.0000     0.9094 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.3592     0.8890 0.000 0.344 0.000 0.000 0.000 0.656
#> GSM329714     4  0.4443     0.4879 0.000 0.000 0.000 0.648 0.300 0.052
#> GSM329693     4  0.0000     0.9368 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000     0.9368 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000     0.9368 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000     0.9094 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.0632     0.8145 0.000 0.000 0.000 0.024 0.976 0.000
#> GSM329708     3  0.0000     0.8613 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329710     4  0.0000     0.9368 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0363     0.9925 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329695     1  0.0363     0.9925 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329698     1  0.0363     0.9925 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329701     1  0.0260     0.9942 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM329705     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.3714     0.8908 0.000 0.340 0.000 0.000 0.004 0.656
#> GSM329715     1  0.0000     0.9969 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-pam-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) tissue(p) k
#> SD:pam 56         0.505684  5.82e-11 2
#> SD:pam 56         0.000528  2.02e-10 3
#> SD:pam 44         0.001155  2.46e-08 4
#> SD:pam 54         0.001995  8.34e-10 5
#> SD:pam 54         0.005841  9.31e-10 6

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


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

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 0.790           0.830       0.923         0.5364 0.773   0.601
#> 4 4 0.890           0.899       0.943         0.1186 0.862   0.633
#> 5 5 0.912           0.865       0.936         0.0606 0.924   0.730
#> 6 6 0.889           0.805       0.903         0.0384 0.946   0.759

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.0000     0.8253  0 1.000 0.000
#> GSM329663     2  0.0000     0.8253  0 1.000 0.000
#> GSM329664     3  0.6299     0.0901  0 0.476 0.524
#> GSM329666     2  0.0000     0.8253  0 1.000 0.000
#> GSM329667     2  0.4654     0.6546  0 0.792 0.208
#> GSM329670     2  0.0000     0.8253  0 1.000 0.000
#> GSM329672     2  0.0000     0.8253  0 1.000 0.000
#> GSM329674     2  0.0000     0.8253  0 1.000 0.000
#> GSM329661     3  0.0237     0.9211  0 0.004 0.996
#> GSM329669     2  0.0000     0.8253  0 1.000 0.000
#> GSM329662     1  0.0000     1.0000  1 0.000 0.000
#> GSM329665     1  0.0000     1.0000  1 0.000 0.000
#> GSM329668     1  0.0000     1.0000  1 0.000 0.000
#> GSM329671     1  0.0000     1.0000  1 0.000 0.000
#> GSM329673     1  0.0000     1.0000  1 0.000 0.000
#> GSM329675     1  0.0000     1.0000  1 0.000 0.000
#> GSM329676     1  0.0000     1.0000  1 0.000 0.000
#> GSM329677     3  0.0424     0.9206  0 0.008 0.992
#> GSM329679     2  0.0000     0.8253  0 1.000 0.000
#> GSM329681     3  0.0424     0.9206  0 0.008 0.992
#> GSM329683     3  0.0000     0.9202  0 0.000 1.000
#> GSM329686     3  0.0000     0.9202  0 0.000 1.000
#> GSM329689     3  0.0424     0.9206  0 0.008 0.992
#> GSM329678     2  0.6062     0.5232  0 0.616 0.384
#> GSM329680     3  0.0424     0.9206  0 0.008 0.992
#> GSM329685     3  0.0000     0.9202  0 0.000 1.000
#> GSM329688     3  0.0000     0.9202  0 0.000 1.000
#> GSM329691     3  0.0000     0.9202  0 0.000 1.000
#> GSM329682     1  0.0000     1.0000  1 0.000 0.000
#> GSM329684     1  0.0000     1.0000  1 0.000 0.000
#> GSM329687     1  0.0000     1.0000  1 0.000 0.000
#> GSM329690     1  0.0000     1.0000  1 0.000 0.000
#> GSM329692     2  0.5968     0.5581  0 0.636 0.364
#> GSM329694     2  0.5216     0.6656  0 0.740 0.260
#> GSM329697     2  0.0000     0.8253  0 1.000 0.000
#> GSM329700     2  0.0000     0.8253  0 1.000 0.000
#> GSM329703     2  0.5968     0.5581  0 0.636 0.364
#> GSM329704     2  0.6192     0.1946  0 0.580 0.420
#> GSM329707     3  0.3941     0.7531  0 0.156 0.844
#> GSM329709     2  0.0000     0.8253  0 1.000 0.000
#> GSM329711     2  0.0000     0.8253  0 1.000 0.000
#> GSM329714     2  0.1529     0.8083  0 0.960 0.040
#> GSM329693     2  0.5968     0.5581  0 0.636 0.364
#> GSM329696     2  0.5968     0.5581  0 0.636 0.364
#> GSM329699     2  0.5968     0.5581  0 0.636 0.364
#> GSM329702     2  0.0000     0.8253  0 1.000 0.000
#> GSM329706     3  0.4121     0.7340  0 0.168 0.832
#> GSM329708     3  0.0237     0.9211  0 0.004 0.996
#> GSM329710     2  0.5968     0.5581  0 0.636 0.364
#> GSM329713     1  0.0000     1.0000  1 0.000 0.000
#> GSM329695     1  0.0000     1.0000  1 0.000 0.000
#> GSM329698     1  0.0000     1.0000  1 0.000 0.000
#> GSM329701     1  0.0000     1.0000  1 0.000 0.000
#> GSM329705     1  0.0000     1.0000  1 0.000 0.000
#> GSM329712     2  0.0000     0.8253  0 1.000 0.000
#> GSM329715     1  0.0000     1.0000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.3610      0.766  0 0.800 0.000 0.200
#> GSM329663     2  0.1022      0.840  0 0.968 0.000 0.032
#> GSM329664     2  0.1913      0.824  0 0.940 0.040 0.020
#> GSM329666     2  0.0000      0.839  0 1.000 0.000 0.000
#> GSM329667     2  0.1389      0.836  0 0.952 0.000 0.048
#> GSM329670     2  0.3610      0.766  0 0.800 0.000 0.200
#> GSM329672     2  0.1118      0.838  0 0.964 0.000 0.036
#> GSM329674     2  0.0000      0.839  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329669     2  0.3610      0.766  0 0.800 0.000 0.200
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.3610      0.744  0 0.200 0.800 0.000
#> GSM329679     2  0.1022      0.839  0 0.968 0.000 0.032
#> GSM329681     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329678     4  0.0000      0.997  0 0.000 0.000 1.000
#> GSM329680     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.997  0 0.000 0.000 1.000
#> GSM329694     2  0.4585      0.536  0 0.668 0.000 0.332
#> GSM329697     2  0.0000      0.839  0 1.000 0.000 0.000
#> GSM329700     2  0.4164      0.737  0 0.736 0.000 0.264
#> GSM329703     4  0.0188      0.997  0 0.004 0.000 0.996
#> GSM329704     2  0.1389      0.836  0 0.952 0.000 0.048
#> GSM329707     2  0.6397      0.536  0 0.652 0.164 0.184
#> GSM329709     2  0.0000      0.839  0 1.000 0.000 0.000
#> GSM329711     2  0.3726      0.758  0 0.788 0.000 0.212
#> GSM329714     2  0.3610      0.766  0 0.800 0.000 0.200
#> GSM329693     4  0.0188      0.997  0 0.004 0.000 0.996
#> GSM329696     4  0.0188      0.997  0 0.004 0.000 0.996
#> GSM329699     4  0.0188      0.997  0 0.004 0.000 0.996
#> GSM329702     2  0.0000      0.839  0 1.000 0.000 0.000
#> GSM329706     2  0.5582      0.345  0 0.576 0.024 0.400
#> GSM329708     3  0.0000      0.977  0 0.000 1.000 0.000
#> GSM329710     4  0.0000      0.997  0 0.000 0.000 1.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.4431      0.687  0 0.696 0.000 0.304
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     2  0.0000      0.855  0 1.000 0.000 0.000 0.000
#> GSM329663     2  0.0000      0.855  0 1.000 0.000 0.000 0.000
#> GSM329664     5  0.1908      0.825  0 0.092 0.000 0.000 0.908
#> GSM329666     2  0.0162      0.856  0 0.996 0.000 0.000 0.004
#> GSM329667     5  0.3177      0.744  0 0.208 0.000 0.000 0.792
#> GSM329670     2  0.0000      0.855  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.1270      0.821  0 0.948 0.000 0.000 0.052
#> GSM329674     2  0.0162      0.856  0 0.996 0.000 0.000 0.004
#> GSM329661     3  0.0703      0.950  0 0.000 0.976 0.000 0.024
#> GSM329669     2  0.0000      0.855  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     5  0.3534      0.534  0 0.000 0.256 0.000 0.744
#> GSM329679     2  0.1410      0.814  0 0.940 0.000 0.000 0.060
#> GSM329681     3  0.2966      0.825  0 0.000 0.816 0.000 0.184
#> GSM329683     3  0.0963      0.946  0 0.000 0.964 0.000 0.036
#> GSM329686     3  0.0703      0.950  0 0.000 0.976 0.000 0.024
#> GSM329689     3  0.2605      0.866  0 0.000 0.852 0.000 0.148
#> GSM329678     4  0.0324      0.894  0 0.000 0.004 0.992 0.004
#> GSM329680     3  0.1043      0.924  0 0.000 0.960 0.040 0.000
#> GSM329685     3  0.0000      0.951  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.951  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.951  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.3241      0.765  0 0.024 0.000 0.832 0.144
#> GSM329694     4  0.6463      0.301  0 0.228 0.000 0.496 0.276
#> GSM329697     2  0.0162      0.856  0 0.996 0.000 0.000 0.004
#> GSM329700     2  0.4045      0.508  0 0.644 0.000 0.356 0.000
#> GSM329703     4  0.0000      0.899  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.2280      0.816  0 0.120 0.000 0.000 0.880
#> GSM329707     5  0.0000      0.794  0 0.000 0.000 0.000 1.000
#> GSM329709     2  0.0162      0.856  0 0.996 0.000 0.000 0.004
#> GSM329711     2  0.4030      0.514  0 0.648 0.000 0.352 0.000
#> GSM329714     2  0.5181      0.426  0 0.588 0.000 0.360 0.052
#> GSM329693     4  0.0000      0.899  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.899  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.899  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0162      0.856  0 0.996 0.000 0.000 0.004
#> GSM329706     5  0.2964      0.748  0 0.024 0.000 0.120 0.856
#> GSM329708     3  0.0000      0.951  0 0.000 1.000 0.000 0.000
#> GSM329710     4  0.0000      0.899  0 0.000 0.000 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     2  0.4114      0.469  0 0.624 0.000 0.376 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     6  0.4045      0.518 0.000 0.428 0.000 0.000 0.008 0.564
#> GSM329663     2  0.4543     -0.147 0.000 0.576 0.000 0.000 0.040 0.384
#> GSM329664     5  0.4757      0.664 0.000 0.180 0.000 0.000 0.676 0.144
#> GSM329666     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     2  0.3221      0.650 0.000 0.792 0.000 0.000 0.188 0.020
#> GSM329670     6  0.4032      0.530 0.000 0.420 0.000 0.000 0.008 0.572
#> GSM329672     2  0.0146      0.886 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM329674     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.0363      0.870 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM329669     6  0.3797      0.533 0.000 0.420 0.000 0.000 0.000 0.580
#> GSM329662     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0363      0.990 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329676     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329677     5  0.2882      0.509 0.000 0.000 0.180 0.000 0.812 0.008
#> GSM329679     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329681     3  0.5045      0.404 0.000 0.000 0.552 0.000 0.364 0.084
#> GSM329683     3  0.0458      0.868 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM329686     3  0.0363      0.870 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM329689     3  0.5035      0.410 0.000 0.000 0.556 0.000 0.360 0.084
#> GSM329678     4  0.0363      0.957 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM329680     3  0.0363      0.866 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM329685     3  0.0000      0.870 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.870 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.870 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0363      0.990 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329687     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329692     4  0.3014      0.767 0.000 0.000 0.000 0.804 0.012 0.184
#> GSM329694     6  0.4180     -0.212 0.000 0.008 0.000 0.012 0.348 0.632
#> GSM329697     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6  0.2854      0.699 0.000 0.208 0.000 0.000 0.000 0.792
#> GSM329703     4  0.0000      0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.4762      0.665 0.000 0.148 0.000 0.000 0.676 0.176
#> GSM329707     5  0.1802      0.690 0.000 0.072 0.000 0.000 0.916 0.012
#> GSM329709     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.2664      0.704 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM329714     6  0.0547      0.530 0.000 0.020 0.000 0.000 0.000 0.980
#> GSM329693     4  0.0000      0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000      0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000      0.890 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.3490      0.659 0.000 0.000 0.000 0.008 0.724 0.268
#> GSM329708     3  0.2219      0.744 0.000 0.000 0.864 0.136 0.000 0.000
#> GSM329710     4  0.0260      0.960 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM329713     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.2664      0.704 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM329715     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) tissue(p) k
#> SD:mclust 56         5.06e-01  5.82e-11 2
#> SD:mclust 54         1.79e-03  9.10e-10 3
#> SD:mclust 55         7.84e-05  2.32e-11 4
#> SD:mclust 53         1.78e-03  2.07e-10 5
#> SD:mclust 52         1.96e-02  2.76e-09 6

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


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

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.998       0.999         0.4316 0.569   0.569
#> 3 3 1.000           0.969       0.986         0.5565 0.761   0.580
#> 4 4 0.755           0.681       0.829         0.1145 0.871   0.639
#> 5 5 0.725           0.625       0.770         0.0319 0.963   0.860
#> 6 6 0.709           0.610       0.741         0.0371 0.946   0.787

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
#> GSM329660     2  0.0000      0.999 0.000 1.000
#> GSM329663     2  0.0000      0.999 0.000 1.000
#> GSM329664     2  0.0000      0.999 0.000 1.000
#> GSM329666     2  0.0000      0.999 0.000 1.000
#> GSM329667     2  0.0000      0.999 0.000 1.000
#> GSM329670     2  0.0938      0.988 0.012 0.988
#> GSM329672     2  0.0000      0.999 0.000 1.000
#> GSM329674     2  0.0000      0.999 0.000 1.000
#> GSM329661     2  0.0000      0.999 0.000 1.000
#> GSM329669     2  0.2043      0.968 0.032 0.968
#> GSM329662     1  0.0000      1.000 1.000 0.000
#> GSM329665     1  0.0000      1.000 1.000 0.000
#> GSM329668     1  0.0000      1.000 1.000 0.000
#> GSM329671     1  0.0000      1.000 1.000 0.000
#> GSM329673     1  0.0000      1.000 1.000 0.000
#> GSM329675     1  0.0000      1.000 1.000 0.000
#> GSM329676     1  0.0000      1.000 1.000 0.000
#> GSM329677     2  0.0000      0.999 0.000 1.000
#> GSM329679     2  0.0000      0.999 0.000 1.000
#> GSM329681     2  0.0000      0.999 0.000 1.000
#> GSM329683     2  0.0000      0.999 0.000 1.000
#> GSM329686     2  0.0000      0.999 0.000 1.000
#> GSM329689     2  0.0000      0.999 0.000 1.000
#> GSM329678     2  0.0000      0.999 0.000 1.000
#> GSM329680     2  0.0000      0.999 0.000 1.000
#> GSM329685     2  0.0000      0.999 0.000 1.000
#> GSM329688     2  0.0000      0.999 0.000 1.000
#> GSM329691     2  0.0000      0.999 0.000 1.000
#> GSM329682     1  0.0000      1.000 1.000 0.000
#> GSM329684     1  0.0000      1.000 1.000 0.000
#> GSM329687     1  0.0000      1.000 1.000 0.000
#> GSM329690     1  0.0000      1.000 1.000 0.000
#> GSM329692     2  0.0000      0.999 0.000 1.000
#> GSM329694     2  0.0000      0.999 0.000 1.000
#> GSM329697     2  0.0000      0.999 0.000 1.000
#> GSM329700     2  0.0000      0.999 0.000 1.000
#> GSM329703     2  0.0000      0.999 0.000 1.000
#> GSM329704     2  0.0000      0.999 0.000 1.000
#> GSM329707     2  0.0000      0.999 0.000 1.000
#> GSM329709     2  0.0000      0.999 0.000 1.000
#> GSM329711     2  0.0000      0.999 0.000 1.000
#> GSM329714     2  0.0000      0.999 0.000 1.000
#> GSM329693     2  0.0000      0.999 0.000 1.000
#> GSM329696     2  0.0000      0.999 0.000 1.000
#> GSM329699     2  0.0000      0.999 0.000 1.000
#> GSM329702     2  0.0000      0.999 0.000 1.000
#> GSM329706     2  0.0000      0.999 0.000 1.000
#> GSM329708     2  0.0000      0.999 0.000 1.000
#> GSM329710     2  0.0000      0.999 0.000 1.000
#> GSM329713     1  0.0000      1.000 1.000 0.000
#> GSM329695     1  0.0000      1.000 1.000 0.000
#> GSM329698     1  0.0000      1.000 1.000 0.000
#> GSM329701     1  0.0000      1.000 1.000 0.000
#> GSM329705     1  0.0000      1.000 1.000 0.000
#> GSM329712     2  0.0000      0.999 0.000 1.000
#> GSM329715     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM329660     2  0.0000      0.965  0 1.000 0.000
#> GSM329663     2  0.0000      0.965  0 1.000 0.000
#> GSM329664     2  0.5733      0.555  0 0.676 0.324
#> GSM329666     2  0.0000      0.965  0 1.000 0.000
#> GSM329667     2  0.0000      0.965  0 1.000 0.000
#> GSM329670     2  0.0000      0.965  0 1.000 0.000
#> GSM329672     2  0.0000      0.965  0 1.000 0.000
#> GSM329674     2  0.0000      0.965  0 1.000 0.000
#> GSM329661     3  0.0000      0.998  0 0.000 1.000
#> GSM329669     2  0.0000      0.965  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.998  0 0.000 1.000
#> GSM329679     2  0.0000      0.965  0 1.000 0.000
#> GSM329681     3  0.0000      0.998  0 0.000 1.000
#> GSM329683     3  0.0000      0.998  0 0.000 1.000
#> GSM329686     3  0.0000      0.998  0 0.000 1.000
#> GSM329689     3  0.0000      0.998  0 0.000 1.000
#> GSM329678     3  0.0000      0.998  0 0.000 1.000
#> GSM329680     3  0.0000      0.998  0 0.000 1.000
#> GSM329685     3  0.0000      0.998  0 0.000 1.000
#> GSM329688     3  0.0000      0.998  0 0.000 1.000
#> GSM329691     3  0.0000      0.998  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     3  0.0000      0.998  0 0.000 1.000
#> GSM329694     2  0.0892      0.950  0 0.980 0.020
#> GSM329697     2  0.0000      0.965  0 1.000 0.000
#> GSM329700     2  0.0000      0.965  0 1.000 0.000
#> GSM329703     2  0.0000      0.965  0 1.000 0.000
#> GSM329704     2  0.5497      0.616  0 0.708 0.292
#> GSM329707     3  0.0000      0.998  0 0.000 1.000
#> GSM329709     2  0.0000      0.965  0 1.000 0.000
#> GSM329711     2  0.0000      0.965  0 1.000 0.000
#> GSM329714     2  0.0000      0.965  0 1.000 0.000
#> GSM329693     2  0.0000      0.965  0 1.000 0.000
#> GSM329696     2  0.0000      0.965  0 1.000 0.000
#> GSM329699     2  0.3267      0.861  0 0.884 0.116
#> GSM329702     2  0.0000      0.965  0 1.000 0.000
#> GSM329706     3  0.0000      0.998  0 0.000 1.000
#> GSM329708     3  0.0000      0.998  0 0.000 1.000
#> GSM329710     3  0.1163      0.969  0 0.028 0.972
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.965  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.1489     0.8070  0 0.952 0.004 0.044
#> GSM329663     2  0.2081     0.8077  0 0.916 0.000 0.084
#> GSM329664     3  0.5150     0.1994  0 0.396 0.596 0.008
#> GSM329666     2  0.0336     0.7996  0 0.992 0.000 0.008
#> GSM329667     2  0.4482     0.5503  0 0.728 0.264 0.008
#> GSM329670     2  0.3266     0.7862  0 0.832 0.000 0.168
#> GSM329672     2  0.2611     0.7363  0 0.896 0.096 0.008
#> GSM329674     2  0.3688     0.7689  0 0.792 0.000 0.208
#> GSM329661     3  0.4877     0.4208  0 0.000 0.592 0.408
#> GSM329669     2  0.4164     0.7291  0 0.736 0.000 0.264
#> GSM329662     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329677     3  0.0469     0.5792  0 0.012 0.988 0.000
#> GSM329679     2  0.2675     0.7337  0 0.892 0.100 0.008
#> GSM329681     3  0.2216     0.6096  0 0.000 0.908 0.092
#> GSM329683     3  0.3569     0.5954  0 0.000 0.804 0.196
#> GSM329686     3  0.4164     0.5711  0 0.000 0.736 0.264
#> GSM329689     3  0.2281     0.6100  0 0.000 0.904 0.096
#> GSM329678     4  0.4713     0.0887  0 0.000 0.360 0.640
#> GSM329680     3  0.4730     0.4969  0 0.000 0.636 0.364
#> GSM329685     3  0.4925     0.3926  0 0.000 0.572 0.428
#> GSM329688     3  0.4972     0.3331  0 0.000 0.544 0.456
#> GSM329691     3  0.4697     0.5054  0 0.000 0.644 0.356
#> GSM329682     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329692     4  0.4933    -0.0502  0 0.000 0.432 0.568
#> GSM329694     2  0.2859     0.7521  0 0.880 0.112 0.008
#> GSM329697     2  0.1211     0.8073  0 0.960 0.000 0.040
#> GSM329700     2  0.3975     0.7473  0 0.760 0.000 0.240
#> GSM329703     4  0.3444     0.4828  0 0.184 0.000 0.816
#> GSM329704     3  0.5193     0.1680  0 0.412 0.580 0.008
#> GSM329707     3  0.3933     0.4490  0 0.200 0.792 0.008
#> GSM329709     2  0.2408     0.8053  0 0.896 0.000 0.104
#> GSM329711     2  0.4746     0.6110  0 0.632 0.000 0.368
#> GSM329714     2  0.4761     0.5790  0 0.628 0.000 0.372
#> GSM329693     4  0.4500     0.1408  0 0.316 0.000 0.684
#> GSM329696     4  0.3219     0.5123  0 0.164 0.000 0.836
#> GSM329699     4  0.2345     0.5621  0 0.100 0.000 0.900
#> GSM329702     2  0.0469     0.7916  0 0.988 0.012 0.000
#> GSM329706     3  0.2256     0.5862  0 0.020 0.924 0.056
#> GSM329708     4  0.4855    -0.0122  0 0.000 0.400 0.600
#> GSM329710     4  0.2281     0.4610  0 0.000 0.096 0.904
#> GSM329713     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329712     2  0.4776     0.5992  0 0.624 0.000 0.376
#> GSM329715     1  0.0000     1.0000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.2660     0.7169 0.000 0.864 0.000 0.128 0.008
#> GSM329663     2  0.3051     0.6992 0.000 0.864 0.000 0.076 0.060
#> GSM329664     3  0.7853     0.2303 0.000 0.288 0.340 0.308 0.064
#> GSM329666     2  0.1792     0.7097 0.000 0.916 0.000 0.084 0.000
#> GSM329667     2  0.5963     0.4338 0.000 0.596 0.060 0.308 0.036
#> GSM329670     2  0.4258     0.6191 0.000 0.768 0.000 0.160 0.072
#> GSM329672     2  0.3612     0.6129 0.000 0.764 0.000 0.228 0.008
#> GSM329674     2  0.2305     0.7063 0.000 0.896 0.000 0.092 0.012
#> GSM329661     5  0.4752     0.7059 0.000 0.000 0.412 0.020 0.568
#> GSM329669     2  0.2561     0.6808 0.000 0.856 0.000 0.144 0.000
#> GSM329662     1  0.1043     0.9646 0.960 0.000 0.000 0.000 0.040
#> GSM329665     1  0.0510     0.9723 0.984 0.000 0.000 0.000 0.016
#> GSM329668     1  0.0404     0.9730 0.988 0.000 0.000 0.000 0.012
#> GSM329671     1  0.0290     0.9716 0.992 0.000 0.000 0.000 0.008
#> GSM329673     1  0.0510     0.9720 0.984 0.000 0.000 0.000 0.016
#> GSM329675     1  0.0794     0.9693 0.972 0.000 0.000 0.000 0.028
#> GSM329676     1  0.0794     0.9693 0.972 0.000 0.000 0.000 0.028
#> GSM329677     3  0.4649     0.3430 0.000 0.004 0.732 0.200 0.064
#> GSM329679     2  0.4216     0.5747 0.000 0.720 0.008 0.260 0.012
#> GSM329681     5  0.5092     0.5696 0.000 0.000 0.440 0.036 0.524
#> GSM329683     3  0.3398    -0.0690 0.000 0.000 0.780 0.004 0.216
#> GSM329686     3  0.0963     0.2834 0.000 0.000 0.964 0.036 0.000
#> GSM329689     3  0.4334     0.1818 0.000 0.000 0.768 0.092 0.140
#> GSM329678     3  0.4747    -0.0749 0.000 0.000 0.500 0.484 0.016
#> GSM329680     3  0.3112     0.2203 0.000 0.000 0.856 0.100 0.044
#> GSM329685     3  0.3696     0.1515 0.000 0.000 0.772 0.212 0.016
#> GSM329688     3  0.3659     0.1483 0.000 0.000 0.768 0.220 0.012
#> GSM329691     3  0.2522     0.2563 0.000 0.000 0.880 0.108 0.012
#> GSM329682     1  0.0162     0.9730 0.996 0.000 0.000 0.000 0.004
#> GSM329684     1  0.1341     0.9561 0.944 0.000 0.000 0.000 0.056
#> GSM329687     1  0.0609     0.9714 0.980 0.000 0.000 0.000 0.020
#> GSM329690     1  0.1478     0.9489 0.936 0.000 0.000 0.000 0.064
#> GSM329692     5  0.6711     0.5763 0.000 0.004 0.396 0.204 0.396
#> GSM329694     2  0.4728     0.5944 0.000 0.764 0.128 0.088 0.020
#> GSM329697     2  0.0609     0.7263 0.000 0.980 0.000 0.000 0.020
#> GSM329700     2  0.3675     0.6369 0.000 0.788 0.000 0.188 0.024
#> GSM329703     4  0.4251     0.7109 0.000 0.316 0.012 0.672 0.000
#> GSM329704     3  0.7815     0.2292 0.000 0.292 0.340 0.308 0.060
#> GSM329707     3  0.7185     0.2610 0.000 0.128 0.496 0.308 0.068
#> GSM329709     2  0.1485     0.7232 0.000 0.948 0.000 0.032 0.020
#> GSM329711     2  0.3689     0.5481 0.000 0.740 0.000 0.256 0.004
#> GSM329714     2  0.4003     0.4574 0.000 0.704 0.000 0.288 0.008
#> GSM329693     4  0.4586     0.6816 0.000 0.336 0.016 0.644 0.004
#> GSM329696     4  0.5360     0.7543 0.000 0.244 0.076 0.668 0.012
#> GSM329699     4  0.5413     0.6829 0.000 0.172 0.164 0.664 0.000
#> GSM329702     2  0.2179     0.7017 0.000 0.896 0.000 0.100 0.004
#> GSM329706     3  0.4792     0.3458 0.000 0.012 0.712 0.232 0.044
#> GSM329708     5  0.5865     0.7117 0.000 0.000 0.360 0.108 0.532
#> GSM329710     4  0.8136     0.0694 0.000 0.124 0.192 0.348 0.336
#> GSM329713     1  0.1965     0.9281 0.904 0.000 0.000 0.000 0.096
#> GSM329695     1  0.1908     0.9309 0.908 0.000 0.000 0.000 0.092
#> GSM329698     1  0.1121     0.9590 0.956 0.000 0.000 0.000 0.044
#> GSM329701     1  0.0609     0.9686 0.980 0.000 0.000 0.000 0.020
#> GSM329705     1  0.0000     0.9727 1.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.3766     0.5244 0.000 0.728 0.000 0.268 0.004
#> GSM329715     1  0.0290     0.9716 0.992 0.000 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
#> GSM329660     2  0.3025     0.6668 0.000 0.820 0.000 0.024 0.156 0.000
#> GSM329663     2  0.4896     0.5608 0.000 0.708 0.000 0.116 0.148 0.028
#> GSM329664     5  0.4261     0.6433 0.000 0.112 0.156 0.000 0.732 0.000
#> GSM329666     2  0.2854     0.6385 0.000 0.792 0.000 0.000 0.208 0.000
#> GSM329667     5  0.4118     0.0194 0.000 0.396 0.004 0.000 0.592 0.008
#> GSM329670     2  0.4806     0.5047 0.000 0.708 0.000 0.160 0.112 0.020
#> GSM329672     2  0.3872     0.3725 0.000 0.604 0.000 0.000 0.392 0.004
#> GSM329674     2  0.2000     0.6448 0.000 0.916 0.000 0.048 0.032 0.004
#> GSM329661     6  0.1888     0.7615 0.000 0.000 0.068 0.004 0.012 0.916
#> GSM329669     2  0.1434     0.6281 0.000 0.940 0.000 0.048 0.012 0.000
#> GSM329662     1  0.1219     0.8990 0.948 0.000 0.000 0.048 0.004 0.000
#> GSM329665     1  0.0790     0.9073 0.968 0.000 0.000 0.032 0.000 0.000
#> GSM329668     1  0.0603     0.9116 0.980 0.000 0.000 0.016 0.004 0.000
#> GSM329671     1  0.2285     0.9064 0.900 0.000 0.000 0.064 0.028 0.008
#> GSM329673     1  0.0865     0.9046 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM329675     1  0.1007     0.9021 0.956 0.000 0.000 0.044 0.000 0.000
#> GSM329676     1  0.0937     0.9035 0.960 0.000 0.000 0.040 0.000 0.000
#> GSM329677     3  0.4964    -0.1138 0.000 0.000 0.484 0.040 0.464 0.012
#> GSM329679     2  0.3717     0.3820 0.000 0.616 0.000 0.000 0.384 0.000
#> GSM329681     6  0.2653     0.7319 0.000 0.000 0.100 0.004 0.028 0.868
#> GSM329683     3  0.6680     0.1194 0.000 0.000 0.420 0.072 0.140 0.368
#> GSM329686     3  0.3792     0.5747 0.000 0.000 0.792 0.044 0.144 0.020
#> GSM329689     3  0.6731     0.2768 0.000 0.000 0.468 0.072 0.288 0.172
#> GSM329678     3  0.3799     0.1793 0.000 0.000 0.704 0.276 0.000 0.020
#> GSM329680     3  0.3825     0.6185 0.000 0.000 0.812 0.044 0.072 0.072
#> GSM329685     3  0.0935     0.6294 0.000 0.000 0.964 0.032 0.000 0.004
#> GSM329688     3  0.0806     0.6282 0.000 0.000 0.972 0.020 0.000 0.008
#> GSM329691     3  0.2428     0.6423 0.000 0.000 0.896 0.024 0.060 0.020
#> GSM329682     1  0.1592     0.9113 0.940 0.000 0.000 0.032 0.020 0.008
#> GSM329684     1  0.1349     0.8953 0.940 0.000 0.000 0.056 0.004 0.000
#> GSM329687     1  0.0865     0.9046 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM329690     1  0.3917     0.8556 0.780 0.000 0.000 0.144 0.064 0.012
#> GSM329692     6  0.4263     0.7183 0.000 0.016 0.232 0.028 0.004 0.720
#> GSM329694     2  0.6202     0.4310 0.000 0.556 0.004 0.040 0.244 0.156
#> GSM329697     2  0.2804     0.6661 0.000 0.852 0.000 0.024 0.120 0.004
#> GSM329700     2  0.3725     0.5767 0.000 0.792 0.000 0.140 0.060 0.008
#> GSM329703     4  0.6035     0.6135 0.000 0.396 0.152 0.436 0.016 0.000
#> GSM329704     5  0.4314     0.6450 0.000 0.096 0.184 0.000 0.720 0.000
#> GSM329707     5  0.4273     0.5597 0.000 0.028 0.248 0.004 0.708 0.012
#> GSM329709     2  0.3207     0.6533 0.000 0.828 0.000 0.044 0.124 0.004
#> GSM329711     2  0.2778     0.4929 0.000 0.824 0.000 0.168 0.008 0.000
#> GSM329714     2  0.4593     0.4912 0.000 0.708 0.012 0.220 0.052 0.008
#> GSM329693     2  0.6048    -0.7094 0.000 0.416 0.212 0.368 0.004 0.000
#> GSM329696     4  0.6680     0.7752 0.000 0.244 0.288 0.436 0.016 0.016
#> GSM329699     4  0.6001     0.7503 0.000 0.208 0.340 0.448 0.004 0.000
#> GSM329702     2  0.3151     0.5990 0.000 0.748 0.000 0.000 0.252 0.000
#> GSM329706     5  0.4744     0.0480 0.000 0.004 0.440 0.024 0.524 0.008
#> GSM329708     6  0.2805     0.7702 0.000 0.000 0.160 0.012 0.000 0.828
#> GSM329710     6  0.6992     0.3614 0.000 0.080 0.192 0.220 0.012 0.496
#> GSM329713     1  0.4324     0.8219 0.736 0.000 0.000 0.188 0.060 0.016
#> GSM329695     1  0.4317     0.8252 0.740 0.000 0.000 0.180 0.064 0.016
#> GSM329698     1  0.3224     0.8798 0.828 0.000 0.000 0.128 0.036 0.008
#> GSM329701     1  0.2859     0.8921 0.856 0.000 0.000 0.108 0.028 0.008
#> GSM329705     1  0.2101     0.9084 0.912 0.000 0.000 0.052 0.028 0.008
#> GSM329712     2  0.2871     0.4509 0.000 0.804 0.000 0.192 0.004 0.000
#> GSM329715     1  0.2285     0.9060 0.900 0.000 0.000 0.064 0.028 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) tissue(p) k
#> SD:NMF 56          0.50568  5.82e-11 2
#> SD:NMF 56          0.00121  7.06e-11 3
#> SD:NMF 43          0.00238  1.86e-08 4
#> SD:NMF 40          0.29301  1.53e-07 5
#> SD:NMF 42          0.00355  1.73e-07 6

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


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

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.795           0.950       0.973         0.3809 0.618   0.618
#> 3 3 0.869           0.953       0.975         0.7192 0.724   0.554
#> 4 4 0.864           0.805       0.889         0.1368 0.918   0.761
#> 5 5 0.860           0.684       0.857         0.0513 0.957   0.841
#> 6 6 0.848           0.847       0.894         0.0418 0.937   0.737

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM329660     1  0.0376      0.978 0.996 0.004
#> GSM329663     1  0.0376      0.978 0.996 0.004
#> GSM329664     1  0.5519      0.870 0.872 0.128
#> GSM329666     1  0.0376      0.978 0.996 0.004
#> GSM329667     1  0.5178      0.880 0.884 0.116
#> GSM329670     1  0.0376      0.978 0.996 0.004
#> GSM329672     1  0.5178      0.880 0.884 0.116
#> GSM329674     1  0.0376      0.978 0.996 0.004
#> GSM329661     2  0.0000      0.949 0.000 1.000
#> GSM329669     1  0.0376      0.978 0.996 0.004
#> GSM329662     1  0.0000      0.978 1.000 0.000
#> GSM329665     1  0.0000      0.978 1.000 0.000
#> GSM329668     1  0.0000      0.978 1.000 0.000
#> GSM329671     1  0.0000      0.978 1.000 0.000
#> GSM329673     1  0.0000      0.978 1.000 0.000
#> GSM329675     1  0.0000      0.978 1.000 0.000
#> GSM329676     1  0.0000      0.978 1.000 0.000
#> GSM329677     2  0.7376      0.765 0.208 0.792
#> GSM329679     1  0.5178      0.880 0.884 0.116
#> GSM329681     2  0.0000      0.949 0.000 1.000
#> GSM329683     2  0.0000      0.949 0.000 1.000
#> GSM329686     2  0.0000      0.949 0.000 1.000
#> GSM329689     2  0.0000      0.949 0.000 1.000
#> GSM329678     2  0.3431      0.909 0.064 0.936
#> GSM329680     2  0.0000      0.949 0.000 1.000
#> GSM329685     2  0.0000      0.949 0.000 1.000
#> GSM329688     2  0.0000      0.949 0.000 1.000
#> GSM329691     2  0.0000      0.949 0.000 1.000
#> GSM329682     1  0.0000      0.978 1.000 0.000
#> GSM329684     1  0.0000      0.978 1.000 0.000
#> GSM329687     1  0.0000      0.978 1.000 0.000
#> GSM329690     1  0.0000      0.978 1.000 0.000
#> GSM329692     1  0.1184      0.972 0.984 0.016
#> GSM329694     1  0.5519      0.870 0.872 0.128
#> GSM329697     1  0.0376      0.978 0.996 0.004
#> GSM329700     1  0.0376      0.978 0.996 0.004
#> GSM329703     1  0.1184      0.972 0.984 0.016
#> GSM329704     1  0.5178      0.880 0.884 0.116
#> GSM329707     2  0.7376      0.765 0.208 0.792
#> GSM329709     1  0.0376      0.978 0.996 0.004
#> GSM329711     1  0.0376      0.978 0.996 0.004
#> GSM329714     1  0.0376      0.978 0.996 0.004
#> GSM329693     1  0.1184      0.972 0.984 0.016
#> GSM329696     1  0.1184      0.972 0.984 0.016
#> GSM329699     1  0.1184      0.972 0.984 0.016
#> GSM329702     1  0.0376      0.978 0.996 0.004
#> GSM329706     2  0.5946      0.842 0.144 0.856
#> GSM329708     2  0.0000      0.949 0.000 1.000
#> GSM329710     1  0.1184      0.972 0.984 0.016
#> GSM329713     1  0.0000      0.978 1.000 0.000
#> GSM329695     1  0.0000      0.978 1.000 0.000
#> GSM329698     1  0.0000      0.978 1.000 0.000
#> GSM329701     1  0.0000      0.978 1.000 0.000
#> GSM329705     1  0.0000      0.978 1.000 0.000
#> GSM329712     1  0.0376      0.978 0.996 0.004
#> GSM329715     1  0.0000      0.978 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
#> GSM329660     2  0.0000      0.965  0 1.000 0.000
#> GSM329663     2  0.0000      0.965  0 1.000 0.000
#> GSM329664     2  0.3412      0.884  0 0.876 0.124
#> GSM329666     2  0.0000      0.965  0 1.000 0.000
#> GSM329667     2  0.3192      0.892  0 0.888 0.112
#> GSM329670     2  0.0000      0.965  0 1.000 0.000
#> GSM329672     2  0.3192      0.892  0 0.888 0.112
#> GSM329674     2  0.0000      0.965  0 1.000 0.000
#> GSM329661     3  0.0000      0.945  0 0.000 1.000
#> GSM329669     2  0.0000      0.965  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.4702      0.755  0 0.212 0.788
#> GSM329679     2  0.3192      0.892  0 0.888 0.112
#> GSM329681     3  0.0000      0.945  0 0.000 1.000
#> GSM329683     3  0.0000      0.945  0 0.000 1.000
#> GSM329686     3  0.0000      0.945  0 0.000 1.000
#> GSM329689     3  0.0000      0.945  0 0.000 1.000
#> GSM329678     3  0.2165      0.905  0 0.064 0.936
#> GSM329680     3  0.0000      0.945  0 0.000 1.000
#> GSM329685     3  0.0000      0.945  0 0.000 1.000
#> GSM329688     3  0.0000      0.945  0 0.000 1.000
#> GSM329691     3  0.0000      0.945  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     2  0.0592      0.962  0 0.988 0.012
#> GSM329694     2  0.3412      0.884  0 0.876 0.124
#> GSM329697     2  0.0000      0.965  0 1.000 0.000
#> GSM329700     2  0.0000      0.965  0 1.000 0.000
#> GSM329703     2  0.0592      0.962  0 0.988 0.012
#> GSM329704     2  0.3192      0.892  0 0.888 0.112
#> GSM329707     3  0.4702      0.755  0 0.212 0.788
#> GSM329709     2  0.0000      0.965  0 1.000 0.000
#> GSM329711     2  0.0000      0.965  0 1.000 0.000
#> GSM329714     2  0.0000      0.965  0 1.000 0.000
#> GSM329693     2  0.0592      0.962  0 0.988 0.012
#> GSM329696     2  0.0592      0.962  0 0.988 0.012
#> GSM329699     2  0.0592      0.962  0 0.988 0.012
#> GSM329702     2  0.0000      0.965  0 1.000 0.000
#> GSM329706     3  0.3816      0.833  0 0.148 0.852
#> GSM329708     3  0.0000      0.945  0 0.000 1.000
#> GSM329710     2  0.0592      0.962  0 0.988 0.012
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.965  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0188      0.770  0 0.996 0.000 0.004
#> GSM329663     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329664     2  0.4605      0.549  0 0.664 0.000 0.336
#> GSM329666     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329667     2  0.4103      0.629  0 0.744 0.000 0.256
#> GSM329670     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329672     2  0.4040      0.636  0 0.752 0.000 0.248
#> GSM329674     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.921  0 0.000 1.000 0.000
#> GSM329669     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.4605      0.682  0 0.000 0.664 0.336
#> GSM329679     2  0.4040      0.636  0 0.752 0.000 0.248
#> GSM329681     3  0.0000      0.921  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.921  0 0.000 1.000 0.000
#> GSM329686     3  0.0469      0.922  0 0.000 0.988 0.012
#> GSM329689     3  0.0000      0.921  0 0.000 1.000 0.000
#> GSM329678     3  0.2053      0.876  0 0.004 0.924 0.072
#> GSM329680     3  0.0469      0.922  0 0.000 0.988 0.012
#> GSM329685     3  0.0469      0.922  0 0.000 0.988 0.012
#> GSM329688     3  0.0469      0.922  0 0.000 0.988 0.012
#> GSM329691     3  0.0469      0.922  0 0.000 0.988 0.012
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.4134      0.859  0 0.260 0.000 0.740
#> GSM329694     4  0.4996     -0.353  0 0.484 0.000 0.516
#> GSM329697     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329700     2  0.4776     -0.038  0 0.624 0.000 0.376
#> GSM329703     4  0.4134      0.859  0 0.260 0.000 0.740
#> GSM329704     2  0.4134      0.626  0 0.740 0.000 0.260
#> GSM329707     3  0.4605      0.682  0 0.000 0.664 0.336
#> GSM329709     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329711     2  0.3266      0.581  0 0.832 0.000 0.168
#> GSM329714     2  0.4776     -0.038  0 0.624 0.000 0.376
#> GSM329693     4  0.4134      0.859  0 0.260 0.000 0.740
#> GSM329696     4  0.4134      0.859  0 0.260 0.000 0.740
#> GSM329699     4  0.4134      0.859  0 0.260 0.000 0.740
#> GSM329702     2  0.0000      0.773  0 1.000 0.000 0.000
#> GSM329706     3  0.4222      0.740  0 0.000 0.728 0.272
#> GSM329708     3  0.0000      0.921  0 0.000 1.000 0.000
#> GSM329710     4  0.4134      0.859  0 0.260 0.000 0.740
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.3266      0.581  0 0.832 0.000 0.168
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     2  0.0324      0.720  0 0.992 0.000 0.004 0.004
#> GSM329663     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329664     5  0.4656      0.319  0 0.480 0.012 0.000 0.508
#> GSM329666     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329667     2  0.4262     -0.437  0 0.560 0.000 0.000 0.440
#> GSM329670     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.4235     -0.392  0 0.576 0.000 0.000 0.424
#> GSM329674     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329661     3  0.4306      0.610  0 0.000 0.508 0.000 0.492
#> GSM329669     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     3  0.3913      0.456  0 0.000 0.676 0.000 0.324
#> GSM329679     2  0.4235     -0.392  0 0.576 0.000 0.000 0.424
#> GSM329681     3  0.4304      0.614  0 0.000 0.516 0.000 0.484
#> GSM329683     3  0.4304      0.614  0 0.000 0.516 0.000 0.484
#> GSM329686     3  0.0000      0.727  0 0.000 1.000 0.000 0.000
#> GSM329689     3  0.4304      0.614  0 0.000 0.516 0.000 0.484
#> GSM329678     3  0.1478      0.704  0 0.000 0.936 0.064 0.000
#> GSM329680     3  0.0000      0.727  0 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.727  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.727  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.727  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.848  0 0.000 0.000 1.000 0.000
#> GSM329694     5  0.6733      0.505  0 0.296 0.000 0.288 0.416
#> GSM329697     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329700     4  0.4074      0.336  0 0.364 0.000 0.636 0.000
#> GSM329703     4  0.0000      0.848  0 0.000 0.000 1.000 0.000
#> GSM329704     2  0.4268     -0.449  0 0.556 0.000 0.000 0.444
#> GSM329707     3  0.3913      0.456  0 0.000 0.676 0.000 0.324
#> GSM329709     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329711     2  0.2813      0.518  0 0.832 0.000 0.168 0.000
#> GSM329714     4  0.4074      0.336  0 0.364 0.000 0.636 0.000
#> GSM329693     4  0.0000      0.848  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.848  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.848  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0000      0.725  0 1.000 0.000 0.000 0.000
#> GSM329706     3  0.3561      0.515  0 0.000 0.740 0.000 0.260
#> GSM329708     3  0.4306      0.610  0 0.000 0.508 0.000 0.492
#> GSM329710     4  0.0000      0.848  0 0.000 0.000 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     2  0.2813      0.518  0 0.832 0.000 0.168 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     2  0.0603      0.945 0.000 0.980 0.000 0.004 0.016 0.000
#> GSM329663     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329664     5  0.0000      0.784 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329666     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.1556      0.845 0.000 0.080 0.000 0.000 0.920 0.000
#> GSM329670     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329672     5  0.2912      0.805 0.000 0.216 0.000 0.000 0.784 0.000
#> GSM329674     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.2762      0.817 0.000 0.000 0.804 0.000 0.000 0.196
#> GSM329669     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329662     1  0.2491      0.907 0.836 0.000 0.164 0.000 0.000 0.000
#> GSM329665     1  0.2491      0.907 0.836 0.000 0.164 0.000 0.000 0.000
#> GSM329668     1  0.2491      0.907 0.836 0.000 0.164 0.000 0.000 0.000
#> GSM329671     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM329673     1  0.2491      0.907 0.836 0.000 0.164 0.000 0.000 0.000
#> GSM329675     1  0.2697      0.896 0.812 0.000 0.188 0.000 0.000 0.000
#> GSM329676     1  0.2491      0.907 0.836 0.000 0.164 0.000 0.000 0.000
#> GSM329677     6  0.3563      0.620 0.000 0.000 0.000 0.000 0.336 0.664
#> GSM329679     5  0.2912      0.805 0.000 0.216 0.000 0.000 0.784 0.000
#> GSM329681     3  0.3717      0.860 0.000 0.000 0.616 0.000 0.000 0.384
#> GSM329683     3  0.3717      0.860 0.000 0.000 0.616 0.000 0.000 0.384
#> GSM329686     6  0.0000      0.797 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329689     3  0.3717      0.860 0.000 0.000 0.616 0.000 0.000 0.384
#> GSM329678     6  0.1327      0.734 0.000 0.000 0.000 0.064 0.000 0.936
#> GSM329680     6  0.0000      0.797 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329685     6  0.0000      0.797 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329688     6  0.0000      0.797 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329691     6  0.0000      0.797 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329682     1  0.2491      0.907 0.836 0.000 0.164 0.000 0.000 0.000
#> GSM329684     1  0.2697      0.896 0.812 0.000 0.188 0.000 0.000 0.000
#> GSM329687     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.863 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329694     5  0.3595      0.615 0.000 0.008 0.000 0.288 0.704 0.000
#> GSM329697     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     4  0.3659      0.495 0.000 0.364 0.000 0.636 0.000 0.000
#> GSM329703     4  0.0000      0.863 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.1610      0.846 0.000 0.084 0.000 0.000 0.916 0.000
#> GSM329707     6  0.3563      0.620 0.000 0.000 0.000 0.000 0.336 0.664
#> GSM329709     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     2  0.2527      0.805 0.000 0.832 0.000 0.168 0.000 0.000
#> GSM329714     4  0.3659      0.495 0.000 0.364 0.000 0.636 0.000 0.000
#> GSM329693     4  0.0000      0.863 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000      0.863 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.863 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000      0.958 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     6  0.3198      0.665 0.000 0.000 0.000 0.000 0.260 0.740
#> GSM329708     3  0.2762      0.817 0.000 0.000 0.804 0.000 0.000 0.196
#> GSM329710     4  0.0000      0.863 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM329695     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM329698     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM329701     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM329705     1  0.0000      0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.2527      0.805 0.000 0.832 0.000 0.168 0.000 0.000
#> GSM329715     1  0.0260      0.918 0.992 0.000 0.008 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-hclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) tissue(p) k
#> CV:hclust 56         6.76e-05  2.37e-03 2
#> CV:hclust 56         1.85e-04  1.01e-10 3
#> CV:hclust 53         7.35e-05  3.44e-10 4
#> CV:hclust 47         2.81e-04  6.63e-08 5
#> CV:hclust 54         9.44e-04  3.56e-09 6

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


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

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.584           0.946       0.960         0.4397 0.569   0.569
#> 3 3 0.726           0.976       0.935         0.4599 0.761   0.580
#> 4 4 0.765           0.702       0.846         0.1276 0.966   0.898
#> 5 5 0.732           0.743       0.800         0.0680 0.932   0.783
#> 6 6 0.703           0.626       0.753         0.0519 0.902   0.629

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM329660     2  0.5842      0.902 0.140 0.860
#> GSM329663     2  0.5842      0.902 0.140 0.860
#> GSM329664     2  0.0000      0.937 0.000 1.000
#> GSM329666     2  0.5842      0.902 0.140 0.860
#> GSM329667     2  0.5737      0.903 0.136 0.864
#> GSM329670     2  0.5842      0.902 0.140 0.860
#> GSM329672     2  0.5842      0.902 0.140 0.860
#> GSM329674     2  0.5842      0.902 0.140 0.860
#> GSM329661     2  0.0000      0.937 0.000 1.000
#> GSM329669     2  0.5842      0.902 0.140 0.860
#> GSM329662     1  0.0000      1.000 1.000 0.000
#> GSM329665     1  0.0000      1.000 1.000 0.000
#> GSM329668     1  0.0000      1.000 1.000 0.000
#> GSM329671     1  0.0000      1.000 1.000 0.000
#> GSM329673     1  0.0000      1.000 1.000 0.000
#> GSM329675     1  0.0000      1.000 1.000 0.000
#> GSM329676     1  0.0000      1.000 1.000 0.000
#> GSM329677     2  0.0000      0.937 0.000 1.000
#> GSM329679     2  0.5842      0.902 0.140 0.860
#> GSM329681     2  0.0000      0.937 0.000 1.000
#> GSM329683     2  0.0000      0.937 0.000 1.000
#> GSM329686     2  0.0000      0.937 0.000 1.000
#> GSM329689     2  0.0000      0.937 0.000 1.000
#> GSM329678     2  0.0000      0.937 0.000 1.000
#> GSM329680     2  0.0000      0.937 0.000 1.000
#> GSM329685     2  0.0000      0.937 0.000 1.000
#> GSM329688     2  0.0000      0.937 0.000 1.000
#> GSM329691     2  0.0000      0.937 0.000 1.000
#> GSM329682     1  0.0000      1.000 1.000 0.000
#> GSM329684     1  0.0000      1.000 1.000 0.000
#> GSM329687     1  0.0000      1.000 1.000 0.000
#> GSM329690     1  0.0000      1.000 1.000 0.000
#> GSM329692     2  0.0000      0.937 0.000 1.000
#> GSM329694     2  0.0000      0.937 0.000 1.000
#> GSM329697     2  0.5842      0.902 0.140 0.860
#> GSM329700     2  0.5842      0.902 0.140 0.860
#> GSM329703     2  0.0376      0.936 0.004 0.996
#> GSM329704     2  0.0000      0.937 0.000 1.000
#> GSM329707     2  0.0000      0.937 0.000 1.000
#> GSM329709     2  0.5842      0.902 0.140 0.860
#> GSM329711     2  0.5842      0.902 0.140 0.860
#> GSM329714     2  0.5842      0.902 0.140 0.860
#> GSM329693     2  0.0376      0.936 0.004 0.996
#> GSM329696     2  0.0376      0.936 0.004 0.996
#> GSM329699     2  0.0000      0.937 0.000 1.000
#> GSM329702     2  0.5842      0.902 0.140 0.860
#> GSM329706     2  0.0000      0.937 0.000 1.000
#> GSM329708     2  0.0000      0.937 0.000 1.000
#> GSM329710     2  0.0000      0.937 0.000 1.000
#> GSM329713     1  0.0000      1.000 1.000 0.000
#> GSM329695     1  0.0000      1.000 1.000 0.000
#> GSM329698     1  0.0000      1.000 1.000 0.000
#> GSM329701     1  0.0000      1.000 1.000 0.000
#> GSM329705     1  0.0000      1.000 1.000 0.000
#> GSM329712     2  0.5842      0.902 0.140 0.860
#> GSM329715     1  0.0000      1.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM329660     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329663     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329664     2  0.4974      0.890 0.000 0.764 0.236
#> GSM329666     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329667     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329670     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329672     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329674     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329661     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329669     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329662     1  0.2261      0.949 0.932 0.068 0.000
#> GSM329665     1  0.0237      0.952 0.996 0.004 0.000
#> GSM329668     1  0.1411      0.952 0.964 0.036 0.000
#> GSM329671     1  0.2537      0.944 0.920 0.080 0.000
#> GSM329673     1  0.2261      0.949 0.932 0.068 0.000
#> GSM329675     1  0.2261      0.949 0.932 0.068 0.000
#> GSM329676     1  0.2261      0.949 0.932 0.068 0.000
#> GSM329677     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329679     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329681     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329683     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329686     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329689     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329678     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329680     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329685     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329688     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329691     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329682     1  0.2165      0.949 0.936 0.064 0.000
#> GSM329684     1  0.2261      0.949 0.932 0.068 0.000
#> GSM329687     1  0.2261      0.949 0.932 0.068 0.000
#> GSM329690     1  0.2537      0.944 0.920 0.080 0.000
#> GSM329692     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329694     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329697     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329700     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329703     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329704     2  0.4974      0.890 0.000 0.764 0.236
#> GSM329707     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329709     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329711     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329714     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329693     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329696     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329699     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329702     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329706     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329708     3  0.0000      0.999 0.000 0.000 1.000
#> GSM329710     3  0.0424      0.990 0.000 0.008 0.992
#> GSM329713     1  0.2537      0.944 0.920 0.080 0.000
#> GSM329695     1  0.2537      0.944 0.920 0.080 0.000
#> GSM329698     1  0.2537      0.944 0.920 0.080 0.000
#> GSM329701     1  0.2537      0.944 0.920 0.080 0.000
#> GSM329705     1  0.0000      0.952 1.000 0.000 0.000
#> GSM329712     2  0.3816      0.991 0.000 0.852 0.148
#> GSM329715     1  0.2537      0.944 0.920 0.080 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM329660     2  0.0188     0.7918 0.000 0.996 0.000 0.004
#> GSM329663     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329664     2  0.4282     0.6342 0.000 0.816 0.060 0.124
#> GSM329666     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329667     2  0.2704     0.7011 0.000 0.876 0.000 0.124
#> GSM329670     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329672     2  0.0188     0.7918 0.000 0.996 0.000 0.004
#> GSM329674     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329661     3  0.4046     0.8141 0.000 0.048 0.828 0.124
#> GSM329669     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329662     1  0.2714     0.8917 0.884 0.000 0.004 0.112
#> GSM329665     1  0.1256     0.9024 0.964 0.000 0.028 0.008
#> GSM329668     1  0.2399     0.9018 0.920 0.000 0.032 0.048
#> GSM329671     1  0.3523     0.8873 0.856 0.000 0.032 0.112
#> GSM329673     1  0.2714     0.8917 0.884 0.000 0.004 0.112
#> GSM329675     1  0.2859     0.8910 0.880 0.000 0.008 0.112
#> GSM329676     1  0.2714     0.8917 0.884 0.000 0.004 0.112
#> GSM329677     3  0.3991     0.7798 0.000 0.048 0.832 0.120
#> GSM329679     2  0.0188     0.7918 0.000 0.996 0.000 0.004
#> GSM329681     3  0.3156     0.8506 0.000 0.048 0.884 0.068
#> GSM329683     3  0.3156     0.8506 0.000 0.048 0.884 0.068
#> GSM329686     3  0.1389     0.8599 0.000 0.048 0.952 0.000
#> GSM329689     3  0.3081     0.8517 0.000 0.048 0.888 0.064
#> GSM329678     3  0.6145    -0.3807 0.000 0.048 0.492 0.460
#> GSM329680     3  0.1389     0.8599 0.000 0.048 0.952 0.000
#> GSM329685     3  0.1389     0.8599 0.000 0.048 0.952 0.000
#> GSM329688     3  0.1389     0.8599 0.000 0.048 0.952 0.000
#> GSM329691     3  0.1389     0.8599 0.000 0.048 0.952 0.000
#> GSM329682     1  0.2469     0.8953 0.892 0.000 0.000 0.108
#> GSM329684     1  0.2859     0.8910 0.880 0.000 0.008 0.112
#> GSM329687     1  0.2469     0.8927 0.892 0.000 0.000 0.108
#> GSM329690     1  0.3377     0.8841 0.848 0.000 0.012 0.140
#> GSM329692     4  0.5773     0.4703 0.000 0.048 0.320 0.632
#> GSM329694     4  0.4972    -0.2212 0.000 0.456 0.000 0.544
#> GSM329697     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329700     2  0.4277     0.5205 0.000 0.720 0.000 0.280
#> GSM329703     2  0.4998    -0.0156 0.000 0.512 0.000 0.488
#> GSM329704     2  0.4282     0.6342 0.000 0.816 0.060 0.124
#> GSM329707     3  0.4761     0.7827 0.000 0.048 0.768 0.184
#> GSM329709     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329711     2  0.2216     0.7429 0.000 0.908 0.000 0.092
#> GSM329714     2  0.4406     0.4914 0.000 0.700 0.000 0.300
#> GSM329693     2  0.4998    -0.0156 0.000 0.512 0.000 0.488
#> GSM329696     2  0.4998    -0.0156 0.000 0.512 0.000 0.488
#> GSM329699     2  0.5000    -0.0356 0.000 0.504 0.000 0.496
#> GSM329702     2  0.0000     0.7928 0.000 1.000 0.000 0.000
#> GSM329706     3  0.4994     0.6917 0.000 0.048 0.744 0.208
#> GSM329708     3  0.4046     0.8141 0.000 0.048 0.828 0.124
#> GSM329710     4  0.5773     0.4703 0.000 0.048 0.320 0.632
#> GSM329713     1  0.3300     0.8834 0.848 0.000 0.008 0.144
#> GSM329695     1  0.3300     0.8834 0.848 0.000 0.008 0.144
#> GSM329698     1  0.3208     0.8835 0.848 0.000 0.004 0.148
#> GSM329701     1  0.3278     0.8877 0.864 0.000 0.020 0.116
#> GSM329705     1  0.1297     0.9018 0.964 0.000 0.020 0.016
#> GSM329712     2  0.2216     0.7429 0.000 0.908 0.000 0.092
#> GSM329715     1  0.3278     0.8877 0.864 0.000 0.020 0.116

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4 p5
#> GSM329660     2  0.1952      0.814 0.000 0.912 0.000 0.004 NA
#> GSM329663     2  0.2074      0.806 0.000 0.896 0.000 0.000 NA
#> GSM329664     2  0.6164      0.497 0.000 0.584 0.052 0.056 NA
#> GSM329666     2  0.0000      0.821 0.000 1.000 0.000 0.000 NA
#> GSM329667     2  0.4693      0.632 0.000 0.700 0.000 0.056 NA
#> GSM329670     2  0.1608      0.809 0.000 0.928 0.000 0.000 NA
#> GSM329672     2  0.1341      0.814 0.000 0.944 0.000 0.000 NA
#> GSM329674     2  0.0000      0.821 0.000 1.000 0.000 0.000 NA
#> GSM329661     3  0.4555      0.800 0.000 0.016 0.776 0.096 NA
#> GSM329669     2  0.0865      0.816 0.000 0.972 0.000 0.004 NA
#> GSM329662     1  0.0510      0.787 0.984 0.000 0.000 0.016 NA
#> GSM329665     1  0.4096      0.808 0.784 0.000 0.000 0.072 NA
#> GSM329668     1  0.4183      0.807 0.780 0.000 0.000 0.084 NA
#> GSM329671     1  0.5627      0.772 0.548 0.000 0.000 0.084 NA
#> GSM329673     1  0.0404      0.788 0.988 0.000 0.000 0.012 NA
#> GSM329675     1  0.0865      0.785 0.972 0.000 0.004 0.024 NA
#> GSM329676     1  0.0162      0.789 0.996 0.000 0.000 0.004 NA
#> GSM329677     3  0.5141      0.693 0.000 0.016 0.688 0.056 NA
#> GSM329679     2  0.1341      0.814 0.000 0.944 0.000 0.000 NA
#> GSM329681     3  0.3538      0.843 0.000 0.016 0.848 0.056 NA
#> GSM329683     3  0.3174      0.848 0.000 0.016 0.868 0.036 NA
#> GSM329686     3  0.0510      0.861 0.000 0.016 0.984 0.000 NA
#> GSM329689     3  0.2861      0.852 0.000 0.016 0.884 0.024 NA
#> GSM329678     4  0.4618      0.450 0.000 0.016 0.344 0.636 NA
#> GSM329680     3  0.0671      0.860 0.000 0.016 0.980 0.004 NA
#> GSM329685     3  0.0510      0.861 0.000 0.016 0.984 0.000 NA
#> GSM329688     3  0.0510      0.861 0.000 0.016 0.984 0.000 NA
#> GSM329691     3  0.0510      0.861 0.000 0.016 0.984 0.000 NA
#> GSM329682     1  0.1444      0.796 0.948 0.000 0.000 0.012 NA
#> GSM329684     1  0.0865      0.785 0.972 0.000 0.004 0.024 NA
#> GSM329687     1  0.0693      0.791 0.980 0.000 0.000 0.008 NA
#> GSM329690     1  0.5036      0.760 0.516 0.000 0.000 0.032 NA
#> GSM329692     4  0.4370      0.597 0.000 0.016 0.176 0.768 NA
#> GSM329694     4  0.4769      0.716 0.000 0.256 0.000 0.688 NA
#> GSM329697     2  0.0000      0.821 0.000 1.000 0.000 0.000 NA
#> GSM329700     2  0.5331      0.446 0.000 0.640 0.000 0.268 NA
#> GSM329703     4  0.3730      0.745 0.000 0.288 0.000 0.712 NA
#> GSM329704     2  0.6221      0.492 0.000 0.580 0.052 0.060 NA
#> GSM329707     3  0.5663      0.685 0.000 0.016 0.612 0.068 NA
#> GSM329709     2  0.0000      0.821 0.000 1.000 0.000 0.000 NA
#> GSM329711     2  0.3152      0.718 0.000 0.840 0.000 0.136 NA
#> GSM329714     2  0.5794      0.088 0.000 0.520 0.000 0.384 NA
#> GSM329693     4  0.3730      0.745 0.000 0.288 0.000 0.712 NA
#> GSM329696     4  0.3730      0.745 0.000 0.288 0.000 0.712 NA
#> GSM329699     4  0.3730      0.745 0.000 0.288 0.000 0.712 NA
#> GSM329702     2  0.0000      0.821 0.000 1.000 0.000 0.000 NA
#> GSM329706     3  0.6435      0.563 0.000 0.016 0.568 0.176 NA
#> GSM329708     3  0.4555      0.800 0.000 0.016 0.776 0.096 NA
#> GSM329710     4  0.3964      0.606 0.000 0.016 0.176 0.788 NA
#> GSM329713     1  0.5170      0.756 0.512 0.000 0.012 0.020 NA
#> GSM329695     1  0.5170      0.756 0.512 0.000 0.012 0.020 NA
#> GSM329698     1  0.4821      0.759 0.516 0.000 0.000 0.020 NA
#> GSM329701     1  0.5281      0.773 0.548 0.000 0.000 0.052 NA
#> GSM329705     1  0.4303      0.808 0.752 0.000 0.000 0.056 NA
#> GSM329712     2  0.3152      0.718 0.000 0.840 0.000 0.136 NA
#> GSM329715     1  0.5330      0.774 0.548 0.000 0.000 0.056 NA

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM329660     2  0.4819     0.7315 0.000 0.708 0.000 0.020 0.152 0.120
#> GSM329663     2  0.4484     0.7328 0.000 0.728 0.000 0.012 0.168 0.092
#> GSM329664     5  0.4721     0.3522 0.000 0.364 0.024 0.020 0.592 0.000
#> GSM329666     2  0.0260     0.7783 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM329667     2  0.4644    -0.0793 0.000 0.512 0.000 0.020 0.456 0.012
#> GSM329670     2  0.3514     0.7558 0.000 0.804 0.000 0.000 0.108 0.088
#> GSM329672     2  0.2070     0.7478 0.000 0.896 0.000 0.012 0.092 0.000
#> GSM329674     2  0.0260     0.7783 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM329661     3  0.5261     0.6989 0.000 0.000 0.688 0.064 0.092 0.156
#> GSM329669     2  0.3150     0.7616 0.000 0.832 0.000 0.000 0.064 0.104
#> GSM329662     6  0.3737     0.9241 0.392 0.000 0.000 0.000 0.000 0.608
#> GSM329665     1  0.4074    -0.1450 0.656 0.000 0.000 0.004 0.016 0.324
#> GSM329668     1  0.4918    -0.2994 0.604 0.000 0.000 0.028 0.032 0.336
#> GSM329671     1  0.1401     0.6796 0.948 0.000 0.000 0.020 0.028 0.004
#> GSM329673     6  0.3747     0.9238 0.396 0.000 0.000 0.000 0.000 0.604
#> GSM329675     6  0.4290     0.8947 0.364 0.000 0.000 0.020 0.004 0.612
#> GSM329676     6  0.4010     0.9173 0.408 0.000 0.000 0.008 0.000 0.584
#> GSM329677     3  0.4326    -0.3153 0.000 0.000 0.496 0.008 0.488 0.008
#> GSM329679     2  0.2019     0.7494 0.000 0.900 0.000 0.012 0.088 0.000
#> GSM329681     3  0.4102     0.7679 0.000 0.000 0.788 0.036 0.092 0.084
#> GSM329683     3  0.3699     0.7768 0.000 0.000 0.812 0.020 0.092 0.076
#> GSM329686     3  0.0000     0.8006 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.3596     0.7787 0.000 0.000 0.820 0.020 0.088 0.072
#> GSM329678     4  0.3571     0.6106 0.000 0.000 0.216 0.760 0.004 0.020
#> GSM329680     3  0.0748     0.7953 0.000 0.000 0.976 0.016 0.004 0.004
#> GSM329685     3  0.0000     0.8006 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000     0.8006 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000     0.8006 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     6  0.4484     0.8395 0.460 0.000 0.000 0.016 0.008 0.516
#> GSM329684     6  0.4290     0.8947 0.364 0.000 0.000 0.020 0.004 0.612
#> GSM329687     6  0.4268     0.9004 0.428 0.000 0.000 0.012 0.004 0.556
#> GSM329690     1  0.2972     0.6841 0.836 0.000 0.000 0.036 0.128 0.000
#> GSM329692     4  0.4019     0.6723 0.000 0.000 0.076 0.796 0.040 0.088
#> GSM329694     4  0.4576     0.7425 0.000 0.120 0.000 0.748 0.092 0.040
#> GSM329697     2  0.0260     0.7783 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM329700     2  0.6965     0.4396 0.000 0.484 0.000 0.224 0.152 0.140
#> GSM329703     4  0.2624     0.7924 0.000 0.148 0.000 0.844 0.004 0.004
#> GSM329704     5  0.4721     0.3522 0.000 0.364 0.024 0.020 0.592 0.000
#> GSM329707     5  0.4771     0.0825 0.000 0.000 0.388 0.016 0.568 0.028
#> GSM329709     2  0.0260     0.7783 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM329711     2  0.5299     0.6631 0.000 0.688 0.000 0.144 0.068 0.100
#> GSM329714     4  0.7204     0.0251 0.000 0.308 0.000 0.400 0.152 0.140
#> GSM329693     4  0.2624     0.7924 0.000 0.148 0.000 0.844 0.004 0.004
#> GSM329696     4  0.2340     0.7926 0.000 0.148 0.000 0.852 0.000 0.000
#> GSM329699     4  0.2584     0.7929 0.000 0.144 0.000 0.848 0.004 0.004
#> GSM329702     2  0.0260     0.7783 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM329706     5  0.5467     0.1921 0.000 0.000 0.408 0.096 0.488 0.008
#> GSM329708     3  0.5261     0.6989 0.000 0.000 0.688 0.064 0.092 0.156
#> GSM329710     4  0.3125     0.6858 0.000 0.000 0.076 0.852 0.016 0.056
#> GSM329713     1  0.2911     0.6812 0.832 0.000 0.000 0.024 0.144 0.000
#> GSM329695     1  0.2911     0.6812 0.832 0.000 0.000 0.024 0.144 0.000
#> GSM329698     1  0.2662     0.6866 0.856 0.000 0.000 0.024 0.120 0.000
#> GSM329701     1  0.0146     0.6861 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329705     1  0.3383     0.1044 0.728 0.000 0.000 0.004 0.000 0.268
#> GSM329712     2  0.5299     0.6631 0.000 0.688 0.000 0.144 0.068 0.100
#> GSM329715     1  0.0405     0.6833 0.988 0.000 0.000 0.000 0.004 0.008

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-kmeans-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) tissue(p) k
#> CV:kmeans 56         5.06e-01  5.82e-11 2
#> CV:kmeans 56         1.21e-03  7.06e-11 3
#> CV:kmeans 47         4.03e-03  1.20e-09 4
#> CV:kmeans 51         1.14e-04  4.53e-09 5
#> CV:kmeans 45         9.66e-05  3.82e-07 6

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


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 21163 rows and 56 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           1.000       1.000         0.4311 0.569   0.569
#> 3 3 1.000           0.974       0.988         0.5679 0.753   0.567
#> 4 4 0.937           0.897       0.961         0.1103 0.899   0.700
#> 5 5 0.928           0.871       0.930         0.0479 0.955   0.822
#> 6 6 0.854           0.789       0.869         0.0348 0.986   0.932

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.0000      0.999  0 1.000 0.000
#> GSM329663     2  0.0000      0.999  0 1.000 0.000
#> GSM329664     3  0.4702      0.758  0 0.212 0.788
#> GSM329666     2  0.0000      0.999  0 1.000 0.000
#> GSM329667     2  0.0000      0.999  0 1.000 0.000
#> GSM329670     2  0.0000      0.999  0 1.000 0.000
#> GSM329672     2  0.0000      0.999  0 1.000 0.000
#> GSM329674     2  0.0000      0.999  0 1.000 0.000
#> GSM329661     3  0.0000      0.961  0 0.000 1.000
#> GSM329669     2  0.0000      0.999  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.961  0 0.000 1.000
#> GSM329679     2  0.0000      0.999  0 1.000 0.000
#> GSM329681     3  0.0000      0.961  0 0.000 1.000
#> GSM329683     3  0.0000      0.961  0 0.000 1.000
#> GSM329686     3  0.0000      0.961  0 0.000 1.000
#> GSM329689     3  0.0000      0.961  0 0.000 1.000
#> GSM329678     3  0.0000      0.961  0 0.000 1.000
#> GSM329680     3  0.0000      0.961  0 0.000 1.000
#> GSM329685     3  0.0000      0.961  0 0.000 1.000
#> GSM329688     3  0.0000      0.961  0 0.000 1.000
#> GSM329691     3  0.0000      0.961  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     3  0.0000      0.961  0 0.000 1.000
#> GSM329694     3  0.5098      0.705  0 0.248 0.752
#> GSM329697     2  0.0000      0.999  0 1.000 0.000
#> GSM329700     2  0.0000      0.999  0 1.000 0.000
#> GSM329703     2  0.0237      0.996  0 0.996 0.004
#> GSM329704     3  0.4702      0.758  0 0.212 0.788
#> GSM329707     3  0.0000      0.961  0 0.000 1.000
#> GSM329709     2  0.0000      0.999  0 1.000 0.000
#> GSM329711     2  0.0000      0.999  0 1.000 0.000
#> GSM329714     2  0.0000      0.999  0 1.000 0.000
#> GSM329693     2  0.0000      0.999  0 1.000 0.000
#> GSM329696     2  0.0237      0.996  0 0.996 0.004
#> GSM329699     2  0.0237      0.996  0 0.996 0.004
#> GSM329702     2  0.0000      0.999  0 1.000 0.000
#> GSM329706     3  0.0000      0.961  0 0.000 1.000
#> GSM329708     3  0.0000      0.961  0 0.000 1.000
#> GSM329710     3  0.0000      0.961  0 0.000 1.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.999  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0188     0.9400  0 0.996 0.000 0.004
#> GSM329663     2  0.0188     0.9400  0 0.996 0.000 0.004
#> GSM329664     3  0.4697     0.4720  0 0.356 0.644 0.000
#> GSM329666     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329667     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329670     2  0.0188     0.9400  0 0.996 0.000 0.004
#> GSM329672     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329674     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329661     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329669     2  0.0188     0.9400  0 0.996 0.000 0.004
#> GSM329662     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329677     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329679     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329681     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329683     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329686     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329689     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329678     4  0.4981     0.0831  0 0.000 0.464 0.536
#> GSM329680     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329685     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329688     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329691     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329682     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329692     4  0.0469     0.8902  0 0.000 0.012 0.988
#> GSM329694     4  0.0524     0.8910  0 0.004 0.008 0.988
#> GSM329697     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329700     2  0.4981     0.1882  0 0.536 0.000 0.464
#> GSM329703     4  0.0000     0.8938  0 0.000 0.000 1.000
#> GSM329704     3  0.4564     0.5275  0 0.328 0.672 0.000
#> GSM329707     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329709     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329711     2  0.3074     0.8131  0 0.848 0.000 0.152
#> GSM329714     4  0.4072     0.5580  0 0.252 0.000 0.748
#> GSM329693     4  0.0000     0.8938  0 0.000 0.000 1.000
#> GSM329696     4  0.0000     0.8938  0 0.000 0.000 1.000
#> GSM329699     4  0.0000     0.8938  0 0.000 0.000 1.000
#> GSM329702     2  0.0000     0.9409  0 1.000 0.000 0.000
#> GSM329706     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329708     3  0.0000     0.9394  0 0.000 1.000 0.000
#> GSM329710     4  0.0188     0.8933  0 0.000 0.004 0.996
#> GSM329713     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329712     2  0.3074     0.8131  0 0.848 0.000 0.152
#> GSM329715     1  0.0000     1.0000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.0510      0.892 0.000 0.984 0.000 0.000 0.016
#> GSM329663     2  0.0404      0.896 0.000 0.988 0.000 0.000 0.012
#> GSM329664     5  0.1568      0.669 0.000 0.020 0.036 0.000 0.944
#> GSM329666     2  0.1544      0.899 0.000 0.932 0.000 0.000 0.068
#> GSM329667     5  0.3177      0.477 0.000 0.208 0.000 0.000 0.792
#> GSM329670     2  0.0290      0.895 0.000 0.992 0.000 0.000 0.008
#> GSM329672     2  0.2852      0.828 0.000 0.828 0.000 0.000 0.172
#> GSM329674     2  0.1544      0.899 0.000 0.932 0.000 0.000 0.068
#> GSM329661     3  0.0290      0.989 0.000 0.000 0.992 0.000 0.008
#> GSM329669     2  0.0510      0.892 0.000 0.984 0.000 0.000 0.016
#> GSM329662     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004
#> GSM329673     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329677     5  0.4227      0.543 0.000 0.000 0.420 0.000 0.580
#> GSM329679     2  0.2852      0.828 0.000 0.828 0.000 0.000 0.172
#> GSM329681     3  0.0290      0.989 0.000 0.000 0.992 0.000 0.008
#> GSM329683     3  0.0162      0.991 0.000 0.000 0.996 0.000 0.004
#> GSM329686     3  0.0162      0.992 0.000 0.000 0.996 0.000 0.004
#> GSM329689     3  0.0162      0.991 0.000 0.000 0.996 0.000 0.004
#> GSM329678     4  0.4341      0.415 0.000 0.000 0.364 0.628 0.008
#> GSM329680     3  0.0162      0.992 0.000 0.000 0.996 0.000 0.004
#> GSM329685     3  0.0162      0.992 0.000 0.000 0.996 0.000 0.004
#> GSM329688     3  0.0162      0.992 0.000 0.000 0.996 0.000 0.004
#> GSM329691     3  0.0162      0.992 0.000 0.000 0.996 0.000 0.004
#> GSM329682     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004
#> GSM329692     4  0.2124      0.817 0.000 0.000 0.056 0.916 0.028
#> GSM329694     4  0.2127      0.798 0.000 0.000 0.000 0.892 0.108
#> GSM329697     2  0.1544      0.899 0.000 0.932 0.000 0.000 0.068
#> GSM329700     2  0.4820      0.424 0.000 0.632 0.000 0.332 0.036
#> GSM329703     4  0.0000      0.852 0.000 0.000 0.000 1.000 0.000
#> GSM329704     5  0.1568      0.669 0.000 0.020 0.036 0.000 0.944
#> GSM329707     5  0.4161      0.577 0.000 0.000 0.392 0.000 0.608
#> GSM329709     2  0.1544      0.899 0.000 0.932 0.000 0.000 0.068
#> GSM329711     2  0.2172      0.852 0.000 0.908 0.000 0.076 0.016
#> GSM329714     4  0.4990      0.254 0.000 0.384 0.000 0.580 0.036
#> GSM329693     4  0.0000      0.852 0.000 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.852 0.000 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.852 0.000 0.000 0.000 1.000 0.000
#> GSM329702     2  0.1544      0.899 0.000 0.932 0.000 0.000 0.068
#> GSM329706     5  0.4201      0.564 0.000 0.000 0.408 0.000 0.592
#> GSM329708     3  0.0510      0.981 0.000 0.000 0.984 0.000 0.016
#> GSM329710     4  0.0671      0.848 0.000 0.000 0.004 0.980 0.016
#> GSM329713     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004
#> GSM329695     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004
#> GSM329698     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004
#> GSM329701     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004
#> GSM329705     1  0.0000      0.998 1.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.2172      0.852 0.000 0.908 0.000 0.076 0.016
#> GSM329715     1  0.0162      0.998 0.996 0.000 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM329660     2  0.3383      0.565 0.000 0.728 0.000 0.000 0.004 0.268
#> GSM329663     2  0.3330      0.488 0.000 0.716 0.000 0.000 0.000 0.284
#> GSM329664     5  0.0603      0.634 0.000 0.016 0.004 0.000 0.980 0.000
#> GSM329666     2  0.0000      0.762 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.3770      0.379 0.000 0.244 0.000 0.000 0.728 0.028
#> GSM329670     2  0.3390      0.478 0.000 0.704 0.000 0.000 0.000 0.296
#> GSM329672     2  0.1556      0.722 0.000 0.920 0.000 0.000 0.080 0.000
#> GSM329674     2  0.0000      0.762 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.1204      0.946 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM329669     2  0.3175      0.578 0.000 0.744 0.000 0.000 0.000 0.256
#> GSM329662     1  0.1779      0.923 0.920 0.000 0.000 0.000 0.016 0.064
#> GSM329665     1  0.0000      0.932 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0508      0.932 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM329671     1  0.1644      0.922 0.920 0.000 0.000 0.000 0.004 0.076
#> GSM329673     1  0.1779      0.923 0.920 0.000 0.000 0.000 0.016 0.064
#> GSM329675     1  0.1779      0.923 0.920 0.000 0.000 0.000 0.016 0.064
#> GSM329676     1  0.1779      0.923 0.920 0.000 0.000 0.000 0.016 0.064
#> GSM329677     5  0.3765      0.533 0.000 0.000 0.404 0.000 0.596 0.000
#> GSM329679     2  0.1610      0.720 0.000 0.916 0.000 0.000 0.084 0.000
#> GSM329681     3  0.1814      0.918 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM329683     3  0.1387      0.940 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM329686     3  0.0000      0.955 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.1387      0.940 0.000 0.000 0.932 0.000 0.000 0.068
#> GSM329678     4  0.4127      0.568 0.000 0.000 0.284 0.680 0.000 0.036
#> GSM329680     3  0.0146      0.953 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329685     3  0.0000      0.955 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.955 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.955 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.1500      0.927 0.936 0.000 0.000 0.000 0.012 0.052
#> GSM329684     1  0.1779      0.923 0.920 0.000 0.000 0.000 0.016 0.064
#> GSM329687     1  0.1657      0.925 0.928 0.000 0.000 0.000 0.016 0.056
#> GSM329690     1  0.1858      0.917 0.904 0.000 0.000 0.000 0.004 0.092
#> GSM329692     4  0.4252      0.678 0.000 0.000 0.036 0.652 0.000 0.312
#> GSM329694     4  0.4517      0.669 0.000 0.000 0.000 0.648 0.060 0.292
#> GSM329697     2  0.0000      0.762 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6  0.5195      0.910 0.000 0.176 0.000 0.208 0.000 0.616
#> GSM329703     4  0.0146      0.801 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM329704     5  0.0603      0.634 0.000 0.016 0.004 0.000 0.980 0.000
#> GSM329707     5  0.4537      0.630 0.000 0.000 0.264 0.000 0.664 0.072
#> GSM329709     2  0.0000      0.762 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     2  0.5206      0.251 0.000 0.588 0.000 0.128 0.000 0.284
#> GSM329714     6  0.5096      0.915 0.000 0.132 0.000 0.252 0.000 0.616
#> GSM329693     4  0.0146      0.801 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM329696     4  0.0000      0.803 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.803 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000      0.762 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.3782      0.595 0.000 0.000 0.360 0.000 0.636 0.004
#> GSM329708     3  0.1327      0.943 0.000 0.000 0.936 0.000 0.000 0.064
#> GSM329710     4  0.2513      0.775 0.000 0.000 0.008 0.852 0.000 0.140
#> GSM329713     1  0.1858      0.917 0.904 0.000 0.000 0.000 0.004 0.092
#> GSM329695     1  0.1858      0.917 0.904 0.000 0.000 0.000 0.004 0.092
#> GSM329698     1  0.1858      0.917 0.904 0.000 0.000 0.000 0.004 0.092
#> GSM329701     1  0.1753      0.919 0.912 0.000 0.000 0.000 0.004 0.084
#> GSM329705     1  0.0260      0.932 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM329712     2  0.5190      0.259 0.000 0.592 0.000 0.128 0.000 0.280
#> GSM329715     1  0.1471      0.924 0.932 0.000 0.000 0.000 0.004 0.064

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> CV:skmeans 56         0.505684  5.82e-11 2
#> CV:skmeans 56         0.010546  4.13e-10 3
#> CV:skmeans 53         0.000106  3.97e-09 4
#> CV:skmeans 52         0.000262  1.42e-08 5
#> CV:skmeans 51         0.002075  1.77e-08 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 21163 rows and 56 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 1.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 1.000           0.985       0.994         0.5365 0.766   0.590
#> 4 4 0.868           0.857       0.923         0.1279 0.876   0.655
#> 5 5 0.926           0.904       0.955         0.0651 0.916   0.692
#> 6 6 0.904           0.869       0.889         0.0307 0.968   0.846

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 5

There is also optional best \(k\) = 2 3 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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.0000      1.000  0 1.000 0.000
#> GSM329663     2  0.0000      1.000  0 1.000 0.000
#> GSM329664     2  0.0000      1.000  0 1.000 0.000
#> GSM329666     2  0.0000      1.000  0 1.000 0.000
#> GSM329667     2  0.0000      1.000  0 1.000 0.000
#> GSM329670     2  0.0000      1.000  0 1.000 0.000
#> GSM329672     2  0.0000      1.000  0 1.000 0.000
#> GSM329674     2  0.0000      1.000  0 1.000 0.000
#> GSM329661     3  0.0000      0.972  0 0.000 1.000
#> GSM329669     2  0.0000      1.000  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.972  0 0.000 1.000
#> GSM329679     2  0.0000      1.000  0 1.000 0.000
#> GSM329681     3  0.0000      0.972  0 0.000 1.000
#> GSM329683     3  0.0000      0.972  0 0.000 1.000
#> GSM329686     3  0.0000      0.972  0 0.000 1.000
#> GSM329689     3  0.0000      0.972  0 0.000 1.000
#> GSM329678     3  0.0000      0.972  0 0.000 1.000
#> GSM329680     3  0.0000      0.972  0 0.000 1.000
#> GSM329685     3  0.0000      0.972  0 0.000 1.000
#> GSM329688     3  0.0000      0.972  0 0.000 1.000
#> GSM329691     3  0.0000      0.972  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     3  0.2796      0.887  0 0.092 0.908
#> GSM329694     2  0.0000      1.000  0 1.000 0.000
#> GSM329697     2  0.0000      1.000  0 1.000 0.000
#> GSM329700     2  0.0000      1.000  0 1.000 0.000
#> GSM329703     2  0.0000      1.000  0 1.000 0.000
#> GSM329704     2  0.0000      1.000  0 1.000 0.000
#> GSM329707     3  0.5178      0.661  0 0.256 0.744
#> GSM329709     2  0.0000      1.000  0 1.000 0.000
#> GSM329711     2  0.0000      1.000  0 1.000 0.000
#> GSM329714     2  0.0000      1.000  0 1.000 0.000
#> GSM329693     2  0.0000      1.000  0 1.000 0.000
#> GSM329696     2  0.0000      1.000  0 1.000 0.000
#> GSM329699     2  0.0000      1.000  0 1.000 0.000
#> GSM329702     2  0.0000      1.000  0 1.000 0.000
#> GSM329706     3  0.0000      0.972  0 0.000 1.000
#> GSM329708     3  0.0000      0.972  0 0.000 1.000
#> GSM329710     2  0.0237      0.996  0 0.996 0.004
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      1.000  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329663     2   0.139      0.820  0 0.952 0.000 0.048
#> GSM329664     2   0.462      0.662  0 0.660 0.000 0.340
#> GSM329666     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329667     2   0.430      0.702  0 0.716 0.000 0.284
#> GSM329670     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329672     2   0.430      0.702  0 0.716 0.000 0.284
#> GSM329674     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329661     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329669     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329662     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329665     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329668     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329671     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329673     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329675     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329676     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329677     3   0.416      0.658  0 0.000 0.736 0.264
#> GSM329679     2   0.430      0.702  0 0.716 0.000 0.284
#> GSM329681     3   0.384      0.717  0 0.000 0.776 0.224
#> GSM329683     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329686     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329689     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329678     4   0.380      0.645  0 0.000 0.220 0.780
#> GSM329680     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329685     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329688     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329691     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329682     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329684     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329687     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329690     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329692     4   0.000      0.786  0 0.000 0.000 1.000
#> GSM329694     2   0.462      0.662  0 0.660 0.000 0.340
#> GSM329697     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329700     2   0.156      0.798  0 0.944 0.000 0.056
#> GSM329703     4   0.430      0.729  0 0.284 0.000 0.716
#> GSM329704     2   0.462      0.662  0 0.660 0.000 0.340
#> GSM329707     2   0.752      0.381  0 0.464 0.196 0.340
#> GSM329709     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329711     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329714     4   0.369      0.768  0 0.208 0.000 0.792
#> GSM329693     4   0.430      0.729  0 0.284 0.000 0.716
#> GSM329696     4   0.430      0.729  0 0.284 0.000 0.716
#> GSM329699     4   0.000      0.786  0 0.000 0.000 1.000
#> GSM329702     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329706     4   0.102      0.767  0 0.000 0.032 0.968
#> GSM329708     3   0.000      0.944  0 0.000 1.000 0.000
#> GSM329710     4   0.000      0.786  0 0.000 0.000 1.000
#> GSM329713     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329695     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329698     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329701     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329705     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM329712     2   0.000      0.832  0 1.000 0.000 0.000
#> GSM329715     1   0.000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     5  0.3534      0.663  0 0.256 0.000 0.000 0.744
#> GSM329663     2  0.0162      0.950  0 0.996 0.000 0.000 0.004
#> GSM329664     5  0.0162      0.906  0 0.004 0.000 0.000 0.996
#> GSM329666     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329667     5  0.3177      0.722  0 0.208 0.000 0.000 0.792
#> GSM329670     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.2690      0.806  0 0.844 0.000 0.000 0.156
#> GSM329674     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329661     3  0.1197      0.910  0 0.000 0.952 0.000 0.048
#> GSM329669     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     5  0.0703      0.887  0 0.000 0.024 0.000 0.976
#> GSM329679     2  0.3452      0.668  0 0.756 0.000 0.000 0.244
#> GSM329681     3  0.3534      0.743  0 0.000 0.744 0.000 0.256
#> GSM329683     3  0.2561      0.852  0 0.000 0.856 0.000 0.144
#> GSM329686     3  0.0000      0.927  0 0.000 1.000 0.000 0.000
#> GSM329689     3  0.3177      0.803  0 0.000 0.792 0.000 0.208
#> GSM329678     4  0.0880      0.866  0 0.000 0.000 0.968 0.032
#> GSM329680     3  0.0000      0.927  0 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.927  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.927  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.927  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.4088      0.468  0 0.000 0.000 0.632 0.368
#> GSM329694     5  0.0162      0.906  0 0.004 0.000 0.000 0.996
#> GSM329697     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329700     4  0.5172      0.455  0 0.324 0.000 0.616 0.060
#> GSM329703     4  0.0000      0.882  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.0162      0.906  0 0.004 0.000 0.000 0.996
#> GSM329707     5  0.0000      0.903  0 0.000 0.000 0.000 1.000
#> GSM329709     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329711     2  0.0880      0.934  0 0.968 0.000 0.032 0.000
#> GSM329714     4  0.2074      0.825  0 0.000 0.000 0.896 0.104
#> GSM329693     4  0.0000      0.882  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.882  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.882  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0000      0.952  0 1.000 0.000 0.000 0.000
#> GSM329706     5  0.0290      0.901  0 0.000 0.000 0.008 0.992
#> GSM329708     3  0.0000      0.927  0 0.000 1.000 0.000 0.000
#> GSM329710     4  0.0000      0.882  0 0.000 0.000 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     2  0.1043      0.928  0 0.960 0.000 0.040 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     6  0.4494      0.710 0.000 0.092 0.000 0.000 0.216 0.692
#> GSM329663     2  0.1910      0.803 0.000 0.892 0.000 0.000 0.108 0.000
#> GSM329664     5  0.0632      0.886 0.000 0.024 0.000 0.000 0.976 0.000
#> GSM329666     2  0.0000      0.839 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.0632      0.886 0.000 0.024 0.000 0.000 0.976 0.000
#> GSM329670     2  0.0000      0.839 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329672     2  0.3221      0.667 0.000 0.736 0.000 0.000 0.264 0.000
#> GSM329674     2  0.0146      0.835 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM329661     3  0.3789      0.809 0.000 0.000 0.716 0.000 0.024 0.260
#> GSM329669     6  0.3563      0.790 0.000 0.336 0.000 0.000 0.000 0.664
#> GSM329662     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329677     5  0.3122      0.763 0.000 0.000 0.020 0.000 0.804 0.176
#> GSM329679     2  0.3737      0.470 0.000 0.608 0.000 0.000 0.392 0.000
#> GSM329681     3  0.3789      0.809 0.000 0.000 0.716 0.000 0.024 0.260
#> GSM329683     3  0.3789      0.809 0.000 0.000 0.716 0.000 0.024 0.260
#> GSM329686     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.3789      0.809 0.000 0.000 0.716 0.000 0.024 0.260
#> GSM329678     4  0.0000      0.898 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329680     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0632      0.984 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM329692     4  0.5202      0.533 0.000 0.000 0.000 0.600 0.140 0.260
#> GSM329694     5  0.0632      0.886 0.000 0.024 0.000 0.000 0.976 0.000
#> GSM329697     2  0.1910      0.803 0.000 0.892 0.000 0.000 0.108 0.000
#> GSM329700     6  0.4690      0.775 0.000 0.112 0.000 0.016 0.156 0.716
#> GSM329703     4  0.0000      0.898 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.0632      0.886 0.000 0.024 0.000 0.000 0.976 0.000
#> GSM329707     5  0.2300      0.807 0.000 0.000 0.000 0.000 0.856 0.144
#> GSM329709     2  0.0000      0.839 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.3330      0.835 0.000 0.284 0.000 0.000 0.000 0.716
#> GSM329714     4  0.4599      0.604 0.000 0.000 0.000 0.684 0.212 0.104
#> GSM329693     4  0.0000      0.898 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000      0.898 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.898 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000      0.839 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.2178      0.804 0.000 0.000 0.000 0.132 0.868 0.000
#> GSM329708     3  0.0000      0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329710     4  0.0000      0.898 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0632      0.984 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM329695     1  0.0632      0.984 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM329698     1  0.0632      0.984 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM329701     1  0.0458      0.987 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM329705     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.3330      0.835 0.000 0.284 0.000 0.000 0.000 0.716
#> GSM329715     1  0.0000      0.994 1.000 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-pam-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) tissue(p) k
#> CV:pam 56         0.505684  5.82e-11 2
#> CV:pam 56         0.000528  2.02e-10 3
#> CV:pam 55         0.000025  6.20e-11 4
#> CV:pam 54         0.001995  8.34e-10 5
#> CV:pam 55         0.000810  6.32e-09 6

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


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 21163 rows and 56 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 1.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 0.766           0.788       0.910         0.5265 0.781   0.615
#> 4 4 0.891           0.918       0.959         0.1182 0.875   0.666
#> 5 5 0.910           0.851       0.932         0.0718 0.911   0.689
#> 6 6 0.917           0.869       0.930         0.0340 0.955   0.797

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.0000      0.789  0 1.000 0.000
#> GSM329663     2  0.0000      0.789  0 1.000 0.000
#> GSM329664     2  0.5760      0.461  0 0.672 0.328
#> GSM329666     2  0.0000      0.789  0 1.000 0.000
#> GSM329667     2  0.1860      0.760  0 0.948 0.052
#> GSM329670     2  0.0000      0.789  0 1.000 0.000
#> GSM329672     2  0.0000      0.789  0 1.000 0.000
#> GSM329674     2  0.0000      0.789  0 1.000 0.000
#> GSM329661     3  0.0000      0.922  0 0.000 1.000
#> GSM329669     2  0.0000      0.789  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.1031      0.909  0 0.024 0.976
#> GSM329679     2  0.0000      0.789  0 1.000 0.000
#> GSM329681     3  0.0592      0.918  0 0.012 0.988
#> GSM329683     3  0.0000      0.922  0 0.000 1.000
#> GSM329686     3  0.0000      0.922  0 0.000 1.000
#> GSM329689     3  0.0237      0.921  0 0.004 0.996
#> GSM329678     2  0.6274      0.330  0 0.544 0.456
#> GSM329680     3  0.0237      0.921  0 0.004 0.996
#> GSM329685     3  0.0000      0.922  0 0.000 1.000
#> GSM329688     3  0.0000      0.922  0 0.000 1.000
#> GSM329691     3  0.0000      0.922  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     2  0.6274      0.330  0 0.544 0.456
#> GSM329694     2  0.6274      0.330  0 0.544 0.456
#> GSM329697     2  0.0000      0.789  0 1.000 0.000
#> GSM329700     2  0.0000      0.789  0 1.000 0.000
#> GSM329703     2  0.6274      0.330  0 0.544 0.456
#> GSM329704     2  0.5591      0.504  0 0.696 0.304
#> GSM329707     3  0.5621      0.414  0 0.308 0.692
#> GSM329709     2  0.0000      0.789  0 1.000 0.000
#> GSM329711     2  0.0000      0.789  0 1.000 0.000
#> GSM329714     2  0.0000      0.789  0 1.000 0.000
#> GSM329693     2  0.6274      0.330  0 0.544 0.456
#> GSM329696     2  0.6274      0.330  0 0.544 0.456
#> GSM329699     2  0.6274      0.330  0 0.544 0.456
#> GSM329702     2  0.0000      0.789  0 1.000 0.000
#> GSM329706     3  0.5621      0.414  0 0.308 0.692
#> GSM329708     3  0.0892      0.912  0 0.020 0.980
#> GSM329710     2  0.6274      0.330  0 0.544 0.456
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.789  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.2530      0.862  0 0.888 0.000 0.112
#> GSM329663     2  0.0469      0.888  0 0.988 0.000 0.012
#> GSM329664     2  0.1510      0.875  0 0.956 0.028 0.016
#> GSM329666     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329667     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329670     2  0.2530      0.862  0 0.888 0.000 0.112
#> GSM329672     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329674     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329669     2  0.2530      0.862  0 0.888 0.000 0.112
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.3217      0.827  0 0.128 0.860 0.012
#> GSM329679     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329681     3  0.0336      0.976  0 0.000 0.992 0.008
#> GSM329683     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329689     3  0.0188      0.980  0 0.000 0.996 0.004
#> GSM329678     4  0.0000      0.980  0 0.000 0.000 1.000
#> GSM329680     3  0.0188      0.980  0 0.000 0.996 0.004
#> GSM329685     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.980  0 0.000 0.000 1.000
#> GSM329694     2  0.4817      0.390  0 0.612 0.000 0.388
#> GSM329697     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329700     2  0.2704      0.856  0 0.876 0.000 0.124
#> GSM329703     4  0.0000      0.980  0 0.000 0.000 1.000
#> GSM329704     2  0.0592      0.887  0 0.984 0.000 0.016
#> GSM329707     2  0.6371      0.465  0 0.608 0.300 0.092
#> GSM329709     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329711     2  0.2589      0.860  0 0.884 0.000 0.116
#> GSM329714     2  0.2647      0.859  0 0.880 0.000 0.120
#> GSM329693     4  0.0000      0.980  0 0.000 0.000 1.000
#> GSM329696     4  0.0000      0.980  0 0.000 0.000 1.000
#> GSM329699     4  0.2281      0.870  0 0.096 0.000 0.904
#> GSM329702     2  0.0000      0.889  0 1.000 0.000 0.000
#> GSM329706     2  0.5217      0.389  0 0.608 0.012 0.380
#> GSM329708     3  0.0000      0.982  0 0.000 1.000 0.000
#> GSM329710     4  0.0000      0.980  0 0.000 0.000 1.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.2589      0.860  0 0.884 0.000 0.116
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     2  0.0000     0.7894  0 1.000 0.000 0.000 0.000
#> GSM329663     2  0.0510     0.7939  0 0.984 0.000 0.000 0.016
#> GSM329664     5  0.1121     0.8270  0 0.044 0.000 0.000 0.956
#> GSM329666     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329667     5  0.3837     0.4713  0 0.308 0.000 0.000 0.692
#> GSM329670     2  0.0000     0.7894  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329674     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329661     3  0.0000     0.9814  0 0.000 1.000 0.000 0.000
#> GSM329669     2  0.0000     0.7894  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329677     5  0.3003     0.7178  0 0.000 0.188 0.000 0.812
#> GSM329679     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329681     3  0.1965     0.9077  0 0.000 0.904 0.000 0.096
#> GSM329683     3  0.0162     0.9800  0 0.000 0.996 0.000 0.004
#> GSM329686     3  0.0000     0.9814  0 0.000 1.000 0.000 0.000
#> GSM329689     3  0.1478     0.9366  0 0.000 0.936 0.000 0.064
#> GSM329678     4  0.0162     0.8946  0 0.000 0.000 0.996 0.004
#> GSM329680     3  0.0162     0.9800  0 0.000 0.996 0.000 0.004
#> GSM329685     3  0.0000     0.9814  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000     0.9814  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000     0.9814  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.1478     0.8611  0 0.000 0.000 0.936 0.064
#> GSM329694     4  0.4849     0.6703  0 0.140 0.000 0.724 0.136
#> GSM329697     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329700     2  0.4449    -0.0511  0 0.512 0.000 0.484 0.004
#> GSM329703     4  0.0000     0.8953  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.1270     0.8244  0 0.052 0.000 0.000 0.948
#> GSM329707     5  0.1043     0.8151  0 0.000 0.040 0.000 0.960
#> GSM329709     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329711     2  0.4171     0.2529  0 0.604 0.000 0.396 0.000
#> GSM329714     4  0.6206     0.3981  0 0.304 0.000 0.528 0.168
#> GSM329693     4  0.0000     0.8953  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000     0.8953  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000     0.8953  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.2127     0.8058  0 0.892 0.000 0.000 0.108
#> GSM329706     5  0.3141     0.7678  0 0.000 0.040 0.108 0.852
#> GSM329708     3  0.0000     0.9814  0 0.000 1.000 0.000 0.000
#> GSM329710     4  0.0162     0.8946  0 0.000 0.000 0.996 0.004
#> GSM329713     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329712     2  0.4321     0.2463  0 0.600 0.000 0.396 0.004
#> GSM329715     1  0.0000     1.0000  1 0.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
#> GSM329660     2  0.3323      0.714  0 0.752 0.000 0.000 0.008 0.240
#> GSM329663     2  0.3259      0.732  0 0.772 0.000 0.000 0.012 0.216
#> GSM329664     5  0.2679      0.833  0 0.096 0.000 0.000 0.864 0.040
#> GSM329666     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329667     2  0.3620      0.304  0 0.648 0.000 0.000 0.352 0.000
#> GSM329670     2  0.3271      0.722  0 0.760 0.000 0.000 0.008 0.232
#> GSM329672     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329674     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.0146      0.873  0 0.000 0.996 0.000 0.004 0.000
#> GSM329669     2  0.3175      0.702  0 0.744 0.000 0.000 0.000 0.256
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329677     5  0.1462      0.802  0 0.000 0.056 0.000 0.936 0.008
#> GSM329679     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329681     3  0.4910      0.610  0 0.000 0.656 0.000 0.192 0.152
#> GSM329683     3  0.0508      0.870  0 0.000 0.984 0.000 0.012 0.004
#> GSM329686     3  0.0146      0.873  0 0.000 0.996 0.000 0.004 0.000
#> GSM329689     3  0.4849      0.619  0 0.000 0.664 0.000 0.188 0.148
#> GSM329678     4  0.0547      0.963  0 0.000 0.000 0.980 0.000 0.020
#> GSM329680     3  0.0891      0.865  0 0.000 0.968 0.000 0.024 0.008
#> GSM329685     3  0.0146      0.873  0 0.000 0.996 0.000 0.004 0.000
#> GSM329688     3  0.0146      0.872  0 0.000 0.996 0.000 0.000 0.004
#> GSM329691     3  0.0146      0.872  0 0.000 0.996 0.000 0.000 0.004
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329692     4  0.2402      0.870  0 0.000 0.000 0.868 0.012 0.120
#> GSM329694     6  0.3333      0.538  0 0.024 0.000 0.000 0.192 0.784
#> GSM329697     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6  0.1863      0.876  0 0.104 0.000 0.000 0.000 0.896
#> GSM329703     4  0.0260      0.973  0 0.000 0.000 0.992 0.000 0.008
#> GSM329704     5  0.3274      0.812  0 0.096 0.000 0.000 0.824 0.080
#> GSM329707     5  0.1738      0.844  0 0.052 0.004 0.000 0.928 0.016
#> GSM329709     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.2003      0.866  0 0.116 0.000 0.000 0.000 0.884
#> GSM329714     6  0.1692      0.837  0 0.048 0.000 0.008 0.012 0.932
#> GSM329693     4  0.0363      0.972  0 0.000 0.000 0.988 0.000 0.012
#> GSM329696     4  0.0260      0.973  0 0.000 0.000 0.992 0.000 0.008
#> GSM329699     4  0.0260      0.973  0 0.000 0.000 0.992 0.000 0.008
#> GSM329702     2  0.0000      0.857  0 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.3570      0.724  0 0.016 0.004 0.000 0.752 0.228
#> GSM329708     3  0.3819      0.435  0 0.000 0.652 0.340 0.000 0.008
#> GSM329710     4  0.0000      0.970  0 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.1863      0.876  0 0.104 0.000 0.000 0.000 0.896
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-mclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-mclust-collect-classes

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

test_to_known_factors(res)
#>            n disease.state(p) tissue(p) k
#> CV:mclust 56         5.06e-01  5.82e-11 2
#> CV:mclust 45         8.79e-04  3.07e-09 3
#> CV:mclust 53         9.94e-05  1.11e-10 4
#> CV:mclust 51         5.42e-04  2.99e-09 5
#> CV:mclust 54         5.03e-05  5.16e-09 6

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


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

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 1.000           0.980       0.990         0.5574 0.761   0.580
#> 4 4 0.777           0.730       0.838         0.1145 0.927   0.783
#> 5 5 0.708           0.595       0.789         0.0414 0.953   0.829
#> 6 6 0.692           0.586       0.710         0.0401 0.945   0.786

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.0000      0.974  0 1.000 0.000
#> GSM329663     2  0.0000      0.974  0 1.000 0.000
#> GSM329664     2  0.3879      0.836  0 0.848 0.152
#> GSM329666     2  0.0000      0.974  0 1.000 0.000
#> GSM329667     2  0.0000      0.974  0 1.000 0.000
#> GSM329670     2  0.0000      0.974  0 1.000 0.000
#> GSM329672     2  0.0000      0.974  0 1.000 0.000
#> GSM329674     2  0.0000      0.974  0 1.000 0.000
#> GSM329661     3  0.0000      0.999  0 0.000 1.000
#> GSM329669     2  0.0000      0.974  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.999  0 0.000 1.000
#> GSM329679     2  0.0000      0.974  0 1.000 0.000
#> GSM329681     3  0.0000      0.999  0 0.000 1.000
#> GSM329683     3  0.0000      0.999  0 0.000 1.000
#> GSM329686     3  0.0000      0.999  0 0.000 1.000
#> GSM329689     3  0.0000      0.999  0 0.000 1.000
#> GSM329678     3  0.0000      0.999  0 0.000 1.000
#> GSM329680     3  0.0000      0.999  0 0.000 1.000
#> GSM329685     3  0.0000      0.999  0 0.000 1.000
#> GSM329688     3  0.0000      0.999  0 0.000 1.000
#> GSM329691     3  0.0000      0.999  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     3  0.0000      0.999  0 0.000 1.000
#> GSM329694     2  0.1529      0.945  0 0.960 0.040
#> GSM329697     2  0.0000      0.974  0 1.000 0.000
#> GSM329700     2  0.0000      0.974  0 1.000 0.000
#> GSM329703     2  0.0000      0.974  0 1.000 0.000
#> GSM329704     2  0.4555      0.775  0 0.800 0.200
#> GSM329707     3  0.0000      0.999  0 0.000 1.000
#> GSM329709     2  0.0000      0.974  0 1.000 0.000
#> GSM329711     2  0.0000      0.974  0 1.000 0.000
#> GSM329714     2  0.0000      0.974  0 1.000 0.000
#> GSM329693     2  0.0000      0.974  0 1.000 0.000
#> GSM329696     2  0.0237      0.972  0 0.996 0.004
#> GSM329699     2  0.4178      0.813  0 0.828 0.172
#> GSM329702     2  0.0000      0.974  0 1.000 0.000
#> GSM329706     3  0.0000      0.999  0 0.000 1.000
#> GSM329708     3  0.0000      0.999  0 0.000 1.000
#> GSM329710     3  0.0424      0.991  0 0.008 0.992
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.974  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM329660     2  0.1022      0.772 0.000 0.968 0.000 0.032
#> GSM329663     2  0.0817      0.773 0.000 0.976 0.000 0.024
#> GSM329664     2  0.6120      0.225 0.000 0.520 0.432 0.048
#> GSM329666     2  0.0336      0.772 0.000 0.992 0.000 0.008
#> GSM329667     2  0.3570      0.698 0.000 0.860 0.092 0.048
#> GSM329670     2  0.2469      0.750 0.000 0.892 0.000 0.108
#> GSM329672     2  0.1854      0.748 0.000 0.940 0.012 0.048
#> GSM329674     2  0.3074      0.727 0.000 0.848 0.000 0.152
#> GSM329661     3  0.2921      0.741 0.000 0.000 0.860 0.140
#> GSM329669     2  0.4331      0.618 0.000 0.712 0.000 0.288
#> GSM329662     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> GSM329665     1  0.0188      0.997 0.996 0.000 0.000 0.004
#> GSM329668     1  0.0188      0.997 0.996 0.000 0.000 0.004
#> GSM329671     1  0.0188      0.995 0.996 0.000 0.000 0.004
#> GSM329673     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> GSM329675     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> GSM329676     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> GSM329677     3  0.1635      0.695 0.000 0.008 0.948 0.044
#> GSM329679     2  0.2586      0.734 0.000 0.912 0.040 0.048
#> GSM329681     3  0.0000      0.726 0.000 0.000 1.000 0.000
#> GSM329683     3  0.2216      0.745 0.000 0.000 0.908 0.092
#> GSM329686     3  0.2281      0.746 0.000 0.000 0.904 0.096
#> GSM329689     3  0.0000      0.726 0.000 0.000 1.000 0.000
#> GSM329678     4  0.4888     -0.196 0.000 0.000 0.412 0.588
#> GSM329680     3  0.4250      0.689 0.000 0.000 0.724 0.276
#> GSM329685     3  0.4697      0.603 0.000 0.000 0.644 0.356
#> GSM329688     3  0.4761      0.583 0.000 0.000 0.628 0.372
#> GSM329691     3  0.4222      0.692 0.000 0.000 0.728 0.272
#> GSM329682     1  0.0188      0.996 0.996 0.000 0.000 0.004
#> GSM329684     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> GSM329687     1  0.0336      0.996 0.992 0.000 0.000 0.008
#> GSM329690     1  0.0188      0.995 0.996 0.000 0.000 0.004
#> GSM329692     3  0.4941      0.351 0.000 0.000 0.564 0.436
#> GSM329694     2  0.2976      0.710 0.000 0.872 0.120 0.008
#> GSM329697     2  0.0707      0.773 0.000 0.980 0.000 0.020
#> GSM329700     2  0.4331      0.617 0.000 0.712 0.000 0.288
#> GSM329703     4  0.2654      0.736 0.000 0.108 0.004 0.888
#> GSM329704     2  0.6125      0.210 0.000 0.516 0.436 0.048
#> GSM329707     3  0.4100      0.574 0.000 0.128 0.824 0.048
#> GSM329709     2  0.1022      0.772 0.000 0.968 0.000 0.032
#> GSM329711     2  0.4830      0.476 0.000 0.608 0.000 0.392
#> GSM329714     2  0.4925      0.378 0.000 0.572 0.000 0.428
#> GSM329693     4  0.3764      0.563 0.000 0.216 0.000 0.784
#> GSM329696     4  0.2654      0.736 0.000 0.108 0.004 0.888
#> GSM329699     4  0.1929      0.710 0.000 0.036 0.024 0.940
#> GSM329702     2  0.0592      0.770 0.000 0.984 0.000 0.016
#> GSM329706     3  0.3606      0.690 0.000 0.024 0.844 0.132
#> GSM329708     3  0.5000      0.291 0.000 0.000 0.500 0.500
#> GSM329710     4  0.3444      0.526 0.000 0.000 0.184 0.816
#> GSM329713     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      0.997 1.000 0.000 0.000 0.000
#> GSM329712     2  0.4843      0.469 0.000 0.604 0.000 0.396
#> GSM329715     1  0.0000      0.997 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.2672     0.6589 0.000 0.872 0.008 0.116 0.004
#> GSM329663     2  0.4258     0.6060 0.000 0.744 0.004 0.220 0.032
#> GSM329664     2  0.4410     0.0824 0.000 0.556 0.440 0.000 0.004
#> GSM329666     2  0.1671     0.6637 0.000 0.924 0.000 0.076 0.000
#> GSM329667     2  0.2848     0.5563 0.000 0.840 0.156 0.000 0.004
#> GSM329670     2  0.5246     0.4257 0.000 0.564 0.000 0.384 0.052
#> GSM329672     2  0.1270     0.6246 0.000 0.948 0.052 0.000 0.000
#> GSM329674     2  0.3807     0.5984 0.000 0.748 0.000 0.240 0.012
#> GSM329661     5  0.4637     0.5916 0.000 0.000 0.292 0.036 0.672
#> GSM329669     2  0.4341     0.4342 0.000 0.592 0.000 0.404 0.004
#> GSM329662     1  0.1544     0.9416 0.932 0.000 0.000 0.000 0.068
#> GSM329665     1  0.1121     0.9488 0.956 0.000 0.000 0.000 0.044
#> GSM329668     1  0.0290     0.9514 0.992 0.000 0.000 0.000 0.008
#> GSM329671     1  0.0510     0.9493 0.984 0.000 0.000 0.000 0.016
#> GSM329673     1  0.1121     0.9488 0.956 0.000 0.000 0.000 0.044
#> GSM329675     1  0.1410     0.9446 0.940 0.000 0.000 0.000 0.060
#> GSM329676     1  0.1341     0.9458 0.944 0.000 0.000 0.000 0.056
#> GSM329677     3  0.1638     0.5406 0.000 0.064 0.932 0.000 0.004
#> GSM329679     2  0.1732     0.6106 0.000 0.920 0.080 0.000 0.000
#> GSM329681     5  0.4171     0.4436 0.000 0.000 0.396 0.000 0.604
#> GSM329683     3  0.5188    -0.1236 0.000 0.000 0.540 0.044 0.416
#> GSM329686     3  0.3242     0.5799 0.000 0.000 0.844 0.116 0.040
#> GSM329689     3  0.3928     0.2053 0.000 0.000 0.700 0.004 0.296
#> GSM329678     4  0.5431    -0.2016 0.000 0.000 0.424 0.516 0.060
#> GSM329680     3  0.4428     0.5493 0.000 0.000 0.756 0.160 0.084
#> GSM329685     3  0.4777     0.4801 0.000 0.000 0.680 0.268 0.052
#> GSM329688     3  0.4907     0.4652 0.000 0.000 0.664 0.280 0.056
#> GSM329691     3  0.3944     0.5717 0.000 0.000 0.788 0.160 0.052
#> GSM329682     1  0.0000     0.9512 1.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.1608     0.9398 0.928 0.000 0.000 0.000 0.072
#> GSM329687     1  0.1270     0.9469 0.948 0.000 0.000 0.000 0.052
#> GSM329690     1  0.2124     0.9145 0.900 0.000 0.000 0.004 0.096
#> GSM329692     5  0.5877     0.6418 0.000 0.000 0.200 0.196 0.604
#> GSM329694     2  0.4830     0.5677 0.000 0.768 0.120 0.068 0.044
#> GSM329697     2  0.2669     0.6620 0.000 0.876 0.000 0.104 0.020
#> GSM329700     2  0.4740     0.3242 0.000 0.516 0.000 0.468 0.016
#> GSM329703     4  0.2077     0.6252 0.000 0.084 0.000 0.908 0.008
#> GSM329704     2  0.4383     0.1111 0.000 0.572 0.424 0.000 0.004
#> GSM329707     3  0.4941     0.2452 0.000 0.328 0.628 0.000 0.044
#> GSM329709     2  0.2674     0.6594 0.000 0.868 0.000 0.120 0.012
#> GSM329711     2  0.4297     0.3257 0.000 0.528 0.000 0.472 0.000
#> GSM329714     4  0.4658    -0.2958 0.000 0.484 0.000 0.504 0.012
#> GSM329693     4  0.2919     0.6242 0.000 0.104 0.024 0.868 0.004
#> GSM329696     4  0.2640     0.6068 0.000 0.052 0.016 0.900 0.032
#> GSM329699     4  0.3059     0.5138 0.000 0.016 0.120 0.856 0.008
#> GSM329702     2  0.1628     0.6599 0.000 0.936 0.008 0.056 0.000
#> GSM329706     3  0.2332     0.5410 0.000 0.076 0.904 0.016 0.004
#> GSM329708     5  0.5466     0.6616 0.000 0.000 0.192 0.152 0.656
#> GSM329710     5  0.6040     0.2407 0.000 0.012 0.080 0.452 0.456
#> GSM329713     1  0.2629     0.8876 0.860 0.000 0.000 0.004 0.136
#> GSM329695     1  0.2583     0.8905 0.864 0.000 0.000 0.004 0.132
#> GSM329698     1  0.1831     0.9248 0.920 0.000 0.000 0.004 0.076
#> GSM329701     1  0.0880     0.9451 0.968 0.000 0.000 0.000 0.032
#> GSM329705     1  0.0290     0.9505 0.992 0.000 0.000 0.000 0.008
#> GSM329712     2  0.4448     0.3026 0.000 0.516 0.000 0.480 0.004
#> GSM329715     1  0.0404     0.9500 0.988 0.000 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM329660     2  0.1666    0.67322 0.000 0.936 0.000 0.020 0.008 NA
#> GSM329663     2  0.5649    0.54725 0.000 0.644 0.032 0.136 0.008 NA
#> GSM329664     5  0.4981    0.20101 0.000 0.340 0.004 0.000 0.584 NA
#> GSM329666     2  0.1434    0.66858 0.000 0.940 0.000 0.012 0.048 NA
#> GSM329667     2  0.4979    0.38186 0.000 0.604 0.004 0.000 0.312 NA
#> GSM329670     2  0.5831    0.44207 0.000 0.560 0.024 0.276 0.000 NA
#> GSM329672     2  0.3201    0.56937 0.000 0.780 0.000 0.000 0.208 NA
#> GSM329674     2  0.3231    0.62347 0.000 0.800 0.008 0.180 0.000 NA
#> GSM329661     3  0.1672    0.76363 0.000 0.000 0.932 0.004 0.048 NA
#> GSM329669     2  0.3421    0.57071 0.000 0.736 0.000 0.256 0.000 NA
#> GSM329662     1  0.1267    0.84011 0.940 0.000 0.000 0.000 0.000 NA
#> GSM329665     1  0.0363    0.85380 0.988 0.000 0.000 0.000 0.000 NA
#> GSM329668     1  0.0937    0.85852 0.960 0.000 0.000 0.000 0.000 NA
#> GSM329671     1  0.2527    0.84293 0.832 0.000 0.000 0.000 0.000 NA
#> GSM329673     1  0.0713    0.85054 0.972 0.000 0.000 0.000 0.000 NA
#> GSM329675     1  0.1267    0.84011 0.940 0.000 0.000 0.000 0.000 NA
#> GSM329676     1  0.1267    0.84011 0.940 0.000 0.000 0.000 0.000 NA
#> GSM329677     5  0.0748    0.50489 0.000 0.004 0.004 0.000 0.976 NA
#> GSM329679     2  0.3050    0.54478 0.000 0.764 0.000 0.000 0.236 NA
#> GSM329681     3  0.2088    0.74154 0.000 0.000 0.904 0.000 0.068 NA
#> GSM329683     3  0.5212    0.36109 0.000 0.000 0.592 0.024 0.324 NA
#> GSM329686     5  0.5234    0.47612 0.000 0.000 0.048 0.208 0.668 NA
#> GSM329689     5  0.5358    0.00273 0.000 0.000 0.368 0.020 0.544 NA
#> GSM329678     4  0.5691   -0.13407 0.000 0.000 0.036 0.544 0.340 NA
#> GSM329680     5  0.6259    0.35252 0.000 0.000 0.096 0.304 0.524 NA
#> GSM329685     5  0.5412    0.36602 0.000 0.000 0.024 0.360 0.548 NA
#> GSM329688     5  0.5551    0.34706 0.000 0.000 0.028 0.372 0.528 NA
#> GSM329691     5  0.5608    0.41783 0.000 0.000 0.036 0.300 0.580 NA
#> GSM329682     1  0.1444    0.85862 0.928 0.000 0.000 0.000 0.000 NA
#> GSM329684     1  0.1387    0.83631 0.932 0.000 0.000 0.000 0.000 NA
#> GSM329687     1  0.0632    0.85183 0.976 0.000 0.000 0.000 0.000 NA
#> GSM329690     1  0.3684    0.73663 0.628 0.000 0.000 0.000 0.000 NA
#> GSM329692     3  0.2664    0.75525 0.000 0.000 0.848 0.136 0.016 NA
#> GSM329694     2  0.6099    0.51675 0.000 0.640 0.164 0.048 0.112 NA
#> GSM329697     2  0.1710    0.67320 0.000 0.940 0.008 0.020 0.012 NA
#> GSM329700     2  0.5291    0.39772 0.000 0.556 0.028 0.364 0.000 NA
#> GSM329703     4  0.3515    0.52327 0.000 0.192 0.012 0.780 0.000 NA
#> GSM329704     5  0.4724    0.20490 0.000 0.348 0.000 0.000 0.592 NA
#> GSM329707     5  0.4873    0.38228 0.000 0.172 0.048 0.000 0.712 NA
#> GSM329709     2  0.3342    0.66506 0.000 0.848 0.012 0.084 0.036 NA
#> GSM329711     2  0.4026    0.47508 0.000 0.636 0.000 0.348 0.000 NA
#> GSM329714     2  0.6113    0.26954 0.000 0.468 0.016 0.376 0.008 NA
#> GSM329693     4  0.3946    0.57145 0.000 0.208 0.000 0.748 0.012 NA
#> GSM329696     4  0.2742    0.66537 0.000 0.076 0.020 0.880 0.008 NA
#> GSM329699     4  0.2434    0.61794 0.000 0.032 0.000 0.896 0.056 NA
#> GSM329702     2  0.1897    0.65542 0.000 0.908 0.000 0.004 0.084 NA
#> GSM329706     5  0.1296    0.51360 0.000 0.012 0.000 0.032 0.952 NA
#> GSM329708     3  0.2860    0.76752 0.000 0.000 0.872 0.068 0.032 NA
#> GSM329710     3  0.5402    0.42733 0.000 0.020 0.584 0.336 0.024 NA
#> GSM329713     1  0.4076    0.65588 0.540 0.000 0.008 0.000 0.000 NA
#> GSM329695     1  0.3823    0.68047 0.564 0.000 0.000 0.000 0.000 NA
#> GSM329698     1  0.3446    0.77885 0.692 0.000 0.000 0.000 0.000 NA
#> GSM329701     1  0.3023    0.81889 0.768 0.000 0.000 0.000 0.000 NA
#> GSM329705     1  0.2048    0.85286 0.880 0.000 0.000 0.000 0.000 NA
#> GSM329712     2  0.3911    0.45228 0.000 0.624 0.000 0.368 0.000 NA
#> GSM329715     1  0.2491    0.84382 0.836 0.000 0.000 0.000 0.000 NA

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) tissue(p) k
#> CV:NMF 56         0.505684  5.82e-11 2
#> CV:NMF 56         0.001210  7.06e-11 3
#> CV:NMF 48         0.000237  3.83e-10 4
#> CV:NMF 40         0.016126  4.65e-08 5
#> CV:NMF 38         0.314557  1.34e-06 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 21163 rows and 56 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 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-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 1.000           0.970       0.985         0.3915 0.618   0.618
#> 3 3 1.000           0.972       0.985         0.6857 0.724   0.554
#> 4 4 0.860           0.791       0.887         0.1246 0.906   0.727
#> 5 5 0.834           0.884       0.912         0.0564 0.961   0.843
#> 6 6 0.834           0.832       0.864         0.0434 0.953   0.777

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
#> GSM329660     1  0.0376      0.980 0.996 0.004
#> GSM329663     1  0.0000      0.981 1.000 0.000
#> GSM329664     1  0.1184      0.973 0.984 0.016
#> GSM329666     1  0.0000      0.981 1.000 0.000
#> GSM329667     1  0.1184      0.973 0.984 0.016
#> GSM329670     1  0.0000      0.981 1.000 0.000
#> GSM329672     1  0.0000      0.981 1.000 0.000
#> GSM329674     1  0.0000      0.981 1.000 0.000
#> GSM329661     2  0.0000      0.992 0.000 1.000
#> GSM329669     1  0.0000      0.981 1.000 0.000
#> GSM329662     1  0.0000      0.981 1.000 0.000
#> GSM329665     1  0.0000      0.981 1.000 0.000
#> GSM329668     1  0.0000      0.981 1.000 0.000
#> GSM329671     1  0.0000      0.981 1.000 0.000
#> GSM329673     1  0.0000      0.981 1.000 0.000
#> GSM329675     1  0.0000      0.981 1.000 0.000
#> GSM329676     1  0.0000      0.981 1.000 0.000
#> GSM329677     2  0.0000      0.992 0.000 1.000
#> GSM329679     1  0.0000      0.981 1.000 0.000
#> GSM329681     2  0.0000      0.992 0.000 1.000
#> GSM329683     2  0.0000      0.992 0.000 1.000
#> GSM329686     2  0.0000      0.992 0.000 1.000
#> GSM329689     2  0.0000      0.992 0.000 1.000
#> GSM329678     2  0.4562      0.890 0.096 0.904
#> GSM329680     2  0.0000      0.992 0.000 1.000
#> GSM329685     2  0.0000      0.992 0.000 1.000
#> GSM329688     2  0.0000      0.992 0.000 1.000
#> GSM329691     2  0.0000      0.992 0.000 1.000
#> GSM329682     1  0.0000      0.981 1.000 0.000
#> GSM329684     1  0.0000      0.981 1.000 0.000
#> GSM329687     1  0.0000      0.981 1.000 0.000
#> GSM329690     1  0.0000      0.981 1.000 0.000
#> GSM329692     1  0.7674      0.735 0.776 0.224
#> GSM329694     1  0.1414      0.971 0.980 0.020
#> GSM329697     1  0.0000      0.981 1.000 0.000
#> GSM329700     1  0.0672      0.978 0.992 0.008
#> GSM329703     1  0.3114      0.942 0.944 0.056
#> GSM329704     1  0.1414      0.971 0.980 0.020
#> GSM329707     2  0.0000      0.992 0.000 1.000
#> GSM329709     1  0.0000      0.981 1.000 0.000
#> GSM329711     1  0.0000      0.981 1.000 0.000
#> GSM329714     1  0.0672      0.978 0.992 0.008
#> GSM329693     1  0.3114      0.942 0.944 0.056
#> GSM329696     1  0.3114      0.942 0.944 0.056
#> GSM329699     1  0.3114      0.942 0.944 0.056
#> GSM329702     1  0.0000      0.981 1.000 0.000
#> GSM329706     2  0.0376      0.989 0.004 0.996
#> GSM329708     2  0.0000      0.992 0.000 1.000
#> GSM329710     1  0.7674      0.735 0.776 0.224
#> GSM329713     1  0.0000      0.981 1.000 0.000
#> GSM329695     1  0.0000      0.981 1.000 0.000
#> GSM329698     1  0.0000      0.981 1.000 0.000
#> GSM329701     1  0.0000      0.981 1.000 0.000
#> GSM329705     1  0.0000      0.981 1.000 0.000
#> GSM329712     1  0.0000      0.981 1.000 0.000
#> GSM329715     1  0.0000      0.981 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
#> GSM329660     2  0.0237      0.968  0 0.996 0.004
#> GSM329663     2  0.0000      0.969  0 1.000 0.000
#> GSM329664     2  0.0747      0.966  0 0.984 0.016
#> GSM329666     2  0.0000      0.969  0 1.000 0.000
#> GSM329667     2  0.0747      0.966  0 0.984 0.016
#> GSM329670     2  0.0000      0.969  0 1.000 0.000
#> GSM329672     2  0.0000      0.969  0 1.000 0.000
#> GSM329674     2  0.0000      0.969  0 1.000 0.000
#> GSM329661     3  0.0000      0.991  0 0.000 1.000
#> GSM329669     2  0.0000      0.969  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.991  0 0.000 1.000
#> GSM329679     2  0.0000      0.969  0 1.000 0.000
#> GSM329681     3  0.0000      0.991  0 0.000 1.000
#> GSM329683     3  0.0000      0.991  0 0.000 1.000
#> GSM329686     3  0.0000      0.991  0 0.000 1.000
#> GSM329689     3  0.0000      0.991  0 0.000 1.000
#> GSM329678     3  0.2878      0.887  0 0.096 0.904
#> GSM329680     3  0.0000      0.991  0 0.000 1.000
#> GSM329685     3  0.0000      0.991  0 0.000 1.000
#> GSM329688     3  0.0000      0.991  0 0.000 1.000
#> GSM329691     3  0.0000      0.991  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     2  0.4842      0.748  0 0.776 0.224
#> GSM329694     2  0.0892      0.964  0 0.980 0.020
#> GSM329697     2  0.0000      0.969  0 1.000 0.000
#> GSM329700     2  0.0424      0.968  0 0.992 0.008
#> GSM329703     2  0.1964      0.943  0 0.944 0.056
#> GSM329704     2  0.0892      0.964  0 0.980 0.020
#> GSM329707     3  0.0000      0.991  0 0.000 1.000
#> GSM329709     2  0.0000      0.969  0 1.000 0.000
#> GSM329711     2  0.0000      0.969  0 1.000 0.000
#> GSM329714     2  0.0424      0.968  0 0.992 0.008
#> GSM329693     2  0.1964      0.943  0 0.944 0.056
#> GSM329696     2  0.1964      0.943  0 0.944 0.056
#> GSM329699     2  0.1964      0.943  0 0.944 0.056
#> GSM329702     2  0.0000      0.969  0 1.000 0.000
#> GSM329706     3  0.0237      0.988  0 0.004 0.996
#> GSM329708     3  0.0000      0.991  0 0.000 1.000
#> GSM329710     2  0.4842      0.748  0 0.776 0.224
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.969  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     4  0.4406      0.186  0 0.300 0.000 0.700
#> GSM329663     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329664     2  0.0707      0.466  0 0.980 0.000 0.020
#> GSM329666     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329667     2  0.0707      0.466  0 0.980 0.000 0.020
#> GSM329670     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329672     2  0.0336      0.474  0 0.992 0.000 0.008
#> GSM329674     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329661     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329669     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0592      0.976  0 0.000 0.984 0.016
#> GSM329679     2  0.0336      0.474  0 0.992 0.000 0.008
#> GSM329681     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329678     3  0.3074      0.841  0 0.000 0.848 0.152
#> GSM329680     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.3266      0.623  0 0.000 0.168 0.832
#> GSM329694     2  0.4500      0.115  0 0.684 0.000 0.316
#> GSM329697     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329700     4  0.3172      0.606  0 0.160 0.000 0.840
#> GSM329703     4  0.0000      0.771  0 0.000 0.000 1.000
#> GSM329704     2  0.3219      0.333  0 0.836 0.000 0.164
#> GSM329707     3  0.0592      0.976  0 0.000 0.984 0.016
#> GSM329709     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329711     2  0.4994      0.537  0 0.520 0.000 0.480
#> GSM329714     4  0.3172      0.606  0 0.160 0.000 0.840
#> GSM329693     4  0.0000      0.771  0 0.000 0.000 1.000
#> GSM329696     4  0.0000      0.771  0 0.000 0.000 1.000
#> GSM329699     4  0.0000      0.771  0 0.000 0.000 1.000
#> GSM329702     2  0.4977      0.571  0 0.540 0.000 0.460
#> GSM329706     3  0.0817      0.970  0 0.000 0.976 0.024
#> GSM329708     3  0.0000      0.984  0 0.000 1.000 0.000
#> GSM329710     4  0.3266      0.623  0 0.000 0.168 0.832
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.4994      0.537  0 0.520 0.000 0.480
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     4  0.5314      0.498 0.000 0.420 0.000 0.528 0.052
#> GSM329663     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329664     5  0.0000      0.739 0.000 0.000 0.000 0.000 1.000
#> GSM329666     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329667     5  0.0000      0.739 0.000 0.000 0.000 0.000 1.000
#> GSM329670     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329672     5  0.4283      0.584 0.000 0.348 0.000 0.008 0.644
#> GSM329674     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329661     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329669     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.2813      0.920 0.832 0.000 0.000 0.168 0.000
#> GSM329673     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329677     3  0.0510      0.976 0.000 0.000 0.984 0.000 0.016
#> GSM329679     5  0.4283      0.584 0.000 0.348 0.000 0.008 0.644
#> GSM329681     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329683     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329686     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329689     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329678     3  0.2763      0.827 0.000 0.000 0.848 0.148 0.004
#> GSM329680     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      0.911 1.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.2773      0.921 0.836 0.000 0.000 0.164 0.000
#> GSM329690     1  0.2813      0.920 0.832 0.000 0.000 0.168 0.000
#> GSM329692     4  0.2813      0.647 0.000 0.000 0.168 0.832 0.000
#> GSM329694     5  0.3857      0.557 0.000 0.000 0.000 0.312 0.688
#> GSM329697     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329700     4  0.4637      0.745 0.000 0.292 0.000 0.672 0.036
#> GSM329703     4  0.2813      0.819 0.000 0.168 0.000 0.832 0.000
#> GSM329704     5  0.2605      0.703 0.000 0.000 0.000 0.148 0.852
#> GSM329707     3  0.0510      0.976 0.000 0.000 0.984 0.000 0.016
#> GSM329709     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329711     2  0.0771      0.970 0.000 0.976 0.000 0.020 0.004
#> GSM329714     4  0.4637      0.745 0.000 0.292 0.000 0.672 0.036
#> GSM329693     4  0.2813      0.819 0.000 0.168 0.000 0.832 0.000
#> GSM329696     4  0.2813      0.819 0.000 0.168 0.000 0.832 0.000
#> GSM329699     4  0.2813      0.819 0.000 0.168 0.000 0.832 0.000
#> GSM329702     2  0.0000      0.993 0.000 1.000 0.000 0.000 0.000
#> GSM329706     3  0.0771      0.971 0.000 0.000 0.976 0.004 0.020
#> GSM329708     3  0.0000      0.984 0.000 0.000 1.000 0.000 0.000
#> GSM329710     4  0.2813      0.647 0.000 0.000 0.168 0.832 0.000
#> GSM329713     1  0.2813      0.920 0.832 0.000 0.000 0.168 0.000
#> GSM329695     1  0.2813      0.920 0.832 0.000 0.000 0.168 0.000
#> GSM329698     1  0.2813      0.920 0.832 0.000 0.000 0.168 0.000
#> GSM329701     1  0.2813      0.920 0.832 0.000 0.000 0.168 0.000
#> GSM329705     1  0.2773      0.921 0.836 0.000 0.000 0.164 0.000
#> GSM329712     2  0.0771      0.970 0.000 0.976 0.000 0.020 0.004
#> GSM329715     1  0.2813      0.920 0.832 0.000 0.000 0.168 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
#> GSM329660     4  0.5100    0.51293 0.000 0.416 0.000 0.524 0.028 0.032
#> GSM329663     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329664     5  0.0000    0.73151 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329666     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.0000    0.73151 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329670     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329672     5  0.3847    0.58467 0.000 0.348 0.000 0.008 0.644 0.000
#> GSM329674     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.3050    0.81089 0.000 0.000 0.764 0.000 0.000 0.236
#> GSM329669     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329662     6  0.3371    0.99595 0.292 0.000 0.000 0.000 0.000 0.708
#> GSM329665     6  0.3371    0.99595 0.292 0.000 0.000 0.000 0.000 0.708
#> GSM329668     6  0.3371    0.99595 0.292 0.000 0.000 0.000 0.000 0.708
#> GSM329671     1  0.0000    0.82750 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329673     6  0.3371    0.99595 0.292 0.000 0.000 0.000 0.000 0.708
#> GSM329675     6  0.3330    0.98789 0.284 0.000 0.000 0.000 0.000 0.716
#> GSM329676     6  0.3371    0.99595 0.292 0.000 0.000 0.000 0.000 0.708
#> GSM329677     3  0.0458    0.91925 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM329679     5  0.3847    0.58467 0.000 0.348 0.000 0.008 0.644 0.000
#> GSM329681     3  0.0790    0.92021 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM329683     3  0.0790    0.92021 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM329686     3  0.1204    0.91875 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM329689     3  0.0790    0.92021 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM329678     3  0.2520    0.79869 0.000 0.000 0.844 0.152 0.000 0.004
#> GSM329680     3  0.0146    0.92151 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329685     3  0.1204    0.91875 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM329688     3  0.1204    0.91875 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM329691     3  0.1204    0.91875 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM329682     6  0.3371    0.99595 0.292 0.000 0.000 0.000 0.000 0.708
#> GSM329684     6  0.3330    0.98789 0.284 0.000 0.000 0.000 0.000 0.716
#> GSM329687     1  0.3737   -0.00152 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM329690     1  0.0000    0.82750 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329692     4  0.0000    0.69454 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329694     5  0.4361    0.54381 0.000 0.000 0.000 0.308 0.648 0.044
#> GSM329697     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     4  0.4272    0.75995 0.000 0.288 0.000 0.668 0.000 0.044
#> GSM329703     4  0.2527    0.83708 0.000 0.168 0.000 0.832 0.000 0.000
#> GSM329704     5  0.3268    0.69188 0.000 0.000 0.000 0.144 0.812 0.044
#> GSM329707     3  0.0458    0.91925 0.000 0.000 0.984 0.000 0.016 0.000
#> GSM329709     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     2  0.0692    0.97012 0.000 0.976 0.000 0.020 0.000 0.004
#> GSM329714     4  0.4272    0.75995 0.000 0.288 0.000 0.668 0.000 0.044
#> GSM329693     4  0.2527    0.83708 0.000 0.168 0.000 0.832 0.000 0.000
#> GSM329696     4  0.2527    0.83708 0.000 0.168 0.000 0.832 0.000 0.000
#> GSM329699     4  0.2527    0.83708 0.000 0.168 0.000 0.832 0.000 0.000
#> GSM329702     2  0.0000    0.99270 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     3  0.0748    0.91702 0.000 0.000 0.976 0.004 0.016 0.004
#> GSM329708     3  0.5296    0.62739 0.000 0.000 0.596 0.168 0.000 0.236
#> GSM329710     4  0.0000    0.69454 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0000    0.82750 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000    0.82750 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329698     1  0.1204    0.81420 0.944 0.000 0.000 0.000 0.000 0.056
#> GSM329701     1  0.1007    0.82310 0.956 0.000 0.000 0.000 0.000 0.044
#> GSM329705     1  0.3737   -0.00152 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM329712     2  0.0692    0.97012 0.000 0.976 0.000 0.020 0.000 0.004
#> GSM329715     1  0.1007    0.82310 0.956 0.000 0.000 0.000 0.000 0.044

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-hclust-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-hclust-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> MAD:hclust 56         6.76e-05  2.37e-03 2
#> MAD:hclust 56         1.85e-04  1.01e-10 3
#> MAD:hclust 49         5.14e-05  4.77e-08 4
#> MAD:hclust 55         1.36e-04  1.95e-09 5
#> MAD:hclust 54         2.83e-05  3.10e-08 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 21163 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.616           0.936       0.949         0.4392 0.569   0.569
#> 3 3 1.000           0.936       0.956         0.4994 0.766   0.590
#> 4 4 0.782           0.799       0.849         0.1123 0.903   0.714
#> 5 5 0.734           0.651       0.804         0.0679 0.949   0.801
#> 6 6 0.730           0.713       0.775         0.0438 0.915   0.633

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

suggest_best_k(res)
#> [1] 3

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM329660     2   0.644      0.892 0.164 0.836
#> GSM329663     2   0.644      0.892 0.164 0.836
#> GSM329664     2   0.000      0.920 0.000 1.000
#> GSM329666     2   0.644      0.892 0.164 0.836
#> GSM329667     2   0.529      0.905 0.120 0.880
#> GSM329670     2   0.644      0.892 0.164 0.836
#> GSM329672     2   0.634      0.894 0.160 0.840
#> GSM329674     2   0.644      0.892 0.164 0.836
#> GSM329661     2   0.000      0.920 0.000 1.000
#> GSM329669     2   0.644      0.892 0.164 0.836
#> GSM329662     1   0.000      1.000 1.000 0.000
#> GSM329665     1   0.000      1.000 1.000 0.000
#> GSM329668     1   0.000      1.000 1.000 0.000
#> GSM329671     1   0.000      1.000 1.000 0.000
#> GSM329673     1   0.000      1.000 1.000 0.000
#> GSM329675     1   0.000      1.000 1.000 0.000
#> GSM329676     1   0.000      1.000 1.000 0.000
#> GSM329677     2   0.000      0.920 0.000 1.000
#> GSM329679     2   0.634      0.894 0.160 0.840
#> GSM329681     2   0.000      0.920 0.000 1.000
#> GSM329683     2   0.000      0.920 0.000 1.000
#> GSM329686     2   0.000      0.920 0.000 1.000
#> GSM329689     2   0.000      0.920 0.000 1.000
#> GSM329678     2   0.000      0.920 0.000 1.000
#> GSM329680     2   0.000      0.920 0.000 1.000
#> GSM329685     2   0.000      0.920 0.000 1.000
#> GSM329688     2   0.000      0.920 0.000 1.000
#> GSM329691     2   0.000      0.920 0.000 1.000
#> GSM329682     1   0.000      1.000 1.000 0.000
#> GSM329684     1   0.000      1.000 1.000 0.000
#> GSM329687     1   0.000      1.000 1.000 0.000
#> GSM329690     1   0.000      1.000 1.000 0.000
#> GSM329692     2   0.000      0.920 0.000 1.000
#> GSM329694     2   0.000      0.920 0.000 1.000
#> GSM329697     2   0.644      0.892 0.164 0.836
#> GSM329700     2   0.644      0.892 0.164 0.836
#> GSM329703     2   0.456      0.911 0.096 0.904
#> GSM329704     2   0.000      0.920 0.000 1.000
#> GSM329707     2   0.000      0.920 0.000 1.000
#> GSM329709     2   0.644      0.892 0.164 0.836
#> GSM329711     2   0.644      0.892 0.164 0.836
#> GSM329714     2   0.634      0.894 0.160 0.840
#> GSM329693     2   0.456      0.911 0.096 0.904
#> GSM329696     2   0.456      0.911 0.096 0.904
#> GSM329699     2   0.000      0.920 0.000 1.000
#> GSM329702     2   0.644      0.892 0.164 0.836
#> GSM329706     2   0.000      0.920 0.000 1.000
#> GSM329708     2   0.000      0.920 0.000 1.000
#> GSM329710     2   0.000      0.920 0.000 1.000
#> GSM329713     1   0.000      1.000 1.000 0.000
#> GSM329695     1   0.000      1.000 1.000 0.000
#> GSM329698     1   0.000      1.000 1.000 0.000
#> GSM329701     1   0.000      1.000 1.000 0.000
#> GSM329705     1   0.000      1.000 1.000 0.000
#> GSM329712     2   0.644      0.892 0.164 0.836
#> GSM329715     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
#> GSM329660     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329663     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329664     2  0.6280     0.0847 0.000 0.54 0.460
#> GSM329666     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329667     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329670     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329672     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329674     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329661     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329669     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329662     1  0.1753     0.9764 0.952 0.00 0.048
#> GSM329665     1  0.0000     0.9800 1.000 0.00 0.000
#> GSM329668     1  0.1289     0.9785 0.968 0.00 0.032
#> GSM329671     1  0.0592     0.9797 0.988 0.00 0.012
#> GSM329673     1  0.1753     0.9764 0.952 0.00 0.048
#> GSM329675     1  0.1753     0.9764 0.952 0.00 0.048
#> GSM329676     1  0.1753     0.9764 0.952 0.00 0.048
#> GSM329677     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329679     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329681     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329683     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329686     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329689     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329678     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329680     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329685     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329688     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329691     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329682     1  0.1643     0.9772 0.956 0.00 0.044
#> GSM329684     1  0.1753     0.9764 0.952 0.00 0.048
#> GSM329687     1  0.1643     0.9772 0.956 0.00 0.044
#> GSM329690     1  0.0592     0.9797 0.988 0.00 0.012
#> GSM329692     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329694     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329697     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329700     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329703     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329704     2  0.6280     0.0847 0.000 0.54 0.460
#> GSM329707     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329709     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329711     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329714     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329693     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329696     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329699     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329702     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329706     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329708     3  0.2066     1.0000 0.000 0.06 0.940
#> GSM329710     2  0.4291     0.7404 0.000 0.82 0.180
#> GSM329713     1  0.0592     0.9797 0.988 0.00 0.012
#> GSM329695     1  0.0592     0.9797 0.988 0.00 0.012
#> GSM329698     1  0.0592     0.9797 0.988 0.00 0.012
#> GSM329701     1  0.0592     0.9797 0.988 0.00 0.012
#> GSM329705     1  0.0424     0.9799 0.992 0.00 0.008
#> GSM329712     2  0.0000     0.9473 0.000 1.00 0.000
#> GSM329715     1  0.0592     0.9797 0.988 0.00 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM329660     2  0.0592      0.853 0.000 0.984 0.000 0.016
#> GSM329663     2  0.0592      0.857 0.000 0.984 0.000 0.016
#> GSM329664     2  0.6968      0.131 0.000 0.552 0.308 0.140
#> GSM329666     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> GSM329667     2  0.2921      0.713 0.000 0.860 0.000 0.140
#> GSM329670     2  0.0188      0.858 0.000 0.996 0.000 0.004
#> GSM329672     2  0.1022      0.848 0.000 0.968 0.000 0.032
#> GSM329674     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> GSM329661     3  0.1833      0.918 0.000 0.032 0.944 0.024
#> GSM329669     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> GSM329662     1  0.2805      0.881 0.888 0.000 0.012 0.100
#> GSM329665     1  0.2773      0.907 0.880 0.000 0.004 0.116
#> GSM329668     1  0.0657      0.905 0.984 0.000 0.004 0.012
#> GSM329671     1  0.3306      0.898 0.840 0.000 0.004 0.156
#> GSM329673     1  0.2805      0.881 0.888 0.000 0.012 0.100
#> GSM329675     1  0.2924      0.880 0.884 0.000 0.016 0.100
#> GSM329676     1  0.2401      0.886 0.904 0.000 0.004 0.092
#> GSM329677     3  0.2871      0.888 0.000 0.032 0.896 0.072
#> GSM329679     2  0.1022      0.848 0.000 0.968 0.000 0.032
#> GSM329681     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329683     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329686     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329689     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329678     3  0.5766      0.328 0.000 0.032 0.564 0.404
#> GSM329680     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329685     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329688     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329691     3  0.1022      0.930 0.000 0.032 0.968 0.000
#> GSM329682     1  0.1151      0.901 0.968 0.000 0.008 0.024
#> GSM329684     1  0.2924      0.880 0.884 0.000 0.016 0.100
#> GSM329687     1  0.1824      0.894 0.936 0.000 0.004 0.060
#> GSM329690     1  0.3591      0.895 0.824 0.000 0.008 0.168
#> GSM329692     4  0.5530      0.226 0.000 0.032 0.336 0.632
#> GSM329694     4  0.4679      0.712 0.000 0.352 0.000 0.648
#> GSM329697     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> GSM329700     2  0.3649      0.579 0.000 0.796 0.000 0.204
#> GSM329703     4  0.4925      0.716 0.000 0.428 0.000 0.572
#> GSM329704     4  0.7836      0.232 0.000 0.288 0.304 0.408
#> GSM329707     3  0.3638      0.857 0.000 0.032 0.848 0.120
#> GSM329709     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> GSM329711     2  0.3528      0.597 0.000 0.808 0.000 0.192
#> GSM329714     4  0.4972      0.667 0.000 0.456 0.000 0.544
#> GSM329693     4  0.4925      0.716 0.000 0.428 0.000 0.572
#> GSM329696     4  0.4925      0.716 0.000 0.428 0.000 0.572
#> GSM329699     4  0.4830      0.724 0.000 0.392 0.000 0.608
#> GSM329702     2  0.0000      0.860 0.000 1.000 0.000 0.000
#> GSM329706     3  0.4833      0.745 0.000 0.032 0.740 0.228
#> GSM329708     3  0.1833      0.918 0.000 0.032 0.944 0.024
#> GSM329710     4  0.5717      0.701 0.000 0.324 0.044 0.632
#> GSM329713     1  0.3672      0.895 0.824 0.000 0.012 0.164
#> GSM329695     1  0.3672      0.895 0.824 0.000 0.012 0.164
#> GSM329698     1  0.3672      0.895 0.824 0.000 0.012 0.164
#> GSM329701     1  0.3172      0.897 0.840 0.000 0.000 0.160
#> GSM329705     1  0.2342      0.906 0.912 0.000 0.008 0.080
#> GSM329712     2  0.3528      0.597 0.000 0.808 0.000 0.192
#> GSM329715     1  0.3172      0.897 0.840 0.000 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
#> GSM329660     2  0.3180     0.7978 0.000 0.856 0.000 0.076 0.068
#> GSM329663     2  0.0865     0.8542 0.000 0.972 0.000 0.004 0.024
#> GSM329664     5  0.7602    -0.0804 0.000 0.304 0.192 0.068 0.436
#> GSM329666     2  0.0794     0.8602 0.000 0.972 0.000 0.000 0.028
#> GSM329667     2  0.5538     0.2987 0.000 0.504 0.000 0.068 0.428
#> GSM329670     2  0.0162     0.8549 0.000 0.996 0.000 0.000 0.004
#> GSM329672     2  0.2361     0.8314 0.000 0.892 0.000 0.012 0.096
#> GSM329674     2  0.0794     0.8602 0.000 0.972 0.000 0.000 0.028
#> GSM329661     3  0.2459     0.8373 0.000 0.004 0.904 0.052 0.040
#> GSM329669     2  0.0162     0.8549 0.000 0.996 0.000 0.000 0.004
#> GSM329662     1  0.4304     0.4163 0.516 0.000 0.000 0.000 0.484
#> GSM329665     1  0.3171     0.7018 0.816 0.000 0.000 0.008 0.176
#> GSM329668     1  0.3845     0.6716 0.760 0.000 0.004 0.012 0.224
#> GSM329671     1  0.0290     0.7291 0.992 0.000 0.000 0.008 0.000
#> GSM329673     1  0.4448     0.4132 0.516 0.000 0.000 0.004 0.480
#> GSM329675     5  0.4747    -0.5438 0.484 0.000 0.000 0.016 0.500
#> GSM329676     1  0.4268     0.4688 0.556 0.000 0.000 0.000 0.444
#> GSM329677     3  0.5324     0.5481 0.000 0.004 0.600 0.056 0.340
#> GSM329679     2  0.2361     0.8314 0.000 0.892 0.000 0.012 0.096
#> GSM329681     3  0.0613     0.8694 0.000 0.004 0.984 0.008 0.004
#> GSM329683     3  0.0324     0.8704 0.000 0.004 0.992 0.000 0.004
#> GSM329686     3  0.0162     0.8706 0.000 0.004 0.996 0.000 0.000
#> GSM329689     3  0.0324     0.8704 0.000 0.004 0.992 0.000 0.004
#> GSM329678     4  0.4499     0.1615 0.000 0.004 0.408 0.584 0.004
#> GSM329680     3  0.1205     0.8594 0.000 0.004 0.956 0.040 0.000
#> GSM329685     3  0.0162     0.8706 0.000 0.004 0.996 0.000 0.000
#> GSM329688     3  0.0162     0.8706 0.000 0.004 0.996 0.000 0.000
#> GSM329691     3  0.0162     0.8706 0.000 0.004 0.996 0.000 0.000
#> GSM329682     1  0.4335     0.5985 0.664 0.000 0.004 0.008 0.324
#> GSM329684     5  0.4747    -0.5438 0.484 0.000 0.000 0.016 0.500
#> GSM329687     1  0.4426     0.5453 0.612 0.000 0.004 0.004 0.380
#> GSM329690     1  0.1851     0.7118 0.912 0.000 0.000 0.088 0.000
#> GSM329692     4  0.3205     0.6315 0.000 0.004 0.176 0.816 0.004
#> GSM329694     4  0.4537     0.7895 0.000 0.184 0.000 0.740 0.076
#> GSM329697     2  0.0794     0.8602 0.000 0.972 0.000 0.000 0.028
#> GSM329700     2  0.4054     0.6325 0.000 0.748 0.000 0.224 0.028
#> GSM329703     4  0.3366     0.8232 0.000 0.232 0.000 0.768 0.000
#> GSM329704     5  0.8029    -0.0797 0.000 0.144 0.180 0.240 0.436
#> GSM329707     3  0.5409     0.5383 0.000 0.004 0.588 0.060 0.348
#> GSM329709     2  0.0794     0.8602 0.000 0.972 0.000 0.000 0.028
#> GSM329711     2  0.3551     0.6443 0.000 0.772 0.000 0.220 0.008
#> GSM329714     4  0.4712     0.7554 0.000 0.268 0.000 0.684 0.048
#> GSM329693     4  0.3366     0.8232 0.000 0.232 0.000 0.768 0.000
#> GSM329696     4  0.3366     0.8232 0.000 0.232 0.000 0.768 0.000
#> GSM329699     4  0.3366     0.8232 0.000 0.232 0.000 0.768 0.000
#> GSM329702     2  0.0794     0.8602 0.000 0.972 0.000 0.000 0.028
#> GSM329706     3  0.6370     0.4213 0.000 0.004 0.500 0.156 0.340
#> GSM329708     3  0.2536     0.8346 0.000 0.004 0.900 0.052 0.044
#> GSM329710     4  0.3360     0.8042 0.000 0.168 0.012 0.816 0.004
#> GSM329713     1  0.1851     0.7126 0.912 0.000 0.000 0.088 0.000
#> GSM329695     1  0.1851     0.7126 0.912 0.000 0.000 0.088 0.000
#> GSM329698     1  0.1792     0.7126 0.916 0.000 0.000 0.084 0.000
#> GSM329701     1  0.0000     0.7295 1.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.2233     0.7230 0.892 0.000 0.000 0.004 0.104
#> GSM329712     2  0.3551     0.6443 0.000 0.772 0.000 0.220 0.008
#> GSM329715     1  0.0162     0.7301 0.996 0.000 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM329660     2  0.5113     0.6867 0.000 0.704 0.000 0.096 0.140 0.060
#> GSM329663     2  0.2772     0.7835 0.000 0.864 0.000 0.004 0.040 0.092
#> GSM329664     5  0.4141     0.6366 0.000 0.140 0.084 0.012 0.764 0.000
#> GSM329666     2  0.2250     0.8129 0.000 0.896 0.000 0.000 0.040 0.064
#> GSM329667     5  0.4391     0.4063 0.000 0.236 0.000 0.012 0.704 0.048
#> GSM329670     2  0.1588     0.7941 0.000 0.924 0.000 0.000 0.004 0.072
#> GSM329672     2  0.4391     0.7465 0.000 0.720 0.000 0.004 0.188 0.088
#> GSM329674     2  0.2250     0.8129 0.000 0.896 0.000 0.000 0.040 0.064
#> GSM329661     3  0.3940     0.8175 0.000 0.000 0.796 0.040 0.048 0.116
#> GSM329669     2  0.0405     0.8052 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM329662     1  0.0993     0.6933 0.964 0.000 0.000 0.012 0.024 0.000
#> GSM329665     1  0.4577     0.0804 0.684 0.000 0.000 0.012 0.056 0.248
#> GSM329668     1  0.4276     0.4195 0.748 0.000 0.000 0.024 0.052 0.176
#> GSM329671     6  0.5318     0.7493 0.452 0.000 0.000 0.020 0.056 0.472
#> GSM329673     1  0.1074     0.6927 0.960 0.000 0.000 0.012 0.028 0.000
#> GSM329675     1  0.2633     0.6455 0.864 0.000 0.000 0.032 0.104 0.000
#> GSM329676     1  0.0436     0.6916 0.988 0.000 0.000 0.004 0.004 0.004
#> GSM329677     5  0.4939     0.5424 0.000 0.000 0.380 0.004 0.556 0.060
#> GSM329679     2  0.4391     0.7465 0.000 0.720 0.000 0.004 0.188 0.088
#> GSM329681     3  0.2009     0.9000 0.000 0.000 0.904 0.008 0.004 0.084
#> GSM329683     3  0.0692     0.9218 0.000 0.000 0.976 0.000 0.004 0.020
#> GSM329686     3  0.0000     0.9259 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.1588     0.9034 0.000 0.000 0.924 0.004 0.000 0.072
#> GSM329678     4  0.4365     0.4438 0.000 0.000 0.292 0.664 0.004 0.040
#> GSM329680     3  0.1890     0.8988 0.000 0.000 0.916 0.024 0.000 0.060
#> GSM329685     3  0.0000     0.9259 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000     0.9259 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000     0.9259 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.2982     0.5725 0.820 0.000 0.000 0.012 0.004 0.164
#> GSM329684     1  0.2633     0.6455 0.864 0.000 0.000 0.032 0.104 0.000
#> GSM329687     1  0.2213     0.6502 0.888 0.000 0.000 0.008 0.004 0.100
#> GSM329690     6  0.4625     0.8228 0.356 0.000 0.000 0.020 0.020 0.604
#> GSM329692     4  0.2554     0.7282 0.000 0.000 0.092 0.876 0.004 0.028
#> GSM329694     4  0.4635     0.7535 0.000 0.092 0.000 0.736 0.140 0.032
#> GSM329697     2  0.2308     0.8128 0.000 0.892 0.000 0.000 0.040 0.068
#> GSM329700     2  0.5427     0.5623 0.000 0.644 0.000 0.224 0.048 0.084
#> GSM329703     4  0.2362     0.8379 0.000 0.136 0.000 0.860 0.000 0.004
#> GSM329704     5  0.4461     0.6294 0.000 0.056 0.080 0.100 0.764 0.000
#> GSM329707     5  0.5207     0.5699 0.000 0.000 0.352 0.012 0.564 0.072
#> GSM329709     2  0.2250     0.8129 0.000 0.896 0.000 0.000 0.040 0.064
#> GSM329711     2  0.3893     0.6253 0.000 0.744 0.000 0.220 0.020 0.016
#> GSM329714     4  0.5610     0.6100 0.000 0.244 0.000 0.620 0.060 0.076
#> GSM329693     4  0.2362     0.8379 0.000 0.136 0.000 0.860 0.000 0.004
#> GSM329696     4  0.2219     0.8384 0.000 0.136 0.000 0.864 0.000 0.000
#> GSM329699     4  0.2278     0.8394 0.000 0.128 0.000 0.868 0.000 0.004
#> GSM329702     2  0.2250     0.8129 0.000 0.896 0.000 0.000 0.040 0.064
#> GSM329706     5  0.5653     0.5930 0.000 0.000 0.328 0.052 0.560 0.060
#> GSM329708     3  0.3755     0.8168 0.000 0.000 0.812 0.036 0.052 0.100
#> GSM329710     4  0.2675     0.8141 0.000 0.080 0.012 0.880 0.004 0.024
#> GSM329713     6  0.4411     0.8365 0.356 0.000 0.000 0.028 0.004 0.612
#> GSM329695     6  0.4411     0.8365 0.356 0.000 0.000 0.028 0.004 0.612
#> GSM329698     6  0.3874     0.8376 0.356 0.000 0.000 0.000 0.008 0.636
#> GSM329701     6  0.4832     0.7785 0.440 0.000 0.000 0.012 0.032 0.516
#> GSM329705     1  0.4888    -0.3095 0.592 0.000 0.000 0.020 0.036 0.352
#> GSM329712     2  0.3893     0.6253 0.000 0.744 0.000 0.220 0.020 0.016
#> GSM329715     6  0.4832     0.7785 0.440 0.000 0.000 0.012 0.032 0.516

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-kmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-kmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> MAD:kmeans 56         5.06e-01  5.82e-11 2
#> MAD:kmeans 54         8.47e-04  7.20e-10 3
#> MAD:kmeans 52         1.31e-04  2.07e-09 4
#> MAD:kmeans 46         9.45e-05  2.01e-07 5
#> MAD:kmeans 51         6.20e-05  2.23e-07 6

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


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

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

collect_plots(res)

plot of chunk MAD-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           1.000       1.000         0.4311 0.569   0.569
#> 3 3 1.000           0.971       0.987         0.5696 0.753   0.567
#> 4 4 0.959           0.947       0.976         0.1093 0.910   0.730
#> 5 5 0.916           0.881       0.936         0.0478 0.952   0.812
#> 6 6 0.834           0.626       0.821         0.0391 0.972   0.872

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.0000      0.988  0 1.000 0.000
#> GSM329663     2  0.0000      0.988  0 1.000 0.000
#> GSM329664     3  0.1289      0.944  0 0.032 0.968
#> GSM329666     2  0.0000      0.988  0 1.000 0.000
#> GSM329667     2  0.0000      0.988  0 1.000 0.000
#> GSM329670     2  0.0000      0.988  0 1.000 0.000
#> GSM329672     2  0.0000      0.988  0 1.000 0.000
#> GSM329674     2  0.0000      0.988  0 1.000 0.000
#> GSM329661     3  0.0000      0.970  0 0.000 1.000
#> GSM329669     2  0.0000      0.988  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.970  0 0.000 1.000
#> GSM329679     2  0.0000      0.988  0 1.000 0.000
#> GSM329681     3  0.0000      0.970  0 0.000 1.000
#> GSM329683     3  0.0000      0.970  0 0.000 1.000
#> GSM329686     3  0.0000      0.970  0 0.000 1.000
#> GSM329689     3  0.0000      0.970  0 0.000 1.000
#> GSM329678     3  0.0000      0.970  0 0.000 1.000
#> GSM329680     3  0.0000      0.970  0 0.000 1.000
#> GSM329685     3  0.0000      0.970  0 0.000 1.000
#> GSM329688     3  0.0000      0.970  0 0.000 1.000
#> GSM329691     3  0.0000      0.970  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     3  0.0000      0.970  0 0.000 1.000
#> GSM329694     3  0.5431      0.613  0 0.284 0.716
#> GSM329697     2  0.0000      0.988  0 1.000 0.000
#> GSM329700     2  0.0000      0.988  0 1.000 0.000
#> GSM329703     2  0.0424      0.982  0 0.992 0.008
#> GSM329704     3  0.0000      0.970  0 0.000 1.000
#> GSM329707     3  0.0000      0.970  0 0.000 1.000
#> GSM329709     2  0.0000      0.988  0 1.000 0.000
#> GSM329711     2  0.0000      0.988  0 1.000 0.000
#> GSM329714     2  0.0000      0.988  0 1.000 0.000
#> GSM329693     2  0.0000      0.988  0 1.000 0.000
#> GSM329696     2  0.2165      0.929  0 0.936 0.064
#> GSM329699     2  0.3752      0.832  0 0.856 0.144
#> GSM329702     2  0.0000      0.988  0 1.000 0.000
#> GSM329706     3  0.0000      0.970  0 0.000 1.000
#> GSM329708     3  0.0000      0.970  0 0.000 1.000
#> GSM329710     3  0.4555      0.752  0 0.200 0.800
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.988  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329663     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329664     3  0.1305      0.935  0 0.036 0.960 0.004
#> GSM329666     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329667     2  0.0188      0.942  0 0.996 0.000 0.004
#> GSM329670     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329672     2  0.0188      0.942  0 0.996 0.000 0.004
#> GSM329674     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329669     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329679     2  0.0188      0.942  0 0.996 0.000 0.004
#> GSM329681     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329678     3  0.4790      0.409  0 0.000 0.620 0.380
#> GSM329680     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0188      0.974  0 0.000 0.004 0.996
#> GSM329694     4  0.0000      0.974  0 0.000 0.000 1.000
#> GSM329697     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329700     2  0.3975      0.720  0 0.760 0.000 0.240
#> GSM329703     4  0.0188      0.976  0 0.004 0.000 0.996
#> GSM329704     3  0.1356      0.941  0 0.008 0.960 0.032
#> GSM329707     3  0.0188      0.966  0 0.000 0.996 0.004
#> GSM329709     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329711     2  0.3942      0.726  0 0.764 0.000 0.236
#> GSM329714     4  0.2921      0.820  0 0.140 0.000 0.860
#> GSM329693     4  0.0188      0.976  0 0.004 0.000 0.996
#> GSM329696     4  0.0188      0.976  0 0.004 0.000 0.996
#> GSM329699     4  0.0188      0.976  0 0.004 0.000 0.996
#> GSM329702     2  0.0000      0.944  0 1.000 0.000 0.000
#> GSM329706     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329708     3  0.0000      0.969  0 0.000 1.000 0.000
#> GSM329710     4  0.0188      0.974  0 0.000 0.004 0.996
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.3942      0.726  0 0.764 0.000 0.236
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.1121      0.926 0.000 0.956 0.000 0.000 0.044
#> GSM329663     2  0.0000      0.938 0.000 1.000 0.000 0.000 0.000
#> GSM329664     5  0.1671      0.710 0.000 0.000 0.076 0.000 0.924
#> GSM329666     2  0.0162      0.938 0.000 0.996 0.000 0.000 0.004
#> GSM329667     5  0.1671      0.627 0.000 0.076 0.000 0.000 0.924
#> GSM329670     2  0.0162      0.937 0.000 0.996 0.000 0.000 0.004
#> GSM329672     2  0.1671      0.898 0.000 0.924 0.000 0.000 0.076
#> GSM329674     2  0.0162      0.938 0.000 0.996 0.000 0.000 0.004
#> GSM329661     3  0.0162      0.942 0.000 0.000 0.996 0.000 0.004
#> GSM329669     2  0.1121      0.926 0.000 0.956 0.000 0.000 0.044
#> GSM329662     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> GSM329665     1  0.0000      0.991 1.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0162      0.991 0.996 0.000 0.000 0.000 0.004
#> GSM329671     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329673     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> GSM329675     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> GSM329676     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> GSM329677     5  0.4297      0.493 0.000 0.000 0.472 0.000 0.528
#> GSM329679     2  0.1671      0.898 0.000 0.924 0.000 0.000 0.076
#> GSM329681     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329683     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329686     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329689     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329678     3  0.4135      0.417 0.000 0.000 0.656 0.340 0.004
#> GSM329680     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.946 0.000 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0162      0.991 0.996 0.000 0.000 0.000 0.004
#> GSM329684     1  0.0404      0.989 0.988 0.000 0.000 0.000 0.012
#> GSM329687     1  0.0162      0.991 0.996 0.000 0.000 0.000 0.004
#> GSM329690     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329692     4  0.2612      0.764 0.000 0.000 0.124 0.868 0.008
#> GSM329694     4  0.4235      0.335 0.000 0.000 0.000 0.576 0.424
#> GSM329697     2  0.0162      0.938 0.000 0.996 0.000 0.000 0.004
#> GSM329700     2  0.3681      0.825 0.000 0.808 0.000 0.148 0.044
#> GSM329703     4  0.0000      0.882 0.000 0.000 0.000 1.000 0.000
#> GSM329704     5  0.1671      0.710 0.000 0.000 0.076 0.000 0.924
#> GSM329707     5  0.3932      0.663 0.000 0.000 0.328 0.000 0.672
#> GSM329709     2  0.0162      0.938 0.000 0.996 0.000 0.000 0.004
#> GSM329711     2  0.3595      0.833 0.000 0.816 0.000 0.140 0.044
#> GSM329714     4  0.3365      0.733 0.000 0.120 0.000 0.836 0.044
#> GSM329693     4  0.0000      0.882 0.000 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.882 0.000 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.882 0.000 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0162      0.938 0.000 0.996 0.000 0.000 0.004
#> GSM329706     5  0.4291      0.508 0.000 0.000 0.464 0.000 0.536
#> GSM329708     3  0.0290      0.938 0.000 0.000 0.992 0.000 0.008
#> GSM329710     4  0.0290      0.879 0.000 0.000 0.000 0.992 0.008
#> GSM329713     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329695     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329698     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329701     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329705     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012
#> GSM329712     2  0.3595      0.833 0.000 0.816 0.000 0.140 0.044
#> GSM329715     1  0.0404      0.991 0.988 0.000 0.000 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM329660     2  0.0937     0.0497 0.000 0.960 0.000 0.000 0.000 0.040
#> GSM329663     6  0.3810     0.9131 0.000 0.428 0.000 0.000 0.000 0.572
#> GSM329664     5  0.0547     0.7355 0.000 0.000 0.020 0.000 0.980 0.000
#> GSM329666     2  0.3823    -0.1924 0.000 0.564 0.000 0.000 0.000 0.436
#> GSM329667     5  0.1918     0.6787 0.000 0.008 0.000 0.000 0.904 0.088
#> GSM329670     6  0.3857     0.9121 0.000 0.468 0.000 0.000 0.000 0.532
#> GSM329672     2  0.4570    -0.2348 0.000 0.528 0.000 0.000 0.036 0.436
#> GSM329674     2  0.3823    -0.1924 0.000 0.564 0.000 0.000 0.000 0.436
#> GSM329661     3  0.0146     0.9351 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329669     2  0.1327    -0.0128 0.000 0.936 0.000 0.000 0.000 0.064
#> GSM329662     1  0.2212     0.8894 0.880 0.000 0.000 0.000 0.008 0.112
#> GSM329665     1  0.0547     0.9068 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM329668     1  0.1285     0.9047 0.944 0.000 0.000 0.000 0.004 0.052
#> GSM329671     1  0.2165     0.8915 0.884 0.000 0.000 0.000 0.008 0.108
#> GSM329673     1  0.2212     0.8894 0.880 0.000 0.000 0.000 0.008 0.112
#> GSM329675     1  0.2212     0.8894 0.880 0.000 0.000 0.000 0.008 0.112
#> GSM329676     1  0.2212     0.8894 0.880 0.000 0.000 0.000 0.008 0.112
#> GSM329677     5  0.3915     0.5248 0.000 0.000 0.412 0.000 0.584 0.004
#> GSM329679     2  0.4739    -0.2493 0.000 0.516 0.000 0.000 0.048 0.436
#> GSM329681     3  0.0260     0.9338 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM329683     3  0.0146     0.9351 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329686     3  0.0000     0.9358 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.0260     0.9338 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM329678     3  0.4750     0.1298 0.000 0.000 0.544 0.404 0.000 0.052
#> GSM329680     3  0.0000     0.9358 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000     0.9358 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000     0.9358 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000     0.9358 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.1462     0.9035 0.936 0.000 0.000 0.000 0.008 0.056
#> GSM329684     1  0.2212     0.8894 0.880 0.000 0.000 0.000 0.008 0.112
#> GSM329687     1  0.1643     0.9012 0.924 0.000 0.000 0.000 0.008 0.068
#> GSM329690     1  0.2257     0.8889 0.876 0.000 0.000 0.000 0.008 0.116
#> GSM329692     4  0.3121     0.8278 0.000 0.000 0.044 0.836 0.004 0.116
#> GSM329694     4  0.5238     0.5196 0.000 0.000 0.000 0.580 0.292 0.128
#> GSM329697     2  0.3823    -0.1924 0.000 0.564 0.000 0.000 0.000 0.436
#> GSM329700     2  0.4655     0.0194 0.000 0.680 0.000 0.112 0.000 0.208
#> GSM329703     4  0.0260     0.8908 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM329704     5  0.0547     0.7355 0.000 0.000 0.020 0.000 0.980 0.000
#> GSM329707     5  0.3081     0.7363 0.000 0.000 0.220 0.000 0.776 0.004
#> GSM329709     2  0.3823    -0.1924 0.000 0.564 0.000 0.000 0.000 0.436
#> GSM329711     2  0.2100     0.1388 0.000 0.884 0.000 0.112 0.000 0.004
#> GSM329714     2  0.5895    -0.1369 0.000 0.436 0.000 0.356 0.000 0.208
#> GSM329693     4  0.0260     0.8908 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM329696     4  0.0000     0.8904 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0260     0.8908 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM329702     2  0.3823    -0.1924 0.000 0.564 0.000 0.000 0.000 0.436
#> GSM329706     5  0.3887     0.6122 0.000 0.000 0.360 0.000 0.632 0.008
#> GSM329708     3  0.0260     0.9331 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM329710     4  0.2100     0.8578 0.000 0.000 0.000 0.884 0.004 0.112
#> GSM329713     1  0.2257     0.8889 0.876 0.000 0.000 0.000 0.008 0.116
#> GSM329695     1  0.2257     0.8889 0.876 0.000 0.000 0.000 0.008 0.116
#> GSM329698     1  0.2257     0.8889 0.876 0.000 0.000 0.000 0.008 0.116
#> GSM329701     1  0.2165     0.8915 0.884 0.000 0.000 0.000 0.008 0.108
#> GSM329705     1  0.0632     0.9049 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM329712     2  0.2100     0.1388 0.000 0.884 0.000 0.112 0.000 0.004
#> GSM329715     1  0.2020     0.8943 0.896 0.000 0.000 0.000 0.008 0.096

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n disease.state(p) tissue(p) k
#> MAD:skmeans 56         0.505684  5.82e-11 2
#> MAD:skmeans 56         0.010546  4.13e-10 3
#> MAD:skmeans 55         0.000301  1.65e-09 4
#> MAD:skmeans 53         0.000127  6.91e-09 5
#> MAD:skmeans 42         0.000387  2.30e-07 6

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


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 21163 rows and 56 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.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 1.000           0.996       0.998         0.5402 0.766   0.590
#> 4 4 0.788           0.770       0.888         0.1322 0.850   0.588
#> 5 5 0.919           0.852       0.943         0.0627 0.942   0.770
#> 6 6 0.964           0.924       0.960         0.0271 0.968   0.846

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 5

There is also optional best \(k\) = 2 3 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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2   0.000      1.000  0 1.000 0.000
#> GSM329663     2   0.000      1.000  0 1.000 0.000
#> GSM329664     2   0.000      1.000  0 1.000 0.000
#> GSM329666     2   0.000      1.000  0 1.000 0.000
#> GSM329667     2   0.000      1.000  0 1.000 0.000
#> GSM329670     2   0.000      1.000  0 1.000 0.000
#> GSM329672     2   0.000      1.000  0 1.000 0.000
#> GSM329674     2   0.000      1.000  0 1.000 0.000
#> GSM329661     3   0.000      0.992  0 0.000 1.000
#> GSM329669     2   0.000      1.000  0 1.000 0.000
#> GSM329662     1   0.000      1.000  1 0.000 0.000
#> GSM329665     1   0.000      1.000  1 0.000 0.000
#> GSM329668     1   0.000      1.000  1 0.000 0.000
#> GSM329671     1   0.000      1.000  1 0.000 0.000
#> GSM329673     1   0.000      1.000  1 0.000 0.000
#> GSM329675     1   0.000      1.000  1 0.000 0.000
#> GSM329676     1   0.000      1.000  1 0.000 0.000
#> GSM329677     3   0.000      0.992  0 0.000 1.000
#> GSM329679     2   0.000      1.000  0 1.000 0.000
#> GSM329681     3   0.000      0.992  0 0.000 1.000
#> GSM329683     3   0.000      0.992  0 0.000 1.000
#> GSM329686     3   0.000      0.992  0 0.000 1.000
#> GSM329689     3   0.000      0.992  0 0.000 1.000
#> GSM329678     3   0.000      0.992  0 0.000 1.000
#> GSM329680     3   0.000      0.992  0 0.000 1.000
#> GSM329685     3   0.000      0.992  0 0.000 1.000
#> GSM329688     3   0.000      0.992  0 0.000 1.000
#> GSM329691     3   0.000      0.992  0 0.000 1.000
#> GSM329682     1   0.000      1.000  1 0.000 0.000
#> GSM329684     1   0.000      1.000  1 0.000 0.000
#> GSM329687     1   0.000      1.000  1 0.000 0.000
#> GSM329690     1   0.000      1.000  1 0.000 0.000
#> GSM329692     3   0.141      0.961  0 0.036 0.964
#> GSM329694     2   0.000      1.000  0 1.000 0.000
#> GSM329697     2   0.000      1.000  0 1.000 0.000
#> GSM329700     2   0.000      1.000  0 1.000 0.000
#> GSM329703     2   0.000      1.000  0 1.000 0.000
#> GSM329704     2   0.000      1.000  0 1.000 0.000
#> GSM329707     3   0.207      0.936  0 0.060 0.940
#> GSM329709     2   0.000      1.000  0 1.000 0.000
#> GSM329711     2   0.000      1.000  0 1.000 0.000
#> GSM329714     2   0.000      1.000  0 1.000 0.000
#> GSM329693     2   0.000      1.000  0 1.000 0.000
#> GSM329696     2   0.000      1.000  0 1.000 0.000
#> GSM329699     2   0.000      1.000  0 1.000 0.000
#> GSM329702     2   0.000      1.000  0 1.000 0.000
#> GSM329706     3   0.000      0.992  0 0.000 1.000
#> GSM329708     3   0.000      0.992  0 0.000 1.000
#> GSM329710     2   0.000      1.000  0 1.000 0.000
#> GSM329713     1   0.000      1.000  1 0.000 0.000
#> GSM329695     1   0.000      1.000  1 0.000 0.000
#> GSM329698     1   0.000      1.000  1 0.000 0.000
#> GSM329701     1   0.000      1.000  1 0.000 0.000
#> GSM329705     1   0.000      1.000  1 0.000 0.000
#> GSM329712     2   0.000      1.000  0 1.000 0.000
#> GSM329715     1   0.000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.3942      0.729  0 0.764 0.000 0.236
#> GSM329663     2  0.0921      0.816  0 0.972 0.000 0.028
#> GSM329664     4  0.4999      0.326  0 0.492 0.000 0.508
#> GSM329666     2  0.0000      0.834  0 1.000 0.000 0.000
#> GSM329667     4  0.4999      0.326  0 0.492 0.000 0.508
#> GSM329670     2  0.3610      0.762  0 0.800 0.000 0.200
#> GSM329672     2  0.2814      0.689  0 0.868 0.000 0.132
#> GSM329674     2  0.0188      0.834  0 0.996 0.000 0.004
#> GSM329661     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329669     2  0.3610      0.762  0 0.800 0.000 0.200
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.2647      0.813  0 0.000 0.880 0.120
#> GSM329679     2  0.2704      0.697  0 0.876 0.000 0.124
#> GSM329681     3  0.4907      0.156  0 0.000 0.580 0.420
#> GSM329683     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329678     4  0.3764      0.517  0 0.000 0.216 0.784
#> GSM329680     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.3668      0.540  0 0.004 0.188 0.808
#> GSM329694     4  0.4999      0.326  0 0.492 0.000 0.508
#> GSM329697     2  0.0000      0.834  0 1.000 0.000 0.000
#> GSM329700     4  0.4888      0.216  0 0.412 0.000 0.588
#> GSM329703     4  0.2704      0.582  0 0.124 0.000 0.876
#> GSM329704     4  0.4999      0.326  0 0.492 0.000 0.508
#> GSM329707     4  0.7216      0.378  0 0.156 0.336 0.508
#> GSM329709     2  0.0000      0.834  0 1.000 0.000 0.000
#> GSM329711     2  0.3649      0.759  0 0.796 0.000 0.204
#> GSM329714     4  0.2704      0.582  0 0.124 0.000 0.876
#> GSM329693     4  0.2704      0.582  0 0.124 0.000 0.876
#> GSM329696     4  0.2704      0.582  0 0.124 0.000 0.876
#> GSM329699     4  0.0336      0.613  0 0.008 0.000 0.992
#> GSM329702     2  0.0000      0.834  0 1.000 0.000 0.000
#> GSM329706     4  0.4948      0.110  0 0.000 0.440 0.560
#> GSM329708     3  0.0000      0.935  0 0.000 1.000 0.000
#> GSM329710     4  0.3610      0.582  0 0.200 0.000 0.800
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.3649      0.759  0 0.796 0.000 0.204
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329663     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329664     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329666     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329667     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329670     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329672     2   0.314     0.6576  0 0.796 0.000 0.000 0.204
#> GSM329674     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329661     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329669     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329662     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329665     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329668     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329671     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329673     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329675     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329676     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329677     5   0.228     0.8337  0 0.000 0.120 0.000 0.880
#> GSM329679     2   0.420     0.2700  0 0.592 0.000 0.000 0.408
#> GSM329681     3   0.337     0.6836  0 0.000 0.768 0.000 0.232
#> GSM329683     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329686     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329689     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329678     4   0.455     0.0484  0 0.000 0.008 0.532 0.460
#> GSM329680     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329685     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329688     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329691     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329682     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329684     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329687     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329690     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329692     4   0.314     0.7066  0 0.000 0.000 0.796 0.204
#> GSM329694     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329697     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329700     4   0.402     0.3468  0 0.348 0.000 0.652 0.000
#> GSM329703     4   0.000     0.8151  0 0.000 0.000 1.000 0.000
#> GSM329704     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329707     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329709     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329711     2   0.429     0.0933  0 0.532 0.000 0.468 0.000
#> GSM329714     4   0.359     0.6479  0 0.000 0.000 0.736 0.264
#> GSM329693     4   0.000     0.8151  0 0.000 0.000 1.000 0.000
#> GSM329696     4   0.000     0.8151  0 0.000 0.000 1.000 0.000
#> GSM329699     4   0.000     0.8151  0 0.000 0.000 1.000 0.000
#> GSM329702     2   0.000     0.8327  0 1.000 0.000 0.000 0.000
#> GSM329706     5   0.000     0.9770  0 0.000 0.000 0.000 1.000
#> GSM329708     3   0.000     0.9720  0 0.000 1.000 0.000 0.000
#> GSM329710     4   0.000     0.8151  0 0.000 0.000 1.000 0.000
#> GSM329713     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329695     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329698     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329701     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329705     1   0.000     1.0000  1 0.000 0.000 0.000 0.000
#> GSM329712     2   0.429     0.0933  0 0.532 0.000 0.468 0.000
#> GSM329715     1   0.000     1.0000  1 0.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
#> GSM329660     6  0.1501      0.869  0 0.000 0.000 0.000 0.076 0.924
#> GSM329663     2  0.0146      0.901  0 0.996 0.000 0.000 0.000 0.004
#> GSM329664     5  0.0146      0.960  0 0.000 0.000 0.000 0.996 0.004
#> GSM329666     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.0146      0.960  0 0.000 0.000 0.000 0.996 0.004
#> GSM329670     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> GSM329672     2  0.2902      0.728  0 0.800 0.000 0.000 0.196 0.004
#> GSM329674     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.1588      0.931  0 0.000 0.924 0.000 0.004 0.072
#> GSM329669     6  0.2597      0.859  0 0.176 0.000 0.000 0.000 0.824
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329677     5  0.3405      0.757  0 0.000 0.112 0.000 0.812 0.076
#> GSM329679     2  0.3955      0.262  0 0.560 0.000 0.000 0.436 0.004
#> GSM329681     3  0.3979      0.747  0 0.000 0.752 0.000 0.172 0.076
#> GSM329683     3  0.1644      0.930  0 0.000 0.920 0.000 0.004 0.076
#> GSM329686     3  0.0000      0.951  0 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.1644      0.930  0 0.000 0.920 0.000 0.004 0.076
#> GSM329678     4  0.0146      0.934  0 0.000 0.000 0.996 0.004 0.000
#> GSM329680     3  0.0000      0.951  0 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000      0.951  0 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.951  0 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.951  0 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329692     4  0.2823      0.761  0 0.000 0.000 0.796 0.204 0.000
#> GSM329694     5  0.0146      0.960  0 0.000 0.000 0.000 0.996 0.004
#> GSM329697     2  0.0146      0.901  0 0.996 0.000 0.000 0.000 0.004
#> GSM329700     6  0.1501      0.945  0 0.076 0.000 0.000 0.000 0.924
#> GSM329703     4  0.0000      0.936  0 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.0146      0.960  0 0.000 0.000 0.000 0.996 0.004
#> GSM329707     5  0.0000      0.958  0 0.000 0.000 0.000 1.000 0.000
#> GSM329709     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.1501      0.945  0 0.076 0.000 0.000 0.000 0.924
#> GSM329714     4  0.3806      0.758  0 0.000 0.000 0.772 0.076 0.152
#> GSM329693     4  0.0000      0.936  0 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000      0.936  0 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.936  0 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000      0.902  0 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.0146      0.958  0 0.000 0.000 0.004 0.996 0.000
#> GSM329708     3  0.0000      0.951  0 0.000 1.000 0.000 0.000 0.000
#> GSM329710     4  0.0000      0.936  0 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.1501      0.945  0 0.076 0.000 0.000 0.000 0.924
#> GSM329715     1  0.0000      1.000  1 0.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-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-pam-collect-classes

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

test_to_known_factors(res)
#>          n disease.state(p) tissue(p) k
#> MAD:pam 56         5.06e-01  5.82e-11 2
#> MAD:pam 56         5.28e-04  2.02e-10 3
#> MAD:pam 48         2.88e-04  9.55e-09 4
#> MAD:pam 51         8.28e-05  3.04e-09 5
#> MAD:pam 55         8.10e-04  6.32e-09 6

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


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 21163 rows and 56 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.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 0.819           0.893       0.937         0.5143 0.766   0.590
#> 4 4 0.829           0.771       0.908         0.1390 0.845   0.580
#> 5 5 0.917           0.905       0.945         0.0601 0.912   0.676
#> 6 6 0.935           0.858       0.928         0.0403 0.944   0.744

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.2165      0.916  0 0.936 0.064
#> GSM329663     2  0.2165      0.916  0 0.936 0.064
#> GSM329664     3  0.5882      0.522  0 0.348 0.652
#> GSM329666     2  0.0424      0.899  0 0.992 0.008
#> GSM329667     2  0.3752      0.863  0 0.856 0.144
#> GSM329670     2  0.0424      0.899  0 0.992 0.008
#> GSM329672     2  0.2165      0.916  0 0.936 0.064
#> GSM329674     2  0.0424      0.899  0 0.992 0.008
#> GSM329661     3  0.0000      0.890  0 0.000 1.000
#> GSM329669     2  0.0424      0.899  0 0.992 0.008
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.890  0 0.000 1.000
#> GSM329679     2  0.2165      0.916  0 0.936 0.064
#> GSM329681     3  0.0000      0.890  0 0.000 1.000
#> GSM329683     3  0.0000      0.890  0 0.000 1.000
#> GSM329686     3  0.0000      0.890  0 0.000 1.000
#> GSM329689     3  0.0000      0.890  0 0.000 1.000
#> GSM329678     2  0.4504      0.845  0 0.804 0.196
#> GSM329680     3  0.0000      0.890  0 0.000 1.000
#> GSM329685     3  0.0000      0.890  0 0.000 1.000
#> GSM329688     3  0.0000      0.890  0 0.000 1.000
#> GSM329691     3  0.0000      0.890  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     2  0.4504      0.845  0 0.804 0.196
#> GSM329694     2  0.2796      0.909  0 0.908 0.092
#> GSM329697     2  0.0747      0.903  0 0.984 0.016
#> GSM329700     2  0.1964      0.917  0 0.944 0.056
#> GSM329703     2  0.4504      0.845  0 0.804 0.196
#> GSM329704     3  0.6302      0.135  0 0.480 0.520
#> GSM329707     3  0.5678      0.572  0 0.316 0.684
#> GSM329709     2  0.0592      0.901  0 0.988 0.012
#> GSM329711     2  0.1964      0.917  0 0.944 0.056
#> GSM329714     2  0.2537      0.913  0 0.920 0.080
#> GSM329693     2  0.4504      0.845  0 0.804 0.196
#> GSM329696     2  0.4504      0.845  0 0.804 0.196
#> GSM329699     2  0.4504      0.845  0 0.804 0.196
#> GSM329702     2  0.0424      0.899  0 0.992 0.008
#> GSM329706     3  0.4796      0.672  0 0.220 0.780
#> GSM329708     3  0.0424      0.884  0 0.008 0.992
#> GSM329710     2  0.4504      0.845  0 0.804 0.196
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.1964      0.917  0 0.944 0.056
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     4  0.4877      0.328  0 0.408 0.000 0.592
#> GSM329663     2  0.2760      0.746  0 0.872 0.000 0.128
#> GSM329664     2  0.3539      0.671  0 0.820 0.176 0.004
#> GSM329666     2  0.0000      0.732  0 1.000 0.000 0.000
#> GSM329667     2  0.3486      0.732  0 0.812 0.000 0.188
#> GSM329670     2  0.4967     -0.195  0 0.548 0.000 0.452
#> GSM329672     2  0.3356      0.737  0 0.824 0.000 0.176
#> GSM329674     2  0.0000      0.732  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329669     2  0.4967     -0.195  0 0.548 0.000 0.452
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.4907      0.281  0 0.420 0.580 0.000
#> GSM329679     2  0.3356      0.737  0 0.824 0.000 0.176
#> GSM329681     3  0.1022      0.924  0 0.032 0.968 0.000
#> GSM329683     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329678     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329680     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329694     2  0.3649      0.721  0 0.796 0.000 0.204
#> GSM329697     2  0.1211      0.744  0 0.960 0.000 0.040
#> GSM329700     4  0.4804      0.373  0 0.384 0.000 0.616
#> GSM329703     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329704     2  0.3610      0.724  0 0.800 0.000 0.200
#> GSM329707     2  0.4348      0.650  0 0.780 0.196 0.024
#> GSM329709     2  0.0817      0.741  0 0.976 0.000 0.024
#> GSM329711     4  0.4925      0.315  0 0.428 0.000 0.572
#> GSM329714     2  0.4967     -0.195  0 0.548 0.000 0.452
#> GSM329693     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329696     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329699     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329702     2  0.0000      0.732  0 1.000 0.000 0.000
#> GSM329706     2  0.4323      0.714  0 0.776 0.020 0.204
#> GSM329708     3  0.0000      0.950  0 0.000 1.000 0.000
#> GSM329710     4  0.0000      0.782  0 0.000 0.000 1.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     4  0.4679      0.398  0 0.352 0.000 0.648
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     2  0.1851      0.920  0 0.912 0.000 0.088 0.000
#> GSM329663     2  0.1851      0.921  0 0.912 0.000 0.088 0.000
#> GSM329664     5  0.0404      0.888  0 0.012 0.000 0.000 0.988
#> GSM329666     2  0.0162      0.944  0 0.996 0.000 0.000 0.004
#> GSM329667     5  0.3182      0.873  0 0.032 0.000 0.124 0.844
#> GSM329670     2  0.0162      0.944  0 0.996 0.000 0.000 0.004
#> GSM329672     2  0.2011      0.920  0 0.908 0.000 0.088 0.004
#> GSM329674     2  0.0162      0.944  0 0.996 0.000 0.000 0.004
#> GSM329661     3  0.0880      0.950  0 0.000 0.968 0.000 0.032
#> GSM329669     2  0.0162      0.944  0 0.996 0.000 0.000 0.004
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     5  0.0963      0.867  0 0.000 0.036 0.000 0.964
#> GSM329679     2  0.1768      0.932  0 0.924 0.000 0.072 0.004
#> GSM329681     3  0.3242      0.792  0 0.000 0.784 0.000 0.216
#> GSM329683     3  0.0963      0.948  0 0.000 0.964 0.000 0.036
#> GSM329686     3  0.0000      0.959  0 0.000 1.000 0.000 0.000
#> GSM329689     3  0.2280      0.892  0 0.000 0.880 0.000 0.120
#> GSM329678     4  0.3039      0.621  0 0.000 0.192 0.808 0.000
#> GSM329680     3  0.0000      0.959  0 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.959  0 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.959  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.959  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.802  0 0.000 0.000 1.000 0.000
#> GSM329694     4  0.4101      0.583  0 0.332 0.000 0.664 0.004
#> GSM329697     2  0.1197      0.943  0 0.952 0.000 0.048 0.000
#> GSM329700     4  0.3636      0.700  0 0.272 0.000 0.728 0.000
#> GSM329703     4  0.0000      0.802  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.2818      0.884  0 0.012 0.000 0.132 0.856
#> GSM329707     5  0.0898      0.895  0 0.000 0.008 0.020 0.972
#> GSM329709     2  0.0880      0.946  0 0.968 0.000 0.032 0.000
#> GSM329711     4  0.3684      0.692  0 0.280 0.000 0.720 0.000
#> GSM329714     4  0.4972      0.605  0 0.336 0.000 0.620 0.044
#> GSM329693     4  0.0000      0.802  0 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000      0.802  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000      0.802  0 0.000 0.000 1.000 0.000
#> GSM329702     2  0.0162      0.944  0 0.996 0.000 0.000 0.004
#> GSM329706     5  0.2629      0.884  0 0.004 0.000 0.136 0.860
#> GSM329708     3  0.0000      0.959  0 0.000 1.000 0.000 0.000
#> GSM329710     4  0.0000      0.802  0 0.000 0.000 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     4  0.3561      0.711  0 0.260 0.000 0.740 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     6  0.3376    0.75262 0.000 0.220 0.000 0.016 0.000 0.764
#> GSM329663     2  0.3695    0.49635 0.000 0.712 0.000 0.016 0.000 0.272
#> GSM329664     5  0.2821    0.76611 0.000 0.152 0.000 0.000 0.832 0.016
#> GSM329666     2  0.0000    0.87288 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     2  0.4866   -0.13498 0.000 0.484 0.000 0.028 0.472 0.016
#> GSM329670     6  0.3126    0.73529 0.000 0.248 0.000 0.000 0.000 0.752
#> GSM329672     2  0.0713    0.85744 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM329674     2  0.0000    0.87288 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.0000    0.92335 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329669     6  0.3126    0.73529 0.000 0.248 0.000 0.000 0.000 0.752
#> GSM329662     1  0.0146    0.98656 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329665     1  0.0000    0.98671 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0146    0.98656 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329671     1  0.0146    0.98639 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329673     1  0.0146    0.98656 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329675     1  0.1556    0.93782 0.920 0.000 0.000 0.000 0.000 0.080
#> GSM329676     1  0.0146    0.98656 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329677     5  0.2048    0.77071 0.000 0.000 0.120 0.000 0.880 0.000
#> GSM329679     2  0.0632    0.86042 0.000 0.976 0.000 0.024 0.000 0.000
#> GSM329681     3  0.3756    0.42918 0.000 0.000 0.600 0.000 0.400 0.000
#> GSM329683     3  0.0363    0.91761 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM329686     3  0.0000    0.92335 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.3126    0.69917 0.000 0.000 0.752 0.000 0.248 0.000
#> GSM329678     4  0.0260    0.99008 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM329680     3  0.0000    0.92335 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000    0.92335 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000    0.92335 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000    0.92335 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0146    0.98656 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329684     1  0.1444    0.93892 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM329687     1  0.0146    0.98656 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM329690     1  0.0363    0.98561 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329692     4  0.0000    0.99835 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329694     6  0.6441   -0.00466 0.000 0.120 0.000 0.060 0.400 0.420
#> GSM329697     2  0.0000    0.87288 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6  0.2179    0.80924 0.000 0.036 0.000 0.064 0.000 0.900
#> GSM329703     4  0.0000    0.99835 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5  0.3740    0.78130 0.000 0.064 0.000 0.028 0.812 0.096
#> GSM329707     5  0.0146    0.84627 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM329709     2  0.0000    0.87288 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.2179    0.80905 0.000 0.036 0.000 0.064 0.000 0.900
#> GSM329714     6  0.2265    0.80291 0.000 0.052 0.000 0.052 0.000 0.896
#> GSM329693     4  0.0000    0.99835 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4  0.0000    0.99835 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000    0.99835 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.0000    0.87288 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5  0.0713    0.84887 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM329708     3  0.0363    0.91516 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM329710     4  0.0000    0.99835 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0363    0.98561 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329695     1  0.0363    0.98561 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329698     1  0.0363    0.98561 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329701     1  0.0363    0.98561 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM329705     1  0.0000    0.98671 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.2164    0.80680 0.000 0.032 0.000 0.068 0.000 0.900
#> GSM329715     1  0.0363    0.98561 0.988 0.000 0.000 0.000 0.000 0.012

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

plot of chunk tab-MAD-mclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-MAD-mclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk MAD-mclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-MAD-mclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk MAD-mclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> MAD:mclust 56         5.06e-01  5.82e-11 2
#> MAD:mclust 55         4.15e-03  8.30e-10 3
#> MAD:mclust 48         7.93e-04  2.70e-10 4
#> MAD:mclust 56         5.03e-05  4.55e-09 5
#> MAD:mclust 52         1.36e-02  9.86e-09 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21163 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk MAD-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.963           0.982       0.991         0.4563 0.544   0.544
#> 3 3 0.975           0.927       0.974         0.4772 0.731   0.527
#> 4 4 0.778           0.752       0.873         0.1144 0.899   0.699
#> 5 5 0.703           0.527       0.783         0.0247 0.951   0.819
#> 6 6 0.692           0.501       0.687         0.0407 0.869   0.565

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
#> GSM329660     2   0.000      0.993 0.000 1.000
#> GSM329663     2   0.000      0.993 0.000 1.000
#> GSM329664     2   0.000      0.993 0.000 1.000
#> GSM329666     2   0.506      0.876 0.112 0.888
#> GSM329667     2   0.000      0.993 0.000 1.000
#> GSM329670     1   0.595      0.837 0.856 0.144
#> GSM329672     2   0.000      0.993 0.000 1.000
#> GSM329674     2   0.469      0.891 0.100 0.900
#> GSM329661     2   0.000      0.993 0.000 1.000
#> GSM329669     1   0.494      0.881 0.892 0.108
#> GSM329662     1   0.000      0.986 1.000 0.000
#> GSM329665     1   0.000      0.986 1.000 0.000
#> GSM329668     1   0.000      0.986 1.000 0.000
#> GSM329671     1   0.000      0.986 1.000 0.000
#> GSM329673     1   0.000      0.986 1.000 0.000
#> GSM329675     1   0.000      0.986 1.000 0.000
#> GSM329676     1   0.000      0.986 1.000 0.000
#> GSM329677     2   0.000      0.993 0.000 1.000
#> GSM329679     2   0.000      0.993 0.000 1.000
#> GSM329681     2   0.000      0.993 0.000 1.000
#> GSM329683     2   0.000      0.993 0.000 1.000
#> GSM329686     2   0.000      0.993 0.000 1.000
#> GSM329689     2   0.000      0.993 0.000 1.000
#> GSM329678     2   0.000      0.993 0.000 1.000
#> GSM329680     2   0.000      0.993 0.000 1.000
#> GSM329685     2   0.000      0.993 0.000 1.000
#> GSM329688     2   0.000      0.993 0.000 1.000
#> GSM329691     2   0.000      0.993 0.000 1.000
#> GSM329682     1   0.000      0.986 1.000 0.000
#> GSM329684     1   0.000      0.986 1.000 0.000
#> GSM329687     1   0.000      0.986 1.000 0.000
#> GSM329690     1   0.000      0.986 1.000 0.000
#> GSM329692     2   0.000      0.993 0.000 1.000
#> GSM329694     2   0.000      0.993 0.000 1.000
#> GSM329697     2   0.000      0.993 0.000 1.000
#> GSM329700     2   0.000      0.993 0.000 1.000
#> GSM329703     2   0.000      0.993 0.000 1.000
#> GSM329704     2   0.000      0.993 0.000 1.000
#> GSM329707     2   0.000      0.993 0.000 1.000
#> GSM329709     2   0.000      0.993 0.000 1.000
#> GSM329711     2   0.000      0.993 0.000 1.000
#> GSM329714     2   0.000      0.993 0.000 1.000
#> GSM329693     2   0.000      0.993 0.000 1.000
#> GSM329696     2   0.000      0.993 0.000 1.000
#> GSM329699     2   0.000      0.993 0.000 1.000
#> GSM329702     2   0.204      0.964 0.032 0.968
#> GSM329706     2   0.000      0.993 0.000 1.000
#> GSM329708     2   0.000      0.993 0.000 1.000
#> GSM329710     2   0.000      0.993 0.000 1.000
#> GSM329713     1   0.000      0.986 1.000 0.000
#> GSM329695     1   0.000      0.986 1.000 0.000
#> GSM329698     1   0.000      0.986 1.000 0.000
#> GSM329701     1   0.000      0.986 1.000 0.000
#> GSM329705     1   0.000      0.986 1.000 0.000
#> GSM329712     2   0.000      0.993 0.000 1.000
#> GSM329715     1   0.000      0.986 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
#> GSM329660     2  0.0000     0.9730  0 1.000 0.000
#> GSM329663     2  0.0000     0.9730  0 1.000 0.000
#> GSM329664     3  0.6252     0.2264  0 0.444 0.556
#> GSM329666     2  0.0000     0.9730  0 1.000 0.000
#> GSM329667     2  0.0000     0.9730  0 1.000 0.000
#> GSM329670     2  0.0000     0.9730  0 1.000 0.000
#> GSM329672     2  0.0000     0.9730  0 1.000 0.000
#> GSM329674     2  0.0000     0.9730  0 1.000 0.000
#> GSM329661     3  0.0000     0.9386  0 0.000 1.000
#> GSM329669     2  0.0000     0.9730  0 1.000 0.000
#> GSM329662     1  0.0000     1.0000  1 0.000 0.000
#> GSM329665     1  0.0000     1.0000  1 0.000 0.000
#> GSM329668     1  0.0000     1.0000  1 0.000 0.000
#> GSM329671     1  0.0000     1.0000  1 0.000 0.000
#> GSM329673     1  0.0000     1.0000  1 0.000 0.000
#> GSM329675     1  0.0000     1.0000  1 0.000 0.000
#> GSM329676     1  0.0000     1.0000  1 0.000 0.000
#> GSM329677     3  0.0000     0.9386  0 0.000 1.000
#> GSM329679     2  0.0000     0.9730  0 1.000 0.000
#> GSM329681     3  0.0000     0.9386  0 0.000 1.000
#> GSM329683     3  0.0000     0.9386  0 0.000 1.000
#> GSM329686     3  0.0000     0.9386  0 0.000 1.000
#> GSM329689     3  0.0000     0.9386  0 0.000 1.000
#> GSM329678     3  0.0000     0.9386  0 0.000 1.000
#> GSM329680     3  0.0000     0.9386  0 0.000 1.000
#> GSM329685     3  0.0000     0.9386  0 0.000 1.000
#> GSM329688     3  0.0000     0.9386  0 0.000 1.000
#> GSM329691     3  0.0000     0.9386  0 0.000 1.000
#> GSM329682     1  0.0000     1.0000  1 0.000 0.000
#> GSM329684     1  0.0000     1.0000  1 0.000 0.000
#> GSM329687     1  0.0000     1.0000  1 0.000 0.000
#> GSM329690     1  0.0000     1.0000  1 0.000 0.000
#> GSM329692     3  0.0000     0.9386  0 0.000 1.000
#> GSM329694     2  0.0892     0.9535  0 0.980 0.020
#> GSM329697     2  0.0000     0.9730  0 1.000 0.000
#> GSM329700     2  0.0000     0.9730  0 1.000 0.000
#> GSM329703     2  0.0000     0.9730  0 1.000 0.000
#> GSM329704     3  0.6026     0.4111  0 0.376 0.624
#> GSM329707     3  0.0000     0.9386  0 0.000 1.000
#> GSM329709     2  0.0000     0.9730  0 1.000 0.000
#> GSM329711     2  0.0000     0.9730  0 1.000 0.000
#> GSM329714     2  0.0000     0.9730  0 1.000 0.000
#> GSM329693     2  0.0000     0.9730  0 1.000 0.000
#> GSM329696     2  0.0000     0.9730  0 1.000 0.000
#> GSM329699     2  0.6299    -0.0233  0 0.524 0.476
#> GSM329702     2  0.0000     0.9730  0 1.000 0.000
#> GSM329706     3  0.0000     0.9386  0 0.000 1.000
#> GSM329708     3  0.0000     0.9386  0 0.000 1.000
#> GSM329710     3  0.4121     0.7734  0 0.168 0.832
#> GSM329713     1  0.0000     1.0000  1 0.000 0.000
#> GSM329695     1  0.0000     1.0000  1 0.000 0.000
#> GSM329698     1  0.0000     1.0000  1 0.000 0.000
#> GSM329701     1  0.0000     1.0000  1 0.000 0.000
#> GSM329705     1  0.0000     1.0000  1 0.000 0.000
#> GSM329712     2  0.0000     0.9730  0 1.000 0.000
#> GSM329715     1  0.0000     1.0000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0188      0.847  0 0.996 0.004 0.000
#> GSM329663     2  0.0895      0.849  0 0.976 0.004 0.020
#> GSM329664     3  0.4910      0.456  0 0.276 0.704 0.020
#> GSM329666     2  0.0000      0.847  0 1.000 0.000 0.000
#> GSM329667     2  0.4826      0.595  0 0.716 0.264 0.020
#> GSM329670     2  0.2530      0.821  0 0.888 0.000 0.112
#> GSM329672     2  0.2089      0.814  0 0.932 0.048 0.020
#> GSM329674     2  0.2921      0.809  0 0.860 0.000 0.140
#> GSM329661     3  0.4406      0.620  0 0.000 0.700 0.300
#> GSM329669     2  0.3837      0.750  0 0.776 0.000 0.224
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0336      0.702  0 0.000 0.992 0.008
#> GSM329679     2  0.2706      0.793  0 0.900 0.080 0.020
#> GSM329681     3  0.1557      0.714  0 0.000 0.944 0.056
#> GSM329683     3  0.3528      0.700  0 0.000 0.808 0.192
#> GSM329686     3  0.3907      0.685  0 0.000 0.768 0.232
#> GSM329689     3  0.1637      0.715  0 0.000 0.940 0.060
#> GSM329678     4  0.4382      0.348  0 0.000 0.296 0.704
#> GSM329680     3  0.4040      0.677  0 0.000 0.752 0.248
#> GSM329685     3  0.4992      0.279  0 0.000 0.524 0.476
#> GSM329688     3  0.4998      0.249  0 0.000 0.512 0.488
#> GSM329691     3  0.4072      0.672  0 0.000 0.748 0.252
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.4406      0.342  0 0.000 0.300 0.700
#> GSM329694     2  0.3577      0.744  0 0.832 0.156 0.012
#> GSM329697     2  0.0657      0.848  0 0.984 0.004 0.012
#> GSM329700     2  0.4040      0.726  0 0.752 0.000 0.248
#> GSM329703     4  0.2814      0.671  0 0.132 0.000 0.868
#> GSM329704     3  0.4855      0.466  0 0.268 0.712 0.020
#> GSM329707     3  0.2973      0.626  0 0.096 0.884 0.020
#> GSM329709     2  0.1211      0.845  0 0.960 0.000 0.040
#> GSM329711     2  0.4250      0.696  0 0.724 0.000 0.276
#> GSM329714     4  0.4907      0.127  0 0.420 0.000 0.580
#> GSM329693     4  0.3837      0.545  0 0.224 0.000 0.776
#> GSM329696     4  0.2760      0.672  0 0.128 0.000 0.872
#> GSM329699     4  0.1474      0.664  0 0.052 0.000 0.948
#> GSM329702     2  0.0188      0.847  0 0.996 0.000 0.004
#> GSM329706     3  0.0469      0.704  0 0.000 0.988 0.012
#> GSM329708     4  0.4522      0.294  0 0.000 0.320 0.680
#> GSM329710     4  0.1722      0.629  0 0.008 0.048 0.944
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.4222      0.701  0 0.728 0.000 0.272
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.3452     0.7565 0.000 0.852 0.092 0.032 0.024
#> GSM329663     2  0.2095     0.7647 0.000 0.920 0.012 0.008 0.060
#> GSM329664     3  0.4029     0.2718 0.000 0.232 0.744 0.000 0.024
#> GSM329666     2  0.2208     0.7536 0.000 0.908 0.072 0.000 0.020
#> GSM329667     2  0.4974     0.2979 0.000 0.508 0.464 0.000 0.028
#> GSM329670     2  0.3192     0.7326 0.000 0.848 0.000 0.040 0.112
#> GSM329672     2  0.3929     0.6780 0.000 0.764 0.208 0.000 0.028
#> GSM329674     2  0.1830     0.7584 0.000 0.924 0.000 0.068 0.008
#> GSM329661     5  0.6628     0.0000 0.000 0.000 0.372 0.220 0.408
#> GSM329669     2  0.2616     0.7448 0.000 0.880 0.000 0.100 0.020
#> GSM329662     1  0.0609     0.9714 0.980 0.000 0.000 0.000 0.020
#> GSM329665     1  0.0162     0.9770 0.996 0.000 0.000 0.000 0.004
#> GSM329668     1  0.0000     0.9772 1.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000     0.9772 1.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0162     0.9770 0.996 0.000 0.000 0.000 0.004
#> GSM329675     1  0.0290     0.9762 0.992 0.000 0.000 0.000 0.008
#> GSM329676     1  0.0290     0.9762 0.992 0.000 0.000 0.000 0.008
#> GSM329677     3  0.2270     0.3758 0.000 0.000 0.904 0.076 0.020
#> GSM329679     2  0.4350     0.6232 0.000 0.704 0.268 0.000 0.028
#> GSM329681     3  0.5215    -0.3933 0.000 0.000 0.592 0.056 0.352
#> GSM329683     3  0.5467     0.0256 0.000 0.000 0.624 0.276 0.100
#> GSM329686     3  0.5274     0.0697 0.000 0.000 0.600 0.336 0.064
#> GSM329689     3  0.4376     0.2316 0.000 0.000 0.764 0.144 0.092
#> GSM329678     4  0.3016     0.2391 0.000 0.000 0.132 0.848 0.020
#> GSM329680     3  0.5648    -0.2406 0.000 0.000 0.476 0.448 0.076
#> GSM329685     4  0.5168    -0.1683 0.000 0.000 0.356 0.592 0.052
#> GSM329688     4  0.5077    -0.2513 0.000 0.000 0.392 0.568 0.040
#> GSM329691     3  0.5256    -0.0652 0.000 0.000 0.532 0.420 0.048
#> GSM329682     1  0.0162     0.9766 0.996 0.000 0.000 0.000 0.004
#> GSM329684     1  0.0880     0.9647 0.968 0.000 0.000 0.000 0.032
#> GSM329687     1  0.0162     0.9770 0.996 0.000 0.000 0.000 0.004
#> GSM329690     1  0.0880     0.9649 0.968 0.000 0.000 0.000 0.032
#> GSM329692     4  0.4680     0.0908 0.000 0.000 0.132 0.740 0.128
#> GSM329694     2  0.6242     0.3377 0.000 0.528 0.372 0.052 0.048
#> GSM329697     2  0.2436     0.7675 0.000 0.912 0.020 0.032 0.036
#> GSM329700     2  0.3432     0.7188 0.000 0.828 0.000 0.132 0.040
#> GSM329703     4  0.5202     0.2132 0.000 0.348 0.000 0.596 0.056
#> GSM329704     3  0.3970     0.2721 0.000 0.236 0.744 0.000 0.020
#> GSM329707     3  0.1012     0.3480 0.000 0.020 0.968 0.000 0.012
#> GSM329709     2  0.2244     0.7678 0.000 0.920 0.024 0.040 0.016
#> GSM329711     2  0.3687     0.6891 0.000 0.792 0.000 0.180 0.028
#> GSM329714     2  0.5535     0.2347 0.000 0.536 0.000 0.392 0.072
#> GSM329693     4  0.4774     0.1849 0.000 0.360 0.000 0.612 0.028
#> GSM329696     4  0.4355     0.4170 0.000 0.224 0.000 0.732 0.044
#> GSM329699     4  0.4045     0.4143 0.000 0.136 0.004 0.796 0.064
#> GSM329702     2  0.2669     0.7422 0.000 0.876 0.104 0.000 0.020
#> GSM329706     3  0.2193     0.3792 0.000 0.000 0.900 0.092 0.008
#> GSM329708     4  0.6540    -0.4792 0.000 0.000 0.236 0.476 0.288
#> GSM329710     4  0.5575     0.1787 0.000 0.068 0.020 0.644 0.268
#> GSM329713     1  0.2648     0.8724 0.848 0.000 0.000 0.000 0.152
#> GSM329695     1  0.2471     0.8868 0.864 0.000 0.000 0.000 0.136
#> GSM329698     1  0.0609     0.9710 0.980 0.000 0.000 0.000 0.020
#> GSM329701     1  0.0404     0.9742 0.988 0.000 0.000 0.000 0.012
#> GSM329705     1  0.0000     0.9772 1.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.3745     0.6816 0.000 0.780 0.000 0.196 0.024
#> GSM329715     1  0.0000     0.9772 1.000 0.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
#> GSM329660     2  0.3619    0.49169 0.000 0.680 0.000 NA 0.316 0.000
#> GSM329663     2  0.5873    0.54341 0.000 0.632 0.000 NA 0.144 0.084
#> GSM329664     5  0.1533    0.49981 0.000 0.012 0.016 NA 0.948 0.008
#> GSM329666     2  0.4176    0.28162 0.000 0.580 0.000 NA 0.404 0.000
#> GSM329667     5  0.3056    0.43033 0.000 0.184 0.000 NA 0.804 0.004
#> GSM329670     2  0.4609    0.59542 0.000 0.720 0.000 NA 0.116 0.012
#> GSM329672     5  0.4181    0.17173 0.000 0.384 0.000 NA 0.600 0.004
#> GSM329674     2  0.3849    0.53506 0.000 0.752 0.000 NA 0.208 0.008
#> GSM329661     6  0.3454    0.62753 0.000 0.000 0.224 NA 0.012 0.760
#> GSM329669     2  0.2135    0.62163 0.000 0.872 0.000 NA 0.128 0.000
#> GSM329662     1  0.1349    0.89743 0.940 0.000 0.000 NA 0.000 0.004
#> GSM329665     1  0.0603    0.91231 0.980 0.000 0.000 NA 0.000 0.004
#> GSM329668     1  0.0146    0.91522 0.996 0.000 0.000 NA 0.000 0.000
#> GSM329671     1  0.0865    0.91419 0.964 0.000 0.000 NA 0.000 0.000
#> GSM329673     1  0.0260    0.91426 0.992 0.000 0.000 NA 0.000 0.000
#> GSM329675     1  0.1082    0.90456 0.956 0.000 0.000 NA 0.000 0.004
#> GSM329676     1  0.0935    0.90744 0.964 0.000 0.000 NA 0.000 0.004
#> GSM329677     5  0.5755    0.00557 0.000 0.000 0.292 NA 0.568 0.108
#> GSM329679     5  0.3953    0.27326 0.000 0.328 0.000 NA 0.656 0.000
#> GSM329681     6  0.5007    0.64549 0.000 0.000 0.136 NA 0.100 0.712
#> GSM329683     3  0.6979   -0.07174 0.000 0.000 0.428 NA 0.212 0.280
#> GSM329686     3  0.5021    0.31672 0.000 0.000 0.684 NA 0.204 0.076
#> GSM329689     3  0.7201   -0.12198 0.000 0.000 0.344 NA 0.324 0.244
#> GSM329678     3  0.3756    0.38646 0.000 0.052 0.824 NA 0.004 0.060
#> GSM329680     3  0.4672    0.34674 0.000 0.000 0.700 NA 0.152 0.144
#> GSM329685     3  0.2255    0.43327 0.000 0.000 0.892 NA 0.088 0.016
#> GSM329688     3  0.1918    0.43548 0.000 0.000 0.904 NA 0.088 0.008
#> GSM329691     3  0.4255    0.37519 0.000 0.000 0.756 NA 0.156 0.068
#> GSM329682     1  0.1141    0.91080 0.948 0.000 0.000 NA 0.000 0.000
#> GSM329684     1  0.2207    0.87185 0.900 0.000 0.016 NA 0.000 0.008
#> GSM329687     1  0.0363    0.91369 0.988 0.000 0.000 NA 0.000 0.000
#> GSM329690     1  0.2883    0.82498 0.788 0.000 0.000 NA 0.000 0.000
#> GSM329692     3  0.4526    0.24509 0.000 0.044 0.664 NA 0.004 0.284
#> GSM329694     5  0.7616    0.14906 0.000 0.308 0.084 NA 0.416 0.140
#> GSM329697     2  0.5049    0.42272 0.000 0.624 0.000 NA 0.268 0.004
#> GSM329700     2  0.3488    0.63213 0.000 0.832 0.000 NA 0.084 0.032
#> GSM329703     2  0.5896    0.37356 0.000 0.624 0.200 NA 0.004 0.068
#> GSM329704     5  0.2177    0.49351 0.000 0.024 0.060 NA 0.908 0.004
#> GSM329707     5  0.3913    0.32903 0.000 0.000 0.156 NA 0.776 0.056
#> GSM329709     2  0.4411    0.42137 0.000 0.672 0.000 NA 0.276 0.004
#> GSM329711     2  0.2563    0.62074 0.000 0.888 0.008 NA 0.016 0.012
#> GSM329714     2  0.5497    0.54974 0.000 0.692 0.068 NA 0.016 0.080
#> GSM329693     2  0.5846    0.11251 0.000 0.512 0.364 NA 0.000 0.040
#> GSM329696     3  0.6116    0.20940 0.000 0.340 0.512 NA 0.004 0.040
#> GSM329699     3  0.6461    0.15228 0.000 0.344 0.472 NA 0.000 0.076
#> GSM329702     5  0.4097   -0.15451 0.000 0.492 0.000 NA 0.500 0.000
#> GSM329706     5  0.4693    0.17718 0.000 0.000 0.280 NA 0.660 0.032
#> GSM329708     3  0.4312   -0.08649 0.000 0.000 0.528 NA 0.008 0.456
#> GSM329710     3  0.6351    0.14089 0.000 0.152 0.488 NA 0.000 0.316
#> GSM329713     1  0.3819    0.64940 0.624 0.000 0.000 NA 0.000 0.004
#> GSM329695     1  0.3499    0.71760 0.680 0.000 0.000 NA 0.000 0.000
#> GSM329698     1  0.2300    0.86917 0.856 0.000 0.000 NA 0.000 0.000
#> GSM329701     1  0.1501    0.90295 0.924 0.000 0.000 NA 0.000 0.000
#> GSM329705     1  0.0790    0.91476 0.968 0.000 0.000 NA 0.000 0.000
#> GSM329712     2  0.2760    0.61647 0.000 0.884 0.012 NA 0.020 0.020
#> GSM329715     1  0.0937    0.91333 0.960 0.000 0.000 NA 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 disease.state(p) tissue(p) k
#> MAD:NMF 56          0.13893  2.28e-09 2
#> MAD:NMF 53          0.00255  2.23e-10 3
#> MAD:NMF 48          0.00123  2.40e-09 4
#> MAD:NMF 31          0.46674  4.77e-06 5
#> MAD:NMF 27          0.40461  1.55e-04 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


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 21163 rows and 56 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 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-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.988       0.987         0.4311 0.569   0.569
#> 3 3 1.000           0.985       0.989         0.5523 0.761   0.580
#> 4 4 0.870           0.896       0.868         0.0961 0.914   0.741
#> 5 5 0.841           0.893       0.930         0.0573 0.953   0.820
#> 6 6 0.941           0.882       0.948         0.0422 0.969   0.862

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

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
#> GSM329660     2   0.204      0.985 0.032 0.968
#> GSM329663     2   0.204      0.985 0.032 0.968
#> GSM329664     2   0.000      0.981 0.000 1.000
#> GSM329666     2   0.204      0.985 0.032 0.968
#> GSM329667     2   0.000      0.981 0.000 1.000
#> GSM329670     2   0.204      0.985 0.032 0.968
#> GSM329672     2   0.204      0.985 0.032 0.968
#> GSM329674     2   0.204      0.985 0.032 0.968
#> GSM329661     2   0.000      0.981 0.000 1.000
#> GSM329669     2   0.204      0.985 0.032 0.968
#> GSM329662     1   0.000      1.000 1.000 0.000
#> GSM329665     1   0.000      1.000 1.000 0.000
#> GSM329668     1   0.000      1.000 1.000 0.000
#> GSM329671     1   0.000      1.000 1.000 0.000
#> GSM329673     1   0.000      1.000 1.000 0.000
#> GSM329675     1   0.000      1.000 1.000 0.000
#> GSM329676     1   0.000      1.000 1.000 0.000
#> GSM329677     2   0.000      0.981 0.000 1.000
#> GSM329679     2   0.204      0.985 0.032 0.968
#> GSM329681     2   0.000      0.981 0.000 1.000
#> GSM329683     2   0.000      0.981 0.000 1.000
#> GSM329686     2   0.000      0.981 0.000 1.000
#> GSM329689     2   0.000      0.981 0.000 1.000
#> GSM329678     2   0.000      0.981 0.000 1.000
#> GSM329680     2   0.000      0.981 0.000 1.000
#> GSM329685     2   0.000      0.981 0.000 1.000
#> GSM329688     2   0.000      0.981 0.000 1.000
#> GSM329691     2   0.000      0.981 0.000 1.000
#> GSM329682     1   0.000      1.000 1.000 0.000
#> GSM329684     1   0.000      1.000 1.000 0.000
#> GSM329687     1   0.000      1.000 1.000 0.000
#> GSM329690     1   0.000      1.000 1.000 0.000
#> GSM329692     2   0.204      0.985 0.032 0.968
#> GSM329694     2   0.204      0.985 0.032 0.968
#> GSM329697     2   0.204      0.985 0.032 0.968
#> GSM329700     2   0.204      0.985 0.032 0.968
#> GSM329703     2   0.204      0.985 0.032 0.968
#> GSM329704     2   0.000      0.981 0.000 1.000
#> GSM329707     2   0.000      0.981 0.000 1.000
#> GSM329709     2   0.204      0.985 0.032 0.968
#> GSM329711     2   0.204      0.985 0.032 0.968
#> GSM329714     2   0.204      0.985 0.032 0.968
#> GSM329693     2   0.204      0.985 0.032 0.968
#> GSM329696     2   0.204      0.985 0.032 0.968
#> GSM329699     2   0.204      0.985 0.032 0.968
#> GSM329702     2   0.204      0.985 0.032 0.968
#> GSM329706     2   0.000      0.981 0.000 1.000
#> GSM329708     2   0.000      0.981 0.000 1.000
#> GSM329710     2   0.204      0.985 0.032 0.968
#> GSM329713     1   0.000      1.000 1.000 0.000
#> GSM329695     1   0.000      1.000 1.000 0.000
#> GSM329698     1   0.000      1.000 1.000 0.000
#> GSM329701     1   0.000      1.000 1.000 0.000
#> GSM329705     1   0.000      1.000 1.000 0.000
#> GSM329712     2   0.204      0.985 0.032 0.968
#> GSM329715     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
#> GSM329660     2   0.103      0.972  0 0.976 0.024
#> GSM329663     2   0.000      0.972  0 1.000 0.000
#> GSM329664     3   0.000      1.000  0 0.000 1.000
#> GSM329666     2   0.000      0.972  0 1.000 0.000
#> GSM329667     3   0.000      1.000  0 0.000 1.000
#> GSM329670     2   0.000      0.972  0 1.000 0.000
#> GSM329672     2   0.153      0.969  0 0.960 0.040
#> GSM329674     2   0.000      0.972  0 1.000 0.000
#> GSM329661     3   0.000      1.000  0 0.000 1.000
#> GSM329669     2   0.000      0.972  0 1.000 0.000
#> GSM329662     1   0.000      1.000  1 0.000 0.000
#> GSM329665     1   0.000      1.000  1 0.000 0.000
#> GSM329668     1   0.000      1.000  1 0.000 0.000
#> GSM329671     1   0.000      1.000  1 0.000 0.000
#> GSM329673     1   0.000      1.000  1 0.000 0.000
#> GSM329675     1   0.000      1.000  1 0.000 0.000
#> GSM329676     1   0.000      1.000  1 0.000 0.000
#> GSM329677     3   0.000      1.000  0 0.000 1.000
#> GSM329679     2   0.153      0.969  0 0.960 0.040
#> GSM329681     3   0.000      1.000  0 0.000 1.000
#> GSM329683     3   0.000      1.000  0 0.000 1.000
#> GSM329686     3   0.000      1.000  0 0.000 1.000
#> GSM329689     3   0.000      1.000  0 0.000 1.000
#> GSM329678     2   0.412      0.836  0 0.832 0.168
#> GSM329680     3   0.000      1.000  0 0.000 1.000
#> GSM329685     3   0.000      1.000  0 0.000 1.000
#> GSM329688     3   0.000      1.000  0 0.000 1.000
#> GSM329691     3   0.000      1.000  0 0.000 1.000
#> GSM329682     1   0.000      1.000  1 0.000 0.000
#> GSM329684     1   0.000      1.000  1 0.000 0.000
#> GSM329687     1   0.000      1.000  1 0.000 0.000
#> GSM329690     1   0.000      1.000  1 0.000 0.000
#> GSM329692     2   0.226      0.949  0 0.932 0.068
#> GSM329694     2   0.153      0.969  0 0.960 0.040
#> GSM329697     2   0.000      0.972  0 1.000 0.000
#> GSM329700     2   0.000      0.972  0 1.000 0.000
#> GSM329703     2   0.153      0.969  0 0.960 0.040
#> GSM329704     3   0.000      1.000  0 0.000 1.000
#> GSM329707     3   0.000      1.000  0 0.000 1.000
#> GSM329709     2   0.000      0.972  0 1.000 0.000
#> GSM329711     2   0.000      0.972  0 1.000 0.000
#> GSM329714     2   0.103      0.972  0 0.976 0.024
#> GSM329693     2   0.153      0.969  0 0.960 0.040
#> GSM329696     2   0.153      0.969  0 0.960 0.040
#> GSM329699     2   0.153      0.969  0 0.960 0.040
#> GSM329702     2   0.000      0.972  0 1.000 0.000
#> GSM329706     3   0.000      1.000  0 0.000 1.000
#> GSM329708     3   0.000      1.000  0 0.000 1.000
#> GSM329710     2   0.226      0.949  0 0.932 0.068
#> GSM329713     1   0.000      1.000  1 0.000 0.000
#> GSM329695     1   0.000      1.000  1 0.000 0.000
#> GSM329698     1   0.000      1.000  1 0.000 0.000
#> GSM329701     1   0.000      1.000  1 0.000 0.000
#> GSM329705     1   0.000      1.000  1 0.000 0.000
#> GSM329712     2   0.000      0.972  0 1.000 0.000
#> GSM329715     1   0.000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM329660     4  0.4477    -0.0729 0.000 0.312 0.000 0.688
#> GSM329663     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329664     3  0.0336     0.9949 0.000 0.008 0.992 0.000
#> GSM329666     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329667     3  0.0336     0.9949 0.000 0.008 0.992 0.000
#> GSM329670     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329672     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329674     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329661     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329669     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329662     1  0.0000     0.8759 1.000 0.000 0.000 0.000
#> GSM329665     1  0.0000     0.8759 1.000 0.000 0.000 0.000
#> GSM329668     1  0.0000     0.8759 1.000 0.000 0.000 0.000
#> GSM329671     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329673     1  0.0000     0.8759 1.000 0.000 0.000 0.000
#> GSM329675     1  0.3688     0.7485 0.792 0.208 0.000 0.000
#> GSM329676     1  0.0000     0.8759 1.000 0.000 0.000 0.000
#> GSM329677     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329679     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329681     3  0.0188     0.9969 0.000 0.004 0.996 0.000
#> GSM329683     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329686     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329689     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329678     4  0.2976     0.6763 0.000 0.008 0.120 0.872
#> GSM329680     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329685     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329688     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329691     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329682     1  0.3528     0.9139 0.808 0.192 0.000 0.000
#> GSM329684     1  0.3688     0.7485 0.792 0.208 0.000 0.000
#> GSM329687     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329690     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329692     4  0.1042     0.8373 0.000 0.008 0.020 0.972
#> GSM329694     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329697     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329700     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329703     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329704     3  0.0336     0.9949 0.000 0.008 0.992 0.000
#> GSM329707     3  0.0188     0.9969 0.000 0.004 0.996 0.000
#> GSM329709     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329711     2  0.4907     0.9930 0.000 0.580 0.000 0.420
#> GSM329714     4  0.4477    -0.0729 0.000 0.312 0.000 0.688
#> GSM329693     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329696     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329699     4  0.0000     0.8610 0.000 0.000 0.000 1.000
#> GSM329702     2  0.4898     0.9984 0.000 0.584 0.000 0.416
#> GSM329706     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329708     3  0.0000     0.9983 0.000 0.000 1.000 0.000
#> GSM329710     4  0.1042     0.8373 0.000 0.008 0.020 0.972
#> GSM329713     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329695     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329698     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329701     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329705     1  0.3610     0.9148 0.800 0.200 0.000 0.000
#> GSM329712     2  0.4907     0.9930 0.000 0.580 0.000 0.420
#> GSM329715     1  0.3610     0.9148 0.800 0.200 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
#> GSM329660     2  0.4114      0.318 0.000 0.624 0.000 0.376 0.000
#> GSM329663     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329664     3  0.3060      0.877 0.000 0.000 0.848 0.128 0.024
#> GSM329666     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329667     3  0.3060      0.877 0.000 0.000 0.848 0.128 0.024
#> GSM329670     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329672     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329674     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329661     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329669     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329662     1  0.3508      0.759 0.748 0.000 0.000 0.000 0.252
#> GSM329665     1  0.3508      0.759 0.748 0.000 0.000 0.000 0.252
#> GSM329668     1  0.3508      0.759 0.748 0.000 0.000 0.000 0.252
#> GSM329671     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.3508      0.759 0.748 0.000 0.000 0.000 0.252
#> GSM329675     5  0.0703      1.000 0.024 0.000 0.000 0.000 0.976
#> GSM329676     1  0.3508      0.759 0.748 0.000 0.000 0.000 0.252
#> GSM329677     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329679     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329681     3  0.0703      0.951 0.000 0.000 0.976 0.024 0.000
#> GSM329683     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329686     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329689     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329678     4  0.2020      0.795 0.000 0.000 0.100 0.900 0.000
#> GSM329680     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329682     1  0.1043      0.878 0.960 0.000 0.000 0.000 0.040
#> GSM329684     5  0.0703      1.000 0.024 0.000 0.000 0.000 0.976
#> GSM329687     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329692     4  0.2020      0.949 0.000 0.100 0.000 0.900 0.000
#> GSM329694     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329697     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329700     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329703     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329704     3  0.3060      0.877 0.000 0.000 0.848 0.128 0.024
#> GSM329707     3  0.2230      0.900 0.000 0.000 0.884 0.116 0.000
#> GSM329709     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329711     2  0.0162      0.917 0.000 0.996 0.000 0.004 0.000
#> GSM329714     2  0.4114      0.318 0.000 0.624 0.000 0.376 0.000
#> GSM329693     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329696     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329699     4  0.2377      0.969 0.000 0.128 0.000 0.872 0.000
#> GSM329702     2  0.0000      0.920 0.000 1.000 0.000 0.000 0.000
#> GSM329706     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329708     3  0.0000      0.963 0.000 0.000 1.000 0.000 0.000
#> GSM329710     4  0.2020      0.949 0.000 0.100 0.000 0.900 0.000
#> GSM329713     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      0.893 1.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.0162      0.917 0.000 0.996 0.000 0.004 0.000
#> GSM329715     1  0.0000      0.893 1.000 0.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
#> GSM329660     2  0.3823      0.261 0.000 0.564 0.000 0.436 0.000 0.000
#> GSM329663     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329664     5  0.0000      0.767 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329666     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.0000      0.767 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329670     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329672     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329674     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329669     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329662     1  0.3151      0.767 0.748 0.000 0.000 0.000 0.000 0.252
#> GSM329665     1  0.3151      0.767 0.748 0.000 0.000 0.000 0.000 0.252
#> GSM329668     1  0.3151      0.767 0.748 0.000 0.000 0.000 0.000 0.252
#> GSM329671     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.3151      0.767 0.748 0.000 0.000 0.000 0.000 0.252
#> GSM329675     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329676     1  0.3151      0.767 0.748 0.000 0.000 0.000 0.000 0.252
#> GSM329677     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329679     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329681     3  0.0632      0.973 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM329683     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329686     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329678     4  0.1814      0.839 0.000 0.000 0.100 0.900 0.000 0.000
#> GSM329680     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0937      0.882 0.960 0.000 0.000 0.000 0.000 0.040
#> GSM329684     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM329687     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.954 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329694     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329697     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329703     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329704     5  0.0146      0.766 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM329707     5  0.4184      0.298 0.000 0.000 0.408 0.016 0.576 0.000
#> GSM329709     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     2  0.0146      0.904 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM329714     2  0.3823      0.261 0.000 0.564 0.000 0.436 0.000 0.000
#> GSM329693     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329696     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329699     4  0.0713      0.974 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM329702     2  0.0000      0.906 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329708     3  0.0000      0.998 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329710     4  0.0000      0.954 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     2  0.0146      0.904 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM329715     1  0.0000      0.896 1.000 0.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-hclust-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-hclust-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-hclust-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-hclust-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-hclust-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-hclust-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-hclust-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-hclust-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-hclust-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-hclust-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-hclust-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-hclust-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-hclust-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-hclust-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-hclust-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> ATC:hclust 56          0.50568  5.82e-11 2
#> ATC:hclust 56          0.01348  9.47e-10 3
#> ATC:hclust 54          0.01879  9.34e-09 4
#> ATC:hclust 54          0.03588  7.70e-08 5
#> ATC:hclust 53          0.00466  7.90e-08 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 21163 rows and 56 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.4311 0.569   0.569
#> 3 3 0.733           0.986       0.942         0.4850 0.761   0.580
#> 4 4 0.773           0.663       0.783         0.1211 0.951   0.851
#> 5 5 0.753           0.659       0.782         0.0793 0.902   0.679
#> 6 6 0.762           0.657       0.775         0.0478 0.926   0.714

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2   0.000      0.997 0.000 1.000 0.000
#> GSM329663     2   0.000      0.997 0.000 1.000 0.000
#> GSM329664     3   0.382      1.000 0.000 0.148 0.852
#> GSM329666     2   0.000      0.997 0.000 1.000 0.000
#> GSM329667     2   0.000      0.997 0.000 1.000 0.000
#> GSM329670     2   0.000      0.997 0.000 1.000 0.000
#> GSM329672     2   0.000      0.997 0.000 1.000 0.000
#> GSM329674     2   0.000      0.997 0.000 1.000 0.000
#> GSM329661     3   0.382      1.000 0.000 0.148 0.852
#> GSM329669     2   0.000      0.997 0.000 1.000 0.000
#> GSM329662     1   0.312      0.954 0.892 0.000 0.108
#> GSM329665     1   0.263      0.961 0.916 0.000 0.084
#> GSM329668     1   0.263      0.961 0.916 0.000 0.084
#> GSM329671     1   0.000      0.965 1.000 0.000 0.000
#> GSM329673     1   0.296      0.957 0.900 0.000 0.100
#> GSM329675     1   0.382      0.937 0.852 0.000 0.148
#> GSM329676     1   0.263      0.961 0.916 0.000 0.084
#> GSM329677     3   0.382      1.000 0.000 0.148 0.852
#> GSM329679     2   0.000      0.997 0.000 1.000 0.000
#> GSM329681     3   0.382      1.000 0.000 0.148 0.852
#> GSM329683     3   0.382      1.000 0.000 0.148 0.852
#> GSM329686     3   0.382      1.000 0.000 0.148 0.852
#> GSM329689     3   0.382      1.000 0.000 0.148 0.852
#> GSM329678     3   0.382      1.000 0.000 0.148 0.852
#> GSM329680     3   0.382      1.000 0.000 0.148 0.852
#> GSM329685     3   0.382      1.000 0.000 0.148 0.852
#> GSM329688     3   0.382      1.000 0.000 0.148 0.852
#> GSM329691     3   0.382      1.000 0.000 0.148 0.852
#> GSM329682     1   0.196      0.965 0.944 0.000 0.056
#> GSM329684     1   0.382      0.937 0.852 0.000 0.148
#> GSM329687     1   0.196      0.965 0.944 0.000 0.056
#> GSM329690     1   0.000      0.965 1.000 0.000 0.000
#> GSM329692     2   0.175      0.940 0.000 0.952 0.048
#> GSM329694     2   0.000      0.997 0.000 1.000 0.000
#> GSM329697     2   0.000      0.997 0.000 1.000 0.000
#> GSM329700     2   0.000      0.997 0.000 1.000 0.000
#> GSM329703     2   0.000      0.997 0.000 1.000 0.000
#> GSM329704     3   0.382      1.000 0.000 0.148 0.852
#> GSM329707     3   0.382      1.000 0.000 0.148 0.852
#> GSM329709     2   0.000      0.997 0.000 1.000 0.000
#> GSM329711     2   0.000      0.997 0.000 1.000 0.000
#> GSM329714     2   0.000      0.997 0.000 1.000 0.000
#> GSM329693     2   0.000      0.997 0.000 1.000 0.000
#> GSM329696     2   0.000      0.997 0.000 1.000 0.000
#> GSM329699     2   0.000      0.997 0.000 1.000 0.000
#> GSM329702     2   0.000      0.997 0.000 1.000 0.000
#> GSM329706     3   0.382      1.000 0.000 0.148 0.852
#> GSM329708     3   0.382      1.000 0.000 0.148 0.852
#> GSM329710     2   0.000      0.997 0.000 1.000 0.000
#> GSM329713     1   0.000      0.965 1.000 0.000 0.000
#> GSM329695     1   0.000      0.965 1.000 0.000 0.000
#> GSM329698     1   0.000      0.965 1.000 0.000 0.000
#> GSM329701     1   0.000      0.965 1.000 0.000 0.000
#> GSM329705     1   0.000      0.965 1.000 0.000 0.000
#> GSM329712     2   0.000      0.997 0.000 1.000 0.000
#> GSM329715     1   0.000      0.965 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM329660     2  0.4193   0.133317 0.000 0.732 0.000 0.268
#> GSM329663     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329664     3  0.4893   0.873725 0.000 0.064 0.768 0.168
#> GSM329666     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329667     2  0.4877   0.000401 0.000 0.592 0.000 0.408
#> GSM329670     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329672     2  0.3569   0.319778 0.000 0.804 0.000 0.196
#> GSM329674     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329661     3  0.1902   0.935651 0.000 0.064 0.932 0.004
#> GSM329669     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329662     1  0.3801   0.888015 0.780 0.000 0.000 0.220
#> GSM329665     1  0.3123   0.909558 0.844 0.000 0.000 0.156
#> GSM329668     1  0.3123   0.909558 0.844 0.000 0.000 0.156
#> GSM329671     1  0.0927   0.909602 0.976 0.000 0.008 0.016
#> GSM329673     1  0.3311   0.905486 0.828 0.000 0.000 0.172
#> GSM329675     1  0.4608   0.854428 0.692 0.000 0.004 0.304
#> GSM329676     1  0.3123   0.909558 0.844 0.000 0.000 0.156
#> GSM329677     3  0.4614   0.885597 0.000 0.064 0.792 0.144
#> GSM329679     2  0.4008   0.150415 0.000 0.756 0.000 0.244
#> GSM329681     3  0.2300   0.933455 0.000 0.064 0.920 0.016
#> GSM329683     3  0.2048   0.935756 0.000 0.064 0.928 0.008
#> GSM329686     3  0.2048   0.935756 0.000 0.064 0.928 0.008
#> GSM329689     3  0.1716   0.935845 0.000 0.064 0.936 0.000
#> GSM329678     3  0.3885   0.886197 0.000 0.064 0.844 0.092
#> GSM329680     3  0.1716   0.935845 0.000 0.064 0.936 0.000
#> GSM329685     3  0.2048   0.935756 0.000 0.064 0.928 0.008
#> GSM329688     3  0.2048   0.935756 0.000 0.064 0.928 0.008
#> GSM329691     3  0.1716   0.935845 0.000 0.064 0.936 0.000
#> GSM329682     1  0.2773   0.914426 0.880 0.000 0.004 0.116
#> GSM329684     1  0.4608   0.854428 0.692 0.000 0.004 0.304
#> GSM329687     1  0.2773   0.914426 0.880 0.000 0.004 0.116
#> GSM329690     1  0.2021   0.899798 0.932 0.000 0.056 0.012
#> GSM329692     4  0.5292   0.935615 0.000 0.480 0.008 0.512
#> GSM329694     4  0.5000   0.978065 0.000 0.496 0.000 0.504
#> GSM329697     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329700     2  0.3356   0.417949 0.000 0.824 0.000 0.176
#> GSM329703     2  0.4999  -0.944417 0.000 0.508 0.000 0.492
#> GSM329704     3  0.6171   0.676077 0.000 0.064 0.588 0.348
#> GSM329707     3  0.4758   0.880031 0.000 0.064 0.780 0.156
#> GSM329709     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329711     2  0.3311   0.426217 0.000 0.828 0.000 0.172
#> GSM329714     2  0.4661  -0.324240 0.000 0.652 0.000 0.348
#> GSM329693     2  0.4999  -0.944417 0.000 0.508 0.000 0.492
#> GSM329696     2  0.4999  -0.944417 0.000 0.508 0.000 0.492
#> GSM329699     4  0.5000   0.978065 0.000 0.496 0.000 0.504
#> GSM329702     2  0.0000   0.603568 0.000 1.000 0.000 0.000
#> GSM329706     3  0.4758   0.880031 0.000 0.064 0.780 0.156
#> GSM329708     3  0.2413   0.932570 0.000 0.064 0.916 0.020
#> GSM329710     4  0.5000   0.978065 0.000 0.496 0.000 0.504
#> GSM329713     1  0.2021   0.899798 0.932 0.000 0.056 0.012
#> GSM329695     1  0.2021   0.899798 0.932 0.000 0.056 0.012
#> GSM329698     1  0.2021   0.899798 0.932 0.000 0.056 0.012
#> GSM329701     1  0.1174   0.907119 0.968 0.000 0.020 0.012
#> GSM329705     1  0.0188   0.911984 0.996 0.000 0.004 0.000
#> GSM329712     2  0.3311   0.426217 0.000 0.828 0.000 0.172
#> GSM329715     1  0.0188   0.911984 0.996 0.000 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     4  0.4822     0.3386 0.000 0.288 0.000 0.664 0.048
#> GSM329663     2  0.4589     0.8969 0.000 0.704 0.000 0.248 0.048
#> GSM329664     3  0.5407     0.1661 0.000 0.048 0.524 0.004 0.424
#> GSM329666     2  0.3480     0.9211 0.000 0.752 0.000 0.248 0.000
#> GSM329667     5  0.6535     0.1109 0.000 0.232 0.000 0.292 0.476
#> GSM329670     2  0.4378     0.9041 0.000 0.716 0.000 0.248 0.036
#> GSM329672     2  0.5692     0.3010 0.000 0.472 0.000 0.448 0.080
#> GSM329674     2  0.3480     0.9211 0.000 0.752 0.000 0.248 0.000
#> GSM329661     3  0.1704     0.8096 0.000 0.068 0.928 0.004 0.000
#> GSM329669     2  0.4167     0.9019 0.000 0.724 0.000 0.252 0.024
#> GSM329662     1  0.4384     0.7893 0.660 0.016 0.000 0.000 0.324
#> GSM329665     1  0.3508     0.8280 0.748 0.000 0.000 0.000 0.252
#> GSM329668     1  0.3508     0.8280 0.748 0.000 0.000 0.000 0.252
#> GSM329671     1  0.0854     0.8258 0.976 0.008 0.004 0.000 0.012
#> GSM329673     1  0.3928     0.8098 0.700 0.004 0.000 0.000 0.296
#> GSM329675     1  0.4965     0.7113 0.520 0.028 0.000 0.000 0.452
#> GSM329676     1  0.3508     0.8280 0.748 0.000 0.000 0.000 0.252
#> GSM329677     3  0.5191     0.5442 0.000 0.080 0.672 0.004 0.244
#> GSM329679     4  0.5816    -0.3421 0.000 0.440 0.000 0.468 0.092
#> GSM329681     3  0.0912     0.8093 0.000 0.000 0.972 0.012 0.016
#> GSM329683     3  0.0162     0.8188 0.000 0.000 0.996 0.004 0.000
#> GSM329686     3  0.0324     0.8196 0.000 0.000 0.992 0.004 0.004
#> GSM329689     3  0.1443     0.8160 0.000 0.044 0.948 0.004 0.004
#> GSM329678     3  0.4004     0.5913 0.000 0.004 0.784 0.172 0.040
#> GSM329680     3  0.1282     0.8161 0.000 0.044 0.952 0.004 0.000
#> GSM329685     3  0.0324     0.8196 0.000 0.000 0.992 0.004 0.004
#> GSM329688     3  0.0324     0.8196 0.000 0.000 0.992 0.004 0.004
#> GSM329691     3  0.1443     0.8160 0.000 0.044 0.948 0.004 0.004
#> GSM329682     1  0.3074     0.8366 0.804 0.000 0.000 0.000 0.196
#> GSM329684     1  0.4965     0.7113 0.520 0.028 0.000 0.000 0.452
#> GSM329687     1  0.3074     0.8366 0.804 0.000 0.000 0.000 0.196
#> GSM329690     1  0.2233     0.7966 0.892 0.104 0.004 0.000 0.000
#> GSM329692     4  0.2536     0.5975 0.000 0.004 0.044 0.900 0.052
#> GSM329694     4  0.1197     0.6698 0.000 0.000 0.000 0.952 0.048
#> GSM329697     2  0.3480     0.9211 0.000 0.752 0.000 0.248 0.000
#> GSM329700     4  0.5065    -0.0135 0.000 0.420 0.000 0.544 0.036
#> GSM329703     4  0.0510     0.6835 0.000 0.016 0.000 0.984 0.000
#> GSM329704     5  0.7013    -0.0357 0.000 0.048 0.364 0.124 0.464
#> GSM329707     3  0.5289     0.4348 0.000 0.060 0.620 0.004 0.316
#> GSM329709     2  0.3480     0.9211 0.000 0.752 0.000 0.248 0.000
#> GSM329711     4  0.5071    -0.0291 0.000 0.424 0.000 0.540 0.036
#> GSM329714     4  0.3622     0.5854 0.000 0.136 0.000 0.816 0.048
#> GSM329693     4  0.0510     0.6835 0.000 0.016 0.000 0.984 0.000
#> GSM329696     4  0.0510     0.6835 0.000 0.016 0.000 0.984 0.000
#> GSM329699     4  0.0510     0.6794 0.000 0.000 0.000 0.984 0.016
#> GSM329702     2  0.3480     0.9211 0.000 0.752 0.000 0.248 0.000
#> GSM329706     3  0.5523     0.4571 0.000 0.084 0.616 0.004 0.296
#> GSM329708     3  0.1074     0.8088 0.000 0.004 0.968 0.012 0.016
#> GSM329710     4  0.0963     0.6721 0.000 0.000 0.000 0.964 0.036
#> GSM329713     1  0.2127     0.7967 0.892 0.108 0.000 0.000 0.000
#> GSM329695     1  0.2127     0.7967 0.892 0.108 0.000 0.000 0.000
#> GSM329698     1  0.2074     0.7967 0.896 0.104 0.000 0.000 0.000
#> GSM329701     1  0.0880     0.8194 0.968 0.032 0.000 0.000 0.000
#> GSM329705     1  0.0609     0.8300 0.980 0.000 0.000 0.000 0.020
#> GSM329712     4  0.5071    -0.0291 0.000 0.424 0.000 0.540 0.036
#> GSM329715     1  0.0771     0.8299 0.976 0.004 0.000 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5 p6
#> GSM329660     4  0.6646     -0.148 0.000 0.376 0.000 0.400 0.052 NA
#> GSM329663     2  0.2697      0.745 0.000 0.864 0.000 0.000 0.044 NA
#> GSM329664     5  0.3668      0.580 0.000 0.000 0.328 0.004 0.668 NA
#> GSM329666     2  0.0000      0.764 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329667     5  0.5685      0.310 0.000 0.192 0.000 0.112 0.636 NA
#> GSM329670     2  0.2129      0.750 0.000 0.904 0.000 0.000 0.040 NA
#> GSM329672     2  0.5461      0.532 0.000 0.672 0.000 0.156 0.080 NA
#> GSM329674     2  0.0000      0.764 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329661     3  0.2921      0.756 0.000 0.000 0.828 0.008 0.008 NA
#> GSM329669     2  0.3394      0.713 0.000 0.832 0.000 0.028 0.036 NA
#> GSM329662     1  0.1913      0.745 0.908 0.000 0.000 0.000 0.012 NA
#> GSM329665     1  0.0000      0.785 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329668     1  0.0000      0.785 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329671     1  0.3265      0.785 0.748 0.000 0.000 0.004 0.000 NA
#> GSM329673     1  0.1297      0.765 0.948 0.000 0.000 0.000 0.012 NA
#> GSM329675     1  0.5298      0.598 0.644 0.000 0.000 0.020 0.212 NA
#> GSM329676     1  0.0000      0.785 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329677     3  0.5128     -0.293 0.000 0.000 0.548 0.008 0.376 NA
#> GSM329679     2  0.6037      0.458 0.000 0.612 0.000 0.172 0.124 NA
#> GSM329681     3  0.2398      0.760 0.000 0.000 0.888 0.004 0.028 NA
#> GSM329683     3  0.0458      0.801 0.000 0.000 0.984 0.000 0.000 NA
#> GSM329686     3  0.0405      0.802 0.000 0.000 0.988 0.000 0.004 NA
#> GSM329689     3  0.1900      0.777 0.000 0.000 0.916 0.008 0.008 NA
#> GSM329678     3  0.5705      0.298 0.000 0.000 0.592 0.268 0.040 NA
#> GSM329680     3  0.2355      0.777 0.000 0.000 0.876 0.008 0.004 NA
#> GSM329685     3  0.0405      0.802 0.000 0.000 0.988 0.000 0.004 NA
#> GSM329688     3  0.0405      0.802 0.000 0.000 0.988 0.000 0.004 NA
#> GSM329691     3  0.1957      0.778 0.000 0.000 0.912 0.008 0.008 NA
#> GSM329682     1  0.2213      0.794 0.908 0.000 0.000 0.032 0.012 NA
#> GSM329684     1  0.5298      0.598 0.644 0.000 0.000 0.020 0.212 NA
#> GSM329687     1  0.2213      0.794 0.908 0.000 0.000 0.032 0.012 NA
#> GSM329690     1  0.3843      0.724 0.548 0.000 0.000 0.000 0.000 NA
#> GSM329692     4  0.3402      0.800 0.000 0.052 0.012 0.852 0.040 NA
#> GSM329694     4  0.3714      0.801 0.000 0.064 0.000 0.820 0.044 NA
#> GSM329697     2  0.0000      0.764 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329700     2  0.6145      0.327 0.000 0.508 0.000 0.324 0.040 NA
#> GSM329703     4  0.1588      0.828 0.000 0.072 0.000 0.924 0.000 NA
#> GSM329704     5  0.5081      0.583 0.000 0.000 0.224 0.088 0.664 NA
#> GSM329707     5  0.5075      0.407 0.000 0.000 0.452 0.004 0.480 NA
#> GSM329709     2  0.0000      0.764 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329711     2  0.6145      0.327 0.000 0.508 0.000 0.324 0.040 NA
#> GSM329714     4  0.5835      0.488 0.000 0.188 0.000 0.616 0.052 NA
#> GSM329693     4  0.1588      0.828 0.000 0.072 0.000 0.924 0.000 NA
#> GSM329696     4  0.1588      0.828 0.000 0.072 0.000 0.924 0.000 NA
#> GSM329699     4  0.2206      0.826 0.000 0.064 0.000 0.904 0.008 NA
#> GSM329702     2  0.0000      0.764 0.000 1.000 0.000 0.000 0.000 NA
#> GSM329706     5  0.5218      0.386 0.000 0.000 0.456 0.008 0.468 NA
#> GSM329708     3  0.2604      0.754 0.000 0.000 0.872 0.004 0.028 NA
#> GSM329710     4  0.2950      0.815 0.000 0.064 0.000 0.868 0.036 NA
#> GSM329713     1  0.3971      0.724 0.548 0.000 0.000 0.000 0.004 NA
#> GSM329695     1  0.3971      0.724 0.548 0.000 0.000 0.000 0.004 NA
#> GSM329698     1  0.3971      0.725 0.548 0.000 0.000 0.004 0.000 NA
#> GSM329701     1  0.3934      0.773 0.676 0.000 0.000 0.020 0.000 NA
#> GSM329705     1  0.4056      0.786 0.732 0.000 0.000 0.032 0.012 NA
#> GSM329712     2  0.6145      0.327 0.000 0.508 0.000 0.324 0.040 NA
#> GSM329715     1  0.4124      0.785 0.728 0.000 0.000 0.036 0.012 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-kmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-kmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-kmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-kmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-kmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-kmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-kmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-kmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-kmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-kmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-kmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-kmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-kmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-kmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-kmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>             n disease.state(p) tissue(p) k
#> ATC:kmeans 56         5.06e-01  5.82e-11 2
#> ATC:kmeans 56         1.44e-03  3.53e-10 3
#> ATC:kmeans 45         2.72e-03  1.01e-07 4
#> ATC:kmeans 45         6.13e-06  6.01e-08 5
#> ATC:kmeans 45         1.02e-04  7.85e-08 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 21163 rows and 56 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.978       0.992         0.4373 0.569   0.569
#> 3 3 1.000           0.947       0.978         0.5466 0.755   0.569
#> 4 4 0.965           0.967       0.980         0.1059 0.921   0.759
#> 5 5 0.894           0.766       0.873         0.0435 0.984   0.939
#> 6 6 0.938           0.788       0.902         0.0359 0.933   0.733

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
#> GSM329660     2   0.000      0.988 0.000 1.000
#> GSM329663     2   0.000      0.988 0.000 1.000
#> GSM329664     2   0.000      0.988 0.000 1.000
#> GSM329666     2   0.000      0.988 0.000 1.000
#> GSM329667     2   0.000      0.988 0.000 1.000
#> GSM329670     2   0.985      0.255 0.428 0.572
#> GSM329672     2   0.000      0.988 0.000 1.000
#> GSM329674     2   0.000      0.988 0.000 1.000
#> GSM329661     2   0.000      0.988 0.000 1.000
#> GSM329669     2   0.184      0.961 0.028 0.972
#> GSM329662     1   0.000      1.000 1.000 0.000
#> GSM329665     1   0.000      1.000 1.000 0.000
#> GSM329668     1   0.000      1.000 1.000 0.000
#> GSM329671     1   0.000      1.000 1.000 0.000
#> GSM329673     1   0.000      1.000 1.000 0.000
#> GSM329675     1   0.000      1.000 1.000 0.000
#> GSM329676     1   0.000      1.000 1.000 0.000
#> GSM329677     2   0.000      0.988 0.000 1.000
#> GSM329679     2   0.000      0.988 0.000 1.000
#> GSM329681     2   0.000      0.988 0.000 1.000
#> GSM329683     2   0.000      0.988 0.000 1.000
#> GSM329686     2   0.000      0.988 0.000 1.000
#> GSM329689     2   0.000      0.988 0.000 1.000
#> GSM329678     2   0.000      0.988 0.000 1.000
#> GSM329680     2   0.000      0.988 0.000 1.000
#> GSM329685     2   0.000      0.988 0.000 1.000
#> GSM329688     2   0.000      0.988 0.000 1.000
#> GSM329691     2   0.000      0.988 0.000 1.000
#> GSM329682     1   0.000      1.000 1.000 0.000
#> GSM329684     1   0.000      1.000 1.000 0.000
#> GSM329687     1   0.000      1.000 1.000 0.000
#> GSM329690     1   0.000      1.000 1.000 0.000
#> GSM329692     2   0.000      0.988 0.000 1.000
#> GSM329694     2   0.000      0.988 0.000 1.000
#> GSM329697     2   0.000      0.988 0.000 1.000
#> GSM329700     2   0.000      0.988 0.000 1.000
#> GSM329703     2   0.000      0.988 0.000 1.000
#> GSM329704     2   0.000      0.988 0.000 1.000
#> GSM329707     2   0.000      0.988 0.000 1.000
#> GSM329709     2   0.000      0.988 0.000 1.000
#> GSM329711     2   0.000      0.988 0.000 1.000
#> GSM329714     2   0.000      0.988 0.000 1.000
#> GSM329693     2   0.000      0.988 0.000 1.000
#> GSM329696     2   0.000      0.988 0.000 1.000
#> GSM329699     2   0.000      0.988 0.000 1.000
#> GSM329702     2   0.000      0.988 0.000 1.000
#> GSM329706     2   0.000      0.988 0.000 1.000
#> GSM329708     2   0.000      0.988 0.000 1.000
#> GSM329710     2   0.000      0.988 0.000 1.000
#> GSM329713     1   0.000      1.000 1.000 0.000
#> GSM329695     1   0.000      1.000 1.000 0.000
#> GSM329698     1   0.000      1.000 1.000 0.000
#> GSM329701     1   0.000      1.000 1.000 0.000
#> GSM329705     1   0.000      1.000 1.000 0.000
#> GSM329712     2   0.000      0.988 0.000 1.000
#> GSM329715     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
#> GSM329660     2   0.000      0.936  0 1.000 0.000
#> GSM329663     2   0.000      0.936  0 1.000 0.000
#> GSM329664     3   0.000      1.000  0 0.000 1.000
#> GSM329666     2   0.000      0.936  0 1.000 0.000
#> GSM329667     3   0.000      1.000  0 0.000 1.000
#> GSM329670     2   0.000      0.936  0 1.000 0.000
#> GSM329672     2   0.000      0.936  0 1.000 0.000
#> GSM329674     2   0.000      0.936  0 1.000 0.000
#> GSM329661     3   0.000      1.000  0 0.000 1.000
#> GSM329669     2   0.000      0.936  0 1.000 0.000
#> GSM329662     1   0.000      1.000  1 0.000 0.000
#> GSM329665     1   0.000      1.000  1 0.000 0.000
#> GSM329668     1   0.000      1.000  1 0.000 0.000
#> GSM329671     1   0.000      1.000  1 0.000 0.000
#> GSM329673     1   0.000      1.000  1 0.000 0.000
#> GSM329675     1   0.000      1.000  1 0.000 0.000
#> GSM329676     1   0.000      1.000  1 0.000 0.000
#> GSM329677     3   0.000      1.000  0 0.000 1.000
#> GSM329679     2   0.103      0.918  0 0.976 0.024
#> GSM329681     3   0.000      1.000  0 0.000 1.000
#> GSM329683     3   0.000      1.000  0 0.000 1.000
#> GSM329686     3   0.000      1.000  0 0.000 1.000
#> GSM329689     3   0.000      1.000  0 0.000 1.000
#> GSM329678     3   0.000      1.000  0 0.000 1.000
#> GSM329680     3   0.000      1.000  0 0.000 1.000
#> GSM329685     3   0.000      1.000  0 0.000 1.000
#> GSM329688     3   0.000      1.000  0 0.000 1.000
#> GSM329691     3   0.000      1.000  0 0.000 1.000
#> GSM329682     1   0.000      1.000  1 0.000 0.000
#> GSM329684     1   0.000      1.000  1 0.000 0.000
#> GSM329687     1   0.000      1.000  1 0.000 0.000
#> GSM329690     1   0.000      1.000  1 0.000 0.000
#> GSM329692     3   0.000      1.000  0 0.000 1.000
#> GSM329694     2   0.613      0.403  0 0.600 0.400
#> GSM329697     2   0.000      0.936  0 1.000 0.000
#> GSM329700     2   0.000      0.936  0 1.000 0.000
#> GSM329703     2   0.000      0.936  0 1.000 0.000
#> GSM329704     3   0.000      1.000  0 0.000 1.000
#> GSM329707     3   0.000      1.000  0 0.000 1.000
#> GSM329709     2   0.000      0.936  0 1.000 0.000
#> GSM329711     2   0.000      0.936  0 1.000 0.000
#> GSM329714     2   0.000      0.936  0 1.000 0.000
#> GSM329693     2   0.000      0.936  0 1.000 0.000
#> GSM329696     2   0.000      0.936  0 1.000 0.000
#> GSM329699     2   0.614      0.394  0 0.596 0.404
#> GSM329702     2   0.000      0.936  0 1.000 0.000
#> GSM329706     3   0.000      1.000  0 0.000 1.000
#> GSM329708     3   0.000      1.000  0 0.000 1.000
#> GSM329710     2   0.613      0.403  0 0.600 0.400
#> GSM329713     1   0.000      1.000  1 0.000 0.000
#> GSM329695     1   0.000      1.000  1 0.000 0.000
#> GSM329698     1   0.000      1.000  1 0.000 0.000
#> GSM329701     1   0.000      1.000  1 0.000 0.000
#> GSM329705     1   0.000      1.000  1 0.000 0.000
#> GSM329712     2   0.000      0.936  0 1.000 0.000
#> GSM329715     1   0.000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.4222      0.720  0 0.728 0.000 0.272
#> GSM329663     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329664     3  0.0336      0.995  0 0.000 0.992 0.008
#> GSM329666     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329667     3  0.0336      0.995  0 0.000 0.992 0.008
#> GSM329670     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329672     2  0.3528      0.789  0 0.808 0.000 0.192
#> GSM329674     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329669     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0336      0.995  0 0.000 0.992 0.008
#> GSM329679     2  0.3569      0.785  0 0.804 0.000 0.196
#> GSM329681     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329678     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329680     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0707      0.975  0 0.000 0.020 0.980
#> GSM329694     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329697     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329700     2  0.2647      0.867  0 0.880 0.000 0.120
#> GSM329703     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329704     3  0.0336      0.995  0 0.000 0.992 0.008
#> GSM329707     3  0.0336      0.995  0 0.000 0.992 0.008
#> GSM329709     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329711     2  0.2589      0.870  0 0.884 0.000 0.116
#> GSM329714     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329693     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329696     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329699     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329702     2  0.0000      0.918  0 1.000 0.000 0.000
#> GSM329706     3  0.0336      0.995  0 0.000 0.992 0.008
#> GSM329708     3  0.0000      0.997  0 0.000 1.000 0.000
#> GSM329710     4  0.0336      0.996  0 0.008 0.000 0.992
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.2647      0.868  0 0.880 0.000 0.120
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.5195     0.0344 0.000 0.676 0.000 0.108 0.216
#> GSM329663     2  0.4088     0.3135 0.000 0.632 0.000 0.000 0.368
#> GSM329664     3  0.0404     0.7673 0.000 0.000 0.988 0.000 0.012
#> GSM329666     2  0.4161     0.3031 0.000 0.608 0.000 0.000 0.392
#> GSM329667     3  0.3949     0.3151 0.000 0.000 0.668 0.000 0.332
#> GSM329670     2  0.4088     0.3135 0.000 0.632 0.000 0.000 0.368
#> GSM329672     5  0.4623     0.9500 0.000 0.304 0.000 0.032 0.664
#> GSM329674     2  0.4161     0.3031 0.000 0.608 0.000 0.000 0.392
#> GSM329661     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329669     2  0.0162     0.3306 0.000 0.996 0.000 0.000 0.004
#> GSM329662     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329673     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329677     3  0.0000     0.7748 0.000 0.000 1.000 0.000 0.000
#> GSM329679     5  0.4883     0.9509 0.000 0.300 0.000 0.048 0.652
#> GSM329681     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329683     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329686     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329689     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329678     3  0.3730     0.8808 0.000 0.000 0.712 0.000 0.288
#> GSM329680     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329685     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329688     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329691     3  0.3707     0.8827 0.000 0.000 0.716 0.000 0.284
#> GSM329682     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000     0.9983 1.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329692     4  0.2171     0.8416 0.000 0.000 0.064 0.912 0.024
#> GSM329694     4  0.2690     0.8001 0.000 0.000 0.000 0.844 0.156
#> GSM329697     2  0.4161     0.3031 0.000 0.608 0.000 0.000 0.392
#> GSM329700     2  0.2389     0.3346 0.000 0.880 0.000 0.116 0.004
#> GSM329703     4  0.0000     0.8989 0.000 0.000 0.000 1.000 0.000
#> GSM329704     3  0.0404     0.7673 0.000 0.000 0.988 0.000 0.012
#> GSM329707     3  0.0000     0.7748 0.000 0.000 1.000 0.000 0.000
#> GSM329709     2  0.4161     0.3031 0.000 0.608 0.000 0.000 0.392
#> GSM329711     2  0.2389     0.3346 0.000 0.880 0.000 0.116 0.004
#> GSM329714     4  0.4425     0.4866 0.000 0.392 0.000 0.600 0.008
#> GSM329693     4  0.0000     0.8989 0.000 0.000 0.000 1.000 0.000
#> GSM329696     4  0.0000     0.8989 0.000 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0000     0.8989 0.000 0.000 0.000 1.000 0.000
#> GSM329702     2  0.4161     0.3031 0.000 0.608 0.000 0.000 0.392
#> GSM329706     3  0.0000     0.7748 0.000 0.000 1.000 0.000 0.000
#> GSM329708     3  0.3730     0.8808 0.000 0.000 0.712 0.000 0.288
#> GSM329710     4  0.0703     0.8900 0.000 0.000 0.000 0.976 0.024
#> GSM329713     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329695     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329698     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329701     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329705     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004
#> GSM329712     2  0.2280     0.3331 0.000 0.880 0.000 0.120 0.000
#> GSM329715     1  0.0162     0.9980 0.996 0.000 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM329660     6  0.2318      0.887 0.000 0.048 0.000 0.020 0.028 0.904
#> GSM329663     2  0.1549      0.845 0.000 0.936 0.000 0.000 0.020 0.044
#> GSM329664     5  0.3817      0.536 0.000 0.000 0.432 0.000 0.568 0.000
#> GSM329666     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5  0.1738      0.409 0.000 0.016 0.052 0.004 0.928 0.000
#> GSM329670     2  0.1528      0.842 0.000 0.936 0.000 0.000 0.016 0.048
#> GSM329672     2  0.4659      0.554 0.000 0.556 0.000 0.012 0.408 0.024
#> GSM329674     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3  0.0146      0.824 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM329669     6  0.3266      0.712 0.000 0.272 0.000 0.000 0.000 0.728
#> GSM329662     1  0.0405      0.961 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM329665     1  0.0146      0.963 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM329668     1  0.0146      0.963 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM329671     1  0.1713      0.960 0.928 0.000 0.000 0.000 0.028 0.044
#> GSM329673     1  0.0146      0.963 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM329675     1  0.0405      0.961 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM329676     1  0.0146      0.963 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM329677     3  0.3851     -0.399 0.000 0.000 0.540 0.000 0.460 0.000
#> GSM329679     2  0.4683      0.540 0.000 0.540 0.000 0.012 0.424 0.024
#> GSM329681     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329683     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329686     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.0146      0.824 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM329678     3  0.0146      0.822 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM329680     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.0000      0.964 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0405      0.961 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM329687     1  0.0000      0.964 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.1856      0.957 0.920 0.000 0.000 0.000 0.032 0.048
#> GSM329692     4  0.0547      0.898 0.000 0.000 0.020 0.980 0.000 0.000
#> GSM329694     4  0.3320      0.727 0.000 0.000 0.000 0.772 0.212 0.016
#> GSM329697     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6  0.2412      0.914 0.000 0.092 0.000 0.028 0.000 0.880
#> GSM329703     4  0.1610      0.919 0.000 0.000 0.000 0.916 0.000 0.084
#> GSM329704     5  0.3810      0.543 0.000 0.000 0.428 0.000 0.572 0.000
#> GSM329707     3  0.3857     -0.422 0.000 0.000 0.532 0.000 0.468 0.000
#> GSM329709     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6  0.2383      0.915 0.000 0.096 0.000 0.024 0.000 0.880
#> GSM329714     6  0.2019      0.831 0.000 0.000 0.000 0.088 0.012 0.900
#> GSM329693     4  0.1556      0.921 0.000 0.000 0.000 0.920 0.000 0.080
#> GSM329696     4  0.1444      0.923 0.000 0.000 0.000 0.928 0.000 0.072
#> GSM329699     4  0.1444      0.923 0.000 0.000 0.000 0.928 0.000 0.072
#> GSM329702     2  0.0000      0.871 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     3  0.3868     -0.505 0.000 0.000 0.504 0.000 0.496 0.000
#> GSM329708     3  0.0000      0.826 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329710     4  0.0146      0.906 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM329713     1  0.1856      0.957 0.920 0.000 0.000 0.000 0.032 0.048
#> GSM329695     1  0.1856      0.957 0.920 0.000 0.000 0.000 0.032 0.048
#> GSM329698     1  0.1856      0.957 0.920 0.000 0.000 0.000 0.032 0.048
#> GSM329701     1  0.1789      0.959 0.924 0.000 0.000 0.000 0.032 0.044
#> GSM329705     1  0.1644      0.960 0.932 0.000 0.000 0.000 0.028 0.040
#> GSM329712     6  0.2383      0.915 0.000 0.096 0.000 0.024 0.000 0.880
#> GSM329715     1  0.1713      0.960 0.928 0.000 0.000 0.000 0.028 0.044

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-skmeans-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-skmeans-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-skmeans-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-skmeans-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-skmeans-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-skmeans-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-skmeans-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-skmeans-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-skmeans-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-skmeans-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-skmeans-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-skmeans-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>              n disease.state(p) tissue(p) k
#> ATC:skmeans 55         0.415982  9.18e-11 2
#> ATC:skmeans 53         0.016952  1.59e-09 3
#> ATC:skmeans 56         0.000457  1.41e-09 4
#> ATC:skmeans 42         0.003021  2.24e-07 5
#> ATC:skmeans 52         0.000237  1.45e-08 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 21163 rows and 56 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.4311 0.569   0.569
#> 3 3 1.000           1.000       1.000         0.5417 0.766   0.590
#> 4 4 0.888           0.831       0.923         0.1381 0.909   0.729
#> 5 5 0.829           0.798       0.885         0.0467 0.946   0.788
#> 6 6 0.920           0.807       0.919         0.0482 0.961   0.815

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

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
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2       0          1  0  1  0
#> GSM329663     2       0          1  0  1  0
#> GSM329664     3       0          1  0  0  1
#> GSM329666     2       0          1  0  1  0
#> GSM329667     2       0          1  0  1  0
#> GSM329670     2       0          1  0  1  0
#> GSM329672     2       0          1  0  1  0
#> GSM329674     2       0          1  0  1  0
#> GSM329661     3       0          1  0  0  1
#> GSM329669     2       0          1  0  1  0
#> GSM329662     1       0          1  1  0  0
#> GSM329665     1       0          1  1  0  0
#> GSM329668     1       0          1  1  0  0
#> GSM329671     1       0          1  1  0  0
#> GSM329673     1       0          1  1  0  0
#> GSM329675     1       0          1  1  0  0
#> GSM329676     1       0          1  1  0  0
#> GSM329677     3       0          1  0  0  1
#> GSM329679     2       0          1  0  1  0
#> GSM329681     3       0          1  0  0  1
#> GSM329683     3       0          1  0  0  1
#> GSM329686     3       0          1  0  0  1
#> GSM329689     3       0          1  0  0  1
#> GSM329678     3       0          1  0  0  1
#> GSM329680     3       0          1  0  0  1
#> GSM329685     3       0          1  0  0  1
#> GSM329688     3       0          1  0  0  1
#> GSM329691     3       0          1  0  0  1
#> GSM329682     1       0          1  1  0  0
#> GSM329684     1       0          1  1  0  0
#> GSM329687     1       0          1  1  0  0
#> GSM329690     1       0          1  1  0  0
#> GSM329692     2       0          1  0  1  0
#> GSM329694     2       0          1  0  1  0
#> GSM329697     2       0          1  0  1  0
#> GSM329700     2       0          1  0  1  0
#> GSM329703     2       0          1  0  1  0
#> GSM329704     2       0          1  0  1  0
#> GSM329707     3       0          1  0  0  1
#> GSM329709     2       0          1  0  1  0
#> GSM329711     2       0          1  0  1  0
#> GSM329714     2       0          1  0  1  0
#> GSM329693     2       0          1  0  1  0
#> GSM329696     2       0          1  0  1  0
#> GSM329699     2       0          1  0  1  0
#> GSM329702     2       0          1  0  1  0
#> GSM329706     3       0          1  0  0  1
#> GSM329708     3       0          1  0  0  1
#> GSM329710     2       0          1  0  1  0
#> GSM329713     1       0          1  1  0  0
#> GSM329695     1       0          1  1  0  0
#> GSM329698     1       0          1  1  0  0
#> GSM329701     1       0          1  1  0  0
#> GSM329705     1       0          1  1  0  0
#> GSM329712     2       0          1  0  1  0
#> GSM329715     1       0          1  1  0  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.3907      0.678  0 0.768 0.000 0.232
#> GSM329663     2  0.0336      0.779  0 0.992 0.000 0.008
#> GSM329664     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329666     2  0.0336      0.779  0 0.992 0.000 0.008
#> GSM329667     2  0.0817      0.776  0 0.976 0.000 0.024
#> GSM329670     4  0.4989      0.411  0 0.472 0.000 0.528
#> GSM329672     2  0.0188      0.780  0 0.996 0.000 0.004
#> GSM329674     4  0.4989      0.411  0 0.472 0.000 0.528
#> GSM329661     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329669     4  0.4989      0.411  0 0.472 0.000 0.528
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329679     2  0.0188      0.780  0 0.996 0.000 0.004
#> GSM329681     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329678     3  0.5288      0.161  0 0.008 0.520 0.472
#> GSM329680     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     2  0.4989      0.381  0 0.528 0.000 0.472
#> GSM329694     2  0.3942      0.668  0 0.764 0.000 0.236
#> GSM329697     2  0.0336      0.779  0 0.992 0.000 0.008
#> GSM329700     4  0.1792      0.770  0 0.068 0.000 0.932
#> GSM329703     4  0.0000      0.752  0 0.000 0.000 1.000
#> GSM329704     2  0.4964      0.641  0 0.764 0.168 0.068
#> GSM329707     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329709     2  0.0336      0.779  0 0.992 0.000 0.008
#> GSM329711     4  0.1792      0.770  0 0.068 0.000 0.932
#> GSM329714     4  0.2081      0.733  0 0.084 0.000 0.916
#> GSM329693     4  0.0000      0.752  0 0.000 0.000 1.000
#> GSM329696     4  0.0336      0.747  0 0.008 0.000 0.992
#> GSM329699     2  0.4989      0.381  0 0.528 0.000 0.472
#> GSM329702     2  0.0336      0.779  0 0.992 0.000 0.008
#> GSM329706     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329708     3  0.0000      0.964  0 0.000 1.000 0.000
#> GSM329710     2  0.4989      0.381  0 0.528 0.000 0.472
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     4  0.1792      0.770  0 0.068 0.000 0.932
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     2  0.4866      0.248 0.000 0.580 0.000 0.028 0.392
#> GSM329663     2  0.0162      0.796 0.000 0.996 0.000 0.000 0.004
#> GSM329664     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329666     2  0.1121      0.792 0.000 0.956 0.000 0.000 0.044
#> GSM329667     2  0.0703      0.786 0.000 0.976 0.000 0.024 0.000
#> GSM329670     5  0.4306      0.300 0.000 0.492 0.000 0.000 0.508
#> GSM329672     2  0.0162      0.796 0.000 0.996 0.000 0.004 0.000
#> GSM329674     5  0.4306      0.300 0.000 0.492 0.000 0.000 0.508
#> GSM329661     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329669     5  0.2179      0.716 0.000 0.112 0.000 0.000 0.888
#> GSM329662     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329677     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329679     2  0.0162      0.796 0.000 0.996 0.000 0.004 0.000
#> GSM329681     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329683     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329686     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329689     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329678     4  0.5001      0.639 0.000 0.004 0.216 0.700 0.080
#> GSM329680     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329688     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329682     1  0.2230      0.881 0.884 0.000 0.000 0.116 0.000
#> GSM329684     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.4428      0.799 0.700 0.000 0.000 0.268 0.032
#> GSM329692     4  0.4660      0.780 0.000 0.192 0.000 0.728 0.080
#> GSM329694     2  0.4464      0.122 0.000 0.584 0.000 0.408 0.008
#> GSM329697     2  0.1121      0.792 0.000 0.956 0.000 0.000 0.044
#> GSM329700     5  0.1750      0.718 0.000 0.028 0.000 0.036 0.936
#> GSM329703     4  0.3636      0.756 0.000 0.000 0.000 0.728 0.272
#> GSM329704     2  0.4920      0.359 0.000 0.584 0.384 0.032 0.000
#> GSM329707     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329709     2  0.1121      0.792 0.000 0.956 0.000 0.000 0.044
#> GSM329711     5  0.0955      0.729 0.000 0.028 0.000 0.004 0.968
#> GSM329714     5  0.2221      0.693 0.000 0.052 0.000 0.036 0.912
#> GSM329693     4  0.3636      0.756 0.000 0.000 0.000 0.728 0.272
#> GSM329696     4  0.3741      0.760 0.000 0.004 0.000 0.732 0.264
#> GSM329699     4  0.4627      0.783 0.000 0.188 0.000 0.732 0.080
#> GSM329702     2  0.1121      0.792 0.000 0.956 0.000 0.000 0.044
#> GSM329706     3  0.0000      0.977 0.000 0.000 1.000 0.000 0.000
#> GSM329708     3  0.3586      0.597 0.000 0.000 0.736 0.264 0.000
#> GSM329710     4  0.4627      0.783 0.000 0.188 0.000 0.732 0.080
#> GSM329713     1  0.4428      0.799 0.700 0.000 0.000 0.268 0.032
#> GSM329695     1  0.4428      0.799 0.700 0.000 0.000 0.268 0.032
#> GSM329698     1  0.4428      0.799 0.700 0.000 0.000 0.268 0.032
#> GSM329701     1  0.3852      0.830 0.760 0.000 0.000 0.220 0.020
#> GSM329705     1  0.0000      0.909 1.000 0.000 0.000 0.000 0.000
#> GSM329712     5  0.1918      0.717 0.000 0.036 0.000 0.036 0.928
#> GSM329715     1  0.2230      0.881 0.884 0.000 0.000 0.116 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
#> GSM329660     2  0.3930      0.193 0.000 0.576 0.000 0.004 0.000 0.420
#> GSM329663     2  0.0000      0.779 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329664     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329666     2  0.1444      0.769 0.000 0.928 0.000 0.000 0.000 0.072
#> GSM329667     2  0.0508      0.778 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM329670     6  0.3804      0.337 0.000 0.424 0.000 0.000 0.000 0.576
#> GSM329672     2  0.0363      0.780 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM329674     6  0.3810      0.330 0.000 0.428 0.000 0.000 0.000 0.572
#> GSM329661     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329669     6  0.0146      0.755 0.000 0.004 0.000 0.000 0.000 0.996
#> GSM329662     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0865      0.877 0.964 0.000 0.000 0.000 0.036 0.000
#> GSM329676     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329677     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329679     2  0.0363      0.780 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM329681     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329683     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329686     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329678     4  0.1010      0.943 0.000 0.000 0.036 0.960 0.000 0.004
#> GSM329680     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3  0.0000      0.974 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1  0.3823      0.185 0.564 0.000 0.000 0.000 0.436 0.000
#> GSM329684     1  0.0865      0.877 0.964 0.000 0.000 0.000 0.036 0.000
#> GSM329687     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     5  0.0865      0.951 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM329692     4  0.0146      0.983 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM329694     2  0.3804      0.235 0.000 0.576 0.000 0.424 0.000 0.000
#> GSM329697     2  0.1444      0.769 0.000 0.928 0.000 0.000 0.000 0.072
#> GSM329700     6  0.1141      0.754 0.000 0.000 0.000 0.052 0.000 0.948
#> GSM329703     4  0.0363      0.979 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM329704     2  0.4234      0.290 0.000 0.576 0.408 0.012 0.000 0.004
#> GSM329707     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329709     2  0.1444      0.769 0.000 0.928 0.000 0.000 0.000 0.072
#> GSM329711     6  0.0458      0.759 0.000 0.000 0.000 0.016 0.000 0.984
#> GSM329714     6  0.3925      0.590 0.000 0.056 0.000 0.200 0.000 0.744
#> GSM329693     4  0.0363      0.979 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM329696     4  0.0000      0.985 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4  0.0000      0.985 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2  0.1444      0.769 0.000 0.928 0.000 0.000 0.000 0.072
#> GSM329706     3  0.0146      0.973 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM329708     3  0.3351      0.572 0.000 0.000 0.712 0.288 0.000 0.000
#> GSM329710     4  0.0000      0.985 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     5  0.0865      0.951 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM329695     5  0.0865      0.951 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM329698     5  0.0865      0.951 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM329701     5  0.2697      0.782 0.188 0.000 0.000 0.000 0.812 0.000
#> GSM329705     1  0.0000      0.901 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6  0.1765      0.746 0.000 0.024 0.000 0.052 0.000 0.924
#> GSM329715     1  0.3823      0.185 0.564 0.000 0.000 0.000 0.436 0.000

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-pam-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-pam-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-pam-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-pam-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-pam-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-pam-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-pam-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-pam-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-pam-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-pam-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-pam-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-pam-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) tissue(p) k
#> ATC:pam 56         0.505684  5.82e-11 2
#> ATC:pam 56         0.000515  2.02e-10 3
#> ATC:pam 49         0.001220  1.01e-08 4
#> ATC:pam 51         0.008034  1.46e-08 5
#> ATC:pam 49         0.000498  2.14e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC: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 21163 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-mclust-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-mclust-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4311 0.569   0.569
#> 3 3 0.811           0.963       0.964         0.5352 0.761   0.580
#> 4 4 0.970           0.926       0.969         0.1247 0.894   0.692
#> 5 5 1.000           0.965       0.983         0.0674 0.892   0.618
#> 6 6 0.888           0.939       0.947         0.0270 0.971   0.860

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 4

There is also optional best \(k\) = 2 4 that is worth to check.

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM329660     2       0          1  0  1
#> GSM329663     2       0          1  0  1
#> GSM329664     2       0          1  0  1
#> GSM329666     2       0          1  0  1
#> GSM329667     2       0          1  0  1
#> GSM329670     2       0          1  0  1
#> GSM329672     2       0          1  0  1
#> GSM329674     2       0          1  0  1
#> GSM329661     2       0          1  0  1
#> GSM329669     2       0          1  0  1
#> GSM329662     1       0          1  1  0
#> GSM329665     1       0          1  1  0
#> GSM329668     1       0          1  1  0
#> GSM329671     1       0          1  1  0
#> GSM329673     1       0          1  1  0
#> GSM329675     1       0          1  1  0
#> GSM329676     1       0          1  1  0
#> GSM329677     2       0          1  0  1
#> GSM329679     2       0          1  0  1
#> GSM329681     2       0          1  0  1
#> GSM329683     2       0          1  0  1
#> GSM329686     2       0          1  0  1
#> GSM329689     2       0          1  0  1
#> GSM329678     2       0          1  0  1
#> GSM329680     2       0          1  0  1
#> GSM329685     2       0          1  0  1
#> GSM329688     2       0          1  0  1
#> GSM329691     2       0          1  0  1
#> GSM329682     1       0          1  1  0
#> GSM329684     1       0          1  1  0
#> GSM329687     1       0          1  1  0
#> GSM329690     1       0          1  1  0
#> GSM329692     2       0          1  0  1
#> GSM329694     2       0          1  0  1
#> GSM329697     2       0          1  0  1
#> GSM329700     2       0          1  0  1
#> GSM329703     2       0          1  0  1
#> GSM329704     2       0          1  0  1
#> GSM329707     2       0          1  0  1
#> GSM329709     2       0          1  0  1
#> GSM329711     2       0          1  0  1
#> GSM329714     2       0          1  0  1
#> GSM329693     2       0          1  0  1
#> GSM329696     2       0          1  0  1
#> GSM329699     2       0          1  0  1
#> GSM329702     2       0          1  0  1
#> GSM329706     2       0          1  0  1
#> GSM329708     2       0          1  0  1
#> GSM329710     2       0          1  0  1
#> GSM329713     1       0          1  1  0
#> GSM329695     1       0          1  1  0
#> GSM329698     1       0          1  1  0
#> GSM329701     1       0          1  1  0
#> GSM329705     1       0          1  1  0
#> GSM329712     2       0          1  0  1
#> GSM329715     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
#> GSM329660     2  0.3116      0.940  0 0.892 0.108
#> GSM329663     2  0.2066      0.937  0 0.940 0.060
#> GSM329664     3  0.1289      0.961  0 0.032 0.968
#> GSM329666     2  0.0000      0.917  0 1.000 0.000
#> GSM329667     2  0.3879      0.910  0 0.848 0.152
#> GSM329670     2  0.0000      0.917  0 1.000 0.000
#> GSM329672     2  0.3116      0.940  0 0.892 0.108
#> GSM329674     2  0.0000      0.917  0 1.000 0.000
#> GSM329661     3  0.0237      0.984  0 0.004 0.996
#> GSM329669     2  0.1031      0.927  0 0.976 0.024
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0424      0.983  0 0.008 0.992
#> GSM329679     2  0.3116      0.940  0 0.892 0.108
#> GSM329681     3  0.0000      0.985  0 0.000 1.000
#> GSM329683     3  0.0000      0.985  0 0.000 1.000
#> GSM329686     3  0.0000      0.985  0 0.000 1.000
#> GSM329689     3  0.0424      0.983  0 0.008 0.992
#> GSM329678     3  0.0000      0.985  0 0.000 1.000
#> GSM329680     3  0.0000      0.985  0 0.000 1.000
#> GSM329685     3  0.0000      0.985  0 0.000 1.000
#> GSM329688     3  0.0000      0.985  0 0.000 1.000
#> GSM329691     3  0.0000      0.985  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     2  0.3686      0.932  0 0.860 0.140
#> GSM329694     2  0.3551      0.934  0 0.868 0.132
#> GSM329697     2  0.0000      0.917  0 1.000 0.000
#> GSM329700     2  0.1529      0.933  0 0.960 0.040
#> GSM329703     2  0.3686      0.932  0 0.860 0.140
#> GSM329704     3  0.3686      0.835  0 0.140 0.860
#> GSM329707     3  0.0424      0.983  0 0.008 0.992
#> GSM329709     2  0.0000      0.917  0 1.000 0.000
#> GSM329711     2  0.1529      0.933  0 0.960 0.040
#> GSM329714     2  0.3267      0.939  0 0.884 0.116
#> GSM329693     2  0.3686      0.932  0 0.860 0.140
#> GSM329696     2  0.3686      0.932  0 0.860 0.140
#> GSM329699     2  0.3686      0.932  0 0.860 0.140
#> GSM329702     2  0.0000      0.917  0 1.000 0.000
#> GSM329706     3  0.0424      0.983  0 0.008 0.992
#> GSM329708     3  0.0000      0.985  0 0.000 1.000
#> GSM329710     2  0.3686      0.932  0 0.860 0.140
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.3038      0.940  0 0.896 0.104
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM329663     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM329664     3  0.0707      0.983  0 0.020 0.980 0.000
#> GSM329666     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329667     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329670     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM329672     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329674     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329661     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329669     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329677     3  0.0592      0.986  0 0.016 0.984 0.000
#> GSM329679     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329681     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329683     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329686     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329689     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329678     4  0.0592      0.864  0 0.000 0.016 0.984
#> GSM329680     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329685     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329688     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329691     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.875  0 0.000 0.000 1.000
#> GSM329694     2  0.4431      0.552  0 0.696 0.000 0.304
#> GSM329697     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329700     2  0.4564      0.499  0 0.672 0.000 0.328
#> GSM329703     4  0.0000      0.875  0 0.000 0.000 1.000
#> GSM329704     2  0.0707      0.921  0 0.980 0.020 0.000
#> GSM329707     3  0.0592      0.986  0 0.016 0.984 0.000
#> GSM329709     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329711     2  0.2921      0.815  0 0.860 0.000 0.140
#> GSM329714     4  0.4776      0.397  0 0.376 0.000 0.624
#> GSM329693     4  0.0000      0.875  0 0.000 0.000 1.000
#> GSM329696     4  0.0000      0.875  0 0.000 0.000 1.000
#> GSM329699     4  0.4730      0.426  0 0.364 0.000 0.636
#> GSM329702     2  0.0000      0.935  0 1.000 0.000 0.000
#> GSM329706     3  0.0592      0.986  0 0.016 0.984 0.000
#> GSM329708     3  0.0000      0.994  0 0.000 1.000 0.000
#> GSM329710     4  0.0000      0.875  0 0.000 0.000 1.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM329712     2  0.1118      0.920  0 0.964 0.000 0.036
#> GSM329715     1  0.0000      1.000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM329660     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329663     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329664     5  0.0000      0.970  0 0.000 0.000 0.000 1.000
#> GSM329666     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329667     5  0.0000      0.970  0 0.000 0.000 0.000 1.000
#> GSM329670     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329672     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329674     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329661     3  0.3774      0.559  0 0.000 0.704 0.000 0.296
#> GSM329669     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329677     5  0.1197      0.969  0 0.000 0.048 0.000 0.952
#> GSM329679     2  0.0404      0.987  0 0.988 0.000 0.000 0.012
#> GSM329681     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329683     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329686     3  0.0404      0.959  0 0.000 0.988 0.012 0.000
#> GSM329689     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329678     3  0.0404      0.959  0 0.000 0.988 0.012 0.000
#> GSM329680     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329685     3  0.0162      0.964  0 0.000 0.996 0.004 0.000
#> GSM329688     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329691     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329692     4  0.0000      0.945  0 0.000 0.000 1.000 0.000
#> GSM329694     4  0.0404      0.944  0 0.000 0.000 0.988 0.012
#> GSM329697     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329700     4  0.1732      0.906  0 0.080 0.000 0.920 0.000
#> GSM329703     4  0.0000      0.945  0 0.000 0.000 1.000 0.000
#> GSM329704     5  0.0000      0.970  0 0.000 0.000 0.000 1.000
#> GSM329707     5  0.1197      0.969  0 0.000 0.048 0.000 0.952
#> GSM329709     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329711     4  0.2179      0.880  0 0.112 0.000 0.888 0.000
#> GSM329714     4  0.0794      0.937  0 0.028 0.000 0.972 0.000
#> GSM329693     4  0.0162      0.945  0 0.000 0.000 0.996 0.004
#> GSM329696     4  0.0000      0.945  0 0.000 0.000 1.000 0.000
#> GSM329699     4  0.0404      0.944  0 0.000 0.000 0.988 0.012
#> GSM329702     2  0.0000      0.999  0 1.000 0.000 0.000 0.000
#> GSM329706     5  0.1197      0.969  0 0.000 0.048 0.000 0.952
#> GSM329708     3  0.0000      0.966  0 0.000 1.000 0.000 0.000
#> GSM329710     4  0.0000      0.945  0 0.000 0.000 1.000 0.000
#> GSM329713     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM329712     4  0.3480      0.715  0 0.248 0.000 0.752 0.000
#> GSM329715     1  0.0000      1.000  1 0.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
#> GSM329660     6   0.404      0.865 0.000 0.180 0.000 0.076 0.000 0.744
#> GSM329663     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329664     5   0.000      0.903 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329666     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329667     5   0.144      0.860 0.000 0.072 0.000 0.000 0.928 0.000
#> GSM329670     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329672     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329674     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329661     3   0.297      0.680 0.000 0.000 0.776 0.000 0.224 0.000
#> GSM329669     2   0.150      0.904 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM329662     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329665     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329668     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329671     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329673     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329675     1   0.196      0.894 0.888 0.000 0.000 0.000 0.000 0.112
#> GSM329676     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329677     5   0.196      0.907 0.000 0.000 0.112 0.000 0.888 0.000
#> GSM329679     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329681     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329683     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329686     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329689     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329678     3   0.101      0.936 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM329680     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329685     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329688     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329691     3   0.000      0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM329682     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329684     1   0.196      0.894 0.888 0.000 0.000 0.000 0.000 0.112
#> GSM329687     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329690     1   0.230      0.879 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM329692     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329694     6   0.317      0.762 0.000 0.000 0.000 0.256 0.000 0.744
#> GSM329697     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329700     6   0.415      0.898 0.000 0.108 0.000 0.148 0.000 0.744
#> GSM329703     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329704     5   0.000      0.903 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM329707     5   0.186      0.913 0.000 0.000 0.104 0.000 0.896 0.000
#> GSM329709     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329711     6   0.415      0.899 0.000 0.112 0.000 0.144 0.000 0.744
#> GSM329714     6   0.404      0.876 0.000 0.076 0.000 0.180 0.000 0.744
#> GSM329693     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329696     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329699     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329702     2   0.000      0.990 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM329706     5   0.186      0.913 0.000 0.000 0.104 0.000 0.896 0.000
#> GSM329708     3   0.101      0.936 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM329710     4   0.000      1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM329713     1   0.230      0.879 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM329695     1   0.230      0.879 0.856 0.000 0.000 0.000 0.000 0.144
#> GSM329698     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329701     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329705     1   0.000      0.963 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM329712     6   0.383      0.831 0.000 0.212 0.000 0.044 0.000 0.744
#> GSM329715     1   0.000      0.963 1.000 0.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 disease.state(p) tissue(p) k
#> ATC:mclust 56         5.06e-01  5.82e-11 2
#> ATC:mclust 56         1.44e-03  3.53e-10 3
#> ATC:mclust 53         3.94e-03  6.91e-10 4
#> ATC:mclust 56         5.22e-06  2.70e-09 5
#> ATC:mclust 56         1.31e-04  1.27e-09 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.


ATC: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 21163 rows and 56 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

collect_plots() function collects all the plots made from res for all k (number of partitions) into one single page to provide an easy and fast comparison between different k.

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

All the plots in panels can be made by individual functions and they are plotted later in this section.

select_partition_number() produces several plots showing different statistics for choosing “optimized” k. There are following statistics:

The detailed explanations of these statistics can be found in the cola vignette.

Generally speaking, lower PAC score, higher mean silhouette score or higher concordance corresponds to better partition. Rand index and Jaccard index measure how similar the current partition is compared to partition with k-1. If they are too similar, we won't accept k is better than k-1.

select_partition_number(res)

plot of chunk ATC-NMF-select-partition-number

The numeric values for all these statistics can be obtained by get_stats().

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.889           0.913       0.965         0.4895 0.514   0.514
#> 3 3 1.000           0.965       0.986         0.3774 0.706   0.481
#> 4 4 0.811           0.707       0.856         0.0934 0.911   0.737
#> 5 5 0.762           0.709       0.815         0.0547 0.906   0.664
#> 6 6 0.750           0.707       0.822         0.0320 0.967   0.848

suggest_best_k() suggests the best \(k\) based on these statistics. The rules are as follows:

suggest_best_k(res)
#> [1] 3

Following shows the table of the partitions (You need to click the show/hide code output link to see it). The membership matrix (columns with name p*) is inferred by clue::cl_consensus() function with the SE method. Basically the value in the membership matrix represents the probability to belong to a certain group. The finall class label for an item is determined with the group with highest probability it belongs to.

In get_classes() function, the entropy is calculated from the membership matrix and the silhouette score is calculated from the consensus matrix.

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette    p1    p2
#> GSM329660     2   0.000      0.953 0.000 1.000
#> GSM329663     2   0.000      0.953 0.000 1.000
#> GSM329664     2   0.000      0.953 0.000 1.000
#> GSM329666     1   0.671      0.777 0.824 0.176
#> GSM329667     2   0.000      0.953 0.000 1.000
#> GSM329670     1   0.000      0.974 1.000 0.000
#> GSM329672     2   0.000      0.953 0.000 1.000
#> GSM329674     1   0.327      0.919 0.940 0.060
#> GSM329661     2   0.000      0.953 0.000 1.000
#> GSM329669     1   0.000      0.974 1.000 0.000
#> GSM329662     1   0.000      0.974 1.000 0.000
#> GSM329665     1   0.000      0.974 1.000 0.000
#> GSM329668     1   0.000      0.974 1.000 0.000
#> GSM329671     1   0.000      0.974 1.000 0.000
#> GSM329673     1   0.000      0.974 1.000 0.000
#> GSM329675     1   0.000      0.974 1.000 0.000
#> GSM329676     1   0.000      0.974 1.000 0.000
#> GSM329677     2   0.000      0.953 0.000 1.000
#> GSM329679     2   0.000      0.953 0.000 1.000
#> GSM329681     2   0.000      0.953 0.000 1.000
#> GSM329683     2   0.000      0.953 0.000 1.000
#> GSM329686     2   0.000      0.953 0.000 1.000
#> GSM329689     2   0.000      0.953 0.000 1.000
#> GSM329678     2   0.000      0.953 0.000 1.000
#> GSM329680     2   0.000      0.953 0.000 1.000
#> GSM329685     2   0.000      0.953 0.000 1.000
#> GSM329688     2   0.000      0.953 0.000 1.000
#> GSM329691     2   0.000      0.953 0.000 1.000
#> GSM329682     1   0.000      0.974 1.000 0.000
#> GSM329684     1   0.000      0.974 1.000 0.000
#> GSM329687     1   0.000      0.974 1.000 0.000
#> GSM329690     1   0.000      0.974 1.000 0.000
#> GSM329692     2   0.000      0.953 0.000 1.000
#> GSM329694     2   0.000      0.953 0.000 1.000
#> GSM329697     1   0.839      0.619 0.732 0.268
#> GSM329700     2   0.781      0.693 0.232 0.768
#> GSM329703     2   0.000      0.953 0.000 1.000
#> GSM329704     2   0.000      0.953 0.000 1.000
#> GSM329707     2   0.000      0.953 0.000 1.000
#> GSM329709     2   0.994      0.187 0.456 0.544
#> GSM329711     2   0.855      0.615 0.280 0.720
#> GSM329714     2   0.373      0.889 0.072 0.928
#> GSM329693     2   0.000      0.953 0.000 1.000
#> GSM329696     2   0.000      0.953 0.000 1.000
#> GSM329699     2   0.000      0.953 0.000 1.000
#> GSM329702     2   0.981      0.299 0.420 0.580
#> GSM329706     2   0.000      0.953 0.000 1.000
#> GSM329708     2   0.000      0.953 0.000 1.000
#> GSM329710     2   0.000      0.953 0.000 1.000
#> GSM329713     1   0.000      0.974 1.000 0.000
#> GSM329695     1   0.000      0.974 1.000 0.000
#> GSM329698     1   0.000      0.974 1.000 0.000
#> GSM329701     1   0.000      0.974 1.000 0.000
#> GSM329705     1   0.000      0.974 1.000 0.000
#> GSM329712     2   0.000      0.953 0.000 1.000
#> GSM329715     1   0.000      0.974 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
#> GSM329660     2  0.0000      0.998  0 1.000 0.000
#> GSM329663     2  0.0000      0.998  0 1.000 0.000
#> GSM329664     3  0.0000      0.955  0 0.000 1.000
#> GSM329666     2  0.0000      0.998  0 1.000 0.000
#> GSM329667     3  0.6252      0.230  0 0.444 0.556
#> GSM329670     2  0.0000      0.998  0 1.000 0.000
#> GSM329672     2  0.0000      0.998  0 1.000 0.000
#> GSM329674     2  0.0000      0.998  0 1.000 0.000
#> GSM329661     3  0.0000      0.955  0 0.000 1.000
#> GSM329669     2  0.0000      0.998  0 1.000 0.000
#> GSM329662     1  0.0000      1.000  1 0.000 0.000
#> GSM329665     1  0.0000      1.000  1 0.000 0.000
#> GSM329668     1  0.0000      1.000  1 0.000 0.000
#> GSM329671     1  0.0000      1.000  1 0.000 0.000
#> GSM329673     1  0.0000      1.000  1 0.000 0.000
#> GSM329675     1  0.0000      1.000  1 0.000 0.000
#> GSM329676     1  0.0000      1.000  1 0.000 0.000
#> GSM329677     3  0.0000      0.955  0 0.000 1.000
#> GSM329679     2  0.0000      0.998  0 1.000 0.000
#> GSM329681     3  0.0000      0.955  0 0.000 1.000
#> GSM329683     3  0.0000      0.955  0 0.000 1.000
#> GSM329686     3  0.0000      0.955  0 0.000 1.000
#> GSM329689     3  0.0000      0.955  0 0.000 1.000
#> GSM329678     3  0.0000      0.955  0 0.000 1.000
#> GSM329680     3  0.0000      0.955  0 0.000 1.000
#> GSM329685     3  0.0000      0.955  0 0.000 1.000
#> GSM329688     3  0.0000      0.955  0 0.000 1.000
#> GSM329691     3  0.0000      0.955  0 0.000 1.000
#> GSM329682     1  0.0000      1.000  1 0.000 0.000
#> GSM329684     1  0.0000      1.000  1 0.000 0.000
#> GSM329687     1  0.0000      1.000  1 0.000 0.000
#> GSM329690     1  0.0000      1.000  1 0.000 0.000
#> GSM329692     3  0.5397      0.617  0 0.280 0.720
#> GSM329694     2  0.0000      0.998  0 1.000 0.000
#> GSM329697     2  0.0000      0.998  0 1.000 0.000
#> GSM329700     2  0.0000      0.998  0 1.000 0.000
#> GSM329703     2  0.0000      0.998  0 1.000 0.000
#> GSM329704     3  0.0000      0.955  0 0.000 1.000
#> GSM329707     3  0.0000      0.955  0 0.000 1.000
#> GSM329709     2  0.0000      0.998  0 1.000 0.000
#> GSM329711     2  0.0000      0.998  0 1.000 0.000
#> GSM329714     2  0.0000      0.998  0 1.000 0.000
#> GSM329693     2  0.0000      0.998  0 1.000 0.000
#> GSM329696     2  0.0000      0.998  0 1.000 0.000
#> GSM329699     2  0.0592      0.987  0 0.988 0.012
#> GSM329702     2  0.0000      0.998  0 1.000 0.000
#> GSM329706     3  0.0000      0.955  0 0.000 1.000
#> GSM329708     3  0.0000      0.955  0 0.000 1.000
#> GSM329710     2  0.0892      0.979  0 0.980 0.020
#> GSM329713     1  0.0000      1.000  1 0.000 0.000
#> GSM329695     1  0.0000      1.000  1 0.000 0.000
#> GSM329698     1  0.0000      1.000  1 0.000 0.000
#> GSM329701     1  0.0000      1.000  1 0.000 0.000
#> GSM329705     1  0.0000      1.000  1 0.000 0.000
#> GSM329712     2  0.0000      0.998  0 1.000 0.000
#> GSM329715     1  0.0000      1.000  1 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM329660     2  0.0188     0.8755  0 0.996 0.004 0.000
#> GSM329663     2  0.0921     0.8750  0 0.972 0.000 0.028
#> GSM329664     4  0.1940     0.7168  0 0.000 0.076 0.924
#> GSM329666     2  0.2345     0.8443  0 0.900 0.000 0.100
#> GSM329667     4  0.2385     0.6613  0 0.028 0.052 0.920
#> GSM329670     2  0.1302     0.8705  0 0.956 0.000 0.044
#> GSM329672     2  0.3172     0.8044  0 0.840 0.000 0.160
#> GSM329674     2  0.0592     0.8758  0 0.984 0.000 0.016
#> GSM329661     3  0.5000    -0.2933  0 0.000 0.500 0.500
#> GSM329669     2  0.0000     0.8758  0 1.000 0.000 0.000
#> GSM329662     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329665     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329668     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329671     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329673     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329675     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329676     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329677     4  0.4643     0.5890  0 0.000 0.344 0.656
#> GSM329679     2  0.3907     0.7370  0 0.768 0.000 0.232
#> GSM329681     3  0.4250     0.3602  0 0.000 0.724 0.276
#> GSM329683     3  0.4605     0.2685  0 0.000 0.664 0.336
#> GSM329686     3  0.4543     0.2912  0 0.000 0.676 0.324
#> GSM329689     4  0.4977     0.2835  0 0.000 0.460 0.540
#> GSM329678     3  0.0188     0.4800  0 0.000 0.996 0.004
#> GSM329680     3  0.4843     0.1059  0 0.000 0.604 0.396
#> GSM329685     3  0.2704     0.4749  0 0.000 0.876 0.124
#> GSM329688     3  0.3172     0.4604  0 0.000 0.840 0.160
#> GSM329691     3  0.4907     0.0186  0 0.000 0.580 0.420
#> GSM329682     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329684     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329687     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329690     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329692     3  0.2814     0.4200  0 0.132 0.868 0.000
#> GSM329694     2  0.0817     0.8698  0 0.976 0.024 0.000
#> GSM329697     2  0.1022     0.8742  0 0.968 0.000 0.032
#> GSM329700     2  0.0592     0.8727  0 0.984 0.016 0.000
#> GSM329703     2  0.4746     0.5422  0 0.632 0.368 0.000
#> GSM329704     4  0.2345     0.7293  0 0.000 0.100 0.900
#> GSM329707     4  0.4008     0.7217  0 0.000 0.244 0.756
#> GSM329709     2  0.1022     0.8742  0 0.968 0.000 0.032
#> GSM329711     2  0.0336     0.8747  0 0.992 0.008 0.000
#> GSM329714     2  0.3942     0.7071  0 0.764 0.236 0.000
#> GSM329693     2  0.4697     0.5621  0 0.644 0.356 0.000
#> GSM329696     2  0.4624     0.5852  0 0.660 0.340 0.000
#> GSM329699     3  0.4898    -0.0760  0 0.416 0.584 0.000
#> GSM329702     2  0.2973     0.8163  0 0.856 0.000 0.144
#> GSM329706     4  0.3873     0.7295  0 0.000 0.228 0.772
#> GSM329708     3  0.0336     0.4810  0 0.000 0.992 0.008
#> GSM329710     3  0.4843    -0.0175  0 0.396 0.604 0.000
#> GSM329713     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329695     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329698     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329701     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329705     1  0.0000     1.0000  1 0.000 0.000 0.000
#> GSM329712     2  0.0188     0.8755  0 0.996 0.004 0.000
#> GSM329715     1  0.0000     1.0000  1 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM329660     4  0.1012      0.684 0.000 0.012 0.000 0.968 0.020
#> GSM329663     4  0.3884     -0.104 0.000 0.288 0.000 0.708 0.004
#> GSM329664     5  0.0566      0.643 0.000 0.004 0.012 0.000 0.984
#> GSM329666     2  0.4872      0.784 0.000 0.540 0.000 0.436 0.024
#> GSM329667     5  0.2729      0.574 0.000 0.084 0.004 0.028 0.884
#> GSM329670     4  0.3912      0.217 0.000 0.228 0.000 0.752 0.020
#> GSM329672     2  0.5773      0.766 0.000 0.476 0.000 0.436 0.088
#> GSM329674     2  0.4306      0.657 0.000 0.508 0.000 0.492 0.000
#> GSM329661     5  0.4273      0.464 0.000 0.000 0.448 0.000 0.552
#> GSM329669     4  0.1544      0.617 0.000 0.068 0.000 0.932 0.000
#> GSM329662     1  0.1892      0.937 0.916 0.080 0.000 0.000 0.004
#> GSM329665     1  0.0404      0.977 0.988 0.012 0.000 0.000 0.000
#> GSM329668     1  0.0566      0.976 0.984 0.012 0.004 0.000 0.000
#> GSM329671     1  0.0290      0.977 0.992 0.008 0.000 0.000 0.000
#> GSM329673     1  0.0290      0.977 0.992 0.008 0.000 0.000 0.000
#> GSM329675     1  0.0771      0.973 0.976 0.020 0.004 0.000 0.000
#> GSM329676     1  0.0510      0.976 0.984 0.016 0.000 0.000 0.000
#> GSM329677     5  0.3561      0.682 0.000 0.000 0.260 0.000 0.740
#> GSM329679     2  0.5948      0.768 0.000 0.484 0.000 0.408 0.108
#> GSM329681     3  0.2970      0.628 0.000 0.004 0.828 0.000 0.168
#> GSM329683     3  0.3452      0.528 0.000 0.000 0.756 0.000 0.244
#> GSM329686     3  0.3366      0.553 0.000 0.000 0.768 0.000 0.232
#> GSM329689     5  0.4126      0.587 0.000 0.000 0.380 0.000 0.620
#> GSM329678     3  0.2387      0.630 0.000 0.048 0.908 0.040 0.004
#> GSM329680     3  0.4060      0.171 0.000 0.000 0.640 0.000 0.360
#> GSM329685     3  0.2351      0.669 0.000 0.016 0.896 0.000 0.088
#> GSM329688     3  0.2806      0.645 0.000 0.004 0.844 0.000 0.152
#> GSM329691     5  0.4283      0.440 0.000 0.000 0.456 0.000 0.544
#> GSM329682     1  0.0290      0.976 0.992 0.008 0.000 0.000 0.000
#> GSM329684     1  0.2548      0.907 0.876 0.116 0.004 0.000 0.004
#> GSM329687     1  0.0000      0.978 1.000 0.000 0.000 0.000 0.000
#> GSM329690     1  0.0510      0.974 0.984 0.016 0.000 0.000 0.000
#> GSM329692     3  0.3667      0.551 0.000 0.048 0.812 0.140 0.000
#> GSM329694     2  0.6538      0.541 0.000 0.480 0.248 0.272 0.000
#> GSM329697     2  0.3816      0.756 0.000 0.696 0.000 0.304 0.000
#> GSM329700     4  0.0671      0.688 0.000 0.016 0.004 0.980 0.000
#> GSM329703     4  0.4028      0.660 0.000 0.048 0.176 0.776 0.000
#> GSM329704     5  0.1082      0.653 0.000 0.008 0.028 0.000 0.964
#> GSM329707     5  0.5019      0.643 0.000 0.052 0.316 0.000 0.632
#> GSM329709     2  0.4066      0.770 0.000 0.672 0.000 0.324 0.004
#> GSM329711     4  0.0404      0.689 0.000 0.012 0.000 0.988 0.000
#> GSM329714     4  0.3479      0.677 0.000 0.084 0.080 0.836 0.000
#> GSM329693     4  0.4237      0.645 0.000 0.048 0.200 0.752 0.000
#> GSM329696     4  0.3779      0.629 0.000 0.012 0.236 0.752 0.000
#> GSM329699     4  0.4587      0.617 0.000 0.068 0.204 0.728 0.000
#> GSM329702     2  0.5337      0.782 0.000 0.508 0.000 0.440 0.052
#> GSM329706     5  0.2813      0.691 0.000 0.000 0.168 0.000 0.832
#> GSM329708     3  0.0854      0.661 0.000 0.004 0.976 0.008 0.012
#> GSM329710     3  0.4297      0.354 0.000 0.020 0.692 0.288 0.000
#> GSM329713     1  0.1792      0.932 0.916 0.084 0.000 0.000 0.000
#> GSM329695     1  0.1043      0.963 0.960 0.040 0.000 0.000 0.000
#> GSM329698     1  0.0510      0.974 0.984 0.016 0.000 0.000 0.000
#> GSM329701     1  0.0000      0.978 1.000 0.000 0.000 0.000 0.000
#> GSM329705     1  0.0162      0.977 0.996 0.004 0.000 0.000 0.000
#> GSM329712     4  0.0703      0.686 0.000 0.024 0.000 0.976 0.000
#> GSM329715     1  0.0000      0.978 1.000 0.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
#> GSM329660     4  0.4497      0.490 0.000 0.368 0.000 0.600 0.012 NA
#> GSM329663     2  0.4658      0.103 0.000 0.568 0.000 0.384 0.000 NA
#> GSM329664     5  0.2309      0.643 0.000 0.084 0.000 0.000 0.888 NA
#> GSM329666     2  0.2384      0.762 0.000 0.888 0.000 0.064 0.000 NA
#> GSM329667     2  0.4585      0.434 0.000 0.644 0.000 0.008 0.304 NA
#> GSM329670     4  0.5820      0.295 0.000 0.328 0.000 0.504 0.008 NA
#> GSM329672     2  0.1922      0.761 0.000 0.924 0.000 0.040 0.012 NA
#> GSM329674     2  0.4734      0.590 0.000 0.672 0.000 0.208 0.000 NA
#> GSM329661     5  0.3878      0.648 0.000 0.000 0.320 0.004 0.668 NA
#> GSM329669     4  0.3835      0.576 0.000 0.336 0.000 0.656 0.004 NA
#> GSM329662     1  0.2219      0.872 0.864 0.000 0.000 0.000 0.000 NA
#> GSM329665     1  0.0146      0.942 0.996 0.000 0.000 0.000 0.000 NA
#> GSM329668     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329671     1  0.0260      0.941 0.992 0.000 0.000 0.000 0.000 NA
#> GSM329673     1  0.0146      0.942 0.996 0.000 0.000 0.000 0.000 NA
#> GSM329675     1  0.1957      0.888 0.888 0.000 0.000 0.000 0.000 NA
#> GSM329676     1  0.0146      0.942 0.996 0.000 0.000 0.000 0.000 NA
#> GSM329677     5  0.2146      0.723 0.000 0.000 0.116 0.000 0.880 NA
#> GSM329679     2  0.2345      0.756 0.000 0.904 0.000 0.036 0.036 NA
#> GSM329681     3  0.1194      0.711 0.000 0.004 0.956 0.000 0.032 NA
#> GSM329683     3  0.2667      0.679 0.000 0.000 0.852 0.000 0.128 NA
#> GSM329686     3  0.3221      0.613 0.000 0.000 0.792 0.000 0.188 NA
#> GSM329689     5  0.3592      0.625 0.000 0.000 0.344 0.000 0.656 NA
#> GSM329678     3  0.3263      0.658 0.000 0.000 0.800 0.176 0.020 NA
#> GSM329680     3  0.3966     -0.170 0.000 0.000 0.552 0.004 0.444 NA
#> GSM329685     3  0.2716      0.698 0.000 0.000 0.868 0.008 0.096 NA
#> GSM329688     3  0.3210      0.644 0.000 0.000 0.804 0.000 0.168 NA
#> GSM329691     5  0.3881      0.533 0.000 0.000 0.396 0.000 0.600 NA
#> GSM329682     1  0.0260      0.941 0.992 0.000 0.000 0.000 0.000 NA
#> GSM329684     1  0.3265      0.772 0.748 0.000 0.000 0.000 0.004 NA
#> GSM329687     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329690     1  0.1267      0.922 0.940 0.000 0.000 0.000 0.000 NA
#> GSM329692     3  0.2199      0.681 0.000 0.000 0.892 0.088 0.000 NA
#> GSM329694     3  0.4469      0.263 0.000 0.388 0.584 0.012 0.000 NA
#> GSM329697     2  0.3697      0.670 0.000 0.732 0.004 0.016 0.000 NA
#> GSM329700     4  0.2632      0.757 0.000 0.164 0.000 0.832 0.000 NA
#> GSM329703     4  0.1655      0.771 0.000 0.008 0.052 0.932 0.000 NA
#> GSM329704     5  0.4511      0.579 0.000 0.224 0.036 0.004 0.712 NA
#> GSM329707     5  0.5634      0.631 0.000 0.156 0.256 0.000 0.576 NA
#> GSM329709     2  0.2709      0.740 0.000 0.848 0.000 0.020 0.000 NA
#> GSM329711     4  0.2378      0.763 0.000 0.152 0.000 0.848 0.000 NA
#> GSM329714     4  0.2089      0.766 0.000 0.020 0.020 0.916 0.000 NA
#> GSM329693     4  0.2013      0.763 0.000 0.008 0.076 0.908 0.000 NA
#> GSM329696     4  0.2068      0.763 0.000 0.008 0.080 0.904 0.000 NA
#> GSM329699     4  0.1769      0.769 0.000 0.012 0.060 0.924 0.000 NA
#> GSM329702     2  0.1738      0.766 0.000 0.928 0.000 0.052 0.004 NA
#> GSM329706     5  0.2100      0.722 0.000 0.000 0.112 0.000 0.884 NA
#> GSM329708     3  0.0951      0.709 0.000 0.000 0.968 0.020 0.004 NA
#> GSM329710     3  0.3281      0.593 0.000 0.004 0.784 0.200 0.000 NA
#> GSM329713     1  0.3879      0.692 0.688 0.020 0.000 0.000 0.000 NA
#> GSM329695     1  0.2302      0.878 0.872 0.008 0.000 0.000 0.000 NA
#> GSM329698     1  0.1007      0.929 0.956 0.000 0.000 0.000 0.000 NA
#> GSM329701     1  0.0260      0.941 0.992 0.000 0.000 0.000 0.000 NA
#> GSM329705     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000 NA
#> GSM329712     4  0.2697      0.745 0.000 0.188 0.000 0.812 0.000 NA
#> GSM329715     1  0.0000      0.942 1.000 0.000 0.000 0.000 0.000 NA

Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-consensus-heatmap-1

consensus_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-consensus-heatmap-2

consensus_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-consensus-heatmap-3

consensus_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-consensus-heatmap-4

consensus_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-consensus-heatmap-5

Heatmaps for the membership of samples in all partitions to see how consistent they are:

membership_heatmap(res, k = 2)

plot of chunk tab-ATC-NMF-membership-heatmap-1

membership_heatmap(res, k = 3)

plot of chunk tab-ATC-NMF-membership-heatmap-2

membership_heatmap(res, k = 4)

plot of chunk tab-ATC-NMF-membership-heatmap-3

membership_heatmap(res, k = 5)

plot of chunk tab-ATC-NMF-membership-heatmap-4

membership_heatmap(res, k = 6)

plot of chunk tab-ATC-NMF-membership-heatmap-5

As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

plot of chunk tab-ATC-NMF-get-signatures-1

get_signatures(res, k = 3)

plot of chunk tab-ATC-NMF-get-signatures-2

get_signatures(res, k = 4)

plot of chunk tab-ATC-NMF-get-signatures-3

get_signatures(res, k = 5)

plot of chunk tab-ATC-NMF-get-signatures-4

get_signatures(res, k = 6)

plot of chunk tab-ATC-NMF-get-signatures-5

Signature heatmaps where rows are not scaled:

get_signatures(res, k = 2, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-1

get_signatures(res, k = 3, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-2

get_signatures(res, k = 4, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-3

get_signatures(res, k = 5, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-4

get_signatures(res, k = 6, scale_rows = FALSE)

plot of chunk tab-ATC-NMF-get-signatures-no-scale-5

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-NMF-signature_compare

get_signature() returns a data frame invisibly. TO get the list of signatures, the function call should be assigned to a variable explicitly. In following code, if plot argument is set to FALSE, no heatmap is plotted while only the differential analysis is performed.

# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)

An example of the output of tb is:

#>   which_row         fdr    mean_1    mean_2 scaled_mean_1 scaled_mean_2 km
#> 1        38 0.042760348  8.373488  9.131774    -0.5533452     0.5164555  1
#> 2        40 0.018707592  7.106213  8.469186    -0.6173731     0.5762149  1
#> 3        55 0.019134737 10.221463 11.207825    -0.6159697     0.5749050  1
#> 4        59 0.006059896  5.921854  7.869574    -0.6899429     0.6439467  1
#> 5        60 0.018055526  8.928898 10.211722    -0.6204761     0.5791110  1
#> 6        98 0.009384629 15.714769 14.887706     0.6635654    -0.6193277  2
...

The columns in tb are:

  1. which_row: row indices corresponding to the input matrix.
  2. fdr: FDR for the differential test.
  3. mean_x: The mean value in group x.
  4. scaled_mean_x: The mean value in group x after rows are scaled.
  5. km: Row groups if k-means clustering is applied to rows.

UMAP plot which shows how samples are separated.

dimension_reduction(res, k = 2, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-1

dimension_reduction(res, k = 3, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-2

dimension_reduction(res, k = 4, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-3

dimension_reduction(res, k = 5, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-4

dimension_reduction(res, k = 6, method = "UMAP")

plot of chunk tab-ATC-NMF-dimension-reduction-5

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-NMF-collect-classes

Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.

test_to_known_factors(res)
#>          n disease.state(p) tissue(p) k
#> ATC:NMF 54          0.04978  4.31e-07 2
#> ATC:NMF 55          0.00361  9.94e-10 3
#> ATC:NMF 42          0.52817  5.06e-07 4
#> ATC:NMF 50          0.02024  8.77e-08 5
#> ATC:NMF 50          0.02098  1.72e-07 6

If matrix rows can be associated to genes, consider to use functional_enrichment(res, ...) to perform function enrichment for the signature genes. See this vignette for more detailed explanations.

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