cola Report for GDS4607

Date: 2019-12-25 21:45:20 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 22263 rows and 60 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] 22263    60

Density distribution

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

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

plot of chunk density-heatmap

Suggest the best k

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

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

suggest_best_k(res_list)
The best k 1-PAC Mean silhouette Concordance Optional k
SD:hclust 2 1.000 1.000 1.000 **
SD:kmeans 2 1.000 0.976 0.970 **
SD:skmeans 2 1.000 1.000 1.000 **
SD:pam 3 1.000 1.000 1.000 ** 2
SD:mclust 2 1.000 1.000 1.000 **
SD:NMF 2 1.000 1.000 1.000 **
CV:hclust 2 1.000 1.000 1.000 **
CV:skmeans 2 1.000 1.000 1.000 **
CV:NMF 2 1.000 1.000 1.000 **
MAD:hclust 2 1.000 1.000 1.000 **
MAD:kmeans 2 1.000 0.994 0.992 **
MAD:skmeans 2 1.000 1.000 1.000 **
MAD:mclust 2 1.000 1.000 1.000 **
MAD:NMF 2 1.000 1.000 1.000 **
ATC:hclust 2 1.000 1.000 1.000 **
ATC:kmeans 2 1.000 1.000 1.000 **
ATC:mclust 2 1.000 1.000 1.000 **
ATC:NMF 2 1.000 1.000 1.000 **
CV:mclust 4 0.987 0.926 0.975 ** 2
CV:pam 6 0.952 0.928 0.965 ** 2,3,4,5
ATC:skmeans 3 0.929 0.965 0.980 * 2
ATC:pam 4 0.922 0.897 0.956 * 2
MAD:pam 5 0.921 0.889 0.944 * 2,3
CV:kmeans 2 0.506 0.946 0.939

**: 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           1.000       1.000          0.473 0.528   0.528
#> CV:NMF      2 1.000           1.000       1.000          0.473 0.528   0.528
#> MAD:NMF     2 1.000           1.000       1.000          0.473 0.528   0.528
#> ATC:NMF     2 1.000           1.000       1.000          0.473 0.528   0.528
#> SD:skmeans  2 1.000           1.000       1.000          0.473 0.528   0.528
#> CV:skmeans  2 1.000           1.000       1.000          0.473 0.528   0.528
#> MAD:skmeans 2 1.000           1.000       1.000          0.473 0.528   0.528
#> ATC:skmeans 2 1.000           1.000       1.000          0.473 0.528   0.528
#> SD:mclust   2 1.000           1.000       1.000          0.473 0.528   0.528
#> CV:mclust   2 1.000           1.000       1.000          0.473 0.528   0.528
#> MAD:mclust  2 1.000           1.000       1.000          0.473 0.528   0.528
#> ATC:mclust  2 1.000           1.000       1.000          0.473 0.528   0.528
#> SD:kmeans   2 1.000           0.976       0.970          0.461 0.528   0.528
#> CV:kmeans   2 0.506           0.946       0.939          0.450 0.528   0.528
#> MAD:kmeans  2 1.000           0.994       0.992          0.470 0.528   0.528
#> ATC:kmeans  2 1.000           1.000       1.000          0.473 0.528   0.528
#> SD:pam      2 1.000           1.000       1.000          0.473 0.528   0.528
#> CV:pam      2 1.000           1.000       1.000          0.473 0.528   0.528
#> MAD:pam     2 1.000           1.000       1.000          0.473 0.528   0.528
#> ATC:pam     2 1.000           1.000       1.000          0.473 0.528   0.528
#> SD:hclust   2 1.000           1.000       1.000          0.473 0.528   0.528
#> CV:hclust   2 1.000           1.000       1.000          0.473 0.528   0.528
#> MAD:hclust  2 1.000           1.000       1.000          0.473 0.528   0.528
#> ATC:hclust  2 1.000           1.000       1.000          0.473 0.528   0.528
get_stats(res_list, k = 3)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      3 0.727           0.782       0.889          0.327 0.824   0.666
#> CV:NMF      3 0.764           0.824       0.893          0.341 0.842   0.700
#> MAD:NMF     3 0.701           0.724       0.865          0.333 0.810   0.640
#> ATC:NMF     3 0.744           0.814       0.888          0.352 0.798   0.618
#> SD:skmeans  3 0.857           0.946       0.963          0.313 0.864   0.743
#> CV:skmeans  3 0.895           0.949       0.965          0.312 0.864   0.743
#> MAD:skmeans 3 0.821           0.891       0.913          0.384 0.798   0.618
#> ATC:skmeans 3 0.929           0.965       0.980          0.143 0.941   0.888
#> SD:mclust   3 0.774           0.659       0.834          0.334 0.666   0.443
#> CV:mclust   3 0.792           0.835       0.918          0.307 0.864   0.743
#> MAD:mclust  3 0.778           0.841       0.915          0.299 0.877   0.768
#> ATC:mclust  3 0.819           0.849       0.931          0.280 0.864   0.743
#> SD:kmeans   3 0.784           0.929       0.930          0.249 0.892   0.794
#> CV:kmeans   3 0.837           0.921       0.916          0.287 0.877   0.768
#> MAD:kmeans  3 0.695           0.701       0.750          0.280 0.801   0.623
#> ATC:kmeans  3 0.657           0.580       0.846          0.248 0.959   0.923
#> SD:pam      3 1.000           1.000       1.000          0.229 0.892   0.794
#> CV:pam      3 1.000           1.000       1.000          0.229 0.892   0.794
#> MAD:pam     3 1.000           0.990       0.996          0.237 0.892   0.794
#> ATC:pam     3 0.747           0.840       0.887          0.280 0.892   0.794
#> SD:hclust   3 0.806           0.924       0.937          0.272 0.892   0.794
#> CV:hclust   3 0.885           0.962       0.965          0.254 0.892   0.794
#> MAD:hclust  3 0.789           0.886       0.911          0.368 0.805   0.631
#> ATC:hclust  3 0.837           0.944       0.968          0.125 0.959   0.923
get_stats(res_list, k = 4)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      4 0.803           0.785       0.878         0.1371 0.885   0.691
#> CV:NMF      4 0.758           0.659       0.838         0.1330 0.803   0.525
#> MAD:NMF     4 0.785           0.699       0.839         0.1171 0.895   0.709
#> ATC:NMF     4 0.674           0.685       0.820         0.0718 0.823   0.565
#> SD:skmeans  4 0.882           0.924       0.950         0.1675 0.849   0.631
#> CV:skmeans  4 0.804           0.574       0.831         0.1724 0.864   0.662
#> MAD:skmeans 4 0.890           0.906       0.946         0.1046 0.915   0.753
#> ATC:skmeans 4 0.732           0.850       0.897         0.2222 0.889   0.764
#> SD:mclust   4 0.900           0.912       0.948         0.0553 0.792   0.529
#> CV:mclust   4 0.987           0.926       0.975         0.0667 0.905   0.770
#> MAD:mclust  4 0.672           0.623       0.816         0.1176 0.927   0.819
#> ATC:mclust  4 0.745           0.774       0.887         0.0864 0.906   0.774
#> SD:kmeans   4 0.703           0.673       0.811         0.1710 0.883   0.721
#> CV:kmeans   4 0.635           0.754       0.817         0.1586 1.000   1.000
#> MAD:kmeans  4 0.621           0.686       0.792         0.1357 0.839   0.595
#> ATC:kmeans  4 0.598           0.511       0.749         0.1333 0.941   0.879
#> SD:pam      4 0.893           0.875       0.949         0.2136 0.883   0.721
#> CV:pam      4 0.999           0.964       0.985         0.1995 0.883   0.721
#> MAD:pam     4 0.841           0.852       0.927         0.2238 0.858   0.660
#> ATC:pam     4 0.922           0.897       0.956         0.1752 0.869   0.689
#> SD:hclust   4 0.786           0.803       0.880         0.1146 0.937   0.849
#> CV:hclust   4 0.742           0.766       0.884         0.1491 0.901   0.764
#> MAD:hclust  4 0.874           0.895       0.938         0.0990 0.942   0.827
#> ATC:hclust  4 0.819           0.871       0.927         0.0780 1.000   1.000
get_stats(res_list, k = 5)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      5 0.803           0.803       0.872         0.0635 0.908   0.696
#> CV:NMF      5 0.786           0.817       0.885         0.0647 0.915   0.705
#> MAD:NMF     5 0.786           0.743       0.838         0.0678 0.918   0.723
#> ATC:NMF     5 0.741           0.639       0.827         0.0486 0.973   0.919
#> SD:skmeans  5 0.791           0.683       0.829         0.0600 0.980   0.926
#> CV:skmeans  5 0.751           0.665       0.792         0.0599 0.899   0.667
#> MAD:skmeans 5 0.812           0.774       0.862         0.0556 0.955   0.841
#> ATC:skmeans 5 0.808           0.788       0.892         0.1081 0.910   0.747
#> SD:mclust   5 0.805           0.816       0.890         0.0623 0.949   0.855
#> CV:mclust   5 0.860           0.822       0.902         0.0544 0.973   0.922
#> MAD:mclust  5 0.768           0.792       0.875         0.0644 0.940   0.819
#> ATC:mclust  5 0.646           0.566       0.818         0.0608 0.928   0.819
#> SD:kmeans   5 0.670           0.790       0.805         0.0769 0.883   0.643
#> CV:kmeans   5 0.649           0.619       0.702         0.0932 0.818   0.558
#> MAD:kmeans  5 0.585           0.629       0.718         0.0912 0.853   0.557
#> ATC:kmeans  5 0.585           0.547       0.704         0.0796 0.862   0.681
#> SD:pam      5 0.893           0.874       0.949         0.0580 0.959   0.865
#> CV:pam      5 0.999           0.960       0.983         0.0580 0.959   0.865
#> MAD:pam     5 0.921           0.889       0.944         0.0669 0.932   0.763
#> ATC:pam     5 0.774           0.788       0.869         0.0674 0.934   0.771
#> SD:hclust   5 0.825           0.824       0.912         0.0490 0.959   0.886
#> CV:hclust   5 0.782           0.775       0.895         0.0596 0.959   0.873
#> MAD:hclust  5 0.804           0.866       0.895         0.0517 0.959   0.852
#> ATC:hclust  5 0.789           0.778       0.896         0.0623 0.921   0.838
get_stats(res_list, k = 6)
#>             k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> SD:NMF      6 0.733           0.643       0.803         0.0338 0.924   0.713
#> CV:NMF      6 0.734           0.674       0.823         0.0368 0.919   0.698
#> MAD:NMF     6 0.769           0.595       0.799         0.0380 0.931   0.741
#> ATC:NMF     6 0.718           0.641       0.784         0.0322 0.919   0.754
#> SD:skmeans  6 0.781           0.651       0.809         0.0439 0.884   0.586
#> CV:skmeans  6 0.782           0.713       0.811         0.0491 0.899   0.611
#> MAD:skmeans 6 0.789           0.511       0.724         0.0426 0.908   0.671
#> ATC:skmeans 6 0.786           0.585       0.820         0.0457 0.961   0.865
#> SD:mclust   6 0.697           0.599       0.790         0.0689 0.953   0.852
#> CV:mclust   6 0.702           0.675       0.779         0.1016 0.852   0.573
#> MAD:mclust  6 0.726           0.631       0.818         0.0572 0.982   0.937
#> ATC:mclust  6 0.708           0.783       0.833         0.0507 0.885   0.699
#> SD:kmeans   6 0.652           0.625       0.712         0.0727 0.986   0.943
#> CV:kmeans   6 0.652           0.576       0.708         0.0741 0.901   0.648
#> MAD:kmeans  6 0.669           0.501       0.657         0.0573 0.932   0.727
#> ATC:kmeans  6 0.603           0.643       0.711         0.0701 0.858   0.551
#> SD:pam      6 0.900           0.853       0.928         0.0660 0.915   0.688
#> CV:pam      6 0.952           0.928       0.965         0.0569 0.959   0.844
#> MAD:pam     6 0.884           0.880       0.921         0.0440 0.959   0.824
#> ATC:pam     6 0.747           0.578       0.830         0.0518 0.966   0.857
#> SD:hclust   6 0.805           0.712       0.854         0.0618 0.886   0.656
#> CV:hclust   6 0.772           0.683       0.825         0.0521 0.936   0.786
#> MAD:hclust  6 0.858           0.871       0.911         0.0465 0.964   0.850
#> ATC:hclust  6 0.724           0.758       0.858         0.1143 0.892   0.740

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) protocol(p)  time(p) individual(p) k
#> SD:NMF      60                1    4.43e-09 0.000103             1 2
#> CV:NMF      60                1    4.43e-09 0.000103             1 2
#> MAD:NMF     60                1    4.43e-09 0.000103             1 2
#> ATC:NMF     60                1    4.43e-09 0.000103             1 2
#> SD:skmeans  60                1    4.43e-09 0.000103             1 2
#> CV:skmeans  60                1    4.43e-09 0.000103             1 2
#> MAD:skmeans 60                1    4.43e-09 0.000103             1 2
#> ATC:skmeans 60                1    4.43e-09 0.000103             1 2
#> SD:mclust   60                1    4.43e-09 0.000103             1 2
#> CV:mclust   60                1    4.43e-09 0.000103             1 2
#> MAD:mclust  60                1    4.43e-09 0.000103             1 2
#> ATC:mclust  60                1    4.43e-09 0.000103             1 2
#> SD:kmeans   60                1    4.43e-09 0.000103             1 2
#> CV:kmeans   60                1    4.43e-09 0.000103             1 2
#> MAD:kmeans  60                1    4.43e-09 0.000103             1 2
#> ATC:kmeans  60                1    4.43e-09 0.000103             1 2
#> SD:pam      60                1    4.43e-09 0.000103             1 2
#> CV:pam      60                1    4.43e-09 0.000103             1 2
#> MAD:pam     60                1    4.43e-09 0.000103             1 2
#> ATC:pam     60                1    4.43e-09 0.000103             1 2
#> SD:hclust   60                1    4.43e-09 0.000103             1 2
#> CV:hclust   60                1    4.43e-09 0.000103             1 2
#> MAD:hclust  60                1    4.43e-09 0.000103             1 2
#> ATC:hclust  60                1    4.43e-09 0.000103             1 2
test_to_known_factors(res_list, k = 3)
#>              n disease.state(p) protocol(p)  time(p) individual(p) k
#> SD:NMF      54            0.579    2.35e-07 1.08e-04         0.895 3
#> CV:NMF      55            0.989    5.24e-07 2.73e-04         0.500 3
#> MAD:NMF     50            0.705    4.45e-07 2.64e-04         0.809 3
#> ATC:NMF     53            0.980    6.14e-07 4.93e-04         0.699 3
#> SD:skmeans  60            1.000    7.98e-08 1.67e-04         0.501 3
#> CV:skmeans  60            1.000    7.98e-08 1.67e-04         0.501 3
#> MAD:skmeans 60            0.948    7.13e-08 1.69e-04         0.418 3
#> ATC:skmeans 60            0.834    5.63e-08 1.29e-04         0.597 3
#> SD:mclust   53            0.739    8.04e-06 9.75e-04         0.142 3
#> CV:mclust   58            0.947    1.33e-07 1.71e-04         0.426 3
#> MAD:mclust  56            0.914    2.79e-07 9.08e-05         0.415 3
#> ATC:mclust  56            0.534    1.39e-08 5.65e-05         0.822 3
#> SD:kmeans   60            1.000    7.22e-08 1.67e-04         0.575 3
#> CV:kmeans   60            0.916    6.33e-08 1.63e-04         0.376 3
#> MAD:kmeans  38            1.000    1.33e-06 8.69e-04         0.780 3
#> ATC:kmeans  47            0.989    6.82e-07 3.03e-05         0.946 3
#> SD:pam      60            1.000    7.22e-08 1.67e-04         0.575 3
#> CV:pam      60            1.000    7.22e-08 1.67e-04         0.575 3
#> MAD:pam     60            1.000    7.22e-08 1.67e-04         0.575 3
#> ATC:pam     60            1.000    7.22e-08 1.67e-04         0.575 3
#> SD:hclust   59            0.711    1.07e-07 2.40e-04         0.231 3
#> CV:hclust   60            0.673    7.22e-08 1.67e-04         0.287 3
#> MAD:hclust  59            0.682    1.15e-07 2.35e-04         0.466 3
#> ATC:hclust  60            1.000    1.40e-08 4.54e-05         0.986 3
test_to_known_factors(res_list, k = 4)
#>              n disease.state(p) protocol(p)  time(p) individual(p) k
#> SD:NMF      53            0.637    3.03e-06 2.01e-04        0.2120 4
#> CV:NMF      45            0.363    1.99e-05 3.35e-04        0.4927 4
#> MAD:NMF     46            0.324    9.25e-06 2.91e-04        0.3732 4
#> ATC:NMF     48            0.909    1.70e-05 2.18e-04        0.4548 4
#> SD:skmeans  59            0.998    4.84e-07 5.40e-04        0.1560 4
#> CV:skmeans  28            1.000    7.27e-04 5.68e-03        0.8307 4
#> MAD:skmeans 58            0.866    1.18e-06 5.00e-04        0.0634 4
#> ATC:skmeans 60            0.924    4.54e-07 4.51e-04        0.0787 4
#> SD:mclust   58            0.795    1.31e-06 6.01e-04        0.3832 4
#> CV:mclust   58            0.795    1.31e-06 6.01e-04        0.3832 4
#> MAD:mclust  48            0.940    8.62e-05 3.58e-03        0.0832 4
#> ATC:mclust  53            0.981    1.09e-06 2.69e-04        0.2428 4
#> SD:kmeans   54            0.982    4.92e-06 3.12e-04        0.2005 4
#> CV:kmeans   59            0.992    1.07e-07 2.40e-04        0.4784 4
#> MAD:kmeans  53            0.901    6.62e-06 3.63e-04        0.1380 4
#> ATC:kmeans  41            0.983    1.15e-06 2.46e-05        0.9467 4
#> SD:pam      57            0.674    4.06e-07 8.71e-04        0.1824 4
#> CV:pam      59            0.913    8.80e-07 4.09e-04        0.1310 4
#> MAD:pam     58            0.172    1.13e-06 3.04e-04        0.1965 4
#> ATC:pam     57            0.998    5.84e-07 2.10e-04        0.2990 4
#> SD:hclust   58            0.809    1.14e-06 9.46e-04        0.0569 4
#> CV:hclust   54            0.840    5.58e-06 1.17e-03        0.0562 4
#> MAD:hclust  59            0.741    1.01e-06 8.11e-04        0.0405 4
#> ATC:hclust  58            0.976    3.61e-08 9.99e-05        0.9182 4
test_to_known_factors(res_list, k = 5)
#>              n disease.state(p) protocol(p)  time(p) individual(p) k
#> SD:NMF      58            0.251    6.10e-07 0.000212       0.11769 5
#> CV:NMF      55            0.338    2.48e-07 0.000280       0.18253 5
#> MAD:NMF     48            0.506    7.71e-06 0.000160       0.22650 5
#> ATC:NMF     45            0.954    1.44e-05 0.000296       0.29554 5
#> SD:skmeans  51            0.872    1.32e-05 0.000452       0.10974 5
#> CV:skmeans  45            0.366    4.47e-04 0.007105       0.11720 5
#> MAD:skmeans 54            0.920    3.31e-05 0.003085       0.01017 5
#> ATC:skmeans 54            0.977    2.26e-05 0.001357       0.02510 5
#> SD:mclust   57            0.903    2.13e-06 0.000359       0.29925 5
#> CV:mclust   57            0.691    2.16e-06 0.000877       0.26076 5
#> MAD:mclust  55            0.754    2.17e-05 0.003922       0.08994 5
#> ATC:mclust  44            1.000    7.88e-06 0.002587       0.13344 5
#> SD:kmeans   58            0.982    1.91e-06 0.001449       0.08004 5
#> CV:kmeans   41            0.739    4.53e-04 0.000376       0.66349 5
#> MAD:kmeans  47            0.759    4.88e-05 0.015548       0.00317 5
#> ATC:kmeans  41            0.689    2.42e-04 0.001345       0.17520 5
#> SD:pam      57            0.820    1.91e-06 0.002355       0.19674 5
#> CV:pam      59            0.971    3.94e-06 0.001151       0.17371 5
#> MAD:pam     57            0.529    2.34e-06 0.001091       0.05005 5
#> ATC:pam     53            0.603    1.21e-05 0.001424       0.24317 5
#> SD:hclust   58            0.914    5.11e-06 0.002546       0.07831 5
#> CV:hclust   54            0.933    2.32e-05 0.003117       0.08586 5
#> MAD:hclust  59            0.870    4.54e-06 0.002202       0.06657 5
#> ATC:hclust  56            0.493    1.66e-06 0.000749       0.48603 5
test_to_known_factors(res_list, k = 6)
#>              n disease.state(p) protocol(p)  time(p) individual(p) k
#> SD:NMF      41           0.8024    2.75e-04 0.001062        0.5348 6
#> CV:NMF      50           0.4142    1.13e-05 0.000778        0.1842 6
#> MAD:NMF     40           0.9796    4.46e-05 0.000160        0.7365 6
#> ATC:NMF     41           0.9399    2.53e-05 0.000159        0.7493 6
#> SD:skmeans  42           0.8517    7.30e-04 0.010283        0.2509 6
#> CV:skmeans  51           0.0724    3.03e-04 0.006622        0.0231 6
#> MAD:skmeans 41           0.5039    1.44e-04 0.000406        0.2136 6
#> ATC:skmeans 35           0.8719    1.02e-03 0.003829        0.4370 6
#> SD:mclust   49           0.9800    7.67e-06 0.000674        0.2371 6
#> CV:mclust   55           0.6081    2.69e-05 0.001144        0.1768 6
#> MAD:mclust  47           0.9716    1.13e-04 0.005049        0.1261 6
#> ATC:mclust  59           0.9308    1.45e-06 0.000397        0.2921 6
#> SD:kmeans   46           0.9999    1.55e-04 0.001844        0.3598 6
#> CV:kmeans   35           0.9670    6.69e-04 0.012444        0.8002 6
#> MAD:kmeans  46           0.8085    2.34e-05 0.027120        0.0138 6
#> ATC:kmeans  45           0.5618    1.10e-03 0.018149        0.1833 6
#> SD:pam      55           0.8178    1.07e-05 0.005954        0.0463 6
#> CV:pam      58           0.8452    1.25e-05 0.003659        0.1151 6
#> MAD:pam     57           0.6729    8.48e-06 0.002622        0.0769 6
#> ATC:pam     43           0.7136    2.18e-04 0.000806        0.1016 6
#> SD:hclust   50           0.7323    4.84e-05 0.001090        0.1762 6
#> CV:hclust   40           0.6474    1.41e-03 0.008765        0.4468 6
#> MAD:hclust  55           0.8423    7.27e-05 0.015292        0.0113 6
#> ATC:hclust  52           0.7639    9.98e-07 0.001425        0.1397 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.806           0.924       0.937         0.2717 0.892   0.794
#> 4 4 0.786           0.803       0.880         0.1146 0.937   0.849
#> 5 5 0.825           0.824       0.912         0.0490 0.959   0.886
#> 6 6 0.805           0.712       0.854         0.0618 0.886   0.656

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2  0.4504      0.875  0 0.804 0.196
#> GSM802144     2  0.2165      0.876  0 0.936 0.064
#> GSM802153     3  0.1163      0.984  0 0.028 0.972
#> GSM802156     3  0.0592      0.992  0 0.012 0.988
#> GSM802165     2  0.0237      0.863  0 0.996 0.004
#> GSM802168     2  0.1031      0.871  0 0.976 0.024
#> GSM802177     2  0.4452      0.876  0 0.808 0.192
#> GSM802180     2  0.4452      0.876  0 0.808 0.192
#> GSM802189     2  0.4452      0.876  0 0.808 0.192
#> GSM802192     2  0.0237      0.863  0 0.996 0.004
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     2  0.4504      0.875  0 0.804 0.196
#> GSM802145     2  0.2165      0.876  0 0.936 0.064
#> GSM802154     3  0.1163      0.984  0 0.028 0.972
#> GSM802157     3  0.0592      0.992  0 0.012 0.988
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     2  0.4452      0.876  0 0.808 0.192
#> GSM802178     2  0.0592      0.869  0 0.988 0.012
#> GSM802181     2  0.4452      0.876  0 0.808 0.192
#> GSM802190     2  0.4452      0.876  0 0.808 0.192
#> GSM802193     2  0.0592      0.859  0 0.988 0.012
#> GSM802135     2  0.0237      0.863  0 0.996 0.004
#> GSM802138     2  0.0237      0.863  0 0.996 0.004
#> GSM802147     2  0.0747      0.857  0 0.984 0.016
#> GSM802150     2  0.4504      0.875  0 0.804 0.196
#> GSM802159     2  0.5431      0.496  0 0.716 0.284
#> GSM802162     3  0.0592      0.992  0 0.012 0.988
#> GSM802171     2  0.0592      0.869  0 0.988 0.012
#> GSM802174     2  0.4121      0.876  0 0.832 0.168
#> GSM802183     2  0.4504      0.875  0 0.804 0.196
#> GSM802186     2  0.4504      0.875  0 0.804 0.196
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     3  0.0592      0.992  0 0.012 0.988
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     2  0.4504      0.875  0 0.804 0.196
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.0237      0.863  0 0.996 0.004
#> GSM802139     2  0.0237      0.863  0 0.996 0.004
#> GSM802148     2  0.0592      0.859  0 0.988 0.012
#> GSM802152     2  0.4504      0.875  0 0.804 0.196
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.0592      0.869  0 0.988 0.012
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     2  0.4504      0.875  0 0.804 0.196
#> GSM802187     2  0.4504      0.875  0 0.804 0.196

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette   p1    p2    p3    p4
#> GSM802141     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802144     2  0.2760      0.739 0.00 0.872 0.000 0.128
#> GSM802153     3  0.1624      0.973 0.00 0.028 0.952 0.020
#> GSM802156     3  0.0707      0.986 0.00 0.020 0.980 0.000
#> GSM802165     2  0.4522      0.564 0.00 0.680 0.000 0.320
#> GSM802168     2  0.4331      0.611 0.00 0.712 0.000 0.288
#> GSM802177     2  0.0000      0.792 0.00 1.000 0.000 0.000
#> GSM802180     2  0.0000      0.792 0.00 1.000 0.000 0.000
#> GSM802189     2  0.0000      0.792 0.00 1.000 0.000 0.000
#> GSM802192     2  0.4522      0.564 0.00 0.680 0.000 0.320
#> GSM802143     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802155     1  0.4642      0.765 0.74 0.000 0.020 0.240
#> GSM802158     1  0.4642      0.765 0.74 0.000 0.020 0.240
#> GSM802167     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802142     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802145     2  0.2760      0.739 0.00 0.872 0.000 0.128
#> GSM802154     3  0.1624      0.973 0.00 0.028 0.952 0.020
#> GSM802157     3  0.0707      0.986 0.00 0.020 0.980 0.000
#> GSM802166     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802169     2  0.0000      0.792 0.00 1.000 0.000 0.000
#> GSM802178     2  0.4406      0.597 0.00 0.700 0.000 0.300
#> GSM802181     2  0.0000      0.792 0.00 1.000 0.000 0.000
#> GSM802190     2  0.0000      0.792 0.00 1.000 0.000 0.000
#> GSM802193     4  0.4585      0.641 0.00 0.332 0.000 0.668
#> GSM802135     2  0.4304      0.621 0.00 0.716 0.000 0.284
#> GSM802138     2  0.4304      0.621 0.00 0.716 0.000 0.284
#> GSM802147     4  0.4283      0.769 0.00 0.256 0.004 0.740
#> GSM802150     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802159     4  0.4222      0.315 0.00 0.000 0.272 0.728
#> GSM802162     3  0.0707      0.986 0.00 0.020 0.980 0.000
#> GSM802171     2  0.4406      0.597 0.00 0.700 0.000 0.300
#> GSM802174     2  0.4697      0.202 0.00 0.644 0.000 0.356
#> GSM802183     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802186     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802137     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802149     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802151     1  0.4642      0.765 0.74 0.000 0.020 0.240
#> GSM802161     1  0.4642      0.765 0.74 0.000 0.020 0.240
#> GSM802163     3  0.0707      0.986 0.00 0.020 0.980 0.000
#> GSM802173     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802175     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802185     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802136     2  0.4304      0.621 0.00 0.716 0.000 0.284
#> GSM802139     2  0.4304      0.621 0.00 0.716 0.000 0.284
#> GSM802148     4  0.4134      0.767 0.00 0.260 0.000 0.740
#> GSM802152     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802160     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802164     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802172     2  0.4406      0.597 0.00 0.700 0.000 0.300
#> GSM802176     1  0.0000      0.955 1.00 0.000 0.000 0.000
#> GSM802184     2  0.0707      0.788 0.00 0.980 0.000 0.020
#> GSM802187     2  0.0707      0.788 0.00 0.980 0.000 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette   p1    p2    p3    p4   p5
#> GSM802141     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802144     2  0.2377      0.739 0.00 0.872 0.000 0.128 0.00
#> GSM802153     3  0.1168      0.903 0.00 0.008 0.960 0.032 0.00
#> GSM802156     3  0.3109      0.847 0.00 0.000 0.800 0.200 0.00
#> GSM802165     2  0.3895      0.563 0.00 0.680 0.000 0.320 0.00
#> GSM802168     2  0.3730      0.610 0.00 0.712 0.000 0.288 0.00
#> GSM802177     2  0.0000      0.792 0.00 1.000 0.000 0.000 0.00
#> GSM802180     2  0.0000      0.792 0.00 1.000 0.000 0.000 0.00
#> GSM802189     2  0.0000      0.792 0.00 1.000 0.000 0.000 0.00
#> GSM802192     2  0.3895      0.563 0.00 0.680 0.000 0.320 0.00
#> GSM802143     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802146     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802155     5  0.0000      1.000 0.00 0.000 0.000 0.000 1.00
#> GSM802158     5  0.0000      1.000 0.00 0.000 0.000 0.000 1.00
#> GSM802167     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802170     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802179     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802182     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802191     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802194     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802142     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802145     2  0.2377      0.739 0.00 0.872 0.000 0.128 0.00
#> GSM802154     3  0.1168      0.903 0.00 0.008 0.960 0.032 0.00
#> GSM802157     3  0.3109      0.847 0.00 0.000 0.800 0.200 0.00
#> GSM802166     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802169     2  0.0000      0.792 0.00 1.000 0.000 0.000 0.00
#> GSM802178     2  0.3796      0.596 0.00 0.700 0.000 0.300 0.00
#> GSM802181     2  0.0000      0.792 0.00 1.000 0.000 0.000 0.00
#> GSM802190     2  0.0000      0.792 0.00 1.000 0.000 0.000 0.00
#> GSM802193     4  0.3949      0.651 0.00 0.332 0.000 0.668 0.00
#> GSM802135     2  0.3707      0.620 0.00 0.716 0.000 0.284 0.00
#> GSM802138     2  0.3707      0.620 0.00 0.716 0.000 0.284 0.00
#> GSM802147     4  0.3534      0.780 0.00 0.256 0.000 0.744 0.00
#> GSM802150     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802159     4  0.1121      0.401 0.00 0.000 0.044 0.956 0.00
#> GSM802162     3  0.0000      0.912 0.00 0.000 1.000 0.000 0.00
#> GSM802171     2  0.3796      0.596 0.00 0.700 0.000 0.300 0.00
#> GSM802174     2  0.4045      0.198 0.00 0.644 0.000 0.356 0.00
#> GSM802183     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802186     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802137     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802140     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802149     1  0.0609      0.980 0.98 0.000 0.000 0.000 0.02
#> GSM802151     5  0.0000      1.000 0.00 0.000 0.000 0.000 1.00
#> GSM802161     5  0.0000      1.000 0.00 0.000 0.000 0.000 1.00
#> GSM802163     3  0.0000      0.912 0.00 0.000 1.000 0.000 0.00
#> GSM802173     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802175     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802185     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802188     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802136     2  0.3707      0.620 0.00 0.716 0.000 0.284 0.00
#> GSM802139     2  0.3707      0.620 0.00 0.716 0.000 0.284 0.00
#> GSM802148     4  0.3561      0.778 0.00 0.260 0.000 0.740 0.00
#> GSM802152     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802160     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802164     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802172     2  0.3796      0.596 0.00 0.700 0.000 0.300 0.00
#> GSM802176     1  0.0000      0.999 1.00 0.000 0.000 0.000 0.00
#> GSM802184     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00
#> GSM802187     2  0.0609      0.788 0.00 0.980 0.000 0.020 0.00

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette   p1    p2   p3    p4   p5    p6
#> GSM802141     2  0.0603     0.7573 0.00 0.980 0.00 0.004 0.00 0.016
#> GSM802144     2  0.3807     0.2223 0.00 0.628 0.00 0.004 0.00 0.368
#> GSM802153     3  0.1010     0.8845 0.00 0.004 0.96 0.036 0.00 0.000
#> GSM802156     3  0.2793     0.7904 0.00 0.000 0.80 0.200 0.00 0.000
#> GSM802165     6  0.3592     0.5944 0.00 0.344 0.00 0.000 0.00 0.656
#> GSM802168     2  0.3867    -0.3355 0.00 0.512 0.00 0.000 0.00 0.488
#> GSM802177     2  0.2520     0.7188 0.00 0.844 0.00 0.004 0.00 0.152
#> GSM802180     2  0.2520     0.7188 0.00 0.844 0.00 0.004 0.00 0.152
#> GSM802189     2  0.2442     0.7220 0.00 0.852 0.00 0.004 0.00 0.144
#> GSM802192     6  0.3592     0.5944 0.00 0.344 0.00 0.000 0.00 0.656
#> GSM802143     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802146     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802155     5  0.0000     1.0000 0.00 0.000 0.00 0.000 1.00 0.000
#> GSM802158     5  0.0000     1.0000 0.00 0.000 0.00 0.000 1.00 0.000
#> GSM802167     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802170     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802179     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802182     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802191     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802194     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802142     2  0.0603     0.7573 0.00 0.980 0.00 0.004 0.00 0.016
#> GSM802145     2  0.3807     0.2223 0.00 0.628 0.00 0.004 0.00 0.368
#> GSM802154     3  0.1010     0.8845 0.00 0.004 0.96 0.036 0.00 0.000
#> GSM802157     3  0.2793     0.7904 0.00 0.000 0.80 0.200 0.00 0.000
#> GSM802166     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802169     2  0.2871     0.6742 0.00 0.804 0.00 0.004 0.00 0.192
#> GSM802178     6  0.3868     0.3124 0.00 0.492 0.00 0.000 0.00 0.508
#> GSM802181     2  0.2520     0.7188 0.00 0.844 0.00 0.004 0.00 0.152
#> GSM802190     2  0.2871     0.6742 0.00 0.804 0.00 0.004 0.00 0.192
#> GSM802193     6  0.3431    -0.0815 0.00 0.016 0.00 0.228 0.00 0.756
#> GSM802135     6  0.3955     0.5787 0.00 0.384 0.00 0.008 0.00 0.608
#> GSM802138     6  0.3955     0.5787 0.00 0.384 0.00 0.008 0.00 0.608
#> GSM802147     6  0.3446    -0.2053 0.00 0.000 0.00 0.308 0.00 0.692
#> GSM802150     2  0.1753     0.7477 0.00 0.912 0.00 0.004 0.00 0.084
#> GSM802159     4  0.3738     0.0000 0.00 0.000 0.04 0.752 0.00 0.208
#> GSM802162     3  0.0000     0.8934 0.00 0.000 1.00 0.000 0.00 0.000
#> GSM802171     6  0.3695     0.5735 0.00 0.376 0.00 0.000 0.00 0.624
#> GSM802174     2  0.4934     0.2680 0.00 0.632 0.00 0.112 0.00 0.256
#> GSM802183     2  0.0146     0.7493 0.00 0.996 0.00 0.004 0.00 0.000
#> GSM802186     2  0.0146     0.7493 0.00 0.996 0.00 0.004 0.00 0.000
#> GSM802137     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802140     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802149     1  0.0547     0.9784 0.98 0.000 0.00 0.000 0.02 0.000
#> GSM802151     5  0.0000     1.0000 0.00 0.000 0.00 0.000 1.00 0.000
#> GSM802161     5  0.0000     1.0000 0.00 0.000 0.00 0.000 1.00 0.000
#> GSM802163     3  0.0000     0.8934 0.00 0.000 1.00 0.000 0.00 0.000
#> GSM802173     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802175     2  0.0547     0.7550 0.00 0.980 0.00 0.000 0.00 0.020
#> GSM802185     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802188     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802136     6  0.3955     0.5787 0.00 0.384 0.00 0.008 0.00 0.608
#> GSM802139     6  0.3955     0.5787 0.00 0.384 0.00 0.008 0.00 0.608
#> GSM802148     6  0.3371    -0.1875 0.00 0.000 0.00 0.292 0.00 0.708
#> GSM802152     2  0.0146     0.7493 0.00 0.996 0.00 0.004 0.00 0.000
#> GSM802160     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802164     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802172     6  0.3867     0.3207 0.00 0.488 0.00 0.000 0.00 0.512
#> GSM802176     1  0.0000     0.9988 1.00 0.000 0.00 0.000 0.00 0.000
#> GSM802184     2  0.0146     0.7493 0.00 0.996 0.00 0.004 0.00 0.000
#> GSM802187     2  0.0603     0.7573 0.00 0.980 0.00 0.004 0.00 0.016

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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) protocol(p)  time(p) individual(p) k
#> SD:hclust 60            1.000    4.43e-09 0.000103        1.0000 2
#> SD:hclust 59            0.711    1.07e-07 0.000240        0.2305 3
#> SD:hclust 58            0.809    1.14e-06 0.000946        0.0569 4
#> SD:hclust 58            0.914    5.11e-06 0.002546        0.0783 5
#> SD:hclust 50            0.732    4.84e-05 0.001090        0.1762 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.976       0.970         0.4611 0.528   0.528
#> 3 3 0.784           0.929       0.930         0.2495 0.892   0.794
#> 4 4 0.703           0.673       0.811         0.1710 0.883   0.721
#> 5 5 0.670           0.790       0.805         0.0769 0.883   0.643
#> 6 6 0.652           0.625       0.712         0.0727 0.986   0.943

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
#> GSM802141     2  0.0000      0.985 0.000 1.000
#> GSM802144     2  0.0000      0.985 0.000 1.000
#> GSM802153     2  0.3584      0.938 0.068 0.932
#> GSM802156     2  0.3733      0.935 0.072 0.928
#> GSM802165     2  0.0000      0.985 0.000 1.000
#> GSM802168     2  0.0000      0.985 0.000 1.000
#> GSM802177     2  0.0000      0.985 0.000 1.000
#> GSM802180     2  0.0000      0.985 0.000 1.000
#> GSM802189     2  0.0000      0.985 0.000 1.000
#> GSM802192     2  0.0000      0.985 0.000 1.000
#> GSM802143     1  0.3733      0.985 0.928 0.072
#> GSM802146     1  0.3733      0.985 0.928 0.072
#> GSM802155     1  0.0000      0.935 1.000 0.000
#> GSM802158     1  0.0000      0.935 1.000 0.000
#> GSM802167     1  0.3733      0.985 0.928 0.072
#> GSM802170     1  0.3733      0.985 0.928 0.072
#> GSM802179     1  0.3733      0.985 0.928 0.072
#> GSM802182     1  0.3733      0.985 0.928 0.072
#> GSM802191     1  0.3733      0.985 0.928 0.072
#> GSM802194     1  0.3733      0.985 0.928 0.072
#> GSM802142     2  0.0000      0.985 0.000 1.000
#> GSM802145     2  0.0000      0.985 0.000 1.000
#> GSM802154     2  0.3733      0.935 0.072 0.928
#> GSM802157     2  0.3733      0.935 0.072 0.928
#> GSM802166     1  0.3733      0.985 0.928 0.072
#> GSM802169     2  0.0000      0.985 0.000 1.000
#> GSM802178     2  0.0000      0.985 0.000 1.000
#> GSM802181     2  0.0000      0.985 0.000 1.000
#> GSM802190     2  0.0000      0.985 0.000 1.000
#> GSM802193     2  0.0000      0.985 0.000 1.000
#> GSM802135     2  0.0000      0.985 0.000 1.000
#> GSM802138     2  0.0000      0.985 0.000 1.000
#> GSM802147     2  0.0376      0.983 0.004 0.996
#> GSM802150     2  0.0000      0.985 0.000 1.000
#> GSM802159     2  0.3733      0.935 0.072 0.928
#> GSM802162     2  0.3733      0.935 0.072 0.928
#> GSM802171     2  0.0000      0.985 0.000 1.000
#> GSM802174     2  0.0000      0.985 0.000 1.000
#> GSM802183     2  0.0000      0.985 0.000 1.000
#> GSM802186     2  0.0000      0.985 0.000 1.000
#> GSM802137     1  0.3733      0.985 0.928 0.072
#> GSM802140     1  0.3733      0.985 0.928 0.072
#> GSM802149     1  0.3584      0.983 0.932 0.068
#> GSM802151     1  0.0000      0.935 1.000 0.000
#> GSM802161     1  0.0000      0.935 1.000 0.000
#> GSM802163     2  0.3733      0.935 0.072 0.928
#> GSM802173     1  0.3733      0.985 0.928 0.072
#> GSM802175     2  0.0000      0.985 0.000 1.000
#> GSM802185     1  0.3733      0.985 0.928 0.072
#> GSM802188     1  0.3733      0.985 0.928 0.072
#> GSM802136     2  0.0000      0.985 0.000 1.000
#> GSM802139     2  0.0000      0.985 0.000 1.000
#> GSM802148     2  0.0000      0.985 0.000 1.000
#> GSM802152     2  0.0376      0.983 0.004 0.996
#> GSM802160     1  0.3733      0.985 0.928 0.072
#> GSM802164     1  0.3584      0.983 0.932 0.068
#> GSM802172     2  0.0000      0.985 0.000 1.000
#> GSM802176     1  0.3733      0.985 0.928 0.072
#> GSM802184     2  0.0000      0.985 0.000 1.000
#> GSM802187     2  0.0000      0.985 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802144     2  0.0000      0.937 0.000 1.000 0.000
#> GSM802153     2  0.2878      0.916 0.000 0.904 0.096
#> GSM802156     3  0.5138      0.963 0.000 0.252 0.748
#> GSM802165     2  0.0592      0.932 0.000 0.988 0.012
#> GSM802168     2  0.0592      0.937 0.000 0.988 0.012
#> GSM802177     2  0.1860      0.935 0.000 0.948 0.052
#> GSM802180     2  0.1860      0.935 0.000 0.948 0.052
#> GSM802189     2  0.2711      0.922 0.000 0.912 0.088
#> GSM802192     2  0.0592      0.932 0.000 0.988 0.012
#> GSM802143     1  0.0592      0.951 0.988 0.000 0.012
#> GSM802146     1  0.0592      0.951 0.988 0.000 0.012
#> GSM802155     1  0.4842      0.823 0.776 0.000 0.224
#> GSM802158     1  0.4842      0.823 0.776 0.000 0.224
#> GSM802167     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802194     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802142     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802145     2  0.0000      0.937 0.000 1.000 0.000
#> GSM802154     3  0.5138      0.964 0.000 0.252 0.748
#> GSM802157     3  0.5058      0.967 0.000 0.244 0.756
#> GSM802166     1  0.0747      0.949 0.984 0.000 0.016
#> GSM802169     2  0.0237      0.935 0.000 0.996 0.004
#> GSM802178     2  0.0237      0.935 0.000 0.996 0.004
#> GSM802181     2  0.1860      0.935 0.000 0.948 0.052
#> GSM802190     2  0.1860      0.935 0.000 0.948 0.052
#> GSM802193     2  0.0747      0.930 0.000 0.984 0.016
#> GSM802135     2  0.0592      0.932 0.000 0.988 0.012
#> GSM802138     2  0.0424      0.935 0.000 0.992 0.008
#> GSM802147     2  0.1860      0.897 0.000 0.948 0.052
#> GSM802150     2  0.1643      0.937 0.000 0.956 0.044
#> GSM802159     3  0.5785      0.865 0.000 0.332 0.668
#> GSM802162     3  0.5058      0.967 0.000 0.244 0.756
#> GSM802171     2  0.0592      0.932 0.000 0.988 0.012
#> GSM802174     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802183     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802186     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802137     1  0.0592      0.951 0.988 0.000 0.012
#> GSM802140     1  0.0592      0.951 0.988 0.000 0.012
#> GSM802149     1  0.0592      0.951 0.988 0.000 0.012
#> GSM802151     1  0.4842      0.823 0.776 0.000 0.224
#> GSM802161     1  0.4842      0.823 0.776 0.000 0.224
#> GSM802163     3  0.5138      0.964 0.000 0.252 0.748
#> GSM802173     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802175     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802185     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802188     1  0.0000      0.952 1.000 0.000 0.000
#> GSM802136     2  0.0424      0.935 0.000 0.992 0.008
#> GSM802139     2  0.0000      0.937 0.000 1.000 0.000
#> GSM802148     2  0.0747      0.930 0.000 0.984 0.016
#> GSM802152     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802160     1  0.0747      0.949 0.984 0.000 0.016
#> GSM802164     1  0.4002      0.865 0.840 0.000 0.160
#> GSM802172     2  0.0237      0.935 0.000 0.996 0.004
#> GSM802176     1  0.0592      0.951 0.988 0.000 0.012
#> GSM802184     2  0.2796      0.920 0.000 0.908 0.092
#> GSM802187     2  0.2796      0.920 0.000 0.908 0.092

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.0336      0.726 0.000 0.992 0.000 0.008
#> GSM802144     2  0.4855     -0.457 0.000 0.600 0.000 0.400
#> GSM802153     2  0.0804      0.718 0.000 0.980 0.012 0.008
#> GSM802156     3  0.3695      0.943 0.000 0.156 0.828 0.016
#> GSM802165     4  0.5220      0.898 0.000 0.424 0.008 0.568
#> GSM802168     2  0.3024      0.594 0.000 0.852 0.000 0.148
#> GSM802177     2  0.2345      0.671 0.000 0.900 0.000 0.100
#> GSM802180     2  0.1211      0.719 0.000 0.960 0.000 0.040
#> GSM802189     2  0.0469      0.728 0.000 0.988 0.000 0.012
#> GSM802192     4  0.5220      0.898 0.000 0.424 0.008 0.568
#> GSM802143     1  0.2224      0.881 0.928 0.000 0.032 0.040
#> GSM802146     1  0.2224      0.881 0.928 0.000 0.032 0.040
#> GSM802155     1  0.6468      0.606 0.568 0.000 0.084 0.348
#> GSM802158     1  0.6426      0.606 0.568 0.000 0.080 0.352
#> GSM802167     1  0.0188      0.891 0.996 0.000 0.004 0.000
#> GSM802170     1  0.0336      0.891 0.992 0.000 0.008 0.000
#> GSM802179     1  0.0000      0.891 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0469      0.890 0.988 0.000 0.012 0.000
#> GSM802191     1  0.0469      0.890 0.988 0.000 0.012 0.000
#> GSM802194     1  0.0188      0.891 0.996 0.000 0.004 0.000
#> GSM802142     2  0.0336      0.726 0.000 0.992 0.000 0.008
#> GSM802145     2  0.4855     -0.457 0.000 0.600 0.000 0.400
#> GSM802154     3  0.3311      0.942 0.000 0.172 0.828 0.000
#> GSM802157     3  0.3625      0.945 0.000 0.160 0.828 0.012
#> GSM802166     1  0.2300      0.882 0.924 0.000 0.048 0.028
#> GSM802169     2  0.4817     -0.399 0.000 0.612 0.000 0.388
#> GSM802178     4  0.4992      0.822 0.000 0.476 0.000 0.524
#> GSM802181     2  0.2281      0.674 0.000 0.904 0.000 0.096
#> GSM802190     2  0.2011      0.687 0.000 0.920 0.000 0.080
#> GSM802193     4  0.5016      0.884 0.000 0.396 0.004 0.600
#> GSM802135     4  0.5203      0.892 0.000 0.416 0.008 0.576
#> GSM802138     2  0.5244     -0.613 0.000 0.556 0.008 0.436
#> GSM802147     4  0.6794      0.731 0.000 0.372 0.104 0.524
#> GSM802150     2  0.1474      0.707 0.000 0.948 0.000 0.052
#> GSM802159     3  0.5756      0.727 0.000 0.084 0.692 0.224
#> GSM802162     3  0.3545      0.945 0.000 0.164 0.828 0.008
#> GSM802171     4  0.5281      0.856 0.000 0.464 0.008 0.528
#> GSM802174     2  0.1978      0.690 0.000 0.928 0.004 0.068
#> GSM802183     2  0.0524      0.727 0.000 0.988 0.004 0.008
#> GSM802186     2  0.0524      0.727 0.000 0.988 0.004 0.008
#> GSM802137     1  0.2500      0.879 0.916 0.000 0.044 0.040
#> GSM802140     1  0.2319      0.881 0.924 0.000 0.036 0.040
#> GSM802149     1  0.2871      0.876 0.896 0.000 0.072 0.032
#> GSM802151     1  0.6426      0.606 0.568 0.000 0.080 0.352
#> GSM802161     1  0.6412      0.607 0.572 0.000 0.080 0.348
#> GSM802163     3  0.3311      0.942 0.000 0.172 0.828 0.000
#> GSM802173     1  0.0000      0.891 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0524      0.727 0.000 0.988 0.004 0.008
#> GSM802185     1  0.0469      0.890 0.988 0.000 0.012 0.000
#> GSM802188     1  0.0469      0.890 0.988 0.000 0.012 0.000
#> GSM802136     2  0.5244     -0.613 0.000 0.556 0.008 0.436
#> GSM802139     2  0.4877     -0.483 0.000 0.592 0.000 0.408
#> GSM802148     4  0.5016      0.884 0.000 0.396 0.004 0.600
#> GSM802152     2  0.0524      0.724 0.000 0.988 0.004 0.008
#> GSM802160     1  0.2385      0.881 0.920 0.000 0.052 0.028
#> GSM802164     1  0.4824      0.775 0.780 0.000 0.076 0.144
#> GSM802172     4  0.4992      0.822 0.000 0.476 0.000 0.524
#> GSM802176     1  0.2124      0.882 0.932 0.000 0.028 0.040
#> GSM802184     2  0.0524      0.727 0.000 0.988 0.004 0.008
#> GSM802187     2  0.0524      0.724 0.000 0.988 0.004 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.1300      0.848 0.000 0.956 0.000 0.016 0.028
#> GSM802144     4  0.5684      0.704 0.000 0.432 0.000 0.488 0.080
#> GSM802153     2  0.2151      0.825 0.000 0.924 0.020 0.016 0.040
#> GSM802156     3  0.2457      0.933 0.000 0.076 0.900 0.008 0.016
#> GSM802165     4  0.3752      0.778 0.000 0.292 0.000 0.708 0.000
#> GSM802168     2  0.3479      0.763 0.000 0.836 0.000 0.080 0.084
#> GSM802177     2  0.3090      0.797 0.000 0.860 0.000 0.052 0.088
#> GSM802180     2  0.1893      0.845 0.000 0.928 0.000 0.024 0.048
#> GSM802189     2  0.1300      0.857 0.000 0.956 0.000 0.016 0.028
#> GSM802192     4  0.4485      0.778 0.000 0.292 0.000 0.680 0.028
#> GSM802143     1  0.3463      0.808 0.840 0.000 0.020 0.120 0.020
#> GSM802146     1  0.3166      0.809 0.856 0.000 0.012 0.112 0.020
#> GSM802155     5  0.4084      0.997 0.328 0.000 0.004 0.000 0.668
#> GSM802158     5  0.3932      0.999 0.328 0.000 0.000 0.000 0.672
#> GSM802167     1  0.0162      0.853 0.996 0.000 0.004 0.000 0.000
#> GSM802170     1  0.0451      0.852 0.988 0.000 0.004 0.008 0.000
#> GSM802179     1  0.0162      0.853 0.996 0.000 0.004 0.000 0.000
#> GSM802182     1  0.1579      0.843 0.944 0.000 0.032 0.024 0.000
#> GSM802191     1  0.1493      0.844 0.948 0.000 0.028 0.024 0.000
#> GSM802194     1  0.0162      0.853 0.996 0.000 0.004 0.000 0.000
#> GSM802142     2  0.1300      0.848 0.000 0.956 0.000 0.016 0.028
#> GSM802145     4  0.5684      0.704 0.000 0.432 0.000 0.488 0.080
#> GSM802154     3  0.2233      0.933 0.000 0.080 0.904 0.000 0.016
#> GSM802157     3  0.2393      0.934 0.000 0.080 0.900 0.004 0.016
#> GSM802166     1  0.3579      0.765 0.836 0.000 0.032 0.116 0.016
#> GSM802169     2  0.5627     -0.352 0.000 0.548 0.000 0.368 0.084
#> GSM802178     4  0.5678      0.713 0.000 0.392 0.000 0.524 0.084
#> GSM802181     2  0.3090      0.797 0.000 0.860 0.000 0.052 0.088
#> GSM802190     2  0.3102      0.799 0.000 0.860 0.000 0.056 0.084
#> GSM802193     4  0.5832      0.698 0.000 0.248 0.000 0.600 0.152
#> GSM802135     4  0.4780      0.777 0.000 0.280 0.000 0.672 0.048
#> GSM802138     4  0.5484      0.745 0.000 0.392 0.000 0.540 0.068
#> GSM802147     4  0.7203      0.608 0.000 0.224 0.088 0.544 0.144
#> GSM802150     2  0.3354      0.763 0.000 0.844 0.000 0.088 0.068
#> GSM802159     3  0.5005      0.723 0.000 0.036 0.696 0.244 0.024
#> GSM802162     3  0.1732      0.936 0.000 0.080 0.920 0.000 0.000
#> GSM802171     4  0.4313      0.779 0.000 0.356 0.000 0.636 0.008
#> GSM802174     2  0.2278      0.831 0.000 0.908 0.000 0.032 0.060
#> GSM802183     2  0.0404      0.860 0.000 0.988 0.000 0.000 0.012
#> GSM802186     2  0.0404      0.860 0.000 0.988 0.000 0.000 0.012
#> GSM802137     1  0.3257      0.807 0.852 0.000 0.012 0.112 0.024
#> GSM802140     1  0.3166      0.809 0.856 0.000 0.012 0.112 0.020
#> GSM802149     1  0.4734      0.710 0.732 0.000 0.040 0.208 0.020
#> GSM802151     5  0.3932      0.999 0.328 0.000 0.000 0.000 0.672
#> GSM802161     5  0.3932      0.999 0.328 0.000 0.000 0.000 0.672
#> GSM802163     3  0.2130      0.934 0.000 0.080 0.908 0.000 0.012
#> GSM802173     1  0.0162      0.853 0.996 0.000 0.004 0.000 0.000
#> GSM802175     2  0.0510      0.860 0.000 0.984 0.000 0.000 0.016
#> GSM802185     1  0.1661      0.842 0.940 0.000 0.036 0.024 0.000
#> GSM802188     1  0.1579      0.843 0.944 0.000 0.032 0.024 0.000
#> GSM802136     4  0.5484      0.745 0.000 0.392 0.000 0.540 0.068
#> GSM802139     4  0.5542      0.708 0.000 0.432 0.000 0.500 0.068
#> GSM802148     4  0.5612      0.702 0.000 0.248 0.000 0.624 0.128
#> GSM802152     2  0.1211      0.849 0.000 0.960 0.000 0.016 0.024
#> GSM802160     1  0.3707      0.765 0.828 0.000 0.036 0.120 0.016
#> GSM802164     1  0.5197      0.154 0.664 0.000 0.036 0.024 0.276
#> GSM802172     4  0.5678      0.713 0.000 0.392 0.000 0.524 0.084
#> GSM802176     1  0.3262      0.815 0.856 0.000 0.020 0.104 0.020
#> GSM802184     2  0.0510      0.860 0.000 0.984 0.000 0.000 0.016
#> GSM802187     2  0.1211      0.849 0.000 0.960 0.000 0.016 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.2266      0.692 0.000 0.908 0.000 0.024 0.040 0.028
#> GSM802144     4  0.5506      0.494 0.000 0.264 0.000 0.616 0.052 0.068
#> GSM802153     2  0.2938      0.674 0.000 0.880 0.020 0.020 0.040 0.040
#> GSM802156     3  0.1608      0.906 0.000 0.020 0.944 0.008 0.020 0.008
#> GSM802165     4  0.4284      0.191 0.000 0.136 0.000 0.748 0.008 0.108
#> GSM802168     2  0.6091      0.586 0.000 0.592 0.000 0.072 0.132 0.204
#> GSM802177     2  0.5889      0.605 0.000 0.616 0.000 0.068 0.120 0.196
#> GSM802180     2  0.5133      0.659 0.000 0.692 0.000 0.040 0.116 0.152
#> GSM802189     2  0.4535      0.685 0.000 0.748 0.000 0.032 0.116 0.104
#> GSM802192     4  0.5565      0.113 0.000 0.136 0.000 0.640 0.040 0.184
#> GSM802143     1  0.3376      0.738 0.764 0.000 0.000 0.000 0.016 0.220
#> GSM802146     1  0.3348      0.739 0.768 0.000 0.000 0.000 0.016 0.216
#> GSM802155     5  0.3288      0.996 0.276 0.000 0.000 0.000 0.724 0.000
#> GSM802158     5  0.3288      0.996 0.276 0.000 0.000 0.000 0.724 0.000
#> GSM802167     1  0.0632      0.804 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM802170     1  0.0260      0.803 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802179     1  0.0363      0.803 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM802182     1  0.1699      0.792 0.936 0.000 0.016 0.032 0.000 0.016
#> GSM802191     1  0.1699      0.792 0.936 0.000 0.016 0.032 0.000 0.016
#> GSM802194     1  0.0632      0.804 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM802142     2  0.2266      0.692 0.000 0.908 0.000 0.024 0.040 0.028
#> GSM802145     4  0.5456      0.495 0.000 0.264 0.000 0.620 0.052 0.064
#> GSM802154     3  0.1262      0.905 0.000 0.020 0.956 0.000 0.008 0.016
#> GSM802157     3  0.1608      0.906 0.000 0.020 0.944 0.008 0.020 0.008
#> GSM802166     1  0.4131      0.669 0.752 0.000 0.004 0.064 0.004 0.176
#> GSM802169     2  0.7370     -0.164 0.000 0.356 0.000 0.292 0.120 0.232
#> GSM802178     4  0.7025      0.132 0.000 0.176 0.000 0.460 0.116 0.248
#> GSM802181     2  0.5852      0.609 0.000 0.620 0.000 0.068 0.116 0.196
#> GSM802190     2  0.5849      0.607 0.000 0.620 0.000 0.064 0.124 0.192
#> GSM802193     6  0.5668      0.699 0.000 0.108 0.000 0.428 0.012 0.452
#> GSM802135     4  0.2538      0.326 0.000 0.124 0.000 0.860 0.000 0.016
#> GSM802138     4  0.4381      0.493 0.000 0.236 0.000 0.708 0.032 0.024
#> GSM802147     6  0.6850      0.736 0.000 0.100 0.044 0.392 0.040 0.424
#> GSM802150     2  0.5537      0.593 0.000 0.668 0.000 0.104 0.084 0.144
#> GSM802159     3  0.5752      0.504 0.000 0.004 0.620 0.232 0.052 0.092
#> GSM802162     3  0.0547      0.908 0.000 0.020 0.980 0.000 0.000 0.000
#> GSM802171     4  0.5204      0.299 0.000 0.164 0.000 0.688 0.052 0.096
#> GSM802174     2  0.5044      0.667 0.000 0.708 0.000 0.052 0.140 0.100
#> GSM802183     2  0.0790      0.721 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM802186     2  0.0790      0.721 0.000 0.968 0.000 0.000 0.032 0.000
#> GSM802137     1  0.3457      0.732 0.752 0.000 0.000 0.000 0.016 0.232
#> GSM802140     1  0.3376      0.738 0.764 0.000 0.000 0.000 0.016 0.220
#> GSM802149     1  0.4986      0.608 0.632 0.000 0.004 0.060 0.012 0.292
#> GSM802151     5  0.3288      0.996 0.276 0.000 0.000 0.000 0.724 0.000
#> GSM802161     5  0.3555      0.987 0.280 0.000 0.000 0.000 0.712 0.008
#> GSM802163     3  0.1262      0.905 0.000 0.020 0.956 0.000 0.008 0.016
#> GSM802173     1  0.0363      0.803 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM802175     2  0.1007      0.721 0.000 0.956 0.000 0.000 0.044 0.000
#> GSM802185     1  0.1699      0.792 0.936 0.000 0.016 0.032 0.000 0.016
#> GSM802188     1  0.1699      0.792 0.936 0.000 0.016 0.032 0.000 0.016
#> GSM802136     4  0.4381      0.493 0.000 0.236 0.000 0.708 0.032 0.024
#> GSM802139     4  0.5000      0.497 0.000 0.264 0.000 0.652 0.048 0.036
#> GSM802148     4  0.5764     -0.795 0.000 0.104 0.000 0.480 0.020 0.396
#> GSM802152     2  0.2403      0.702 0.000 0.900 0.000 0.020 0.040 0.040
#> GSM802160     1  0.4249      0.667 0.740 0.000 0.004 0.068 0.004 0.184
#> GSM802164     1  0.4867      0.200 0.660 0.000 0.016 0.032 0.276 0.016
#> GSM802172     4  0.7025      0.132 0.000 0.176 0.000 0.460 0.116 0.248
#> GSM802176     1  0.3746      0.743 0.764 0.000 0.012 0.004 0.016 0.204
#> GSM802184     2  0.1007      0.721 0.000 0.956 0.000 0.000 0.044 0.000
#> GSM802187     2  0.1875      0.696 0.000 0.928 0.000 0.020 0.032 0.020

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

consensus_heatmap(res, k = 2)

plot of chunk tab-SD-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) protocol(p)  time(p) individual(p) k
#> SD:kmeans 60            1.000    4.43e-09 0.000103         1.000 2
#> SD:kmeans 60            1.000    7.22e-08 0.000167         0.575 3
#> SD:kmeans 54            0.982    4.92e-06 0.000312         0.200 4
#> SD:kmeans 58            0.982    1.91e-06 0.001449         0.080 5
#> SD:kmeans 46            1.000    1.55e-04 0.001844         0.360 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.857           0.946       0.963         0.3129 0.864   0.743
#> 4 4 0.882           0.924       0.950         0.1675 0.849   0.631
#> 5 5 0.791           0.683       0.829         0.0600 0.980   0.926
#> 6 6 0.781           0.651       0.809         0.0439 0.884   0.586

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2  0.3551      0.903  0 0.868 0.132
#> GSM802144     2  0.0000      0.926  0 1.000 0.000
#> GSM802153     3  0.0000      0.972  0 0.000 1.000
#> GSM802156     3  0.1031      0.957  0 0.024 0.976
#> GSM802165     2  0.0000      0.926  0 1.000 0.000
#> GSM802168     2  0.0892      0.926  0 0.980 0.020
#> GSM802177     2  0.2711      0.919  0 0.912 0.088
#> GSM802180     2  0.3038      0.915  0 0.896 0.104
#> GSM802189     2  0.3482      0.905  0 0.872 0.128
#> GSM802192     2  0.0000      0.926  0 1.000 0.000
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     2  0.3941      0.888  0 0.844 0.156
#> GSM802145     2  0.0000      0.926  0 1.000 0.000
#> GSM802154     3  0.0000      0.972  0 0.000 1.000
#> GSM802157     3  0.0000      0.972  0 0.000 1.000
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     2  0.0000      0.926  0 1.000 0.000
#> GSM802178     2  0.0000      0.926  0 1.000 0.000
#> GSM802181     2  0.2796      0.918  0 0.908 0.092
#> GSM802190     2  0.3038      0.915  0 0.896 0.104
#> GSM802193     2  0.0000      0.926  0 1.000 0.000
#> GSM802135     2  0.0000      0.926  0 1.000 0.000
#> GSM802138     2  0.0000      0.926  0 1.000 0.000
#> GSM802147     2  0.5216      0.597  0 0.740 0.260
#> GSM802150     2  0.2537      0.921  0 0.920 0.080
#> GSM802159     3  0.3879      0.838  0 0.152 0.848
#> GSM802162     3  0.0000      0.972  0 0.000 1.000
#> GSM802171     2  0.0000      0.926  0 1.000 0.000
#> GSM802174     2  0.3267      0.911  0 0.884 0.116
#> GSM802183     2  0.3879      0.891  0 0.848 0.152
#> GSM802186     2  0.3879      0.891  0 0.848 0.152
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     3  0.0000      0.972  0 0.000 1.000
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     2  0.3752      0.896  0 0.856 0.144
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.0000      0.926  0 1.000 0.000
#> GSM802139     2  0.0000      0.926  0 1.000 0.000
#> GSM802148     2  0.0000      0.926  0 1.000 0.000
#> GSM802152     3  0.0424      0.967  0 0.008 0.992
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.0000      0.926  0 1.000 0.000
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     2  0.3816      0.893  0 0.852 0.148
#> GSM802187     2  0.3941      0.888  0 0.844 0.156

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.0592      0.922 0.000 0.984 0.000 0.016
#> GSM802144     4  0.3074      0.849 0.000 0.152 0.000 0.848
#> GSM802153     2  0.2704      0.838 0.000 0.876 0.124 0.000
#> GSM802156     3  0.0188      0.993 0.000 0.004 0.996 0.000
#> GSM802165     4  0.1211      0.885 0.000 0.040 0.000 0.960
#> GSM802168     2  0.2868      0.882 0.000 0.864 0.000 0.136
#> GSM802177     2  0.2530      0.900 0.000 0.888 0.000 0.112
#> GSM802180     2  0.1940      0.917 0.000 0.924 0.000 0.076
#> GSM802189     2  0.1940      0.917 0.000 0.924 0.000 0.076
#> GSM802192     4  0.1211      0.885 0.000 0.040 0.000 0.960
#> GSM802143     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0895      0.984 0.976 0.000 0.004 0.020
#> GSM802158     1  0.0895      0.984 0.976 0.000 0.004 0.020
#> GSM802167     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802142     2  0.0592      0.922 0.000 0.984 0.000 0.016
#> GSM802145     4  0.3024      0.851 0.000 0.148 0.000 0.852
#> GSM802154     3  0.0188      0.993 0.000 0.004 0.996 0.000
#> GSM802157     3  0.0188      0.993 0.000 0.004 0.996 0.000
#> GSM802166     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802169     4  0.4477      0.546 0.000 0.312 0.000 0.688
#> GSM802178     4  0.1302      0.885 0.000 0.044 0.000 0.956
#> GSM802181     2  0.2530      0.900 0.000 0.888 0.000 0.112
#> GSM802190     2  0.2647      0.895 0.000 0.880 0.000 0.120
#> GSM802193     4  0.1118      0.884 0.000 0.036 0.000 0.964
#> GSM802135     4  0.1118      0.881 0.000 0.036 0.000 0.964
#> GSM802138     4  0.2973      0.851 0.000 0.144 0.000 0.856
#> GSM802147     4  0.5713      0.380 0.000 0.036 0.360 0.604
#> GSM802150     2  0.1557      0.904 0.000 0.944 0.000 0.056
#> GSM802159     3  0.1022      0.966 0.000 0.000 0.968 0.032
#> GSM802162     3  0.0188      0.993 0.000 0.004 0.996 0.000
#> GSM802171     4  0.1211      0.885 0.000 0.040 0.000 0.960
#> GSM802174     2  0.2530      0.900 0.000 0.888 0.000 0.112
#> GSM802183     2  0.0188      0.929 0.000 0.996 0.004 0.000
#> GSM802186     2  0.0188      0.929 0.000 0.996 0.004 0.000
#> GSM802137     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0657      0.988 0.984 0.000 0.004 0.012
#> GSM802151     1  0.0895      0.984 0.976 0.000 0.004 0.020
#> GSM802161     1  0.0895      0.984 0.976 0.000 0.004 0.020
#> GSM802163     3  0.0188      0.993 0.000 0.004 0.996 0.000
#> GSM802173     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0188      0.929 0.000 0.996 0.004 0.000
#> GSM802185     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802136     4  0.2973      0.851 0.000 0.144 0.000 0.856
#> GSM802139     4  0.3074      0.849 0.000 0.152 0.000 0.848
#> GSM802148     4  0.1118      0.884 0.000 0.036 0.000 0.964
#> GSM802152     2  0.1584      0.907 0.000 0.952 0.036 0.012
#> GSM802160     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802164     1  0.0779      0.986 0.980 0.000 0.004 0.016
#> GSM802172     4  0.1302      0.885 0.000 0.044 0.000 0.956
#> GSM802176     1  0.0000      0.995 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0188      0.929 0.000 0.996 0.004 0.000
#> GSM802187     2  0.0779      0.922 0.000 0.980 0.004 0.016

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.2127     0.7487 0.000 0.892 0.000 0.108 0.000
#> GSM802144     4  0.1106     0.5749 0.000 0.024 0.000 0.964 0.012
#> GSM802153     2  0.2825     0.7154 0.000 0.860 0.124 0.016 0.000
#> GSM802156     3  0.0000     0.9748 0.000 0.000 1.000 0.000 0.000
#> GSM802165     4  0.3684     0.3605 0.000 0.000 0.000 0.720 0.280
#> GSM802168     2  0.4668     0.5796 0.000 0.624 0.000 0.024 0.352
#> GSM802177     2  0.4456     0.6372 0.000 0.660 0.000 0.020 0.320
#> GSM802180     2  0.3906     0.7105 0.000 0.744 0.000 0.016 0.240
#> GSM802189     2  0.3759     0.7209 0.000 0.764 0.000 0.016 0.220
#> GSM802192     4  0.4210     0.0308 0.000 0.000 0.000 0.588 0.412
#> GSM802143     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802155     1  0.4101     0.6759 0.628 0.000 0.000 0.000 0.372
#> GSM802158     1  0.4101     0.6759 0.628 0.000 0.000 0.000 0.372
#> GSM802167     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0162     0.9162 0.996 0.000 0.000 0.000 0.004
#> GSM802191     1  0.0162     0.9162 0.996 0.000 0.000 0.000 0.004
#> GSM802194     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.2074     0.7497 0.000 0.896 0.000 0.104 0.000
#> GSM802145     4  0.0992     0.5771 0.000 0.024 0.000 0.968 0.008
#> GSM802154     3  0.0000     0.9748 0.000 0.000 1.000 0.000 0.000
#> GSM802157     3  0.0000     0.9748 0.000 0.000 1.000 0.000 0.000
#> GSM802166     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802169     5  0.6519     0.1923 0.000 0.192 0.000 0.400 0.408
#> GSM802178     4  0.5049    -0.2677 0.000 0.032 0.000 0.488 0.480
#> GSM802181     2  0.4419     0.6464 0.000 0.668 0.000 0.020 0.312
#> GSM802190     2  0.4384     0.6382 0.000 0.660 0.000 0.016 0.324
#> GSM802193     5  0.4268     0.0540 0.000 0.000 0.000 0.444 0.556
#> GSM802135     4  0.2074     0.5239 0.000 0.000 0.000 0.896 0.104
#> GSM802138     4  0.0703     0.5778 0.000 0.024 0.000 0.976 0.000
#> GSM802147     5  0.6358     0.2846 0.000 0.000 0.276 0.208 0.516
#> GSM802150     2  0.5205     0.6131 0.000 0.672 0.000 0.224 0.104
#> GSM802159     3  0.2408     0.8613 0.000 0.000 0.892 0.016 0.092
#> GSM802162     3  0.0000     0.9748 0.000 0.000 1.000 0.000 0.000
#> GSM802171     4  0.4608     0.1653 0.000 0.024 0.000 0.640 0.336
#> GSM802174     2  0.4080     0.6879 0.000 0.728 0.000 0.020 0.252
#> GSM802183     2  0.0000     0.7853 0.000 1.000 0.000 0.000 0.000
#> GSM802186     2  0.0000     0.7853 0.000 1.000 0.000 0.000 0.000
#> GSM802137     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.1965     0.8680 0.904 0.000 0.000 0.000 0.096
#> GSM802151     1  0.4101     0.6759 0.628 0.000 0.000 0.000 0.372
#> GSM802161     1  0.4101     0.6759 0.628 0.000 0.000 0.000 0.372
#> GSM802163     3  0.0000     0.9748 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0000     0.7853 0.000 1.000 0.000 0.000 0.000
#> GSM802185     1  0.0162     0.9162 0.996 0.000 0.000 0.000 0.004
#> GSM802188     1  0.0162     0.9162 0.996 0.000 0.000 0.000 0.004
#> GSM802136     4  0.0703     0.5778 0.000 0.024 0.000 0.976 0.000
#> GSM802139     4  0.0865     0.5776 0.000 0.024 0.000 0.972 0.004
#> GSM802148     4  0.4126     0.1735 0.000 0.000 0.000 0.620 0.380
#> GSM802152     2  0.1648     0.7710 0.000 0.940 0.020 0.040 0.000
#> GSM802160     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802164     1  0.3816     0.7278 0.696 0.000 0.000 0.000 0.304
#> GSM802172     4  0.5049    -0.2677 0.000 0.032 0.000 0.488 0.480
#> GSM802176     1  0.0000     0.9170 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0000     0.7853 0.000 1.000 0.000 0.000 0.000
#> GSM802187     2  0.1908     0.7561 0.000 0.908 0.000 0.092 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
#> GSM802141     2  0.2566    0.71598 0.000 0.868 0.000 0.112 0.008 0.012
#> GSM802144     4  0.0891    0.85672 0.000 0.008 0.000 0.968 0.000 0.024
#> GSM802153     2  0.2714    0.67081 0.000 0.848 0.136 0.012 0.004 0.000
#> GSM802156     3  0.0000    0.96620 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802165     4  0.4977    0.23731 0.000 0.000 0.000 0.552 0.076 0.372
#> GSM802168     6  0.4760    0.13240 0.000 0.376 0.000 0.040 0.008 0.576
#> GSM802177     6  0.4719   -0.05795 0.000 0.464 0.000 0.024 0.012 0.500
#> GSM802180     2  0.4546    0.14070 0.000 0.540 0.000 0.016 0.012 0.432
#> GSM802189     2  0.4497    0.29860 0.000 0.600 0.000 0.020 0.012 0.368
#> GSM802192     6  0.4871    0.15784 0.000 0.000 0.000 0.348 0.072 0.580
#> GSM802143     1  0.0363    0.92898 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802146     1  0.0363    0.92898 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802155     5  0.3499    1.00000 0.320 0.000 0.000 0.000 0.680 0.000
#> GSM802158     5  0.3499    1.00000 0.320 0.000 0.000 0.000 0.680 0.000
#> GSM802167     1  0.0000    0.93125 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000    0.93125 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000    0.93125 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0146    0.92956 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802191     1  0.0146    0.92956 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802194     1  0.0000    0.93125 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.2566    0.71598 0.000 0.868 0.000 0.112 0.008 0.012
#> GSM802145     4  0.0622    0.86701 0.000 0.008 0.000 0.980 0.000 0.012
#> GSM802154     3  0.0000    0.96620 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802157     3  0.0000    0.96620 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802166     1  0.0622    0.92481 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM802169     6  0.4952    0.43918 0.000 0.132 0.000 0.188 0.008 0.672
#> GSM802178     6  0.3998    0.37860 0.000 0.016 0.000 0.236 0.020 0.728
#> GSM802181     6  0.4579   -0.09855 0.000 0.480 0.000 0.016 0.012 0.492
#> GSM802190     6  0.4795   -0.03984 0.000 0.456 0.000 0.024 0.016 0.504
#> GSM802193     6  0.5121    0.24284 0.000 0.000 0.000 0.124 0.272 0.604
#> GSM802135     4  0.2263    0.77516 0.000 0.000 0.000 0.884 0.016 0.100
#> GSM802138     4  0.0146    0.87000 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM802147     6  0.5950    0.21411 0.000 0.000 0.152 0.024 0.284 0.540
#> GSM802150     2  0.6053    0.18244 0.000 0.440 0.000 0.360 0.008 0.192
#> GSM802159     3  0.3281    0.81245 0.000 0.000 0.828 0.012 0.036 0.124
#> GSM802162     3  0.0000    0.96620 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     6  0.5029   -0.05196 0.000 0.008 0.000 0.448 0.052 0.492
#> GSM802174     2  0.4183    0.28134 0.000 0.604 0.000 0.008 0.008 0.380
#> GSM802183     2  0.0291    0.74476 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM802186     2  0.0291    0.74476 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM802137     1  0.0508    0.92710 0.984 0.000 0.000 0.000 0.012 0.004
#> GSM802140     1  0.0363    0.92898 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802149     1  0.3103    0.57433 0.784 0.000 0.000 0.000 0.208 0.008
#> GSM802151     5  0.3499    1.00000 0.320 0.000 0.000 0.000 0.680 0.000
#> GSM802161     5  0.3499    1.00000 0.320 0.000 0.000 0.000 0.680 0.000
#> GSM802163     3  0.0000    0.96620 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802173     1  0.0000    0.93125 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.1155    0.73576 0.000 0.956 0.000 0.004 0.004 0.036
#> GSM802185     1  0.0146    0.92956 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802188     1  0.0146    0.92956 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802136     4  0.0146    0.87000 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM802139     4  0.0405    0.86924 0.000 0.008 0.000 0.988 0.000 0.004
#> GSM802148     6  0.5980   -0.00356 0.000 0.000 0.000 0.264 0.292 0.444
#> GSM802152     2  0.2606    0.73562 0.000 0.896 0.036 0.032 0.008 0.028
#> GSM802160     1  0.0622    0.92481 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM802164     1  0.3854   -0.52369 0.536 0.000 0.000 0.000 0.464 0.000
#> GSM802172     6  0.4199    0.36898 0.000 0.016 0.000 0.244 0.028 0.712
#> GSM802176     1  0.0363    0.92898 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802184     2  0.0603    0.74307 0.000 0.980 0.000 0.000 0.004 0.016
#> GSM802187     2  0.1387    0.73418 0.000 0.932 0.000 0.068 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk SD-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk SD-skmeans-collect-classes

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

test_to_known_factors(res)
#>             n disease.state(p) protocol(p)  time(p) individual(p) k
#> SD:skmeans 60            1.000    4.43e-09 0.000103         1.000 2
#> SD:skmeans 60            1.000    7.98e-08 0.000167         0.501 3
#> SD:skmeans 59            0.998    4.84e-07 0.000540         0.156 4
#> SD:skmeans 51            0.872    1.32e-05 0.000452         0.110 5
#> SD:skmeans 42            0.852    7.30e-04 0.010283         0.251 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 3.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000          0.473 0.528   0.528
#> 3 3 1.000           1.000       1.000          0.229 0.892   0.794
#> 4 4 0.893           0.875       0.949          0.214 0.883   0.721
#> 5 5 0.893           0.874       0.949          0.058 0.959   0.865
#> 6 6 0.900           0.853       0.928          0.066 0.915   0.688

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> GSM802141     2       0          1  0  1  0
#> GSM802144     2       0          1  0  1  0
#> GSM802153     2       0          1  0  1  0
#> GSM802156     3       0          1  0  0  1
#> GSM802165     2       0          1  0  1  0
#> GSM802168     2       0          1  0  1  0
#> GSM802177     2       0          1  0  1  0
#> GSM802180     2       0          1  0  1  0
#> GSM802189     2       0          1  0  1  0
#> GSM802192     2       0          1  0  1  0
#> GSM802143     1       0          1  1  0  0
#> GSM802146     1       0          1  1  0  0
#> GSM802155     1       0          1  1  0  0
#> GSM802158     1       0          1  1  0  0
#> GSM802167     1       0          1  1  0  0
#> GSM802170     1       0          1  1  0  0
#> GSM802179     1       0          1  1  0  0
#> GSM802182     1       0          1  1  0  0
#> GSM802191     1       0          1  1  0  0
#> GSM802194     1       0          1  1  0  0
#> GSM802142     2       0          1  0  1  0
#> GSM802145     2       0          1  0  1  0
#> GSM802154     3       0          1  0  0  1
#> GSM802157     3       0          1  0  0  1
#> GSM802166     1       0          1  1  0  0
#> GSM802169     2       0          1  0  1  0
#> GSM802178     2       0          1  0  1  0
#> GSM802181     2       0          1  0  1  0
#> GSM802190     2       0          1  0  1  0
#> GSM802193     2       0          1  0  1  0
#> GSM802135     2       0          1  0  1  0
#> GSM802138     2       0          1  0  1  0
#> GSM802147     2       0          1  0  1  0
#> GSM802150     2       0          1  0  1  0
#> GSM802159     3       0          1  0  0  1
#> GSM802162     3       0          1  0  0  1
#> GSM802171     2       0          1  0  1  0
#> GSM802174     2       0          1  0  1  0
#> GSM802183     2       0          1  0  1  0
#> GSM802186     2       0          1  0  1  0
#> GSM802137     1       0          1  1  0  0
#> GSM802140     1       0          1  1  0  0
#> GSM802149     1       0          1  1  0  0
#> GSM802151     1       0          1  1  0  0
#> GSM802161     1       0          1  1  0  0
#> GSM802163     3       0          1  0  0  1
#> GSM802173     1       0          1  1  0  0
#> GSM802175     2       0          1  0  1  0
#> GSM802185     1       0          1  1  0  0
#> GSM802188     1       0          1  1  0  0
#> GSM802136     2       0          1  0  1  0
#> GSM802139     2       0          1  0  1  0
#> GSM802148     2       0          1  0  1  0
#> GSM802152     2       0          1  0  1  0
#> GSM802160     1       0          1  1  0  0
#> GSM802164     1       0          1  1  0  0
#> GSM802172     2       0          1  0  1  0
#> GSM802176     1       0          1  1  0  0
#> GSM802184     2       0          1  0  1  0
#> GSM802187     2       0          1  0  1  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> GSM802141     2  0.0188      0.882 0.000 0.996  0 0.004
#> GSM802144     4  0.3649      0.703 0.000 0.204  0 0.796
#> GSM802153     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802156     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM802165     4  0.0188      0.857 0.000 0.004  0 0.996
#> GSM802168     2  0.0188      0.883 0.000 0.996  0 0.004
#> GSM802177     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802180     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802189     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802192     2  0.3311      0.771 0.000 0.828  0 0.172
#> GSM802143     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802146     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802155     1  0.0188      0.997 0.996 0.000  0 0.004
#> GSM802158     1  0.0188      0.997 0.996 0.000  0 0.004
#> GSM802167     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802170     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802179     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802182     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802191     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802194     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802142     2  0.2814      0.771 0.000 0.868  0 0.132
#> GSM802145     4  0.0817      0.864 0.000 0.024  0 0.976
#> GSM802154     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM802157     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM802166     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802169     2  0.1716      0.853 0.000 0.936  0 0.064
#> GSM802178     2  0.4250      0.659 0.000 0.724  0 0.276
#> GSM802181     2  0.0336      0.881 0.000 0.992  0 0.008
#> GSM802190     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802193     2  0.3311      0.771 0.000 0.828  0 0.172
#> GSM802135     4  0.0188      0.857 0.000 0.004  0 0.996
#> GSM802138     4  0.1302      0.861 0.000 0.044  0 0.956
#> GSM802147     2  0.0336      0.882 0.000 0.992  0 0.008
#> GSM802150     2  0.4817      0.364 0.000 0.612  0 0.388
#> GSM802159     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM802162     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM802171     4  0.4998     -0.179 0.000 0.488  0 0.512
#> GSM802174     2  0.4222      0.591 0.000 0.728  0 0.272
#> GSM802183     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802186     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802137     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802140     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802149     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802151     1  0.0188      0.997 0.996 0.000  0 0.004
#> GSM802161     1  0.0188      0.997 0.996 0.000  0 0.004
#> GSM802163     3  0.0000      1.000 0.000 0.000  1 0.000
#> GSM802173     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802175     2  0.4955      0.175 0.000 0.556  0 0.444
#> GSM802185     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802188     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802136     4  0.1302      0.861 0.000 0.044  0 0.956
#> GSM802139     4  0.1118      0.863 0.000 0.036  0 0.964
#> GSM802148     4  0.0188      0.857 0.000 0.004  0 0.996
#> GSM802152     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802160     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802164     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802172     2  0.4222      0.665 0.000 0.728  0 0.272
#> GSM802176     1  0.0000      0.999 1.000 0.000  0 0.000
#> GSM802184     2  0.0000      0.884 0.000 1.000  0 0.000
#> GSM802187     2  0.0000      0.884 0.000 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2 p3    p4 p5
#> GSM802141     2  0.0162      0.883  0 0.996  0 0.004  0
#> GSM802144     4  0.3143      0.672  0 0.204  0 0.796  0
#> GSM802153     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802156     3  0.0000      1.000  0 0.000  1 0.000  0
#> GSM802165     4  0.0000      0.845  0 0.000  0 1.000  0
#> GSM802168     2  0.0162      0.883  0 0.996  0 0.004  0
#> GSM802177     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802180     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802189     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802192     2  0.2852      0.772  0 0.828  0 0.172  0
#> GSM802143     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802146     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802155     5  0.0000      1.000  0 0.000  0 0.000  1
#> GSM802158     5  0.0000      1.000  0 0.000  0 0.000  1
#> GSM802167     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802170     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802179     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802182     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802191     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802194     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802142     2  0.2424      0.772  0 0.868  0 0.132  0
#> GSM802145     4  0.0609      0.852  0 0.020  0 0.980  0
#> GSM802154     3  0.0000      1.000  0 0.000  1 0.000  0
#> GSM802157     3  0.0000      1.000  0 0.000  1 0.000  0
#> GSM802166     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802169     2  0.1478      0.853  0 0.936  0 0.064  0
#> GSM802178     2  0.3661      0.660  0 0.724  0 0.276  0
#> GSM802181     2  0.0290      0.881  0 0.992  0 0.008  0
#> GSM802190     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802193     2  0.2852      0.772  0 0.828  0 0.172  0
#> GSM802135     4  0.0000      0.845  0 0.000  0 1.000  0
#> GSM802138     4  0.1043      0.848  0 0.040  0 0.960  0
#> GSM802147     2  0.0290      0.882  0 0.992  0 0.008  0
#> GSM802150     2  0.4150      0.367  0 0.612  0 0.388  0
#> GSM802159     3  0.0000      1.000  0 0.000  1 0.000  0
#> GSM802162     3  0.0000      1.000  0 0.000  1 0.000  0
#> GSM802171     4  0.4305     -0.185  0 0.488  0 0.512  0
#> GSM802174     2  0.3636      0.593  0 0.728  0 0.272  0
#> GSM802183     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802186     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802137     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802140     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802149     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802151     5  0.0000      1.000  0 0.000  0 0.000  1
#> GSM802161     5  0.0000      1.000  0 0.000  0 0.000  1
#> GSM802163     3  0.0000      1.000  0 0.000  1 0.000  0
#> GSM802173     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802175     2  0.4268      0.181  0 0.556  0 0.444  0
#> GSM802185     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802188     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802136     4  0.1043      0.848  0 0.040  0 0.960  0
#> GSM802139     4  0.0880      0.851  0 0.032  0 0.968  0
#> GSM802148     4  0.0000      0.845  0 0.000  0 1.000  0
#> GSM802152     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802160     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802164     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802172     2  0.3636      0.666  0 0.728  0 0.272  0
#> GSM802176     1  0.0000      1.000  1 0.000  0 0.000  0
#> GSM802184     2  0.0000      0.884  0 1.000  0 0.000  0
#> GSM802187     2  0.0000      0.884  0 1.000  0 0.000  0

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette p1    p2 p3    p4 p5    p6
#> GSM802141     2  0.0146     0.9027  0 0.996  0 0.004  0 0.000
#> GSM802144     4  0.2178     0.6795  0 0.132  0 0.868  0 0.000
#> GSM802153     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802156     3  0.0000     1.0000  0 0.000  1 0.000  0 0.000
#> GSM802165     4  0.3838    -0.0704  0 0.000  0 0.552  0 0.448
#> GSM802168     2  0.3706     0.2130  0 0.620  0 0.000  0 0.380
#> GSM802177     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802180     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802189     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802192     6  0.3907     0.9096  0 0.152  0 0.084  0 0.764
#> GSM802143     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802146     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802155     5  0.0000     1.0000  0 0.000  0 0.000  1 0.000
#> GSM802158     5  0.0000     1.0000  0 0.000  0 0.000  1 0.000
#> GSM802167     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802170     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802179     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802182     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802191     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802194     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802142     2  0.1007     0.8628  0 0.956  0 0.044  0 0.000
#> GSM802145     4  0.0146     0.7453  0 0.004  0 0.996  0 0.000
#> GSM802154     3  0.0000     1.0000  0 0.000  1 0.000  0 0.000
#> GSM802157     3  0.0000     1.0000  0 0.000  1 0.000  0 0.000
#> GSM802166     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802169     6  0.3373     0.8043  0 0.248  0 0.008  0 0.744
#> GSM802178     6  0.3907     0.9096  0 0.152  0 0.084  0 0.764
#> GSM802181     2  0.0260     0.8995  0 0.992  0 0.000  0 0.008
#> GSM802190     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802193     6  0.0000     0.6791  0 0.000  0 0.000  0 1.000
#> GSM802135     4  0.0000     0.7451  0 0.000  0 1.000  0 0.000
#> GSM802138     4  0.0000     0.7451  0 0.000  0 1.000  0 0.000
#> GSM802147     2  0.3531     0.5385  0 0.672  0 0.000  0 0.328
#> GSM802150     4  0.5675     0.1934  0 0.400  0 0.444  0 0.156
#> GSM802159     3  0.0000     1.0000  0 0.000  1 0.000  0 0.000
#> GSM802162     3  0.0000     1.0000  0 0.000  1 0.000  0 0.000
#> GSM802171     6  0.3907     0.9096  0 0.152  0 0.084  0 0.764
#> GSM802174     2  0.5571     0.2576  0 0.552  0 0.224  0 0.224
#> GSM802183     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802186     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802137     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802140     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802149     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802151     5  0.0000     1.0000  0 0.000  0 0.000  1 0.000
#> GSM802161     5  0.0000     1.0000  0 0.000  0 0.000  1 0.000
#> GSM802163     3  0.0000     1.0000  0 0.000  1 0.000  0 0.000
#> GSM802173     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802175     4  0.3833     0.2106  0 0.444  0 0.556  0 0.000
#> GSM802185     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802188     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802136     4  0.0000     0.7451  0 0.000  0 1.000  0 0.000
#> GSM802139     4  0.0146     0.7454  0 0.004  0 0.996  0 0.000
#> GSM802148     4  0.3076     0.6138  0 0.000  0 0.760  0 0.240
#> GSM802152     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802160     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802164     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802172     6  0.3907     0.9096  0 0.152  0 0.084  0 0.764
#> GSM802176     1  0.0000     1.0000  1 0.000  0 0.000  0 0.000
#> GSM802184     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000
#> GSM802187     2  0.0000     0.9056  0 1.000  0 0.000  0 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) protocol(p)  time(p) individual(p) k
#> SD:pam 60            1.000    4.43e-09 0.000103        1.0000 2
#> SD:pam 60            1.000    7.22e-08 0.000167        0.5754 3
#> SD:pam 57            0.674    4.06e-07 0.000871        0.1824 4
#> SD:pam 57            0.820    1.91e-06 0.002355        0.1967 5
#> SD:pam 55            0.818    1.07e-05 0.005954        0.0463 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.774           0.659       0.834         0.3345 0.666   0.443
#> 4 4 0.900           0.912       0.948         0.0553 0.792   0.529
#> 5 5 0.805           0.816       0.890         0.0623 0.949   0.855
#> 6 6 0.697           0.599       0.790         0.0689 0.953   0.852

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2   0.630      0.982 0.472 0.528 0.000
#> GSM802144     2   0.630      0.982 0.472 0.528 0.000
#> GSM802153     3   0.681      0.597 0.012 0.468 0.520
#> GSM802156     3   0.630      0.606 0.000 0.472 0.528
#> GSM802165     2   0.630      0.982 0.472 0.528 0.000
#> GSM802168     2   0.630      0.982 0.472 0.528 0.000
#> GSM802177     2   0.630      0.982 0.472 0.528 0.000
#> GSM802180     2   0.630      0.982 0.472 0.528 0.000
#> GSM802189     2   0.630      0.982 0.472 0.528 0.000
#> GSM802192     2   0.630      0.982 0.472 0.528 0.000
#> GSM802143     1   0.630      0.596 0.528 0.000 0.472
#> GSM802146     1   0.630      0.596 0.528 0.000 0.472
#> GSM802155     3   0.000      0.566 0.000 0.000 1.000
#> GSM802158     3   0.000      0.566 0.000 0.000 1.000
#> GSM802167     1   0.630      0.596 0.528 0.000 0.472
#> GSM802170     1   0.630      0.596 0.528 0.000 0.472
#> GSM802179     1   0.630      0.596 0.528 0.000 0.472
#> GSM802182     1   0.630      0.596 0.528 0.000 0.472
#> GSM802191     1   0.630      0.596 0.528 0.000 0.472
#> GSM802194     3   0.623     -0.486 0.436 0.000 0.564
#> GSM802142     2   0.630      0.982 0.472 0.528 0.000
#> GSM802145     1   0.840     -0.290 0.472 0.084 0.444
#> GSM802154     3   0.630      0.606 0.000 0.472 0.528
#> GSM802157     3   0.630      0.606 0.000 0.472 0.528
#> GSM802166     3   0.164      0.517 0.044 0.000 0.956
#> GSM802169     2   0.630      0.982 0.472 0.528 0.000
#> GSM802178     2   0.630      0.982 0.472 0.528 0.000
#> GSM802181     2   0.630      0.982 0.472 0.528 0.000
#> GSM802190     1   0.915     -0.795 0.472 0.380 0.148
#> GSM802193     1   0.840     -0.290 0.472 0.084 0.444
#> GSM802135     2   0.630      0.982 0.472 0.528 0.000
#> GSM802138     2   0.630      0.982 0.472 0.528 0.000
#> GSM802147     2   0.524      0.401 0.120 0.824 0.056
#> GSM802150     2   0.630      0.982 0.472 0.528 0.000
#> GSM802159     3   0.630      0.606 0.000 0.472 0.528
#> GSM802162     3   0.630      0.606 0.000 0.472 0.528
#> GSM802171     2   0.630      0.982 0.472 0.528 0.000
#> GSM802174     2   0.630      0.982 0.472 0.528 0.000
#> GSM802183     2   0.630      0.982 0.472 0.528 0.000
#> GSM802186     2   0.630      0.982 0.472 0.528 0.000
#> GSM802137     1   0.630      0.596 0.528 0.000 0.472
#> GSM802140     1   0.630      0.596 0.528 0.000 0.472
#> GSM802149     3   0.000      0.566 0.000 0.000 1.000
#> GSM802151     3   0.000      0.566 0.000 0.000 1.000
#> GSM802161     3   0.000      0.566 0.000 0.000 1.000
#> GSM802163     3   0.630      0.606 0.000 0.472 0.528
#> GSM802173     1   0.630      0.596 0.528 0.000 0.472
#> GSM802175     2   0.630      0.982 0.472 0.528 0.000
#> GSM802185     1   0.630      0.596 0.528 0.000 0.472
#> GSM802188     3   0.186      0.505 0.052 0.000 0.948
#> GSM802136     2   0.630      0.982 0.472 0.528 0.000
#> GSM802139     2   0.630      0.982 0.472 0.528 0.000
#> GSM802148     1   0.840     -0.290 0.472 0.084 0.444
#> GSM802152     3   0.936      0.442 0.196 0.304 0.500
#> GSM802160     3   0.164      0.517 0.044 0.000 0.956
#> GSM802164     3   0.000      0.566 0.000 0.000 1.000
#> GSM802172     2   0.630      0.982 0.472 0.528 0.000
#> GSM802176     1   0.630      0.596 0.528 0.000 0.472
#> GSM802184     2   0.630      0.982 0.472 0.528 0.000
#> GSM802187     2   0.630      0.982 0.472 0.528 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.1792     0.9074 0.000 0.932 0.068 0.000
#> GSM802144     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802153     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802156     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802165     2  0.2011     0.8959 0.000 0.920 0.080 0.000
#> GSM802168     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802177     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802180     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802189     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802192     2  0.2345     0.8754 0.000 0.900 0.100 0.000
#> GSM802143     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802155     4  0.3486     0.8433 0.000 0.000 0.188 0.812
#> GSM802158     4  0.3486     0.8433 0.000 0.000 0.188 0.812
#> GSM802167     1  0.0188     0.9968 0.996 0.000 0.000 0.004
#> GSM802170     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0188     0.9968 0.996 0.000 0.000 0.004
#> GSM802142     2  0.0592     0.9496 0.000 0.984 0.016 0.000
#> GSM802145     2  0.0779     0.9478 0.000 0.980 0.016 0.004
#> GSM802154     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802157     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802166     1  0.0188     0.9968 0.996 0.000 0.000 0.004
#> GSM802169     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802178     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802181     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802190     2  0.0592     0.9496 0.000 0.984 0.016 0.000
#> GSM802193     2  0.4054     0.7822 0.000 0.796 0.016 0.188
#> GSM802135     2  0.0469     0.9505 0.000 0.988 0.012 0.000
#> GSM802138     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802147     3  0.4522     0.4181 0.000 0.320 0.680 0.000
#> GSM802150     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802159     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802162     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802171     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802174     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802183     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802186     2  0.0592     0.9481 0.000 0.984 0.016 0.000
#> GSM802137     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802149     4  0.6823     0.7040 0.244 0.000 0.160 0.596
#> GSM802151     4  0.3668     0.8455 0.004 0.000 0.188 0.808
#> GSM802161     4  0.3668     0.8455 0.004 0.000 0.188 0.808
#> GSM802163     3  0.0000     0.9071 0.000 0.000 1.000 0.000
#> GSM802173     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802185     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802136     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802139     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802148     2  0.4054     0.7822 0.000 0.796 0.016 0.188
#> GSM802152     2  0.4989     0.0772 0.000 0.528 0.472 0.000
#> GSM802160     1  0.0188     0.9968 0.996 0.000 0.000 0.004
#> GSM802164     4  0.6823     0.7040 0.244 0.000 0.160 0.596
#> GSM802172     2  0.0000     0.9561 0.000 1.000 0.000 0.000
#> GSM802176     1  0.0000     0.9989 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0592     0.9496 0.000 0.984 0.016 0.000
#> GSM802187     2  0.0592     0.9496 0.000 0.984 0.016 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.2074      0.821 0.000 0.896 0.000 0.104 0.000
#> GSM802144     2  0.0671      0.805 0.000 0.980 0.000 0.016 0.004
#> GSM802153     3  0.3694      0.761 0.000 0.032 0.796 0.172 0.000
#> GSM802156     3  0.1282      0.927 0.000 0.000 0.952 0.044 0.004
#> GSM802165     2  0.2144      0.744 0.000 0.912 0.020 0.068 0.000
#> GSM802168     2  0.0000      0.811 0.000 1.000 0.000 0.000 0.000
#> GSM802177     2  0.1571      0.825 0.000 0.936 0.000 0.060 0.004
#> GSM802180     2  0.1965      0.821 0.000 0.904 0.000 0.096 0.000
#> GSM802189     2  0.2020      0.822 0.000 0.900 0.000 0.100 0.000
#> GSM802192     2  0.2012      0.753 0.000 0.920 0.020 0.060 0.000
#> GSM802143     1  0.0510      0.964 0.984 0.000 0.000 0.016 0.000
#> GSM802146     1  0.0510      0.964 0.984 0.000 0.000 0.016 0.000
#> GSM802155     5  0.0865      0.858 0.000 0.000 0.004 0.024 0.972
#> GSM802158     5  0.0671      0.855 0.000 0.000 0.004 0.016 0.980
#> GSM802167     1  0.1197      0.948 0.952 0.000 0.000 0.048 0.000
#> GSM802170     1  0.0000      0.966 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0162      0.966 0.996 0.000 0.000 0.004 0.000
#> GSM802182     1  0.0609      0.963 0.980 0.000 0.000 0.020 0.000
#> GSM802191     1  0.0510      0.964 0.984 0.000 0.000 0.016 0.000
#> GSM802194     1  0.0794      0.959 0.972 0.000 0.000 0.028 0.000
#> GSM802142     2  0.3333      0.720 0.000 0.788 0.004 0.208 0.000
#> GSM802145     2  0.4182     -0.311 0.000 0.644 0.000 0.352 0.004
#> GSM802154     3  0.1205      0.921 0.000 0.000 0.956 0.040 0.004
#> GSM802157     3  0.1282      0.927 0.000 0.000 0.952 0.044 0.004
#> GSM802166     1  0.2561      0.871 0.856 0.000 0.000 0.144 0.000
#> GSM802169     2  0.0609      0.804 0.000 0.980 0.000 0.020 0.000
#> GSM802178     2  0.0324      0.810 0.000 0.992 0.004 0.004 0.000
#> GSM802181     2  0.2068      0.824 0.000 0.904 0.000 0.092 0.004
#> GSM802190     2  0.2230      0.818 0.000 0.884 0.000 0.116 0.000
#> GSM802193     4  0.4227      0.954 0.000 0.420 0.000 0.580 0.000
#> GSM802135     2  0.1764      0.765 0.000 0.928 0.008 0.064 0.000
#> GSM802138     2  0.0162      0.811 0.000 0.996 0.000 0.004 0.000
#> GSM802147     2  0.5773     -0.090 0.000 0.476 0.436 0.088 0.000
#> GSM802150     2  0.2127      0.821 0.000 0.892 0.000 0.108 0.000
#> GSM802159     3  0.1638      0.916 0.000 0.000 0.932 0.064 0.004
#> GSM802162     3  0.0324      0.928 0.000 0.000 0.992 0.004 0.004
#> GSM802171     2  0.0404      0.810 0.000 0.988 0.000 0.012 0.000
#> GSM802174     2  0.2280      0.812 0.000 0.880 0.000 0.120 0.000
#> GSM802183     2  0.2286      0.816 0.000 0.888 0.004 0.108 0.000
#> GSM802186     2  0.2439      0.812 0.000 0.876 0.004 0.120 0.000
#> GSM802137     1  0.0703      0.961 0.976 0.000 0.000 0.024 0.000
#> GSM802140     1  0.0290      0.965 0.992 0.000 0.000 0.008 0.000
#> GSM802149     5  0.4430      0.799 0.172 0.000 0.000 0.076 0.752
#> GSM802151     5  0.1357      0.881 0.048 0.000 0.004 0.000 0.948
#> GSM802161     5  0.1357      0.881 0.048 0.000 0.004 0.000 0.948
#> GSM802163     3  0.1205      0.921 0.000 0.000 0.956 0.040 0.004
#> GSM802173     1  0.0162      0.966 0.996 0.000 0.000 0.004 0.000
#> GSM802175     2  0.2127      0.820 0.000 0.892 0.000 0.108 0.000
#> GSM802185     1  0.0609      0.963 0.980 0.000 0.000 0.020 0.000
#> GSM802188     1  0.1041      0.956 0.964 0.000 0.000 0.032 0.004
#> GSM802136     2  0.0404      0.810 0.000 0.988 0.000 0.012 0.000
#> GSM802139     2  0.0324      0.810 0.000 0.992 0.000 0.004 0.004
#> GSM802148     4  0.4171      0.955 0.000 0.396 0.000 0.604 0.000
#> GSM802152     2  0.6361      0.103 0.000 0.508 0.296 0.196 0.000
#> GSM802160     1  0.2561      0.871 0.856 0.000 0.000 0.144 0.000
#> GSM802164     5  0.4424      0.761 0.224 0.000 0.000 0.048 0.728
#> GSM802172     2  0.0671      0.806 0.000 0.980 0.004 0.016 0.000
#> GSM802176     1  0.0609      0.963 0.980 0.000 0.000 0.020 0.000
#> GSM802184     2  0.3074      0.736 0.000 0.804 0.000 0.196 0.000
#> GSM802187     2  0.2439      0.814 0.000 0.876 0.004 0.120 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
#> GSM802141     2  0.1913    0.62475 0.000 0.908 0.000 NA 0.000 0.012
#> GSM802144     2  0.2883    0.57211 0.000 0.788 0.000 NA 0.000 0.212
#> GSM802153     3  0.6244    0.38127 0.000 0.204 0.508 NA 0.000 0.028
#> GSM802156     3  0.2218    0.77330 0.000 0.000 0.884 NA 0.000 0.104
#> GSM802165     6  0.5023    0.25229 0.000 0.416 0.020 NA 0.000 0.528
#> GSM802168     2  0.2454    0.60314 0.000 0.840 0.000 NA 0.000 0.160
#> GSM802177     2  0.1387    0.64929 0.000 0.932 0.000 NA 0.000 0.068
#> GSM802180     2  0.0260    0.65642 0.000 0.992 0.000 NA 0.000 0.008
#> GSM802189     2  0.0405    0.65569 0.000 0.988 0.000 NA 0.000 0.004
#> GSM802192     2  0.4886   -0.03347 0.000 0.536 0.016 NA 0.000 0.416
#> GSM802143     1  0.3175    0.73915 0.744 0.000 0.000 NA 0.000 0.000
#> GSM802146     1  0.0146    0.84836 0.996 0.000 0.000 NA 0.000 0.000
#> GSM802155     5  0.3337    0.64340 0.000 0.000 0.004 NA 0.736 0.000
#> GSM802158     5  0.1700    0.68678 0.000 0.000 0.004 NA 0.916 0.000
#> GSM802167     1  0.1644    0.81518 0.920 0.000 0.000 NA 0.004 0.000
#> GSM802170     1  0.0000    0.84885 1.000 0.000 0.000 NA 0.000 0.000
#> GSM802179     1  0.0000    0.84885 1.000 0.000 0.000 NA 0.000 0.000
#> GSM802182     1  0.3198    0.73609 0.740 0.000 0.000 NA 0.000 0.000
#> GSM802191     1  0.1556    0.82972 0.920 0.000 0.000 NA 0.000 0.000
#> GSM802194     1  0.1644    0.81657 0.920 0.000 0.000 NA 0.004 0.000
#> GSM802142     2  0.4699    0.32930 0.000 0.668 0.000 NA 0.000 0.104
#> GSM802145     6  0.3995    0.10025 0.000 0.480 0.000 NA 0.000 0.516
#> GSM802154     3  0.1644    0.77688 0.000 0.000 0.932 NA 0.000 0.040
#> GSM802157     3  0.2118    0.77404 0.000 0.000 0.888 NA 0.000 0.104
#> GSM802166     1  0.3273    0.69424 0.776 0.000 0.000 NA 0.008 0.004
#> GSM802169     2  0.2912    0.56955 0.000 0.784 0.000 NA 0.000 0.216
#> GSM802178     2  0.3161    0.55519 0.000 0.776 0.008 NA 0.000 0.216
#> GSM802181     2  0.0000    0.65657 0.000 1.000 0.000 NA 0.000 0.000
#> GSM802190     2  0.2002    0.63261 0.000 0.916 0.008 NA 0.000 0.020
#> GSM802193     6  0.3230    0.55889 0.000 0.212 0.000 NA 0.000 0.776
#> GSM802135     2  0.4718    0.07310 0.000 0.572 0.008 NA 0.000 0.384
#> GSM802138     2  0.2823    0.57138 0.000 0.796 0.000 NA 0.000 0.204
#> GSM802147     6  0.6880    0.25337 0.000 0.308 0.256 NA 0.000 0.384
#> GSM802150     2  0.0891    0.65419 0.000 0.968 0.000 NA 0.000 0.008
#> GSM802159     3  0.5266    0.56950 0.000 0.008 0.580 NA 0.000 0.316
#> GSM802162     3  0.0508    0.78277 0.000 0.000 0.984 NA 0.000 0.004
#> GSM802171     2  0.3163    0.55960 0.000 0.780 0.004 NA 0.000 0.212
#> GSM802174     2  0.2209    0.59826 0.000 0.904 0.040 NA 0.000 0.052
#> GSM802183     2  0.2907    0.56088 0.000 0.828 0.000 NA 0.000 0.020
#> GSM802186     2  0.3315    0.53777 0.000 0.804 0.000 NA 0.000 0.040
#> GSM802137     1  0.0146    0.84836 0.996 0.000 0.000 NA 0.000 0.000
#> GSM802140     1  0.0260    0.84776 0.992 0.000 0.000 NA 0.000 0.000
#> GSM802149     5  0.5638    0.52429 0.240 0.000 0.004 NA 0.576 0.004
#> GSM802151     5  0.0146    0.69981 0.000 0.000 0.004 NA 0.996 0.000
#> GSM802161     5  0.0935    0.69762 0.000 0.000 0.004 NA 0.964 0.000
#> GSM802163     3  0.1644    0.77688 0.000 0.000 0.932 NA 0.000 0.040
#> GSM802173     1  0.0000    0.84885 1.000 0.000 0.000 NA 0.000 0.000
#> GSM802175     2  0.1297    0.64682 0.000 0.948 0.000 NA 0.000 0.012
#> GSM802185     1  0.3198    0.73609 0.740 0.000 0.000 NA 0.000 0.000
#> GSM802188     1  0.3373    0.74065 0.744 0.000 0.000 NA 0.008 0.000
#> GSM802136     2  0.2964    0.57272 0.000 0.792 0.000 NA 0.000 0.204
#> GSM802139     2  0.2823    0.57138 0.000 0.796 0.000 NA 0.000 0.204
#> GSM802148     6  0.3230    0.55889 0.000 0.212 0.000 NA 0.000 0.776
#> GSM802152     2  0.6454    0.00116 0.000 0.476 0.160 NA 0.000 0.048
#> GSM802160     1  0.3301    0.68994 0.772 0.000 0.000 NA 0.008 0.004
#> GSM802164     5  0.6170    0.22804 0.328 0.000 0.004 NA 0.404 0.000
#> GSM802172     2  0.3109    0.55701 0.000 0.772 0.004 NA 0.000 0.224
#> GSM802176     1  0.3175    0.73915 0.744 0.000 0.000 NA 0.000 0.000
#> GSM802184     2  0.3997    0.46169 0.000 0.760 0.000 NA 0.000 0.108
#> GSM802187     2  0.3560    0.43271 0.000 0.732 0.008 NA 0.000 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) protocol(p)  time(p) individual(p) k
#> SD:mclust 60            1.000    4.43e-09 0.000103         1.000 2
#> SD:mclust 53            0.739    8.04e-06 0.000975         0.142 3
#> SD:mclust 58            0.795    1.31e-06 0.000601         0.383 4
#> SD:mclust 57            0.903    2.13e-06 0.000359         0.299 5
#> SD:mclust 49            0.980    7.67e-06 0.000674         0.237 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk SD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.727           0.782       0.889         0.3270 0.824   0.666
#> 4 4 0.803           0.785       0.878         0.1371 0.885   0.691
#> 5 5 0.803           0.803       0.872         0.0635 0.908   0.696
#> 6 6 0.733           0.643       0.803         0.0338 0.924   0.713

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.5926     0.5395 0.000 0.644 0.356
#> GSM802144     3  0.4887     0.6245 0.000 0.228 0.772
#> GSM802153     2  0.0592     0.7640 0.000 0.988 0.012
#> GSM802156     2  0.0747     0.7571 0.000 0.984 0.016
#> GSM802165     3  0.4346     0.6753 0.000 0.184 0.816
#> GSM802168     3  0.6286     0.1160 0.000 0.464 0.536
#> GSM802177     3  0.6295     0.0211 0.000 0.472 0.528
#> GSM802180     2  0.4555     0.7800 0.000 0.800 0.200
#> GSM802189     2  0.3482     0.8037 0.000 0.872 0.128
#> GSM802192     2  0.5178     0.7383 0.000 0.744 0.256
#> GSM802143     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802146     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802155     1  0.0237     0.9974 0.996 0.000 0.004
#> GSM802158     1  0.0237     0.9974 0.996 0.000 0.004
#> GSM802167     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802170     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802179     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802182     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802191     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802194     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802142     2  0.3752     0.8014 0.000 0.856 0.144
#> GSM802145     3  0.0592     0.7182 0.000 0.012 0.988
#> GSM802154     2  0.0000     0.7575 0.000 1.000 0.000
#> GSM802157     2  0.0000     0.7575 0.000 1.000 0.000
#> GSM802166     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802169     3  0.6062     0.3524 0.000 0.384 0.616
#> GSM802178     3  0.0237     0.7150 0.000 0.004 0.996
#> GSM802181     2  0.6260     0.2251 0.000 0.552 0.448
#> GSM802190     2  0.3482     0.8037 0.000 0.872 0.128
#> GSM802193     3  0.0237     0.7150 0.000 0.004 0.996
#> GSM802135     3  0.1289     0.7212 0.000 0.032 0.968
#> GSM802138     2  0.5560     0.6878 0.000 0.700 0.300
#> GSM802147     2  0.5363     0.7082 0.000 0.724 0.276
#> GSM802150     2  0.4750     0.7752 0.000 0.784 0.216
#> GSM802159     2  0.1964     0.7509 0.000 0.944 0.056
#> GSM802162     2  0.0000     0.7575 0.000 1.000 0.000
#> GSM802171     2  0.6235     0.3387 0.000 0.564 0.436
#> GSM802174     2  0.4796     0.7663 0.000 0.780 0.220
#> GSM802183     2  0.3551     0.8034 0.000 0.868 0.132
#> GSM802186     2  0.3412     0.8033 0.000 0.876 0.124
#> GSM802137     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802140     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802149     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802151     1  0.0237     0.9974 0.996 0.000 0.004
#> GSM802161     1  0.0237     0.9974 0.996 0.000 0.004
#> GSM802163     2  0.0000     0.7575 0.000 1.000 0.000
#> GSM802173     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802175     2  0.4504     0.7819 0.000 0.804 0.196
#> GSM802185     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802188     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802136     2  0.5254     0.7358 0.000 0.736 0.264
#> GSM802139     3  0.6154     0.3010 0.000 0.408 0.592
#> GSM802148     3  0.0237     0.7150 0.000 0.004 0.996
#> GSM802152     2  0.0892     0.7688 0.000 0.980 0.020
#> GSM802160     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802164     1  0.0237     0.9974 0.996 0.000 0.004
#> GSM802172     3  0.2625     0.7154 0.000 0.084 0.916
#> GSM802176     1  0.0000     0.9992 1.000 0.000 0.000
#> GSM802184     2  0.5733     0.6176 0.000 0.676 0.324
#> GSM802187     2  0.2066     0.7866 0.000 0.940 0.060

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.4382    0.80040 0.000 0.704 0.296 0.000
#> GSM802144     3  0.2271    0.70032 0.000 0.008 0.916 0.076
#> GSM802153     2  0.0592    0.67994 0.000 0.984 0.016 0.000
#> GSM802156     4  0.5366    0.36738 0.000 0.440 0.012 0.548
#> GSM802165     4  0.0469    0.78101 0.000 0.000 0.012 0.988
#> GSM802168     3  0.4228    0.48673 0.000 0.232 0.760 0.008
#> GSM802177     3  0.4088    0.47746 0.000 0.232 0.764 0.004
#> GSM802180     2  0.4382    0.79983 0.000 0.704 0.296 0.000
#> GSM802189     2  0.4193    0.81188 0.000 0.732 0.268 0.000
#> GSM802192     4  0.0336    0.78061 0.000 0.000 0.008 0.992
#> GSM802143     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0524    0.99374 0.988 0.000 0.004 0.008
#> GSM802158     1  0.0524    0.99374 0.988 0.000 0.004 0.008
#> GSM802167     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0188    0.99623 0.996 0.000 0.000 0.004
#> GSM802191     1  0.0188    0.99623 0.996 0.000 0.000 0.004
#> GSM802194     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802142     2  0.4277    0.80998 0.000 0.720 0.280 0.000
#> GSM802145     3  0.1576    0.70030 0.000 0.004 0.948 0.048
#> GSM802154     2  0.0804    0.65531 0.000 0.980 0.012 0.008
#> GSM802157     2  0.3161    0.51634 0.000 0.864 0.012 0.124
#> GSM802166     1  0.0188    0.99593 0.996 0.000 0.000 0.004
#> GSM802169     3  0.4889    0.36933 0.000 0.004 0.636 0.360
#> GSM802178     3  0.5028    0.22124 0.000 0.004 0.596 0.400
#> GSM802181     2  0.5168    0.40121 0.000 0.504 0.492 0.004
#> GSM802190     2  0.3907    0.80548 0.000 0.768 0.232 0.000
#> GSM802193     4  0.2266    0.75470 0.000 0.004 0.084 0.912
#> GSM802135     4  0.0469    0.78101 0.000 0.000 0.012 0.988
#> GSM802138     4  0.4485    0.55414 0.000 0.012 0.248 0.740
#> GSM802147     4  0.1388    0.77011 0.000 0.028 0.012 0.960
#> GSM802150     2  0.4477    0.75157 0.000 0.688 0.312 0.000
#> GSM802159     4  0.2179    0.74352 0.000 0.064 0.012 0.924
#> GSM802162     2  0.1059    0.64856 0.000 0.972 0.012 0.016
#> GSM802171     4  0.3626    0.65220 0.000 0.004 0.184 0.812
#> GSM802174     2  0.4697    0.78971 0.000 0.696 0.296 0.008
#> GSM802183     2  0.4193    0.81237 0.000 0.732 0.268 0.000
#> GSM802186     2  0.4193    0.81238 0.000 0.732 0.268 0.000
#> GSM802137     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0188    0.99593 0.996 0.000 0.000 0.004
#> GSM802151     1  0.0524    0.99374 0.988 0.000 0.004 0.008
#> GSM802161     1  0.0524    0.99374 0.988 0.000 0.004 0.008
#> GSM802163     2  0.0657    0.65922 0.000 0.984 0.012 0.004
#> GSM802173     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802175     2  0.4304    0.80740 0.000 0.716 0.284 0.000
#> GSM802185     1  0.0188    0.99623 0.996 0.000 0.000 0.004
#> GSM802188     1  0.0376    0.99489 0.992 0.000 0.004 0.004
#> GSM802136     4  0.4137    0.61667 0.000 0.012 0.208 0.780
#> GSM802139     3  0.1807    0.70309 0.000 0.052 0.940 0.008
#> GSM802148     4  0.0469    0.78101 0.000 0.000 0.012 0.988
#> GSM802152     2  0.2814    0.75829 0.000 0.868 0.132 0.000
#> GSM802160     1  0.0188    0.99593 0.996 0.000 0.000 0.004
#> GSM802164     1  0.0376    0.99489 0.992 0.000 0.004 0.004
#> GSM802172     4  0.5158    0.00376 0.000 0.004 0.472 0.524
#> GSM802176     1  0.0000    0.99674 1.000 0.000 0.000 0.000
#> GSM802184     2  0.4304    0.80740 0.000 0.716 0.284 0.000
#> GSM802187     2  0.3873    0.80456 0.000 0.772 0.228 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
#> GSM802141     3  0.5215      0.667 0.000 0.240 0.664 0.000 0.096
#> GSM802144     5  0.3912      0.785 0.000 0.208 0.004 0.020 0.768
#> GSM802153     3  0.0000      0.776 0.000 0.000 1.000 0.000 0.000
#> GSM802156     4  0.4542      0.231 0.000 0.008 0.456 0.536 0.000
#> GSM802165     4  0.0000      0.794 0.000 0.000 0.000 1.000 0.000
#> GSM802168     2  0.2659      0.789 0.000 0.888 0.052 0.000 0.060
#> GSM802177     2  0.0771      0.800 0.000 0.976 0.020 0.004 0.000
#> GSM802180     2  0.3452      0.654 0.000 0.756 0.244 0.000 0.000
#> GSM802189     3  0.4323      0.605 0.000 0.332 0.656 0.000 0.012
#> GSM802192     4  0.1608      0.779 0.000 0.072 0.000 0.928 0.000
#> GSM802143     1  0.0162      0.978 0.996 0.000 0.000 0.000 0.004
#> GSM802146     1  0.0510      0.975 0.984 0.000 0.000 0.000 0.016
#> GSM802155     1  0.1197      0.971 0.952 0.000 0.000 0.000 0.048
#> GSM802158     1  0.1197      0.971 0.952 0.000 0.000 0.000 0.048
#> GSM802167     1  0.0404      0.977 0.988 0.000 0.000 0.000 0.012
#> GSM802170     1  0.0162      0.979 0.996 0.000 0.000 0.000 0.004
#> GSM802179     1  0.0162      0.979 0.996 0.000 0.000 0.000 0.004
#> GSM802182     1  0.0880      0.976 0.968 0.000 0.000 0.000 0.032
#> GSM802191     1  0.0703      0.978 0.976 0.000 0.000 0.000 0.024
#> GSM802194     1  0.0510      0.975 0.984 0.000 0.000 0.000 0.016
#> GSM802142     3  0.4946      0.523 0.000 0.060 0.664 0.000 0.276
#> GSM802145     5  0.1877      0.758 0.000 0.064 0.000 0.012 0.924
#> GSM802154     3  0.0000      0.776 0.000 0.000 1.000 0.000 0.000
#> GSM802157     3  0.1408      0.748 0.000 0.008 0.948 0.044 0.000
#> GSM802166     1  0.0794      0.978 0.972 0.000 0.000 0.000 0.028
#> GSM802169     2  0.1168      0.786 0.000 0.960 0.000 0.032 0.008
#> GSM802178     2  0.1740      0.774 0.000 0.932 0.000 0.056 0.012
#> GSM802181     2  0.1341      0.803 0.000 0.944 0.056 0.000 0.000
#> GSM802190     2  0.3196      0.742 0.000 0.804 0.192 0.000 0.004
#> GSM802193     2  0.3828      0.630 0.000 0.808 0.000 0.120 0.072
#> GSM802135     4  0.1012      0.791 0.000 0.012 0.000 0.968 0.020
#> GSM802138     5  0.5809      0.746 0.000 0.128 0.012 0.220 0.640
#> GSM802147     4  0.2074      0.772 0.000 0.104 0.000 0.896 0.000
#> GSM802150     3  0.5831      0.575 0.000 0.268 0.592 0.000 0.140
#> GSM802159     4  0.0162      0.796 0.000 0.004 0.000 0.996 0.000
#> GSM802162     3  0.0451      0.771 0.000 0.004 0.988 0.008 0.000
#> GSM802171     4  0.2648      0.685 0.000 0.152 0.000 0.848 0.000
#> GSM802174     2  0.3366      0.671 0.000 0.768 0.232 0.000 0.000
#> GSM802183     3  0.4046      0.650 0.000 0.296 0.696 0.000 0.008
#> GSM802186     3  0.4040      0.687 0.000 0.260 0.724 0.000 0.016
#> GSM802137     1  0.0162      0.978 0.996 0.000 0.000 0.000 0.004
#> GSM802140     1  0.0290      0.978 0.992 0.000 0.000 0.000 0.008
#> GSM802149     1  0.0404      0.979 0.988 0.000 0.000 0.000 0.012
#> GSM802151     1  0.1197      0.971 0.952 0.000 0.000 0.000 0.048
#> GSM802161     1  0.1197      0.971 0.952 0.000 0.000 0.000 0.048
#> GSM802163     3  0.0000      0.776 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802175     3  0.4575      0.603 0.000 0.328 0.648 0.000 0.024
#> GSM802185     1  0.0963      0.975 0.964 0.000 0.000 0.000 0.036
#> GSM802188     1  0.0703      0.978 0.976 0.000 0.000 0.000 0.024
#> GSM802136     5  0.5212      0.614 0.000 0.032 0.016 0.332 0.620
#> GSM802139     5  0.3969      0.795 0.000 0.156 0.008 0.040 0.796
#> GSM802148     4  0.3780      0.718 0.000 0.116 0.000 0.812 0.072
#> GSM802152     3  0.2179      0.772 0.000 0.112 0.888 0.000 0.000
#> GSM802160     1  0.1671      0.926 0.924 0.000 0.000 0.000 0.076
#> GSM802164     1  0.1043      0.974 0.960 0.000 0.000 0.000 0.040
#> GSM802172     2  0.1469      0.783 0.000 0.948 0.000 0.036 0.016
#> GSM802176     1  0.0290      0.978 0.992 0.000 0.000 0.000 0.008
#> GSM802184     2  0.4620      0.327 0.000 0.592 0.392 0.000 0.016
#> GSM802187     3  0.1485      0.780 0.000 0.032 0.948 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
#> GSM802141     2  0.5411      0.387 0.000 0.572 0.168 0.260 0.000 0.000
#> GSM802144     4  0.3678      0.784 0.000 0.164 0.004 0.792 0.024 0.016
#> GSM802153     3  0.1594      0.751 0.000 0.052 0.932 0.016 0.000 0.000
#> GSM802156     3  0.3426      0.477 0.000 0.000 0.720 0.000 0.004 0.276
#> GSM802165     6  0.0551      0.633 0.000 0.000 0.004 0.004 0.008 0.984
#> GSM802168     2  0.2245      0.482 0.000 0.904 0.012 0.012 0.068 0.004
#> GSM802177     2  0.3550      0.305 0.000 0.764 0.004 0.008 0.216 0.008
#> GSM802180     2  0.3167      0.568 0.000 0.836 0.120 0.012 0.032 0.000
#> GSM802189     2  0.4546      0.429 0.000 0.572 0.396 0.024 0.008 0.000
#> GSM802192     6  0.5190      0.297 0.000 0.052 0.028 0.000 0.328 0.592
#> GSM802143     1  0.1480      0.934 0.940 0.000 0.000 0.040 0.020 0.000
#> GSM802146     1  0.0777      0.940 0.972 0.000 0.000 0.004 0.024 0.000
#> GSM802155     1  0.2747      0.914 0.880 0.000 0.024 0.040 0.056 0.000
#> GSM802158     1  0.2058      0.929 0.908 0.000 0.000 0.036 0.056 0.000
#> GSM802167     1  0.0777      0.940 0.972 0.000 0.000 0.004 0.024 0.000
#> GSM802170     1  0.0458      0.943 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802179     1  0.0363      0.942 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802182     1  0.1713      0.936 0.928 0.000 0.000 0.028 0.044 0.000
#> GSM802191     1  0.0622      0.944 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM802194     1  0.2848      0.807 0.816 0.000 0.000 0.008 0.176 0.000
#> GSM802142     3  0.5152      0.109 0.000 0.088 0.512 0.400 0.000 0.000
#> GSM802145     4  0.2009      0.735 0.000 0.040 0.000 0.916 0.040 0.004
#> GSM802154     3  0.0692      0.764 0.000 0.020 0.976 0.004 0.000 0.000
#> GSM802157     3  0.1700      0.710 0.000 0.000 0.916 0.000 0.004 0.080
#> GSM802166     1  0.1088      0.943 0.960 0.000 0.000 0.016 0.024 0.000
#> GSM802169     5  0.4622      0.446 0.000 0.404 0.004 0.020 0.564 0.008
#> GSM802178     2  0.4977     -0.317 0.000 0.524 0.004 0.020 0.428 0.024
#> GSM802181     2  0.2944      0.446 0.000 0.832 0.012 0.008 0.148 0.000
#> GSM802190     5  0.5898      0.471 0.000 0.240 0.228 0.008 0.524 0.000
#> GSM802193     5  0.2882      0.502 0.000 0.120 0.000 0.004 0.848 0.028
#> GSM802135     6  0.1720      0.615 0.000 0.032 0.000 0.040 0.000 0.928
#> GSM802138     4  0.4474      0.761 0.000 0.120 0.000 0.708 0.000 0.172
#> GSM802147     6  0.5547      0.329 0.000 0.388 0.000 0.004 0.120 0.488
#> GSM802150     2  0.6012      0.400 0.000 0.524 0.284 0.172 0.020 0.000
#> GSM802159     6  0.0291      0.635 0.000 0.000 0.004 0.000 0.004 0.992
#> GSM802162     3  0.0000      0.760 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     6  0.4956      0.338 0.000 0.324 0.008 0.016 0.036 0.616
#> GSM802174     2  0.2828      0.546 0.000 0.864 0.072 0.000 0.060 0.004
#> GSM802183     2  0.4620      0.455 0.000 0.580 0.384 0.016 0.020 0.000
#> GSM802186     2  0.4654      0.417 0.000 0.564 0.400 0.016 0.020 0.000
#> GSM802137     1  0.0806      0.940 0.972 0.000 0.000 0.008 0.020 0.000
#> GSM802140     1  0.1092      0.937 0.960 0.000 0.000 0.020 0.020 0.000
#> GSM802149     1  0.1462      0.942 0.936 0.000 0.000 0.008 0.056 0.000
#> GSM802151     1  0.2119      0.928 0.904 0.000 0.000 0.036 0.060 0.000
#> GSM802161     1  0.2058      0.929 0.908 0.000 0.000 0.036 0.056 0.000
#> GSM802163     3  0.0713      0.763 0.000 0.028 0.972 0.000 0.000 0.000
#> GSM802173     1  0.0508      0.942 0.984 0.000 0.000 0.004 0.012 0.000
#> GSM802175     2  0.4056      0.576 0.000 0.704 0.264 0.024 0.008 0.000
#> GSM802185     1  0.1498      0.939 0.940 0.000 0.000 0.028 0.032 0.000
#> GSM802188     1  0.1528      0.940 0.936 0.000 0.000 0.016 0.048 0.000
#> GSM802136     4  0.3817      0.680 0.000 0.028 0.000 0.720 0.000 0.252
#> GSM802139     4  0.3466      0.728 0.000 0.224 0.000 0.760 0.008 0.008
#> GSM802148     6  0.6693      0.409 0.000 0.220 0.000 0.072 0.212 0.496
#> GSM802152     3  0.4461     -0.189 0.000 0.464 0.512 0.020 0.004 0.000
#> GSM802160     1  0.3610      0.805 0.808 0.004 0.000 0.064 0.120 0.004
#> GSM802164     1  0.1995      0.931 0.912 0.000 0.000 0.036 0.052 0.000
#> GSM802172     2  0.4627     -0.229 0.000 0.568 0.004 0.016 0.400 0.012
#> GSM802176     1  0.0291      0.943 0.992 0.000 0.000 0.004 0.004 0.000
#> GSM802184     2  0.4849      0.521 0.000 0.692 0.200 0.020 0.088 0.000
#> GSM802187     3  0.1594      0.749 0.000 0.052 0.932 0.016 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) protocol(p)  time(p) individual(p) k
#> SD:NMF 60            1.000    4.43e-09 0.000103         1.000 2
#> SD:NMF 54            0.579    2.35e-07 0.000108         0.895 3
#> SD:NMF 53            0.637    3.03e-06 0.000201         0.212 4
#> SD:NMF 58            0.251    6.10e-07 0.000212         0.118 5
#> SD:NMF 41            0.802    2.75e-04 0.001062         0.535 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.885           0.962       0.965         0.2537 0.892   0.794
#> 4 4 0.742           0.766       0.884         0.1491 0.901   0.764
#> 5 5 0.782           0.775       0.895         0.0596 0.959   0.873
#> 6 6 0.772           0.683       0.825         0.0521 0.936   0.786

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2  0.2878      0.938  0 0.904 0.096
#> GSM802144     2  0.2625      0.941  0 0.916 0.084
#> GSM802153     3  0.1031      0.998  0 0.024 0.976
#> GSM802156     3  0.1163      0.996  0 0.028 0.972
#> GSM802165     2  0.0892      0.927  0 0.980 0.020
#> GSM802168     2  0.0424      0.933  0 0.992 0.008
#> GSM802177     2  0.2356      0.944  0 0.928 0.072
#> GSM802180     2  0.2356      0.944  0 0.928 0.072
#> GSM802189     2  0.2356      0.944  0 0.928 0.072
#> GSM802192     2  0.0892      0.927  0 0.980 0.020
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     2  0.2878      0.938  0 0.904 0.096
#> GSM802145     2  0.2625      0.941  0 0.916 0.084
#> GSM802154     3  0.1031      0.998  0 0.024 0.976
#> GSM802157     3  0.1163      0.996  0 0.028 0.972
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     2  0.2356      0.944  0 0.928 0.072
#> GSM802178     2  0.2165      0.944  0 0.936 0.064
#> GSM802181     2  0.2356      0.944  0 0.928 0.072
#> GSM802190     2  0.2356      0.944  0 0.928 0.072
#> GSM802193     2  0.1031      0.925  0 0.976 0.024
#> GSM802135     2  0.0592      0.931  0 0.988 0.012
#> GSM802138     2  0.0592      0.931  0 0.988 0.012
#> GSM802147     2  0.1031      0.925  0 0.976 0.024
#> GSM802150     2  0.2796      0.939  0 0.908 0.092
#> GSM802159     2  0.4842      0.692  0 0.776 0.224
#> GSM802162     3  0.1031      0.998  0 0.024 0.976
#> GSM802171     2  0.0424      0.933  0 0.992 0.008
#> GSM802174     2  0.1031      0.934  0 0.976 0.024
#> GSM802183     2  0.2878      0.938  0 0.904 0.096
#> GSM802186     2  0.2878      0.938  0 0.904 0.096
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     3  0.1031      0.998  0 0.024 0.976
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     2  0.2878      0.938  0 0.904 0.096
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.0592      0.931  0 0.988 0.012
#> GSM802139     2  0.0592      0.931  0 0.988 0.012
#> GSM802148     2  0.1031      0.925  0 0.976 0.024
#> GSM802152     2  0.2878      0.938  0 0.904 0.096
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.0592      0.934  0 0.988 0.012
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     2  0.2878      0.938  0 0.904 0.096
#> GSM802187     2  0.2878      0.938  0 0.904 0.096

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802144     2  0.0188     0.7683 0.000 0.996 0.004 0.000
#> GSM802153     3  0.0817     0.9974 0.000 0.024 0.976 0.000
#> GSM802156     3  0.0921     0.9948 0.000 0.028 0.972 0.000
#> GSM802165     4  0.4907     0.5720 0.000 0.420 0.000 0.580
#> GSM802168     2  0.4925    -0.0198 0.000 0.572 0.000 0.428
#> GSM802177     2  0.3444     0.6715 0.000 0.816 0.000 0.184
#> GSM802180     2  0.3444     0.6715 0.000 0.816 0.000 0.184
#> GSM802189     2  0.3444     0.6715 0.000 0.816 0.000 0.184
#> GSM802192     4  0.4907     0.5720 0.000 0.420 0.000 0.580
#> GSM802143     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802155     1  0.4574     0.7949 0.756 0.000 0.024 0.220
#> GSM802158     1  0.4574     0.7949 0.756 0.000 0.024 0.220
#> GSM802167     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802142     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802145     2  0.0188     0.7683 0.000 0.996 0.004 0.000
#> GSM802154     3  0.0817     0.9974 0.000 0.024 0.976 0.000
#> GSM802157     3  0.0921     0.9948 0.000 0.028 0.972 0.000
#> GSM802166     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802169     2  0.3444     0.6715 0.000 0.816 0.000 0.184
#> GSM802178     2  0.4382     0.4479 0.000 0.704 0.000 0.296
#> GSM802181     2  0.3444     0.6715 0.000 0.816 0.000 0.184
#> GSM802190     2  0.3444     0.6715 0.000 0.816 0.000 0.184
#> GSM802193     4  0.4679     0.6601 0.000 0.352 0.000 0.648
#> GSM802135     2  0.2868     0.6879 0.000 0.864 0.000 0.136
#> GSM802138     2  0.2868     0.6879 0.000 0.864 0.000 0.136
#> GSM802147     4  0.3801     0.7075 0.000 0.220 0.000 0.780
#> GSM802150     2  0.0469     0.7681 0.000 0.988 0.012 0.000
#> GSM802159     4  0.4284     0.3792 0.000 0.020 0.200 0.780
#> GSM802162     3  0.0817     0.9974 0.000 0.024 0.976 0.000
#> GSM802171     2  0.4925    -0.0198 0.000 0.572 0.000 0.428
#> GSM802174     4  0.5097     0.4721 0.000 0.428 0.004 0.568
#> GSM802183     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802186     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802137     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802149     1  0.2944     0.8751 0.868 0.000 0.004 0.128
#> GSM802151     1  0.4574     0.7949 0.756 0.000 0.024 0.220
#> GSM802161     1  0.4501     0.8013 0.764 0.000 0.024 0.212
#> GSM802163     3  0.0817     0.9974 0.000 0.024 0.976 0.000
#> GSM802173     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802185     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802136     2  0.2868     0.6879 0.000 0.864 0.000 0.136
#> GSM802139     2  0.2868     0.6879 0.000 0.864 0.000 0.136
#> GSM802148     4  0.3801     0.7075 0.000 0.220 0.000 0.780
#> GSM802152     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802160     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802164     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802172     2  0.4916    -0.0040 0.000 0.576 0.000 0.424
#> GSM802176     1  0.0000     0.9530 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0592     0.7680 0.000 0.984 0.016 0.000
#> GSM802187     2  0.0592     0.7680 0.000 0.984 0.016 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802144     2  0.0290     0.7549 0.000 0.992 0.000 0.008 0.000
#> GSM802153     3  0.0000     0.9603 0.000 0.000 1.000 0.000 0.000
#> GSM802156     3  0.2230     0.9188 0.000 0.000 0.884 0.116 0.000
#> GSM802165     4  0.4060     0.5945 0.000 0.360 0.000 0.640 0.000
#> GSM802168     2  0.4300    -0.0655 0.000 0.524 0.000 0.476 0.000
#> GSM802177     2  0.3274     0.6554 0.000 0.780 0.000 0.220 0.000
#> GSM802180     2  0.3274     0.6554 0.000 0.780 0.000 0.220 0.000
#> GSM802189     2  0.3210     0.6584 0.000 0.788 0.000 0.212 0.000
#> GSM802192     4  0.4060     0.5945 0.000 0.360 0.000 0.640 0.000
#> GSM802143     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802155     5  0.0000     0.9977 0.000 0.000 0.000 0.000 1.000
#> GSM802158     5  0.0000     0.9977 0.000 0.000 0.000 0.000 1.000
#> GSM802167     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802145     2  0.0290     0.7549 0.000 0.992 0.000 0.008 0.000
#> GSM802154     3  0.0000     0.9603 0.000 0.000 1.000 0.000 0.000
#> GSM802157     3  0.2230     0.9188 0.000 0.000 0.884 0.116 0.000
#> GSM802166     1  0.1121     0.9602 0.956 0.000 0.000 0.044 0.000
#> GSM802169     2  0.3305     0.6527 0.000 0.776 0.000 0.224 0.000
#> GSM802178     2  0.3949     0.4406 0.000 0.668 0.000 0.332 0.000
#> GSM802181     2  0.3274     0.6554 0.000 0.780 0.000 0.220 0.000
#> GSM802190     2  0.3274     0.6556 0.000 0.780 0.000 0.220 0.000
#> GSM802193     4  0.3752     0.6748 0.000 0.292 0.000 0.708 0.000
#> GSM802135     2  0.3003     0.6550 0.000 0.812 0.000 0.188 0.000
#> GSM802138     2  0.3003     0.6550 0.000 0.812 0.000 0.188 0.000
#> GSM802147     4  0.2732     0.7182 0.000 0.160 0.000 0.840 0.000
#> GSM802150     2  0.0609     0.7527 0.000 0.980 0.000 0.020 0.000
#> GSM802159     4  0.1851     0.4418 0.000 0.000 0.088 0.912 0.000
#> GSM802162     3  0.0000     0.9603 0.000 0.000 1.000 0.000 0.000
#> GSM802171     2  0.4302    -0.0779 0.000 0.520 0.000 0.480 0.000
#> GSM802174     4  0.4359     0.4289 0.000 0.412 0.004 0.584 0.000
#> GSM802183     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802186     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802137     1  0.0404     0.9803 0.988 0.000 0.000 0.012 0.000
#> GSM802140     1  0.0404     0.9803 0.988 0.000 0.000 0.012 0.000
#> GSM802149     1  0.3106     0.8282 0.840 0.000 0.000 0.020 0.140
#> GSM802151     5  0.0000     0.9977 0.000 0.000 0.000 0.000 1.000
#> GSM802161     5  0.0290     0.9931 0.000 0.000 0.000 0.008 0.992
#> GSM802163     3  0.0000     0.9603 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802185     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0162     0.9838 0.996 0.000 0.000 0.004 0.000
#> GSM802136     2  0.3003     0.6550 0.000 0.812 0.000 0.188 0.000
#> GSM802139     2  0.3003     0.6550 0.000 0.812 0.000 0.188 0.000
#> GSM802148     4  0.2732     0.7182 0.000 0.160 0.000 0.840 0.000
#> GSM802152     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802160     1  0.1121     0.9602 0.956 0.000 0.000 0.044 0.000
#> GSM802164     1  0.0000     0.9850 1.000 0.000 0.000 0.000 0.000
#> GSM802172     2  0.4291    -0.0124 0.000 0.536 0.000 0.464 0.000
#> GSM802176     1  0.0162     0.9838 0.996 0.000 0.000 0.004 0.000
#> GSM802184     2  0.0162     0.7535 0.000 0.996 0.004 0.000 0.000
#> GSM802187     2  0.0162     0.7535 0.000 0.996 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
#> GSM802141     2  0.0458      0.665 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM802144     2  0.1610      0.658 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM802153     3  0.0146      0.928 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM802156     3  0.2491      0.841 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM802165     6  0.5666      0.483 0.000 0.164 0.000 0.352 0.000 0.484
#> GSM802168     6  0.4672      0.360 0.000 0.348 0.000 0.056 0.000 0.596
#> GSM802177     2  0.3717      0.448 0.000 0.616 0.000 0.000 0.000 0.384
#> GSM802180     2  0.3717      0.448 0.000 0.616 0.000 0.000 0.000 0.384
#> GSM802189     2  0.3620      0.474 0.000 0.648 0.000 0.000 0.000 0.352
#> GSM802192     6  0.5666      0.483 0.000 0.164 0.000 0.352 0.000 0.484
#> GSM802143     1  0.0260      0.973 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802146     1  0.0260      0.973 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802155     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM802158     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM802167     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0260      0.973 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802191     1  0.0260      0.973 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802194     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.0458      0.665 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM802145     2  0.1610      0.658 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM802154     3  0.0146      0.928 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM802157     3  0.2491      0.841 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM802166     1  0.2250      0.905 0.896 0.000 0.000 0.040 0.000 0.064
#> GSM802169     2  0.3765      0.421 0.000 0.596 0.000 0.000 0.000 0.404
#> GSM802178     2  0.3868      0.131 0.000 0.504 0.000 0.000 0.000 0.496
#> GSM802181     2  0.3717      0.448 0.000 0.616 0.000 0.000 0.000 0.384
#> GSM802190     2  0.3727      0.445 0.000 0.612 0.000 0.000 0.000 0.388
#> GSM802193     6  0.1757      0.508 0.000 0.076 0.000 0.008 0.000 0.916
#> GSM802135     2  0.5270      0.377 0.000 0.588 0.000 0.144 0.000 0.268
#> GSM802138     2  0.5270      0.377 0.000 0.588 0.000 0.144 0.000 0.268
#> GSM802147     6  0.4332      0.260 0.000 0.072 0.000 0.228 0.000 0.700
#> GSM802150     2  0.1528      0.658 0.000 0.936 0.000 0.016 0.000 0.048
#> GSM802159     4  0.1480      0.000 0.000 0.000 0.040 0.940 0.000 0.020
#> GSM802162     3  0.0146      0.928 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM802171     6  0.4548      0.420 0.000 0.312 0.000 0.056 0.000 0.632
#> GSM802174     2  0.6066     -0.259 0.000 0.392 0.000 0.340 0.000 0.268
#> GSM802183     2  0.0508      0.658 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM802186     2  0.0508      0.658 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM802137     1  0.0520      0.968 0.984 0.000 0.000 0.008 0.000 0.008
#> GSM802140     1  0.0520      0.968 0.984 0.000 0.000 0.008 0.000 0.008
#> GSM802149     1  0.3201      0.814 0.824 0.000 0.000 0.008 0.140 0.028
#> GSM802151     5  0.0000      0.997 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM802161     5  0.0260      0.991 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM802163     3  0.0146      0.928 0.000 0.004 0.996 0.000 0.000 0.000
#> GSM802173     1  0.0000      0.974 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0508      0.658 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM802185     1  0.0260      0.973 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802188     1  0.0291      0.973 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM802136     2  0.5270      0.377 0.000 0.588 0.000 0.144 0.000 0.268
#> GSM802139     2  0.5270      0.377 0.000 0.588 0.000 0.144 0.000 0.268
#> GSM802148     6  0.4332      0.260 0.000 0.072 0.000 0.228 0.000 0.700
#> GSM802152     2  0.0603      0.655 0.000 0.980 0.000 0.016 0.000 0.004
#> GSM802160     1  0.2250      0.905 0.896 0.000 0.000 0.040 0.000 0.064
#> GSM802164     1  0.0260      0.973 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM802172     6  0.4696      0.322 0.000 0.356 0.000 0.056 0.000 0.588
#> GSM802176     1  0.0291      0.973 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM802184     2  0.0508      0.658 0.000 0.984 0.000 0.012 0.000 0.004
#> GSM802187     2  0.0622      0.662 0.000 0.980 0.000 0.012 0.000 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-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) protocol(p)  time(p) individual(p) k
#> CV:hclust 60            1.000    4.43e-09 0.000103        1.0000 2
#> CV:hclust 60            0.673    7.22e-08 0.000167        0.2874 3
#> CV:hclust 54            0.840    5.58e-06 0.001173        0.0562 4
#> CV:hclust 54            0.933    2.32e-05 0.003117        0.0859 5
#> CV:hclust 40            0.647    1.41e-03 0.008765        0.4468 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 0.506           0.946       0.939         0.4495 0.528   0.528
#> 3 3 0.837           0.921       0.916         0.2867 0.877   0.768
#> 4 4 0.635           0.754       0.817         0.1586 1.000   1.000
#> 5 5 0.649           0.619       0.702         0.0932 0.818   0.558
#> 6 6 0.652           0.576       0.708         0.0741 0.901   0.648

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
#> GSM802141     2  0.0000      0.968 0.000 1.000
#> GSM802144     2  0.0000      0.968 0.000 1.000
#> GSM802153     2  0.5408      0.874 0.124 0.876
#> GSM802156     2  0.6048      0.856 0.148 0.852
#> GSM802165     2  0.0000      0.968 0.000 1.000
#> GSM802168     2  0.0000      0.968 0.000 1.000
#> GSM802177     2  0.0000      0.968 0.000 1.000
#> GSM802180     2  0.0000      0.968 0.000 1.000
#> GSM802189     2  0.0000      0.968 0.000 1.000
#> GSM802192     2  0.0000      0.968 0.000 1.000
#> GSM802143     1  0.6048      0.964 0.852 0.148
#> GSM802146     1  0.6048      0.964 0.852 0.148
#> GSM802155     1  0.0000      0.863 1.000 0.000
#> GSM802158     1  0.0000      0.863 1.000 0.000
#> GSM802167     1  0.6048      0.964 0.852 0.148
#> GSM802170     1  0.6048      0.964 0.852 0.148
#> GSM802179     1  0.6048      0.964 0.852 0.148
#> GSM802182     1  0.6048      0.964 0.852 0.148
#> GSM802191     1  0.6048      0.964 0.852 0.148
#> GSM802194     1  0.6048      0.964 0.852 0.148
#> GSM802142     2  0.0000      0.968 0.000 1.000
#> GSM802145     2  0.0000      0.968 0.000 1.000
#> GSM802154     2  0.6048      0.856 0.148 0.852
#> GSM802157     2  0.6048      0.856 0.148 0.852
#> GSM802166     1  0.6048      0.964 0.852 0.148
#> GSM802169     2  0.0000      0.968 0.000 1.000
#> GSM802178     2  0.0000      0.968 0.000 1.000
#> GSM802181     2  0.0000      0.968 0.000 1.000
#> GSM802190     2  0.0000      0.968 0.000 1.000
#> GSM802193     2  0.0000      0.968 0.000 1.000
#> GSM802135     2  0.0000      0.968 0.000 1.000
#> GSM802138     2  0.0000      0.968 0.000 1.000
#> GSM802147     2  0.0938      0.960 0.012 0.988
#> GSM802150     2  0.0000      0.968 0.000 1.000
#> GSM802159     2  0.6048      0.856 0.148 0.852
#> GSM802162     2  0.6048      0.856 0.148 0.852
#> GSM802171     2  0.0000      0.968 0.000 1.000
#> GSM802174     2  0.0000      0.968 0.000 1.000
#> GSM802183     2  0.0000      0.968 0.000 1.000
#> GSM802186     2  0.0000      0.968 0.000 1.000
#> GSM802137     1  0.6048      0.964 0.852 0.148
#> GSM802140     1  0.6048      0.964 0.852 0.148
#> GSM802149     1  0.5178      0.946 0.884 0.116
#> GSM802151     1  0.0000      0.863 1.000 0.000
#> GSM802161     1  0.0000      0.863 1.000 0.000
#> GSM802163     2  0.6048      0.856 0.148 0.852
#> GSM802173     1  0.6048      0.964 0.852 0.148
#> GSM802175     2  0.0000      0.968 0.000 1.000
#> GSM802185     1  0.6048      0.964 0.852 0.148
#> GSM802188     1  0.6048      0.964 0.852 0.148
#> GSM802136     2  0.0000      0.968 0.000 1.000
#> GSM802139     2  0.0000      0.968 0.000 1.000
#> GSM802148     2  0.0000      0.968 0.000 1.000
#> GSM802152     2  0.1184      0.957 0.016 0.984
#> GSM802160     1  0.6048      0.964 0.852 0.148
#> GSM802164     1  0.5178      0.946 0.884 0.116
#> GSM802172     2  0.0000      0.968 0.000 1.000
#> GSM802176     1  0.6048      0.964 0.852 0.148
#> GSM802184     2  0.0000      0.968 0.000 1.000
#> GSM802187     2  0.0000      0.968 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802144     2  0.0747      0.947 0.000 0.984 0.016
#> GSM802153     3  0.6305      0.580 0.000 0.484 0.516
#> GSM802156     3  0.5733      0.920 0.000 0.324 0.676
#> GSM802165     2  0.0747      0.941 0.000 0.984 0.016
#> GSM802168     2  0.0892      0.950 0.000 0.980 0.020
#> GSM802177     2  0.1643      0.948 0.000 0.956 0.044
#> GSM802180     2  0.1529      0.947 0.000 0.960 0.040
#> GSM802189     2  0.1964      0.939 0.000 0.944 0.056
#> GSM802192     2  0.0747      0.941 0.000 0.984 0.016
#> GSM802143     1  0.1964      0.927 0.944 0.000 0.056
#> GSM802146     1  0.1964      0.927 0.944 0.000 0.056
#> GSM802155     1  0.4974      0.820 0.764 0.000 0.236
#> GSM802158     1  0.4974      0.820 0.764 0.000 0.236
#> GSM802167     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802194     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802142     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802145     2  0.0747      0.947 0.000 0.984 0.016
#> GSM802154     3  0.5497      0.915 0.000 0.292 0.708
#> GSM802157     3  0.5621      0.927 0.000 0.308 0.692
#> GSM802166     1  0.0424      0.938 0.992 0.000 0.008
#> GSM802169     2  0.0237      0.946 0.000 0.996 0.004
#> GSM802178     2  0.0237      0.946 0.000 0.996 0.004
#> GSM802181     2  0.1643      0.948 0.000 0.956 0.044
#> GSM802190     2  0.1289      0.950 0.000 0.968 0.032
#> GSM802193     2  0.0424      0.945 0.000 0.992 0.008
#> GSM802135     2  0.0747      0.941 0.000 0.984 0.016
#> GSM802138     2  0.1163      0.944 0.000 0.972 0.028
#> GSM802147     2  0.1289      0.928 0.000 0.968 0.032
#> GSM802150     2  0.1964      0.945 0.000 0.944 0.056
#> GSM802159     3  0.5948      0.878 0.000 0.360 0.640
#> GSM802162     3  0.5621      0.927 0.000 0.308 0.692
#> GSM802171     2  0.0747      0.941 0.000 0.984 0.016
#> GSM802174     2  0.2066      0.940 0.000 0.940 0.060
#> GSM802183     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802186     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802137     1  0.1964      0.927 0.944 0.000 0.056
#> GSM802140     1  0.1964      0.927 0.944 0.000 0.056
#> GSM802149     1  0.1289      0.934 0.968 0.000 0.032
#> GSM802151     1  0.4974      0.820 0.764 0.000 0.236
#> GSM802161     1  0.4931      0.820 0.768 0.000 0.232
#> GSM802163     3  0.5621      0.927 0.000 0.308 0.692
#> GSM802173     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802175     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802185     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802188     1  0.0000      0.939 1.000 0.000 0.000
#> GSM802136     2  0.1163      0.944 0.000 0.972 0.028
#> GSM802139     2  0.0747      0.947 0.000 0.984 0.016
#> GSM802148     2  0.0747      0.941 0.000 0.984 0.016
#> GSM802152     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802160     1  0.1163      0.934 0.972 0.000 0.028
#> GSM802164     1  0.4887      0.823 0.772 0.000 0.228
#> GSM802172     2  0.0237      0.946 0.000 0.996 0.004
#> GSM802176     1  0.1964      0.927 0.944 0.000 0.056
#> GSM802184     2  0.2356      0.937 0.000 0.928 0.072
#> GSM802187     2  0.2356      0.937 0.000 0.928 0.072

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3 p4
#> GSM802141     2  0.4761      0.724 0.000 0.628 0.372 NA
#> GSM802144     2  0.3768      0.757 0.000 0.808 0.184 NA
#> GSM802153     3  0.6004      0.062 0.000 0.276 0.648 NA
#> GSM802156     3  0.6887      0.861 0.000 0.104 0.452 NA
#> GSM802165     2  0.3335      0.691 0.000 0.860 0.120 NA
#> GSM802168     2  0.2530      0.773 0.000 0.888 0.112 NA
#> GSM802177     2  0.2921      0.769 0.000 0.860 0.140 NA
#> GSM802180     2  0.3444      0.774 0.000 0.816 0.184 NA
#> GSM802189     2  0.4222      0.755 0.000 0.728 0.272 NA
#> GSM802192     2  0.2918      0.695 0.000 0.876 0.116 NA
#> GSM802143     1  0.2919      0.846 0.896 0.000 0.044 NA
#> GSM802146     1  0.2830      0.847 0.900 0.000 0.040 NA
#> GSM802155     1  0.4996      0.556 0.516 0.000 0.000 NA
#> GSM802158     1  0.4996      0.556 0.516 0.000 0.000 NA
#> GSM802167     1  0.0000      0.867 1.000 0.000 0.000 NA
#> GSM802170     1  0.0000      0.867 1.000 0.000 0.000 NA
#> GSM802179     1  0.0000      0.867 1.000 0.000 0.000 NA
#> GSM802182     1  0.0336      0.866 0.992 0.000 0.008 NA
#> GSM802191     1  0.0336      0.866 0.992 0.000 0.008 NA
#> GSM802194     1  0.0188      0.866 0.996 0.000 0.000 NA
#> GSM802142     2  0.4761      0.724 0.000 0.628 0.372 NA
#> GSM802145     2  0.3768      0.757 0.000 0.808 0.184 NA
#> GSM802154     3  0.6586      0.857 0.000 0.080 0.500 NA
#> GSM802157     3  0.6754      0.867 0.000 0.092 0.464 NA
#> GSM802166     1  0.1209      0.861 0.964 0.000 0.032 NA
#> GSM802169     2  0.1118      0.767 0.000 0.964 0.036 NA
#> GSM802178     2  0.0592      0.752 0.000 0.984 0.016 NA
#> GSM802181     2  0.2921      0.769 0.000 0.860 0.140 NA
#> GSM802190     2  0.3219      0.775 0.000 0.836 0.164 NA
#> GSM802193     2  0.3529      0.665 0.000 0.836 0.152 NA
#> GSM802135     2  0.3495      0.692 0.000 0.844 0.140 NA
#> GSM802138     2  0.4399      0.738 0.000 0.760 0.224 NA
#> GSM802147     2  0.3743      0.652 0.000 0.824 0.160 NA
#> GSM802150     2  0.4543      0.748 0.000 0.676 0.324 NA
#> GSM802159     3  0.7261      0.741 0.000 0.160 0.500 NA
#> GSM802162     3  0.6748      0.868 0.000 0.092 0.476 NA
#> GSM802171     2  0.2402      0.723 0.000 0.912 0.076 NA
#> GSM802174     2  0.3400      0.757 0.000 0.820 0.180 NA
#> GSM802183     2  0.4661      0.732 0.000 0.652 0.348 NA
#> GSM802186     2  0.4661      0.732 0.000 0.652 0.348 NA
#> GSM802137     1  0.2830      0.846 0.900 0.000 0.040 NA
#> GSM802140     1  0.2830      0.846 0.900 0.000 0.040 NA
#> GSM802149     1  0.2623      0.854 0.908 0.000 0.064 NA
#> GSM802151     1  0.4996      0.556 0.516 0.000 0.000 NA
#> GSM802161     1  0.4996      0.555 0.516 0.000 0.000 NA
#> GSM802163     3  0.6792      0.866 0.000 0.096 0.476 NA
#> GSM802173     1  0.0000      0.867 1.000 0.000 0.000 NA
#> GSM802175     2  0.4661      0.732 0.000 0.652 0.348 NA
#> GSM802185     1  0.0336      0.866 0.992 0.000 0.008 NA
#> GSM802188     1  0.0524      0.866 0.988 0.000 0.008 NA
#> GSM802136     2  0.4399      0.738 0.000 0.760 0.224 NA
#> GSM802139     2  0.3768      0.757 0.000 0.808 0.184 NA
#> GSM802148     2  0.3806      0.659 0.000 0.824 0.156 NA
#> GSM802152     2  0.4776      0.716 0.000 0.624 0.376 NA
#> GSM802160     1  0.2124      0.858 0.932 0.000 0.040 NA
#> GSM802164     1  0.5268      0.572 0.540 0.000 0.008 NA
#> GSM802172     2  0.0707      0.751 0.000 0.980 0.020 NA
#> GSM802176     1  0.2644      0.849 0.908 0.000 0.032 NA
#> GSM802184     2  0.4661      0.732 0.000 0.652 0.348 NA
#> GSM802187     2  0.4730      0.725 0.000 0.636 0.364 NA

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.4163     0.7402 0.000 0.740 0.000 0.228 0.032
#> GSM802144     4  0.5724     0.1341 0.000 0.420 0.004 0.504 0.072
#> GSM802153     2  0.5637     0.3577 0.000 0.644 0.248 0.096 0.012
#> GSM802156     3  0.2673     0.9160 0.000 0.044 0.900 0.036 0.020
#> GSM802165     4  0.2938     0.5124 0.000 0.032 0.008 0.876 0.084
#> GSM802168     4  0.4759     0.0354 0.000 0.388 0.004 0.592 0.016
#> GSM802177     4  0.4722    -0.0416 0.000 0.412 0.004 0.572 0.012
#> GSM802180     2  0.4800     0.3209 0.000 0.508 0.004 0.476 0.012
#> GSM802189     2  0.4478     0.6607 0.000 0.628 0.004 0.360 0.008
#> GSM802192     4  0.2390     0.5172 0.000 0.032 0.012 0.912 0.044
#> GSM802143     1  0.4178     0.7773 0.788 0.156 0.016 0.000 0.040
#> GSM802146     1  0.4078     0.7791 0.792 0.156 0.012 0.000 0.040
#> GSM802155     5  0.3876     0.9513 0.316 0.000 0.000 0.000 0.684
#> GSM802158     5  0.3876     0.9513 0.316 0.000 0.000 0.000 0.684
#> GSM802167     1  0.0451     0.8588 0.988 0.004 0.008 0.000 0.000
#> GSM802170     1  0.0451     0.8588 0.988 0.004 0.008 0.000 0.000
#> GSM802179     1  0.0000     0.8589 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0693     0.8552 0.980 0.008 0.012 0.000 0.000
#> GSM802191     1  0.0693     0.8552 0.980 0.008 0.012 0.000 0.000
#> GSM802194     1  0.0451     0.8588 0.988 0.004 0.008 0.000 0.000
#> GSM802142     2  0.4163     0.7402 0.000 0.740 0.000 0.228 0.032
#> GSM802145     4  0.5771     0.1363 0.000 0.420 0.004 0.500 0.076
#> GSM802154     3  0.2673     0.9145 0.000 0.072 0.892 0.028 0.008
#> GSM802157     3  0.2665     0.9180 0.000 0.048 0.900 0.032 0.020
#> GSM802166     1  0.3021     0.8021 0.880 0.052 0.052 0.000 0.016
#> GSM802169     4  0.4070     0.3659 0.000 0.256 0.004 0.728 0.012
#> GSM802178     4  0.3437     0.4633 0.000 0.176 0.004 0.808 0.012
#> GSM802181     4  0.4806    -0.0311 0.000 0.408 0.004 0.572 0.016
#> GSM802190     4  0.4849    -0.1262 0.000 0.432 0.004 0.548 0.016
#> GSM802193     4  0.2230     0.4892 0.000 0.000 0.000 0.884 0.116
#> GSM802135     4  0.4718     0.4770 0.000 0.092 0.012 0.756 0.140
#> GSM802138     4  0.6159     0.2315 0.000 0.368 0.012 0.520 0.100
#> GSM802147     4  0.3304     0.4705 0.000 0.000 0.016 0.816 0.168
#> GSM802150     2  0.4708     0.6799 0.000 0.668 0.000 0.292 0.040
#> GSM802159     3  0.5287     0.6672 0.000 0.000 0.648 0.260 0.092
#> GSM802162     3  0.2193     0.9200 0.000 0.060 0.912 0.028 0.000
#> GSM802171     4  0.3707     0.5087 0.000 0.116 0.012 0.828 0.044
#> GSM802174     4  0.4886    -0.2263 0.000 0.468 0.004 0.512 0.016
#> GSM802183     2  0.3774     0.7734 0.000 0.704 0.000 0.296 0.000
#> GSM802186     2  0.3774     0.7734 0.000 0.704 0.000 0.296 0.000
#> GSM802137     1  0.4440     0.7721 0.772 0.164 0.024 0.000 0.040
#> GSM802140     1  0.4351     0.7745 0.776 0.164 0.020 0.000 0.040
#> GSM802149     1  0.4997     0.7283 0.724 0.196 0.056 0.000 0.024
#> GSM802151     5  0.3876     0.9513 0.316 0.000 0.000 0.000 0.684
#> GSM802161     5  0.3876     0.9480 0.316 0.000 0.000 0.000 0.684
#> GSM802163     3  0.2353     0.9196 0.000 0.060 0.908 0.028 0.004
#> GSM802173     1  0.0000     0.8589 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.3796     0.7708 0.000 0.700 0.000 0.300 0.000
#> GSM802185     1  0.0693     0.8552 0.980 0.008 0.012 0.000 0.000
#> GSM802188     1  0.0693     0.8552 0.980 0.008 0.012 0.000 0.000
#> GSM802136     4  0.6159     0.2315 0.000 0.368 0.012 0.520 0.100
#> GSM802139     4  0.5862     0.1410 0.000 0.420 0.004 0.492 0.084
#> GSM802148     4  0.2930     0.4795 0.000 0.000 0.004 0.832 0.164
#> GSM802152     2  0.3430     0.7613 0.000 0.776 0.000 0.220 0.004
#> GSM802160     1  0.3254     0.8012 0.868 0.060 0.052 0.000 0.020
#> GSM802164     5  0.4876     0.7850 0.436 0.008 0.012 0.000 0.544
#> GSM802172     4  0.3437     0.4633 0.000 0.176 0.004 0.808 0.012
#> GSM802176     1  0.3844     0.7866 0.808 0.144 0.008 0.000 0.040
#> GSM802184     2  0.3796     0.7708 0.000 0.700 0.000 0.300 0.000
#> GSM802187     2  0.3336     0.7652 0.000 0.772 0.000 0.228 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
#> GSM802141     2  0.3273     0.5603 0.000 0.848 0.000 NA 0.044 0.072
#> GSM802144     2  0.7075     0.3070 0.000 0.400 0.000 NA 0.176 0.324
#> GSM802153     2  0.4292     0.4326 0.000 0.740 0.204 NA 0.024 0.016
#> GSM802156     3  0.1608     0.8939 0.000 0.016 0.940 NA 0.004 0.004
#> GSM802165     6  0.5190     0.4255 0.000 0.024 0.016 NA 0.084 0.692
#> GSM802168     6  0.3713     0.4736 0.000 0.284 0.000 NA 0.004 0.704
#> GSM802177     6  0.3619     0.4522 0.000 0.316 0.000 NA 0.000 0.680
#> GSM802180     6  0.3905     0.3966 0.000 0.356 0.000 NA 0.004 0.636
#> GSM802189     6  0.3999     0.1249 0.000 0.496 0.000 NA 0.004 0.500
#> GSM802192     6  0.4118     0.4740 0.000 0.016 0.012 NA 0.048 0.780
#> GSM802143     1  0.3690     0.6619 0.684 0.000 0.000 NA 0.008 0.000
#> GSM802146     1  0.3653     0.6659 0.692 0.000 0.000 NA 0.008 0.000
#> GSM802155     5  0.3489     0.9189 0.288 0.000 0.000 NA 0.708 0.000
#> GSM802158     5  0.3489     0.9189 0.288 0.000 0.000 NA 0.708 0.000
#> GSM802167     1  0.0632     0.7747 0.976 0.000 0.000 NA 0.000 0.000
#> GSM802170     1  0.0632     0.7747 0.976 0.000 0.000 NA 0.000 0.000
#> GSM802179     1  0.0000     0.7739 1.000 0.000 0.000 NA 0.000 0.000
#> GSM802182     1  0.1780     0.7570 0.932 0.028 0.012 NA 0.000 0.000
#> GSM802191     1  0.1780     0.7570 0.932 0.028 0.012 NA 0.000 0.000
#> GSM802194     1  0.0713     0.7740 0.972 0.000 0.000 NA 0.000 0.000
#> GSM802142     2  0.3273     0.5603 0.000 0.848 0.000 NA 0.044 0.072
#> GSM802145     2  0.7075     0.3070 0.000 0.400 0.000 NA 0.176 0.324
#> GSM802154     3  0.1693     0.8922 0.000 0.032 0.936 NA 0.020 0.000
#> GSM802157     3  0.1552     0.8955 0.000 0.020 0.940 NA 0.004 0.000
#> GSM802166     1  0.3336     0.6883 0.824 0.032 0.004 NA 0.008 0.000
#> GSM802169     6  0.3354     0.5122 0.000 0.184 0.000 NA 0.016 0.792
#> GSM802178     6  0.3227     0.5261 0.000 0.124 0.000 NA 0.016 0.832
#> GSM802181     6  0.3619     0.4522 0.000 0.316 0.000 NA 0.000 0.680
#> GSM802190     6  0.3861     0.4501 0.000 0.316 0.000 NA 0.008 0.672
#> GSM802193     6  0.3952     0.4205 0.000 0.000 0.000 NA 0.020 0.672
#> GSM802135     6  0.7446     0.0669 0.000 0.116 0.016 NA 0.216 0.444
#> GSM802138     2  0.7800     0.2224 0.000 0.324 0.016 NA 0.196 0.316
#> GSM802147     6  0.4874     0.3628 0.000 0.000 0.032 NA 0.016 0.544
#> GSM802150     2  0.4758     0.4899 0.000 0.704 0.000 NA 0.056 0.204
#> GSM802159     3  0.5771     0.6059 0.000 0.000 0.608 NA 0.044 0.124
#> GSM802162     3  0.0790     0.8990 0.000 0.032 0.968 NA 0.000 0.000
#> GSM802171     6  0.4766     0.4736 0.000 0.048 0.016 NA 0.060 0.752
#> GSM802174     6  0.4344     0.3254 0.000 0.412 0.000 NA 0.008 0.568
#> GSM802183     2  0.3189     0.4296 0.000 0.760 0.000 NA 0.000 0.236
#> GSM802186     2  0.3189     0.4296 0.000 0.760 0.000 NA 0.000 0.236
#> GSM802137     1  0.3774     0.6576 0.664 0.000 0.000 NA 0.008 0.000
#> GSM802140     1  0.3758     0.6600 0.668 0.000 0.000 NA 0.008 0.000
#> GSM802149     1  0.4830     0.5804 0.588 0.032 0.004 NA 0.012 0.000
#> GSM802151     5  0.3626     0.9183 0.288 0.004 0.000 NA 0.704 0.000
#> GSM802161     5  0.3626     0.9094 0.288 0.004 0.000 NA 0.704 0.000
#> GSM802163     3  0.1409     0.8964 0.000 0.032 0.948 NA 0.012 0.000
#> GSM802173     1  0.0000     0.7739 1.000 0.000 0.000 NA 0.000 0.000
#> GSM802175     2  0.3533     0.4259 0.000 0.748 0.000 NA 0.004 0.236
#> GSM802185     1  0.1700     0.7559 0.936 0.028 0.012 NA 0.000 0.000
#> GSM802188     1  0.1857     0.7561 0.928 0.028 0.012 NA 0.000 0.000
#> GSM802136     2  0.7800     0.2224 0.000 0.324 0.016 NA 0.196 0.316
#> GSM802139     2  0.7319     0.3061 0.000 0.396 0.004 NA 0.184 0.300
#> GSM802148     6  0.5118     0.3459 0.000 0.008 0.016 NA 0.032 0.528
#> GSM802152     2  0.3124     0.5422 0.000 0.848 0.000 NA 0.040 0.096
#> GSM802160     1  0.3775     0.6822 0.776 0.032 0.004 NA 0.008 0.000
#> GSM802164     5  0.5250     0.6323 0.456 0.028 0.012 NA 0.484 0.000
#> GSM802172     6  0.3140     0.5242 0.000 0.116 0.000 NA 0.016 0.840
#> GSM802176     1  0.3534     0.6756 0.716 0.000 0.000 NA 0.008 0.000
#> GSM802184     2  0.3533     0.4259 0.000 0.748 0.000 NA 0.004 0.236
#> GSM802187     2  0.1843     0.5499 0.000 0.912 0.000 NA 0.004 0.080

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) protocol(p)  time(p) individual(p) k
#> CV:kmeans 60            1.000    4.43e-09 0.000103         1.000 2
#> CV:kmeans 60            0.916    6.33e-08 0.000163         0.376 3
#> CV:kmeans 59            0.992    1.07e-07 0.000240         0.478 4
#> CV:kmeans 41            0.739    4.53e-04 0.000376         0.663 5
#> CV:kmeans 35            0.967    6.69e-04 0.012444         0.800 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.895           0.949       0.965         0.3117 0.864   0.743
#> 4 4 0.804           0.574       0.831         0.1724 0.864   0.662
#> 5 5 0.751           0.665       0.792         0.0599 0.899   0.667
#> 6 6 0.782           0.713       0.811         0.0491 0.899   0.611

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2  0.3551      0.904  0 0.868 0.132
#> GSM802144     2  0.0000      0.932  0 1.000 0.000
#> GSM802153     3  0.0000      0.969  0 0.000 1.000
#> GSM802156     3  0.1643      0.941  0 0.044 0.956
#> GSM802165     2  0.0000      0.932  0 1.000 0.000
#> GSM802168     2  0.1643      0.930  0 0.956 0.044
#> GSM802177     2  0.2066      0.929  0 0.940 0.060
#> GSM802180     2  0.2796      0.921  0 0.908 0.092
#> GSM802189     2  0.3619      0.902  0 0.864 0.136
#> GSM802192     2  0.0000      0.932  0 1.000 0.000
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     2  0.3879      0.890  0 0.848 0.152
#> GSM802145     2  0.0000      0.932  0 1.000 0.000
#> GSM802154     3  0.0000      0.969  0 0.000 1.000
#> GSM802157     3  0.0000      0.969  0 0.000 1.000
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     2  0.0000      0.932  0 1.000 0.000
#> GSM802178     2  0.0000      0.932  0 1.000 0.000
#> GSM802181     2  0.2066      0.929  0 0.940 0.060
#> GSM802190     2  0.2711      0.923  0 0.912 0.088
#> GSM802193     2  0.0000      0.932  0 1.000 0.000
#> GSM802135     2  0.0000      0.932  0 1.000 0.000
#> GSM802138     2  0.0000      0.932  0 1.000 0.000
#> GSM802147     2  0.4887      0.664  0 0.772 0.228
#> GSM802150     2  0.2261      0.927  0 0.932 0.068
#> GSM802159     3  0.3816      0.848  0 0.148 0.852
#> GSM802162     3  0.0000      0.969  0 0.000 1.000
#> GSM802171     2  0.0000      0.932  0 1.000 0.000
#> GSM802174     2  0.3412      0.908  0 0.876 0.124
#> GSM802183     2  0.3816      0.893  0 0.852 0.148
#> GSM802186     2  0.3816      0.893  0 0.852 0.148
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     3  0.0000      0.969  0 0.000 1.000
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     2  0.3619      0.902  0 0.864 0.136
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.0000      0.932  0 1.000 0.000
#> GSM802139     2  0.0000      0.932  0 1.000 0.000
#> GSM802148     2  0.0000      0.932  0 1.000 0.000
#> GSM802152     3  0.0592      0.961  0 0.012 0.988
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.0000      0.932  0 1.000 0.000
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     2  0.3619      0.902  0 0.864 0.136
#> GSM802187     2  0.3941      0.887  0 0.844 0.156

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     4  0.5512    -0.0901 0.000 0.488 0.016 0.496
#> GSM802144     4  0.1022     0.4703 0.000 0.032 0.000 0.968
#> GSM802153     3  0.7006     0.3708 0.000 0.216 0.580 0.204
#> GSM802156     3  0.0469     0.9077 0.000 0.000 0.988 0.012
#> GSM802165     2  0.5000    -0.1148 0.000 0.500 0.000 0.500
#> GSM802168     2  0.1118     0.4712 0.000 0.964 0.000 0.036
#> GSM802177     2  0.0188     0.4898 0.000 0.996 0.000 0.004
#> GSM802180     2  0.0921     0.4863 0.000 0.972 0.000 0.028
#> GSM802189     2  0.2124     0.4675 0.000 0.924 0.008 0.068
#> GSM802192     4  0.5000    -0.0189 0.000 0.500 0.000 0.500
#> GSM802143     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0188     0.9973 0.996 0.000 0.000 0.004
#> GSM802158     1  0.0188     0.9973 0.996 0.000 0.000 0.004
#> GSM802167     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802142     4  0.5512    -0.0901 0.000 0.488 0.016 0.496
#> GSM802145     4  0.1022     0.4703 0.000 0.032 0.000 0.968
#> GSM802154     3  0.0000     0.9097 0.000 0.000 1.000 0.000
#> GSM802157     3  0.0469     0.9077 0.000 0.000 0.988 0.012
#> GSM802166     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802169     2  0.4643     0.1206 0.000 0.656 0.000 0.344
#> GSM802178     2  0.4933    -0.0094 0.000 0.568 0.000 0.432
#> GSM802181     2  0.0188     0.4898 0.000 0.996 0.000 0.004
#> GSM802190     2  0.0672     0.4871 0.000 0.984 0.008 0.008
#> GSM802193     2  0.4998    -0.1034 0.000 0.512 0.000 0.488
#> GSM802135     4  0.4500     0.2083 0.000 0.316 0.000 0.684
#> GSM802138     4  0.0592     0.4693 0.000 0.016 0.000 0.984
#> GSM802147     2  0.7500     0.0480 0.000 0.500 0.248 0.252
#> GSM802150     4  0.4999    -0.0796 0.000 0.492 0.000 0.508
#> GSM802159     3  0.1398     0.8865 0.000 0.004 0.956 0.040
#> GSM802162     3  0.0000     0.9097 0.000 0.000 1.000 0.000
#> GSM802171     4  0.5000    -0.0189 0.000 0.500 0.000 0.500
#> GSM802174     2  0.0657     0.4891 0.000 0.984 0.012 0.004
#> GSM802183     2  0.5173     0.2756 0.000 0.660 0.020 0.320
#> GSM802186     2  0.5173     0.2756 0.000 0.660 0.020 0.320
#> GSM802137     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0188     0.9973 0.996 0.000 0.000 0.004
#> GSM802151     1  0.0188     0.9973 0.996 0.000 0.000 0.004
#> GSM802161     1  0.0188     0.9973 0.996 0.000 0.000 0.004
#> GSM802163     3  0.0000     0.9097 0.000 0.000 1.000 0.000
#> GSM802173     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802175     2  0.5069     0.2784 0.000 0.664 0.016 0.320
#> GSM802185     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802136     4  0.0592     0.4693 0.000 0.016 0.000 0.984
#> GSM802139     4  0.1211     0.4658 0.000 0.040 0.000 0.960
#> GSM802148     4  0.5000    -0.0132 0.000 0.496 0.000 0.504
#> GSM802152     2  0.7542     0.0887 0.000 0.476 0.212 0.312
#> GSM802160     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802164     1  0.0188     0.9973 0.996 0.000 0.000 0.004
#> GSM802172     2  0.4972    -0.0495 0.000 0.544 0.000 0.456
#> GSM802176     1  0.0000     0.9990 1.000 0.000 0.000 0.000
#> GSM802184     2  0.5069     0.2784 0.000 0.664 0.016 0.320
#> GSM802187     2  0.5607    -0.0336 0.000 0.492 0.020 0.488

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.4015     0.2514 0.000 0.652 0.000 0.000 0.348
#> GSM802144     5  0.4528     0.8478 0.000 0.104 0.000 0.144 0.752
#> GSM802153     3  0.4300     0.1506 0.000 0.476 0.524 0.000 0.000
#> GSM802156     3  0.0000     0.8732 0.000 0.000 1.000 0.000 0.000
#> GSM802165     4  0.3671     0.4383 0.000 0.008 0.000 0.756 0.236
#> GSM802168     4  0.4390     0.3270 0.000 0.428 0.000 0.568 0.004
#> GSM802177     4  0.4410     0.3078 0.000 0.440 0.000 0.556 0.004
#> GSM802180     2  0.4430    -0.1603 0.000 0.540 0.000 0.456 0.004
#> GSM802189     2  0.4211     0.1133 0.000 0.636 0.000 0.360 0.004
#> GSM802192     4  0.2416     0.5867 0.000 0.012 0.000 0.888 0.100
#> GSM802143     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802155     1  0.4024     0.8027 0.752 0.028 0.000 0.000 0.220
#> GSM802158     1  0.4024     0.8027 0.752 0.028 0.000 0.000 0.220
#> GSM802167     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.4030     0.2408 0.000 0.648 0.000 0.000 0.352
#> GSM802145     5  0.4487     0.8502 0.000 0.104 0.000 0.140 0.756
#> GSM802154     3  0.0000     0.8732 0.000 0.000 1.000 0.000 0.000
#> GSM802157     3  0.0000     0.8732 0.000 0.000 1.000 0.000 0.000
#> GSM802166     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802169     4  0.3967     0.5445 0.000 0.264 0.000 0.724 0.012
#> GSM802178     4  0.2909     0.6252 0.000 0.140 0.000 0.848 0.012
#> GSM802181     4  0.4397     0.3227 0.000 0.432 0.000 0.564 0.004
#> GSM802190     4  0.4397     0.3230 0.000 0.432 0.000 0.564 0.004
#> GSM802193     4  0.1671     0.5880 0.000 0.000 0.000 0.924 0.076
#> GSM802135     5  0.4067     0.6199 0.000 0.008 0.000 0.300 0.692
#> GSM802138     5  0.4307     0.8519 0.000 0.100 0.000 0.128 0.772
#> GSM802147     4  0.4054     0.5021 0.000 0.000 0.204 0.760 0.036
#> GSM802150     5  0.6373    -0.0571 0.000 0.416 0.000 0.164 0.420
#> GSM802159     3  0.3779     0.6855 0.000 0.000 0.776 0.200 0.024
#> GSM802162     3  0.0000     0.8732 0.000 0.000 1.000 0.000 0.000
#> GSM802171     4  0.5107     0.5599 0.000 0.108 0.000 0.688 0.204
#> GSM802174     2  0.4403    -0.1233 0.000 0.560 0.000 0.436 0.004
#> GSM802183     2  0.0794     0.6462 0.000 0.972 0.000 0.028 0.000
#> GSM802186     2  0.0794     0.6462 0.000 0.972 0.000 0.028 0.000
#> GSM802137     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.2727     0.8747 0.868 0.016 0.000 0.000 0.116
#> GSM802151     1  0.4024     0.8027 0.752 0.028 0.000 0.000 0.220
#> GSM802161     1  0.4024     0.8027 0.752 0.028 0.000 0.000 0.220
#> GSM802163     3  0.0000     0.8732 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0794     0.6462 0.000 0.972 0.000 0.028 0.000
#> GSM802185     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802136     5  0.4307     0.8519 0.000 0.100 0.000 0.128 0.772
#> GSM802139     5  0.4351     0.8525 0.000 0.100 0.000 0.132 0.768
#> GSM802148     4  0.3636     0.3434 0.000 0.000 0.000 0.728 0.272
#> GSM802152     2  0.4514     0.4603 0.000 0.728 0.228 0.008 0.036
#> GSM802160     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802164     1  0.3845     0.8136 0.768 0.024 0.000 0.000 0.208
#> GSM802172     4  0.2771     0.6291 0.000 0.128 0.000 0.860 0.012
#> GSM802176     1  0.0000     0.9412 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0794     0.6462 0.000 0.972 0.000 0.028 0.000
#> GSM802187     2  0.3300     0.4804 0.000 0.792 0.000 0.004 0.204

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.4037      0.442 0.000 0.608 0.000 0.380 0.012 0.000
#> GSM802144     4  0.1003      0.764 0.000 0.020 0.000 0.964 0.000 0.016
#> GSM802153     2  0.4076      0.279 0.000 0.564 0.428 0.004 0.004 0.000
#> GSM802156     3  0.0146      0.937 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM802165     6  0.6665      0.243 0.000 0.092 0.000 0.296 0.128 0.484
#> GSM802168     6  0.3315      0.660 0.000 0.200 0.000 0.000 0.020 0.780
#> GSM802177     6  0.2871      0.661 0.000 0.192 0.000 0.000 0.004 0.804
#> GSM802180     6  0.3595      0.581 0.000 0.288 0.000 0.000 0.008 0.704
#> GSM802189     6  0.3912      0.521 0.000 0.340 0.000 0.000 0.012 0.648
#> GSM802192     6  0.5607      0.510 0.000 0.092 0.000 0.120 0.124 0.664
#> GSM802143     1  0.0982      0.920 0.968 0.004 0.000 0.004 0.020 0.004
#> GSM802146     1  0.0982      0.920 0.968 0.004 0.000 0.004 0.020 0.004
#> GSM802155     5  0.3409      0.949 0.300 0.000 0.000 0.000 0.700 0.000
#> GSM802158     5  0.3409      0.949 0.300 0.000 0.000 0.000 0.700 0.000
#> GSM802167     1  0.0458      0.932 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802170     1  0.0632      0.931 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802179     1  0.0632      0.931 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802182     1  0.0937      0.921 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM802191     1  0.0865      0.924 0.964 0.000 0.000 0.000 0.036 0.000
#> GSM802194     1  0.0458      0.932 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802142     2  0.4037      0.442 0.000 0.608 0.000 0.380 0.012 0.000
#> GSM802145     4  0.0806      0.767 0.000 0.020 0.000 0.972 0.000 0.008
#> GSM802154     3  0.0000      0.937 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802157     3  0.0146      0.937 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM802166     1  0.0291      0.928 0.992 0.004 0.000 0.000 0.004 0.000
#> GSM802169     6  0.2395      0.686 0.000 0.076 0.000 0.012 0.020 0.892
#> GSM802178     6  0.1542      0.685 0.000 0.016 0.000 0.024 0.016 0.944
#> GSM802181     6  0.2871      0.661 0.000 0.192 0.000 0.000 0.004 0.804
#> GSM802190     6  0.3245      0.670 0.000 0.172 0.000 0.000 0.028 0.800
#> GSM802193     6  0.6184      0.424 0.000 0.112 0.000 0.084 0.228 0.576
#> GSM802135     4  0.2201      0.714 0.000 0.036 0.000 0.904 0.004 0.056
#> GSM802138     4  0.0603      0.769 0.000 0.016 0.000 0.980 0.000 0.004
#> GSM802147     6  0.7609      0.334 0.000 0.112 0.140 0.048 0.236 0.464
#> GSM802150     4  0.6471     -0.199 0.000 0.328 0.000 0.396 0.020 0.256
#> GSM802159     3  0.5515      0.664 0.000 0.088 0.708 0.032 0.100 0.072
#> GSM802162     3  0.0000      0.937 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     6  0.4715      0.506 0.000 0.012 0.000 0.244 0.068 0.676
#> GSM802174     6  0.3927      0.511 0.000 0.344 0.000 0.000 0.012 0.644
#> GSM802183     2  0.2092      0.716 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM802186     2  0.2092      0.716 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM802137     1  0.0982      0.920 0.968 0.004 0.000 0.004 0.020 0.004
#> GSM802140     1  0.0982      0.920 0.968 0.004 0.000 0.004 0.020 0.004
#> GSM802149     1  0.3892      0.155 0.672 0.004 0.000 0.004 0.316 0.004
#> GSM802151     5  0.3409      0.949 0.300 0.000 0.000 0.000 0.700 0.000
#> GSM802161     5  0.3446      0.943 0.308 0.000 0.000 0.000 0.692 0.000
#> GSM802163     3  0.0000      0.937 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802173     1  0.0632      0.931 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802175     2  0.2513      0.703 0.000 0.852 0.000 0.000 0.008 0.140
#> GSM802185     1  0.0937      0.921 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM802188     1  0.1007      0.918 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM802136     4  0.0603      0.769 0.000 0.016 0.000 0.980 0.000 0.004
#> GSM802139     4  0.0914      0.768 0.000 0.016 0.000 0.968 0.000 0.016
#> GSM802148     4  0.7342     -0.110 0.000 0.112 0.000 0.328 0.232 0.328
#> GSM802152     2  0.5754      0.633 0.000 0.660 0.184 0.052 0.024 0.080
#> GSM802160     1  0.0798      0.923 0.976 0.004 0.000 0.004 0.012 0.004
#> GSM802164     5  0.3810      0.768 0.428 0.000 0.000 0.000 0.572 0.000
#> GSM802172     6  0.1616      0.684 0.000 0.012 0.000 0.028 0.020 0.940
#> GSM802176     1  0.0837      0.925 0.972 0.000 0.000 0.004 0.020 0.004
#> GSM802184     2  0.2473      0.708 0.000 0.856 0.000 0.000 0.008 0.136
#> GSM802187     2  0.2794      0.692 0.000 0.840 0.004 0.144 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-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) protocol(p)  time(p) individual(p) k
#> CV:skmeans 60           1.0000    4.43e-09 0.000103        1.0000 2
#> CV:skmeans 60           1.0000    7.98e-08 0.000167        0.5015 3
#> CV:skmeans 28           1.0000    7.27e-04 0.005685        0.8307 4
#> CV:skmeans 45           0.3660    4.47e-04 0.007105        0.1172 5
#> CV:skmeans 51           0.0724    3.03e-04 0.006622        0.0231 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 22263 rows and 60 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.4728 0.528   0.528
#> 3 3 1.000           1.000       1.000         0.2292 0.892   0.794
#> 4 4 0.999           0.964       0.985         0.1995 0.883   0.721
#> 5 5 0.999           0.960       0.983         0.0580 0.959   0.865
#> 6 6 0.952           0.928       0.965         0.0569 0.959   0.844

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

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

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

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1 p2 p3
#> GSM802141     2       0          1  0  1  0
#> GSM802144     2       0          1  0  1  0
#> GSM802153     2       0          1  0  1  0
#> GSM802156     3       0          1  0  0  1
#> GSM802165     2       0          1  0  1  0
#> GSM802168     2       0          1  0  1  0
#> GSM802177     2       0          1  0  1  0
#> GSM802180     2       0          1  0  1  0
#> GSM802189     2       0          1  0  1  0
#> GSM802192     2       0          1  0  1  0
#> GSM802143     1       0          1  1  0  0
#> GSM802146     1       0          1  1  0  0
#> GSM802155     1       0          1  1  0  0
#> GSM802158     1       0          1  1  0  0
#> GSM802167     1       0          1  1  0  0
#> GSM802170     1       0          1  1  0  0
#> GSM802179     1       0          1  1  0  0
#> GSM802182     1       0          1  1  0  0
#> GSM802191     1       0          1  1  0  0
#> GSM802194     1       0          1  1  0  0
#> GSM802142     2       0          1  0  1  0
#> GSM802145     2       0          1  0  1  0
#> GSM802154     3       0          1  0  0  1
#> GSM802157     3       0          1  0  0  1
#> GSM802166     1       0          1  1  0  0
#> GSM802169     2       0          1  0  1  0
#> GSM802178     2       0          1  0  1  0
#> GSM802181     2       0          1  0  1  0
#> GSM802190     2       0          1  0  1  0
#> GSM802193     2       0          1  0  1  0
#> GSM802135     2       0          1  0  1  0
#> GSM802138     2       0          1  0  1  0
#> GSM802147     2       0          1  0  1  0
#> GSM802150     2       0          1  0  1  0
#> GSM802159     3       0          1  0  0  1
#> GSM802162     3       0          1  0  0  1
#> GSM802171     2       0          1  0  1  0
#> GSM802174     2       0          1  0  1  0
#> GSM802183     2       0          1  0  1  0
#> GSM802186     2       0          1  0  1  0
#> GSM802137     1       0          1  1  0  0
#> GSM802140     1       0          1  1  0  0
#> GSM802149     1       0          1  1  0  0
#> GSM802151     1       0          1  1  0  0
#> GSM802161     1       0          1  1  0  0
#> GSM802163     3       0          1  0  0  1
#> GSM802173     1       0          1  1  0  0
#> GSM802175     2       0          1  0  1  0
#> GSM802185     1       0          1  1  0  0
#> GSM802188     1       0          1  1  0  0
#> GSM802136     2       0          1  0  1  0
#> GSM802139     2       0          1  0  1  0
#> GSM802148     2       0          1  0  1  0
#> GSM802152     2       0          1  0  1  0
#> GSM802160     1       0          1  1  0  0
#> GSM802164     1       0          1  1  0  0
#> GSM802172     2       0          1  0  1  0
#> GSM802176     1       0          1  1  0  0
#> GSM802184     2       0          1  0  1  0
#> GSM802187     2       0          1  0  1  0

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2 p3    p4
#> GSM802141     2  0.2281      0.898  0 0.904  0 0.096
#> GSM802144     4  0.0817      0.907  0 0.024  0 0.976
#> GSM802153     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802156     3  0.0000      1.000  0 0.000  1 0.000
#> GSM802165     4  0.0000      0.916  0 0.000  0 1.000
#> GSM802168     2  0.0336      0.978  0 0.992  0 0.008
#> GSM802177     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802180     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802189     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802192     2  0.0592      0.975  0 0.984  0 0.016
#> GSM802143     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802146     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802155     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802158     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802167     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802170     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802179     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802182     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802191     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802194     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802142     4  0.4888      0.308  0 0.412  0 0.588
#> GSM802145     4  0.0469      0.916  0 0.012  0 0.988
#> GSM802154     3  0.0000      1.000  0 0.000  1 0.000
#> GSM802157     3  0.0000      1.000  0 0.000  1 0.000
#> GSM802166     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802169     2  0.0469      0.976  0 0.988  0 0.012
#> GSM802178     2  0.0336      0.978  0 0.992  0 0.008
#> GSM802181     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802190     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802193     2  0.0469      0.976  0 0.988  0 0.012
#> GSM802135     4  0.0000      0.916  0 0.000  0 1.000
#> GSM802138     4  0.0336      0.919  0 0.008  0 0.992
#> GSM802147     2  0.0188      0.979  0 0.996  0 0.004
#> GSM802150     2  0.1389      0.944  0 0.952  0 0.048
#> GSM802159     3  0.0000      1.000  0 0.000  1 0.000
#> GSM802162     3  0.0000      1.000  0 0.000  1 0.000
#> GSM802171     2  0.2647      0.870  0 0.880  0 0.120
#> GSM802174     2  0.0336      0.978  0 0.992  0 0.008
#> GSM802183     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802186     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802137     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802140     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802149     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802151     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802161     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802163     3  0.0000      1.000  0 0.000  1 0.000
#> GSM802173     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802175     2  0.2081      0.910  0 0.916  0 0.084
#> GSM802185     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802188     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802136     4  0.0336      0.919  0 0.008  0 0.992
#> GSM802139     4  0.0336      0.919  0 0.008  0 0.992
#> GSM802148     4  0.0000      0.916  0 0.000  0 1.000
#> GSM802152     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802160     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802164     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802172     2  0.0469      0.976  0 0.988  0 0.012
#> GSM802176     1  0.0000      1.000  1 0.000  0 0.000
#> GSM802184     2  0.0000      0.980  0 1.000  0 0.000
#> GSM802187     2  0.0000      0.980  0 1.000  0 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2 p3    p4    p5
#> GSM802141     2  0.1965      0.898 0.000 0.904  0 0.096 0.000
#> GSM802144     4  0.0703      0.899 0.000 0.024  0 0.976 0.000
#> GSM802153     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802156     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM802165     4  0.0000      0.909 0.000 0.000  0 1.000 0.000
#> GSM802168     2  0.0290      0.978 0.000 0.992  0 0.008 0.000
#> GSM802177     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802180     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802189     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802192     2  0.0510      0.975 0.000 0.984  0 0.016 0.000
#> GSM802143     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802146     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802155     5  0.0290      0.982 0.008 0.000  0 0.000 0.992
#> GSM802158     5  0.0290      0.982 0.008 0.000  0 0.000 0.992
#> GSM802167     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802170     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802179     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802182     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802191     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802194     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802142     4  0.4210      0.308 0.000 0.412  0 0.588 0.000
#> GSM802145     4  0.0404      0.909 0.000 0.012  0 0.988 0.000
#> GSM802154     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM802157     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM802166     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802169     2  0.0404      0.976 0.000 0.988  0 0.012 0.000
#> GSM802178     2  0.0290      0.978 0.000 0.992  0 0.008 0.000
#> GSM802181     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802190     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802193     2  0.0404      0.976 0.000 0.988  0 0.012 0.000
#> GSM802135     4  0.0000      0.909 0.000 0.000  0 1.000 0.000
#> GSM802138     4  0.0290      0.912 0.000 0.008  0 0.992 0.000
#> GSM802147     2  0.0162      0.979 0.000 0.996  0 0.004 0.000
#> GSM802150     2  0.1197      0.944 0.000 0.952  0 0.048 0.000
#> GSM802159     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM802162     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM802171     2  0.2280      0.870 0.000 0.880  0 0.120 0.000
#> GSM802174     2  0.0290      0.978 0.000 0.992  0 0.008 0.000
#> GSM802183     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802186     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802137     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802140     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802149     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802151     5  0.0290      0.982 0.008 0.000  0 0.000 0.992
#> GSM802161     5  0.1121      0.946 0.044 0.000  0 0.000 0.956
#> GSM802163     3  0.0000      1.000 0.000 0.000  1 0.000 0.000
#> GSM802173     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802175     2  0.1792      0.910 0.000 0.916  0 0.084 0.000
#> GSM802185     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802188     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802136     4  0.0290      0.912 0.000 0.008  0 0.992 0.000
#> GSM802139     4  0.0290      0.912 0.000 0.008  0 0.992 0.000
#> GSM802148     4  0.0000      0.909 0.000 0.000  0 1.000 0.000
#> GSM802152     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802160     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802164     1  0.0000      0.997 1.000 0.000  0 0.000 0.000
#> GSM802172     2  0.0404      0.976 0.000 0.988  0 0.012 0.000
#> GSM802176     1  0.0290      0.995 0.992 0.000  0 0.000 0.008
#> GSM802184     2  0.0000      0.980 0.000 1.000  0 0.000 0.000
#> GSM802187     2  0.0000      0.980 0.000 1.000  0 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2 p3    p4   p5    p6
#> GSM802141     2  0.1910      0.891 0.000 0.892  0 0.108 0.00 0.000
#> GSM802144     4  0.0458      0.901 0.000 0.016  0 0.984 0.00 0.000
#> GSM802153     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802156     3  0.0000      1.000 0.000 0.000  1 0.000 0.00 0.000
#> GSM802165     4  0.0547      0.902 0.000 0.000  0 0.980 0.00 0.020
#> GSM802168     2  0.0146      0.974 0.000 0.996  0 0.000 0.00 0.004
#> GSM802177     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802180     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802189     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802192     2  0.0972      0.962 0.000 0.964  0 0.008 0.00 0.028
#> GSM802143     6  0.1075      0.968 0.048 0.000  0 0.000 0.00 0.952
#> GSM802146     6  0.1075      0.968 0.048 0.000  0 0.000 0.00 0.952
#> GSM802155     5  0.0000      0.983 0.000 0.000  0 0.000 1.00 0.000
#> GSM802158     5  0.0000      0.983 0.000 0.000  0 0.000 1.00 0.000
#> GSM802167     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802170     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802179     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802182     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802191     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802194     1  0.2527      0.776 0.832 0.000  0 0.000 0.00 0.168
#> GSM802142     4  0.3782      0.305 0.000 0.412  0 0.588 0.00 0.000
#> GSM802145     4  0.0146      0.910 0.000 0.004  0 0.996 0.00 0.000
#> GSM802154     3  0.0000      1.000 0.000 0.000  1 0.000 0.00 0.000
#> GSM802157     3  0.0000      1.000 0.000 0.000  1 0.000 0.00 0.000
#> GSM802166     1  0.0458      0.931 0.984 0.000  0 0.000 0.00 0.016
#> GSM802169     2  0.0935      0.963 0.000 0.964  0 0.004 0.00 0.032
#> GSM802178     2  0.0632      0.968 0.000 0.976  0 0.000 0.00 0.024
#> GSM802181     2  0.0146      0.974 0.000 0.996  0 0.000 0.00 0.004
#> GSM802190     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802193     2  0.1219      0.956 0.000 0.948  0 0.004 0.00 0.048
#> GSM802135     4  0.0000      0.912 0.000 0.000  0 1.000 0.00 0.000
#> GSM802138     4  0.0000      0.912 0.000 0.000  0 1.000 0.00 0.000
#> GSM802147     2  0.0692      0.967 0.000 0.976  0 0.004 0.00 0.020
#> GSM802150     2  0.1285      0.941 0.000 0.944  0 0.052 0.00 0.004
#> GSM802159     3  0.0000      1.000 0.000 0.000  1 0.000 0.00 0.000
#> GSM802162     3  0.0000      1.000 0.000 0.000  1 0.000 0.00 0.000
#> GSM802171     2  0.2605      0.866 0.000 0.864  0 0.108 0.00 0.028
#> GSM802174     2  0.0146      0.974 0.000 0.996  0 0.000 0.00 0.004
#> GSM802183     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802186     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802137     6  0.1075      0.968 0.048 0.000  0 0.000 0.00 0.952
#> GSM802140     6  0.1075      0.968 0.048 0.000  0 0.000 0.00 0.952
#> GSM802149     6  0.1267      0.960 0.060 0.000  0 0.000 0.00 0.940
#> GSM802151     5  0.0000      0.983 0.000 0.000  0 0.000 1.00 0.000
#> GSM802161     5  0.0937      0.949 0.040 0.000  0 0.000 0.96 0.000
#> GSM802163     3  0.0000      1.000 0.000 0.000  1 0.000 0.00 0.000
#> GSM802173     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802175     2  0.1753      0.911 0.000 0.912  0 0.084 0.00 0.004
#> GSM802185     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802188     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802136     4  0.0000      0.912 0.000 0.000  0 1.000 0.00 0.000
#> GSM802139     4  0.0000      0.912 0.000 0.000  0 1.000 0.00 0.000
#> GSM802148     4  0.0547      0.903 0.000 0.000  0 0.980 0.00 0.020
#> GSM802152     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 0.000
#> GSM802160     1  0.3774      0.298 0.592 0.000  0 0.000 0.00 0.408
#> GSM802164     1  0.0000      0.942 1.000 0.000  0 0.000 0.00 0.000
#> GSM802172     2  0.0777      0.967 0.000 0.972  0 0.004 0.00 0.024
#> GSM802176     6  0.2454      0.850 0.160 0.000  0 0.000 0.00 0.840
#> GSM802184     2  0.0146      0.974 0.000 0.996  0 0.000 0.00 0.004
#> GSM802187     2  0.0000      0.974 0.000 1.000  0 0.000 0.00 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) protocol(p)  time(p) individual(p) k
#> CV:pam 60            1.000    4.43e-09 0.000103         1.000 2
#> CV:pam 60            1.000    7.22e-08 0.000167         0.575 3
#> CV:pam 59            0.913    8.80e-07 0.000409         0.131 4
#> CV:pam 59            0.971    3.94e-06 0.001151         0.174 5
#> CV:pam 58            0.845    1.25e-05 0.003659         0.115 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 22263 rows and 60 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 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 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.4728 0.528   0.528
#> 3 3 0.792           0.835       0.918         0.3073 0.864   0.743
#> 4 4 0.987           0.926       0.975         0.0667 0.905   0.770
#> 5 5 0.860           0.822       0.902         0.0544 0.973   0.922
#> 6 6 0.702           0.675       0.779         0.1016 0.852   0.573

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

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802144     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802153     3  0.3752      0.791 0.000 0.144 0.856
#> GSM802156     3  0.0747      0.893 0.000 0.016 0.984
#> GSM802165     2  0.0747      0.944 0.000 0.984 0.016
#> GSM802168     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802177     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802180     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802189     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802192     2  0.0424      0.950 0.000 0.992 0.008
#> GSM802143     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802146     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802155     1  0.6079      0.607 0.612 0.000 0.388
#> GSM802158     1  0.6079      0.607 0.612 0.000 0.388
#> GSM802167     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802194     1  0.0237      0.823 0.996 0.000 0.004
#> GSM802142     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802145     2  0.4654      0.688 0.000 0.792 0.208
#> GSM802154     3  0.0747      0.893 0.000 0.016 0.984
#> GSM802157     3  0.0747      0.893 0.000 0.016 0.984
#> GSM802166     1  0.5621      0.676 0.692 0.000 0.308
#> GSM802169     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802178     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802181     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802190     2  0.0592      0.945 0.000 0.988 0.012
#> GSM802193     2  0.4702      0.681 0.000 0.788 0.212
#> GSM802135     2  0.0424      0.950 0.000 0.992 0.008
#> GSM802138     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802147     2  0.6079      0.289 0.000 0.612 0.388
#> GSM802150     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802159     3  0.1031      0.892 0.000 0.024 0.976
#> GSM802162     3  0.0747      0.893 0.000 0.016 0.984
#> GSM802171     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802174     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802183     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802186     2  0.1031      0.937 0.000 0.976 0.024
#> GSM802137     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802140     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802149     1  0.6045      0.617 0.620 0.000 0.380
#> GSM802151     1  0.6045      0.617 0.620 0.000 0.380
#> GSM802161     1  0.6045      0.617 0.620 0.000 0.380
#> GSM802163     3  0.1031      0.892 0.000 0.024 0.976
#> GSM802173     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802175     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802185     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802188     1  0.5363      0.696 0.724 0.000 0.276
#> GSM802136     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802139     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802148     2  0.4750      0.673 0.000 0.784 0.216
#> GSM802152     3  0.6095      0.388 0.000 0.392 0.608
#> GSM802160     1  0.5621      0.676 0.692 0.000 0.308
#> GSM802164     1  0.6045      0.617 0.620 0.000 0.380
#> GSM802172     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802176     1  0.0000      0.824 1.000 0.000 0.000
#> GSM802184     2  0.0000      0.955 0.000 1.000 0.000
#> GSM802187     2  0.0000      0.955 0.000 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802144     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802153     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802156     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802165     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802168     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802177     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802180     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802189     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802192     2  0.1022     0.9476 0.000 0.968 0.032 0.000
#> GSM802143     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802155     4  0.0000     0.8699 0.000 0.000 0.000 1.000
#> GSM802158     4  0.0000     0.8699 0.000 0.000 0.000 1.000
#> GSM802167     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802142     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802145     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802154     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802157     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802166     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802169     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802178     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802181     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802190     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802193     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802135     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802138     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802147     3  0.4992     0.0630 0.000 0.476 0.524 0.000
#> GSM802150     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802159     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802162     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802171     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802174     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802183     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802186     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802137     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802149     4  0.4040     0.7380 0.248 0.000 0.000 0.752
#> GSM802151     4  0.0188     0.8717 0.004 0.000 0.000 0.996
#> GSM802161     4  0.0188     0.8717 0.004 0.000 0.000 0.996
#> GSM802163     3  0.0000     0.8839 0.000 0.000 1.000 0.000
#> GSM802173     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802185     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802136     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802139     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802148     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802152     2  0.5000    -0.0768 0.000 0.504 0.496 0.000
#> GSM802160     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802164     4  0.4008     0.7431 0.244 0.000 0.000 0.756
#> GSM802172     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802176     1  0.0000     1.0000 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0000     0.9804 0.000 1.000 0.000 0.000
#> GSM802187     2  0.0000     0.9804 0.000 1.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.0703      0.916 0.000 0.976 0.000 0.024 0.000
#> GSM802144     2  0.1043      0.922 0.000 0.960 0.000 0.040 0.000
#> GSM802153     3  0.3399      0.628 0.000 0.020 0.812 0.168 0.000
#> GSM802156     3  0.3336      0.633 0.000 0.000 0.772 0.228 0.000
#> GSM802165     2  0.3274      0.734 0.000 0.780 0.000 0.220 0.000
#> GSM802168     2  0.0898      0.922 0.000 0.972 0.000 0.020 0.008
#> GSM802177     2  0.0992      0.921 0.000 0.968 0.000 0.024 0.008
#> GSM802180     2  0.0404      0.921 0.000 0.988 0.000 0.012 0.000
#> GSM802189     2  0.0609      0.917 0.000 0.980 0.000 0.020 0.000
#> GSM802192     2  0.2516      0.851 0.000 0.860 0.000 0.140 0.000
#> GSM802143     1  0.0609      0.975 0.980 0.000 0.000 0.020 0.000
#> GSM802146     1  0.0162      0.979 0.996 0.000 0.000 0.004 0.000
#> GSM802155     5  0.1106      0.777 0.000 0.000 0.012 0.024 0.964
#> GSM802158     5  0.1484      0.776 0.000 0.000 0.008 0.048 0.944
#> GSM802167     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0609      0.975 0.980 0.000 0.000 0.020 0.000
#> GSM802191     1  0.0880      0.969 0.968 0.000 0.000 0.032 0.000
#> GSM802194     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.1544      0.900 0.000 0.932 0.000 0.068 0.000
#> GSM802145     2  0.1732      0.905 0.000 0.920 0.000 0.080 0.000
#> GSM802154     3  0.0510      0.697 0.000 0.000 0.984 0.016 0.000
#> GSM802157     3  0.3395      0.628 0.000 0.000 0.764 0.236 0.000
#> GSM802166     1  0.1836      0.934 0.932 0.000 0.000 0.032 0.036
#> GSM802169     2  0.1830      0.909 0.000 0.924 0.000 0.068 0.008
#> GSM802178     2  0.1484      0.916 0.000 0.944 0.000 0.048 0.008
#> GSM802181     2  0.0992      0.921 0.000 0.968 0.000 0.024 0.008
#> GSM802190     2  0.1043      0.920 0.000 0.960 0.000 0.040 0.000
#> GSM802193     2  0.3661      0.660 0.000 0.724 0.000 0.276 0.000
#> GSM802135     2  0.2304      0.890 0.000 0.892 0.000 0.100 0.008
#> GSM802138     2  0.1197      0.921 0.000 0.952 0.000 0.048 0.000
#> GSM802147     4  0.6146      0.128 0.000 0.400 0.132 0.468 0.000
#> GSM802150     2  0.0703      0.916 0.000 0.976 0.000 0.024 0.000
#> GSM802159     4  0.4161     -0.439 0.000 0.000 0.392 0.608 0.000
#> GSM802162     3  0.3143      0.659 0.000 0.000 0.796 0.204 0.000
#> GSM802171     2  0.1697      0.910 0.000 0.932 0.000 0.060 0.008
#> GSM802174     2  0.0992      0.921 0.000 0.968 0.000 0.024 0.008
#> GSM802183     2  0.1357      0.903 0.000 0.948 0.004 0.048 0.000
#> GSM802186     2  0.1768      0.888 0.000 0.924 0.004 0.072 0.000
#> GSM802137     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802149     5  0.4360      0.637 0.284 0.000 0.000 0.024 0.692
#> GSM802151     5  0.0290      0.780 0.000 0.000 0.008 0.000 0.992
#> GSM802161     5  0.3934      0.660 0.000 0.000 0.008 0.276 0.716
#> GSM802163     3  0.0000      0.700 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000      0.979 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0609      0.917 0.000 0.980 0.000 0.020 0.000
#> GSM802185     1  0.0703      0.974 0.976 0.000 0.000 0.024 0.000
#> GSM802188     1  0.1670      0.945 0.936 0.000 0.000 0.012 0.052
#> GSM802136     2  0.1121      0.921 0.000 0.956 0.000 0.044 0.000
#> GSM802139     2  0.0880      0.921 0.000 0.968 0.000 0.032 0.000
#> GSM802148     2  0.3661      0.660 0.000 0.724 0.000 0.276 0.000
#> GSM802152     3  0.5112      0.153 0.000 0.256 0.664 0.080 0.000
#> GSM802160     1  0.1836      0.934 0.932 0.000 0.000 0.032 0.036
#> GSM802164     5  0.4509      0.675 0.236 0.000 0.000 0.048 0.716
#> GSM802172     2  0.1557      0.913 0.000 0.940 0.000 0.052 0.008
#> GSM802176     1  0.0609      0.975 0.980 0.000 0.000 0.020 0.000
#> GSM802184     2  0.1043      0.916 0.000 0.960 0.000 0.040 0.000
#> GSM802187     2  0.2046      0.880 0.000 0.916 0.016 0.068 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
#> GSM802141     2  0.0405     0.7525 0.000 0.988 0.000 0.004 0.000 0.008
#> GSM802144     2  0.2697     0.6215 0.000 0.812 0.000 0.000 0.000 0.188
#> GSM802153     3  0.4651     0.0385 0.000 0.476 0.484 0.040 0.000 0.000
#> GSM802156     3  0.1471     0.7206 0.000 0.000 0.932 0.064 0.004 0.000
#> GSM802165     6  0.5276     0.6739 0.000 0.208 0.000 0.188 0.000 0.604
#> GSM802168     6  0.3847     0.6764 0.000 0.456 0.000 0.000 0.000 0.544
#> GSM802177     6  0.3869     0.5829 0.000 0.500 0.000 0.000 0.000 0.500
#> GSM802180     2  0.0713     0.7493 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM802189     2  0.0713     0.7509 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM802192     6  0.5265     0.6899 0.000 0.220 0.000 0.176 0.000 0.604
#> GSM802143     1  0.4456     0.7968 0.708 0.000 0.000 0.112 0.000 0.180
#> GSM802146     1  0.2848     0.8167 0.816 0.000 0.000 0.008 0.000 0.176
#> GSM802155     5  0.1700     0.8631 0.000 0.000 0.000 0.080 0.916 0.004
#> GSM802158     5  0.0508     0.9043 0.000 0.000 0.000 0.012 0.984 0.004
#> GSM802167     1  0.1444     0.7787 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM802170     1  0.0547     0.7999 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM802179     1  0.0146     0.8044 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM802182     1  0.4566     0.7916 0.696 0.000 0.000 0.120 0.000 0.184
#> GSM802191     1  0.4516     0.7982 0.700 0.000 0.000 0.112 0.000 0.188
#> GSM802194     1  0.1444     0.7787 0.928 0.000 0.000 0.000 0.000 0.072
#> GSM802142     2  0.0363     0.7497 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM802145     2  0.3101     0.5765 0.000 0.756 0.000 0.000 0.000 0.244
#> GSM802154     3  0.0000     0.7529 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802157     3  0.1285     0.7270 0.000 0.000 0.944 0.052 0.004 0.000
#> GSM802166     1  0.3315     0.7296 0.820 0.000 0.000 0.104 0.000 0.076
#> GSM802169     6  0.3747     0.7528 0.000 0.396 0.000 0.000 0.000 0.604
#> GSM802178     6  0.3737     0.7586 0.000 0.392 0.000 0.000 0.000 0.608
#> GSM802181     2  0.3847    -0.5284 0.000 0.544 0.000 0.000 0.000 0.456
#> GSM802190     2  0.3245     0.4723 0.000 0.764 0.008 0.000 0.000 0.228
#> GSM802193     6  0.4626     0.6169 0.000 0.172 0.000 0.136 0.000 0.692
#> GSM802135     6  0.4420     0.7665 0.000 0.360 0.000 0.036 0.000 0.604
#> GSM802138     2  0.2854     0.6069 0.000 0.792 0.000 0.000 0.000 0.208
#> GSM802147     4  0.4909     0.7055 0.000 0.088 0.128 0.724 0.000 0.060
#> GSM802150     2  0.0790     0.7493 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM802159     4  0.3421     0.6647 0.000 0.000 0.256 0.736 0.000 0.008
#> GSM802162     3  0.0146     0.7537 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM802171     6  0.3684     0.7641 0.000 0.372 0.000 0.000 0.000 0.628
#> GSM802174     2  0.3950    -0.4805 0.000 0.564 0.004 0.000 0.000 0.432
#> GSM802183     2  0.0000     0.7541 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802186     2  0.0146     0.7532 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM802137     1  0.2442     0.8188 0.852 0.000 0.000 0.004 0.000 0.144
#> GSM802140     1  0.2703     0.8174 0.824 0.000 0.000 0.004 0.000 0.172
#> GSM802149     1  0.6280     0.7113 0.580 0.000 0.000 0.104 0.120 0.196
#> GSM802151     5  0.1701     0.8930 0.000 0.000 0.000 0.072 0.920 0.008
#> GSM802161     5  0.1926     0.8987 0.000 0.000 0.000 0.020 0.912 0.068
#> GSM802163     3  0.0146     0.7539 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM802173     1  0.1075     0.7896 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM802175     2  0.0000     0.7541 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802185     1  0.4121     0.8069 0.748 0.000 0.000 0.116 0.000 0.136
#> GSM802188     1  0.3732     0.7755 0.776 0.000 0.000 0.180 0.012 0.032
#> GSM802136     2  0.2912     0.5983 0.000 0.784 0.000 0.000 0.000 0.216
#> GSM802139     2  0.2793     0.6123 0.000 0.800 0.000 0.000 0.000 0.200
#> GSM802148     6  0.4626     0.6169 0.000 0.172 0.000 0.136 0.000 0.692
#> GSM802152     2  0.4186     0.2037 0.000 0.656 0.312 0.032 0.000 0.000
#> GSM802160     1  0.3261     0.7320 0.824 0.000 0.000 0.104 0.000 0.072
#> GSM802164     1  0.6839     0.6394 0.500 0.000 0.000 0.188 0.108 0.204
#> GSM802172     6  0.3737     0.7586 0.000 0.392 0.000 0.000 0.000 0.608
#> GSM802176     1  0.4486     0.7951 0.704 0.000 0.000 0.112 0.000 0.184
#> GSM802184     2  0.0547     0.7446 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM802187     2  0.0260     0.7530 0.000 0.992 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-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) protocol(p)  time(p) individual(p) k
#> CV:mclust 60            1.000    4.43e-09 0.000103         1.000 2
#> CV:mclust 58            0.947    1.33e-07 0.000171         0.426 3
#> CV:mclust 58            0.795    1.31e-06 0.000601         0.383 4
#> CV:mclust 57            0.691    2.16e-06 0.000877         0.261 5
#> CV:mclust 55            0.608    2.69e-05 0.001144         0.177 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk CV-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.764           0.824       0.893         0.3414 0.842   0.700
#> 4 4 0.758           0.659       0.838         0.1330 0.803   0.525
#> 5 5 0.786           0.817       0.885         0.0647 0.915   0.705
#> 6 6 0.734           0.674       0.823         0.0368 0.919   0.698

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.4235      0.800 0.000 0.824 0.176
#> GSM802144     2  0.0424      0.786 0.000 0.992 0.008
#> GSM802153     3  0.0592      0.876 0.000 0.012 0.988
#> GSM802156     3  0.1031      0.870 0.000 0.024 0.976
#> GSM802165     2  0.3412      0.808 0.000 0.876 0.124
#> GSM802168     2  0.2066      0.802 0.000 0.940 0.060
#> GSM802177     2  0.0424      0.786 0.000 0.992 0.008
#> GSM802180     2  0.5327      0.754 0.000 0.728 0.272
#> GSM802189     2  0.6308      0.345 0.000 0.508 0.492
#> GSM802192     2  0.5431      0.734 0.000 0.716 0.284
#> GSM802143     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802146     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802155     1  0.0592      0.992 0.988 0.000 0.012
#> GSM802158     1  0.0592      0.992 0.988 0.000 0.012
#> GSM802167     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802194     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802142     2  0.5465      0.740 0.000 0.712 0.288
#> GSM802145     2  0.0000      0.781 0.000 1.000 0.000
#> GSM802154     3  0.0592      0.876 0.000 0.012 0.988
#> GSM802157     3  0.0592      0.876 0.000 0.012 0.988
#> GSM802166     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802169     2  0.1964      0.804 0.000 0.944 0.056
#> GSM802178     2  0.0000      0.781 0.000 1.000 0.000
#> GSM802181     2  0.2356      0.805 0.000 0.928 0.072
#> GSM802190     3  0.6307     -0.354 0.000 0.488 0.512
#> GSM802193     2  0.0000      0.781 0.000 1.000 0.000
#> GSM802135     2  0.1289      0.796 0.000 0.968 0.032
#> GSM802138     2  0.4702      0.783 0.000 0.788 0.212
#> GSM802147     2  0.5810      0.674 0.000 0.664 0.336
#> GSM802150     2  0.5859      0.670 0.000 0.656 0.344
#> GSM802159     3  0.1964      0.849 0.000 0.056 0.944
#> GSM802162     3  0.0592      0.876 0.000 0.012 0.988
#> GSM802171     2  0.4121      0.800 0.000 0.832 0.168
#> GSM802174     2  0.5882      0.669 0.000 0.652 0.348
#> GSM802183     2  0.6302      0.390 0.000 0.520 0.480
#> GSM802186     2  0.6291      0.423 0.000 0.532 0.468
#> GSM802137     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802140     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802149     1  0.0237      0.996 0.996 0.000 0.004
#> GSM802151     1  0.0592      0.992 0.988 0.000 0.012
#> GSM802161     1  0.0592      0.992 0.988 0.000 0.012
#> GSM802163     3  0.0592      0.876 0.000 0.012 0.988
#> GSM802173     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802175     2  0.5327      0.754 0.000 0.728 0.272
#> GSM802185     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802188     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802136     2  0.5138      0.760 0.000 0.748 0.252
#> GSM802139     2  0.3038      0.810 0.000 0.896 0.104
#> GSM802148     2  0.0000      0.781 0.000 1.000 0.000
#> GSM802152     3  0.1163      0.867 0.000 0.028 0.972
#> GSM802160     1  0.0237      0.994 0.996 0.004 0.000
#> GSM802164     1  0.0592      0.992 0.988 0.000 0.012
#> GSM802172     2  0.0000      0.781 0.000 1.000 0.000
#> GSM802176     1  0.0000      0.997 1.000 0.000 0.000
#> GSM802184     2  0.3412      0.808 0.000 0.876 0.124
#> GSM802187     3  0.5178      0.493 0.000 0.256 0.744

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.4713    -0.0959 0.000 0.640 0.360 0.000
#> GSM802144     2  0.0188     0.6026 0.000 0.996 0.000 0.004
#> GSM802153     3  0.0592     0.5531 0.000 0.016 0.984 0.000
#> GSM802156     3  0.4522     0.1003 0.000 0.000 0.680 0.320
#> GSM802165     4  0.0336     0.7791 0.000 0.008 0.000 0.992
#> GSM802168     2  0.4459     0.5896 0.000 0.780 0.032 0.188
#> GSM802177     2  0.3895     0.5800 0.000 0.804 0.012 0.184
#> GSM802180     2  0.7078    -0.2444 0.000 0.456 0.420 0.124
#> GSM802189     3  0.6089     0.5131 0.000 0.328 0.608 0.064
#> GSM802192     4  0.0524     0.7793 0.000 0.008 0.004 0.988
#> GSM802143     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802155     1  0.1114     0.9814 0.972 0.004 0.016 0.008
#> GSM802158     1  0.0712     0.9902 0.984 0.004 0.004 0.008
#> GSM802167     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0188     0.9949 0.996 0.000 0.000 0.004
#> GSM802191     1  0.0188     0.9949 0.996 0.000 0.000 0.004
#> GSM802194     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802142     3  0.4996     0.4256 0.000 0.484 0.516 0.000
#> GSM802145     2  0.0376     0.6016 0.000 0.992 0.004 0.004
#> GSM802154     3  0.0188     0.5489 0.000 0.000 0.996 0.004
#> GSM802157     3  0.1716     0.5062 0.000 0.000 0.936 0.064
#> GSM802166     1  0.0188     0.9948 0.996 0.000 0.000 0.004
#> GSM802169     2  0.4817     0.3591 0.000 0.612 0.000 0.388
#> GSM802178     4  0.4996     0.1137 0.000 0.484 0.000 0.516
#> GSM802181     2  0.6236     0.5171 0.000 0.668 0.152 0.180
#> GSM802190     3  0.6801     0.4486 0.000 0.308 0.568 0.124
#> GSM802193     4  0.2216     0.7356 0.000 0.092 0.000 0.908
#> GSM802135     4  0.1716     0.7455 0.000 0.064 0.000 0.936
#> GSM802138     2  0.4661     0.3458 0.000 0.652 0.000 0.348
#> GSM802147     4  0.0524     0.7793 0.000 0.008 0.004 0.988
#> GSM802150     3  0.4998     0.4179 0.000 0.488 0.512 0.000
#> GSM802159     4  0.2704     0.6807 0.000 0.000 0.124 0.876
#> GSM802162     3  0.0188     0.5489 0.000 0.000 0.996 0.004
#> GSM802171     4  0.4222     0.3937 0.000 0.272 0.000 0.728
#> GSM802174     3  0.7414     0.2210 0.000 0.368 0.460 0.172
#> GSM802183     3  0.4905     0.5432 0.000 0.364 0.632 0.004
#> GSM802186     3  0.4978     0.5335 0.000 0.384 0.612 0.004
#> GSM802137     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0188     0.9948 0.996 0.004 0.000 0.000
#> GSM802151     1  0.0712     0.9902 0.984 0.004 0.004 0.008
#> GSM802161     1  0.0712     0.9902 0.984 0.004 0.004 0.008
#> GSM802163     3  0.0188     0.5489 0.000 0.000 0.996 0.004
#> GSM802173     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802175     3  0.6055     0.4300 0.000 0.436 0.520 0.044
#> GSM802185     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0336     0.9936 0.992 0.000 0.000 0.008
#> GSM802136     2  0.5294     0.0445 0.000 0.508 0.008 0.484
#> GSM802139     2  0.0927     0.6015 0.000 0.976 0.016 0.008
#> GSM802148     4  0.0469     0.7792 0.000 0.012 0.000 0.988
#> GSM802152     3  0.3172     0.5708 0.000 0.160 0.840 0.000
#> GSM802160     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802164     1  0.0712     0.9902 0.984 0.004 0.004 0.008
#> GSM802172     4  0.4907     0.2608 0.000 0.420 0.000 0.580
#> GSM802176     1  0.0000     0.9957 1.000 0.000 0.000 0.000
#> GSM802184     3  0.6755     0.2807 0.000 0.448 0.460 0.092
#> GSM802187     3  0.4804     0.5331 0.000 0.384 0.616 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
#> GSM802141     5  0.6367      0.467 0.000 0.248 0.232 0.000 0.520
#> GSM802144     5  0.2648      0.820 0.000 0.152 0.000 0.000 0.848
#> GSM802153     3  0.0162      0.724 0.000 0.004 0.996 0.000 0.000
#> GSM802156     3  0.4074      0.283 0.000 0.000 0.636 0.364 0.000
#> GSM802165     4  0.0290      0.907 0.000 0.008 0.000 0.992 0.000
#> GSM802168     2  0.1661      0.876 0.000 0.940 0.024 0.000 0.036
#> GSM802177     2  0.0000      0.888 0.000 1.000 0.000 0.000 0.000
#> GSM802180     2  0.2625      0.831 0.000 0.876 0.108 0.000 0.016
#> GSM802189     3  0.4620      0.480 0.000 0.392 0.592 0.000 0.016
#> GSM802192     4  0.1197      0.898 0.000 0.048 0.000 0.952 0.000
#> GSM802143     1  0.1608      0.948 0.928 0.000 0.000 0.000 0.072
#> GSM802146     1  0.1544      0.949 0.932 0.000 0.000 0.000 0.068
#> GSM802155     1  0.2673      0.927 0.892 0.000 0.028 0.008 0.072
#> GSM802158     1  0.1894      0.944 0.920 0.000 0.000 0.008 0.072
#> GSM802167     1  0.0794      0.957 0.972 0.000 0.000 0.000 0.028
#> GSM802170     1  0.0000      0.959 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0162      0.959 0.996 0.000 0.000 0.000 0.004
#> GSM802182     1  0.1043      0.954 0.960 0.000 0.000 0.000 0.040
#> GSM802191     1  0.0794      0.956 0.972 0.000 0.000 0.000 0.028
#> GSM802194     1  0.1270      0.951 0.948 0.000 0.000 0.000 0.052
#> GSM802142     5  0.5159      0.716 0.000 0.124 0.188 0.000 0.688
#> GSM802145     5  0.2127      0.808 0.000 0.108 0.000 0.000 0.892
#> GSM802154     3  0.0000      0.724 0.000 0.000 1.000 0.000 0.000
#> GSM802157     3  0.0609      0.712 0.000 0.000 0.980 0.020 0.000
#> GSM802166     1  0.0703      0.961 0.976 0.000 0.000 0.000 0.024
#> GSM802169     2  0.0703      0.885 0.000 0.976 0.000 0.024 0.000
#> GSM802178     2  0.1502      0.864 0.000 0.940 0.000 0.056 0.004
#> GSM802181     2  0.0290      0.889 0.000 0.992 0.008 0.000 0.000
#> GSM802190     2  0.1121      0.884 0.000 0.956 0.044 0.000 0.000
#> GSM802193     2  0.2806      0.751 0.000 0.844 0.000 0.152 0.004
#> GSM802135     4  0.0798      0.902 0.000 0.008 0.000 0.976 0.016
#> GSM802138     5  0.4946      0.757 0.000 0.120 0.000 0.168 0.712
#> GSM802147     4  0.0880      0.907 0.000 0.032 0.000 0.968 0.000
#> GSM802150     3  0.6261      0.403 0.000 0.264 0.536 0.000 0.200
#> GSM802159     4  0.0451      0.906 0.000 0.008 0.004 0.988 0.000
#> GSM802162     3  0.0000      0.724 0.000 0.000 1.000 0.000 0.000
#> GSM802171     4  0.3957      0.538 0.000 0.280 0.000 0.712 0.008
#> GSM802174     2  0.3044      0.792 0.000 0.840 0.148 0.004 0.008
#> GSM802183     3  0.4152      0.633 0.000 0.296 0.692 0.000 0.012
#> GSM802186     3  0.4184      0.643 0.000 0.284 0.700 0.000 0.016
#> GSM802137     1  0.1544      0.949 0.932 0.000 0.000 0.000 0.068
#> GSM802140     1  0.1952      0.942 0.912 0.000 0.000 0.004 0.084
#> GSM802149     1  0.1638      0.957 0.932 0.000 0.000 0.004 0.064
#> GSM802151     1  0.1894      0.944 0.920 0.000 0.000 0.008 0.072
#> GSM802161     1  0.1894      0.944 0.920 0.000 0.000 0.008 0.072
#> GSM802163     3  0.0000      0.724 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0290      0.959 0.992 0.000 0.000 0.000 0.008
#> GSM802175     3  0.4894      0.319 0.000 0.456 0.520 0.000 0.024
#> GSM802185     1  0.1197      0.951 0.952 0.000 0.000 0.000 0.048
#> GSM802188     1  0.0865      0.959 0.972 0.000 0.000 0.004 0.024
#> GSM802136     5  0.4793      0.697 0.000 0.076 0.000 0.216 0.708
#> GSM802139     5  0.2648      0.819 0.000 0.152 0.000 0.000 0.848
#> GSM802148     4  0.1430      0.895 0.000 0.052 0.000 0.944 0.004
#> GSM802152     3  0.2970      0.707 0.000 0.168 0.828 0.000 0.004
#> GSM802160     1  0.1671      0.942 0.924 0.000 0.000 0.000 0.076
#> GSM802164     1  0.1571      0.945 0.936 0.000 0.000 0.004 0.060
#> GSM802172     2  0.1282      0.873 0.000 0.952 0.000 0.044 0.004
#> GSM802176     1  0.1341      0.953 0.944 0.000 0.000 0.000 0.056
#> GSM802184     2  0.3183      0.772 0.000 0.828 0.156 0.000 0.016
#> GSM802187     3  0.2362      0.719 0.000 0.076 0.900 0.000 0.024

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.4777    0.12627 0.000 0.540 0.036 0.416 0.008 0.000
#> GSM802144     4  0.1812    0.82378 0.000 0.080 0.000 0.912 0.008 0.000
#> GSM802153     3  0.1410    0.84642 0.000 0.044 0.944 0.004 0.008 0.000
#> GSM802156     3  0.2454    0.71574 0.000 0.000 0.840 0.000 0.000 0.160
#> GSM802165     6  0.0405    0.74981 0.000 0.000 0.004 0.000 0.008 0.988
#> GSM802168     2  0.1080    0.54156 0.000 0.960 0.000 0.004 0.032 0.004
#> GSM802177     2  0.2146    0.45573 0.000 0.880 0.000 0.000 0.116 0.004
#> GSM802180     2  0.1552    0.56815 0.000 0.940 0.036 0.004 0.020 0.000
#> GSM802189     2  0.4183    0.50600 0.000 0.716 0.240 0.020 0.024 0.000
#> GSM802192     6  0.4814    0.43894 0.000 0.048 0.020 0.000 0.284 0.648
#> GSM802143     1  0.2586    0.85763 0.868 0.000 0.000 0.100 0.032 0.000
#> GSM802146     1  0.1367    0.89702 0.944 0.000 0.000 0.012 0.044 0.000
#> GSM802155     1  0.3420    0.83247 0.776 0.000 0.012 0.008 0.204 0.000
#> GSM802158     1  0.3073    0.83916 0.788 0.000 0.000 0.008 0.204 0.000
#> GSM802167     1  0.0632    0.90141 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802170     1  0.0363    0.90323 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802179     1  0.0363    0.90384 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802182     1  0.1010    0.90292 0.960 0.000 0.000 0.004 0.036 0.000
#> GSM802191     1  0.0777    0.90364 0.972 0.000 0.000 0.004 0.024 0.000
#> GSM802194     1  0.2482    0.83553 0.848 0.000 0.000 0.004 0.148 0.000
#> GSM802142     4  0.3494    0.75652 0.000 0.036 0.168 0.792 0.004 0.000
#> GSM802145     4  0.0520    0.80678 0.000 0.008 0.000 0.984 0.008 0.000
#> GSM802154     3  0.0436    0.85987 0.000 0.004 0.988 0.004 0.004 0.000
#> GSM802157     3  0.1010    0.83786 0.000 0.000 0.960 0.000 0.004 0.036
#> GSM802166     1  0.1267    0.89726 0.940 0.000 0.000 0.000 0.060 0.000
#> GSM802169     5  0.4406    0.55131 0.000 0.464 0.000 0.012 0.516 0.008
#> GSM802178     2  0.4268   -0.47374 0.000 0.556 0.000 0.012 0.428 0.004
#> GSM802181     2  0.1606    0.53891 0.000 0.932 0.008 0.000 0.056 0.004
#> GSM802190     5  0.5096    0.73441 0.000 0.296 0.084 0.004 0.612 0.004
#> GSM802193     5  0.4470    0.73106 0.000 0.300 0.000 0.012 0.656 0.032
#> GSM802135     6  0.1204    0.72787 0.000 0.000 0.000 0.056 0.000 0.944
#> GSM802138     4  0.3481    0.79298 0.000 0.048 0.000 0.792 0.000 0.160
#> GSM802147     6  0.4315    0.54631 0.000 0.328 0.000 0.000 0.036 0.636
#> GSM802150     2  0.6378    0.30984 0.000 0.544 0.156 0.232 0.068 0.000
#> GSM802159     6  0.0260    0.74754 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM802162     3  0.0000    0.85823 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     2  0.5253    0.06852 0.000 0.476 0.000 0.032 0.036 0.456
#> GSM802174     2  0.2186    0.56942 0.000 0.908 0.048 0.000 0.036 0.008
#> GSM802183     2  0.4147    0.48161 0.000 0.668 0.304 0.024 0.004 0.000
#> GSM802186     2  0.4528    0.45926 0.000 0.636 0.316 0.044 0.004 0.000
#> GSM802137     1  0.1644    0.89312 0.932 0.000 0.000 0.028 0.040 0.000
#> GSM802140     1  0.2420    0.87148 0.884 0.000 0.000 0.076 0.040 0.000
#> GSM802149     1  0.2823    0.84823 0.796 0.000 0.000 0.000 0.204 0.000
#> GSM802151     1  0.3384    0.82107 0.760 0.000 0.004 0.008 0.228 0.000
#> GSM802161     1  0.3073    0.83916 0.788 0.000 0.000 0.008 0.204 0.000
#> GSM802163     3  0.0363    0.86013 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802173     1  0.0146    0.90364 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802175     2  0.3409    0.57096 0.000 0.808 0.144 0.044 0.004 0.000
#> GSM802185     1  0.1124    0.90258 0.956 0.000 0.000 0.008 0.036 0.000
#> GSM802188     1  0.2212    0.89182 0.880 0.000 0.000 0.008 0.112 0.000
#> GSM802136     4  0.2871    0.75887 0.000 0.004 0.000 0.804 0.000 0.192
#> GSM802139     4  0.2838    0.72445 0.000 0.188 0.004 0.808 0.000 0.000
#> GSM802148     6  0.4799    0.59136 0.000 0.252 0.000 0.004 0.088 0.656
#> GSM802152     3  0.5124    0.00295 0.000 0.440 0.500 0.028 0.032 0.000
#> GSM802160     1  0.2846    0.86113 0.856 0.000 0.000 0.060 0.084 0.000
#> GSM802164     1  0.3073    0.83916 0.788 0.000 0.000 0.008 0.204 0.000
#> GSM802172     2  0.3890   -0.36148 0.000 0.596 0.000 0.000 0.400 0.004
#> GSM802176     1  0.0858    0.90209 0.968 0.000 0.000 0.004 0.028 0.000
#> GSM802184     2  0.3127    0.54698 0.000 0.852 0.044 0.020 0.084 0.000
#> GSM802187     3  0.2003    0.83096 0.000 0.044 0.912 0.044 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk CV-NMF-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk CV-NMF-collect-classes

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

test_to_known_factors(res)
#>         n disease.state(p) protocol(p)  time(p) individual(p) k
#> CV:NMF 60            1.000    4.43e-09 0.000103         1.000 2
#> CV:NMF 55            0.989    5.24e-07 0.000273         0.500 3
#> CV:NMF 45            0.363    1.99e-05 0.000335         0.493 4
#> CV:NMF 55            0.338    2.48e-07 0.000280         0.183 5
#> CV:NMF 50            0.414    1.13e-05 0.000778         0.184 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.789           0.886       0.911         0.3680 0.805   0.631
#> 4 4 0.874           0.895       0.938         0.0990 0.942   0.827
#> 5 5 0.804           0.866       0.895         0.0517 0.959   0.852
#> 6 6 0.858           0.871       0.911         0.0465 0.964   0.850

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     3  0.0237      0.872  0 0.004 0.996
#> GSM802144     2  0.5098      0.924  0 0.752 0.248
#> GSM802153     3  0.4605      0.758  0 0.204 0.796
#> GSM802156     3  0.4796      0.753  0 0.220 0.780
#> GSM802165     2  0.4605      0.922  0 0.796 0.204
#> GSM802168     3  0.6260     -0.378  0 0.448 0.552
#> GSM802177     3  0.0892      0.865  0 0.020 0.980
#> GSM802180     3  0.0892      0.865  0 0.020 0.980
#> GSM802189     3  0.0892      0.865  0 0.020 0.980
#> GSM802192     2  0.4605      0.922  0 0.796 0.204
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     3  0.0237      0.872  0 0.004 0.996
#> GSM802145     2  0.5098      0.924  0 0.752 0.248
#> GSM802154     3  0.4605      0.758  0 0.204 0.796
#> GSM802157     3  0.4796      0.753  0 0.220 0.780
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     3  0.1163      0.859  0 0.028 0.972
#> GSM802178     2  0.6095      0.742  0 0.608 0.392
#> GSM802181     3  0.0892      0.865  0 0.020 0.980
#> GSM802190     3  0.1163      0.859  0 0.028 0.972
#> GSM802193     2  0.4605      0.922  0 0.796 0.204
#> GSM802135     2  0.5058      0.927  0 0.756 0.244
#> GSM802138     2  0.5058      0.927  0 0.756 0.244
#> GSM802147     2  0.4605      0.922  0 0.796 0.204
#> GSM802150     3  0.0237      0.871  0 0.004 0.996
#> GSM802159     2  0.4504      0.917  0 0.804 0.196
#> GSM802162     3  0.4605      0.758  0 0.204 0.796
#> GSM802171     2  0.6079      0.749  0 0.612 0.388
#> GSM802174     3  0.4002      0.664  0 0.160 0.840
#> GSM802183     3  0.0000      0.871  0 0.000 1.000
#> GSM802186     3  0.0000      0.871  0 0.000 1.000
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     3  0.4605      0.758  0 0.204 0.796
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     3  0.0424      0.870  0 0.008 0.992
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.5058      0.927  0 0.756 0.244
#> GSM802139     2  0.5058      0.927  0 0.756 0.244
#> GSM802148     2  0.4605      0.922  0 0.796 0.204
#> GSM802152     3  0.0000      0.871  0 0.000 1.000
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.6079      0.749  0 0.612 0.388
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     3  0.0000      0.871  0 0.000 1.000
#> GSM802187     3  0.0237      0.872  0 0.004 0.996

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM802141     2  0.0188      0.935  0 0.996 0.004 0.000
#> GSM802144     4  0.4295      0.813  0 0.240 0.008 0.752
#> GSM802153     3  0.0817      0.985  0 0.024 0.976 0.000
#> GSM802156     3  0.0188      0.983  0 0.000 0.996 0.004
#> GSM802165     4  0.1637      0.791  0 0.060 0.000 0.940
#> GSM802168     2  0.4948     -0.199  0 0.560 0.000 0.440
#> GSM802177     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM802180     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM802189     2  0.0469      0.933  0 0.988 0.000 0.012
#> GSM802192     4  0.1637      0.791  0 0.060 0.000 0.940
#> GSM802143     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802142     2  0.0188      0.935  0 0.996 0.004 0.000
#> GSM802145     4  0.4295      0.813  0 0.240 0.008 0.752
#> GSM802154     3  0.0817      0.985  0 0.024 0.976 0.000
#> GSM802157     3  0.0188      0.983  0 0.000 0.996 0.004
#> GSM802166     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802169     2  0.0817      0.927  0 0.976 0.000 0.024
#> GSM802178     4  0.4817      0.615  0 0.388 0.000 0.612
#> GSM802181     2  0.0592      0.932  0 0.984 0.000 0.016
#> GSM802190     2  0.0817      0.927  0 0.976 0.000 0.024
#> GSM802193     4  0.0000      0.753  0 0.000 0.000 1.000
#> GSM802135     4  0.4262      0.815  0 0.236 0.008 0.756
#> GSM802138     4  0.4262      0.815  0 0.236 0.008 0.756
#> GSM802147     4  0.0000      0.753  0 0.000 0.000 1.000
#> GSM802150     2  0.0524      0.935  0 0.988 0.008 0.004
#> GSM802159     4  0.0707      0.747  0 0.000 0.020 0.980
#> GSM802162     3  0.0469      0.989  0 0.012 0.988 0.000
#> GSM802171     4  0.4790      0.626  0 0.380 0.000 0.620
#> GSM802174     2  0.4188      0.646  0 0.752 0.004 0.244
#> GSM802183     2  0.0336      0.934  0 0.992 0.008 0.000
#> GSM802186     2  0.0336      0.934  0 0.992 0.008 0.000
#> GSM802137     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802163     3  0.0469      0.989  0 0.012 0.988 0.000
#> GSM802173     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802175     2  0.0376      0.934  0 0.992 0.004 0.004
#> GSM802185     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802136     4  0.4262      0.815  0 0.236 0.008 0.756
#> GSM802139     4  0.4262      0.815  0 0.236 0.008 0.756
#> GSM802148     4  0.0000      0.753  0 0.000 0.000 1.000
#> GSM802152     2  0.0336      0.934  0 0.992 0.008 0.000
#> GSM802160     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802172     4  0.4790      0.626  0 0.380 0.000 0.620
#> GSM802176     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802184     2  0.0336      0.934  0 0.992 0.008 0.000
#> GSM802187     2  0.0188      0.935  0 0.996 0.004 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.0162      0.929 0.000 0.996 0.000 0.000 0.004
#> GSM802144     4  0.3424      0.774 0.000 0.240 0.000 0.760 0.000
#> GSM802153     3  0.0566      0.981 0.000 0.012 0.984 0.000 0.004
#> GSM802156     3  0.0807      0.980 0.000 0.000 0.976 0.012 0.012
#> GSM802165     4  0.1809      0.744 0.000 0.060 0.000 0.928 0.012
#> GSM802168     2  0.4403     -0.188 0.000 0.560 0.000 0.436 0.004
#> GSM802177     2  0.0404      0.926 0.000 0.988 0.000 0.012 0.000
#> GSM802180     2  0.0404      0.926 0.000 0.988 0.000 0.012 0.000
#> GSM802189     2  0.0451      0.927 0.000 0.988 0.000 0.008 0.004
#> GSM802192     4  0.1809      0.744 0.000 0.060 0.000 0.928 0.012
#> GSM802143     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802155     5  0.3816      0.998 0.304 0.000 0.000 0.000 0.696
#> GSM802158     5  0.3816      0.998 0.304 0.000 0.000 0.000 0.696
#> GSM802167     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.0162      0.929 0.000 0.996 0.000 0.000 0.004
#> GSM802145     4  0.3424      0.774 0.000 0.240 0.000 0.760 0.000
#> GSM802154     3  0.0566      0.981 0.000 0.012 0.984 0.000 0.004
#> GSM802157     3  0.0807      0.980 0.000 0.000 0.976 0.012 0.012
#> GSM802166     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802169     2  0.0609      0.921 0.000 0.980 0.000 0.020 0.000
#> GSM802178     4  0.4610      0.588 0.000 0.388 0.000 0.596 0.016
#> GSM802181     2  0.0404      0.926 0.000 0.988 0.000 0.012 0.000
#> GSM802190     2  0.0609      0.921 0.000 0.980 0.000 0.020 0.000
#> GSM802193     4  0.3586      0.582 0.000 0.000 0.000 0.736 0.264
#> GSM802135     4  0.3395      0.777 0.000 0.236 0.000 0.764 0.000
#> GSM802138     4  0.3395      0.777 0.000 0.236 0.000 0.764 0.000
#> GSM802147     4  0.3586      0.582 0.000 0.000 0.000 0.736 0.264
#> GSM802150     2  0.0609      0.926 0.000 0.980 0.000 0.000 0.020
#> GSM802159     4  0.0404      0.694 0.000 0.000 0.000 0.988 0.012
#> GSM802162     3  0.0000      0.985 0.000 0.000 1.000 0.000 0.000
#> GSM802171     4  0.4494      0.603 0.000 0.380 0.000 0.608 0.012
#> GSM802174     2  0.4086      0.649 0.000 0.736 0.000 0.240 0.024
#> GSM802183     2  0.0703      0.925 0.000 0.976 0.000 0.000 0.024
#> GSM802186     2  0.0703      0.925 0.000 0.976 0.000 0.000 0.024
#> GSM802137     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.1732      0.872 0.920 0.000 0.000 0.000 0.080
#> GSM802151     5  0.3816      0.998 0.304 0.000 0.000 0.000 0.696
#> GSM802161     5  0.3837      0.994 0.308 0.000 0.000 0.000 0.692
#> GSM802163     3  0.0000      0.985 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0955      0.925 0.000 0.968 0.000 0.004 0.028
#> GSM802185     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802136     4  0.3395      0.777 0.000 0.236 0.000 0.764 0.000
#> GSM802139     4  0.3395      0.777 0.000 0.236 0.000 0.764 0.000
#> GSM802148     4  0.3586      0.582 0.000 0.000 0.000 0.736 0.264
#> GSM802152     2  0.0703      0.925 0.000 0.976 0.000 0.000 0.024
#> GSM802160     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802164     1  0.2329      0.790 0.876 0.000 0.000 0.000 0.124
#> GSM802172     4  0.4494      0.603 0.000 0.380 0.000 0.608 0.012
#> GSM802176     1  0.0000      0.983 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0703      0.925 0.000 0.976 0.000 0.000 0.024
#> GSM802187     2  0.0162      0.929 0.000 0.996 0.000 0.000 0.004

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.0692      0.944 0.000 0.976 0.000 0.020 0.000 0.004
#> GSM802144     4  0.2178      0.727 0.000 0.132 0.000 0.868 0.000 0.000
#> GSM802153     3  0.0508      0.979 0.000 0.012 0.984 0.000 0.000 0.004
#> GSM802156     3  0.0725      0.977 0.000 0.000 0.976 0.012 0.000 0.012
#> GSM802165     4  0.4601      0.482 0.000 0.060 0.000 0.628 0.000 0.312
#> GSM802168     4  0.4767      0.370 0.000 0.444 0.000 0.512 0.004 0.040
#> GSM802177     2  0.1010      0.942 0.000 0.960 0.000 0.036 0.000 0.004
#> GSM802180     2  0.1010      0.942 0.000 0.960 0.000 0.036 0.000 0.004
#> GSM802189     2  0.1080      0.942 0.000 0.960 0.000 0.032 0.004 0.004
#> GSM802192     4  0.4601      0.488 0.000 0.060 0.000 0.628 0.000 0.312
#> GSM802143     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802155     5  0.0146      0.996 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM802158     5  0.0146      0.996 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM802167     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.0692      0.944 0.000 0.976 0.000 0.020 0.000 0.004
#> GSM802145     4  0.2178      0.727 0.000 0.132 0.000 0.868 0.000 0.000
#> GSM802154     3  0.0508      0.979 0.000 0.012 0.984 0.000 0.000 0.004
#> GSM802157     3  0.0725      0.977 0.000 0.000 0.976 0.012 0.000 0.012
#> GSM802166     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802169     2  0.1225      0.938 0.000 0.952 0.000 0.036 0.000 0.012
#> GSM802178     4  0.5832      0.581 0.000 0.292 0.000 0.508 0.004 0.196
#> GSM802181     2  0.1010      0.942 0.000 0.960 0.000 0.036 0.000 0.004
#> GSM802190     2  0.1225      0.938 0.000 0.952 0.000 0.036 0.000 0.012
#> GSM802193     6  0.1814      0.884 0.000 0.000 0.000 0.100 0.000 0.900
#> GSM802135     4  0.2135      0.728 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM802138     4  0.2135      0.728 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM802147     6  0.0713      0.944 0.000 0.000 0.000 0.028 0.000 0.972
#> GSM802150     2  0.0000      0.941 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802159     4  0.3659      0.232 0.000 0.000 0.000 0.636 0.000 0.364
#> GSM802162     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     4  0.5697      0.586 0.000 0.284 0.000 0.516 0.000 0.200
#> GSM802174     2  0.3996      0.460 0.000 0.636 0.000 0.352 0.004 0.008
#> GSM802183     2  0.0260      0.939 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM802186     2  0.0260      0.939 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM802137     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.1714      0.898 0.908 0.000 0.000 0.000 0.092 0.000
#> GSM802151     5  0.0146      0.996 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM802161     5  0.0363      0.987 0.012 0.000 0.000 0.000 0.988 0.000
#> GSM802163     3  0.0000      0.983 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802173     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.2261      0.848 0.000 0.884 0.000 0.104 0.004 0.008
#> GSM802185     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802136     4  0.2135      0.728 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM802139     4  0.2135      0.728 0.000 0.128 0.000 0.872 0.000 0.000
#> GSM802148     6  0.0713      0.944 0.000 0.000 0.000 0.028 0.000 0.972
#> GSM802152     2  0.0146      0.940 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM802160     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802164     1  0.2562      0.797 0.828 0.000 0.000 0.000 0.172 0.000
#> GSM802172     4  0.5697      0.586 0.000 0.284 0.000 0.516 0.000 0.200
#> GSM802176     1  0.0000      0.984 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0260      0.939 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM802187     2  0.0692      0.944 0.000 0.976 0.000 0.020 0.000 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) protocol(p)  time(p) individual(p) k
#> MAD:hclust 60            1.000    4.43e-09 0.000103        1.0000 2
#> MAD:hclust 59            0.682    1.15e-07 0.000235        0.4658 3
#> MAD:hclust 59            0.741    1.01e-06 0.000811        0.0405 4
#> MAD:hclust 59            0.870    4.54e-06 0.002202        0.0666 5
#> MAD:hclust 55            0.842    7.27e-05 0.015292        0.0113 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'kmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-kmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           0.994       0.992         0.4697 0.528   0.528
#> 3 3 0.695           0.701       0.750         0.2804 0.801   0.623
#> 4 4 0.621           0.686       0.792         0.1357 0.839   0.595
#> 5 5 0.585           0.629       0.718         0.0912 0.853   0.557
#> 6 6 0.669           0.501       0.657         0.0573 0.932   0.727

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
#> GSM802141     2  0.0000      0.996 0.000 1.000
#> GSM802144     2  0.0000      0.996 0.000 1.000
#> GSM802153     2  0.1414      0.983 0.020 0.980
#> GSM802156     2  0.1414      0.983 0.020 0.980
#> GSM802165     2  0.0000      0.996 0.000 1.000
#> GSM802168     2  0.0000      0.996 0.000 1.000
#> GSM802177     2  0.0000      0.996 0.000 1.000
#> GSM802180     2  0.0000      0.996 0.000 1.000
#> GSM802189     2  0.0000      0.996 0.000 1.000
#> GSM802192     2  0.0000      0.996 0.000 1.000
#> GSM802143     1  0.1414      0.996 0.980 0.020
#> GSM802146     1  0.1414      0.996 0.980 0.020
#> GSM802155     1  0.0000      0.983 1.000 0.000
#> GSM802158     1  0.0000      0.983 1.000 0.000
#> GSM802167     1  0.1414      0.996 0.980 0.020
#> GSM802170     1  0.1414      0.996 0.980 0.020
#> GSM802179     1  0.1414      0.996 0.980 0.020
#> GSM802182     1  0.1414      0.996 0.980 0.020
#> GSM802191     1  0.1414      0.996 0.980 0.020
#> GSM802194     1  0.1414      0.996 0.980 0.020
#> GSM802142     2  0.0000      0.996 0.000 1.000
#> GSM802145     2  0.0000      0.996 0.000 1.000
#> GSM802154     2  0.1414      0.983 0.020 0.980
#> GSM802157     2  0.1414      0.983 0.020 0.980
#> GSM802166     1  0.1414      0.996 0.980 0.020
#> GSM802169     2  0.0000      0.996 0.000 1.000
#> GSM802178     2  0.0000      0.996 0.000 1.000
#> GSM802181     2  0.0000      0.996 0.000 1.000
#> GSM802190     2  0.0000      0.996 0.000 1.000
#> GSM802193     2  0.0000      0.996 0.000 1.000
#> GSM802135     2  0.0000      0.996 0.000 1.000
#> GSM802138     2  0.0000      0.996 0.000 1.000
#> GSM802147     2  0.0000      0.996 0.000 1.000
#> GSM802150     2  0.0000      0.996 0.000 1.000
#> GSM802159     2  0.1414      0.983 0.020 0.980
#> GSM802162     2  0.1414      0.983 0.020 0.980
#> GSM802171     2  0.0000      0.996 0.000 1.000
#> GSM802174     2  0.0000      0.996 0.000 1.000
#> GSM802183     2  0.0000      0.996 0.000 1.000
#> GSM802186     2  0.0000      0.996 0.000 1.000
#> GSM802137     1  0.1414      0.996 0.980 0.020
#> GSM802140     1  0.1414      0.996 0.980 0.020
#> GSM802149     1  0.1414      0.996 0.980 0.020
#> GSM802151     1  0.0000      0.983 1.000 0.000
#> GSM802161     1  0.0000      0.983 1.000 0.000
#> GSM802163     2  0.1414      0.983 0.020 0.980
#> GSM802173     1  0.1414      0.996 0.980 0.020
#> GSM802175     2  0.0000      0.996 0.000 1.000
#> GSM802185     1  0.1414      0.996 0.980 0.020
#> GSM802188     1  0.1414      0.996 0.980 0.020
#> GSM802136     2  0.0000      0.996 0.000 1.000
#> GSM802139     2  0.0000      0.996 0.000 1.000
#> GSM802148     2  0.0000      0.996 0.000 1.000
#> GSM802152     2  0.0376      0.994 0.004 0.996
#> GSM802160     1  0.1414      0.996 0.980 0.020
#> GSM802164     1  0.1414      0.996 0.980 0.020
#> GSM802172     2  0.0000      0.996 0.000 1.000
#> GSM802176     1  0.1414      0.996 0.980 0.020
#> GSM802184     2  0.0000      0.996 0.000 1.000
#> GSM802187     2  0.0000      0.996 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     3  0.6168    0.41795 0.000 0.412 0.588
#> GSM802144     2  0.5810    0.84798 0.000 0.664 0.336
#> GSM802153     3  0.0747    0.39501 0.000 0.016 0.984
#> GSM802156     3  0.2959    0.31329 0.000 0.100 0.900
#> GSM802165     2  0.5327    0.91774 0.000 0.728 0.272
#> GSM802168     2  0.5926    0.74595 0.000 0.644 0.356
#> GSM802177     3  0.6291    0.24202 0.000 0.468 0.532
#> GSM802180     3  0.6204    0.39088 0.000 0.424 0.576
#> GSM802189     3  0.6192    0.39865 0.000 0.420 0.580
#> GSM802192     2  0.5327    0.91774 0.000 0.728 0.272
#> GSM802143     1  0.1289    0.94733 0.968 0.032 0.000
#> GSM802146     1  0.1289    0.94733 0.968 0.032 0.000
#> GSM802155     1  0.4605    0.87794 0.796 0.204 0.000
#> GSM802158     1  0.4605    0.87794 0.796 0.204 0.000
#> GSM802167     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802170     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802179     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802182     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802191     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802194     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802142     3  0.6140    0.42837 0.000 0.404 0.596
#> GSM802145     2  0.5810    0.84798 0.000 0.664 0.336
#> GSM802154     3  0.0000    0.39228 0.000 0.000 1.000
#> GSM802157     3  0.0592    0.38937 0.000 0.012 0.988
#> GSM802166     1  0.1529    0.94541 0.960 0.040 0.000
#> GSM802169     2  0.5497    0.90615 0.000 0.708 0.292
#> GSM802178     2  0.5327    0.91774 0.000 0.728 0.272
#> GSM802181     3  0.6291    0.24202 0.000 0.468 0.532
#> GSM802190     3  0.6215    0.37363 0.000 0.428 0.572
#> GSM802193     2  0.5058    0.87686 0.000 0.756 0.244
#> GSM802135     2  0.5327    0.91774 0.000 0.728 0.272
#> GSM802138     2  0.5810    0.84798 0.000 0.664 0.336
#> GSM802147     2  0.5098    0.88364 0.000 0.752 0.248
#> GSM802150     3  0.6307    0.06036 0.000 0.488 0.512
#> GSM802159     3  0.5926   -0.00242 0.000 0.356 0.644
#> GSM802162     3  0.0592    0.38937 0.000 0.012 0.988
#> GSM802171     2  0.5327    0.91774 0.000 0.728 0.272
#> GSM802174     3  0.6308    0.10447 0.000 0.492 0.508
#> GSM802183     3  0.6140    0.42837 0.000 0.404 0.596
#> GSM802186     3  0.6140    0.42837 0.000 0.404 0.596
#> GSM802137     1  0.1643    0.94479 0.956 0.044 0.000
#> GSM802140     1  0.1411    0.94667 0.964 0.036 0.000
#> GSM802149     1  0.4452    0.89648 0.808 0.192 0.000
#> GSM802151     1  0.4605    0.87794 0.796 0.204 0.000
#> GSM802161     1  0.4702    0.87509 0.788 0.212 0.000
#> GSM802163     3  0.0592    0.38937 0.000 0.012 0.988
#> GSM802173     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802175     3  0.6168    0.41795 0.000 0.412 0.588
#> GSM802185     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802188     1  0.0000    0.95098 1.000 0.000 0.000
#> GSM802136     2  0.5810    0.84798 0.000 0.664 0.336
#> GSM802139     2  0.5497    0.90567 0.000 0.708 0.292
#> GSM802148     2  0.5058    0.87686 0.000 0.756 0.244
#> GSM802152     3  0.6140    0.42837 0.000 0.404 0.596
#> GSM802160     1  0.1529    0.94541 0.960 0.040 0.000
#> GSM802164     1  0.4555    0.87842 0.800 0.200 0.000
#> GSM802172     2  0.5327    0.91774 0.000 0.728 0.272
#> GSM802176     1  0.1289    0.94733 0.968 0.032 0.000
#> GSM802184     3  0.6168    0.41795 0.000 0.412 0.588
#> GSM802187     3  0.6140    0.42837 0.000 0.404 0.596

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.0524     0.7397 0.000 0.988 0.004 0.008
#> GSM802144     2  0.5402    -0.4192 0.000 0.516 0.012 0.472
#> GSM802153     2  0.4228     0.2356 0.000 0.760 0.232 0.008
#> GSM802156     3  0.5354     0.9229 0.000 0.232 0.712 0.056
#> GSM802165     4  0.4624     0.8719 0.000 0.340 0.000 0.660
#> GSM802168     2  0.3311     0.5897 0.000 0.828 0.000 0.172
#> GSM802177     2  0.1474     0.7249 0.000 0.948 0.000 0.052
#> GSM802180     2  0.0817     0.7386 0.000 0.976 0.000 0.024
#> GSM802189     2  0.0707     0.7396 0.000 0.980 0.000 0.020
#> GSM802192     4  0.4643     0.8709 0.000 0.344 0.000 0.656
#> GSM802143     1  0.2775     0.8707 0.896 0.000 0.084 0.020
#> GSM802146     1  0.2843     0.8701 0.892 0.000 0.088 0.020
#> GSM802155     1  0.6578     0.7058 0.620 0.000 0.136 0.244
#> GSM802158     1  0.6578     0.7058 0.620 0.000 0.136 0.244
#> GSM802167     1  0.0469     0.8854 0.988 0.000 0.012 0.000
#> GSM802170     1  0.0336     0.8846 0.992 0.000 0.008 0.000
#> GSM802179     1  0.0000     0.8850 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0469     0.8846 0.988 0.000 0.012 0.000
#> GSM802191     1  0.0469     0.8846 0.988 0.000 0.012 0.000
#> GSM802194     1  0.0469     0.8854 0.988 0.000 0.012 0.000
#> GSM802142     2  0.0524     0.7397 0.000 0.988 0.004 0.008
#> GSM802145     2  0.5404    -0.4327 0.000 0.512 0.012 0.476
#> GSM802154     3  0.4331     0.9634 0.000 0.288 0.712 0.000
#> GSM802157     3  0.4776     0.9731 0.000 0.272 0.712 0.016
#> GSM802166     1  0.2197     0.8788 0.928 0.000 0.048 0.024
#> GSM802169     2  0.4730     0.0563 0.000 0.636 0.000 0.364
#> GSM802178     4  0.4661     0.8680 0.000 0.348 0.000 0.652
#> GSM802181     2  0.1474     0.7249 0.000 0.948 0.000 0.052
#> GSM802190     2  0.1211     0.7322 0.000 0.960 0.000 0.040
#> GSM802193     4  0.5195     0.8394 0.000 0.276 0.032 0.692
#> GSM802135     4  0.4897     0.8635 0.000 0.332 0.008 0.660
#> GSM802138     2  0.5402    -0.4192 0.000 0.516 0.012 0.472
#> GSM802147     4  0.5222     0.8420 0.000 0.280 0.032 0.688
#> GSM802150     2  0.2329     0.6961 0.000 0.916 0.012 0.072
#> GSM802159     4  0.6104     0.5034 0.000 0.104 0.232 0.664
#> GSM802162     3  0.4690     0.9746 0.000 0.276 0.712 0.012
#> GSM802171     4  0.4661     0.8680 0.000 0.348 0.000 0.652
#> GSM802174     2  0.1867     0.7073 0.000 0.928 0.000 0.072
#> GSM802183     2  0.0000     0.7423 0.000 1.000 0.000 0.000
#> GSM802186     2  0.0000     0.7423 0.000 1.000 0.000 0.000
#> GSM802137     1  0.3143     0.8657 0.876 0.000 0.100 0.024
#> GSM802140     1  0.2843     0.8701 0.892 0.000 0.088 0.020
#> GSM802149     1  0.6039     0.7806 0.684 0.000 0.188 0.128
#> GSM802151     1  0.6578     0.7058 0.620 0.000 0.136 0.244
#> GSM802161     1  0.6621     0.7030 0.616 0.000 0.140 0.244
#> GSM802163     3  0.4690     0.9746 0.000 0.276 0.712 0.012
#> GSM802173     1  0.0000     0.8850 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0000     0.7423 0.000 1.000 0.000 0.000
#> GSM802185     1  0.0469     0.8846 0.988 0.000 0.012 0.000
#> GSM802188     1  0.0469     0.8846 0.988 0.000 0.012 0.000
#> GSM802136     2  0.5402    -0.4192 0.000 0.516 0.012 0.472
#> GSM802139     2  0.5409    -0.4762 0.000 0.496 0.012 0.492
#> GSM802148     4  0.5195     0.8394 0.000 0.276 0.032 0.692
#> GSM802152     2  0.0336     0.7402 0.000 0.992 0.000 0.008
#> GSM802160     1  0.2282     0.8784 0.924 0.000 0.052 0.024
#> GSM802164     1  0.6215     0.7296 0.668 0.000 0.140 0.192
#> GSM802172     4  0.4661     0.8680 0.000 0.348 0.000 0.652
#> GSM802176     1  0.2335     0.8749 0.920 0.000 0.060 0.020
#> GSM802184     2  0.0000     0.7423 0.000 1.000 0.000 0.000
#> GSM802187     2  0.0336     0.7402 0.000 0.992 0.000 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2   0.335    0.77495 0.056 0.864 0.024 0.056 0.000
#> GSM802144     4   0.579    0.62363 0.096 0.328 0.004 0.572 0.000
#> GSM802153     2   0.530    0.59004 0.060 0.724 0.164 0.052 0.000
#> GSM802156     3   0.375    0.94790 0.012 0.132 0.820 0.036 0.000
#> GSM802165     4   0.355    0.74674 0.004 0.216 0.004 0.776 0.000
#> GSM802168     2   0.436    0.62281 0.088 0.764 0.000 0.148 0.000
#> GSM802177     2   0.305    0.76491 0.076 0.864 0.000 0.060 0.000
#> GSM802180     2   0.208    0.79799 0.064 0.916 0.000 0.020 0.000
#> GSM802189     2   0.198    0.79933 0.064 0.920 0.000 0.016 0.000
#> GSM802192     4   0.438    0.73623 0.036 0.248 0.000 0.716 0.000
#> GSM802143     5   0.438   -0.38348 0.420 0.000 0.000 0.004 0.576
#> GSM802146     5   0.437   -0.37820 0.416 0.000 0.000 0.004 0.580
#> GSM802155     5   0.502    0.44927 0.044 0.000 0.112 0.088 0.756
#> GSM802158     5   0.502    0.44927 0.044 0.000 0.112 0.088 0.756
#> GSM802167     1   0.415    0.88621 0.612 0.000 0.000 0.000 0.388
#> GSM802170     1   0.418    0.90272 0.644 0.000 0.000 0.004 0.352
#> GSM802179     1   0.411    0.89108 0.624 0.000 0.000 0.000 0.376
#> GSM802182     1   0.431    0.89926 0.636 0.000 0.000 0.008 0.356
#> GSM802191     1   0.418    0.90383 0.644 0.000 0.000 0.004 0.352
#> GSM802194     1   0.415    0.88621 0.612 0.000 0.000 0.000 0.388
#> GSM802142     2   0.352    0.77265 0.056 0.856 0.032 0.056 0.000
#> GSM802145     4   0.579    0.62363 0.096 0.328 0.004 0.572 0.000
#> GSM802154     3   0.305    0.96926 0.008 0.164 0.828 0.000 0.000
#> GSM802157     3   0.343    0.97315 0.012 0.152 0.824 0.012 0.000
#> GSM802166     1   0.542    0.73990 0.532 0.000 0.036 0.012 0.420
#> GSM802169     2   0.554   -0.00817 0.080 0.568 0.000 0.352 0.000
#> GSM802178     4   0.528    0.69449 0.084 0.276 0.000 0.640 0.000
#> GSM802181     2   0.293    0.76932 0.068 0.872 0.000 0.060 0.000
#> GSM802190     2   0.265    0.79121 0.084 0.884 0.000 0.032 0.000
#> GSM802193     4   0.547    0.69114 0.164 0.148 0.008 0.680 0.000
#> GSM802135     4   0.410    0.73856 0.052 0.160 0.004 0.784 0.000
#> GSM802138     4   0.586    0.62845 0.096 0.316 0.008 0.580 0.000
#> GSM802147     4   0.539    0.69111 0.160 0.144 0.008 0.688 0.000
#> GSM802150     2   0.446    0.68095 0.084 0.764 0.004 0.148 0.000
#> GSM802159     4   0.482    0.49392 0.052 0.016 0.204 0.728 0.000
#> GSM802162     3   0.313    0.97706 0.004 0.156 0.832 0.008 0.000
#> GSM802171     4   0.466    0.73238 0.040 0.256 0.004 0.700 0.000
#> GSM802174     2   0.340    0.75667 0.080 0.848 0.004 0.068 0.000
#> GSM802183     2   0.120    0.81018 0.012 0.960 0.028 0.000 0.000
#> GSM802186     2   0.130    0.80980 0.016 0.956 0.028 0.000 0.000
#> GSM802137     5   0.490   -0.32610 0.368 0.000 0.020 0.008 0.604
#> GSM802140     5   0.435   -0.36594 0.408 0.000 0.000 0.004 0.588
#> GSM802149     5   0.427    0.24138 0.136 0.000 0.052 0.020 0.792
#> GSM802151     5   0.502    0.44927 0.044 0.000 0.112 0.088 0.756
#> GSM802161     5   0.492    0.43981 0.036 0.000 0.116 0.088 0.760
#> GSM802163     3   0.336    0.97620 0.012 0.156 0.824 0.008 0.000
#> GSM802173     1   0.411    0.89108 0.624 0.000 0.000 0.000 0.376
#> GSM802175     2   0.112    0.81214 0.016 0.964 0.020 0.000 0.000
#> GSM802185     1   0.418    0.90152 0.644 0.000 0.000 0.004 0.352
#> GSM802188     1   0.431    0.89926 0.636 0.000 0.000 0.008 0.356
#> GSM802136     4   0.586    0.62845 0.096 0.316 0.008 0.580 0.000
#> GSM802139     4   0.585    0.65240 0.104 0.292 0.008 0.596 0.000
#> GSM802148     4   0.520    0.69540 0.140 0.144 0.008 0.708 0.000
#> GSM802152     2   0.336    0.77588 0.052 0.864 0.028 0.056 0.000
#> GSM802160     1   0.544    0.70572 0.516 0.000 0.036 0.012 0.436
#> GSM802164     5   0.490    0.34629 0.180 0.000 0.040 0.040 0.740
#> GSM802172     4   0.528    0.69449 0.084 0.276 0.000 0.640 0.000
#> GSM802176     5   0.429   -0.48674 0.460 0.000 0.000 0.000 0.540
#> GSM802184     2   0.122    0.81195 0.020 0.960 0.020 0.000 0.000
#> GSM802187     2   0.343    0.77436 0.056 0.860 0.028 0.056 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
#> GSM802141     2  0.4109     0.6886 0.000 0.576 0.012 0.000 0.000 NA
#> GSM802144     4  0.6346     0.5838 0.044 0.172 0.000 0.512 0.000 NA
#> GSM802153     2  0.5040     0.6497 0.000 0.516 0.076 0.000 0.000 NA
#> GSM802156     3  0.2358     0.9563 0.012 0.044 0.908 0.020 0.000 NA
#> GSM802165     4  0.2587     0.6849 0.020 0.108 0.000 0.868 0.000 NA
#> GSM802168     2  0.3000     0.6382 0.024 0.864 0.000 0.064 0.000 NA
#> GSM802177     2  0.0405     0.7208 0.000 0.988 0.000 0.004 0.000 NA
#> GSM802180     2  0.0146     0.7281 0.000 0.996 0.000 0.000 0.000 NA
#> GSM802189     2  0.0508     0.7301 0.004 0.984 0.000 0.000 0.000 NA
#> GSM802192     4  0.3830     0.6568 0.020 0.204 0.004 0.760 0.000 NA
#> GSM802143     1  0.4367     0.7060 0.636 0.000 0.012 0.004 0.336 NA
#> GSM802146     1  0.4229     0.7108 0.652 0.000 0.008 0.004 0.324 NA
#> GSM802155     5  0.2697     0.3627 0.000 0.000 0.000 0.000 0.812 NA
#> GSM802158     5  0.2697     0.3627 0.000 0.000 0.000 0.000 0.812 NA
#> GSM802167     1  0.4122     0.6517 0.520 0.000 0.004 0.004 0.472 NA
#> GSM802170     5  0.4129    -0.6616 0.496 0.000 0.004 0.004 0.496 NA
#> GSM802179     1  0.4122     0.6517 0.520 0.000 0.004 0.004 0.472 NA
#> GSM802182     5  0.4222    -0.6009 0.472 0.000 0.008 0.004 0.516 NA
#> GSM802191     5  0.3993    -0.6159 0.476 0.000 0.004 0.000 0.520 NA
#> GSM802194     1  0.4122     0.6517 0.520 0.000 0.004 0.004 0.472 NA
#> GSM802142     2  0.4109     0.6886 0.000 0.576 0.012 0.000 0.000 NA
#> GSM802145     4  0.6276     0.5848 0.040 0.172 0.000 0.520 0.000 NA
#> GSM802154     3  0.1524     0.9775 0.000 0.060 0.932 0.000 0.000 NA
#> GSM802157     3  0.2095     0.9699 0.012 0.052 0.916 0.004 0.000 NA
#> GSM802166     5  0.6228    -0.3999 0.360 0.000 0.028 0.000 0.456 NA
#> GSM802169     2  0.4429     0.3035 0.012 0.704 0.004 0.240 0.000 NA
#> GSM802178     4  0.4945     0.5649 0.016 0.316 0.004 0.620 0.000 NA
#> GSM802181     2  0.0291     0.7226 0.000 0.992 0.000 0.004 0.000 NA
#> GSM802190     2  0.1857     0.7035 0.012 0.928 0.000 0.028 0.000 NA
#> GSM802193     4  0.5617     0.5410 0.184 0.044 0.016 0.664 0.000 NA
#> GSM802135     4  0.4418     0.6813 0.044 0.084 0.000 0.764 0.000 NA
#> GSM802138     4  0.6212     0.5929 0.044 0.156 0.000 0.536 0.000 NA
#> GSM802147     4  0.5234     0.5419 0.192 0.028 0.012 0.684 0.000 NA
#> GSM802150     2  0.5212     0.5806 0.020 0.572 0.000 0.060 0.000 NA
#> GSM802159     4  0.4291     0.5592 0.052 0.004 0.124 0.776 0.000 NA
#> GSM802162     3  0.1267     0.9778 0.000 0.060 0.940 0.000 0.000 NA
#> GSM802171     4  0.4174     0.6480 0.016 0.208 0.004 0.740 0.000 NA
#> GSM802174     2  0.3134     0.6996 0.044 0.860 0.004 0.024 0.000 NA
#> GSM802183     2  0.3667     0.7455 0.008 0.740 0.012 0.000 0.000 NA
#> GSM802186     2  0.3667     0.7455 0.008 0.740 0.012 0.000 0.000 NA
#> GSM802137     1  0.4975     0.6191 0.616 0.000 0.012 0.004 0.316 NA
#> GSM802140     1  0.4307     0.7059 0.652 0.000 0.012 0.004 0.320 NA
#> GSM802149     5  0.5922     0.0914 0.280 0.000 0.016 0.000 0.532 NA
#> GSM802151     5  0.2697     0.3627 0.000 0.000 0.000 0.000 0.812 NA
#> GSM802161     5  0.3201     0.3580 0.012 0.000 0.000 0.000 0.780 NA
#> GSM802163     3  0.1524     0.9775 0.000 0.060 0.932 0.000 0.000 NA
#> GSM802173     1  0.4122     0.6517 0.520 0.000 0.004 0.004 0.472 NA
#> GSM802175     2  0.4568     0.7378 0.044 0.712 0.012 0.012 0.000 NA
#> GSM802185     5  0.4224    -0.6046 0.476 0.000 0.008 0.004 0.512 NA
#> GSM802188     5  0.4222    -0.6009 0.472 0.000 0.008 0.004 0.516 NA
#> GSM802136     4  0.6212     0.5929 0.044 0.156 0.000 0.536 0.000 NA
#> GSM802139     4  0.6256     0.5862 0.040 0.160 0.000 0.516 0.000 NA
#> GSM802148     4  0.5003     0.5438 0.192 0.016 0.012 0.696 0.000 NA
#> GSM802152     2  0.4546     0.6948 0.020 0.580 0.012 0.000 0.000 NA
#> GSM802160     5  0.6401    -0.3874 0.360 0.000 0.028 0.004 0.444 NA
#> GSM802164     5  0.2017     0.3151 0.020 0.000 0.008 0.004 0.920 NA
#> GSM802172     4  0.4945     0.5649 0.016 0.316 0.004 0.620 0.000 NA
#> GSM802176     1  0.3563     0.7129 0.664 0.000 0.000 0.000 0.336 NA
#> GSM802184     2  0.4228     0.7409 0.032 0.704 0.012 0.000 0.000 NA
#> GSM802187     2  0.4093     0.6926 0.000 0.584 0.012 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-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) protocol(p)  time(p) individual(p) k
#> MAD:kmeans 60            1.000    4.43e-09 0.000103       1.00000 2
#> MAD:kmeans 38            1.000    1.33e-06 0.000869       0.77959 3
#> MAD:kmeans 53            0.901    6.62e-06 0.000363       0.13801 4
#> MAD:kmeans 47            0.759    4.88e-05 0.015548       0.00317 5
#> MAD:kmeans 46            0.809    2.34e-05 0.027120       0.01383 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'skmeans' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.821           0.891       0.913         0.3843 0.798   0.618
#> 4 4 0.890           0.906       0.946         0.1046 0.915   0.753
#> 5 5 0.812           0.774       0.862         0.0556 0.955   0.841
#> 6 6 0.789           0.511       0.724         0.0426 0.908   0.671

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     3  0.0237      0.804  0 0.004 0.996
#> GSM802144     2  0.5529      0.965  0 0.704 0.296
#> GSM802153     3  0.5529      0.709  0 0.296 0.704
#> GSM802156     3  0.6168      0.635  0 0.412 0.588
#> GSM802165     2  0.5529      0.965  0 0.704 0.296
#> GSM802168     2  0.6062      0.836  0 0.616 0.384
#> GSM802177     3  0.2878      0.718  0 0.096 0.904
#> GSM802180     3  0.1411      0.783  0 0.036 0.964
#> GSM802189     3  0.0892      0.796  0 0.020 0.980
#> GSM802192     2  0.5529      0.965  0 0.704 0.296
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     3  0.0000      0.805  0 0.000 1.000
#> GSM802145     2  0.5529      0.965  0 0.704 0.296
#> GSM802154     3  0.5529      0.709  0 0.296 0.704
#> GSM802157     3  0.5529      0.709  0 0.296 0.704
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     2  0.5529      0.965  0 0.704 0.296
#> GSM802178     2  0.5529      0.965  0 0.704 0.296
#> GSM802181     3  0.2878      0.718  0 0.096 0.904
#> GSM802190     3  0.1031      0.793  0 0.024 0.976
#> GSM802193     2  0.5529      0.965  0 0.704 0.296
#> GSM802135     2  0.5529      0.965  0 0.704 0.296
#> GSM802138     2  0.5529      0.965  0 0.704 0.296
#> GSM802147     2  0.5529      0.965  0 0.704 0.296
#> GSM802150     3  0.4178      0.582  0 0.172 0.828
#> GSM802159     2  0.0000      0.540  0 1.000 0.000
#> GSM802162     3  0.5529      0.709  0 0.296 0.704
#> GSM802171     2  0.5529      0.965  0 0.704 0.296
#> GSM802174     3  0.2878      0.718  0 0.096 0.904
#> GSM802183     3  0.0000      0.805  0 0.000 1.000
#> GSM802186     3  0.0000      0.805  0 0.000 1.000
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     3  0.5529      0.709  0 0.296 0.704
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     3  0.0424      0.802  0 0.008 0.992
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.5529      0.965  0 0.704 0.296
#> GSM802139     2  0.5529      0.965  0 0.704 0.296
#> GSM802148     2  0.5529      0.965  0 0.704 0.296
#> GSM802152     3  0.5497      0.711  0 0.292 0.708
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.5529      0.965  0 0.704 0.296
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     3  0.0237      0.804  0 0.004 0.996
#> GSM802187     3  0.0000      0.805  0 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.1118      0.893 0.000 0.964 0.000 0.036
#> GSM802144     4  0.3105      0.855 0.000 0.140 0.004 0.856
#> GSM802153     3  0.4679      0.474 0.000 0.352 0.648 0.000
#> GSM802156     3  0.0524      0.919 0.000 0.008 0.988 0.004
#> GSM802165     4  0.1302      0.895 0.000 0.044 0.000 0.956
#> GSM802168     2  0.2530      0.866 0.000 0.888 0.000 0.112
#> GSM802177     2  0.1940      0.890 0.000 0.924 0.000 0.076
#> GSM802180     2  0.1211      0.903 0.000 0.960 0.000 0.040
#> GSM802189     2  0.1211      0.903 0.000 0.960 0.000 0.040
#> GSM802192     4  0.1637      0.894 0.000 0.060 0.000 0.940
#> GSM802143     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0188      0.997 0.996 0.000 0.004 0.000
#> GSM802158     1  0.0188      0.997 0.996 0.000 0.004 0.000
#> GSM802167     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802142     2  0.1610      0.889 0.000 0.952 0.016 0.032
#> GSM802145     4  0.3052      0.858 0.000 0.136 0.004 0.860
#> GSM802154     3  0.0469      0.923 0.000 0.012 0.988 0.000
#> GSM802157     3  0.0469      0.923 0.000 0.012 0.988 0.000
#> GSM802166     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802169     2  0.4955      0.202 0.000 0.556 0.000 0.444
#> GSM802178     4  0.2081      0.886 0.000 0.084 0.000 0.916
#> GSM802181     2  0.1940      0.890 0.000 0.924 0.000 0.076
#> GSM802190     2  0.2081      0.884 0.000 0.916 0.000 0.084
#> GSM802193     4  0.1305      0.892 0.000 0.036 0.004 0.960
#> GSM802135     4  0.0524      0.890 0.000 0.008 0.004 0.988
#> GSM802138     4  0.2999      0.857 0.000 0.132 0.004 0.864
#> GSM802147     4  0.1706      0.889 0.000 0.036 0.016 0.948
#> GSM802150     2  0.2125      0.874 0.000 0.920 0.004 0.076
#> GSM802159     4  0.5018      0.538 0.000 0.012 0.332 0.656
#> GSM802162     3  0.0469      0.923 0.000 0.012 0.988 0.000
#> GSM802171     4  0.1867      0.892 0.000 0.072 0.000 0.928
#> GSM802174     2  0.2081      0.886 0.000 0.916 0.000 0.084
#> GSM802183     2  0.0469      0.905 0.000 0.988 0.012 0.000
#> GSM802186     2  0.0469      0.905 0.000 0.988 0.012 0.000
#> GSM802137     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802151     1  0.0188      0.997 0.996 0.000 0.004 0.000
#> GSM802161     1  0.0188      0.997 0.996 0.000 0.004 0.000
#> GSM802163     3  0.0469      0.923 0.000 0.012 0.988 0.000
#> GSM802173     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0657      0.906 0.000 0.984 0.012 0.004
#> GSM802185     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802136     4  0.2999      0.857 0.000 0.132 0.004 0.864
#> GSM802139     4  0.3105      0.855 0.000 0.140 0.004 0.856
#> GSM802148     4  0.1109      0.892 0.000 0.028 0.004 0.968
#> GSM802152     2  0.1798      0.884 0.000 0.944 0.040 0.016
#> GSM802160     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802164     1  0.0188      0.997 0.996 0.000 0.004 0.000
#> GSM802172     4  0.2081      0.886 0.000 0.084 0.000 0.916
#> GSM802176     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0469      0.905 0.000 0.988 0.012 0.000
#> GSM802187     2  0.1624      0.889 0.000 0.952 0.028 0.020

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.3210      0.647 0.000 0.788 0.000 0.000 0.212
#> GSM802144     5  0.4268      0.934 0.000 0.024 0.000 0.268 0.708
#> GSM802153     3  0.4718      0.266 0.000 0.444 0.540 0.000 0.016
#> GSM802156     3  0.0290      0.893 0.000 0.008 0.992 0.000 0.000
#> GSM802165     4  0.3769      0.462 0.000 0.032 0.000 0.788 0.180
#> GSM802168     2  0.3949      0.653 0.000 0.696 0.000 0.300 0.004
#> GSM802177     2  0.3715      0.694 0.000 0.736 0.000 0.260 0.004
#> GSM802180     2  0.3521      0.715 0.000 0.764 0.000 0.232 0.004
#> GSM802189     2  0.3491      0.716 0.000 0.768 0.000 0.228 0.004
#> GSM802192     4  0.2797      0.623 0.000 0.060 0.000 0.880 0.060
#> GSM802143     1  0.0000      0.970 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802155     1  0.2513      0.911 0.876 0.000 0.008 0.000 0.116
#> GSM802158     1  0.2513      0.911 0.876 0.000 0.008 0.000 0.116
#> GSM802167     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802170     1  0.0000      0.970 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.970 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM802191     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM802194     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802142     2  0.3210      0.647 0.000 0.788 0.000 0.000 0.212
#> GSM802145     5  0.4243      0.931 0.000 0.024 0.000 0.264 0.712
#> GSM802154     3  0.0290      0.893 0.000 0.008 0.992 0.000 0.000
#> GSM802157     3  0.0290      0.893 0.000 0.008 0.992 0.000 0.000
#> GSM802166     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802169     4  0.4425     -0.135 0.000 0.452 0.000 0.544 0.004
#> GSM802178     4  0.2068      0.625 0.000 0.092 0.000 0.904 0.004
#> GSM802181     2  0.3662      0.701 0.000 0.744 0.000 0.252 0.004
#> GSM802190     2  0.4064      0.680 0.000 0.716 0.004 0.272 0.008
#> GSM802193     4  0.3242      0.605 0.000 0.000 0.000 0.784 0.216
#> GSM802135     5  0.4278      0.596 0.000 0.000 0.000 0.452 0.548
#> GSM802138     5  0.4268      0.934 0.000 0.024 0.000 0.268 0.708
#> GSM802147     4  0.3790      0.590 0.000 0.004 0.004 0.744 0.248
#> GSM802150     2  0.6218      0.222 0.000 0.488 0.000 0.148 0.364
#> GSM802159     4  0.6155      0.299 0.000 0.000 0.336 0.516 0.148
#> GSM802162     3  0.0290      0.893 0.000 0.008 0.992 0.000 0.000
#> GSM802171     4  0.3354      0.618 0.000 0.088 0.000 0.844 0.068
#> GSM802174     2  0.3305      0.715 0.000 0.776 0.000 0.224 0.000
#> GSM802183     2  0.0290      0.754 0.000 0.992 0.000 0.000 0.008
#> GSM802186     2  0.0290      0.754 0.000 0.992 0.000 0.000 0.008
#> GSM802137     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802140     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802149     1  0.1956      0.935 0.916 0.000 0.008 0.000 0.076
#> GSM802151     1  0.2513      0.911 0.876 0.000 0.008 0.000 0.116
#> GSM802161     1  0.2563      0.910 0.872 0.000 0.008 0.000 0.120
#> GSM802163     3  0.0290      0.893 0.000 0.008 0.992 0.000 0.000
#> GSM802173     1  0.0000      0.970 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0671      0.755 0.000 0.980 0.000 0.016 0.004
#> GSM802185     1  0.0162      0.969 0.996 0.000 0.000 0.000 0.004
#> GSM802188     1  0.0404      0.967 0.988 0.000 0.000 0.000 0.012
#> GSM802136     5  0.4268      0.934 0.000 0.024 0.000 0.268 0.708
#> GSM802139     5  0.4292      0.929 0.000 0.024 0.000 0.272 0.704
#> GSM802148     4  0.4182      0.383 0.000 0.000 0.000 0.600 0.400
#> GSM802152     2  0.3169      0.681 0.000 0.856 0.084 0.000 0.060
#> GSM802160     1  0.0162      0.970 0.996 0.000 0.000 0.000 0.004
#> GSM802164     1  0.2011      0.930 0.908 0.000 0.004 0.000 0.088
#> GSM802172     4  0.2068      0.625 0.000 0.092 0.000 0.904 0.004
#> GSM802176     1  0.0000      0.970 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0566      0.754 0.000 0.984 0.000 0.012 0.004
#> GSM802187     2  0.3086      0.676 0.000 0.816 0.004 0.000 0.180

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     6  0.5873   0.065477 0.000 0.352 0.000 0.204 0.000 0.444
#> GSM802144     4  0.0520   0.724173 0.000 0.008 0.000 0.984 0.000 0.008
#> GSM802153     6  0.6432   0.086829 0.000 0.204 0.332 0.028 0.000 0.436
#> GSM802156     3  0.0000   0.883616 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802165     4  0.7265  -0.682828 0.000 0.124 0.000 0.360 0.336 0.180
#> GSM802168     2  0.2740   0.416303 0.000 0.864 0.000 0.000 0.076 0.060
#> GSM802177     2  0.0692   0.541466 0.000 0.976 0.000 0.000 0.020 0.004
#> GSM802180     2  0.0713   0.558937 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM802189     2  0.0891   0.561599 0.000 0.968 0.000 0.000 0.008 0.024
#> GSM802192     5  0.7527   0.909767 0.000 0.264 0.000 0.208 0.356 0.172
#> GSM802143     1  0.0632   0.895889 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802146     1  0.0632   0.895889 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802155     1  0.3747   0.664657 0.604 0.000 0.000 0.000 0.396 0.000
#> GSM802158     1  0.3747   0.664657 0.604 0.000 0.000 0.000 0.396 0.000
#> GSM802167     1  0.0146   0.897760 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802170     1  0.0146   0.898135 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802179     1  0.0000   0.898025 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0547   0.895992 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM802191     1  0.0458   0.896751 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802194     1  0.0146   0.897760 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802142     6  0.5896   0.073665 0.000 0.344 0.000 0.212 0.000 0.444
#> GSM802145     4  0.0520   0.724173 0.000 0.008 0.000 0.984 0.000 0.008
#> GSM802154     3  0.0000   0.883616 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802157     3  0.0000   0.883616 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802166     1  0.0458   0.895641 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802169     2  0.5108   0.000444 0.000 0.708 0.000 0.064 0.120 0.108
#> GSM802178     2  0.7162  -0.737187 0.000 0.432 0.000 0.136 0.268 0.164
#> GSM802181     2  0.0363   0.560167 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM802190     2  0.1934   0.508525 0.000 0.916 0.000 0.000 0.040 0.044
#> GSM802193     6  0.5584  -0.218054 0.000 0.084 0.000 0.020 0.400 0.496
#> GSM802135     4  0.3411   0.506567 0.000 0.008 0.000 0.824 0.100 0.068
#> GSM802138     4  0.0146   0.724335 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM802147     6  0.5812  -0.174897 0.000 0.080 0.000 0.040 0.368 0.512
#> GSM802150     4  0.5949  -0.086674 0.000 0.300 0.000 0.452 0.000 0.248
#> GSM802159     3  0.7237   0.019334 0.000 0.004 0.440 0.124 0.256 0.176
#> GSM802162     3  0.0000   0.883616 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     5  0.7565   0.908794 0.000 0.296 0.000 0.240 0.308 0.156
#> GSM802174     2  0.2058   0.533218 0.000 0.908 0.000 0.000 0.036 0.056
#> GSM802183     2  0.4161   0.163669 0.000 0.540 0.000 0.012 0.000 0.448
#> GSM802186     2  0.4172   0.145794 0.000 0.528 0.000 0.012 0.000 0.460
#> GSM802137     1  0.0713   0.894503 0.972 0.000 0.000 0.000 0.028 0.000
#> GSM802140     1  0.0632   0.895889 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802149     1  0.3244   0.766929 0.732 0.000 0.000 0.000 0.268 0.000
#> GSM802151     1  0.3747   0.664657 0.604 0.000 0.000 0.000 0.396 0.000
#> GSM802161     1  0.3747   0.664657 0.604 0.000 0.000 0.000 0.396 0.000
#> GSM802163     3  0.0000   0.883616 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802173     1  0.0146   0.898135 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802175     2  0.4670   0.245862 0.000 0.548 0.000 0.004 0.036 0.412
#> GSM802185     1  0.0547   0.895992 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM802188     1  0.0632   0.895301 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802136     4  0.0000   0.722393 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802139     4  0.0260   0.724762 0.000 0.008 0.000 0.992 0.000 0.000
#> GSM802148     6  0.5867  -0.150153 0.000 0.028 0.000 0.104 0.372 0.496
#> GSM802152     2  0.5862  -0.038627 0.000 0.444 0.048 0.068 0.000 0.440
#> GSM802160     1  0.0632   0.895088 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM802164     1  0.3330   0.750420 0.716 0.000 0.000 0.000 0.284 0.000
#> GSM802172     2  0.7249  -0.777141 0.000 0.408 0.000 0.144 0.284 0.164
#> GSM802176     1  0.0458   0.898725 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802184     2  0.4385   0.199014 0.000 0.540 0.000 0.008 0.012 0.440
#> GSM802187     6  0.5723  -0.021754 0.000 0.392 0.004 0.144 0.000 0.460

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) protocol(p)  time(p) individual(p) k
#> MAD:skmeans 60            1.000    4.43e-09 0.000103        1.0000 2
#> MAD:skmeans 60            0.948    7.13e-08 0.000169        0.4178 3
#> MAD:skmeans 58            0.866    1.18e-06 0.000500        0.0634 4
#> MAD:skmeans 54            0.920    3.31e-05 0.003085        0.0102 5
#> MAD:skmeans 41            0.504    1.44e-04 0.000406        0.2136 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'pam' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 5.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-pam-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 1.000           0.990       0.996         0.2370 0.892   0.794
#> 4 4 0.841           0.852       0.927         0.2238 0.858   0.660
#> 5 5 0.921           0.889       0.944         0.0669 0.932   0.763
#> 6 6 0.884           0.880       0.921         0.0440 0.959   0.824

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

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2   0.000      0.991  0 1.000 0.000
#> GSM802144     2   0.000      0.991  0 1.000 0.000
#> GSM802153     2   0.525      0.641  0 0.736 0.264
#> GSM802156     3   0.000      1.000  0 0.000 1.000
#> GSM802165     2   0.000      0.991  0 1.000 0.000
#> GSM802168     2   0.000      0.991  0 1.000 0.000
#> GSM802177     2   0.000      0.991  0 1.000 0.000
#> GSM802180     2   0.000      0.991  0 1.000 0.000
#> GSM802189     2   0.000      0.991  0 1.000 0.000
#> GSM802192     2   0.000      0.991  0 1.000 0.000
#> GSM802143     1   0.000      1.000  1 0.000 0.000
#> GSM802146     1   0.000      1.000  1 0.000 0.000
#> GSM802155     1   0.000      1.000  1 0.000 0.000
#> GSM802158     1   0.000      1.000  1 0.000 0.000
#> GSM802167     1   0.000      1.000  1 0.000 0.000
#> GSM802170     1   0.000      1.000  1 0.000 0.000
#> GSM802179     1   0.000      1.000  1 0.000 0.000
#> GSM802182     1   0.000      1.000  1 0.000 0.000
#> GSM802191     1   0.000      1.000  1 0.000 0.000
#> GSM802194     1   0.000      1.000  1 0.000 0.000
#> GSM802142     2   0.000      0.991  0 1.000 0.000
#> GSM802145     2   0.000      0.991  0 1.000 0.000
#> GSM802154     3   0.000      1.000  0 0.000 1.000
#> GSM802157     3   0.000      1.000  0 0.000 1.000
#> GSM802166     1   0.000      1.000  1 0.000 0.000
#> GSM802169     2   0.000      0.991  0 1.000 0.000
#> GSM802178     2   0.000      0.991  0 1.000 0.000
#> GSM802181     2   0.000      0.991  0 1.000 0.000
#> GSM802190     2   0.000      0.991  0 1.000 0.000
#> GSM802193     2   0.000      0.991  0 1.000 0.000
#> GSM802135     2   0.000      0.991  0 1.000 0.000
#> GSM802138     2   0.000      0.991  0 1.000 0.000
#> GSM802147     2   0.000      0.991  0 1.000 0.000
#> GSM802150     2   0.000      0.991  0 1.000 0.000
#> GSM802159     3   0.000      1.000  0 0.000 1.000
#> GSM802162     3   0.000      1.000  0 0.000 1.000
#> GSM802171     2   0.000      0.991  0 1.000 0.000
#> GSM802174     2   0.000      0.991  0 1.000 0.000
#> GSM802183     2   0.000      0.991  0 1.000 0.000
#> GSM802186     2   0.000      0.991  0 1.000 0.000
#> GSM802137     1   0.000      1.000  1 0.000 0.000
#> GSM802140     1   0.000      1.000  1 0.000 0.000
#> GSM802149     1   0.000      1.000  1 0.000 0.000
#> GSM802151     1   0.000      1.000  1 0.000 0.000
#> GSM802161     1   0.000      1.000  1 0.000 0.000
#> GSM802163     3   0.000      1.000  0 0.000 1.000
#> GSM802173     1   0.000      1.000  1 0.000 0.000
#> GSM802175     2   0.000      0.991  0 1.000 0.000
#> GSM802185     1   0.000      1.000  1 0.000 0.000
#> GSM802188     1   0.000      1.000  1 0.000 0.000
#> GSM802136     2   0.000      0.991  0 1.000 0.000
#> GSM802139     2   0.000      0.991  0 1.000 0.000
#> GSM802148     2   0.000      0.991  0 1.000 0.000
#> GSM802152     2   0.000      0.991  0 1.000 0.000
#> GSM802160     1   0.000      1.000  1 0.000 0.000
#> GSM802164     1   0.000      1.000  1 0.000 0.000
#> GSM802172     2   0.000      0.991  0 1.000 0.000
#> GSM802176     1   0.000      1.000  1 0.000 0.000
#> GSM802184     2   0.000      0.991  0 1.000 0.000
#> GSM802187     2   0.000      0.991  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM802141     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802144     4  0.4500      0.587  0 0.316 0.000 0.684
#> GSM802153     2  0.1302      0.851  0 0.956 0.044 0.000
#> GSM802156     3  0.0000      0.988  0 0.000 1.000 0.000
#> GSM802165     4  0.1022      0.720  0 0.032 0.000 0.968
#> GSM802168     2  0.3649      0.677  0 0.796 0.000 0.204
#> GSM802177     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802180     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802189     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802192     2  0.4500      0.519  0 0.684 0.000 0.316
#> GSM802143     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802142     2  0.2469      0.768  0 0.892 0.000 0.108
#> GSM802145     4  0.0188      0.712  0 0.004 0.000 0.996
#> GSM802154     3  0.0000      0.988  0 0.000 1.000 0.000
#> GSM802157     3  0.0000      0.988  0 0.000 1.000 0.000
#> GSM802166     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802169     2  0.3801      0.678  0 0.780 0.000 0.220
#> GSM802178     4  0.4697      0.490  0 0.356 0.000 0.644
#> GSM802181     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802190     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802193     2  0.4500      0.519  0 0.684 0.000 0.316
#> GSM802135     4  0.0000      0.709  0 0.000 0.000 1.000
#> GSM802138     4  0.4477      0.591  0 0.312 0.000 0.688
#> GSM802147     2  0.2868      0.781  0 0.864 0.000 0.136
#> GSM802150     4  0.4907      0.513  0 0.420 0.000 0.580
#> GSM802159     3  0.1716      0.936  0 0.000 0.936 0.064
#> GSM802162     3  0.0000      0.988  0 0.000 1.000 0.000
#> GSM802171     4  0.4382      0.588  0 0.296 0.000 0.704
#> GSM802174     4  0.4382      0.658  0 0.296 0.000 0.704
#> GSM802183     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802186     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802137     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802163     3  0.0000      0.988  0 0.000 1.000 0.000
#> GSM802173     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802175     4  0.4406      0.657  0 0.300 0.000 0.700
#> GSM802185     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802136     4  0.4008      0.642  0 0.244 0.000 0.756
#> GSM802139     4  0.0188      0.712  0 0.004 0.000 0.996
#> GSM802148     4  0.0469      0.715  0 0.012 0.000 0.988
#> GSM802152     2  0.0188      0.885  0 0.996 0.000 0.004
#> GSM802160     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802172     4  0.4790      0.435  0 0.380 0.000 0.620
#> GSM802176     1  0.0000      1.000  1 0.000 0.000 0.000
#> GSM802184     2  0.0000      0.887  0 1.000 0.000 0.000
#> GSM802187     2  0.0469      0.879  0 0.988 0.000 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette p1    p2    p3    p4    p5
#> GSM802141     2  0.0162      0.934  0 0.996 0.000 0.000 0.004
#> GSM802144     4  0.0404      0.858  0 0.012 0.000 0.988 0.000
#> GSM802153     2  0.0000      0.933  0 1.000 0.000 0.000 0.000
#> GSM802156     3  0.0000      0.973  0 0.000 1.000 0.000 0.000
#> GSM802165     5  0.2773      0.715  0 0.000 0.000 0.164 0.836
#> GSM802168     5  0.3783      0.675  0 0.252 0.000 0.008 0.740
#> GSM802177     2  0.0963      0.933  0 0.964 0.000 0.000 0.036
#> GSM802180     2  0.0963      0.933  0 0.964 0.000 0.000 0.036
#> GSM802189     2  0.0963      0.933  0 0.964 0.000 0.000 0.036
#> GSM802192     5  0.1444      0.820  0 0.040 0.000 0.012 0.948
#> GSM802143     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802142     2  0.2891      0.749  0 0.824 0.000 0.176 0.000
#> GSM802145     4  0.0703      0.858  0 0.000 0.000 0.976 0.024
#> GSM802154     3  0.0000      0.973  0 0.000 1.000 0.000 0.000
#> GSM802157     3  0.0000      0.973  0 0.000 1.000 0.000 0.000
#> GSM802166     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802169     5  0.4171      0.347  0 0.396 0.000 0.000 0.604
#> GSM802178     5  0.1485      0.821  0 0.032 0.000 0.020 0.948
#> GSM802181     2  0.0963      0.933  0 0.964 0.000 0.000 0.036
#> GSM802190     2  0.0963      0.933  0 0.964 0.000 0.000 0.036
#> GSM802193     5  0.0000      0.794  0 0.000 0.000 0.000 1.000
#> GSM802135     4  0.0000      0.862  0 0.000 0.000 1.000 0.000
#> GSM802138     4  0.0000      0.862  0 0.000 0.000 1.000 0.000
#> GSM802147     2  0.4045      0.486  0 0.644 0.000 0.000 0.356
#> GSM802150     4  0.5680      0.513  0 0.240 0.000 0.620 0.140
#> GSM802159     3  0.2424      0.847  0 0.000 0.868 0.132 0.000
#> GSM802162     3  0.0000      0.973  0 0.000 1.000 0.000 0.000
#> GSM802171     5  0.1493      0.819  0 0.028 0.000 0.024 0.948
#> GSM802174     5  0.5876      0.511  0 0.192 0.000 0.204 0.604
#> GSM802183     2  0.0000      0.933  0 1.000 0.000 0.000 0.000
#> GSM802186     2  0.0000      0.933  0 1.000 0.000 0.000 0.000
#> GSM802137     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802163     3  0.0000      0.973  0 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802175     4  0.5871      0.452  0 0.184 0.000 0.604 0.212
#> GSM802185     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802136     4  0.0000      0.862  0 0.000 0.000 1.000 0.000
#> GSM802139     4  0.1732      0.821  0 0.000 0.000 0.920 0.080
#> GSM802148     4  0.2329      0.810  0 0.000 0.000 0.876 0.124
#> GSM802152     2  0.1124      0.931  0 0.960 0.000 0.004 0.036
#> GSM802160     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802172     5  0.1485      0.821  0 0.032 0.000 0.020 0.948
#> GSM802176     1  0.0000      1.000  1 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0000      0.933  0 1.000 0.000 0.000 0.000
#> GSM802187     2  0.0000      0.933  0 1.000 0.000 0.000 0.000

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.0146      0.932 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM802144     4  0.0000      0.860 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802153     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802156     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802165     6  0.2092      0.720 0.000 0.000 0.000 0.124 0.000 0.876
#> GSM802168     6  0.2941      0.676 0.000 0.220 0.000 0.000 0.000 0.780
#> GSM802177     2  0.0865      0.931 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM802180     2  0.0865      0.931 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM802189     2  0.0865      0.931 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM802192     6  0.0363      0.795 0.000 0.012 0.000 0.000 0.000 0.988
#> GSM802143     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802155     5  0.3428      1.000 0.304 0.000 0.000 0.000 0.696 0.000
#> GSM802158     5  0.3428      1.000 0.304 0.000 0.000 0.000 0.696 0.000
#> GSM802167     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.1387      0.877 0.000 0.932 0.000 0.068 0.000 0.000
#> GSM802145     4  0.0632      0.854 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM802154     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802157     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802166     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802169     6  0.3747      0.328 0.000 0.396 0.000 0.000 0.000 0.604
#> GSM802178     6  0.0363      0.795 0.000 0.012 0.000 0.000 0.000 0.988
#> GSM802181     2  0.0865      0.931 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM802190     2  0.0865      0.931 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM802193     6  0.3428      0.604 0.000 0.000 0.000 0.000 0.304 0.696
#> GSM802135     4  0.0000      0.860 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802138     4  0.0000      0.860 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802147     2  0.5851      0.184 0.000 0.476 0.000 0.000 0.304 0.220
#> GSM802150     4  0.4393      0.647 0.000 0.140 0.000 0.720 0.000 0.140
#> GSM802159     3  0.2178      0.844 0.000 0.000 0.868 0.132 0.000 0.000
#> GSM802162     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     6  0.0405      0.793 0.000 0.008 0.000 0.004 0.000 0.988
#> GSM802174     6  0.5008      0.521 0.000 0.168 0.000 0.188 0.000 0.644
#> GSM802183     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802186     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802137     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802151     5  0.3428      1.000 0.304 0.000 0.000 0.000 0.696 0.000
#> GSM802161     5  0.3428      1.000 0.304 0.000 0.000 0.000 0.696 0.000
#> GSM802163     3  0.0000      0.972 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802173     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802175     4  0.5191      0.480 0.000 0.172 0.000 0.616 0.000 0.212
#> GSM802185     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802136     4  0.0000      0.860 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802139     4  0.0632      0.853 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM802148     4  0.4859      0.562 0.000 0.000 0.000 0.612 0.304 0.084
#> GSM802152     2  0.1010      0.929 0.000 0.960 0.000 0.004 0.000 0.036
#> GSM802160     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802164     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802172     6  0.0363      0.795 0.000 0.012 0.000 0.000 0.000 0.988
#> GSM802176     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802187     2  0.0000      0.932 0.000 1.000 0.000 0.000 0.000 0.000

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) protocol(p)  time(p) individual(p) k
#> MAD:pam 60            1.000    4.43e-09 0.000103        1.0000 2
#> MAD:pam 60            1.000    7.22e-08 0.000167        0.5754 3
#> MAD:pam 58            0.172    1.13e-06 0.000304        0.1965 4
#> MAD:pam 57            0.529    2.34e-06 0.001091        0.0500 5
#> MAD:pam 57            0.673    8.48e-06 0.002622        0.0769 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'mclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-mclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.778           0.841       0.915         0.2993 0.877   0.768
#> 4 4 0.672           0.623       0.816         0.1176 0.927   0.819
#> 5 5 0.768           0.792       0.875         0.0644 0.940   0.819
#> 6 6 0.726           0.631       0.818         0.0572 0.982   0.937

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802144     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802153     3  0.5859      0.554 0.000 0.344 0.656
#> GSM802156     3  0.1411      0.880 0.000 0.036 0.964
#> GSM802165     2  0.0892      0.904 0.000 0.980 0.020
#> GSM802168     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802177     2  0.0661      0.910 0.008 0.988 0.004
#> GSM802180     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802189     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802192     2  0.0747      0.908 0.000 0.984 0.016
#> GSM802143     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802146     1  0.1289      0.893 0.968 0.000 0.032
#> GSM802155     1  0.4750      0.851 0.784 0.000 0.216
#> GSM802158     1  0.4750      0.851 0.784 0.000 0.216
#> GSM802167     1  0.3192      0.884 0.888 0.000 0.112
#> GSM802170     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802191     1  0.1031      0.893 0.976 0.000 0.024
#> GSM802194     1  0.3551      0.882 0.868 0.000 0.132
#> GSM802142     2  0.0237      0.915 0.000 0.996 0.004
#> GSM802145     2  0.6513      0.317 0.008 0.592 0.400
#> GSM802154     3  0.1411      0.880 0.000 0.036 0.964
#> GSM802157     3  0.1411      0.880 0.000 0.036 0.964
#> GSM802166     1  0.4555      0.858 0.800 0.000 0.200
#> GSM802169     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802178     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802181     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802190     2  0.4702      0.685 0.000 0.788 0.212
#> GSM802193     2  0.6513      0.317 0.008 0.592 0.400
#> GSM802135     2  0.0592      0.910 0.000 0.988 0.012
#> GSM802138     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802147     2  0.5835      0.374 0.000 0.660 0.340
#> GSM802150     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802159     3  0.5291      0.683 0.000 0.268 0.732
#> GSM802162     3  0.1411      0.880 0.000 0.036 0.964
#> GSM802171     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802174     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802183     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802186     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802137     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802140     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802149     1  0.4750      0.851 0.784 0.000 0.216
#> GSM802151     1  0.4750      0.851 0.784 0.000 0.216
#> GSM802161     1  0.4750      0.851 0.784 0.000 0.216
#> GSM802163     3  0.1411      0.880 0.000 0.036 0.964
#> GSM802173     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802175     2  0.0237      0.916 0.000 0.996 0.004
#> GSM802185     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802188     1  0.4291      0.868 0.820 0.000 0.180
#> GSM802136     2  0.0592      0.910 0.000 0.988 0.012
#> GSM802139     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802148     2  0.6513      0.317 0.008 0.592 0.400
#> GSM802152     2  0.4750      0.665 0.000 0.784 0.216
#> GSM802160     1  0.4555      0.858 0.800 0.000 0.200
#> GSM802164     1  0.4555      0.859 0.800 0.000 0.200
#> GSM802172     2  0.0000      0.916 0.000 1.000 0.000
#> GSM802176     1  0.0000      0.891 1.000 0.000 0.000
#> GSM802184     2  0.0848      0.908 0.008 0.984 0.008
#> GSM802187     2  0.0237      0.915 0.000 0.996 0.004

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.3172     0.5658 0.000 0.840 0.160 0.000
#> GSM802144     2  0.3172     0.6163 0.000 0.840 0.000 0.160
#> GSM802153     3  0.5250     0.1133 0.000 0.440 0.552 0.008
#> GSM802156     3  0.0188     0.7902 0.000 0.000 0.996 0.004
#> GSM802165     4  0.7510     0.6248 0.000 0.380 0.184 0.436
#> GSM802168     2  0.0592     0.7239 0.000 0.984 0.000 0.016
#> GSM802177     2  0.0000     0.7242 0.000 1.000 0.000 0.000
#> GSM802180     2  0.0000     0.7242 0.000 1.000 0.000 0.000
#> GSM802189     2  0.0000     0.7242 0.000 1.000 0.000 0.000
#> GSM802192     2  0.7385    -0.4008 0.000 0.484 0.176 0.340
#> GSM802143     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802155     1  0.7595     0.3643 0.428 0.000 0.200 0.372
#> GSM802158     1  0.7595     0.3643 0.428 0.000 0.200 0.372
#> GSM802167     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0188     0.8641 0.996 0.000 0.000 0.004
#> GSM802142     2  0.0927     0.7135 0.000 0.976 0.016 0.008
#> GSM802145     2  0.4804     0.4073 0.000 0.708 0.016 0.276
#> GSM802154     3  0.0000     0.7876 0.000 0.000 1.000 0.000
#> GSM802157     3  0.0188     0.7902 0.000 0.000 0.996 0.004
#> GSM802166     1  0.0657     0.8579 0.984 0.000 0.012 0.004
#> GSM802169     2  0.3873     0.5055 0.000 0.772 0.000 0.228
#> GSM802178     2  0.6448     0.0161 0.000 0.592 0.092 0.316
#> GSM802181     2  0.0921     0.7157 0.000 0.972 0.028 0.000
#> GSM802190     2  0.3280     0.6578 0.000 0.860 0.016 0.124
#> GSM802193     4  0.5511     0.5890 0.000 0.352 0.028 0.620
#> GSM802135     4  0.7466     0.6135 0.000 0.388 0.176 0.436
#> GSM802138     2  0.5964     0.3541 0.000 0.676 0.096 0.228
#> GSM802147     4  0.7795     0.6057 0.000 0.280 0.296 0.424
#> GSM802150     2  0.0188     0.7249 0.000 0.996 0.000 0.004
#> GSM802159     3  0.6788    -0.1825 0.000 0.096 0.480 0.424
#> GSM802162     3  0.0188     0.7902 0.000 0.000 0.996 0.004
#> GSM802171     2  0.6162     0.1324 0.000 0.620 0.076 0.304
#> GSM802174     2  0.0469     0.7234 0.000 0.988 0.000 0.012
#> GSM802183     2  0.2921     0.5987 0.000 0.860 0.140 0.000
#> GSM802186     2  0.3123     0.5697 0.000 0.844 0.156 0.000
#> GSM802137     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802149     1  0.5807     0.5795 0.596 0.000 0.040 0.364
#> GSM802151     1  0.7586     0.3753 0.436 0.000 0.200 0.364
#> GSM802161     1  0.7586     0.3753 0.436 0.000 0.200 0.364
#> GSM802163     3  0.0188     0.7902 0.000 0.000 0.996 0.004
#> GSM802173     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0000     0.7242 0.000 1.000 0.000 0.000
#> GSM802185     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802136     2  0.3873     0.5055 0.000 0.772 0.000 0.228
#> GSM802139     2  0.2921     0.6403 0.000 0.860 0.000 0.140
#> GSM802148     4  0.5511     0.5890 0.000 0.352 0.028 0.620
#> GSM802152     2  0.2611     0.6199 0.000 0.896 0.096 0.008
#> GSM802160     1  0.0657     0.8579 0.984 0.000 0.012 0.004
#> GSM802164     1  0.4793     0.7129 0.756 0.000 0.040 0.204
#> GSM802172     2  0.5947     0.1464 0.000 0.628 0.060 0.312
#> GSM802176     1  0.0000     0.8658 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0804     0.7160 0.000 0.980 0.012 0.008
#> GSM802187     2  0.0927     0.7135 0.000 0.976 0.016 0.008

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.3934      0.487 0.000 0.740 0.244 0.016 0.000
#> GSM802144     2  0.2516      0.778 0.000 0.860 0.000 0.140 0.000
#> GSM802153     3  0.3102      0.802 0.000 0.084 0.860 0.056 0.000
#> GSM802156     3  0.2127      0.886 0.000 0.000 0.892 0.108 0.000
#> GSM802165     4  0.4779      0.419 0.000 0.388 0.024 0.588 0.000
#> GSM802168     2  0.0609      0.812 0.000 0.980 0.000 0.020 0.000
#> GSM802177     2  0.0324      0.808 0.000 0.992 0.000 0.004 0.004
#> GSM802180     2  0.0324      0.809 0.000 0.992 0.000 0.004 0.004
#> GSM802189     2  0.0451      0.808 0.000 0.988 0.000 0.008 0.004
#> GSM802192     2  0.4219      0.592 0.000 0.716 0.024 0.260 0.000
#> GSM802143     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802155     5  0.0162      0.909 0.004 0.000 0.000 0.000 0.996
#> GSM802158     5  0.0162      0.909 0.004 0.000 0.000 0.000 0.996
#> GSM802167     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.1197      0.795 0.000 0.952 0.000 0.048 0.000
#> GSM802145     2  0.3816      0.583 0.000 0.696 0.000 0.304 0.000
#> GSM802154     3  0.0290      0.918 0.000 0.000 0.992 0.008 0.000
#> GSM802157     3  0.1965      0.894 0.000 0.000 0.904 0.096 0.000
#> GSM802166     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802169     2  0.2516      0.778 0.000 0.860 0.000 0.140 0.000
#> GSM802178     2  0.3421      0.721 0.000 0.788 0.008 0.204 0.000
#> GSM802181     2  0.0613      0.807 0.000 0.984 0.004 0.008 0.004
#> GSM802190     2  0.2127      0.800 0.000 0.892 0.000 0.108 0.000
#> GSM802193     4  0.2966      0.595 0.000 0.184 0.000 0.816 0.000
#> GSM802135     4  0.4890      0.251 0.000 0.452 0.024 0.524 0.000
#> GSM802138     2  0.3039      0.735 0.000 0.808 0.000 0.192 0.000
#> GSM802147     4  0.5064      0.567 0.000 0.248 0.080 0.672 0.000
#> GSM802150     2  0.1341      0.810 0.000 0.944 0.000 0.056 0.000
#> GSM802159     4  0.4341     -0.178 0.000 0.004 0.404 0.592 0.000
#> GSM802162     3  0.0510      0.920 0.000 0.000 0.984 0.016 0.000
#> GSM802171     2  0.3074      0.731 0.000 0.804 0.000 0.196 0.000
#> GSM802174     2  0.0324      0.809 0.000 0.992 0.000 0.004 0.004
#> GSM802183     2  0.3388      0.579 0.000 0.792 0.200 0.008 0.000
#> GSM802186     2  0.3882      0.522 0.000 0.756 0.224 0.020 0.000
#> GSM802137     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802149     5  0.1671      0.878 0.076 0.000 0.000 0.000 0.924
#> GSM802151     5  0.0510      0.915 0.016 0.000 0.000 0.000 0.984
#> GSM802161     5  0.0510      0.915 0.016 0.000 0.000 0.000 0.984
#> GSM802163     3  0.0162      0.919 0.000 0.000 0.996 0.004 0.000
#> GSM802173     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0290      0.808 0.000 0.992 0.000 0.008 0.000
#> GSM802185     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802136     2  0.2929      0.752 0.000 0.820 0.000 0.180 0.000
#> GSM802139     2  0.2329      0.784 0.000 0.876 0.000 0.124 0.000
#> GSM802148     4  0.2966      0.595 0.000 0.184 0.000 0.816 0.000
#> GSM802152     2  0.4927      0.280 0.000 0.652 0.296 0.052 0.000
#> GSM802160     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802164     5  0.3395      0.691 0.236 0.000 0.000 0.000 0.764
#> GSM802172     2  0.2471      0.775 0.000 0.864 0.000 0.136 0.000
#> GSM802176     1  0.0000      1.000 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.1732      0.770 0.000 0.920 0.000 0.080 0.000
#> GSM802187     2  0.0609      0.809 0.000 0.980 0.000 0.020 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
#> GSM802141     2  0.3911    0.28273 0.000 0.720 0.008 0.252 0.000 0.020
#> GSM802144     2  0.3342    0.63059 0.000 0.760 0.000 0.012 0.000 0.228
#> GSM802153     4  0.6429    0.35261 0.000 0.112 0.332 0.484 0.000 0.072
#> GSM802156     3  0.2146    0.86775 0.000 0.000 0.880 0.004 0.000 0.116
#> GSM802165     6  0.3767    0.52277 0.000 0.276 0.012 0.004 0.000 0.708
#> GSM802168     2  0.1141    0.66668 0.000 0.948 0.000 0.000 0.000 0.052
#> GSM802177     2  0.0405    0.65065 0.000 0.988 0.000 0.008 0.000 0.004
#> GSM802180     2  0.0260    0.64989 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM802189     2  0.1003    0.64355 0.000 0.964 0.000 0.016 0.000 0.020
#> GSM802192     2  0.4220    0.18800 0.000 0.520 0.008 0.004 0.000 0.468
#> GSM802143     1  0.0725    0.94324 0.976 0.000 0.000 0.012 0.012 0.000
#> GSM802146     1  0.0806    0.94540 0.972 0.000 0.000 0.020 0.008 0.000
#> GSM802155     5  0.1059    0.80964 0.016 0.000 0.004 0.016 0.964 0.000
#> GSM802158     5  0.0363    0.80135 0.000 0.000 0.000 0.012 0.988 0.000
#> GSM802167     1  0.1951    0.90995 0.908 0.000 0.000 0.076 0.016 0.000
#> GSM802170     1  0.0146    0.94799 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802179     1  0.0000    0.94820 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0820    0.94196 0.972 0.000 0.000 0.016 0.012 0.000
#> GSM802191     1  0.0909    0.94102 0.968 0.000 0.000 0.020 0.012 0.000
#> GSM802194     1  0.0820    0.94494 0.972 0.000 0.000 0.012 0.016 0.000
#> GSM802142     2  0.4612   -0.24769 0.000 0.548 0.016 0.420 0.000 0.016
#> GSM802145     2  0.6330   -0.00654 0.016 0.392 0.000 0.220 0.000 0.372
#> GSM802154     3  0.1780    0.92624 0.000 0.000 0.924 0.028 0.000 0.048
#> GSM802157     3  0.0508    0.91817 0.000 0.000 0.984 0.012 0.000 0.004
#> GSM802166     1  0.3201    0.79267 0.780 0.000 0.000 0.208 0.012 0.000
#> GSM802169     2  0.3558    0.63387 0.000 0.760 0.000 0.028 0.000 0.212
#> GSM802178     2  0.3746    0.54795 0.000 0.712 0.004 0.012 0.000 0.272
#> GSM802181     2  0.0146    0.65012 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM802190     2  0.4534    0.58611 0.000 0.672 0.008 0.052 0.000 0.268
#> GSM802193     6  0.2744    0.51707 0.000 0.016 0.000 0.144 0.000 0.840
#> GSM802135     6  0.3753    0.49472 0.000 0.292 0.008 0.004 0.000 0.696
#> GSM802138     2  0.3457    0.61199 0.000 0.752 0.000 0.016 0.000 0.232
#> GSM802147     6  0.3450    0.59297 0.000 0.208 0.012 0.008 0.000 0.772
#> GSM802150     2  0.2678    0.66804 0.000 0.860 0.004 0.020 0.000 0.116
#> GSM802159     6  0.5841   -0.28557 0.000 0.004 0.428 0.104 0.016 0.448
#> GSM802162     3  0.0458    0.91609 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM802171     2  0.3555    0.57752 0.000 0.712 0.000 0.008 0.000 0.280
#> GSM802174     2  0.0547    0.64809 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM802183     2  0.4109    0.09345 0.000 0.652 0.008 0.328 0.000 0.012
#> GSM802186     2  0.4252    0.04328 0.000 0.632 0.008 0.344 0.000 0.016
#> GSM802137     1  0.0547    0.94627 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM802140     1  0.0363    0.94793 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM802149     5  0.3373    0.67496 0.248 0.000 0.000 0.008 0.744 0.000
#> GSM802151     5  0.0717    0.81041 0.016 0.000 0.000 0.008 0.976 0.000
#> GSM802161     5  0.0692    0.80328 0.004 0.000 0.000 0.020 0.976 0.000
#> GSM802163     3  0.1644    0.92799 0.000 0.000 0.932 0.028 0.000 0.040
#> GSM802173     1  0.0547    0.94627 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM802175     2  0.0935    0.64039 0.000 0.964 0.000 0.032 0.000 0.004
#> GSM802185     1  0.0520    0.94572 0.984 0.000 0.000 0.008 0.008 0.000
#> GSM802188     1  0.1074    0.94217 0.960 0.000 0.000 0.028 0.012 0.000
#> GSM802136     2  0.3745    0.61068 0.000 0.732 0.000 0.028 0.000 0.240
#> GSM802139     2  0.3023    0.65286 0.000 0.808 0.004 0.008 0.000 0.180
#> GSM802148     6  0.2744    0.51707 0.000 0.016 0.000 0.144 0.000 0.840
#> GSM802152     4  0.6033    0.40607 0.000 0.368 0.064 0.496 0.000 0.072
#> GSM802160     1  0.3201    0.79267 0.780 0.000 0.000 0.208 0.012 0.000
#> GSM802164     5  0.4241    0.48553 0.368 0.000 0.000 0.024 0.608 0.000
#> GSM802172     2  0.3424    0.63055 0.000 0.772 0.000 0.024 0.000 0.204
#> GSM802176     1  0.0820    0.94196 0.972 0.000 0.000 0.016 0.012 0.000
#> GSM802184     2  0.4632    0.22126 0.000 0.656 0.016 0.288 0.000 0.040
#> GSM802187     2  0.5310   -0.25863 0.000 0.528 0.020 0.392 0.000 0.060

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

consensus_heatmap(res, k = 2)

plot of chunk tab-MAD-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) protocol(p)  time(p) individual(p) k
#> MAD:mclust 60            1.000    4.43e-09 1.03e-04        1.0000 2
#> MAD:mclust 56            0.914    2.79e-07 9.08e-05        0.4148 3
#> MAD:mclust 48            0.940    8.62e-05 3.58e-03        0.0832 4
#> MAD:mclust 55            0.754    2.17e-05 3.92e-03        0.0899 5
#> MAD:mclust 47            0.972    1.13e-04 5.05e-03        0.1261 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk MAD-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.701           0.724       0.865         0.3327 0.810   0.640
#> 4 4 0.785           0.699       0.839         0.1171 0.895   0.709
#> 5 5 0.786           0.743       0.838         0.0678 0.918   0.723
#> 6 6 0.769           0.595       0.799         0.0380 0.931   0.741

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     3  0.5678    0.52665 0.000 0.316 0.684
#> GSM802144     2  0.6111    0.42659 0.000 0.604 0.396
#> GSM802153     3  0.0000    0.70630 0.000 0.000 1.000
#> GSM802156     3  0.0892    0.70177 0.000 0.020 0.980
#> GSM802165     2  0.3686    0.66124 0.000 0.860 0.140
#> GSM802168     2  0.6260    0.30476 0.000 0.552 0.448
#> GSM802177     3  0.6180    0.26169 0.000 0.416 0.584
#> GSM802180     3  0.5560    0.58131 0.000 0.300 0.700
#> GSM802189     3  0.4235    0.70488 0.000 0.176 0.824
#> GSM802192     3  0.6295    0.15872 0.000 0.472 0.528
#> GSM802143     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802146     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802155     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802158     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802167     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802170     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802179     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802182     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802191     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802194     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802142     3  0.3038    0.72698 0.000 0.104 0.896
#> GSM802145     2  0.2625    0.66682 0.000 0.916 0.084
#> GSM802154     3  0.0424    0.70468 0.000 0.008 0.992
#> GSM802157     3  0.0424    0.70468 0.000 0.008 0.992
#> GSM802166     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802169     2  0.5254    0.59475 0.000 0.736 0.264
#> GSM802178     2  0.1643    0.65535 0.000 0.956 0.044
#> GSM802181     2  0.6252    0.31329 0.000 0.556 0.444
#> GSM802190     3  0.4654    0.68595 0.000 0.208 0.792
#> GSM802193     2  0.0424    0.63004 0.000 0.992 0.008
#> GSM802135     2  0.1529    0.65530 0.000 0.960 0.040
#> GSM802138     3  0.6192    0.32751 0.000 0.420 0.580
#> GSM802147     2  0.6140    0.38599 0.000 0.596 0.404
#> GSM802150     3  0.5327    0.62342 0.000 0.272 0.728
#> GSM802159     3  0.4555    0.61752 0.000 0.200 0.800
#> GSM802162     3  0.0424    0.70468 0.000 0.008 0.992
#> GSM802171     2  0.6308    0.00567 0.000 0.508 0.492
#> GSM802174     3  0.5678    0.55090 0.000 0.316 0.684
#> GSM802183     3  0.2959    0.72774 0.000 0.100 0.900
#> GSM802186     3  0.2537    0.72724 0.000 0.080 0.920
#> GSM802137     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802140     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802149     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802151     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802161     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802163     3  0.0424    0.70468 0.000 0.008 0.992
#> GSM802173     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802175     3  0.4931    0.66271 0.000 0.232 0.768
#> GSM802185     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802188     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802136     3  0.6168    0.35544 0.000 0.412 0.588
#> GSM802139     2  0.6225    0.34605 0.000 0.568 0.432
#> GSM802148     2  0.0000    0.62697 0.000 1.000 0.000
#> GSM802152     3  0.0000    0.70630 0.000 0.000 1.000
#> GSM802160     1  0.0237    0.99598 0.996 0.004 0.000
#> GSM802164     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802172     2  0.3619    0.66747 0.000 0.864 0.136
#> GSM802176     1  0.0000    0.99981 1.000 0.000 0.000
#> GSM802184     3  0.5397    0.60511 0.000 0.280 0.720
#> GSM802187     3  0.1529    0.72054 0.000 0.040 0.960

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.4933      0.496 0.000 0.568 0.432 0.000
#> GSM802144     3  0.5624      0.613 0.000 0.148 0.724 0.128
#> GSM802153     2  0.1302      0.475 0.000 0.956 0.044 0.000
#> GSM802156     2  0.4790     -0.194 0.000 0.620 0.000 0.380
#> GSM802165     4  0.0188      0.796 0.000 0.000 0.004 0.996
#> GSM802168     3  0.4711      0.545 0.000 0.236 0.740 0.024
#> GSM802177     3  0.5268     -0.188 0.000 0.452 0.540 0.008
#> GSM802180     2  0.5119      0.466 0.000 0.556 0.440 0.004
#> GSM802189     2  0.4830      0.543 0.000 0.608 0.392 0.000
#> GSM802192     4  0.0524      0.796 0.000 0.008 0.004 0.988
#> GSM802143     1  0.0188      0.996 0.996 0.000 0.000 0.004
#> GSM802146     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0336      0.992 0.992 0.008 0.000 0.000
#> GSM802158     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802167     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802142     2  0.5004      0.544 0.000 0.604 0.392 0.004
#> GSM802145     3  0.3831      0.422 0.000 0.004 0.792 0.204
#> GSM802154     2  0.0000      0.458 0.000 1.000 0.000 0.000
#> GSM802157     2  0.0817      0.436 0.000 0.976 0.000 0.024
#> GSM802166     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802169     3  0.4054      0.531 0.000 0.016 0.796 0.188
#> GSM802178     4  0.4843      0.485 0.000 0.000 0.396 0.604
#> GSM802181     3  0.4990      0.275 0.000 0.352 0.640 0.008
#> GSM802190     2  0.5024      0.547 0.000 0.632 0.360 0.008
#> GSM802193     4  0.3610      0.730 0.000 0.000 0.200 0.800
#> GSM802135     4  0.0336      0.796 0.000 0.000 0.008 0.992
#> GSM802138     4  0.4716      0.709 0.000 0.040 0.196 0.764
#> GSM802147     4  0.1284      0.796 0.000 0.024 0.012 0.964
#> GSM802150     2  0.4830      0.531 0.000 0.608 0.392 0.000
#> GSM802159     4  0.1940      0.773 0.000 0.076 0.000 0.924
#> GSM802162     2  0.0000      0.458 0.000 1.000 0.000 0.000
#> GSM802171     4  0.4647      0.588 0.000 0.008 0.288 0.704
#> GSM802174     2  0.5444      0.468 0.000 0.560 0.424 0.016
#> GSM802183     2  0.4866      0.536 0.000 0.596 0.404 0.000
#> GSM802186     2  0.4776      0.552 0.000 0.624 0.376 0.000
#> GSM802137     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802151     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802161     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802163     2  0.0000      0.458 0.000 1.000 0.000 0.000
#> GSM802173     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802175     2  0.5080      0.510 0.000 0.576 0.420 0.004
#> GSM802185     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802136     4  0.4224      0.747 0.000 0.044 0.144 0.812
#> GSM802139     3  0.3881      0.597 0.000 0.172 0.812 0.016
#> GSM802148     4  0.1118      0.799 0.000 0.000 0.036 0.964
#> GSM802152     2  0.3311      0.512 0.000 0.828 0.172 0.000
#> GSM802160     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802164     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802172     4  0.4967      0.287 0.000 0.000 0.452 0.548
#> GSM802176     1  0.0000      0.999 1.000 0.000 0.000 0.000
#> GSM802184     2  0.5088      0.503 0.000 0.572 0.424 0.004
#> GSM802187     2  0.4500      0.548 0.000 0.684 0.316 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
#> GSM802141     3  0.5819     0.5342 0.000 0.252 0.600 0.000 0.148
#> GSM802144     5  0.3496     0.9242 0.000 0.116 0.028 0.016 0.840
#> GSM802153     3  0.1310     0.6507 0.000 0.020 0.956 0.000 0.024
#> GSM802156     3  0.4162     0.2819 0.000 0.004 0.680 0.312 0.004
#> GSM802165     4  0.0566     0.8351 0.000 0.004 0.000 0.984 0.012
#> GSM802168     2  0.2291     0.6688 0.000 0.908 0.072 0.008 0.012
#> GSM802177     2  0.1644     0.6619 0.000 0.940 0.048 0.004 0.008
#> GSM802180     2  0.4366     0.4205 0.000 0.664 0.320 0.000 0.016
#> GSM802189     3  0.4987     0.4655 0.000 0.340 0.616 0.000 0.044
#> GSM802192     4  0.0854     0.8402 0.000 0.012 0.004 0.976 0.008
#> GSM802143     1  0.0510     0.9879 0.984 0.000 0.000 0.000 0.016
#> GSM802146     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802155     1  0.1701     0.9462 0.936 0.000 0.048 0.000 0.016
#> GSM802158     1  0.0609     0.9889 0.980 0.000 0.000 0.000 0.020
#> GSM802167     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802170     1  0.0162     0.9902 0.996 0.000 0.000 0.000 0.004
#> GSM802179     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802182     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802191     1  0.0000     0.9904 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0404     0.9886 0.988 0.000 0.000 0.000 0.012
#> GSM802142     3  0.5961     0.4618 0.000 0.132 0.552 0.000 0.316
#> GSM802145     5  0.2519     0.9163 0.000 0.100 0.000 0.016 0.884
#> GSM802154     3  0.0404     0.6385 0.000 0.000 0.988 0.012 0.000
#> GSM802157     3  0.1282     0.6201 0.000 0.004 0.952 0.044 0.000
#> GSM802166     1  0.0000     0.9904 1.000 0.000 0.000 0.000 0.000
#> GSM802169     2  0.3299     0.6200 0.000 0.848 0.004 0.108 0.040
#> GSM802178     4  0.5036     0.3074 0.000 0.404 0.000 0.560 0.036
#> GSM802181     2  0.2124     0.6636 0.000 0.900 0.096 0.000 0.004
#> GSM802190     2  0.5295     0.2289 0.000 0.532 0.428 0.012 0.028
#> GSM802193     2  0.4763     0.3521 0.000 0.712 0.000 0.212 0.076
#> GSM802135     4  0.1956     0.8026 0.000 0.008 0.000 0.916 0.076
#> GSM802138     5  0.4248     0.9213 0.000 0.092 0.016 0.092 0.800
#> GSM802147     4  0.2763     0.7982 0.000 0.148 0.004 0.848 0.000
#> GSM802150     3  0.6326     0.3881 0.000 0.172 0.492 0.000 0.336
#> GSM802159     4  0.0963     0.8250 0.000 0.000 0.036 0.964 0.000
#> GSM802162     3  0.0703     0.6349 0.000 0.000 0.976 0.024 0.000
#> GSM802171     4  0.3336     0.7678 0.000 0.144 0.008 0.832 0.016
#> GSM802174     2  0.3815     0.5734 0.000 0.764 0.220 0.004 0.012
#> GSM802183     3  0.4851     0.4541 0.000 0.340 0.624 0.000 0.036
#> GSM802186     3  0.4541     0.5321 0.000 0.288 0.680 0.000 0.032
#> GSM802137     1  0.0404     0.9896 0.988 0.000 0.000 0.000 0.012
#> GSM802140     1  0.0609     0.9873 0.980 0.000 0.000 0.000 0.020
#> GSM802149     1  0.0510     0.9895 0.984 0.000 0.000 0.000 0.016
#> GSM802151     1  0.0609     0.9889 0.980 0.000 0.000 0.000 0.020
#> GSM802161     1  0.0510     0.9881 0.984 0.000 0.000 0.000 0.016
#> GSM802163     3  0.0671     0.6386 0.000 0.004 0.980 0.016 0.000
#> GSM802173     1  0.0162     0.9902 0.996 0.000 0.000 0.000 0.004
#> GSM802175     3  0.5520     0.3974 0.000 0.364 0.560 0.000 0.076
#> GSM802185     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802188     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802136     5  0.4342     0.9204 0.000 0.092 0.020 0.092 0.796
#> GSM802139     5  0.3599     0.8868 0.000 0.160 0.020 0.008 0.812
#> GSM802148     4  0.2358     0.8316 0.000 0.104 0.000 0.888 0.008
#> GSM802152     3  0.4168     0.6309 0.000 0.184 0.764 0.000 0.052
#> GSM802160     1  0.0404     0.9891 0.988 0.000 0.000 0.000 0.012
#> GSM802164     1  0.0290     0.9897 0.992 0.000 0.000 0.000 0.008
#> GSM802172     2  0.4620     0.1093 0.000 0.592 0.000 0.392 0.016
#> GSM802176     1  0.0290     0.9903 0.992 0.000 0.000 0.000 0.008
#> GSM802184     2  0.5024     0.0021 0.000 0.528 0.440 0.000 0.032
#> GSM802187     3  0.4121     0.6488 0.000 0.100 0.788 0.000 0.112

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.6965   0.105509 0.000 0.392 0.364 0.128 0.116 0.000
#> GSM802144     4  0.1237   0.842128 0.000 0.020 0.020 0.956 0.000 0.004
#> GSM802153     3  0.2968   0.579987 0.000 0.056 0.868 0.032 0.044 0.000
#> GSM802156     3  0.3862   0.212814 0.000 0.000 0.608 0.000 0.004 0.388
#> GSM802165     6  0.0972   0.565217 0.000 0.000 0.000 0.028 0.008 0.964
#> GSM802168     2  0.2520   0.506882 0.000 0.888 0.024 0.004 0.076 0.008
#> GSM802177     2  0.3408   0.495764 0.000 0.800 0.048 0.000 0.152 0.000
#> GSM802180     2  0.3974   0.522463 0.000 0.728 0.224 0.000 0.048 0.000
#> GSM802189     3  0.4437  -0.123483 0.000 0.464 0.516 0.012 0.004 0.004
#> GSM802192     6  0.3809   0.481578 0.000 0.048 0.052 0.000 0.088 0.812
#> GSM802143     1  0.1088   0.953863 0.960 0.000 0.000 0.016 0.024 0.000
#> GSM802146     1  0.1285   0.955341 0.944 0.000 0.000 0.004 0.052 0.000
#> GSM802155     1  0.2492   0.868899 0.876 0.000 0.100 0.004 0.020 0.000
#> GSM802158     1  0.0692   0.954439 0.976 0.000 0.000 0.004 0.020 0.000
#> GSM802167     1  0.1141   0.952535 0.948 0.000 0.000 0.000 0.052 0.000
#> GSM802170     1  0.1075   0.954369 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM802179     1  0.1204   0.951182 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM802182     1  0.0146   0.957263 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802191     1  0.0547   0.958306 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM802194     1  0.2135   0.896027 0.872 0.000 0.000 0.000 0.128 0.000
#> GSM802142     3  0.4866   0.300369 0.000 0.068 0.568 0.364 0.000 0.000
#> GSM802145     4  0.0653   0.836197 0.000 0.012 0.004 0.980 0.000 0.004
#> GSM802154     3  0.0458   0.609207 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM802157     3  0.2871   0.516302 0.000 0.000 0.804 0.000 0.004 0.192
#> GSM802166     1  0.1007   0.955731 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM802169     2  0.4570   0.224288 0.000 0.644 0.012 0.000 0.308 0.036
#> GSM802178     2  0.5754   0.152253 0.000 0.536 0.004 0.000 0.212 0.248
#> GSM802181     2  0.4788   0.405418 0.000 0.636 0.072 0.000 0.288 0.004
#> GSM802190     3  0.6654  -0.102373 0.000 0.288 0.352 0.000 0.332 0.028
#> GSM802193     5  0.3873   0.000000 0.000 0.104 0.000 0.000 0.772 0.124
#> GSM802135     6  0.2501   0.534215 0.000 0.004 0.000 0.108 0.016 0.872
#> GSM802138     4  0.2263   0.841809 0.000 0.036 0.004 0.900 0.000 0.060
#> GSM802147     6  0.6401  -0.023647 0.000 0.332 0.004 0.012 0.236 0.416
#> GSM802150     2  0.6256   0.261524 0.000 0.448 0.312 0.228 0.004 0.008
#> GSM802159     6  0.1109   0.562988 0.000 0.004 0.016 0.004 0.012 0.964
#> GSM802162     3  0.1462   0.599679 0.000 0.000 0.936 0.000 0.008 0.056
#> GSM802171     6  0.4736   0.307226 0.000 0.300 0.028 0.012 0.012 0.648
#> GSM802174     2  0.4239   0.520008 0.000 0.740 0.072 0.000 0.180 0.008
#> GSM802183     3  0.5305   0.053582 0.000 0.408 0.512 0.016 0.064 0.000
#> GSM802186     3  0.4973   0.222244 0.000 0.356 0.584 0.024 0.036 0.000
#> GSM802137     1  0.1462   0.954646 0.936 0.000 0.000 0.008 0.056 0.000
#> GSM802140     1  0.1908   0.945198 0.916 0.000 0.000 0.028 0.056 0.000
#> GSM802149     1  0.0458   0.955845 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802151     1  0.0777   0.957917 0.972 0.000 0.000 0.004 0.024 0.000
#> GSM802161     1  0.0893   0.953956 0.972 0.000 0.004 0.004 0.016 0.004
#> GSM802163     3  0.0717   0.609649 0.000 0.008 0.976 0.000 0.000 0.016
#> GSM802173     1  0.1007   0.953866 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM802175     2  0.4275   0.344196 0.000 0.592 0.388 0.016 0.004 0.000
#> GSM802185     1  0.0291   0.957051 0.992 0.000 0.000 0.004 0.004 0.000
#> GSM802188     1  0.0146   0.957263 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802136     4  0.2237   0.837155 0.000 0.024 0.004 0.904 0.004 0.064
#> GSM802139     4  0.3508   0.506726 0.000 0.292 0.000 0.704 0.004 0.000
#> GSM802148     6  0.6529   0.000458 0.000 0.188 0.000 0.044 0.304 0.464
#> GSM802152     2  0.5278   0.214323 0.000 0.508 0.424 0.020 0.044 0.004
#> GSM802160     1  0.2872   0.815810 0.832 0.004 0.000 0.012 0.152 0.000
#> GSM802164     1  0.0547   0.955525 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM802172     2  0.4873   0.324130 0.000 0.676 0.004 0.000 0.164 0.156
#> GSM802176     1  0.0458   0.959209 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802184     2  0.4601   0.526360 0.000 0.692 0.224 0.008 0.076 0.000
#> GSM802187     3  0.2444   0.592811 0.000 0.036 0.896 0.052 0.016 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) protocol(p)  time(p) individual(p) k
#> MAD:NMF 60            1.000    4.43e-09 0.000103         1.000 2
#> MAD:NMF 50            0.705    4.45e-07 0.000264         0.809 3
#> MAD:NMF 46            0.324    9.25e-06 0.000291         0.373 4
#> MAD:NMF 48            0.506    7.71e-06 0.000160         0.226 5
#> MAD:NMF 40            0.980    4.46e-05 0.000160         0.737 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'hclust' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-hclust-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.837           0.944       0.968         0.1255 0.959   0.923
#> 4 4 0.819           0.871       0.927         0.0780 1.000   1.000
#> 5 5 0.789           0.778       0.896         0.0623 0.921   0.838
#> 6 6 0.724           0.758       0.858         0.1143 0.892   0.740

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

suggest_best_k(res)
#> [1] 2

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

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

show/hide code output

cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#>           class entropy silhouette p1 p2
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802144     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802153     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802156     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802165     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802168     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802177     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802180     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802189     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802192     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802143     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802146     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802155     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802158     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802167     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802194     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802142     2  0.0592      0.938 0.000 0.988 0.012
#> GSM802145     2  0.0592      0.938 0.000 0.988 0.012
#> GSM802154     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802157     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802166     1  0.0424      0.993 0.992 0.000 0.008
#> GSM802169     2  0.0237      0.943 0.000 0.996 0.004
#> GSM802178     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802181     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802190     2  0.0592      0.938 0.000 0.988 0.012
#> GSM802193     3  0.4555      1.000 0.000 0.200 0.800
#> GSM802135     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802138     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802147     2  0.3116      0.828 0.000 0.892 0.108
#> GSM802150     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802159     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802162     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802171     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802174     2  0.0424      0.940 0.000 0.992 0.008
#> GSM802183     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802186     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802137     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802140     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802149     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802151     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802161     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802163     2  0.4452      0.778 0.000 0.808 0.192
#> GSM802173     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802175     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802185     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802188     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802136     2  0.0424      0.941 0.000 0.992 0.008
#> GSM802139     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802148     3  0.4555      1.000 0.000 0.200 0.800
#> GSM802152     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802160     1  0.0424      0.993 0.992 0.000 0.008
#> GSM802164     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802172     2  0.0000      0.945 0.000 1.000 0.000
#> GSM802176     1  0.0000      0.999 1.000 0.000 0.000
#> GSM802184     2  0.0592      0.938 0.000 0.988 0.012
#> GSM802187     2  0.0592      0.938 0.000 0.988 0.012

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> GSM802141     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802144     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802153     2  0.3726      0.785 0.000 0.788 NA 0.000
#> GSM802156     2  0.3726      0.785 0.000 0.788 NA 0.000
#> GSM802165     2  0.1022      0.912 0.000 0.968 NA 0.000
#> GSM802168     2  0.0469      0.922 0.000 0.988 NA 0.000
#> GSM802177     2  0.0000      0.925 0.000 1.000 NA 0.000
#> GSM802180     2  0.0000      0.925 0.000 1.000 NA 0.000
#> GSM802189     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802192     2  0.1022      0.912 0.000 0.968 NA 0.000
#> GSM802143     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802146     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802155     1  0.3219      0.853 0.836 0.000 NA 0.000
#> GSM802158     1  0.3074      0.860 0.848 0.000 NA 0.000
#> GSM802167     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802170     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802179     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802182     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802191     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802194     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802142     2  0.0657      0.922 0.000 0.984 NA 0.012
#> GSM802145     2  0.0657      0.922 0.000 0.984 NA 0.012
#> GSM802154     2  0.3726      0.785 0.000 0.788 NA 0.000
#> GSM802157     2  0.3726      0.785 0.000 0.788 NA 0.000
#> GSM802166     1  0.4866      0.601 0.596 0.000 NA 0.000
#> GSM802169     2  0.0376      0.924 0.000 0.992 NA 0.004
#> GSM802178     2  0.0469      0.922 0.000 0.988 NA 0.000
#> GSM802181     2  0.0000      0.925 0.000 1.000 NA 0.000
#> GSM802190     2  0.0657      0.922 0.000 0.984 NA 0.012
#> GSM802193     4  0.0000      1.000 0.000 0.000 NA 1.000
#> GSM802135     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802138     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802147     2  0.6775      0.199 0.000 0.516 NA 0.100
#> GSM802150     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802159     2  0.3837      0.783 0.000 0.776 NA 0.000
#> GSM802162     2  0.3726      0.785 0.000 0.788 NA 0.000
#> GSM802171     2  0.0469      0.922 0.000 0.988 NA 0.000
#> GSM802174     2  0.4804      0.452 0.000 0.616 NA 0.000
#> GSM802183     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802186     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802137     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802140     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802149     1  0.2281      0.886 0.904 0.000 NA 0.000
#> GSM802151     1  0.3219      0.853 0.836 0.000 NA 0.000
#> GSM802161     1  0.3528      0.835 0.808 0.000 NA 0.000
#> GSM802163     2  0.3726      0.785 0.000 0.788 NA 0.000
#> GSM802173     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802175     2  0.0000      0.925 0.000 1.000 NA 0.000
#> GSM802185     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802188     1  0.3528      0.835 0.808 0.000 NA 0.000
#> GSM802136     2  0.0524      0.923 0.000 0.988 NA 0.008
#> GSM802139     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802148     4  0.0000      1.000 0.000 0.000 NA 1.000
#> GSM802152     2  0.0188      0.925 0.000 0.996 NA 0.000
#> GSM802160     1  0.4866      0.601 0.596 0.000 NA 0.000
#> GSM802164     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802172     2  0.0469      0.922 0.000 0.988 NA 0.000
#> GSM802176     1  0.0000      0.921 1.000 0.000 NA 0.000
#> GSM802184     2  0.0657      0.922 0.000 0.984 NA 0.012
#> GSM802187     2  0.0657      0.922 0.000 0.984 NA 0.012

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.0000     0.9084 0.000 1.000 0.000 0.000 0.000
#> GSM802144     2  0.0000     0.9084 0.000 1.000 0.000 0.000 0.000
#> GSM802153     2  0.3530     0.6362 0.000 0.784 0.012 0.000 0.204
#> GSM802156     2  0.3596     0.6215 0.000 0.776 0.012 0.000 0.212
#> GSM802165     2  0.1121     0.8786 0.000 0.956 0.044 0.000 0.000
#> GSM802168     2  0.0510     0.9043 0.000 0.984 0.016 0.000 0.000
#> GSM802177     2  0.0162     0.9084 0.000 0.996 0.004 0.000 0.000
#> GSM802180     2  0.0162     0.9084 0.000 0.996 0.004 0.000 0.000
#> GSM802189     2  0.0290     0.9080 0.000 0.992 0.008 0.000 0.000
#> GSM802192     2  0.1121     0.8786 0.000 0.956 0.044 0.000 0.000
#> GSM802143     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802155     1  0.4273    -0.0248 0.552 0.000 0.000 0.000 0.448
#> GSM802158     1  0.4256     0.0154 0.564 0.000 0.000 0.000 0.436
#> GSM802167     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0162     0.8508 0.996 0.000 0.000 0.000 0.004
#> GSM802191     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.0404     0.9042 0.000 0.988 0.000 0.012 0.000
#> GSM802145     2  0.0404     0.9042 0.000 0.988 0.000 0.012 0.000
#> GSM802154     2  0.3530     0.6362 0.000 0.784 0.012 0.000 0.204
#> GSM802157     2  0.3596     0.6215 0.000 0.776 0.012 0.000 0.212
#> GSM802166     5  0.6584     0.6264 0.208 0.000 0.380 0.000 0.412
#> GSM802169     2  0.0162     0.9078 0.000 0.996 0.000 0.004 0.000
#> GSM802178     2  0.0510     0.9043 0.000 0.984 0.016 0.000 0.000
#> GSM802181     2  0.0162     0.9084 0.000 0.996 0.004 0.000 0.000
#> GSM802190     2  0.0404     0.9042 0.000 0.988 0.000 0.012 0.000
#> GSM802193     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM802135     2  0.0510     0.9045 0.000 0.984 0.016 0.000 0.000
#> GSM802138     2  0.0510     0.9045 0.000 0.984 0.016 0.000 0.000
#> GSM802147     3  0.5426     0.7466 0.000 0.308 0.608 0.084 0.000
#> GSM802150     2  0.0000     0.9084 0.000 1.000 0.000 0.000 0.000
#> GSM802159     2  0.4233     0.5885 0.000 0.748 0.044 0.000 0.208
#> GSM802162     2  0.3596     0.6215 0.000 0.776 0.012 0.000 0.212
#> GSM802171     2  0.0510     0.9043 0.000 0.984 0.016 0.000 0.000
#> GSM802174     3  0.4219     0.7865 0.000 0.416 0.584 0.000 0.000
#> GSM802183     2  0.0000     0.9084 0.000 1.000 0.000 0.000 0.000
#> GSM802186     2  0.0000     0.9084 0.000 1.000 0.000 0.000 0.000
#> GSM802137     1  0.0000     0.8513 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0404     0.8444 0.988 0.000 0.000 0.000 0.012
#> GSM802149     1  0.4201    -0.0523 0.592 0.000 0.000 0.000 0.408
#> GSM802151     1  0.4273    -0.0248 0.552 0.000 0.000 0.000 0.448
#> GSM802161     5  0.3837     0.6368 0.308 0.000 0.000 0.000 0.692
#> GSM802163     2  0.3530     0.6362 0.000 0.784 0.012 0.000 0.204
#> GSM802173     1  0.0162     0.8508 0.996 0.000 0.000 0.000 0.004
#> GSM802175     2  0.0162     0.9084 0.000 0.996 0.004 0.000 0.000
#> GSM802185     1  0.0162     0.8508 0.996 0.000 0.000 0.000 0.004
#> GSM802188     5  0.3837     0.6368 0.308 0.000 0.000 0.000 0.692
#> GSM802136     2  0.0798     0.9014 0.000 0.976 0.016 0.008 0.000
#> GSM802139     2  0.0510     0.9045 0.000 0.984 0.016 0.000 0.000
#> GSM802148     4  0.0000     1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM802152     2  0.0000     0.9084 0.000 1.000 0.000 0.000 0.000
#> GSM802160     5  0.6584     0.6264 0.208 0.000 0.380 0.000 0.412
#> GSM802164     1  0.0162     0.8508 0.996 0.000 0.000 0.000 0.004
#> GSM802172     2  0.0510     0.9043 0.000 0.984 0.016 0.000 0.000
#> GSM802176     1  0.0162     0.8508 0.996 0.000 0.000 0.000 0.004
#> GSM802184     2  0.0404     0.9042 0.000 0.988 0.000 0.012 0.000
#> GSM802187     2  0.0404     0.9042 0.000 0.988 0.000 0.012 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
#> GSM802141     2  0.0146      0.840 0.000 0.996 0.004 0.000 0.000  0
#> GSM802144     2  0.0937      0.829 0.000 0.960 0.040 0.000 0.000  0
#> GSM802153     2  0.3428      0.144 0.000 0.696 0.304 0.000 0.000  0
#> GSM802156     3  0.3620      0.888 0.000 0.352 0.648 0.000 0.000  0
#> GSM802165     2  0.3455      0.636 0.000 0.800 0.144 0.056 0.000  0
#> GSM802168     2  0.1528      0.820 0.000 0.936 0.048 0.016 0.000  0
#> GSM802177     2  0.0260      0.841 0.000 0.992 0.008 0.000 0.000  0
#> GSM802180     2  0.0146      0.842 0.000 0.996 0.004 0.000 0.000  0
#> GSM802189     2  0.1549      0.824 0.000 0.936 0.044 0.020 0.000  0
#> GSM802192     2  0.3455      0.636 0.000 0.800 0.144 0.056 0.000  0
#> GSM802143     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802146     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802155     5  0.3620      0.555 0.352 0.000 0.000 0.000 0.648  0
#> GSM802158     5  0.3659      0.540 0.364 0.000 0.000 0.000 0.636  0
#> GSM802167     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802170     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802179     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802182     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.004  0
#> GSM802191     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802194     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802142     2  0.2092      0.756 0.000 0.876 0.124 0.000 0.000  0
#> GSM802145     2  0.2092      0.756 0.000 0.876 0.124 0.000 0.000  0
#> GSM802154     2  0.3428      0.144 0.000 0.696 0.304 0.000 0.000  0
#> GSM802157     3  0.3620      0.888 0.000 0.352 0.648 0.000 0.000  0
#> GSM802166     5  0.7292      0.221 0.128 0.000 0.224 0.240 0.408  0
#> GSM802169     2  0.0790      0.833 0.000 0.968 0.032 0.000 0.000  0
#> GSM802178     2  0.1657      0.814 0.000 0.928 0.056 0.016 0.000  0
#> GSM802181     2  0.0146      0.842 0.000 0.996 0.004 0.000 0.000  0
#> GSM802190     2  0.2092      0.756 0.000 0.876 0.124 0.000 0.000  0
#> GSM802193     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000  1
#> GSM802135     2  0.1644      0.824 0.000 0.932 0.040 0.028 0.000  0
#> GSM802138     2  0.1644      0.824 0.000 0.932 0.040 0.028 0.000  0
#> GSM802147     4  0.3928      0.646 0.000 0.160 0.080 0.760 0.000  0
#> GSM802150     2  0.0260      0.841 0.000 0.992 0.008 0.000 0.000  0
#> GSM802159     3  0.4841      0.683 0.000 0.436 0.508 0.056 0.000  0
#> GSM802162     3  0.3620      0.888 0.000 0.352 0.648 0.000 0.000  0
#> GSM802171     2  0.1528      0.820 0.000 0.936 0.048 0.016 0.000  0
#> GSM802174     4  0.5119      0.531 0.000 0.264 0.128 0.608 0.000  0
#> GSM802183     2  0.0363      0.841 0.000 0.988 0.012 0.000 0.000  0
#> GSM802186     2  0.0363      0.841 0.000 0.988 0.012 0.000 0.000  0
#> GSM802137     1  0.0000      0.997 1.000 0.000 0.000 0.000 0.000  0
#> GSM802140     1  0.0363      0.987 0.988 0.000 0.000 0.000 0.012  0
#> GSM802149     5  0.3515      0.484 0.324 0.000 0.000 0.000 0.676  0
#> GSM802151     5  0.3620      0.555 0.352 0.000 0.000 0.000 0.648  0
#> GSM802161     5  0.0790      0.455 0.032 0.000 0.000 0.000 0.968  0
#> GSM802163     2  0.3765     -0.382 0.000 0.596 0.404 0.000 0.000  0
#> GSM802173     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.004  0
#> GSM802175     2  0.0790      0.833 0.000 0.968 0.032 0.000 0.000  0
#> GSM802185     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.004  0
#> GSM802188     5  0.1663      0.498 0.088 0.000 0.000 0.000 0.912  0
#> GSM802136     2  0.2696      0.758 0.000 0.856 0.116 0.028 0.000  0
#> GSM802139     2  0.1421      0.828 0.000 0.944 0.028 0.028 0.000  0
#> GSM802148     6  0.0000      1.000 0.000 0.000 0.000 0.000 0.000  1
#> GSM802152     2  0.0547      0.837 0.000 0.980 0.020 0.000 0.000  0
#> GSM802160     5  0.7292      0.221 0.128 0.000 0.224 0.240 0.408  0
#> GSM802164     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.004  0
#> GSM802172     2  0.1528      0.820 0.000 0.936 0.048 0.016 0.000  0
#> GSM802176     1  0.0146      0.996 0.996 0.000 0.000 0.000 0.004  0
#> GSM802184     2  0.2135      0.758 0.000 0.872 0.128 0.000 0.000  0
#> GSM802187     2  0.2092      0.756 0.000 0.876 0.124 0.000 0.000  0

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

consensus_heatmap(res, k = 2)

plot of chunk tab-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) protocol(p)  time(p) individual(p) k
#> ATC:hclust 60            1.000    4.43e-09 1.03e-04         1.000 2
#> ATC:hclust 60            1.000    1.40e-08 4.54e-05         0.986 3
#> ATC:hclust 58            0.976    3.61e-08 9.99e-05         0.918 4
#> ATC:hclust 56            0.493    1.66e-06 7.49e-04         0.486 5
#> ATC:hclust 52            0.764    9.98e-07 1.43e-03         0.140 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 22263 rows and 60 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.4728 0.528   0.528
#> 3 3 0.657           0.580       0.846         0.2481 0.959   0.923
#> 4 4 0.598           0.511       0.749         0.1333 0.941   0.879
#> 5 5 0.585           0.547       0.704         0.0796 0.862   0.681
#> 6 6 0.603           0.643       0.711         0.0701 0.858   0.551

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.5465      0.093 0.000 0.712 0.288
#> GSM802144     2  0.5835     -0.113 0.000 0.660 0.340
#> GSM802153     2  0.1964      0.644 0.000 0.944 0.056
#> GSM802156     2  0.3941      0.549 0.000 0.844 0.156
#> GSM802165     2  0.2625      0.629 0.000 0.916 0.084
#> GSM802168     2  0.1411      0.659 0.000 0.964 0.036
#> GSM802177     2  0.0000      0.665 0.000 1.000 0.000
#> GSM802180     2  0.0000      0.665 0.000 1.000 0.000
#> GSM802189     2  0.0424      0.664 0.000 0.992 0.008
#> GSM802192     2  0.1411      0.662 0.000 0.964 0.036
#> GSM802143     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802146     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802155     1  0.5291      0.843 0.732 0.000 0.268
#> GSM802158     1  0.4750      0.861 0.784 0.000 0.216
#> GSM802167     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802194     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802142     2  0.5785     -0.165 0.000 0.668 0.332
#> GSM802145     2  0.6192     -0.467 0.000 0.580 0.420
#> GSM802154     2  0.3941      0.550 0.000 0.844 0.156
#> GSM802157     2  0.3941      0.549 0.000 0.844 0.156
#> GSM802166     1  0.5465      0.833 0.712 0.000 0.288
#> GSM802169     2  0.5926     -0.224 0.000 0.644 0.356
#> GSM802178     2  0.1964      0.650 0.000 0.944 0.056
#> GSM802181     2  0.5397      0.129 0.000 0.720 0.280
#> GSM802190     2  0.5706     -0.108 0.000 0.680 0.320
#> GSM802193     3  0.6260      1.000 0.000 0.448 0.552
#> GSM802135     2  0.5529      0.135 0.000 0.704 0.296
#> GSM802138     2  0.5465      0.160 0.000 0.712 0.288
#> GSM802147     2  0.6204     -0.556 0.000 0.576 0.424
#> GSM802150     2  0.4555      0.411 0.000 0.800 0.200
#> GSM802159     2  0.4796      0.515 0.000 0.780 0.220
#> GSM802162     2  0.3941      0.549 0.000 0.844 0.156
#> GSM802171     2  0.1964      0.650 0.000 0.944 0.056
#> GSM802174     2  0.1643      0.661 0.000 0.956 0.044
#> GSM802183     2  0.0747      0.663 0.000 0.984 0.016
#> GSM802186     2  0.0747      0.663 0.000 0.984 0.016
#> GSM802137     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802140     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802149     1  0.5216      0.846 0.740 0.000 0.260
#> GSM802151     1  0.5291      0.843 0.732 0.000 0.268
#> GSM802161     1  0.5529      0.828 0.704 0.000 0.296
#> GSM802163     2  0.3941      0.549 0.000 0.844 0.156
#> GSM802173     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802175     2  0.0592      0.663 0.000 0.988 0.012
#> GSM802185     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802188     1  0.5216      0.846 0.740 0.000 0.260
#> GSM802136     2  0.6140     -0.403 0.000 0.596 0.404
#> GSM802139     2  0.1964      0.648 0.000 0.944 0.056
#> GSM802148     3  0.6260      1.000 0.000 0.448 0.552
#> GSM802152     2  0.1163      0.661 0.000 0.972 0.028
#> GSM802160     1  0.5465      0.833 0.712 0.000 0.288
#> GSM802164     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802172     2  0.1964      0.650 0.000 0.944 0.056
#> GSM802176     1  0.0000      0.919 1.000 0.000 0.000
#> GSM802184     2  0.1529      0.654 0.000 0.960 0.040
#> GSM802187     2  0.5733     -0.107 0.000 0.676 0.324

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2 p3    p4
#> GSM802141     2  0.5386    -0.0446 0.000 0.612 NA 0.368
#> GSM802144     2  0.5193    -0.1817 0.000 0.580 NA 0.412
#> GSM802153     2  0.4257     0.5227 0.000 0.812 NA 0.048
#> GSM802156     2  0.6611     0.2537 0.000 0.464 NA 0.080
#> GSM802165     2  0.3037     0.5642 0.000 0.888 NA 0.036
#> GSM802168     2  0.2060     0.5799 0.000 0.932 NA 0.016
#> GSM802177     2  0.1042     0.5790 0.000 0.972 NA 0.008
#> GSM802180     2  0.1042     0.5790 0.000 0.972 NA 0.008
#> GSM802189     2  0.1576     0.5855 0.000 0.948 NA 0.004
#> GSM802192     2  0.2376     0.5787 0.000 0.916 NA 0.016
#> GSM802143     1  0.0469     0.8493 0.988 0.000 NA 0.012
#> GSM802146     1  0.0592     0.8490 0.984 0.000 NA 0.016
#> GSM802155     1  0.6188     0.6972 0.548 0.000 NA 0.056
#> GSM802158     1  0.6023     0.7209 0.600 0.000 NA 0.056
#> GSM802167     1  0.0592     0.8490 0.984 0.000 NA 0.016
#> GSM802170     1  0.0188     0.8493 0.996 0.000 NA 0.004
#> GSM802179     1  0.0188     0.8493 0.996 0.000 NA 0.004
#> GSM802182     1  0.0000     0.8497 1.000 0.000 NA 0.000
#> GSM802191     1  0.0188     0.8493 0.996 0.000 NA 0.004
#> GSM802194     1  0.0592     0.8490 0.984 0.000 NA 0.016
#> GSM802142     2  0.5695    -0.3690 0.000 0.500 NA 0.476
#> GSM802145     4  0.5493     0.3748 0.000 0.456 NA 0.528
#> GSM802154     2  0.6980     0.2182 0.000 0.484 NA 0.116
#> GSM802157     2  0.6611     0.2537 0.000 0.464 NA 0.080
#> GSM802166     1  0.5724     0.6944 0.548 0.000 NA 0.028
#> GSM802169     2  0.4920    -0.0251 0.000 0.628 NA 0.368
#> GSM802178     2  0.2521     0.5738 0.000 0.912 NA 0.024
#> GSM802181     2  0.4599     0.2776 0.000 0.736 NA 0.248
#> GSM802190     2  0.5771    -0.3293 0.000 0.512 NA 0.460
#> GSM802193     4  0.4832     0.6221 0.000 0.176 NA 0.768
#> GSM802135     2  0.6141     0.0780 0.000 0.616 NA 0.312
#> GSM802138     2  0.4957     0.1424 0.000 0.684 NA 0.300
#> GSM802147     4  0.5923     0.4478 0.000 0.376 NA 0.580
#> GSM802150     2  0.3583     0.4155 0.000 0.816 NA 0.180
#> GSM802159     2  0.6798     0.2369 0.000 0.504 NA 0.100
#> GSM802162     2  0.6611     0.2537 0.000 0.464 NA 0.080
#> GSM802171     2  0.2521     0.5738 0.000 0.912 NA 0.024
#> GSM802174     2  0.2142     0.5811 0.000 0.928 NA 0.016
#> GSM802183     2  0.2830     0.5636 0.000 0.900 NA 0.040
#> GSM802186     2  0.2830     0.5636 0.000 0.900 NA 0.040
#> GSM802137     1  0.0469     0.8493 0.988 0.000 NA 0.012
#> GSM802140     1  0.0469     0.8493 0.988 0.000 NA 0.012
#> GSM802149     1  0.4916     0.7107 0.576 0.000 NA 0.000
#> GSM802151     1  0.6188     0.6972 0.548 0.000 NA 0.056
#> GSM802161     1  0.5288     0.6774 0.520 0.000 NA 0.008
#> GSM802163     2  0.6611     0.2537 0.000 0.464 NA 0.080
#> GSM802173     1  0.0000     0.8497 1.000 0.000 NA 0.000
#> GSM802175     2  0.2021     0.5819 0.000 0.932 NA 0.012
#> GSM802185     1  0.0000     0.8497 1.000 0.000 NA 0.000
#> GSM802188     1  0.4916     0.7107 0.576 0.000 NA 0.000
#> GSM802136     4  0.5597     0.3607 0.000 0.464 NA 0.516
#> GSM802139     2  0.2142     0.5545 0.000 0.928 NA 0.056
#> GSM802148     4  0.4907     0.6219 0.000 0.176 NA 0.764
#> GSM802152     2  0.3873     0.5316 0.000 0.844 NA 0.096
#> GSM802160     1  0.5724     0.6944 0.548 0.000 NA 0.028
#> GSM802164     1  0.1211     0.8416 0.960 0.000 NA 0.040
#> GSM802172     2  0.2521     0.5738 0.000 0.912 NA 0.024
#> GSM802176     1  0.0000     0.8497 1.000 0.000 NA 0.000
#> GSM802184     2  0.3754     0.5353 0.000 0.852 NA 0.084
#> GSM802187     2  0.5853    -0.3013 0.000 0.508 NA 0.460

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.7683     0.0987 0.000 0.448 0.080 0.196 0.276
#> GSM802144     2  0.7861    -0.0872 0.000 0.388 0.076 0.236 0.300
#> GSM802153     2  0.6026     0.3664 0.000 0.600 0.196 0.004 0.200
#> GSM802156     3  0.3816     0.9598 0.000 0.304 0.696 0.000 0.000
#> GSM802165     2  0.3963     0.4663 0.000 0.820 0.072 0.016 0.092
#> GSM802168     2  0.1341     0.5119 0.000 0.944 0.056 0.000 0.000
#> GSM802177     2  0.2871     0.5524 0.000 0.876 0.032 0.004 0.088
#> GSM802180     2  0.2871     0.5524 0.000 0.876 0.032 0.004 0.088
#> GSM802189     2  0.3148     0.5424 0.000 0.864 0.060 0.004 0.072
#> GSM802192     2  0.3148     0.4876 0.000 0.864 0.072 0.004 0.060
#> GSM802143     1  0.1872     0.8672 0.928 0.000 0.052 0.020 0.000
#> GSM802146     1  0.1943     0.8657 0.924 0.000 0.056 0.020 0.000
#> GSM802155     5  0.6274     0.8019 0.412 0.000 0.088 0.020 0.480
#> GSM802158     1  0.6281    -0.7505 0.472 0.000 0.088 0.020 0.420
#> GSM802167     1  0.1270     0.8782 0.948 0.000 0.052 0.000 0.000
#> GSM802170     1  0.0162     0.8865 0.996 0.000 0.004 0.000 0.000
#> GSM802179     1  0.0162     0.8865 0.996 0.000 0.004 0.000 0.000
#> GSM802182     1  0.0000     0.8867 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.8867 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.1270     0.8782 0.948 0.000 0.052 0.000 0.000
#> GSM802142     2  0.8130    -0.1697 0.000 0.332 0.100 0.312 0.256
#> GSM802145     4  0.7957     0.1292 0.000 0.320 0.076 0.332 0.272
#> GSM802154     3  0.4084     0.8333 0.000 0.328 0.668 0.000 0.004
#> GSM802157     3  0.3816     0.9598 0.000 0.304 0.696 0.000 0.000
#> GSM802166     5  0.6366     0.8056 0.400 0.000 0.072 0.036 0.492
#> GSM802169     2  0.7348     0.2129 0.000 0.508 0.068 0.192 0.232
#> GSM802178     2  0.2664     0.5020 0.000 0.892 0.064 0.004 0.040
#> GSM802181     2  0.6490     0.4079 0.000 0.620 0.080 0.092 0.208
#> GSM802190     2  0.8123    -0.1253 0.000 0.352 0.104 0.304 0.240
#> GSM802193     4  0.1792     0.5137 0.000 0.084 0.000 0.916 0.000
#> GSM802135     2  0.7040     0.2522 0.000 0.572 0.088 0.148 0.192
#> GSM802138     2  0.7094     0.2306 0.000 0.512 0.056 0.144 0.288
#> GSM802147     4  0.5044     0.3575 0.000 0.280 0.016 0.668 0.036
#> GSM802150     2  0.5652     0.4873 0.000 0.672 0.052 0.052 0.224
#> GSM802159     2  0.6034    -0.4970 0.000 0.472 0.440 0.016 0.072
#> GSM802162     3  0.3816     0.9598 0.000 0.304 0.696 0.000 0.000
#> GSM802171     2  0.2597     0.5016 0.000 0.896 0.060 0.004 0.040
#> GSM802174     2  0.1704     0.5060 0.000 0.928 0.068 0.000 0.004
#> GSM802183     2  0.4137     0.5307 0.000 0.792 0.076 0.004 0.128
#> GSM802186     2  0.4078     0.5302 0.000 0.796 0.072 0.004 0.128
#> GSM802137     1  0.1872     0.8672 0.928 0.000 0.052 0.020 0.000
#> GSM802140     1  0.1965     0.8662 0.924 0.000 0.052 0.024 0.000
#> GSM802149     5  0.4425     0.8348 0.452 0.000 0.000 0.004 0.544
#> GSM802151     5  0.6274     0.8019 0.412 0.000 0.088 0.020 0.480
#> GSM802161     5  0.4060     0.8325 0.360 0.000 0.000 0.000 0.640
#> GSM802163     3  0.3816     0.9598 0.000 0.304 0.696 0.000 0.000
#> GSM802173     1  0.0162     0.8862 0.996 0.000 0.000 0.004 0.000
#> GSM802175     2  0.1768     0.5031 0.000 0.924 0.072 0.000 0.004
#> GSM802185     1  0.0162     0.8862 0.996 0.000 0.000 0.004 0.000
#> GSM802188     5  0.4430     0.8310 0.456 0.000 0.000 0.004 0.540
#> GSM802136     4  0.7957     0.1292 0.000 0.320 0.076 0.332 0.272
#> GSM802139     2  0.3021     0.5471 0.000 0.872 0.060 0.004 0.064
#> GSM802148     4  0.1792     0.5137 0.000 0.084 0.000 0.916 0.000
#> GSM802152     2  0.5601     0.4896 0.000 0.644 0.124 0.004 0.228
#> GSM802160     5  0.6381     0.8056 0.400 0.000 0.068 0.040 0.492
#> GSM802164     1  0.1485     0.8322 0.948 0.000 0.032 0.020 0.000
#> GSM802172     2  0.2103     0.5060 0.000 0.920 0.056 0.004 0.020
#> GSM802176     1  0.0162     0.8862 0.996 0.000 0.000 0.004 0.000
#> GSM802184     2  0.5180     0.5195 0.000 0.728 0.100 0.024 0.148
#> GSM802187     2  0.8170    -0.1358 0.000 0.340 0.108 0.304 0.248

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.1841     0.5771 0.000 0.920 0.000 0.064 0.008 0.008
#> GSM802144     2  0.4211     0.5021 0.000 0.784 0.012 0.092 0.096 0.016
#> GSM802153     2  0.5796     0.2933 0.000 0.572 0.164 0.244 0.020 0.000
#> GSM802156     3  0.3213     0.9672 0.000 0.048 0.820 0.132 0.000 0.000
#> GSM802165     4  0.5215     0.6076 0.000 0.164 0.016 0.684 0.124 0.012
#> GSM802168     4  0.2915     0.6903 0.000 0.184 0.008 0.808 0.000 0.000
#> GSM802177     4  0.4049     0.3217 0.000 0.412 0.004 0.580 0.004 0.000
#> GSM802180     4  0.4056     0.3221 0.000 0.416 0.004 0.576 0.004 0.000
#> GSM802189     4  0.4243     0.3810 0.000 0.392 0.004 0.592 0.008 0.004
#> GSM802192     4  0.4647     0.6594 0.000 0.144 0.008 0.728 0.112 0.008
#> GSM802143     1  0.3048     0.8690 0.844 0.000 0.012 0.028 0.000 0.116
#> GSM802146     1  0.3123     0.8668 0.840 0.000 0.012 0.032 0.000 0.116
#> GSM802155     5  0.6329     0.8220 0.256 0.000 0.036 0.076 0.580 0.052
#> GSM802158     5  0.6734     0.7460 0.328 0.000 0.044 0.080 0.496 0.052
#> GSM802167     1  0.2617     0.8826 0.872 0.000 0.012 0.016 0.000 0.100
#> GSM802170     1  0.0405     0.9023 0.988 0.000 0.008 0.004 0.000 0.000
#> GSM802179     1  0.0405     0.9023 0.988 0.000 0.008 0.004 0.000 0.000
#> GSM802182     1  0.0665     0.8991 0.980 0.000 0.008 0.008 0.000 0.004
#> GSM802191     1  0.0508     0.8987 0.984 0.000 0.012 0.004 0.000 0.000
#> GSM802194     1  0.2568     0.8836 0.876 0.000 0.012 0.016 0.000 0.096
#> GSM802142     2  0.1864     0.5141 0.000 0.924 0.000 0.004 0.032 0.040
#> GSM802145     2  0.3919     0.4323 0.000 0.812 0.008 0.044 0.092 0.044
#> GSM802154     3  0.3603     0.8637 0.000 0.112 0.808 0.072 0.008 0.000
#> GSM802157     3  0.3213     0.9672 0.000 0.048 0.820 0.132 0.000 0.000
#> GSM802166     5  0.6571     0.7841 0.276 0.000 0.092 0.016 0.536 0.080
#> GSM802169     2  0.3484     0.5314 0.000 0.784 0.000 0.188 0.016 0.012
#> GSM802178     4  0.3665     0.6984 0.000 0.140 0.008 0.804 0.040 0.008
#> GSM802181     2  0.3547     0.4183 0.000 0.696 0.000 0.300 0.004 0.000
#> GSM802190     2  0.2981     0.5460 0.000 0.872 0.004 0.052 0.032 0.040
#> GSM802193     6  0.3337     0.8480 0.000 0.260 0.000 0.004 0.000 0.736
#> GSM802135     2  0.6449    -0.0522 0.000 0.428 0.020 0.380 0.160 0.012
#> GSM802138     2  0.5702     0.4029 0.000 0.612 0.016 0.208 0.156 0.008
#> GSM802147     6  0.6542     0.6655 0.000 0.204 0.020 0.176 0.044 0.556
#> GSM802150     2  0.4070     0.3818 0.000 0.672 0.008 0.308 0.008 0.004
#> GSM802159     4  0.6372    -0.2974 0.000 0.032 0.412 0.428 0.116 0.012
#> GSM802162     3  0.3213     0.9672 0.000 0.048 0.820 0.132 0.000 0.000
#> GSM802171     4  0.3375     0.7028 0.000 0.140 0.008 0.820 0.024 0.008
#> GSM802174     4  0.3442     0.6843 0.000 0.172 0.016 0.796 0.016 0.000
#> GSM802183     2  0.4937    -0.0530 0.000 0.492 0.028 0.460 0.020 0.000
#> GSM802186     2  0.4937    -0.0530 0.000 0.492 0.028 0.460 0.020 0.000
#> GSM802137     1  0.3092     0.8662 0.840 0.000 0.012 0.028 0.000 0.120
#> GSM802140     1  0.3135     0.8654 0.836 0.000 0.012 0.028 0.000 0.124
#> GSM802149     5  0.3626     0.8472 0.288 0.000 0.004 0.000 0.704 0.004
#> GSM802151     5  0.6329     0.8220 0.256 0.000 0.036 0.076 0.580 0.052
#> GSM802161     5  0.3126     0.8488 0.248 0.000 0.000 0.000 0.752 0.000
#> GSM802163     3  0.3213     0.9672 0.000 0.048 0.820 0.132 0.000 0.000
#> GSM802173     1  0.0810     0.8968 0.976 0.000 0.008 0.004 0.004 0.008
#> GSM802175     4  0.3264     0.6861 0.000 0.184 0.008 0.796 0.012 0.000
#> GSM802185     1  0.0924     0.8964 0.972 0.000 0.008 0.008 0.004 0.008
#> GSM802188     5  0.3547     0.8443 0.300 0.000 0.000 0.000 0.696 0.004
#> GSM802136     2  0.3885     0.4427 0.000 0.816 0.012 0.040 0.092 0.040
#> GSM802139     4  0.4868     0.5833 0.000 0.232 0.016 0.680 0.068 0.004
#> GSM802148     6  0.3337     0.8480 0.000 0.260 0.000 0.004 0.000 0.736
#> GSM802152     2  0.4662     0.3827 0.000 0.656 0.028 0.288 0.028 0.000
#> GSM802160     5  0.6571     0.7841 0.276 0.000 0.092 0.016 0.536 0.080
#> GSM802164     1  0.2001     0.8459 0.920 0.000 0.020 0.044 0.000 0.016
#> GSM802172     4  0.3184     0.7035 0.000 0.140 0.008 0.828 0.020 0.004
#> GSM802176     1  0.0405     0.9023 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM802184     2  0.4979     0.0781 0.000 0.524 0.028 0.424 0.024 0.000
#> GSM802187     2  0.2402     0.5320 0.000 0.904 0.004 0.020 0.032 0.040

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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) protocol(p)  time(p) individual(p) k
#> ATC:kmeans 60            1.000    4.43e-09 1.03e-04         1.000 2
#> ATC:kmeans 47            0.989    6.82e-07 3.03e-05         0.946 3
#> ATC:kmeans 41            0.983    1.15e-06 2.46e-05         0.947 4
#> ATC:kmeans 41            0.689    2.42e-04 1.35e-03         0.175 5
#> ATC:kmeans 45            0.562    1.10e-03 1.81e-02         0.183 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 22263 rows and 60 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 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-skmeans-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.929           0.965       0.980         0.1434 0.941   0.888
#> 4 4 0.732           0.850       0.897         0.2222 0.889   0.764
#> 5 5 0.808           0.788       0.892         0.1081 0.910   0.747
#> 6 6 0.786           0.585       0.820         0.0457 0.961   0.865

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2  0.2537      0.926  0 0.920 0.080
#> GSM802144     2  0.3116      0.906  0 0.892 0.108
#> GSM802153     2  0.0237      0.968  0 0.996 0.004
#> GSM802156     2  0.0237      0.968  0 0.996 0.004
#> GSM802165     2  0.1163      0.957  0 0.972 0.028
#> GSM802168     2  0.0000      0.970  0 1.000 0.000
#> GSM802177     2  0.0000      0.970  0 1.000 0.000
#> GSM802180     2  0.0000      0.970  0 1.000 0.000
#> GSM802189     2  0.0000      0.970  0 1.000 0.000
#> GSM802192     2  0.0000      0.970  0 1.000 0.000
#> GSM802143     1  0.0000      1.000  1 0.000 0.000
#> GSM802146     1  0.0000      1.000  1 0.000 0.000
#> GSM802155     1  0.0000      1.000  1 0.000 0.000
#> GSM802158     1  0.0000      1.000  1 0.000 0.000
#> GSM802167     1  0.0000      1.000  1 0.000 0.000
#> GSM802170     1  0.0000      1.000  1 0.000 0.000
#> GSM802179     1  0.0000      1.000  1 0.000 0.000
#> GSM802182     1  0.0000      1.000  1 0.000 0.000
#> GSM802191     1  0.0000      1.000  1 0.000 0.000
#> GSM802194     1  0.0000      1.000  1 0.000 0.000
#> GSM802142     2  0.2537      0.926  0 0.920 0.080
#> GSM802145     2  0.3192      0.902  0 0.888 0.112
#> GSM802154     2  0.0237      0.968  0 0.996 0.004
#> GSM802157     2  0.0237      0.968  0 0.996 0.004
#> GSM802166     1  0.0000      1.000  1 0.000 0.000
#> GSM802169     2  0.1031      0.961  0 0.976 0.024
#> GSM802178     2  0.0000      0.970  0 1.000 0.000
#> GSM802181     2  0.1031      0.961  0 0.976 0.024
#> GSM802190     2  0.0000      0.970  0 1.000 0.000
#> GSM802193     3  0.0237      0.876  0 0.004 0.996
#> GSM802135     2  0.3116      0.906  0 0.892 0.108
#> GSM802138     2  0.3116      0.906  0 0.892 0.108
#> GSM802147     3  0.4605      0.728  0 0.204 0.796
#> GSM802150     2  0.2165      0.938  0 0.936 0.064
#> GSM802159     2  0.1289      0.956  0 0.968 0.032
#> GSM802162     2  0.0237      0.968  0 0.996 0.004
#> GSM802171     2  0.0000      0.970  0 1.000 0.000
#> GSM802174     2  0.0000      0.970  0 1.000 0.000
#> GSM802183     2  0.0000      0.970  0 1.000 0.000
#> GSM802186     2  0.0000      0.970  0 1.000 0.000
#> GSM802137     1  0.0000      1.000  1 0.000 0.000
#> GSM802140     1  0.0000      1.000  1 0.000 0.000
#> GSM802149     1  0.0000      1.000  1 0.000 0.000
#> GSM802151     1  0.0000      1.000  1 0.000 0.000
#> GSM802161     1  0.0000      1.000  1 0.000 0.000
#> GSM802163     2  0.0237      0.968  0 0.996 0.004
#> GSM802173     1  0.0000      1.000  1 0.000 0.000
#> GSM802175     2  0.0000      0.970  0 1.000 0.000
#> GSM802185     1  0.0000      1.000  1 0.000 0.000
#> GSM802188     1  0.0000      1.000  1 0.000 0.000
#> GSM802136     2  0.3116      0.906  0 0.892 0.108
#> GSM802139     2  0.2165      0.938  0 0.936 0.064
#> GSM802148     3  0.0237      0.876  0 0.004 0.996
#> GSM802152     2  0.0000      0.970  0 1.000 0.000
#> GSM802160     1  0.0000      1.000  1 0.000 0.000
#> GSM802164     1  0.0000      1.000  1 0.000 0.000
#> GSM802172     2  0.0000      0.970  0 1.000 0.000
#> GSM802176     1  0.0000      1.000  1 0.000 0.000
#> GSM802184     2  0.0000      0.970  0 1.000 0.000
#> GSM802187     2  0.0000      0.970  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette p1    p2    p3    p4
#> GSM802141     2   0.391      0.773  0 0.768 0.232 0.000
#> GSM802144     2   0.386      0.733  0 0.832 0.136 0.032
#> GSM802153     3   0.445      0.692  0 0.308 0.692 0.000
#> GSM802156     3   0.302      0.882  0 0.148 0.852 0.000
#> GSM802165     2   0.147      0.793  0 0.948 0.052 0.000
#> GSM802168     2   0.194      0.798  0 0.924 0.076 0.000
#> GSM802177     2   0.241      0.799  0 0.896 0.104 0.000
#> GSM802180     2   0.241      0.799  0 0.896 0.104 0.000
#> GSM802189     2   0.234      0.799  0 0.900 0.100 0.000
#> GSM802192     2   0.130      0.797  0 0.956 0.044 0.000
#> GSM802143     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802146     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802155     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802158     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802167     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802170     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802179     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802182     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802191     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802194     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802142     2   0.443      0.738  0 0.696 0.304 0.000
#> GSM802145     2   0.444      0.716  0 0.800 0.148 0.052
#> GSM802154     3   0.312      0.861  0 0.156 0.844 0.000
#> GSM802157     3   0.302      0.882  0 0.148 0.852 0.000
#> GSM802166     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802169     2   0.247      0.808  0 0.892 0.108 0.000
#> GSM802178     2   0.130      0.797  0 0.956 0.044 0.000
#> GSM802181     2   0.276      0.801  0 0.872 0.128 0.000
#> GSM802190     2   0.436      0.635  0 0.708 0.292 0.000
#> GSM802193     4   0.000      0.860  0 0.000 0.000 1.000
#> GSM802135     2   0.400      0.734  0 0.812 0.164 0.024
#> GSM802138     2   0.320      0.748  0 0.856 0.136 0.008
#> GSM802147     4   0.476      0.674  0 0.156 0.064 0.780
#> GSM802150     2   0.281      0.801  0 0.868 0.132 0.000
#> GSM802159     3   0.475      0.560  0 0.368 0.632 0.000
#> GSM802162     3   0.302      0.882  0 0.148 0.852 0.000
#> GSM802171     2   0.147      0.794  0 0.948 0.052 0.000
#> GSM802174     2   0.302      0.780  0 0.852 0.148 0.000
#> GSM802183     2   0.401      0.689  0 0.756 0.244 0.000
#> GSM802186     2   0.401      0.689  0 0.756 0.244 0.000
#> GSM802137     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802140     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802149     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802151     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802161     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802163     3   0.302      0.882  0 0.148 0.852 0.000
#> GSM802173     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802175     2   0.361      0.743  0 0.800 0.200 0.000
#> GSM802185     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802188     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802136     2   0.371      0.738  0 0.832 0.148 0.020
#> GSM802139     2   0.327      0.750  0 0.832 0.168 0.000
#> GSM802148     4   0.000      0.860  0 0.000 0.000 1.000
#> GSM802152     2   0.428      0.649  0 0.720 0.280 0.000
#> GSM802160     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802164     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802172     2   0.147      0.794  0 0.948 0.052 0.000
#> GSM802176     1   0.000      1.000  1 0.000 0.000 0.000
#> GSM802184     2   0.441      0.656  0 0.700 0.300 0.000
#> GSM802187     2   0.448      0.638  0 0.688 0.312 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
#> GSM802141     4  0.4798      0.423 0.000 0.440 0.020 0.540 0.000
#> GSM802144     4  0.2416      0.712 0.000 0.100 0.000 0.888 0.012
#> GSM802153     3  0.4836      0.483 0.000 0.304 0.652 0.044 0.000
#> GSM802156     3  0.0703      0.843 0.000 0.024 0.976 0.000 0.000
#> GSM802165     2  0.4940      0.392 0.000 0.576 0.032 0.392 0.000
#> GSM802168     2  0.3608      0.733 0.000 0.812 0.040 0.148 0.000
#> GSM802177     2  0.0693      0.762 0.000 0.980 0.008 0.012 0.000
#> GSM802180     2  0.0798      0.763 0.000 0.976 0.008 0.016 0.000
#> GSM802189     2  0.1300      0.765 0.000 0.956 0.016 0.028 0.000
#> GSM802192     2  0.4425      0.648 0.000 0.716 0.040 0.244 0.000
#> GSM802143     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802155     1  0.0162      0.997 0.996 0.000 0.000 0.004 0.000
#> GSM802158     1  0.0162      0.997 0.996 0.000 0.000 0.004 0.000
#> GSM802167     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802142     4  0.5044      0.459 0.000 0.408 0.036 0.556 0.000
#> GSM802145     4  0.2130      0.704 0.000 0.080 0.000 0.908 0.012
#> GSM802154     3  0.1197      0.812 0.000 0.048 0.952 0.000 0.000
#> GSM802157     3  0.0703      0.843 0.000 0.024 0.976 0.000 0.000
#> GSM802166     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802169     2  0.1597      0.739 0.000 0.940 0.012 0.048 0.000
#> GSM802178     2  0.4180      0.678 0.000 0.744 0.036 0.220 0.000
#> GSM802181     2  0.1597      0.737 0.000 0.940 0.012 0.048 0.000
#> GSM802190     2  0.4010      0.592 0.000 0.784 0.160 0.056 0.000
#> GSM802193     5  0.0992      0.843 0.000 0.000 0.008 0.024 0.968
#> GSM802135     4  0.2233      0.681 0.000 0.104 0.000 0.892 0.004
#> GSM802138     4  0.2674      0.721 0.000 0.140 0.000 0.856 0.004
#> GSM802147     5  0.4618      0.673 0.000 0.128 0.020 0.080 0.772
#> GSM802150     2  0.2612      0.714 0.000 0.868 0.008 0.124 0.000
#> GSM802159     3  0.5037      0.531 0.000 0.088 0.684 0.228 0.000
#> GSM802162     3  0.0703      0.843 0.000 0.024 0.976 0.000 0.000
#> GSM802171     2  0.4224      0.684 0.000 0.744 0.040 0.216 0.000
#> GSM802174     2  0.3551      0.740 0.000 0.820 0.044 0.136 0.000
#> GSM802183     2  0.2036      0.739 0.000 0.920 0.056 0.024 0.000
#> GSM802186     2  0.2036      0.739 0.000 0.920 0.056 0.024 0.000
#> GSM802137     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802151     1  0.0162      0.997 0.996 0.000 0.000 0.004 0.000
#> GSM802161     1  0.0162      0.997 0.996 0.000 0.000 0.004 0.000
#> GSM802163     3  0.0703      0.843 0.000 0.024 0.976 0.000 0.000
#> GSM802173     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.3759      0.740 0.000 0.808 0.056 0.136 0.000
#> GSM802185     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802136     4  0.2674      0.693 0.000 0.140 0.000 0.856 0.004
#> GSM802139     4  0.4321      0.230 0.000 0.396 0.004 0.600 0.000
#> GSM802148     5  0.0000      0.844 0.000 0.000 0.000 0.000 1.000
#> GSM802152     2  0.2735      0.709 0.000 0.880 0.084 0.036 0.000
#> GSM802160     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802164     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802172     2  0.4224      0.684 0.000 0.744 0.040 0.216 0.000
#> GSM802176     1  0.0000      0.999 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.3303      0.754 0.000 0.848 0.076 0.076 0.000
#> GSM802187     2  0.6344     -0.194 0.000 0.484 0.172 0.344 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
#> GSM802141     2  0.5904     0.0554 0.000 0.456 0.000 0.320 0.224 0.000
#> GSM802144     4  0.1633     0.7899 0.000 0.044 0.000 0.932 0.024 0.000
#> GSM802153     3  0.5867     0.3157 0.000 0.308 0.508 0.008 0.176 0.000
#> GSM802156     3  0.0363     0.7966 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802165     5  0.6418     0.0000 0.000 0.332 0.012 0.316 0.340 0.000
#> GSM802168     2  0.4685     0.0182 0.000 0.644 0.016 0.040 0.300 0.000
#> GSM802177     2  0.0964     0.4787 0.000 0.968 0.004 0.016 0.012 0.000
#> GSM802180     2  0.1401     0.4696 0.000 0.948 0.004 0.020 0.028 0.000
#> GSM802189     2  0.2454     0.4281 0.000 0.884 0.008 0.020 0.088 0.000
#> GSM802192     2  0.5753    -0.4111 0.000 0.520 0.020 0.112 0.348 0.000
#> GSM802143     1  0.0260     0.9653 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM802146     1  0.0260     0.9653 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM802155     1  0.2624     0.8609 0.844 0.000 0.000 0.004 0.148 0.004
#> GSM802158     1  0.2624     0.8609 0.844 0.000 0.000 0.004 0.148 0.004
#> GSM802167     1  0.0260     0.9653 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM802170     1  0.0146     0.9658 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802179     1  0.0146     0.9656 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802182     1  0.0146     0.9656 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802191     1  0.0146     0.9656 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802194     1  0.0260     0.9653 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM802142     2  0.6249    -0.0274 0.000 0.404 0.008 0.332 0.256 0.000
#> GSM802145     4  0.1572     0.7869 0.000 0.036 0.000 0.936 0.028 0.000
#> GSM802154     3  0.1421     0.7724 0.000 0.028 0.944 0.000 0.028 0.000
#> GSM802157     3  0.0363     0.7966 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802166     1  0.0458     0.9620 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM802169     2  0.2609     0.4741 0.000 0.868 0.000 0.036 0.096 0.000
#> GSM802178     2  0.5367    -0.2439 0.000 0.556 0.020 0.072 0.352 0.000
#> GSM802181     2  0.2145     0.4875 0.000 0.900 0.000 0.028 0.072 0.000
#> GSM802190     2  0.5060     0.3519 0.000 0.692 0.112 0.032 0.164 0.000
#> GSM802193     6  0.2971     0.8055 0.000 0.000 0.012 0.024 0.116 0.848
#> GSM802135     4  0.2309     0.7091 0.000 0.028 0.000 0.888 0.084 0.000
#> GSM802138     4  0.2009     0.7807 0.000 0.068 0.000 0.908 0.024 0.000
#> GSM802147     6  0.4792     0.6521 0.000 0.084 0.008 0.044 0.120 0.744
#> GSM802150     2  0.2948     0.4648 0.000 0.848 0.000 0.060 0.092 0.000
#> GSM802159     3  0.6260     0.2030 0.000 0.056 0.548 0.152 0.244 0.000
#> GSM802162     3  0.0363     0.7966 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802171     2  0.5172    -0.1879 0.000 0.572 0.020 0.056 0.352 0.000
#> GSM802174     2  0.4464     0.0865 0.000 0.672 0.016 0.032 0.280 0.000
#> GSM802183     2  0.2312     0.4808 0.000 0.876 0.012 0.000 0.112 0.000
#> GSM802186     2  0.2489     0.4760 0.000 0.860 0.012 0.000 0.128 0.000
#> GSM802137     1  0.0260     0.9653 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM802140     1  0.0260     0.9653 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM802149     1  0.0000     0.9659 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802151     1  0.2624     0.8609 0.844 0.000 0.000 0.004 0.148 0.004
#> GSM802161     1  0.2624     0.8609 0.844 0.000 0.000 0.004 0.148 0.004
#> GSM802163     3  0.0363     0.7966 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802173     1  0.0146     0.9656 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802175     2  0.4672     0.0522 0.000 0.636 0.016 0.036 0.312 0.000
#> GSM802185     1  0.0146     0.9656 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802188     1  0.0405     0.9632 0.988 0.000 0.000 0.004 0.008 0.000
#> GSM802136     4  0.1657     0.7814 0.000 0.056 0.000 0.928 0.016 0.000
#> GSM802139     4  0.5904    -0.4152 0.000 0.272 0.004 0.500 0.224 0.000
#> GSM802148     6  0.0146     0.8141 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM802152     2  0.2971     0.4786 0.000 0.860 0.052 0.012 0.076 0.000
#> GSM802160     1  0.0547     0.9599 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM802164     1  0.0363     0.9632 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM802172     2  0.5172    -0.1879 0.000 0.572 0.020 0.056 0.352 0.000
#> GSM802176     1  0.0000     0.9659 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.4538     0.2201 0.000 0.644 0.028 0.016 0.312 0.000
#> GSM802187     2  0.7204     0.1631 0.000 0.428 0.132 0.184 0.256 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-skmeans-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-skmeans-collect-classes

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

test_to_known_factors(res)
#>              n disease.state(p) protocol(p)  time(p) individual(p) k
#> ATC:skmeans 60            1.000    4.43e-09 0.000103        1.0000 2
#> ATC:skmeans 60            0.834    5.63e-08 0.000129        0.5970 3
#> ATC:skmeans 60            0.924    4.54e-07 0.000451        0.0787 4
#> ATC:skmeans 54            0.977    2.26e-05 0.001357        0.0251 5
#> ATC:skmeans 35            0.872    1.02e-03 0.003829        0.4370 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 22263 rows and 60 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 4.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-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.4728 0.528   0.528
#> 3 3 0.747           0.840       0.887         0.2804 0.892   0.794
#> 4 4 0.922           0.897       0.956         0.1752 0.869   0.689
#> 5 5 0.774           0.788       0.869         0.0674 0.934   0.771
#> 6 6 0.747           0.578       0.830         0.0518 0.966   0.857

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

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2   0.440      0.695  0 0.812 0.188
#> GSM802144     2   0.129      0.612  0 0.968 0.032
#> GSM802153     2   0.615      0.777  0 0.592 0.408
#> GSM802156     3   0.000      0.940  0 0.000 1.000
#> GSM802165     2   0.618      0.777  0 0.584 0.416
#> GSM802168     2   0.618      0.777  0 0.584 0.416
#> GSM802177     2   0.618      0.777  0 0.584 0.416
#> GSM802180     2   0.618      0.777  0 0.584 0.416
#> GSM802189     2   0.618      0.777  0 0.584 0.416
#> GSM802192     2   0.618      0.777  0 0.584 0.416
#> GSM802143     1   0.000      1.000  1 0.000 0.000
#> GSM802146     1   0.000      1.000  1 0.000 0.000
#> GSM802155     1   0.000      1.000  1 0.000 0.000
#> GSM802158     1   0.000      1.000  1 0.000 0.000
#> GSM802167     1   0.000      1.000  1 0.000 0.000
#> GSM802170     1   0.000      1.000  1 0.000 0.000
#> GSM802179     1   0.000      1.000  1 0.000 0.000
#> GSM802182     1   0.000      1.000  1 0.000 0.000
#> GSM802191     1   0.000      1.000  1 0.000 0.000
#> GSM802194     1   0.000      1.000  1 0.000 0.000
#> GSM802142     2   0.000      0.591  0 1.000 0.000
#> GSM802145     2   0.000      0.591  0 1.000 0.000
#> GSM802154     3   0.435      0.701  0 0.184 0.816
#> GSM802157     3   0.000      0.940  0 0.000 1.000
#> GSM802166     1   0.000      1.000  1 0.000 0.000
#> GSM802169     2   0.595      0.766  0 0.640 0.360
#> GSM802178     2   0.618      0.777  0 0.584 0.416
#> GSM802181     2   0.613      0.775  0 0.600 0.400
#> GSM802190     2   0.164      0.615  0 0.956 0.044
#> GSM802193     2   0.000      0.591  0 1.000 0.000
#> GSM802135     2   0.406      0.685  0 0.836 0.164
#> GSM802138     2   0.406      0.685  0 0.836 0.164
#> GSM802147     2   0.618      0.777  0 0.584 0.416
#> GSM802150     2   0.618      0.777  0 0.584 0.416
#> GSM802159     3   0.000      0.940  0 0.000 1.000
#> GSM802162     3   0.000      0.940  0 0.000 1.000
#> GSM802171     2   0.618      0.777  0 0.584 0.416
#> GSM802174     2   0.618      0.777  0 0.584 0.416
#> GSM802183     2   0.618      0.777  0 0.584 0.416
#> GSM802186     2   0.618      0.777  0 0.584 0.416
#> GSM802137     1   0.000      1.000  1 0.000 0.000
#> GSM802140     1   0.000      1.000  1 0.000 0.000
#> GSM802149     1   0.000      1.000  1 0.000 0.000
#> GSM802151     1   0.000      1.000  1 0.000 0.000
#> GSM802161     1   0.000      1.000  1 0.000 0.000
#> GSM802163     3   0.000      0.940  0 0.000 1.000
#> GSM802173     1   0.000      1.000  1 0.000 0.000
#> GSM802175     2   0.618      0.777  0 0.584 0.416
#> GSM802185     1   0.000      1.000  1 0.000 0.000
#> GSM802188     1   0.000      1.000  1 0.000 0.000
#> GSM802136     2   0.000      0.591  0 1.000 0.000
#> GSM802139     2   0.606      0.770  0 0.616 0.384
#> GSM802148     2   0.000      0.591  0 1.000 0.000
#> GSM802152     2   0.484      0.708  0 0.776 0.224
#> GSM802160     1   0.000      1.000  1 0.000 0.000
#> GSM802164     1   0.000      1.000  1 0.000 0.000
#> GSM802172     2   0.618      0.777  0 0.584 0.416
#> GSM802176     1   0.000      1.000  1 0.000 0.000
#> GSM802184     2   0.493      0.684  0 0.768 0.232
#> GSM802187     2   0.000      0.591  0 1.000 0.000

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     4  0.4040      0.695 0.000 0.248 0.000 0.752
#> GSM802144     4  0.0921      0.854 0.000 0.028 0.000 0.972
#> GSM802153     2  0.3625      0.745 0.000 0.828 0.012 0.160
#> GSM802156     3  0.0921      0.999 0.000 0.028 0.972 0.000
#> GSM802165     2  0.4817      0.259 0.000 0.612 0.000 0.388
#> GSM802168     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802177     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802180     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802189     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802192     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802143     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802158     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802167     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802142     4  0.0000      0.861 0.000 0.000 0.000 1.000
#> GSM802145     4  0.0000      0.861 0.000 0.000 0.000 1.000
#> GSM802154     3  0.1004      0.994 0.000 0.024 0.972 0.004
#> GSM802157     3  0.0921      0.999 0.000 0.028 0.972 0.000
#> GSM802166     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802169     2  0.1637      0.880 0.000 0.940 0.000 0.060
#> GSM802178     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802181     2  0.0707      0.913 0.000 0.980 0.000 0.020
#> GSM802190     4  0.4855      0.273 0.000 0.400 0.000 0.600
#> GSM802193     4  0.0000      0.861 0.000 0.000 0.000 1.000
#> GSM802135     4  0.3172      0.779 0.000 0.160 0.000 0.840
#> GSM802138     4  0.3172      0.779 0.000 0.160 0.000 0.840
#> GSM802147     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802150     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802159     3  0.0921      0.999 0.000 0.028 0.972 0.000
#> GSM802162     3  0.0921      0.999 0.000 0.028 0.972 0.000
#> GSM802171     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802174     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802183     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802186     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802137     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802149     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802151     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802161     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802163     3  0.0921      0.999 0.000 0.028 0.972 0.000
#> GSM802173     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802175     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802185     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802136     4  0.0000      0.861 0.000 0.000 0.000 1.000
#> GSM802139     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802148     4  0.0000      0.861 0.000 0.000 0.000 1.000
#> GSM802152     2  0.4925      0.128 0.000 0.572 0.000 0.428
#> GSM802160     1  0.0921      0.983 0.972 0.000 0.028 0.000
#> GSM802164     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802172     2  0.0000      0.927 0.000 1.000 0.000 0.000
#> GSM802176     1  0.0000      0.990 1.000 0.000 0.000 0.000
#> GSM802184     2  0.3219      0.754 0.000 0.836 0.000 0.164
#> GSM802187     4  0.0000      0.861 0.000 0.000 0.000 1.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     4  0.4219     0.4103 0.000 0.416 0.000 0.584 0.000
#> GSM802144     4  0.0794     0.7676 0.000 0.028 0.000 0.972 0.000
#> GSM802153     2  0.3123     0.7045 0.000 0.828 0.012 0.160 0.000
#> GSM802156     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM802165     2  0.4150     0.3651 0.000 0.612 0.000 0.388 0.000
#> GSM802168     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802177     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802180     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802189     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802192     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802143     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802146     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802155     5  0.1043     0.7747 0.040 0.000 0.000 0.000 0.960
#> GSM802158     1  0.4045     0.8908 0.644 0.000 0.000 0.000 0.356
#> GSM802167     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802170     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802179     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802182     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802191     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802194     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802142     4  0.0000     0.7643 0.000 0.000 0.000 1.000 0.000
#> GSM802145     4  0.0000     0.7643 0.000 0.000 0.000 1.000 0.000
#> GSM802154     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM802157     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM802166     5  0.0000     0.7649 0.000 0.000 0.000 0.000 1.000
#> GSM802169     2  0.1410     0.8417 0.000 0.940 0.000 0.060 0.000
#> GSM802178     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802181     2  0.0609     0.8702 0.000 0.980 0.000 0.020 0.000
#> GSM802190     4  0.4182     0.3923 0.000 0.400 0.000 0.600 0.000
#> GSM802193     4  0.3816     0.6597 0.304 0.000 0.000 0.696 0.000
#> GSM802135     4  0.2732     0.7239 0.000 0.160 0.000 0.840 0.000
#> GSM802138     4  0.2732     0.7239 0.000 0.160 0.000 0.840 0.000
#> GSM802147     2  0.3816     0.5920 0.304 0.696 0.000 0.000 0.000
#> GSM802150     2  0.2929     0.7296 0.000 0.820 0.000 0.180 0.000
#> GSM802159     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM802162     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM802171     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802174     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802183     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802186     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802137     5  0.4171    -0.0771 0.396 0.000 0.000 0.000 0.604
#> GSM802140     5  0.1908     0.7405 0.092 0.000 0.000 0.000 0.908
#> GSM802149     5  0.1043     0.7747 0.040 0.000 0.000 0.000 0.960
#> GSM802151     5  0.3816     0.3566 0.304 0.000 0.000 0.000 0.696
#> GSM802161     5  0.0510     0.7723 0.016 0.000 0.000 0.000 0.984
#> GSM802163     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM802173     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802175     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802185     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802188     5  0.4060     0.1500 0.360 0.000 0.000 0.000 0.640
#> GSM802136     4  0.0000     0.7643 0.000 0.000 0.000 1.000 0.000
#> GSM802139     2  0.2929     0.7296 0.000 0.820 0.000 0.180 0.000
#> GSM802148     4  0.3816     0.6597 0.304 0.000 0.000 0.696 0.000
#> GSM802152     2  0.4242    -0.0185 0.000 0.572 0.000 0.428 0.000
#> GSM802160     5  0.0000     0.7649 0.000 0.000 0.000 0.000 1.000
#> GSM802164     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802172     2  0.0000     0.8814 0.000 1.000 0.000 0.000 0.000
#> GSM802176     1  0.3816     0.9916 0.696 0.000 0.000 0.000 0.304
#> GSM802184     2  0.2773     0.7178 0.000 0.836 0.000 0.164 0.000
#> GSM802187     4  0.2929     0.7207 0.000 0.180 0.000 0.820 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
#> GSM802141     4  0.4967     0.0479 0.000 0.420 0.000 0.512 0.000 0.068
#> GSM802144     4  0.0713     0.6495 0.000 0.028 0.000 0.972 0.000 0.000
#> GSM802153     2  0.4321     0.4862 0.000 0.652 0.012 0.020 0.000 0.316
#> GSM802156     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802165     2  0.3717    -0.0342 0.000 0.616 0.000 0.384 0.000 0.000
#> GSM802168     2  0.0000     0.5695 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802177     2  0.3482     0.5179 0.000 0.684 0.000 0.000 0.000 0.316
#> GSM802180     2  0.3482     0.5179 0.000 0.684 0.000 0.000 0.000 0.316
#> GSM802189     2  0.3482     0.5179 0.000 0.684 0.000 0.000 0.000 0.316
#> GSM802192     2  0.0000     0.5695 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802143     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802155     5  0.0260     0.6766 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM802158     1  0.3607     0.4373 0.652 0.000 0.000 0.000 0.348 0.000
#> GSM802167     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802142     4  0.0000     0.6539 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802145     4  0.0000     0.6539 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802154     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802157     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802166     5  0.5005     0.7160 0.164 0.000 0.000 0.000 0.644 0.192
#> GSM802169     2  0.4493     0.4596 0.000 0.636 0.000 0.052 0.000 0.312
#> GSM802178     2  0.0000     0.5695 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802181     2  0.3986     0.4991 0.000 0.664 0.000 0.020 0.000 0.316
#> GSM802190     4  0.5391    -0.0479 0.000 0.392 0.000 0.492 0.000 0.116
#> GSM802193     4  0.4097     0.3253 0.000 0.000 0.000 0.500 0.008 0.492
#> GSM802135     4  0.2454     0.5523 0.000 0.160 0.000 0.840 0.000 0.000
#> GSM802138     4  0.2631     0.5508 0.000 0.152 0.000 0.840 0.000 0.008
#> GSM802147     6  0.3490     0.0000 0.000 0.268 0.000 0.000 0.008 0.724
#> GSM802150     2  0.5896    -0.0214 0.000 0.460 0.000 0.224 0.000 0.316
#> GSM802159     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802162     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802171     2  0.0000     0.5695 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802174     2  0.1863     0.5630 0.000 0.896 0.000 0.000 0.000 0.104
#> GSM802183     2  0.3482     0.5179 0.000 0.684 0.000 0.000 0.000 0.316
#> GSM802186     2  0.3482     0.5179 0.000 0.684 0.000 0.000 0.000 0.316
#> GSM802137     1  0.3823    -0.1256 0.564 0.000 0.000 0.000 0.436 0.000
#> GSM802140     5  0.3634     0.5445 0.356 0.000 0.000 0.000 0.644 0.000
#> GSM802149     5  0.2491     0.7246 0.164 0.000 0.000 0.000 0.836 0.000
#> GSM802151     5  0.3782     0.0684 0.412 0.000 0.000 0.000 0.588 0.000
#> GSM802161     5  0.0363     0.6802 0.012 0.000 0.000 0.000 0.988 0.000
#> GSM802163     3  0.0000     1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM802173     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.0000     0.5695 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802185     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.3695     0.2417 0.624 0.000 0.000 0.000 0.376 0.000
#> GSM802136     4  0.0000     0.6539 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM802139     2  0.3109     0.2240 0.000 0.772 0.000 0.224 0.000 0.004
#> GSM802148     4  0.4097     0.3253 0.000 0.000 0.000 0.500 0.008 0.492
#> GSM802152     2  0.5386     0.2911 0.000 0.548 0.000 0.136 0.000 0.316
#> GSM802160     5  0.5005     0.7160 0.164 0.000 0.000 0.000 0.644 0.192
#> GSM802164     1  0.2378     0.7139 0.848 0.000 0.000 0.000 0.152 0.000
#> GSM802172     2  0.0000     0.5695 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM802176     1  0.0000     0.8738 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.2491     0.3362 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM802187     4  0.2969     0.5008 0.000 0.224 0.000 0.776 0.000 0.000

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

consensus_heatmap(res, k = 2)

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

consensus_heatmap(res, k = 3)

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

consensus_heatmap(res, k = 4)

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

consensus_heatmap(res, k = 5)

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

consensus_heatmap(res, k = 6)

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

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

membership_heatmap(res, k = 2)

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

membership_heatmap(res, k = 3)

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

membership_heatmap(res, k = 4)

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

membership_heatmap(res, k = 5)

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

membership_heatmap(res, k = 6)

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

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

Signature heatmaps where rows are scaled:

get_signatures(res, k = 2)

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

get_signatures(res, k = 3)

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

get_signatures(res, k = 4)

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

get_signatures(res, k = 5)

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

get_signatures(res, k = 6)

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

Signature heatmaps where rows are not scaled:

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

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

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

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

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

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

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

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

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

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

Compare the overlap of signatures from different k:

compare_signatures(res)

plot of chunk ATC-pam-signature_compare

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

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

An example of the output of tb is:

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

The columns in tb are:

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

UMAP plot which shows how samples are separated.

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

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

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

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

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

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

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

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

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

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

Following heatmap shows how subgroups are split when increasing k:

collect_classes(res)

plot of chunk ATC-pam-collect-classes

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

test_to_known_factors(res)
#>          n disease.state(p) protocol(p)  time(p) individual(p) k
#> ATC:pam 60            1.000    4.43e-09 0.000103         1.000 2
#> ATC:pam 60            1.000    7.22e-08 0.000167         0.575 3
#> ATC:pam 57            0.998    5.84e-07 0.000210         0.299 4
#> ATC:pam 53            0.603    1.21e-05 0.001424         0.243 5
#> ATC:pam 43            0.714    2.18e-04 0.000806         0.102 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 22263 rows and 60 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 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-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.4728 0.528   0.528
#> 3 3 0.819           0.849       0.931         0.2803 0.864   0.743
#> 4 4 0.745           0.774       0.887         0.0864 0.906   0.774
#> 5 5 0.646           0.566       0.818         0.0608 0.928   0.819
#> 6 6 0.708           0.783       0.833         0.0507 0.885   0.699

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette    p1    p2    p3
#> GSM802141     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802144     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802153     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802156     3  0.4796      0.789 0.000 0.220 0.780
#> GSM802165     2  0.1163      0.887 0.000 0.972 0.028
#> GSM802168     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802177     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802180     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802189     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802192     2  0.0592      0.899 0.000 0.988 0.012
#> GSM802143     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802146     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802155     1  0.0892      0.984 0.980 0.000 0.020
#> GSM802158     1  0.1411      0.976 0.964 0.000 0.036
#> GSM802167     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802170     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802179     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802182     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802191     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802194     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802142     2  0.3941      0.718 0.000 0.844 0.156
#> GSM802145     3  0.6192      0.566 0.000 0.420 0.580
#> GSM802154     3  0.5968      0.671 0.000 0.364 0.636
#> GSM802157     3  0.4796      0.789 0.000 0.220 0.780
#> GSM802166     1  0.1753      0.969 0.952 0.000 0.048
#> GSM802169     2  0.0424      0.901 0.000 0.992 0.008
#> GSM802178     2  0.0592      0.899 0.000 0.988 0.012
#> GSM802181     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802190     2  0.6308     -0.423 0.000 0.508 0.492
#> GSM802193     3  0.0424      0.691 0.000 0.008 0.992
#> GSM802135     2  0.4399      0.672 0.000 0.812 0.188
#> GSM802138     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802147     2  0.5859      0.380 0.000 0.656 0.344
#> GSM802150     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802159     2  0.5988      0.308 0.000 0.632 0.368
#> GSM802162     3  0.4796      0.789 0.000 0.220 0.780
#> GSM802171     2  0.0592      0.899 0.000 0.988 0.012
#> GSM802174     2  0.0237      0.904 0.000 0.996 0.004
#> GSM802183     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802186     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802137     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802140     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802149     1  0.1031      0.983 0.976 0.000 0.024
#> GSM802151     1  0.0892      0.984 0.980 0.000 0.020
#> GSM802161     1  0.1411      0.976 0.964 0.000 0.036
#> GSM802163     3  0.6252      0.498 0.000 0.444 0.556
#> GSM802173     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802175     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802185     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802188     1  0.0892      0.984 0.980 0.000 0.020
#> GSM802136     2  0.0747      0.896 0.000 0.984 0.016
#> GSM802139     2  0.0000      0.905 0.000 1.000 0.000
#> GSM802148     3  0.0424      0.691 0.000 0.008 0.992
#> GSM802152     2  0.0747      0.896 0.000 0.984 0.016
#> GSM802160     1  0.1753      0.969 0.952 0.000 0.048
#> GSM802164     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802172     2  0.0237      0.904 0.000 0.996 0.004
#> GSM802176     1  0.0000      0.990 1.000 0.000 0.000
#> GSM802184     2  0.3816      0.731 0.000 0.852 0.148
#> GSM802187     2  0.4504      0.644 0.000 0.804 0.196

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.0000    0.83273 0.000 1.000 0.000 0.000
#> GSM802144     2  0.0336    0.83477 0.000 0.992 0.008 0.000
#> GSM802153     2  0.4134    0.57259 0.000 0.740 0.260 0.000
#> GSM802156     3  0.1389    0.61009 0.000 0.048 0.952 0.000
#> GSM802165     3  0.5696   -0.01907 0.000 0.484 0.492 0.024
#> GSM802168     2  0.4010    0.77297 0.000 0.836 0.100 0.064
#> GSM802177     2  0.0921    0.83406 0.000 0.972 0.028 0.000
#> GSM802180     2  0.1716    0.82640 0.000 0.936 0.064 0.000
#> GSM802189     2  0.2053    0.82420 0.000 0.924 0.072 0.004
#> GSM802192     2  0.6791    0.10663 0.000 0.508 0.392 0.100
#> GSM802143     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0937    0.97308 0.976 0.000 0.012 0.012
#> GSM802158     1  0.1059    0.97108 0.972 0.000 0.012 0.016
#> GSM802167     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802179     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802182     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802142     2  0.0592    0.83260 0.000 0.984 0.016 0.000
#> GSM802145     2  0.3108    0.76481 0.000 0.872 0.112 0.016
#> GSM802154     3  0.4643    0.44469 0.000 0.344 0.656 0.000
#> GSM802157     3  0.1389    0.61009 0.000 0.048 0.952 0.000
#> GSM802166     1  0.2926    0.90968 0.896 0.000 0.048 0.056
#> GSM802169     2  0.0188    0.83235 0.000 0.996 0.004 0.000
#> GSM802178     2  0.6798    0.09347 0.000 0.504 0.396 0.100
#> GSM802181     2  0.0000    0.83273 0.000 1.000 0.000 0.000
#> GSM802190     2  0.0592    0.83260 0.000 0.984 0.016 0.000
#> GSM802193     4  0.2737    1.00000 0.000 0.008 0.104 0.888
#> GSM802135     3  0.5781   -0.00134 0.000 0.480 0.492 0.028
#> GSM802138     2  0.2741    0.81093 0.000 0.892 0.096 0.012
#> GSM802147     3  0.7385    0.31835 0.000 0.176 0.484 0.340
#> GSM802150     2  0.0188    0.83358 0.000 0.996 0.004 0.000
#> GSM802159     3  0.3239    0.57493 0.000 0.052 0.880 0.068
#> GSM802162     3  0.1576    0.60732 0.000 0.048 0.948 0.004
#> GSM802171     2  0.6167    0.50791 0.000 0.652 0.248 0.100
#> GSM802174     2  0.4071    0.77012 0.000 0.832 0.104 0.064
#> GSM802183     2  0.2408    0.78922 0.000 0.896 0.104 0.000
#> GSM802186     2  0.3024    0.74430 0.000 0.852 0.148 0.000
#> GSM802137     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0657    0.97598 0.984 0.000 0.012 0.004
#> GSM802151     1  0.0937    0.97308 0.976 0.000 0.012 0.012
#> GSM802161     1  0.2813    0.91172 0.896 0.000 0.024 0.080
#> GSM802163     3  0.2081    0.62162 0.000 0.084 0.916 0.000
#> GSM802173     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802175     2  0.2081    0.82128 0.000 0.916 0.084 0.000
#> GSM802185     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0804    0.97468 0.980 0.000 0.012 0.008
#> GSM802136     2  0.0707    0.83400 0.000 0.980 0.020 0.000
#> GSM802139     2  0.4130    0.77146 0.000 0.828 0.108 0.064
#> GSM802148     4  0.2737    1.00000 0.000 0.008 0.104 0.888
#> GSM802152     2  0.0592    0.83260 0.000 0.984 0.016 0.000
#> GSM802160     1  0.2926    0.90968 0.896 0.000 0.048 0.056
#> GSM802164     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802172     2  0.6757    0.16733 0.000 0.524 0.376 0.100
#> GSM802176     1  0.0000    0.98177 1.000 0.000 0.000 0.000
#> GSM802184     2  0.0592    0.83260 0.000 0.984 0.016 0.000
#> GSM802187     2  0.0592    0.83260 0.000 0.984 0.016 0.000

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.0510    0.73208 0.000 0.984 0.016 0.000 0.000
#> GSM802144     2  0.0451    0.73255 0.000 0.988 0.008 0.000 0.004
#> GSM802153     2  0.4040    0.58792 0.000 0.724 0.260 0.000 0.016
#> GSM802156     3  0.0880    0.80198 0.000 0.032 0.968 0.000 0.000
#> GSM802165     2  0.7997    0.09591 0.000 0.368 0.300 0.244 0.088
#> GSM802168     2  0.5886    0.55197 0.000 0.584 0.144 0.000 0.272
#> GSM802177     2  0.2011    0.73340 0.000 0.908 0.088 0.000 0.004
#> GSM802180     2  0.2329    0.72422 0.000 0.876 0.124 0.000 0.000
#> GSM802189     2  0.4406    0.68422 0.000 0.764 0.128 0.000 0.108
#> GSM802192     2  0.6662    0.36181 0.000 0.444 0.276 0.000 0.280
#> GSM802143     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802155     1  0.4074   -0.39992 0.636 0.000 0.000 0.000 0.364
#> GSM802158     1  0.4114   -0.44518 0.624 0.000 0.000 0.000 0.376
#> GSM802167     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802170     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802142     2  0.1106    0.72322 0.000 0.964 0.024 0.000 0.012
#> GSM802145     2  0.4843    0.49929 0.000 0.696 0.028 0.256 0.020
#> GSM802154     2  0.4291    0.00974 0.000 0.536 0.464 0.000 0.000
#> GSM802157     3  0.0880    0.80198 0.000 0.032 0.968 0.000 0.000
#> GSM802166     1  0.4064    0.19079 0.716 0.000 0.004 0.008 0.272
#> GSM802169     2  0.0703    0.72673 0.000 0.976 0.024 0.000 0.000
#> GSM802178     2  0.6771    0.27144 0.000 0.396 0.292 0.000 0.312
#> GSM802181     2  0.0162    0.73220 0.000 0.996 0.004 0.000 0.000
#> GSM802190     2  0.0703    0.72673 0.000 0.976 0.024 0.000 0.000
#> GSM802193     4  0.0000    0.52344 0.000 0.000 0.000 1.000 0.000
#> GSM802135     2  0.8021    0.08249 0.000 0.372 0.292 0.244 0.092
#> GSM802138     2  0.3734    0.70768 0.000 0.812 0.128 0.000 0.060
#> GSM802147     4  0.7584   -0.23477 0.000 0.260 0.288 0.404 0.048
#> GSM802150     2  0.0510    0.73386 0.000 0.984 0.016 0.000 0.000
#> GSM802159     3  0.5646    0.40222 0.000 0.036 0.628 0.292 0.044
#> GSM802162     3  0.0880    0.80198 0.000 0.032 0.968 0.000 0.000
#> GSM802171     2  0.6475    0.43459 0.000 0.484 0.212 0.000 0.304
#> GSM802174     2  0.5711    0.57937 0.000 0.612 0.136 0.000 0.252
#> GSM802183     2  0.2208    0.73136 0.000 0.908 0.072 0.000 0.020
#> GSM802186     2  0.2873    0.71876 0.000 0.860 0.120 0.000 0.020
#> GSM802137     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802140     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802149     1  0.1043    0.77919 0.960 0.000 0.000 0.000 0.040
#> GSM802151     1  0.4060   -0.38528 0.640 0.000 0.000 0.000 0.360
#> GSM802161     5  0.4533    0.00000 0.448 0.000 0.000 0.008 0.544
#> GSM802163     3  0.2929    0.59314 0.000 0.180 0.820 0.000 0.000
#> GSM802173     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802175     2  0.2771    0.72286 0.000 0.860 0.128 0.000 0.012
#> GSM802185     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802188     1  0.1043    0.77919 0.960 0.000 0.000 0.000 0.040
#> GSM802136     2  0.0703    0.72673 0.000 0.976 0.024 0.000 0.000
#> GSM802139     2  0.5778    0.56462 0.000 0.596 0.132 0.000 0.272
#> GSM802148     4  0.0000    0.52344 0.000 0.000 0.000 1.000 0.000
#> GSM802152     2  0.1444    0.71716 0.000 0.948 0.040 0.000 0.012
#> GSM802160     1  0.4064    0.19079 0.716 0.000 0.004 0.008 0.272
#> GSM802164     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802172     2  0.6665    0.36290 0.000 0.440 0.260 0.000 0.300
#> GSM802176     1  0.0000    0.82801 1.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.0807    0.72839 0.000 0.976 0.012 0.000 0.012
#> GSM802187     2  0.1106    0.72322 0.000 0.964 0.024 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
#> GSM802141     2  0.1196     0.8009 0.000 0.952 0.000 0.040 0.008 0.000
#> GSM802144     2  0.3072     0.7719 0.000 0.836 0.004 0.124 0.036 0.000
#> GSM802153     2  0.1616     0.7962 0.000 0.932 0.020 0.048 0.000 0.000
#> GSM802156     3  0.0508     0.8905 0.000 0.012 0.984 0.004 0.000 0.000
#> GSM802165     4  0.5531     0.6152 0.000 0.344 0.040 0.556 0.000 0.060
#> GSM802168     2  0.3726     0.7023 0.000 0.752 0.028 0.216 0.004 0.000
#> GSM802177     2  0.0993     0.8056 0.000 0.964 0.012 0.024 0.000 0.000
#> GSM802180     2  0.1232     0.8035 0.000 0.956 0.024 0.016 0.004 0.000
#> GSM802189     2  0.1562     0.8027 0.000 0.940 0.024 0.032 0.004 0.000
#> GSM802192     2  0.3839     0.6990 0.000 0.748 0.036 0.212 0.004 0.000
#> GSM802143     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802146     1  0.0260     0.9881 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM802155     5  0.2003     0.6528 0.116 0.000 0.000 0.000 0.884 0.000
#> GSM802158     5  0.2462     0.6496 0.132 0.000 0.004 0.004 0.860 0.000
#> GSM802167     1  0.0508     0.9831 0.984 0.000 0.000 0.012 0.004 0.000
#> GSM802170     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802179     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802182     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802194     1  0.0622     0.9796 0.980 0.000 0.000 0.008 0.012 0.000
#> GSM802142     2  0.2615     0.7425 0.000 0.852 0.008 0.136 0.000 0.004
#> GSM802145     2  0.4620     0.6783 0.000 0.696 0.012 0.220 0.000 0.072
#> GSM802154     3  0.2920     0.6894 0.000 0.168 0.820 0.008 0.000 0.004
#> GSM802157     3  0.0363     0.8905 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802166     5  0.6241     0.5720 0.340 0.000 0.004 0.212 0.436 0.008
#> GSM802169     2  0.2993     0.7619 0.000 0.844 0.008 0.120 0.028 0.000
#> GSM802178     2  0.4071     0.6551 0.000 0.712 0.036 0.248 0.004 0.000
#> GSM802181     2  0.1461     0.8070 0.000 0.940 0.000 0.044 0.016 0.000
#> GSM802190     2  0.2400     0.7551 0.000 0.872 0.008 0.116 0.000 0.004
#> GSM802193     6  0.0260     1.0000 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM802135     4  0.5597     0.6666 0.000 0.312 0.048 0.576 0.000 0.064
#> GSM802138     2  0.3621     0.7514 0.000 0.808 0.024 0.132 0.036 0.000
#> GSM802147     4  0.6851     0.5436 0.000 0.256 0.060 0.432 0.000 0.252
#> GSM802150     2  0.1261     0.8090 0.000 0.952 0.000 0.024 0.024 0.000
#> GSM802159     4  0.6464    -0.0229 0.000 0.084 0.408 0.416 0.000 0.092
#> GSM802162     3  0.0363     0.8905 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM802171     2  0.3973     0.6743 0.000 0.728 0.036 0.232 0.004 0.000
#> GSM802174     2  0.4031     0.6984 0.000 0.736 0.048 0.212 0.004 0.000
#> GSM802183     2  0.1594     0.7967 0.000 0.932 0.016 0.052 0.000 0.000
#> GSM802186     2  0.1500     0.7963 0.000 0.936 0.012 0.052 0.000 0.000
#> GSM802137     1  0.0260     0.9881 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM802140     1  0.0820     0.9729 0.972 0.000 0.000 0.012 0.016 0.000
#> GSM802149     5  0.4276     0.5888 0.416 0.000 0.000 0.020 0.564 0.000
#> GSM802151     5  0.2092     0.6588 0.124 0.000 0.000 0.000 0.876 0.000
#> GSM802161     5  0.1637     0.5878 0.056 0.000 0.004 0.004 0.932 0.004
#> GSM802163     3  0.2030     0.8304 0.000 0.064 0.908 0.028 0.000 0.000
#> GSM802173     1  0.0725     0.9728 0.976 0.000 0.000 0.012 0.012 0.000
#> GSM802175     2  0.1780     0.7986 0.000 0.924 0.028 0.048 0.000 0.000
#> GSM802185     1  0.0146     0.9882 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM802188     5  0.4212     0.5795 0.424 0.000 0.000 0.016 0.560 0.000
#> GSM802136     2  0.3828     0.7449 0.000 0.764 0.008 0.196 0.028 0.004
#> GSM802139     2  0.3759     0.7028 0.000 0.752 0.024 0.216 0.008 0.000
#> GSM802148     6  0.0260     1.0000 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM802152     2  0.1923     0.7843 0.000 0.916 0.016 0.064 0.000 0.004
#> GSM802160     5  0.6241     0.5720 0.340 0.000 0.004 0.212 0.436 0.008
#> GSM802164     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802172     2  0.3973     0.6743 0.000 0.728 0.036 0.232 0.004 0.000
#> GSM802176     1  0.0000     0.9903 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM802184     2  0.2680     0.7456 0.000 0.856 0.016 0.124 0.000 0.004
#> GSM802187     2  0.2615     0.7425 0.000 0.852 0.008 0.136 0.000 0.004

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

consensus_heatmap(res, k = 2)

plot of chunk tab-ATC-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) protocol(p)  time(p) individual(p) k
#> ATC:mclust 60            1.000    4.43e-09 1.03e-04         1.000 2
#> ATC:mclust 56            0.534    1.39e-08 5.65e-05         0.822 3
#> ATC:mclust 53            0.981    1.09e-06 2.69e-04         0.243 4
#> ATC:mclust 44            1.000    7.88e-06 2.59e-03         0.133 5
#> ATC:mclust 59            0.931    1.45e-06 3.97e-04         0.292 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 22263 rows and 60 columns.
#>   Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#>   Subgroups are detected by 'NMF' method.
#>   Performed in total 1250 partitions by row resampling.
#>   Best k for subgroups seems to be 2.
#> 
#> Following methods can be applied to this 'ConsensusPartition' object:
#>  [1] "cola_report"             "collect_classes"         "collect_plots"          
#>  [4] "collect_stats"           "colnames"                "compare_signatures"     
#>  [7] "consensus_heatmap"       "dimension_reduction"     "functional_enrichment"  
#> [10] "get_anno_col"            "get_anno"                "get_classes"            
#> [13] "get_consensus"           "get_matrix"              "get_membership"         
#> [16] "get_param"               "get_signatures"          "get_stats"              
#> [19] "is_best_k"               "is_stable_k"             "membership_heatmap"     
#> [22] "ncol"                    "nrow"                    "plot_ecdf"              
#> [25] "rownames"                "select_partition_number" "show"                   
#> [28] "suggest_best_k"          "test_to_known_factors"

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

collect_plots(res)

plot of chunk ATC-NMF-collect-plots

The plots are:

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

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

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

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

select_partition_number(res)

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

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

get_stats(res)
#>   k 1-PAC mean_silhouette concordance area_increased  Rand Jaccard
#> 2 2 1.000           1.000       1.000         0.4728 0.528   0.528
#> 3 3 0.744           0.814       0.888         0.3523 0.798   0.618
#> 4 4 0.674           0.685       0.820         0.0718 0.823   0.565
#> 5 5 0.741           0.639       0.827         0.0486 0.973   0.919
#> 6 6 0.718           0.641       0.784         0.0322 0.919   0.754

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
#> GSM802141     2       0          1  0  1
#> GSM802144     2       0          1  0  1
#> GSM802153     2       0          1  0  1
#> GSM802156     2       0          1  0  1
#> GSM802165     2       0          1  0  1
#> GSM802168     2       0          1  0  1
#> GSM802177     2       0          1  0  1
#> GSM802180     2       0          1  0  1
#> GSM802189     2       0          1  0  1
#> GSM802192     2       0          1  0  1
#> GSM802143     1       0          1  1  0
#> GSM802146     1       0          1  1  0
#> GSM802155     1       0          1  1  0
#> GSM802158     1       0          1  1  0
#> GSM802167     1       0          1  1  0
#> GSM802170     1       0          1  1  0
#> GSM802179     1       0          1  1  0
#> GSM802182     1       0          1  1  0
#> GSM802191     1       0          1  1  0
#> GSM802194     1       0          1  1  0
#> GSM802142     2       0          1  0  1
#> GSM802145     2       0          1  0  1
#> GSM802154     2       0          1  0  1
#> GSM802157     2       0          1  0  1
#> GSM802166     1       0          1  1  0
#> GSM802169     2       0          1  0  1
#> GSM802178     2       0          1  0  1
#> GSM802181     2       0          1  0  1
#> GSM802190     2       0          1  0  1
#> GSM802193     2       0          1  0  1
#> GSM802135     2       0          1  0  1
#> GSM802138     2       0          1  0  1
#> GSM802147     2       0          1  0  1
#> GSM802150     2       0          1  0  1
#> GSM802159     2       0          1  0  1
#> GSM802162     2       0          1  0  1
#> GSM802171     2       0          1  0  1
#> GSM802174     2       0          1  0  1
#> GSM802183     2       0          1  0  1
#> GSM802186     2       0          1  0  1
#> GSM802137     1       0          1  1  0
#> GSM802140     1       0          1  1  0
#> GSM802149     1       0          1  1  0
#> GSM802151     1       0          1  1  0
#> GSM802161     1       0          1  1  0
#> GSM802163     2       0          1  0  1
#> GSM802173     1       0          1  1  0
#> GSM802175     2       0          1  0  1
#> GSM802185     1       0          1  1  0
#> GSM802188     1       0          1  1  0
#> GSM802136     2       0          1  0  1
#> GSM802139     2       0          1  0  1
#> GSM802148     2       0          1  0  1
#> GSM802152     2       0          1  0  1
#> GSM802160     1       0          1  1  0
#> GSM802164     1       0          1  1  0
#> GSM802172     2       0          1  0  1
#> GSM802176     1       0          1  1  0
#> GSM802184     2       0          1  0  1
#> GSM802187     2       0          1  0  1

show/hide code output

cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#>           class entropy silhouette p1    p2    p3
#> GSM802141     2  0.3267     0.8218  0 0.884 0.116
#> GSM802144     2  0.2959     0.8134  0 0.900 0.100
#> GSM802153     3  0.1289     0.8353  0 0.032 0.968
#> GSM802156     3  0.0237     0.8195  0 0.004 0.996
#> GSM802165     2  0.6244     0.3923  0 0.560 0.440
#> GSM802168     2  0.6291     0.2983  0 0.532 0.468
#> GSM802177     3  0.5058     0.6506  0 0.244 0.756
#> GSM802180     3  0.5835     0.4384  0 0.340 0.660
#> GSM802189     3  0.3619     0.7990  0 0.136 0.864
#> GSM802192     3  0.2959     0.8296  0 0.100 0.900
#> GSM802143     1  0.0000     1.0000  1 0.000 0.000
#> GSM802146     1  0.0000     1.0000  1 0.000 0.000
#> GSM802155     1  0.0000     1.0000  1 0.000 0.000
#> GSM802158     1  0.0000     1.0000  1 0.000 0.000
#> GSM802167     1  0.0000     1.0000  1 0.000 0.000
#> GSM802170     1  0.0000     1.0000  1 0.000 0.000
#> GSM802179     1  0.0000     1.0000  1 0.000 0.000
#> GSM802182     1  0.0000     1.0000  1 0.000 0.000
#> GSM802191     1  0.0000     1.0000  1 0.000 0.000
#> GSM802194     1  0.0000     1.0000  1 0.000 0.000
#> GSM802142     3  0.5835     0.4575  0 0.340 0.660
#> GSM802145     2  0.3192     0.8202  0 0.888 0.112
#> GSM802154     3  0.0237     0.8125  0 0.004 0.996
#> GSM802157     3  0.0000     0.8164  0 0.000 1.000
#> GSM802166     1  0.0000     1.0000  1 0.000 0.000
#> GSM802169     2  0.4235     0.8219  0 0.824 0.176
#> GSM802178     2  0.5621     0.6892  0 0.692 0.308
#> GSM802181     2  0.4062     0.8254  0 0.836 0.164
#> GSM802190     3  0.2448     0.8404  0 0.076 0.924
#> GSM802193     2  0.1031     0.7478  0 0.976 0.024
#> GSM802135     2  0.3619     0.8267  0 0.864 0.136
#> GSM802138     2  0.4974     0.7806  0 0.764 0.236
#> GSM802147     2  0.2625     0.8019  0 0.916 0.084
#> GSM802150     2  0.4399     0.8159  0 0.812 0.188
#> GSM802159     3  0.2796     0.8341  0 0.092 0.908
#> GSM802162     3  0.0000     0.8164  0 0.000 1.000
#> GSM802171     3  0.6225     0.0898  0 0.432 0.568
#> GSM802174     2  0.6267     0.3593  0 0.548 0.452
#> GSM802183     3  0.2448     0.8406  0 0.076 0.924
#> GSM802186     3  0.2066     0.8421  0 0.060 0.940
#> GSM802137     1  0.0000     1.0000  1 0.000 0.000
#> GSM802140     1  0.0000     1.0000  1 0.000 0.000
#> GSM802149     1  0.0000     1.0000  1 0.000 0.000
#> GSM802151     1  0.0000     1.0000  1 0.000 0.000
#> GSM802161     1  0.0000     1.0000  1 0.000 0.000
#> GSM802163     3  0.0592     0.8248  0 0.012 0.988
#> GSM802173     1  0.0000     1.0000  1 0.000 0.000
#> GSM802175     3  0.3192     0.8210  0 0.112 0.888
#> GSM802185     1  0.0000     1.0000  1 0.000 0.000
#> GSM802188     1  0.0000     1.0000  1 0.000 0.000
#> GSM802136     2  0.3816     0.8273  0 0.852 0.148
#> GSM802139     2  0.5216     0.7557  0 0.740 0.260
#> GSM802148     2  0.0592     0.7353  0 0.988 0.012
#> GSM802152     3  0.2066     0.8424  0 0.060 0.940
#> GSM802160     1  0.0000     1.0000  1 0.000 0.000
#> GSM802164     1  0.0000     1.0000  1 0.000 0.000
#> GSM802172     3  0.6307    -0.1815  0 0.488 0.512
#> GSM802176     1  0.0000     1.0000  1 0.000 0.000
#> GSM802184     3  0.1753     0.8410  0 0.048 0.952
#> GSM802187     3  0.1643     0.8399  0 0.044 0.956

show/hide code output

cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#>           class entropy silhouette    p1    p2    p3    p4
#> GSM802141     2  0.3004     0.5427 0.000 0.892 0.060 0.048
#> GSM802144     2  0.5069    -0.1265 0.000 0.664 0.016 0.320
#> GSM802153     3  0.7332     0.2986 0.000 0.372 0.468 0.160
#> GSM802156     3  0.4245     0.7873 0.000 0.196 0.784 0.020
#> GSM802165     4  0.7892     0.2745 0.000 0.340 0.292 0.368
#> GSM802168     2  0.2048     0.6355 0.000 0.928 0.064 0.008
#> GSM802177     2  0.3820     0.6417 0.000 0.848 0.088 0.064
#> GSM802180     2  0.2919     0.6480 0.000 0.896 0.060 0.044
#> GSM802189     2  0.5497     0.4337 0.000 0.672 0.284 0.044
#> GSM802192     3  0.5404     0.6313 0.000 0.328 0.644 0.028
#> GSM802143     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802146     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802155     1  0.0336     0.9921 0.992 0.000 0.008 0.000
#> GSM802158     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802167     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802170     1  0.0188     0.9959 0.996 0.000 0.000 0.004
#> GSM802179     1  0.0188     0.9959 0.996 0.000 0.000 0.004
#> GSM802182     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802191     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802194     1  0.0188     0.9959 0.996 0.000 0.000 0.004
#> GSM802142     2  0.6528     0.3727 0.000 0.596 0.104 0.300
#> GSM802145     4  0.5476     0.6594 0.000 0.396 0.020 0.584
#> GSM802154     3  0.5938     0.6046 0.000 0.136 0.696 0.168
#> GSM802157     3  0.3852     0.7877 0.000 0.180 0.808 0.012
#> GSM802166     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802169     2  0.2408     0.5574 0.000 0.920 0.044 0.036
#> GSM802178     2  0.5066     0.4504 0.000 0.768 0.112 0.120
#> GSM802181     2  0.2408     0.5658 0.000 0.920 0.044 0.036
#> GSM802190     2  0.6995    -0.0137 0.000 0.496 0.384 0.120
#> GSM802193     4  0.4621     0.6671 0.000 0.284 0.008 0.708
#> GSM802135     4  0.7275     0.5530 0.000 0.376 0.152 0.472
#> GSM802138     2  0.5384     0.2906 0.000 0.728 0.076 0.196
#> GSM802147     4  0.5165     0.5877 0.000 0.484 0.004 0.512
#> GSM802150     2  0.2376     0.5568 0.000 0.916 0.016 0.068
#> GSM802159     3  0.6248     0.6175 0.000 0.260 0.640 0.100
#> GSM802162     3  0.3448     0.7807 0.000 0.168 0.828 0.004
#> GSM802171     2  0.4127     0.5820 0.000 0.824 0.124 0.052
#> GSM802174     2  0.2660     0.6447 0.000 0.908 0.056 0.036
#> GSM802183     2  0.6159     0.5057 0.000 0.676 0.172 0.152
#> GSM802186     2  0.5902     0.5024 0.000 0.700 0.160 0.140
#> GSM802137     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802140     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802149     1  0.0188     0.9957 0.996 0.000 0.004 0.000
#> GSM802151     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802161     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802163     3  0.3751     0.7921 0.000 0.196 0.800 0.004
#> GSM802173     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802175     2  0.5807     0.5287 0.000 0.708 0.160 0.132
#> GSM802185     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802188     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802136     2  0.5358     0.1673 0.000 0.700 0.048 0.252
#> GSM802139     2  0.2840     0.5847 0.000 0.900 0.044 0.056
#> GSM802148     4  0.4331     0.6647 0.000 0.288 0.000 0.712
#> GSM802152     2  0.7188     0.2039 0.000 0.528 0.308 0.164
#> GSM802160     1  0.0779     0.9820 0.980 0.000 0.004 0.016
#> GSM802164     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802172     2  0.2546     0.6111 0.000 0.912 0.060 0.028
#> GSM802176     1  0.0000     0.9981 1.000 0.000 0.000 0.000
#> GSM802184     2  0.6360     0.4610 0.000 0.656 0.180 0.164
#> GSM802187     2  0.7381     0.1457 0.000 0.492 0.328 0.180

show/hide code output

cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#>           class entropy silhouette    p1    p2    p3    p4    p5
#> GSM802141     2  0.4293     0.6321 0.000 0.772 0.004 0.064 0.160
#> GSM802144     2  0.6297     0.1285 0.000 0.532 0.000 0.256 0.212
#> GSM802153     2  0.6416     0.0745 0.000 0.464 0.356 0.000 0.180
#> GSM802156     3  0.2473     0.5513 0.000 0.072 0.896 0.000 0.032
#> GSM802165     3  0.8375    -0.6185 0.000 0.268 0.336 0.148 0.248
#> GSM802168     2  0.1682     0.6969 0.000 0.940 0.004 0.012 0.044
#> GSM802177     2  0.0566     0.7092 0.000 0.984 0.004 0.000 0.012
#> GSM802180     2  0.0451     0.7087 0.000 0.988 0.000 0.004 0.008
#> GSM802189     2  0.1893     0.7046 0.000 0.928 0.048 0.000 0.024
#> GSM802192     3  0.6478    -0.1773 0.000 0.368 0.476 0.008 0.148
#> GSM802143     1  0.0451     0.9877 0.988 0.000 0.000 0.004 0.008
#> GSM802146     1  0.0451     0.9877 0.988 0.000 0.000 0.004 0.008
#> GSM802155     1  0.1544     0.9256 0.932 0.000 0.068 0.000 0.000
#> GSM802158     1  0.0000     0.9890 1.000 0.000 0.000 0.000 0.000
#> GSM802167     1  0.0162     0.9890 0.996 0.000 0.000 0.000 0.004
#> GSM802170     1  0.0290     0.9886 0.992 0.000 0.000 0.000 0.008
#> GSM802179     1  0.0162     0.9886 0.996 0.000 0.000 0.000 0.004
#> GSM802182     1  0.0162     0.9890 0.996 0.000 0.000 0.004 0.000
#> GSM802191     1  0.0162     0.9886 0.996 0.000 0.000 0.000 0.004
#> GSM802194     1  0.1331     0.9572 0.952 0.000 0.000 0.040 0.008
#> GSM802142     2  0.6117     0.2361 0.000 0.472 0.028 0.060 0.440
#> GSM802145     4  0.4981     0.4957 0.000 0.068 0.008 0.704 0.220
#> GSM802154     3  0.5117     0.4017 0.000 0.072 0.652 0.000 0.276
#> GSM802157     3  0.1768     0.5661 0.000 0.072 0.924 0.000 0.004
#> GSM802166     1  0.0290     0.9886 0.992 0.000 0.000 0.000 0.008
#> GSM802169     2  0.2719     0.6981 0.000 0.884 0.000 0.048 0.068
#> GSM802178     2  0.5719     0.4740 0.000 0.708 0.076 0.116 0.100
#> GSM802181     2  0.2952     0.6939 0.000 0.872 0.004 0.036 0.088
#> GSM802190     2  0.7001     0.1750 0.000 0.508 0.316 0.060 0.116
#> GSM802193     4  0.1372     0.6763 0.000 0.024 0.004 0.956 0.016
#> GSM802135     5  0.8471     0.0000 0.000 0.212 0.248 0.200 0.340
#> GSM802138     2  0.6231     0.2941 0.000 0.604 0.056 0.068 0.272
#> GSM802147     4  0.6138     0.1984 0.000 0.200 0.044 0.644 0.112
#> GSM802150     2  0.2793     0.6870 0.000 0.876 0.000 0.036 0.088
#> GSM802159     3  0.7349    -0.2254 0.000 0.136 0.524 0.100 0.240
#> GSM802162     3  0.2616     0.5666 0.000 0.076 0.888 0.000 0.036
#> GSM802171     2  0.4118     0.6240 0.000 0.812 0.060 0.024 0.104
#> GSM802174     2  0.2393     0.6944 0.000 0.900 0.004 0.016 0.080
#> GSM802183     2  0.2873     0.6921 0.000 0.860 0.020 0.000 0.120
#> GSM802186     2  0.2669     0.6975 0.000 0.876 0.020 0.000 0.104
#> GSM802137     1  0.0451     0.9877 0.988 0.000 0.000 0.004 0.008
#> GSM802140     1  0.0451     0.9877 0.988 0.000 0.000 0.004 0.008
#> GSM802149     1  0.0324     0.9881 0.992 0.000 0.000 0.004 0.004
#> GSM802151     1  0.0162     0.9886 0.996 0.000 0.000 0.000 0.004
#> GSM802161     1  0.0000     0.9890 1.000 0.000 0.000 0.000 0.000
#> GSM802163     3  0.3112     0.5600 0.000 0.100 0.856 0.000 0.044
#> GSM802173     1  0.0162     0.9886 0.996 0.000 0.000 0.000 0.004
#> GSM802175     2  0.1800     0.7068 0.000 0.932 0.020 0.000 0.048
#> GSM802185     1  0.0162     0.9886 0.996 0.000 0.000 0.000 0.004
#> GSM802188     1  0.0162     0.9890 0.996 0.000 0.000 0.004 0.000
#> GSM802136     2  0.7019    -0.1852 0.000 0.424 0.012 0.264 0.300
#> GSM802139     2  0.3650     0.6415 0.000 0.816 0.008 0.028 0.148
#> GSM802148     4  0.1668     0.6796 0.000 0.028 0.000 0.940 0.032
#> GSM802152     2  0.4121     0.6366 0.000 0.788 0.112 0.000 0.100
#> GSM802160     1  0.0912     0.9781 0.972 0.000 0.000 0.016 0.012
#> GSM802164     1  0.0000     0.9890 1.000 0.000 0.000 0.000 0.000
#> GSM802172     2  0.3018     0.6726 0.000 0.876 0.024 0.020 0.080
#> GSM802176     1  0.0451     0.9877 0.988 0.000 0.000 0.004 0.008
#> GSM802184     2  0.2654     0.6982 0.000 0.884 0.032 0.000 0.084
#> GSM802187     2  0.6593     0.2097 0.000 0.464 0.252 0.000 0.284

show/hide code output

cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#>           class entropy silhouette    p1    p2    p3    p4    p5    p6
#> GSM802141     2  0.5792     0.3203 0.000 0.616 0.048 0.260 0.024 0.052
#> GSM802144     2  0.6487    -0.2631 0.000 0.440 0.000 0.380 0.092 0.088
#> GSM802153     3  0.4623     0.1992 0.000 0.428 0.540 0.016 0.016 0.000
#> GSM802156     3  0.4498     0.3365 0.000 0.024 0.544 0.004 0.428 0.000
#> GSM802165     5  0.4889     0.6540 0.000 0.236 0.024 0.020 0.688 0.032
#> GSM802168     2  0.2810     0.6533 0.000 0.856 0.008 0.008 0.120 0.008
#> GSM802177     2  0.1585     0.6887 0.000 0.940 0.012 0.012 0.036 0.000
#> GSM802180     2  0.0914     0.6983 0.000 0.968 0.000 0.016 0.016 0.000
#> GSM802189     2  0.3227     0.6578 0.000 0.832 0.016 0.028 0.124 0.000
#> GSM802192     5  0.4905     0.4388 0.000 0.408 0.064 0.000 0.528 0.000
#> GSM802143     1  0.0922     0.9668 0.968 0.000 0.004 0.024 0.000 0.004
#> GSM802146     1  0.0692     0.9700 0.976 0.000 0.000 0.020 0.000 0.004
#> GSM802155     1  0.2806     0.8410 0.844 0.000 0.136 0.016 0.004 0.000
#> GSM802158     1  0.0862     0.9677 0.972 0.000 0.008 0.016 0.004 0.000
#> GSM802167     1  0.0260     0.9711 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM802170     1  0.0291     0.9707 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM802179     1  0.0405     0.9698 0.988 0.000 0.004 0.008 0.000 0.000
#> GSM802182     1  0.0582     0.9718 0.984 0.000 0.004 0.004 0.004 0.004
#> GSM802191     1  0.0291     0.9707 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM802194     1  0.1719     0.9339 0.932 0.000 0.004 0.032 0.000 0.032
#> GSM802142     4  0.5186     0.4059 0.000 0.304 0.080 0.604 0.008 0.004
#> GSM802145     4  0.6426     0.0632 0.000 0.032 0.008 0.524 0.224 0.212
#> GSM802154     3  0.2475     0.4270 0.000 0.060 0.892 0.012 0.036 0.000
#> GSM802157     3  0.4712     0.3861 0.000 0.052 0.564 0.000 0.384 0.000
#> GSM802166     1  0.0260     0.9712 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM802169     2  0.3819     0.6488 0.000 0.816 0.020 0.108 0.032 0.024
#> GSM802178     2  0.4371     0.2985 0.000 0.620 0.000 0.016 0.352 0.012
#> GSM802181     2  0.3179     0.6584 0.000 0.856 0.020 0.088 0.016 0.020
#> GSM802190     3  0.6442     0.1886 0.000 0.412 0.444 0.072 0.032 0.040
#> GSM802193     6  0.3960     0.6529 0.000 0.000 0.008 0.180 0.052 0.760
#> GSM802135     5  0.6333     0.3886 0.000 0.172 0.008 0.180 0.580 0.060
#> GSM802138     2  0.6441    -0.1890 0.000 0.428 0.008 0.332 0.220 0.012
#> GSM802147     6  0.4671     0.6076 0.000 0.116 0.012 0.028 0.092 0.752
#> GSM802150     2  0.3686     0.5905 0.000 0.788 0.008 0.172 0.020 0.012
#> GSM802159     5  0.4708     0.5228 0.000 0.148 0.092 0.000 0.728 0.032
#> GSM802162     3  0.5081     0.4316 0.000 0.084 0.608 0.008 0.300 0.000
#> GSM802171     2  0.3885     0.4388 0.000 0.684 0.004 0.012 0.300 0.000
#> GSM802174     2  0.4857     0.5528 0.000 0.732 0.016 0.020 0.132 0.100
#> GSM802183     2  0.2100     0.6808 0.000 0.916 0.032 0.036 0.016 0.000
#> GSM802186     2  0.2119     0.6794 0.000 0.912 0.044 0.036 0.008 0.000
#> GSM802137     1  0.1067     0.9655 0.964 0.000 0.004 0.024 0.004 0.004
#> GSM802140     1  0.1147     0.9655 0.960 0.000 0.004 0.028 0.004 0.004
#> GSM802149     1  0.1452     0.9637 0.948 0.000 0.008 0.032 0.008 0.004
#> GSM802151     1  0.0862     0.9677 0.972 0.000 0.008 0.016 0.004 0.000
#> GSM802161     1  0.1078     0.9685 0.964 0.000 0.012 0.016 0.008 0.000
#> GSM802163     3  0.4851     0.4453 0.000 0.096 0.632 0.000 0.272 0.000
#> GSM802173     1  0.0146     0.9712 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM802175     2  0.2325     0.6737 0.000 0.884 0.008 0.008 0.100 0.000
#> GSM802185     1  0.0291     0.9713 0.992 0.000 0.004 0.000 0.004 0.000
#> GSM802188     1  0.0912     0.9709 0.972 0.000 0.012 0.004 0.008 0.004
#> GSM802136     4  0.6755     0.3409 0.000 0.304 0.012 0.484 0.140 0.060
#> GSM802139     2  0.5275     0.4887 0.000 0.644 0.000 0.204 0.136 0.016
#> GSM802148     6  0.1065     0.7368 0.000 0.008 0.000 0.008 0.020 0.964
#> GSM802152     2  0.4348     0.5302 0.000 0.716 0.220 0.052 0.012 0.000
#> GSM802160     1  0.2332     0.9334 0.904 0.000 0.008 0.060 0.016 0.012
#> GSM802164     1  0.0862     0.9677 0.972 0.000 0.008 0.016 0.004 0.000
#> GSM802172     2  0.3538     0.5726 0.000 0.764 0.004 0.012 0.216 0.004
#> GSM802176     1  0.0982     0.9672 0.968 0.000 0.004 0.020 0.004 0.004
#> GSM802184     2  0.1802     0.6910 0.000 0.932 0.020 0.024 0.024 0.000
#> GSM802187     3  0.5969     0.0354 0.000 0.408 0.448 0.120 0.024 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-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) protocol(p)  time(p) individual(p) k
#> ATC:NMF 60            1.000    4.43e-09 0.000103         1.000 2
#> ATC:NMF 53            0.980    6.14e-07 0.000493         0.699 3
#> ATC:NMF 48            0.909    1.70e-05 0.000218         0.455 4
#> ATC:NMF 45            0.954    1.44e-05 0.000296         0.296 5
#> ATC:NMF 41            0.940    2.53e-05 0.000159         0.749 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