Date: 2019-12-25 20:17:11 CET, cola version: 1.3.2
Document is loading...
All available functions which can be applied to this res_list
object:
res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#> On a matrix with 7957 rows and 58 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] 7957 58
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)
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 | ||
---|---|---|---|---|---|---|
ATC:kmeans | 2 | 1.000 | 0.963 | 0.987 | ** | |
ATC:pam | 2 | 1.000 | 0.990 | 0.996 | ** | |
ATC:NMF | 2 | 0.966 | 0.962 | 0.983 | ** | |
SD:pam | 2 | 0.964 | 0.941 | 0.976 | ** | |
CV:pam | 2 | 0.963 | 0.936 | 0.966 | ** | |
SD:mclust | 3 | 0.944 | 0.931 | 0.961 | * | |
MAD:mclust | 3 | 0.939 | 0.931 | 0.964 | * | |
ATC:skmeans | 3 | 0.935 | 0.918 | 0.965 | * | 2 |
MAD:pam | 2 | 0.928 | 0.931 | 0.973 | * | |
CV:skmeans | 3 | 0.896 | 0.896 | 0.954 | ||
SD:skmeans | 3 | 0.890 | 0.913 | 0.962 | ||
MAD:skmeans | 3 | 0.886 | 0.921 | 0.964 | ||
CV:mclust | 3 | 0.877 | 0.934 | 0.961 | ||
SD:kmeans | 3 | 0.820 | 0.847 | 0.918 | ||
CV:NMF | 3 | 0.756 | 0.833 | 0.925 | ||
MAD:NMF | 3 | 0.730 | 0.852 | 0.931 | ||
SD:NMF | 3 | 0.719 | 0.841 | 0.933 | ||
MAD:kmeans | 3 | 0.714 | 0.831 | 0.896 | ||
CV:kmeans | 3 | 0.688 | 0.808 | 0.904 | ||
ATC:mclust | 4 | 0.622 | 0.746 | 0.860 | ||
CV:hclust | 5 | 0.478 | 0.619 | 0.744 | ||
ATC:hclust | 3 | 0.414 | 0.633 | 0.815 | ||
MAD:hclust | 4 | 0.362 | 0.578 | 0.746 | ||
SD:hclust | 3 | 0.196 | 0.503 | 0.688 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
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)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 0.405 0.743 0.863 0.451 0.552 0.552
#> CV:NMF 2 0.355 0.772 0.870 0.463 0.564 0.564
#> MAD:NMF 2 0.322 0.665 0.801 0.488 0.506 0.506
#> ATC:NMF 2 0.966 0.962 0.983 0.391 0.610 0.610
#> SD:skmeans 2 0.318 0.565 0.808 0.501 0.501 0.501
#> CV:skmeans 2 0.321 0.564 0.814 0.499 0.501 0.501
#> MAD:skmeans 2 0.492 0.756 0.886 0.503 0.501 0.501
#> ATC:skmeans 2 0.999 0.949 0.980 0.497 0.506 0.506
#> SD:mclust 2 0.460 0.844 0.903 0.349 0.610 0.610
#> CV:mclust 2 0.332 0.798 0.861 0.368 0.610 0.610
#> MAD:mclust 2 0.403 0.859 0.889 0.368 0.610 0.610
#> ATC:mclust 2 0.762 0.860 0.937 0.274 0.710 0.710
#> SD:kmeans 2 0.252 0.634 0.768 0.422 0.687 0.687
#> CV:kmeans 2 0.246 0.684 0.830 0.416 0.687 0.687
#> MAD:kmeans 2 0.258 0.495 0.704 0.446 0.627 0.627
#> ATC:kmeans 2 1.000 0.963 0.987 0.337 0.666 0.666
#> SD:pam 2 0.964 0.941 0.976 0.248 0.758 0.758
#> CV:pam 2 0.963 0.936 0.966 0.252 0.733 0.733
#> MAD:pam 2 0.928 0.931 0.973 0.272 0.733 0.733
#> ATC:pam 2 1.000 0.990 0.996 0.266 0.733 0.733
#> SD:hclust 2 0.258 0.723 0.854 0.253 0.784 0.784
#> CV:hclust 2 0.264 0.570 0.807 0.353 0.646 0.646
#> MAD:hclust 2 0.249 0.694 0.840 0.247 0.900 0.900
#> ATC:hclust 2 0.731 0.907 0.955 0.333 0.687 0.687
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.719 0.841 0.933 0.463 0.675 0.463
#> CV:NMF 3 0.756 0.833 0.925 0.429 0.683 0.479
#> MAD:NMF 3 0.730 0.852 0.931 0.358 0.659 0.421
#> ATC:NMF 3 0.657 0.761 0.895 0.539 0.745 0.596
#> SD:skmeans 3 0.890 0.913 0.962 0.343 0.658 0.416
#> CV:skmeans 3 0.896 0.896 0.954 0.347 0.658 0.416
#> MAD:skmeans 3 0.886 0.921 0.964 0.334 0.658 0.416
#> ATC:skmeans 3 0.935 0.918 0.965 0.311 0.792 0.609
#> SD:mclust 3 0.944 0.931 0.961 0.539 0.538 0.399
#> CV:mclust 3 0.877 0.934 0.961 0.482 0.538 0.399
#> MAD:mclust 3 0.939 0.931 0.964 0.479 0.542 0.400
#> ATC:mclust 3 0.367 0.497 0.709 0.958 0.681 0.576
#> SD:kmeans 3 0.820 0.847 0.918 0.480 0.652 0.509
#> CV:kmeans 3 0.688 0.808 0.904 0.503 0.652 0.509
#> MAD:kmeans 3 0.714 0.831 0.896 0.412 0.687 0.517
#> ATC:kmeans 3 0.595 0.761 0.880 0.766 0.687 0.548
#> SD:pam 3 0.535 0.709 0.871 1.350 0.623 0.516
#> CV:pam 3 0.365 0.575 0.820 1.290 0.616 0.494
#> MAD:pam 3 0.565 0.756 0.886 1.212 0.570 0.451
#> ATC:pam 3 0.473 0.607 0.783 1.058 0.691 0.579
#> SD:hclust 3 0.196 0.503 0.688 1.047 0.560 0.457
#> CV:hclust 3 0.213 0.385 0.719 0.357 0.784 0.687
#> MAD:hclust 3 0.147 0.494 0.686 1.206 0.525 0.482
#> ATC:hclust 3 0.414 0.633 0.815 0.628 0.670 0.533
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.631 0.690 0.849 0.121 0.835 0.572
#> CV:NMF 4 0.659 0.706 0.843 0.117 0.869 0.648
#> MAD:NMF 4 0.655 0.677 0.845 0.119 0.868 0.640
#> ATC:NMF 4 0.661 0.789 0.888 0.143 0.815 0.591
#> SD:skmeans 4 0.645 0.703 0.843 0.118 0.882 0.661
#> CV:skmeans 4 0.607 0.677 0.823 0.118 0.915 0.744
#> MAD:skmeans 4 0.660 0.708 0.848 0.121 0.883 0.665
#> ATC:skmeans 4 0.768 0.770 0.901 0.118 0.833 0.577
#> SD:mclust 4 0.669 0.708 0.823 0.248 0.895 0.775
#> CV:mclust 4 0.733 0.788 0.863 0.246 0.822 0.619
#> MAD:mclust 4 0.673 0.710 0.846 0.241 0.815 0.604
#> ATC:mclust 4 0.622 0.746 0.860 0.306 0.659 0.385
#> SD:kmeans 4 0.574 0.479 0.761 0.144 0.940 0.842
#> CV:kmeans 4 0.543 0.507 0.745 0.148 0.907 0.765
#> MAD:kmeans 4 0.579 0.522 0.761 0.139 0.915 0.779
#> ATC:kmeans 4 0.603 0.733 0.834 0.206 0.752 0.460
#> SD:pam 4 0.551 0.634 0.778 0.197 0.771 0.520
#> CV:pam 4 0.643 0.784 0.881 0.230 0.731 0.439
#> MAD:pam 4 0.533 0.673 0.819 0.180 0.894 0.736
#> ATC:pam 4 0.549 0.587 0.827 0.252 0.796 0.571
#> SD:hclust 4 0.319 0.535 0.670 0.200 0.862 0.688
#> CV:hclust 4 0.340 0.562 0.757 0.330 0.712 0.496
#> MAD:hclust 4 0.362 0.578 0.746 0.208 0.851 0.681
#> ATC:hclust 4 0.419 0.505 0.754 0.182 0.883 0.731
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.688 0.640 0.824 0.0812 0.897 0.642
#> CV:NMF 5 0.663 0.629 0.797 0.0811 0.872 0.578
#> MAD:NMF 5 0.669 0.579 0.802 0.0764 0.860 0.541
#> ATC:NMF 5 0.606 0.587 0.792 0.1030 0.871 0.626
#> SD:skmeans 5 0.658 0.623 0.754 0.0647 0.950 0.807
#> CV:skmeans 5 0.623 0.546 0.744 0.0670 0.935 0.756
#> MAD:skmeans 5 0.681 0.600 0.770 0.0653 0.940 0.774
#> ATC:skmeans 5 0.639 0.580 0.736 0.0685 0.855 0.548
#> SD:mclust 5 0.731 0.669 0.845 0.1260 0.868 0.643
#> CV:mclust 5 0.582 0.556 0.714 0.0922 0.895 0.662
#> MAD:mclust 5 0.688 0.718 0.835 0.1148 0.839 0.541
#> ATC:mclust 5 0.630 0.603 0.757 0.0983 0.915 0.710
#> SD:kmeans 5 0.566 0.515 0.710 0.0832 0.887 0.669
#> CV:kmeans 5 0.550 0.469 0.713 0.0798 0.850 0.563
#> MAD:kmeans 5 0.574 0.458 0.708 0.0838 0.849 0.577
#> ATC:kmeans 5 0.711 0.679 0.826 0.0873 0.889 0.624
#> SD:pam 5 0.648 0.635 0.817 0.1151 0.817 0.476
#> CV:pam 5 0.677 0.723 0.778 0.0932 0.890 0.645
#> MAD:pam 5 0.671 0.664 0.821 0.0971 0.881 0.620
#> ATC:pam 5 0.657 0.686 0.855 0.1026 0.822 0.509
#> SD:hclust 5 0.427 0.434 0.683 0.1529 0.822 0.550
#> CV:hclust 5 0.478 0.619 0.744 0.1290 0.920 0.773
#> MAD:hclust 5 0.471 0.461 0.708 0.1191 0.864 0.622
#> ATC:hclust 5 0.484 0.587 0.755 0.0977 0.894 0.718
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.739 0.595 0.788 0.0366 0.927 0.684
#> CV:NMF 6 0.716 0.638 0.788 0.0386 0.909 0.613
#> MAD:NMF 6 0.708 0.553 0.780 0.0391 0.895 0.565
#> ATC:NMF 6 0.571 0.437 0.698 0.0563 0.892 0.600
#> SD:skmeans 6 0.661 0.492 0.719 0.0399 0.989 0.950
#> CV:skmeans 6 0.644 0.425 0.671 0.0385 0.978 0.901
#> MAD:skmeans 6 0.666 0.591 0.740 0.0402 0.953 0.784
#> ATC:skmeans 6 0.684 0.608 0.788 0.0381 0.955 0.806
#> SD:mclust 6 0.761 0.669 0.795 0.0592 0.902 0.628
#> CV:mclust 6 0.630 0.647 0.769 0.0589 0.806 0.383
#> MAD:mclust 6 0.761 0.731 0.797 0.0558 0.941 0.774
#> ATC:mclust 6 0.710 0.588 0.763 0.0647 0.892 0.563
#> SD:kmeans 6 0.619 0.486 0.670 0.0504 0.921 0.698
#> CV:kmeans 6 0.621 0.392 0.640 0.0524 0.840 0.460
#> MAD:kmeans 6 0.638 0.467 0.657 0.0452 0.878 0.565
#> ATC:kmeans 6 0.745 0.595 0.776 0.0443 0.929 0.702
#> SD:pam 6 0.700 0.673 0.806 0.0478 0.920 0.663
#> CV:pam 6 0.762 0.755 0.859 0.0468 0.935 0.725
#> MAD:pam 6 0.731 0.757 0.848 0.0481 0.910 0.628
#> ATC:pam 6 0.669 0.641 0.820 0.0456 0.895 0.603
#> SD:hclust 6 0.506 0.615 0.696 0.0650 0.874 0.583
#> CV:hclust 6 0.532 0.545 0.724 0.0551 0.977 0.920
#> MAD:hclust 6 0.528 0.582 0.743 0.0618 0.920 0.710
#> ATC:hclust 6 0.596 0.273 0.611 0.0691 0.785 0.413
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)
collect_stats(res_list, k = 3)
collect_stats(res_list, k = 4)
collect_stats(res_list, k = 5)
collect_stats(res_list, k = 6)
Collect partitions from all methods:
collect_classes(res_list, k = 2)
collect_classes(res_list, k = 3)
collect_classes(res_list, k = 4)
collect_classes(res_list, k = 5)
collect_classes(res_list, k = 6)
Overlap of top rows from different top-row methods:
top_rows_overlap(res_list, top_n = 796, method = "euler")
top_rows_overlap(res_list, top_n = 1592, method = "euler")
top_rows_overlap(res_list, top_n = 2387, method = "euler")
top_rows_overlap(res_list, top_n = 3182, method = "euler")
top_rows_overlap(res_list, top_n = 3978, method = "euler")
Also visualize the correspondance of rankings between different top-row methods:
top_rows_overlap(res_list, top_n = 796, method = "correspondance")
top_rows_overlap(res_list, top_n = 1592, method = "correspondance")
top_rows_overlap(res_list, top_n = 2387, method = "correspondance")
top_rows_overlap(res_list, top_n = 3182, method = "correspondance")
top_rows_overlap(res_list, top_n = 3978, method = "correspondance")
Heatmaps of the top rows:
top_rows_heatmap(res_list, top_n = 796)
top_rows_heatmap(res_list, top_n = 1592)
top_rows_heatmap(res_list, top_n = 2387)
top_rows_heatmap(res_list, top_n = 3182)
top_rows_heatmap(res_list, top_n = 3978)
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) other(p) k
#> SD:NMF 54 8.43e-03 1.44e-02 2
#> CV:NMF 53 1.87e-02 3.18e-02 2
#> MAD:NMF 53 5.22e-02 2.89e-02 2
#> ATC:NMF 58 3.53e-03 4.44e-03 2
#> SD:skmeans 36 NA 1.00e-01 2
#> CV:skmeans 41 1.03e-01 9.00e-03 2
#> MAD:skmeans 49 5.97e-02 3.02e-03 2
#> ATC:skmeans 56 6.12e-02 8.71e-02 2
#> SD:mclust 58 3.53e-03 5.72e-03 2
#> CV:mclust 58 3.53e-03 5.72e-03 2
#> MAD:mclust 58 3.53e-03 5.72e-03 2
#> ATC:mclust 52 3.17e-05 2.25e-05 2
#> SD:kmeans 46 1.81e-03 5.12e-04 2
#> CV:kmeans 54 5.32e-04 2.65e-04 2
#> MAD:kmeans 33 3.91e-03 1.97e-03 2
#> ATC:kmeans 57 7.23e-04 2.01e-04 2
#> SD:pam 56 2.52e-06 1.21e-06 2
#> CV:pam 57 1.15e-05 7.82e-06 2
#> MAD:pam 56 1.41e-05 9.91e-06 2
#> ATC:pam 58 3.78e-05 1.94e-05 2
#> SD:hclust 54 4.37e-07 1.50e-07 2
#> CV:hclust 45 4.84e-06 2.77e-06 2
#> MAD:hclust 50 NA 9.79e-01 2
#> ATC:hclust 57 1.36e-04 5.93e-05 2
test_to_known_factors(res_list, k = 3)
#> n disease.state(p) other(p) k
#> SD:NMF 54 5.21e-04 9.28e-04 3
#> CV:NMF 53 6.17e-04 1.37e-03 3
#> MAD:NMF 56 1.56e-03 1.74e-03 3
#> ATC:NMF 51 3.74e-04 3.30e-04 3
#> SD:skmeans 57 4.04e-03 8.90e-03 3
#> CV:skmeans 56 4.59e-03 1.58e-02 3
#> MAD:skmeans 57 4.04e-03 8.90e-03 3
#> ATC:skmeans 56 1.51e-02 7.19e-02 3
#> SD:mclust 57 4.19e-13 2.62e-11 3
#> CV:mclust 58 2.54e-13 2.01e-11 3
#> MAD:mclust 58 2.54e-13 1.24e-11 3
#> ATC:mclust 46 1.03e-10 2.18e-08 3
#> SD:kmeans 53 2.55e-05 5.85e-05 3
#> CV:kmeans 53 5.19e-06 6.73e-06 3
#> MAD:kmeans 53 5.19e-06 1.28e-05 3
#> ATC:kmeans 52 3.19e-05 8.23e-04 3
#> SD:pam 48 2.33e-07 1.98e-06 3
#> CV:pam 44 8.89e-07 6.45e-06 3
#> MAD:pam 51 8.53e-08 6.79e-07 3
#> ATC:pam 50 5.00e-05 3.66e-04 3
#> SD:hclust 41 1.25e-09 8.15e-08 3
#> CV:hclust 27 9.26e-06 5.89e-06 3
#> MAD:hclust 31 NA 5.33e-01 3
#> ATC:hclust 44 1.92e-04 2.11e-03 3
test_to_known_factors(res_list, k = 4)
#> n disease.state(p) other(p) k
#> SD:NMF 50 5.87e-04 8.72e-03 4
#> CV:NMF 50 5.87e-04 1.43e-02 4
#> MAD:NMF 48 8.61e-04 1.10e-02 4
#> ATC:NMF 53 2.95e-06 9.37e-05 4
#> SD:skmeans 48 8.30e-03 9.30e-03 4
#> CV:skmeans 49 7.18e-03 1.35e-02 4
#> MAD:skmeans 51 2.76e-03 6.36e-03 4
#> ATC:skmeans 50 1.74e-02 1.19e-02 4
#> SD:mclust 55 6.87e-12 1.18e-10 4
#> CV:mclust 55 6.87e-12 1.78e-09 4
#> MAD:mclust 54 1.12e-11 2.21e-09 4
#> ATC:mclust 51 4.89e-11 5.94e-10 4
#> SD:kmeans 30 1.75e-03 2.29e-04 4
#> CV:kmeans 39 3.76e-05 1.42e-04 4
#> MAD:kmeans 42 8.32e-05 1.15e-04 4
#> ATC:kmeans 52 2.71e-05 5.49e-05 4
#> SD:pam 44 3.87e-06 3.51e-05 4
#> CV:pam 54 1.51e-07 9.26e-07 4
#> MAD:pam 50 5.54e-07 2.17e-06 4
#> ATC:pam 42 3.02e-04 5.94e-04 4
#> SD:hclust 45 NA 7.29e-01 4
#> CV:hclust 41 NA 7.46e-01 4
#> MAD:hclust 50 5.87e-04 1.13e-02 4
#> ATC:hclust 36 1.17e-03 3.99e-03 4
test_to_known_factors(res_list, k = 5)
#> n disease.state(p) other(p) k
#> SD:NMF 46 1.23e-03 1.07e-02 5
#> CV:NMF 41 3.36e-03 2.64e-03 5
#> MAD:NMF 38 6.11e-03 4.54e-03 5
#> ATC:NMF 41 2.49e-04 1.65e-03 5
#> SD:skmeans 41 7.09e-03 3.28e-02 5
#> CV:skmeans 39 1.16e-02 5.26e-02 5
#> MAD:skmeans 41 7.09e-03 2.47e-02 5
#> ATC:skmeans 40 6.00e-02 1.02e-01 5
#> SD:mclust 46 2.46e-09 1.61e-07 5
#> CV:mclust 45 3.98e-09 6.60e-08 5
#> MAD:mclust 48 9.44e-10 6.22e-08 5
#> ATC:mclust 41 2.69e-08 8.43e-07 5
#> SD:kmeans 31 8.50e-07 2.00e-06 5
#> CV:kmeans 32 5.23e-07 6.08e-06 5
#> MAD:kmeans 27 1.37e-06 4.20e-06 5
#> ATC:kmeans 46 7.10e-06 1.55e-04 5
#> SD:pam 43 1.81e-05 3.77e-04 5
#> CV:pam 53 7.84e-07 2.69e-06 5
#> MAD:pam 51 1.47e-06 1.02e-05 5
#> ATC:pam 50 6.55e-08 9.24e-07 5
#> SD:hclust 30 1.38e-06 3.49e-05 5
#> CV:hclust 50 3.61e-10 1.76e-07 5
#> MAD:hclust 37 2.46e-04 1.63e-03 5
#> ATC:hclust 45 5.42e-04 4.80e-03 5
test_to_known_factors(res_list, k = 6)
#> n disease.state(p) other(p) k
#> SD:NMF 38 2.40e-03 1.33e-02 6
#> CV:NMF 46 1.23e-03 5.92e-03 6
#> MAD:NMF 33 6.93e-03 3.58e-02 6
#> ATC:NMF 29 1.23e-02 9.43e-03 6
#> SD:skmeans 33 3.32e-02 1.82e-01 6
#> CV:skmeans 28 1.99e-02 2.35e-02 6
#> MAD:skmeans 40 9.12e-03 4.58e-02 6
#> ATC:skmeans 47 6.36e-03 2.53e-02 6
#> SD:mclust 43 1.03e-08 3.45e-07 6
#> CV:mclust 46 9.08e-09 9.54e-07 6
#> MAD:mclust 50 1.39e-09 1.18e-07 6
#> ATC:mclust 42 1.67e-08 3.70e-07 6
#> SD:kmeans 29 7.82e-06 1.06e-05 6
#> CV:kmeans 20 4.54e-05 3.79e-04 6
#> MAD:kmeans 28 3.63e-06 8.04e-06 6
#> ATC:kmeans 45 9.71e-06 1.97e-04 6
#> SD:pam 47 5.68e-09 1.47e-06 6
#> CV:pam 52 5.39e-10 4.01e-08 6
#> MAD:pam 54 2.10e-10 9.86e-09 6
#> ATC:pam 47 5.68e-09 1.20e-07 6
#> SD:hclust 48 3.55e-09 1.23e-06 6
#> CV:hclust 44 6.42e-09 2.16e-06 6
#> MAD:hclust 42 4.01e-09 1.78e-07 6
#> ATC:hclust 20 NA 4.13e-01 6
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.258 0.723 0.854 0.253 0.784 0.784
#> 3 3 0.196 0.503 0.688 1.047 0.560 0.457
#> 4 4 0.319 0.535 0.670 0.200 0.862 0.688
#> 5 5 0.427 0.434 0.683 0.153 0.822 0.550
#> 6 6 0.506 0.615 0.696 0.065 0.874 0.583
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.9754 0.668 0.408 0.592
#> GSM39874 2 0.9754 0.668 0.408 0.592
#> GSM39875 2 0.9754 0.668 0.408 0.592
#> GSM39876 2 0.9754 0.668 0.408 0.592
#> GSM39831 1 0.0000 0.814 1.000 0.000
#> GSM39819 1 0.5519 0.791 0.872 0.128
#> GSM39820 1 0.5737 0.788 0.864 0.136
#> GSM39821 1 0.0000 0.814 1.000 0.000
#> GSM39822 1 0.7883 0.684 0.764 0.236
#> GSM39823 1 0.9087 0.514 0.676 0.324
#> GSM39824 1 0.9710 0.251 0.600 0.400
#> GSM39825 1 0.1414 0.817 0.980 0.020
#> GSM39826 1 0.0376 0.815 0.996 0.004
#> GSM39827 1 0.4690 0.805 0.900 0.100
#> GSM39846 1 0.9427 0.406 0.640 0.360
#> GSM39847 1 0.0000 0.814 1.000 0.000
#> GSM39848 2 0.5059 0.588 0.112 0.888
#> GSM39849 1 0.7376 0.727 0.792 0.208
#> GSM39850 1 0.0376 0.815 0.996 0.004
#> GSM39851 1 0.0000 0.814 1.000 0.000
#> GSM39855 2 0.9850 0.462 0.428 0.572
#> GSM39856 1 0.9323 0.446 0.652 0.348
#> GSM39858 1 0.8327 0.643 0.736 0.264
#> GSM39859 1 0.7674 0.708 0.776 0.224
#> GSM39862 1 0.6247 0.652 0.844 0.156
#> GSM39863 1 0.0000 0.814 1.000 0.000
#> GSM39865 1 0.8813 0.569 0.700 0.300
#> GSM39866 1 0.2423 0.821 0.960 0.040
#> GSM39867 1 0.4431 0.797 0.908 0.092
#> GSM39869 1 0.8327 0.611 0.736 0.264
#> GSM39870 1 0.5629 0.789 0.868 0.132
#> GSM39871 1 0.6531 0.768 0.832 0.168
#> GSM39872 1 0.4690 0.792 0.900 0.100
#> GSM39828 1 0.0376 0.814 0.996 0.004
#> GSM39829 1 0.5294 0.797 0.880 0.120
#> GSM39830 1 0.4431 0.809 0.908 0.092
#> GSM39832 1 0.0000 0.814 1.000 0.000
#> GSM39833 1 0.7219 0.745 0.800 0.200
#> GSM39834 1 0.2043 0.820 0.968 0.032
#> GSM39835 1 0.3584 0.799 0.932 0.068
#> GSM39836 1 0.0376 0.815 0.996 0.004
#> GSM39837 1 0.7883 0.684 0.764 0.236
#> GSM39838 1 0.8081 0.663 0.752 0.248
#> GSM39839 1 0.5519 0.791 0.872 0.128
#> GSM39840 1 0.0000 0.814 1.000 0.000
#> GSM39841 1 0.1843 0.817 0.972 0.028
#> GSM39842 1 0.0000 0.814 1.000 0.000
#> GSM39843 1 0.0000 0.814 1.000 0.000
#> GSM39844 1 0.0000 0.814 1.000 0.000
#> GSM39845 1 0.5737 0.788 0.864 0.136
#> GSM39852 1 0.0938 0.815 0.988 0.012
#> GSM39853 1 0.7883 0.684 0.764 0.236
#> GSM39854 1 0.4431 0.797 0.908 0.092
#> GSM39857 1 0.9087 0.514 0.676 0.324
#> GSM39860 2 0.0000 0.524 0.000 1.000
#> GSM39861 1 0.6438 0.771 0.836 0.164
#> GSM39864 1 0.2423 0.821 0.960 0.040
#> GSM39868 1 0.2043 0.820 0.968 0.032
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.6102 0.5504 0.008 0.672 0.320
#> GSM39874 2 0.6102 0.5504 0.008 0.672 0.320
#> GSM39875 2 0.6102 0.5504 0.008 0.672 0.320
#> GSM39876 2 0.6102 0.5504 0.008 0.672 0.320
#> GSM39831 1 0.1636 0.7188 0.964 0.016 0.020
#> GSM39819 3 0.6521 0.5642 0.496 0.004 0.500
#> GSM39820 1 0.6521 -0.5845 0.504 0.004 0.492
#> GSM39821 1 0.2492 0.7228 0.936 0.016 0.048
#> GSM39822 2 0.9952 0.3998 0.332 0.376 0.292
#> GSM39823 3 0.5553 0.7090 0.272 0.004 0.724
#> GSM39824 3 0.4634 0.5688 0.164 0.012 0.824
#> GSM39825 1 0.3030 0.7047 0.904 0.004 0.092
#> GSM39826 1 0.4413 0.6912 0.860 0.036 0.104
#> GSM39827 1 0.6191 0.5778 0.776 0.140 0.084
#> GSM39846 3 0.5012 0.6405 0.204 0.008 0.788
#> GSM39847 1 0.2492 0.7228 0.936 0.016 0.048
#> GSM39848 2 0.6467 0.3869 0.008 0.604 0.388
#> GSM39849 3 0.6975 0.6808 0.356 0.028 0.616
#> GSM39850 1 0.4413 0.6912 0.860 0.036 0.104
#> GSM39851 1 0.1015 0.7213 0.980 0.008 0.012
#> GSM39855 3 0.5042 0.1747 0.060 0.104 0.836
#> GSM39856 3 0.5156 0.6577 0.216 0.008 0.776
#> GSM39858 3 0.5560 0.7199 0.300 0.000 0.700
#> GSM39859 3 0.6111 0.6891 0.396 0.000 0.604
#> GSM39862 1 0.7340 0.4524 0.676 0.076 0.248
#> GSM39863 1 0.1636 0.7188 0.964 0.016 0.020
#> GSM39865 2 0.9922 0.3874 0.304 0.396 0.300
#> GSM39866 1 0.3325 0.7071 0.904 0.020 0.076
#> GSM39867 1 0.9295 0.0853 0.524 0.252 0.224
#> GSM39869 2 0.9908 0.3816 0.332 0.392 0.276
#> GSM39870 1 0.6421 -0.3964 0.572 0.004 0.424
#> GSM39871 3 0.6468 0.6473 0.444 0.004 0.552
#> GSM39872 1 0.6688 -0.0475 0.580 0.012 0.408
#> GSM39828 1 0.2096 0.7211 0.944 0.004 0.052
#> GSM39829 1 0.6518 -0.5642 0.512 0.004 0.484
#> GSM39830 1 0.4504 0.5001 0.804 0.000 0.196
#> GSM39832 1 0.1919 0.7187 0.956 0.020 0.024
#> GSM39833 3 0.8743 0.5289 0.372 0.116 0.512
#> GSM39834 1 0.3966 0.7040 0.876 0.024 0.100
#> GSM39835 1 0.7862 0.4496 0.668 0.184 0.148
#> GSM39836 1 0.3765 0.7081 0.888 0.028 0.084
#> GSM39837 2 0.9952 0.3998 0.332 0.376 0.292
#> GSM39838 1 0.9767 -0.2205 0.428 0.328 0.244
#> GSM39839 3 0.6521 0.5642 0.496 0.004 0.500
#> GSM39840 1 0.1337 0.7207 0.972 0.012 0.016
#> GSM39841 1 0.2297 0.7154 0.944 0.036 0.020
#> GSM39842 1 0.1919 0.7187 0.956 0.020 0.024
#> GSM39843 1 0.0892 0.7194 0.980 0.000 0.020
#> GSM39844 1 0.1919 0.7187 0.956 0.020 0.024
#> GSM39845 3 0.6521 0.5618 0.496 0.004 0.500
#> GSM39852 1 0.2902 0.7198 0.920 0.016 0.064
#> GSM39853 2 0.9952 0.3998 0.332 0.376 0.292
#> GSM39854 1 0.9295 0.0853 0.524 0.252 0.224
#> GSM39857 3 0.5443 0.7064 0.260 0.004 0.736
#> GSM39860 2 0.6299 0.2589 0.000 0.524 0.476
#> GSM39861 3 0.6483 0.6358 0.452 0.004 0.544
#> GSM39864 1 0.3183 0.7074 0.908 0.016 0.076
#> GSM39868 1 0.3966 0.7040 0.876 0.024 0.100
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0524 0.441 0.000 0.988 0.004 0.008
#> GSM39874 2 0.0524 0.441 0.000 0.988 0.004 0.008
#> GSM39875 2 0.0524 0.441 0.000 0.988 0.004 0.008
#> GSM39876 2 0.0524 0.441 0.000 0.988 0.004 0.008
#> GSM39831 1 0.4360 0.669 0.744 0.000 0.248 0.008
#> GSM39819 3 0.2814 0.684 0.132 0.000 0.868 0.000
#> GSM39820 3 0.2921 0.677 0.140 0.000 0.860 0.000
#> GSM39821 1 0.4632 0.674 0.688 0.004 0.308 0.000
#> GSM39822 2 0.6028 0.607 0.388 0.572 0.032 0.008
#> GSM39823 3 0.4571 0.684 0.072 0.004 0.808 0.116
#> GSM39824 3 0.5507 0.558 0.044 0.028 0.748 0.180
#> GSM39825 1 0.5311 0.619 0.596 0.004 0.392 0.008
#> GSM39826 1 0.4706 0.637 0.748 0.028 0.224 0.000
#> GSM39827 1 0.7569 0.592 0.556 0.188 0.240 0.016
#> GSM39846 3 0.5135 0.618 0.048 0.028 0.784 0.140
#> GSM39847 1 0.4632 0.674 0.688 0.004 0.308 0.000
#> GSM39848 4 0.4631 0.582 0.004 0.260 0.008 0.728
#> GSM39849 3 0.4801 0.679 0.136 0.020 0.800 0.044
#> GSM39850 1 0.4706 0.637 0.748 0.028 0.224 0.000
#> GSM39851 1 0.4304 0.673 0.716 0.000 0.284 0.000
#> GSM39855 3 0.6596 0.175 0.032 0.032 0.556 0.380
#> GSM39856 3 0.4846 0.633 0.044 0.028 0.804 0.124
#> GSM39858 3 0.3640 0.709 0.036 0.028 0.876 0.060
#> GSM39859 3 0.3485 0.713 0.076 0.004 0.872 0.048
#> GSM39862 1 0.7019 0.371 0.524 0.000 0.344 0.132
#> GSM39863 1 0.4360 0.669 0.744 0.000 0.248 0.008
#> GSM39865 2 0.7811 0.542 0.364 0.488 0.036 0.112
#> GSM39866 1 0.5835 0.647 0.608 0.008 0.356 0.028
#> GSM39867 1 0.6303 -0.245 0.600 0.344 0.028 0.028
#> GSM39869 2 0.7800 0.509 0.400 0.440 0.020 0.140
#> GSM39870 3 0.3907 0.561 0.232 0.000 0.768 0.000
#> GSM39871 3 0.2520 0.710 0.088 0.004 0.904 0.004
#> GSM39872 3 0.6020 0.204 0.384 0.000 0.568 0.048
#> GSM39828 1 0.4697 0.659 0.644 0.000 0.356 0.000
#> GSM39829 3 0.3024 0.669 0.148 0.000 0.852 0.000
#> GSM39830 3 0.4992 -0.353 0.476 0.000 0.524 0.000
#> GSM39832 1 0.4253 0.659 0.776 0.000 0.208 0.016
#> GSM39833 3 0.7763 0.448 0.200 0.172 0.584 0.044
#> GSM39834 1 0.5076 0.647 0.712 0.004 0.260 0.024
#> GSM39835 1 0.5436 0.174 0.756 0.172 0.036 0.036
#> GSM39836 1 0.4262 0.653 0.756 0.008 0.236 0.000
#> GSM39837 2 0.6028 0.607 0.388 0.572 0.032 0.008
#> GSM39838 1 0.7972 -0.414 0.436 0.420 0.072 0.072
#> GSM39839 3 0.2814 0.684 0.132 0.000 0.868 0.000
#> GSM39840 1 0.4391 0.672 0.740 0.000 0.252 0.008
#> GSM39841 1 0.5268 0.671 0.724 0.024 0.236 0.016
#> GSM39842 1 0.4253 0.659 0.776 0.000 0.208 0.016
#> GSM39843 1 0.4500 0.666 0.684 0.000 0.316 0.000
#> GSM39844 1 0.4253 0.659 0.776 0.000 0.208 0.016
#> GSM39845 3 0.2814 0.684 0.132 0.000 0.868 0.000
#> GSM39852 1 0.4857 0.666 0.668 0.000 0.324 0.008
#> GSM39853 2 0.6028 0.607 0.388 0.572 0.032 0.008
#> GSM39854 1 0.6303 -0.245 0.600 0.344 0.028 0.028
#> GSM39857 3 0.4353 0.679 0.060 0.004 0.820 0.116
#> GSM39860 4 0.1584 0.678 0.000 0.012 0.036 0.952
#> GSM39861 3 0.2651 0.706 0.096 0.004 0.896 0.004
#> GSM39864 1 0.5835 0.646 0.608 0.008 0.356 0.028
#> GSM39868 1 0.5076 0.647 0.712 0.004 0.260 0.024
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.0579 0.6389 0.984 0.000 0.008 0.000 0.008
#> GSM39819 3 0.4201 0.6750 0.328 0.000 0.664 0.008 0.000
#> GSM39820 3 0.4592 0.6591 0.332 0.000 0.644 0.024 0.000
#> GSM39821 4 0.4744 -0.2299 0.476 0.000 0.016 0.508 0.000
#> GSM39822 4 0.4567 0.0768 0.004 0.448 0.000 0.544 0.004
#> GSM39823 3 0.4005 0.6796 0.072 0.000 0.828 0.044 0.056
#> GSM39824 3 0.2653 0.5803 0.000 0.000 0.880 0.024 0.096
#> GSM39825 1 0.5702 0.3732 0.520 0.000 0.072 0.404 0.004
#> GSM39826 4 0.4268 0.1507 0.344 0.000 0.008 0.648 0.000
#> GSM39827 1 0.6892 0.1616 0.488 0.172 0.012 0.320 0.008
#> GSM39846 3 0.2433 0.6252 0.012 0.000 0.908 0.024 0.056
#> GSM39847 4 0.4744 -0.2299 0.476 0.000 0.016 0.508 0.000
#> GSM39848 5 0.5061 0.5289 0.000 0.240 0.036 0.028 0.696
#> GSM39849 3 0.4081 0.6678 0.080 0.000 0.812 0.092 0.016
#> GSM39850 4 0.4268 0.1507 0.344 0.000 0.008 0.648 0.000
#> GSM39851 1 0.2674 0.6254 0.868 0.000 0.012 0.120 0.000
#> GSM39855 3 0.4173 0.3461 0.000 0.000 0.688 0.012 0.300
#> GSM39856 3 0.2727 0.6361 0.024 0.000 0.896 0.024 0.056
#> GSM39858 3 0.3710 0.7034 0.144 0.000 0.808 0.000 0.048
#> GSM39859 3 0.4702 0.7107 0.256 0.000 0.700 0.008 0.036
#> GSM39862 4 0.7900 -0.0220 0.264 0.000 0.216 0.424 0.096
#> GSM39863 1 0.0579 0.6389 0.984 0.000 0.008 0.000 0.008
#> GSM39865 4 0.6450 0.0999 0.008 0.376 0.008 0.496 0.112
#> GSM39866 1 0.5672 0.3548 0.528 0.000 0.032 0.412 0.028
#> GSM39867 4 0.6008 0.2719 0.156 0.204 0.004 0.628 0.008
#> GSM39869 4 0.6971 0.1190 0.048 0.292 0.004 0.532 0.124
#> GSM39870 3 0.5616 0.4515 0.384 0.000 0.536 0.080 0.000
#> GSM39871 3 0.3861 0.7116 0.264 0.000 0.728 0.008 0.000
#> GSM39872 3 0.7158 0.0676 0.256 0.000 0.424 0.300 0.020
#> GSM39828 1 0.4898 0.4255 0.592 0.000 0.032 0.376 0.000
#> GSM39829 3 0.4524 0.6588 0.336 0.000 0.644 0.020 0.000
#> GSM39830 1 0.4677 0.2594 0.664 0.000 0.300 0.036 0.000
#> GSM39832 1 0.2522 0.5679 0.880 0.000 0.000 0.108 0.012
#> GSM39833 3 0.7006 0.3927 0.060 0.112 0.588 0.224 0.016
#> GSM39834 4 0.5355 0.0190 0.404 0.000 0.024 0.552 0.020
#> GSM39835 4 0.6054 -0.0884 0.404 0.000 0.036 0.512 0.048
#> GSM39836 4 0.4482 0.0818 0.376 0.000 0.012 0.612 0.000
#> GSM39837 4 0.4567 0.0768 0.004 0.448 0.000 0.544 0.004
#> GSM39838 4 0.7406 0.2470 0.116 0.364 0.008 0.448 0.064
#> GSM39839 3 0.4201 0.6750 0.328 0.000 0.664 0.008 0.000
#> GSM39840 1 0.1243 0.6412 0.960 0.000 0.008 0.028 0.004
#> GSM39841 1 0.1884 0.6299 0.940 0.020 0.008 0.024 0.008
#> GSM39842 1 0.2522 0.5679 0.880 0.000 0.000 0.108 0.012
#> GSM39843 1 0.3550 0.6002 0.796 0.000 0.020 0.184 0.000
#> GSM39844 1 0.2522 0.5679 0.880 0.000 0.000 0.108 0.012
#> GSM39845 3 0.4522 0.6758 0.316 0.000 0.660 0.024 0.000
#> GSM39852 1 0.5192 0.2264 0.492 0.000 0.032 0.472 0.004
#> GSM39853 4 0.4567 0.0768 0.004 0.448 0.000 0.544 0.004
#> GSM39854 4 0.6008 0.2719 0.156 0.204 0.004 0.628 0.008
#> GSM39857 3 0.3605 0.6771 0.072 0.000 0.848 0.024 0.056
#> GSM39860 5 0.1341 0.6424 0.000 0.000 0.056 0.000 0.944
#> GSM39861 3 0.3980 0.7021 0.284 0.000 0.708 0.008 0.000
#> GSM39864 1 0.5665 0.3610 0.528 0.000 0.036 0.412 0.024
#> GSM39868 4 0.5355 0.0190 0.404 0.000 0.024 0.552 0.020
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.3819 0.7147 0.672 0.000 0.012 0.316 0.000 0.000
#> GSM39819 3 0.4563 0.6781 0.136 0.000 0.700 0.164 0.000 0.000
#> GSM39820 3 0.4729 0.6605 0.128 0.000 0.676 0.196 0.000 0.000
#> GSM39821 4 0.1434 0.6914 0.012 0.000 0.000 0.940 0.048 0.000
#> GSM39822 5 0.5102 0.7868 0.000 0.228 0.000 0.148 0.624 0.000
#> GSM39823 3 0.2970 0.6828 0.004 0.000 0.860 0.060 0.004 0.072
#> GSM39824 3 0.2320 0.6073 0.000 0.000 0.864 0.000 0.004 0.132
#> GSM39825 4 0.3400 0.5943 0.092 0.000 0.064 0.832 0.008 0.004
#> GSM39826 4 0.3043 0.5923 0.008 0.000 0.000 0.792 0.200 0.000
#> GSM39827 4 0.6033 0.2865 0.132 0.024 0.004 0.560 0.276 0.004
#> GSM39846 3 0.2113 0.6433 0.000 0.000 0.896 0.008 0.004 0.092
#> GSM39847 4 0.1434 0.6914 0.012 0.000 0.000 0.940 0.048 0.000
#> GSM39848 6 0.4604 0.5917 0.004 0.180 0.004 0.000 0.100 0.712
#> GSM39849 3 0.2889 0.6601 0.068 0.000 0.868 0.016 0.048 0.000
#> GSM39850 4 0.3043 0.5923 0.008 0.000 0.000 0.792 0.200 0.000
#> GSM39851 1 0.4751 0.5173 0.536 0.000 0.012 0.424 0.028 0.000
#> GSM39855 3 0.3699 0.3840 0.000 0.000 0.660 0.000 0.004 0.336
#> GSM39856 3 0.1956 0.6509 0.000 0.000 0.908 0.008 0.004 0.080
#> GSM39858 3 0.3932 0.7110 0.056 0.000 0.812 0.064 0.004 0.064
#> GSM39859 3 0.5080 0.7089 0.100 0.000 0.704 0.144 0.000 0.052
#> GSM39862 4 0.5895 0.4729 0.008 0.000 0.224 0.616 0.052 0.100
#> GSM39863 1 0.3819 0.7147 0.672 0.000 0.012 0.316 0.000 0.000
#> GSM39865 5 0.6585 0.7124 0.004 0.188 0.004 0.140 0.568 0.096
#> GSM39866 4 0.3678 0.6030 0.104 0.000 0.020 0.824 0.036 0.016
#> GSM39867 5 0.4702 0.7027 0.120 0.016 0.000 0.148 0.716 0.000
#> GSM39869 5 0.6723 0.7158 0.040 0.116 0.000 0.128 0.596 0.120
#> GSM39870 3 0.5045 0.4814 0.084 0.000 0.552 0.364 0.000 0.000
#> GSM39871 3 0.3930 0.7126 0.092 0.000 0.764 0.144 0.000 0.000
#> GSM39872 3 0.5772 -0.0579 0.032 0.000 0.460 0.436 0.068 0.004
#> GSM39828 4 0.3858 0.4553 0.196 0.000 0.032 0.760 0.012 0.000
#> GSM39829 3 0.4737 0.6660 0.132 0.000 0.676 0.192 0.000 0.000
#> GSM39830 1 0.6085 0.2616 0.392 0.000 0.320 0.288 0.000 0.000
#> GSM39832 1 0.3510 0.7134 0.772 0.000 0.008 0.204 0.016 0.000
#> GSM39833 3 0.6152 0.3979 0.048 0.036 0.624 0.072 0.216 0.004
#> GSM39834 4 0.3828 0.6466 0.040 0.000 0.020 0.796 0.140 0.004
#> GSM39835 1 0.3765 -0.1779 0.596 0.000 0.000 0.000 0.404 0.000
#> GSM39836 4 0.2558 0.6288 0.004 0.000 0.000 0.840 0.156 0.000
#> GSM39837 5 0.5102 0.7868 0.000 0.228 0.000 0.148 0.624 0.000
#> GSM39838 5 0.6744 0.6100 0.004 0.180 0.004 0.284 0.480 0.048
#> GSM39839 3 0.4563 0.6781 0.136 0.000 0.700 0.164 0.000 0.000
#> GSM39840 1 0.3940 0.6885 0.640 0.000 0.012 0.348 0.000 0.000
#> GSM39841 1 0.4808 0.7083 0.644 0.004 0.012 0.300 0.036 0.004
#> GSM39842 1 0.3510 0.7134 0.772 0.000 0.008 0.204 0.016 0.000
#> GSM39843 4 0.4863 -0.4243 0.460 0.000 0.016 0.496 0.028 0.000
#> GSM39844 1 0.3510 0.7134 0.772 0.000 0.008 0.204 0.016 0.000
#> GSM39845 3 0.4589 0.6796 0.132 0.000 0.696 0.172 0.000 0.000
#> GSM39852 4 0.2057 0.6750 0.044 0.000 0.016 0.920 0.016 0.004
#> GSM39853 5 0.5102 0.7868 0.000 0.228 0.000 0.148 0.624 0.000
#> GSM39854 5 0.4702 0.7027 0.120 0.016 0.000 0.148 0.716 0.000
#> GSM39857 3 0.2762 0.6811 0.004 0.000 0.876 0.040 0.008 0.072
#> GSM39860 6 0.0146 0.6552 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM39861 3 0.4148 0.7033 0.108 0.000 0.744 0.148 0.000 0.000
#> GSM39864 4 0.3893 0.5876 0.116 0.000 0.024 0.808 0.036 0.016
#> GSM39868 4 0.3828 0.6466 0.040 0.000 0.020 0.796 0.140 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> SD:hclust 54 4.37e-07 1.50e-07 2
#> SD:hclust 41 1.25e-09 8.15e-08 3
#> SD:hclust 45 NA 7.29e-01 4
#> SD:hclust 30 1.38e-06 3.49e-05 5
#> SD:hclust 48 3.55e-09 1.23e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.252 0.634 0.768 0.4220 0.687 0.687
#> 3 3 0.820 0.847 0.918 0.4799 0.652 0.509
#> 4 4 0.574 0.479 0.761 0.1440 0.940 0.842
#> 5 5 0.566 0.515 0.710 0.0832 0.887 0.669
#> 6 6 0.619 0.486 0.670 0.0504 0.921 0.698
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.5629 0.85917 0.132 0.868
#> GSM39874 2 0.5629 0.85917 0.132 0.868
#> GSM39875 2 0.5629 0.85917 0.132 0.868
#> GSM39876 2 0.5629 0.85917 0.132 0.868
#> GSM39831 1 0.0000 0.74268 1.000 0.000
#> GSM39819 1 0.8267 0.64919 0.740 0.260
#> GSM39820 1 0.8267 0.64919 0.740 0.260
#> GSM39821 1 0.0672 0.74019 0.992 0.008
#> GSM39822 2 0.7745 0.78200 0.228 0.772
#> GSM39823 1 0.9983 0.41125 0.524 0.476
#> GSM39824 2 0.5737 0.65781 0.136 0.864
#> GSM39825 1 0.8443 0.64092 0.728 0.272
#> GSM39826 1 0.0672 0.74019 0.992 0.008
#> GSM39827 1 0.0672 0.74019 0.992 0.008
#> GSM39846 1 0.9983 0.41125 0.524 0.476
#> GSM39847 1 0.0376 0.74202 0.996 0.004
#> GSM39848 2 0.7453 0.79569 0.212 0.788
#> GSM39849 1 0.9983 0.41125 0.524 0.476
#> GSM39850 1 0.0672 0.74019 0.992 0.008
#> GSM39851 1 0.0376 0.74202 0.996 0.004
#> GSM39855 2 0.5737 0.65781 0.136 0.864
#> GSM39856 1 0.9983 0.41125 0.524 0.476
#> GSM39858 1 0.9954 0.43786 0.540 0.460
#> GSM39859 1 0.9954 0.43786 0.540 0.460
#> GSM39862 1 0.8555 0.53789 0.720 0.280
#> GSM39863 1 0.0000 0.74268 1.000 0.000
#> GSM39865 2 0.5408 0.85528 0.124 0.876
#> GSM39866 1 0.1414 0.74143 0.980 0.020
#> GSM39867 1 0.6712 0.55833 0.824 0.176
#> GSM39869 2 0.7883 0.77075 0.236 0.764
#> GSM39870 1 0.8267 0.64919 0.740 0.260
#> GSM39871 1 0.9954 0.43786 0.540 0.460
#> GSM39872 1 0.9970 0.42529 0.532 0.468
#> GSM39828 1 0.0672 0.74298 0.992 0.008
#> GSM39829 1 0.8016 0.65686 0.756 0.244
#> GSM39830 1 0.5294 0.70815 0.880 0.120
#> GSM39832 1 0.0376 0.74202 0.996 0.004
#> GSM39833 1 0.5737 0.67877 0.864 0.136
#> GSM39834 1 0.0672 0.74298 0.992 0.008
#> GSM39835 1 0.4562 0.66714 0.904 0.096
#> GSM39836 1 0.0376 0.74202 0.996 0.004
#> GSM39837 1 0.9661 0.04218 0.608 0.392
#> GSM39838 1 0.9732 0.00326 0.596 0.404
#> GSM39839 1 0.8267 0.64919 0.740 0.260
#> GSM39840 1 0.0376 0.74202 0.996 0.004
#> GSM39841 1 0.1633 0.72928 0.976 0.024
#> GSM39842 1 0.0376 0.74202 0.996 0.004
#> GSM39843 1 0.0938 0.74274 0.988 0.012
#> GSM39844 1 0.0376 0.74202 0.996 0.004
#> GSM39845 1 0.9580 0.54413 0.620 0.380
#> GSM39852 1 0.0000 0.74268 1.000 0.000
#> GSM39853 1 0.9661 0.04218 0.608 0.392
#> GSM39854 1 0.7219 0.52004 0.800 0.200
#> GSM39857 1 0.9983 0.41125 0.524 0.476
#> GSM39860 2 0.3879 0.72699 0.076 0.924
#> GSM39861 1 0.9580 0.54413 0.620 0.380
#> GSM39864 1 0.0672 0.74298 0.992 0.008
#> GSM39868 1 0.3879 0.72576 0.924 0.076
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.1751 0.927 0.012 0.960 0.028
#> GSM39874 2 0.1751 0.927 0.012 0.960 0.028
#> GSM39875 2 0.1751 0.927 0.012 0.960 0.028
#> GSM39876 2 0.1751 0.927 0.012 0.960 0.028
#> GSM39831 1 0.1585 0.911 0.964 0.008 0.028
#> GSM39819 3 0.2878 0.882 0.096 0.000 0.904
#> GSM39820 3 0.2878 0.882 0.096 0.000 0.904
#> GSM39821 1 0.1182 0.910 0.976 0.012 0.012
#> GSM39822 2 0.2743 0.914 0.052 0.928 0.020
#> GSM39823 3 0.1620 0.917 0.012 0.024 0.964
#> GSM39824 3 0.1620 0.895 0.012 0.024 0.964
#> GSM39825 3 0.2682 0.893 0.076 0.004 0.920
#> GSM39826 1 0.0592 0.906 0.988 0.012 0.000
#> GSM39827 1 0.1482 0.910 0.968 0.020 0.012
#> GSM39846 3 0.1337 0.918 0.012 0.016 0.972
#> GSM39847 1 0.1182 0.910 0.976 0.012 0.012
#> GSM39848 2 0.3406 0.895 0.068 0.904 0.028
#> GSM39849 3 0.1337 0.918 0.012 0.016 0.972
#> GSM39850 1 0.0592 0.906 0.988 0.012 0.000
#> GSM39851 1 0.1163 0.911 0.972 0.000 0.028
#> GSM39855 3 0.1620 0.895 0.012 0.024 0.964
#> GSM39856 3 0.1337 0.918 0.012 0.016 0.972
#> GSM39858 3 0.0592 0.921 0.012 0.000 0.988
#> GSM39859 3 0.0592 0.921 0.012 0.000 0.988
#> GSM39862 1 0.7230 0.422 0.616 0.040 0.344
#> GSM39863 1 0.1585 0.911 0.964 0.008 0.028
#> GSM39865 2 0.2434 0.922 0.024 0.940 0.036
#> GSM39866 1 0.1832 0.909 0.956 0.008 0.036
#> GSM39867 1 0.2680 0.871 0.924 0.068 0.008
#> GSM39869 2 0.2187 0.920 0.028 0.948 0.024
#> GSM39870 3 0.2878 0.882 0.096 0.000 0.904
#> GSM39871 3 0.0592 0.921 0.012 0.000 0.988
#> GSM39872 3 0.1905 0.915 0.016 0.028 0.956
#> GSM39828 1 0.1267 0.911 0.972 0.004 0.024
#> GSM39829 3 0.2959 0.880 0.100 0.000 0.900
#> GSM39830 3 0.6267 0.226 0.452 0.000 0.548
#> GSM39832 1 0.1751 0.911 0.960 0.012 0.028
#> GSM39833 1 0.1337 0.904 0.972 0.012 0.016
#> GSM39834 1 0.2297 0.904 0.944 0.020 0.036
#> GSM39835 1 0.1585 0.896 0.964 0.028 0.008
#> GSM39836 1 0.0592 0.906 0.988 0.012 0.000
#> GSM39837 1 0.6669 0.142 0.524 0.468 0.008
#> GSM39838 1 0.6404 0.466 0.644 0.344 0.012
#> GSM39839 3 0.2878 0.882 0.096 0.000 0.904
#> GSM39840 1 0.1453 0.912 0.968 0.008 0.024
#> GSM39841 1 0.1585 0.911 0.964 0.008 0.028
#> GSM39842 1 0.1751 0.911 0.960 0.012 0.028
#> GSM39843 1 0.1163 0.911 0.972 0.000 0.028
#> GSM39844 1 0.1751 0.911 0.960 0.012 0.028
#> GSM39845 3 0.0592 0.921 0.012 0.000 0.988
#> GSM39852 1 0.1315 0.908 0.972 0.020 0.008
#> GSM39853 1 0.6669 0.163 0.524 0.468 0.008
#> GSM39854 1 0.2680 0.871 0.924 0.068 0.008
#> GSM39857 3 0.1620 0.917 0.012 0.024 0.964
#> GSM39860 2 0.6404 0.521 0.012 0.644 0.344
#> GSM39861 3 0.0592 0.921 0.012 0.000 0.988
#> GSM39864 1 0.1751 0.910 0.960 0.012 0.028
#> GSM39868 1 0.2339 0.894 0.940 0.012 0.048
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0469 0.7942 0.000 0.988 0.012 0.000
#> GSM39874 2 0.0469 0.7942 0.000 0.988 0.012 0.000
#> GSM39875 2 0.0469 0.7942 0.000 0.988 0.012 0.000
#> GSM39876 2 0.0469 0.7942 0.000 0.988 0.012 0.000
#> GSM39831 4 0.4925 -0.4690 0.428 0.000 0.000 0.572
#> GSM39819 3 0.3764 0.8195 0.116 0.000 0.844 0.040
#> GSM39820 3 0.3734 0.8213 0.108 0.000 0.848 0.044
#> GSM39821 4 0.0000 0.4438 0.000 0.000 0.000 1.000
#> GSM39822 2 0.5321 0.7854 0.296 0.672 0.000 0.032
#> GSM39823 3 0.1118 0.8553 0.036 0.000 0.964 0.000
#> GSM39824 3 0.3726 0.7083 0.212 0.000 0.788 0.000
#> GSM39825 3 0.5350 0.6994 0.060 0.008 0.744 0.188
#> GSM39826 4 0.0592 0.4386 0.016 0.000 0.000 0.984
#> GSM39827 4 0.3486 0.1838 0.188 0.000 0.000 0.812
#> GSM39846 3 0.0336 0.8613 0.008 0.000 0.992 0.000
#> GSM39847 4 0.0592 0.4491 0.016 0.000 0.000 0.984
#> GSM39848 2 0.6919 0.6689 0.368 0.516 0.000 0.116
#> GSM39849 3 0.1792 0.8432 0.068 0.000 0.932 0.000
#> GSM39850 4 0.0469 0.4394 0.012 0.000 0.000 0.988
#> GSM39851 4 0.3688 0.2048 0.208 0.000 0.000 0.792
#> GSM39855 3 0.4053 0.6846 0.228 0.004 0.768 0.000
#> GSM39856 3 0.0469 0.8608 0.012 0.000 0.988 0.000
#> GSM39858 3 0.0336 0.8613 0.008 0.000 0.992 0.000
#> GSM39859 3 0.0188 0.8616 0.004 0.000 0.996 0.000
#> GSM39862 4 0.7031 0.1687 0.408 0.012 0.084 0.496
#> GSM39863 4 0.4925 -0.4690 0.428 0.000 0.000 0.572
#> GSM39865 2 0.5228 0.7839 0.312 0.664 0.000 0.024
#> GSM39866 4 0.5012 0.0821 0.320 0.008 0.004 0.668
#> GSM39867 4 0.5257 -0.4963 0.444 0.008 0.000 0.548
#> GSM39869 2 0.4868 0.7892 0.304 0.684 0.000 0.012
#> GSM39870 3 0.3734 0.8213 0.108 0.000 0.848 0.044
#> GSM39871 3 0.0000 0.8614 0.000 0.000 1.000 0.000
#> GSM39872 3 0.4963 0.7489 0.136 0.012 0.788 0.064
#> GSM39828 4 0.2408 0.4248 0.104 0.000 0.000 0.896
#> GSM39829 3 0.4015 0.8124 0.116 0.000 0.832 0.052
#> GSM39830 3 0.7381 0.2684 0.180 0.000 0.492 0.328
#> GSM39832 1 0.4994 0.7355 0.520 0.000 0.000 0.480
#> GSM39833 4 0.3074 0.3778 0.152 0.000 0.000 0.848
#> GSM39834 4 0.4240 0.3773 0.200 0.012 0.004 0.784
#> GSM39835 1 0.5163 0.3940 0.516 0.004 0.000 0.480
#> GSM39836 4 0.0817 0.4501 0.024 0.000 0.000 0.976
#> GSM39837 4 0.6794 0.0832 0.116 0.328 0.000 0.556
#> GSM39838 4 0.6653 0.1953 0.328 0.104 0.000 0.568
#> GSM39839 3 0.3764 0.8195 0.116 0.000 0.844 0.040
#> GSM39840 4 0.4624 -0.2394 0.340 0.000 0.000 0.660
#> GSM39841 4 0.4948 -0.5261 0.440 0.000 0.000 0.560
#> GSM39842 1 0.4907 0.6999 0.580 0.000 0.000 0.420
#> GSM39843 4 0.3400 0.2778 0.180 0.000 0.000 0.820
#> GSM39844 1 0.4994 0.7355 0.520 0.000 0.000 0.480
#> GSM39845 3 0.0469 0.8623 0.012 0.000 0.988 0.000
#> GSM39852 4 0.2124 0.4443 0.068 0.008 0.000 0.924
#> GSM39853 4 0.7717 -0.1309 0.264 0.288 0.000 0.448
#> GSM39854 4 0.5257 -0.4750 0.444 0.008 0.000 0.548
#> GSM39857 3 0.1118 0.8553 0.036 0.000 0.964 0.000
#> GSM39860 2 0.8165 0.4970 0.352 0.392 0.244 0.012
#> GSM39861 3 0.0895 0.8599 0.020 0.000 0.976 0.004
#> GSM39864 4 0.4814 0.0911 0.316 0.008 0.000 0.676
#> GSM39868 4 0.4377 0.3822 0.188 0.008 0.016 0.788
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.4251 1.00000 0.000 0.624 0.004 0.000 0.372
#> GSM39874 2 0.4251 1.00000 0.000 0.624 0.004 0.000 0.372
#> GSM39875 2 0.4251 1.00000 0.000 0.624 0.004 0.000 0.372
#> GSM39876 2 0.4251 1.00000 0.000 0.624 0.004 0.000 0.372
#> GSM39831 1 0.5633 0.40926 0.580 0.080 0.004 0.336 0.000
#> GSM39819 3 0.5326 0.69360 0.124 0.120 0.724 0.032 0.000
#> GSM39820 3 0.5145 0.70017 0.116 0.112 0.740 0.032 0.000
#> GSM39821 4 0.1300 0.58011 0.028 0.000 0.000 0.956 0.016
#> GSM39822 5 0.2935 0.39694 0.004 0.016 0.000 0.120 0.860
#> GSM39823 3 0.2665 0.74197 0.020 0.048 0.900 0.000 0.032
#> GSM39824 3 0.5975 0.42651 0.056 0.056 0.632 0.000 0.256
#> GSM39825 3 0.5746 0.59402 0.012 0.060 0.692 0.196 0.040
#> GSM39826 4 0.1560 0.57133 0.028 0.004 0.000 0.948 0.020
#> GSM39827 4 0.4569 0.44268 0.160 0.036 0.000 0.768 0.036
#> GSM39846 3 0.0613 0.77312 0.004 0.008 0.984 0.000 0.004
#> GSM39847 4 0.1278 0.58254 0.020 0.004 0.000 0.960 0.016
#> GSM39848 5 0.5172 0.47053 0.064 0.116 0.000 0.072 0.748
#> GSM39849 3 0.3572 0.72781 0.068 0.076 0.844 0.000 0.012
#> GSM39850 4 0.1560 0.57133 0.028 0.004 0.000 0.948 0.020
#> GSM39851 4 0.5255 0.28278 0.284 0.068 0.004 0.644 0.000
#> GSM39855 3 0.6550 0.29907 0.060 0.080 0.564 0.000 0.296
#> GSM39856 3 0.0613 0.77312 0.004 0.008 0.984 0.000 0.004
#> GSM39858 3 0.0324 0.77478 0.004 0.004 0.992 0.000 0.000
#> GSM39859 3 0.0000 0.77522 0.000 0.000 1.000 0.000 0.000
#> GSM39862 5 0.8798 0.25338 0.108 0.168 0.052 0.276 0.396
#> GSM39863 1 0.5633 0.40926 0.580 0.080 0.004 0.336 0.000
#> GSM39865 5 0.1364 0.44085 0.000 0.012 0.000 0.036 0.952
#> GSM39866 4 0.7466 0.07515 0.356 0.172 0.008 0.424 0.040
#> GSM39867 1 0.6362 0.41173 0.560 0.012 0.000 0.268 0.160
#> GSM39869 5 0.1808 0.40925 0.004 0.020 0.000 0.040 0.936
#> GSM39870 3 0.5145 0.70017 0.116 0.112 0.740 0.032 0.000
#> GSM39871 3 0.0162 0.77513 0.000 0.004 0.996 0.000 0.000
#> GSM39872 3 0.7905 0.40799 0.096 0.164 0.564 0.088 0.088
#> GSM39828 4 0.4023 0.52061 0.144 0.048 0.004 0.800 0.004
#> GSM39829 3 0.5474 0.68782 0.128 0.116 0.716 0.040 0.000
#> GSM39830 3 0.8047 0.25604 0.184 0.148 0.436 0.232 0.000
#> GSM39832 1 0.3205 0.60435 0.816 0.004 0.000 0.176 0.004
#> GSM39833 4 0.5302 0.50444 0.104 0.076 0.004 0.748 0.068
#> GSM39834 4 0.7482 0.39163 0.200 0.160 0.020 0.552 0.068
#> GSM39835 1 0.6561 0.39476 0.624 0.072 0.000 0.144 0.160
#> GSM39836 4 0.1623 0.58045 0.020 0.016 0.000 0.948 0.016
#> GSM39837 4 0.5745 0.00445 0.036 0.028 0.000 0.520 0.416
#> GSM39838 4 0.5925 0.03151 0.020 0.060 0.000 0.520 0.400
#> GSM39839 3 0.5326 0.69360 0.124 0.120 0.724 0.032 0.000
#> GSM39840 4 0.5747 -0.21293 0.460 0.072 0.004 0.464 0.000
#> GSM39841 1 0.5988 0.41321 0.580 0.084 0.004 0.320 0.012
#> GSM39842 1 0.3022 0.58578 0.848 0.012 0.000 0.136 0.004
#> GSM39843 4 0.5180 0.31958 0.260 0.072 0.004 0.664 0.000
#> GSM39844 1 0.3205 0.60435 0.816 0.004 0.000 0.176 0.004
#> GSM39845 3 0.0324 0.77478 0.004 0.004 0.992 0.000 0.000
#> GSM39852 4 0.3997 0.54626 0.040 0.072 0.000 0.828 0.060
#> GSM39853 5 0.7386 -0.01354 0.236 0.036 0.000 0.312 0.416
#> GSM39854 1 0.6422 0.40504 0.552 0.012 0.000 0.268 0.168
#> GSM39857 3 0.2897 0.73565 0.020 0.052 0.888 0.000 0.040
#> GSM39860 5 0.6851 0.34388 0.080 0.148 0.160 0.004 0.608
#> GSM39861 3 0.0955 0.77288 0.004 0.028 0.968 0.000 0.000
#> GSM39864 4 0.7414 0.05794 0.376 0.160 0.008 0.416 0.040
#> GSM39868 4 0.7552 0.39587 0.184 0.160 0.032 0.560 0.064
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.5438 0.4545 0.624 0.000 0.000 0.236 0.024 0.116
#> GSM39819 3 0.6427 0.5575 0.076 0.000 0.592 0.020 0.112 0.200
#> GSM39820 3 0.5939 0.5829 0.052 0.000 0.636 0.020 0.096 0.196
#> GSM39821 4 0.0622 0.6857 0.012 0.000 0.000 0.980 0.000 0.008
#> GSM39822 5 0.5774 0.4921 0.000 0.256 0.000 0.164 0.564 0.016
#> GSM39823 3 0.2978 0.6508 0.008 0.000 0.856 0.000 0.052 0.084
#> GSM39824 3 0.5650 0.3347 0.016 0.000 0.584 0.000 0.248 0.152
#> GSM39825 3 0.5343 0.4001 0.004 0.000 0.636 0.096 0.020 0.244
#> GSM39826 4 0.0951 0.6861 0.020 0.000 0.000 0.968 0.004 0.008
#> GSM39827 4 0.5024 0.4602 0.176 0.000 0.000 0.700 0.064 0.060
#> GSM39846 3 0.0547 0.7069 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM39847 4 0.0622 0.6828 0.008 0.000 0.000 0.980 0.000 0.012
#> GSM39848 5 0.5879 0.4298 0.016 0.096 0.000 0.040 0.620 0.228
#> GSM39849 3 0.5061 0.5665 0.056 0.000 0.684 0.000 0.056 0.204
#> GSM39850 4 0.0951 0.6861 0.020 0.000 0.000 0.968 0.004 0.008
#> GSM39851 4 0.5023 0.3672 0.256 0.000 0.000 0.652 0.024 0.068
#> GSM39855 3 0.6055 0.1789 0.016 0.000 0.492 0.000 0.316 0.176
#> GSM39856 3 0.0632 0.7074 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM39858 3 0.0291 0.7123 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM39859 3 0.0000 0.7109 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM39862 6 0.6316 -0.0102 0.028 0.000 0.020 0.104 0.360 0.488
#> GSM39863 1 0.5438 0.4545 0.624 0.000 0.000 0.236 0.024 0.116
#> GSM39865 5 0.4281 0.5207 0.000 0.244 0.000 0.020 0.708 0.028
#> GSM39866 6 0.6638 0.1348 0.336 0.000 0.004 0.244 0.024 0.392
#> GSM39867 1 0.6352 0.2281 0.532 0.004 0.000 0.176 0.248 0.040
#> GSM39869 5 0.4323 0.5116 0.012 0.248 0.000 0.020 0.708 0.012
#> GSM39870 3 0.5939 0.5829 0.052 0.000 0.636 0.020 0.096 0.196
#> GSM39871 3 0.0891 0.7119 0.000 0.000 0.968 0.000 0.024 0.008
#> GSM39872 6 0.5583 0.0822 0.020 0.000 0.352 0.032 0.036 0.560
#> GSM39828 4 0.4354 0.4543 0.044 0.000 0.000 0.704 0.012 0.240
#> GSM39829 3 0.6447 0.5035 0.056 0.000 0.556 0.024 0.096 0.268
#> GSM39830 3 0.8173 0.2620 0.104 0.000 0.396 0.124 0.120 0.256
#> GSM39832 1 0.1765 0.5534 0.904 0.000 0.000 0.096 0.000 0.000
#> GSM39833 4 0.6163 0.4574 0.068 0.004 0.012 0.628 0.120 0.168
#> GSM39834 6 0.5278 0.4379 0.072 0.000 0.000 0.244 0.040 0.644
#> GSM39835 1 0.6056 0.2251 0.564 0.000 0.000 0.036 0.184 0.216
#> GSM39836 4 0.1333 0.6641 0.000 0.000 0.000 0.944 0.008 0.048
#> GSM39837 4 0.6344 -0.0555 0.012 0.192 0.000 0.504 0.276 0.016
#> GSM39838 5 0.6266 0.2859 0.000 0.036 0.000 0.356 0.464 0.144
#> GSM39839 3 0.6427 0.5575 0.076 0.000 0.592 0.020 0.112 0.200
#> GSM39840 1 0.5560 0.1017 0.468 0.000 0.000 0.436 0.024 0.072
#> GSM39841 1 0.6159 0.4432 0.564 0.000 0.000 0.248 0.064 0.124
#> GSM39842 1 0.1857 0.5084 0.928 0.000 0.000 0.032 0.012 0.028
#> GSM39843 4 0.5035 0.3932 0.236 0.000 0.000 0.664 0.028 0.072
#> GSM39844 1 0.1765 0.5534 0.904 0.000 0.000 0.096 0.000 0.000
#> GSM39845 3 0.0508 0.7126 0.000 0.000 0.984 0.000 0.004 0.012
#> GSM39852 4 0.4136 0.3346 0.004 0.000 0.000 0.692 0.032 0.272
#> GSM39853 5 0.8136 0.1545 0.220 0.180 0.000 0.280 0.292 0.028
#> GSM39854 1 0.6423 0.2111 0.520 0.004 0.000 0.188 0.248 0.040
#> GSM39857 3 0.3269 0.6352 0.008 0.000 0.832 0.000 0.052 0.108
#> GSM39860 5 0.6732 0.2687 0.024 0.068 0.132 0.000 0.548 0.228
#> GSM39861 3 0.1720 0.7046 0.000 0.000 0.928 0.000 0.032 0.040
#> GSM39864 6 0.6457 0.1549 0.332 0.000 0.004 0.256 0.012 0.396
#> GSM39868 6 0.5268 0.4251 0.060 0.000 0.000 0.272 0.040 0.628
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> SD:kmeans 46 1.81e-03 5.12e-04 2
#> SD:kmeans 53 2.55e-05 5.85e-05 3
#> SD:kmeans 30 1.75e-03 2.29e-04 4
#> SD:kmeans 31 8.50e-07 2.00e-06 5
#> SD:kmeans 29 7.82e-06 1.06e-05 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.318 0.565 0.808 0.5005 0.501 0.501
#> 3 3 0.890 0.913 0.962 0.3429 0.658 0.416
#> 4 4 0.645 0.703 0.843 0.1179 0.882 0.661
#> 5 5 0.658 0.623 0.754 0.0647 0.950 0.807
#> 6 6 0.661 0.492 0.719 0.0399 0.989 0.950
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.9608 0.429 0.384 0.616
#> GSM39874 2 0.9608 0.429 0.384 0.616
#> GSM39875 2 0.9608 0.429 0.384 0.616
#> GSM39876 2 0.9608 0.429 0.384 0.616
#> GSM39831 1 0.0000 0.724 1.000 0.000
#> GSM39819 1 0.9850 0.329 0.572 0.428
#> GSM39820 1 0.9850 0.329 0.572 0.428
#> GSM39821 1 0.0376 0.723 0.996 0.004
#> GSM39822 2 0.9635 0.424 0.388 0.612
#> GSM39823 2 0.5059 0.666 0.112 0.888
#> GSM39824 2 0.0000 0.656 0.000 1.000
#> GSM39825 2 0.8327 0.485 0.264 0.736
#> GSM39826 1 0.5408 0.653 0.876 0.124
#> GSM39827 1 0.2603 0.706 0.956 0.044
#> GSM39846 2 0.5059 0.666 0.112 0.888
#> GSM39847 1 0.0000 0.724 1.000 0.000
#> GSM39848 2 0.9635 0.424 0.388 0.612
#> GSM39849 2 0.4431 0.667 0.092 0.908
#> GSM39850 1 0.5059 0.662 0.888 0.112
#> GSM39851 1 0.0000 0.724 1.000 0.000
#> GSM39855 2 0.0000 0.656 0.000 1.000
#> GSM39856 2 0.5059 0.666 0.112 0.888
#> GSM39858 2 0.6801 0.615 0.180 0.820
#> GSM39859 2 0.6801 0.615 0.180 0.820
#> GSM39862 2 0.3584 0.638 0.068 0.932
#> GSM39863 1 0.0000 0.724 1.000 0.000
#> GSM39865 2 0.9608 0.429 0.384 0.616
#> GSM39866 1 0.9358 0.430 0.648 0.352
#> GSM39867 1 0.5059 0.662 0.888 0.112
#> GSM39869 2 0.9795 0.373 0.416 0.584
#> GSM39870 1 0.9850 0.329 0.572 0.428
#> GSM39871 2 0.5629 0.654 0.132 0.868
#> GSM39872 2 0.5059 0.666 0.112 0.888
#> GSM39828 1 0.1414 0.716 0.980 0.020
#> GSM39829 1 0.9795 0.349 0.584 0.416
#> GSM39830 1 0.9608 0.395 0.616 0.384
#> GSM39832 1 0.0000 0.724 1.000 0.000
#> GSM39833 2 0.9775 0.381 0.412 0.588
#> GSM39834 1 0.9000 0.472 0.684 0.316
#> GSM39835 1 0.9661 0.158 0.608 0.392
#> GSM39836 1 0.5059 0.662 0.888 0.112
#> GSM39837 1 0.6801 0.598 0.820 0.180
#> GSM39838 1 0.9087 0.349 0.676 0.324
#> GSM39839 1 0.9850 0.329 0.572 0.428
#> GSM39840 1 0.0000 0.724 1.000 0.000
#> GSM39841 1 0.0000 0.724 1.000 0.000
#> GSM39842 1 0.0000 0.724 1.000 0.000
#> GSM39843 1 0.0938 0.720 0.988 0.012
#> GSM39844 1 0.0000 0.724 1.000 0.000
#> GSM39845 2 0.6801 0.615 0.180 0.820
#> GSM39852 1 0.1843 0.714 0.972 0.028
#> GSM39853 1 0.6801 0.598 0.820 0.180
#> GSM39854 1 0.6801 0.598 0.820 0.180
#> GSM39857 2 0.5059 0.666 0.112 0.888
#> GSM39860 2 0.0000 0.656 0.000 1.000
#> GSM39861 2 0.6801 0.615 0.180 0.820
#> GSM39864 1 0.9552 0.405 0.624 0.376
#> GSM39868 1 0.9608 0.395 0.616 0.384
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39831 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39819 3 0.0747 0.9685 0.016 0.000 0.984
#> GSM39820 3 0.0747 0.9685 0.016 0.000 0.984
#> GSM39821 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39822 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39823 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39824 3 0.0892 0.9618 0.000 0.020 0.980
#> GSM39825 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39826 1 0.0424 0.9505 0.992 0.008 0.000
#> GSM39827 1 0.1289 0.9321 0.968 0.032 0.000
#> GSM39846 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39847 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39848 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39849 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39850 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39851 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39855 3 0.2711 0.8931 0.000 0.088 0.912
#> GSM39856 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39862 2 0.6805 0.5988 0.268 0.688 0.044
#> GSM39863 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39865 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39866 1 0.0592 0.9472 0.988 0.000 0.012
#> GSM39867 1 0.6305 0.0473 0.516 0.484 0.000
#> GSM39869 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39870 3 0.0747 0.9685 0.016 0.000 0.984
#> GSM39871 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39872 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39828 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39829 3 0.1163 0.9590 0.028 0.000 0.972
#> GSM39830 3 0.4931 0.7072 0.232 0.000 0.768
#> GSM39832 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39833 2 0.1919 0.9156 0.024 0.956 0.020
#> GSM39834 1 0.3797 0.8696 0.892 0.056 0.052
#> GSM39835 2 0.3340 0.8411 0.120 0.880 0.000
#> GSM39836 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39837 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39838 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39839 3 0.0592 0.9705 0.012 0.000 0.988
#> GSM39840 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39841 1 0.4605 0.7278 0.796 0.204 0.000
#> GSM39842 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39843 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39844 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39845 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39852 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39853 2 0.0000 0.9376 0.000 1.000 0.000
#> GSM39854 2 0.4555 0.7358 0.200 0.800 0.000
#> GSM39857 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39860 2 0.4842 0.6964 0.000 0.776 0.224
#> GSM39861 3 0.0000 0.9754 0.000 0.000 1.000
#> GSM39864 1 0.0000 0.9552 1.000 0.000 0.000
#> GSM39868 1 0.1529 0.9237 0.960 0.000 0.040
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0592 0.695 0.984 0.000 0.000 0.016
#> GSM39819 3 0.3836 0.797 0.168 0.000 0.816 0.016
#> GSM39820 3 0.3853 0.801 0.160 0.000 0.820 0.020
#> GSM39821 4 0.3610 0.754 0.200 0.000 0.000 0.800
#> GSM39822 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM39823 3 0.1716 0.863 0.000 0.000 0.936 0.064
#> GSM39824 3 0.3168 0.836 0.000 0.060 0.884 0.056
#> GSM39825 3 0.3217 0.808 0.012 0.000 0.860 0.128
#> GSM39826 4 0.3539 0.758 0.176 0.004 0.000 0.820
#> GSM39827 1 0.4252 0.472 0.744 0.004 0.000 0.252
#> GSM39846 3 0.0336 0.874 0.000 0.000 0.992 0.008
#> GSM39847 4 0.3649 0.753 0.204 0.000 0.000 0.796
#> GSM39848 2 0.1716 0.879 0.000 0.936 0.000 0.064
#> GSM39849 3 0.1661 0.865 0.000 0.004 0.944 0.052
#> GSM39850 4 0.3528 0.759 0.192 0.000 0.000 0.808
#> GSM39851 1 0.4961 -0.196 0.552 0.000 0.000 0.448
#> GSM39855 3 0.4336 0.775 0.000 0.128 0.812 0.060
#> GSM39856 3 0.0707 0.872 0.000 0.000 0.980 0.020
#> GSM39858 3 0.0000 0.873 0.000 0.000 1.000 0.000
#> GSM39859 3 0.0000 0.873 0.000 0.000 1.000 0.000
#> GSM39862 4 0.5149 0.523 0.008 0.092 0.124 0.776
#> GSM39863 1 0.0592 0.695 0.984 0.000 0.000 0.016
#> GSM39865 2 0.0469 0.906 0.000 0.988 0.000 0.012
#> GSM39866 1 0.4119 0.589 0.796 0.004 0.012 0.188
#> GSM39867 1 0.5906 0.462 0.644 0.292 0.000 0.064
#> GSM39869 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM39870 3 0.4105 0.799 0.156 0.000 0.812 0.032
#> GSM39871 3 0.0336 0.874 0.000 0.000 0.992 0.008
#> GSM39872 3 0.4475 0.719 0.008 0.004 0.748 0.240
#> GSM39828 4 0.4103 0.709 0.256 0.000 0.000 0.744
#> GSM39829 3 0.4225 0.778 0.184 0.000 0.792 0.024
#> GSM39830 3 0.7359 0.314 0.312 0.000 0.504 0.184
#> GSM39832 1 0.0336 0.698 0.992 0.000 0.000 0.008
#> GSM39833 2 0.7058 0.579 0.096 0.648 0.048 0.208
#> GSM39834 4 0.6127 0.395 0.288 0.008 0.060 0.644
#> GSM39835 1 0.6635 0.241 0.524 0.388 0.000 0.088
#> GSM39836 4 0.3074 0.758 0.152 0.000 0.000 0.848
#> GSM39837 2 0.1256 0.895 0.008 0.964 0.000 0.028
#> GSM39838 2 0.3266 0.783 0.000 0.832 0.000 0.168
#> GSM39839 3 0.3790 0.800 0.164 0.000 0.820 0.016
#> GSM39840 1 0.4134 0.404 0.740 0.000 0.000 0.260
#> GSM39841 1 0.1706 0.689 0.948 0.036 0.000 0.016
#> GSM39842 1 0.0336 0.698 0.992 0.000 0.000 0.008
#> GSM39843 4 0.4999 0.258 0.492 0.000 0.000 0.508
#> GSM39844 1 0.0336 0.698 0.992 0.000 0.000 0.008
#> GSM39845 3 0.0188 0.873 0.000 0.000 0.996 0.004
#> GSM39852 4 0.2530 0.733 0.112 0.000 0.000 0.888
#> GSM39853 2 0.1610 0.884 0.032 0.952 0.000 0.016
#> GSM39854 1 0.6650 0.156 0.484 0.432 0.000 0.084
#> GSM39857 3 0.2011 0.857 0.000 0.000 0.920 0.080
#> GSM39860 2 0.6552 0.540 0.000 0.628 0.228 0.144
#> GSM39861 3 0.0188 0.874 0.000 0.000 0.996 0.004
#> GSM39864 1 0.3074 0.628 0.848 0.000 0.000 0.152
#> GSM39868 4 0.5691 0.425 0.304 0.000 0.048 0.648
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0162 0.862 0.004 0.996 0.000 0.000 0.000
#> GSM39874 2 0.0162 0.862 0.004 0.996 0.000 0.000 0.000
#> GSM39875 2 0.0162 0.862 0.004 0.996 0.000 0.000 0.000
#> GSM39876 2 0.0162 0.862 0.004 0.996 0.000 0.000 0.000
#> GSM39831 1 0.2370 0.726 0.904 0.000 0.000 0.040 0.056
#> GSM39819 3 0.4622 0.656 0.068 0.000 0.756 0.012 0.164
#> GSM39820 3 0.4512 0.658 0.048 0.000 0.760 0.016 0.176
#> GSM39821 4 0.1357 0.792 0.048 0.000 0.000 0.948 0.004
#> GSM39822 2 0.0162 0.861 0.000 0.996 0.000 0.000 0.004
#> GSM39823 3 0.3715 0.589 0.000 0.000 0.736 0.004 0.260
#> GSM39824 3 0.5148 0.493 0.004 0.052 0.660 0.004 0.280
#> GSM39825 3 0.5522 0.471 0.024 0.000 0.680 0.084 0.212
#> GSM39826 4 0.1365 0.785 0.040 0.004 0.000 0.952 0.004
#> GSM39827 1 0.5126 0.511 0.636 0.000 0.000 0.300 0.064
#> GSM39846 3 0.1704 0.719 0.000 0.000 0.928 0.004 0.068
#> GSM39847 4 0.1281 0.789 0.032 0.000 0.000 0.956 0.012
#> GSM39848 2 0.3885 0.607 0.000 0.724 0.000 0.008 0.268
#> GSM39849 3 0.4108 0.556 0.000 0.008 0.684 0.000 0.308
#> GSM39850 4 0.1357 0.789 0.048 0.000 0.000 0.948 0.004
#> GSM39851 4 0.4963 0.448 0.352 0.000 0.000 0.608 0.040
#> GSM39855 3 0.5887 0.380 0.004 0.104 0.596 0.004 0.292
#> GSM39856 3 0.2074 0.702 0.000 0.000 0.896 0.000 0.104
#> GSM39858 3 0.0703 0.727 0.000 0.000 0.976 0.000 0.024
#> GSM39859 3 0.0794 0.725 0.000 0.000 0.972 0.000 0.028
#> GSM39862 5 0.5470 0.455 0.000 0.044 0.044 0.236 0.676
#> GSM39863 1 0.2504 0.722 0.896 0.000 0.000 0.040 0.064
#> GSM39865 2 0.1205 0.850 0.000 0.956 0.000 0.004 0.040
#> GSM39866 1 0.6704 0.455 0.568 0.008 0.028 0.132 0.264
#> GSM39867 1 0.4843 0.651 0.772 0.104 0.000 0.056 0.068
#> GSM39869 2 0.1282 0.850 0.000 0.952 0.000 0.004 0.044
#> GSM39870 3 0.4774 0.650 0.056 0.000 0.744 0.020 0.180
#> GSM39871 3 0.1410 0.720 0.000 0.000 0.940 0.000 0.060
#> GSM39872 5 0.4524 0.226 0.000 0.000 0.336 0.020 0.644
#> GSM39828 4 0.4647 0.678 0.092 0.000 0.000 0.736 0.172
#> GSM39829 3 0.4938 0.630 0.064 0.000 0.716 0.012 0.208
#> GSM39830 3 0.7812 0.288 0.188 0.000 0.476 0.128 0.208
#> GSM39832 1 0.1012 0.737 0.968 0.000 0.000 0.020 0.012
#> GSM39833 2 0.7931 0.275 0.056 0.508 0.044 0.228 0.164
#> GSM39834 5 0.6206 0.406 0.164 0.004 0.012 0.208 0.612
#> GSM39835 1 0.6583 0.448 0.588 0.176 0.000 0.036 0.200
#> GSM39836 4 0.1701 0.766 0.016 0.000 0.000 0.936 0.048
#> GSM39837 2 0.2511 0.811 0.004 0.892 0.000 0.088 0.016
#> GSM39838 2 0.5059 0.621 0.000 0.700 0.000 0.176 0.124
#> GSM39839 3 0.4622 0.656 0.068 0.000 0.756 0.012 0.164
#> GSM39840 1 0.4249 0.454 0.688 0.000 0.000 0.296 0.016
#> GSM39841 1 0.3432 0.721 0.860 0.028 0.000 0.052 0.060
#> GSM39842 1 0.1364 0.733 0.952 0.000 0.000 0.012 0.036
#> GSM39843 4 0.5381 0.538 0.288 0.000 0.012 0.640 0.060
#> GSM39844 1 0.1012 0.737 0.968 0.000 0.000 0.020 0.012
#> GSM39845 3 0.1357 0.725 0.004 0.000 0.948 0.000 0.048
#> GSM39852 4 0.4468 0.523 0.044 0.000 0.000 0.716 0.240
#> GSM39853 2 0.3201 0.794 0.064 0.872 0.000 0.036 0.028
#> GSM39854 1 0.6725 0.397 0.548 0.300 0.000 0.080 0.072
#> GSM39857 3 0.4201 0.486 0.000 0.000 0.664 0.008 0.328
#> GSM39860 5 0.6692 0.212 0.004 0.360 0.160 0.008 0.468
#> GSM39861 3 0.1502 0.729 0.004 0.000 0.940 0.000 0.056
#> GSM39864 1 0.5613 0.480 0.604 0.000 0.000 0.108 0.288
#> GSM39868 5 0.7047 0.276 0.164 0.000 0.040 0.300 0.496
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.0146 0.8035 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39874 5 0.0146 0.8035 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39875 5 0.0146 0.8035 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39876 5 0.0146 0.8035 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39831 1 0.3217 0.6426 0.840 0.108 0.000 0.028 0.000 0.024
#> GSM39819 3 0.4634 -0.0826 0.044 0.400 0.556 0.000 0.000 0.000
#> GSM39820 3 0.4692 0.0748 0.020 0.360 0.600 0.004 0.000 0.016
#> GSM39821 4 0.1138 0.7632 0.024 0.004 0.000 0.960 0.000 0.012
#> GSM39822 5 0.0964 0.8006 0.000 0.016 0.000 0.004 0.968 0.012
#> GSM39823 3 0.4701 0.4946 0.000 0.148 0.684 0.000 0.000 0.168
#> GSM39824 3 0.4958 0.4598 0.000 0.068 0.680 0.000 0.032 0.220
#> GSM39825 3 0.6146 0.0927 0.000 0.196 0.540 0.032 0.000 0.232
#> GSM39826 4 0.1508 0.7527 0.020 0.016 0.000 0.948 0.004 0.012
#> GSM39827 1 0.6060 0.3836 0.524 0.120 0.000 0.316 0.000 0.040
#> GSM39846 3 0.2733 0.5692 0.000 0.080 0.864 0.000 0.000 0.056
#> GSM39847 4 0.1710 0.7601 0.028 0.016 0.000 0.936 0.000 0.020
#> GSM39848 5 0.4915 0.3918 0.004 0.048 0.000 0.004 0.564 0.380
#> GSM39849 3 0.5525 0.3747 0.000 0.164 0.588 0.000 0.008 0.240
#> GSM39850 4 0.1065 0.7593 0.020 0.008 0.000 0.964 0.000 0.008
#> GSM39851 4 0.5163 0.4958 0.268 0.088 0.000 0.628 0.000 0.016
#> GSM39855 3 0.5472 0.4099 0.000 0.064 0.636 0.000 0.064 0.236
#> GSM39856 3 0.2488 0.5669 0.000 0.044 0.880 0.000 0.000 0.076
#> GSM39858 3 0.1267 0.5552 0.000 0.060 0.940 0.000 0.000 0.000
#> GSM39859 3 0.0891 0.5652 0.000 0.024 0.968 0.000 0.000 0.008
#> GSM39862 6 0.4431 0.5411 0.000 0.048 0.060 0.080 0.024 0.788
#> GSM39863 1 0.3337 0.6389 0.832 0.112 0.000 0.032 0.000 0.024
#> GSM39865 5 0.3334 0.7424 0.000 0.052 0.000 0.004 0.820 0.124
#> GSM39866 1 0.7395 0.2925 0.432 0.308 0.028 0.112 0.000 0.120
#> GSM39867 1 0.5838 0.5614 0.680 0.136 0.000 0.052 0.064 0.068
#> GSM39869 5 0.3477 0.7506 0.008 0.080 0.000 0.000 0.820 0.092
#> GSM39870 3 0.5241 0.0547 0.036 0.336 0.592 0.012 0.000 0.024
#> GSM39871 3 0.1789 0.5675 0.000 0.044 0.924 0.000 0.000 0.032
#> GSM39872 6 0.5112 0.4844 0.000 0.128 0.236 0.004 0.000 0.632
#> GSM39828 4 0.6211 0.5045 0.088 0.100 0.000 0.564 0.000 0.248
#> GSM39829 3 0.5459 -0.2421 0.036 0.424 0.492 0.000 0.000 0.048
#> GSM39830 2 0.7489 0.0000 0.128 0.440 0.284 0.116 0.000 0.032
#> GSM39832 1 0.0767 0.6712 0.976 0.012 0.000 0.004 0.000 0.008
#> GSM39833 5 0.8559 0.0809 0.028 0.156 0.048 0.180 0.388 0.200
#> GSM39834 6 0.5859 0.5167 0.056 0.268 0.012 0.064 0.000 0.600
#> GSM39835 1 0.7228 0.3118 0.500 0.148 0.000 0.024 0.112 0.216
#> GSM39836 4 0.1398 0.7392 0.000 0.008 0.000 0.940 0.000 0.052
#> GSM39837 5 0.2255 0.7659 0.000 0.028 0.000 0.080 0.892 0.000
#> GSM39838 5 0.6391 0.5153 0.004 0.120 0.000 0.128 0.588 0.160
#> GSM39839 3 0.4634 -0.0826 0.044 0.400 0.556 0.000 0.000 0.000
#> GSM39840 1 0.4675 0.4982 0.688 0.056 0.000 0.236 0.000 0.020
#> GSM39841 1 0.4339 0.6299 0.772 0.144 0.000 0.032 0.032 0.020
#> GSM39842 1 0.1321 0.6703 0.952 0.020 0.000 0.004 0.000 0.024
#> GSM39843 4 0.5592 0.5494 0.208 0.128 0.004 0.632 0.000 0.028
#> GSM39844 1 0.0767 0.6712 0.976 0.012 0.000 0.004 0.000 0.008
#> GSM39845 3 0.2100 0.5276 0.000 0.112 0.884 0.000 0.000 0.004
#> GSM39852 4 0.5795 0.2686 0.016 0.140 0.000 0.536 0.000 0.308
#> GSM39853 5 0.3953 0.7221 0.064 0.064 0.000 0.044 0.816 0.012
#> GSM39854 1 0.7293 0.4109 0.536 0.140 0.000 0.084 0.168 0.072
#> GSM39857 3 0.4915 0.4040 0.000 0.108 0.632 0.000 0.000 0.260
#> GSM39860 6 0.6519 0.3151 0.000 0.068 0.152 0.004 0.240 0.536
#> GSM39861 3 0.2491 0.5402 0.000 0.112 0.868 0.000 0.000 0.020
#> GSM39864 1 0.6359 0.4056 0.528 0.268 0.004 0.044 0.000 0.156
#> GSM39868 6 0.6927 0.4586 0.064 0.268 0.020 0.152 0.000 0.496
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> SD:skmeans 36 NA 0.1002 2
#> SD:skmeans 57 0.00404 0.0089 3
#> SD:skmeans 48 0.00830 0.0093 4
#> SD:skmeans 41 0.00709 0.0328 5
#> SD:skmeans 33 0.03323 0.1819 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.964 0.941 0.976 0.2476 0.758 0.758
#> 3 3 0.535 0.709 0.871 1.3499 0.623 0.516
#> 4 4 0.551 0.634 0.778 0.1972 0.771 0.520
#> 5 5 0.648 0.635 0.817 0.1151 0.817 0.476
#> 6 6 0.700 0.673 0.806 0.0478 0.920 0.663
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.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0376 0.9190 0.004 0.996
#> GSM39874 2 0.0376 0.9190 0.004 0.996
#> GSM39875 2 0.0000 0.9165 0.000 1.000
#> GSM39876 2 0.0376 0.9190 0.004 0.996
#> GSM39831 1 0.0000 0.9818 1.000 0.000
#> GSM39819 1 0.0672 0.9803 0.992 0.008
#> GSM39820 1 0.0672 0.9803 0.992 0.008
#> GSM39821 1 0.0000 0.9818 1.000 0.000
#> GSM39822 2 0.0672 0.9181 0.008 0.992
#> GSM39823 1 0.0672 0.9803 0.992 0.008
#> GSM39824 1 0.0672 0.9803 0.992 0.008
#> GSM39825 1 0.0376 0.9811 0.996 0.004
#> GSM39826 1 0.0000 0.9818 1.000 0.000
#> GSM39827 1 0.0000 0.9818 1.000 0.000
#> GSM39846 1 0.0672 0.9803 0.992 0.008
#> GSM39847 1 0.0000 0.9818 1.000 0.000
#> GSM39848 1 0.6343 0.7869 0.840 0.160
#> GSM39849 1 0.0672 0.9803 0.992 0.008
#> GSM39850 1 0.0000 0.9818 1.000 0.000
#> GSM39851 1 0.0000 0.9818 1.000 0.000
#> GSM39855 1 0.0672 0.9803 0.992 0.008
#> GSM39856 1 0.0672 0.9803 0.992 0.008
#> GSM39858 1 0.0672 0.9803 0.992 0.008
#> GSM39859 1 0.0672 0.9803 0.992 0.008
#> GSM39862 1 0.0000 0.9818 1.000 0.000
#> GSM39863 1 0.0000 0.9818 1.000 0.000
#> GSM39865 1 0.1414 0.9646 0.980 0.020
#> GSM39866 1 0.0000 0.9818 1.000 0.000
#> GSM39867 1 0.0000 0.9818 1.000 0.000
#> GSM39869 2 0.0672 0.9181 0.008 0.992
#> GSM39870 1 0.0672 0.9803 0.992 0.008
#> GSM39871 1 0.0672 0.9803 0.992 0.008
#> GSM39872 1 0.0672 0.9803 0.992 0.008
#> GSM39828 1 0.0000 0.9818 1.000 0.000
#> GSM39829 1 0.0376 0.9811 0.996 0.004
#> GSM39830 1 0.0376 0.9811 0.996 0.004
#> GSM39832 1 0.0000 0.9818 1.000 0.000
#> GSM39833 1 0.0000 0.9818 1.000 0.000
#> GSM39834 1 0.0000 0.9818 1.000 0.000
#> GSM39835 1 0.0376 0.9795 0.996 0.004
#> GSM39836 1 0.0000 0.9818 1.000 0.000
#> GSM39837 2 0.9522 0.4517 0.372 0.628
#> GSM39838 1 0.0000 0.9818 1.000 0.000
#> GSM39839 1 0.0672 0.9803 0.992 0.008
#> GSM39840 1 0.0000 0.9818 1.000 0.000
#> GSM39841 1 0.0000 0.9818 1.000 0.000
#> GSM39842 1 0.0000 0.9818 1.000 0.000
#> GSM39843 1 0.0000 0.9818 1.000 0.000
#> GSM39844 1 0.0000 0.9818 1.000 0.000
#> GSM39845 1 0.0672 0.9803 0.992 0.008
#> GSM39852 1 0.0000 0.9818 1.000 0.000
#> GSM39853 2 0.6801 0.7814 0.180 0.820
#> GSM39854 1 0.0672 0.9762 0.992 0.008
#> GSM39857 1 0.0672 0.9803 0.992 0.008
#> GSM39860 1 0.9998 -0.0432 0.508 0.492
#> GSM39861 1 0.0672 0.9803 0.992 0.008
#> GSM39864 1 0.0000 0.9818 1.000 0.000
#> GSM39868 1 0.0000 0.9818 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.9535 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.9535 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.9535 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.9535 0.000 1.000 0.000
#> GSM39831 3 0.6045 0.4971 0.380 0.000 0.620
#> GSM39819 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39820 3 0.2711 0.7511 0.088 0.000 0.912
#> GSM39821 1 0.1031 0.8658 0.976 0.000 0.024
#> GSM39822 2 0.4702 0.7060 0.212 0.788 0.000
#> GSM39823 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39824 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39825 3 0.2959 0.7635 0.100 0.000 0.900
#> GSM39826 1 0.1031 0.8658 0.976 0.000 0.024
#> GSM39827 1 0.0892 0.8645 0.980 0.000 0.020
#> GSM39846 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39847 1 0.1753 0.8563 0.952 0.000 0.048
#> GSM39848 3 0.9262 0.3559 0.324 0.176 0.500
#> GSM39849 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39850 1 0.1031 0.8658 0.976 0.000 0.024
#> GSM39851 1 0.0424 0.8582 0.992 0.000 0.008
#> GSM39855 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39856 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39862 3 0.5178 0.6427 0.256 0.000 0.744
#> GSM39863 1 0.6180 0.0622 0.584 0.000 0.416
#> GSM39865 3 0.7084 0.5622 0.044 0.304 0.652
#> GSM39866 1 0.1643 0.8610 0.956 0.000 0.044
#> GSM39867 1 0.1163 0.8576 0.972 0.000 0.028
#> GSM39869 2 0.0000 0.9535 0.000 1.000 0.000
#> GSM39870 3 0.5785 0.3879 0.332 0.000 0.668
#> GSM39871 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39872 3 0.0592 0.7986 0.012 0.000 0.988
#> GSM39828 3 0.5882 0.5248 0.348 0.000 0.652
#> GSM39829 3 0.2066 0.7787 0.060 0.000 0.940
#> GSM39830 3 0.2878 0.7691 0.096 0.000 0.904
#> GSM39832 1 0.0237 0.8549 0.996 0.000 0.004
#> GSM39833 3 0.5968 0.5015 0.364 0.000 0.636
#> GSM39834 3 0.5465 0.6056 0.288 0.000 0.712
#> GSM39835 3 0.6204 0.3920 0.424 0.000 0.576
#> GSM39836 1 0.1031 0.8658 0.976 0.000 0.024
#> GSM39837 1 0.3129 0.7992 0.904 0.088 0.008
#> GSM39838 1 0.4002 0.7524 0.840 0.000 0.160
#> GSM39839 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39840 1 0.3192 0.7860 0.888 0.000 0.112
#> GSM39841 1 0.6267 -0.0464 0.548 0.000 0.452
#> GSM39842 3 0.6154 0.4462 0.408 0.000 0.592
#> GSM39843 1 0.1031 0.8654 0.976 0.000 0.024
#> GSM39844 1 0.2448 0.8307 0.924 0.000 0.076
#> GSM39845 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39852 3 0.6180 0.3975 0.416 0.000 0.584
#> GSM39853 1 0.1643 0.8299 0.956 0.044 0.000
#> GSM39854 1 0.0000 0.8519 1.000 0.000 0.000
#> GSM39857 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39860 3 0.6235 0.0977 0.000 0.436 0.564
#> GSM39861 3 0.0000 0.8010 0.000 0.000 1.000
#> GSM39864 3 0.5835 0.5363 0.340 0.000 0.660
#> GSM39868 1 0.6204 0.2538 0.576 0.000 0.424
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.93906 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.93906 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.93906 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.93906 0.000 1.000 0.000 0.000
#> GSM39831 1 0.3791 0.69783 0.796 0.000 0.200 0.004
#> GSM39819 3 0.1940 0.79849 0.076 0.000 0.924 0.000
#> GSM39820 3 0.3128 0.77502 0.076 0.000 0.884 0.040
#> GSM39821 4 0.1302 0.67999 0.044 0.000 0.000 0.956
#> GSM39822 2 0.4228 0.66633 0.008 0.760 0.000 0.232
#> GSM39823 3 0.1940 0.79849 0.076 0.000 0.924 0.000
#> GSM39824 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39825 3 0.4464 0.60772 0.024 0.000 0.768 0.208
#> GSM39826 4 0.1716 0.67488 0.064 0.000 0.000 0.936
#> GSM39827 4 0.1211 0.68038 0.040 0.000 0.000 0.960
#> GSM39846 3 0.1940 0.79849 0.076 0.000 0.924 0.000
#> GSM39847 4 0.0188 0.68263 0.000 0.000 0.004 0.996
#> GSM39848 4 0.8245 0.29574 0.024 0.208 0.328 0.440
#> GSM39849 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39850 4 0.1867 0.67065 0.072 0.000 0.000 0.928
#> GSM39851 4 0.1867 0.67065 0.072 0.000 0.000 0.928
#> GSM39855 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39856 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39858 3 0.1867 0.79945 0.072 0.000 0.928 0.000
#> GSM39859 3 0.0592 0.80805 0.000 0.000 0.984 0.016
#> GSM39862 3 0.5696 -0.13397 0.024 0.000 0.496 0.480
#> GSM39863 1 0.1635 0.80340 0.948 0.000 0.044 0.008
#> GSM39865 3 0.8462 -0.04401 0.024 0.288 0.400 0.288
#> GSM39866 4 0.3796 0.64844 0.096 0.000 0.056 0.848
#> GSM39867 1 0.2281 0.80128 0.904 0.000 0.000 0.096
#> GSM39869 2 0.0188 0.93614 0.004 0.996 0.000 0.000
#> GSM39870 3 0.5143 0.62204 0.076 0.000 0.752 0.172
#> GSM39871 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39872 3 0.2222 0.78259 0.016 0.000 0.924 0.060
#> GSM39828 4 0.5915 0.35170 0.040 0.000 0.400 0.560
#> GSM39829 3 0.3464 0.77830 0.076 0.000 0.868 0.056
#> GSM39830 3 0.5798 0.54183 0.096 0.000 0.696 0.208
#> GSM39832 1 0.2011 0.80001 0.920 0.000 0.000 0.080
#> GSM39833 4 0.5980 0.37292 0.044 0.000 0.396 0.560
#> GSM39834 3 0.5696 -0.15039 0.024 0.000 0.496 0.480
#> GSM39835 1 0.5713 0.47455 0.620 0.000 0.340 0.040
#> GSM39836 4 0.1022 0.68107 0.032 0.000 0.000 0.968
#> GSM39837 4 0.2542 0.65676 0.012 0.084 0.000 0.904
#> GSM39838 4 0.2670 0.66975 0.024 0.000 0.072 0.904
#> GSM39839 3 0.1940 0.79849 0.076 0.000 0.924 0.000
#> GSM39840 1 0.4713 0.44087 0.640 0.000 0.000 0.360
#> GSM39841 4 0.7048 0.49727 0.160 0.000 0.284 0.556
#> GSM39842 1 0.2797 0.79706 0.900 0.000 0.068 0.032
#> GSM39843 4 0.1792 0.67358 0.068 0.000 0.000 0.932
#> GSM39844 1 0.0336 0.78319 0.992 0.000 0.000 0.008
#> GSM39845 3 0.1940 0.79849 0.076 0.000 0.924 0.000
#> GSM39852 4 0.5467 0.41483 0.024 0.000 0.364 0.612
#> GSM39853 4 0.5950 -0.04683 0.416 0.040 0.000 0.544
#> GSM39854 1 0.2469 0.79660 0.892 0.000 0.000 0.108
#> GSM39857 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39860 3 0.5773 0.35046 0.004 0.376 0.592 0.028
#> GSM39861 3 0.0921 0.80790 0.000 0.000 0.972 0.028
#> GSM39864 4 0.5847 0.32940 0.036 0.000 0.404 0.560
#> GSM39868 4 0.5853 0.00295 0.032 0.000 0.460 0.508
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.9300 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.9300 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.9300 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.9300 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.3003 0.6918 0.812 0.000 0.000 0.000 0.188
#> GSM39819 3 0.0290 0.8309 0.000 0.000 0.992 0.000 0.008
#> GSM39820 3 0.0404 0.8312 0.000 0.000 0.988 0.000 0.012
#> GSM39821 4 0.0162 0.8190 0.004 0.000 0.000 0.996 0.000
#> GSM39822 2 0.4971 0.6538 0.000 0.704 0.004 0.212 0.080
#> GSM39823 3 0.0510 0.8312 0.000 0.000 0.984 0.000 0.016
#> GSM39824 5 0.3480 0.5621 0.000 0.000 0.248 0.000 0.752
#> GSM39825 5 0.3934 0.6068 0.000 0.000 0.076 0.124 0.800
#> GSM39826 4 0.0290 0.8188 0.008 0.000 0.000 0.992 0.000
#> GSM39827 4 0.1697 0.7897 0.008 0.000 0.000 0.932 0.060
#> GSM39846 3 0.3707 0.5642 0.000 0.000 0.716 0.000 0.284
#> GSM39847 4 0.0404 0.8156 0.000 0.000 0.000 0.988 0.012
#> GSM39848 5 0.5852 0.3900 0.000 0.180 0.004 0.192 0.624
#> GSM39849 5 0.3480 0.5615 0.000 0.000 0.248 0.000 0.752
#> GSM39850 4 0.0290 0.8188 0.008 0.000 0.000 0.992 0.000
#> GSM39851 4 0.0290 0.8188 0.008 0.000 0.000 0.992 0.000
#> GSM39855 5 0.3480 0.5621 0.000 0.000 0.248 0.000 0.752
#> GSM39856 5 0.3480 0.5621 0.000 0.000 0.248 0.000 0.752
#> GSM39858 3 0.4242 0.2796 0.000 0.000 0.572 0.000 0.428
#> GSM39859 5 0.3661 0.5262 0.000 0.000 0.276 0.000 0.724
#> GSM39862 5 0.3969 0.4806 0.000 0.000 0.004 0.304 0.692
#> GSM39863 1 0.0162 0.8438 0.996 0.000 0.000 0.000 0.004
#> GSM39865 5 0.5101 0.4908 0.000 0.108 0.004 0.184 0.704
#> GSM39866 3 0.4548 0.5838 0.000 0.000 0.752 0.124 0.124
#> GSM39867 1 0.0000 0.8450 1.000 0.000 0.000 0.000 0.000
#> GSM39869 2 0.1591 0.9014 0.000 0.940 0.004 0.004 0.052
#> GSM39870 3 0.0162 0.8280 0.000 0.000 0.996 0.004 0.000
#> GSM39871 5 0.3480 0.5621 0.000 0.000 0.248 0.000 0.752
#> GSM39872 5 0.2873 0.6095 0.000 0.000 0.128 0.016 0.856
#> GSM39828 5 0.4066 0.4453 0.004 0.000 0.000 0.324 0.672
#> GSM39829 3 0.1364 0.8108 0.000 0.000 0.952 0.012 0.036
#> GSM39830 3 0.5006 0.3877 0.004 0.000 0.644 0.044 0.308
#> GSM39832 1 0.0000 0.8450 1.000 0.000 0.000 0.000 0.000
#> GSM39833 5 0.4443 0.2565 0.004 0.000 0.000 0.472 0.524
#> GSM39834 5 0.4114 0.5156 0.000 0.000 0.016 0.272 0.712
#> GSM39835 1 0.5422 0.3204 0.580 0.000 0.000 0.072 0.348
#> GSM39836 4 0.0162 0.8190 0.004 0.000 0.000 0.996 0.000
#> GSM39837 4 0.2519 0.7593 0.000 0.060 0.004 0.900 0.036
#> GSM39838 4 0.4135 0.5062 0.000 0.000 0.004 0.656 0.340
#> GSM39839 3 0.0290 0.8309 0.000 0.000 0.992 0.000 0.008
#> GSM39840 1 0.4166 0.4243 0.648 0.000 0.000 0.348 0.004
#> GSM39841 4 0.5652 0.0463 0.044 0.000 0.020 0.556 0.380
#> GSM39842 1 0.0000 0.8450 1.000 0.000 0.000 0.000 0.000
#> GSM39843 4 0.0451 0.8183 0.008 0.000 0.000 0.988 0.004
#> GSM39844 1 0.0000 0.8450 1.000 0.000 0.000 0.000 0.000
#> GSM39845 3 0.0510 0.8312 0.000 0.000 0.984 0.000 0.016
#> GSM39852 5 0.4101 0.3666 0.000 0.000 0.000 0.372 0.628
#> GSM39853 4 0.6567 0.2138 0.320 0.060 0.012 0.560 0.048
#> GSM39854 1 0.0324 0.8415 0.992 0.000 0.000 0.004 0.004
#> GSM39857 5 0.3274 0.5748 0.000 0.000 0.220 0.000 0.780
#> GSM39860 5 0.6739 0.1152 0.000 0.356 0.216 0.004 0.424
#> GSM39861 5 0.4719 0.5746 0.000 0.000 0.248 0.056 0.696
#> GSM39864 5 0.4937 0.4930 0.000 0.000 0.064 0.264 0.672
#> GSM39868 4 0.6207 0.1233 0.000 0.000 0.140 0.460 0.400
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.2793 0.6607 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM39819 3 0.0405 0.8048 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM39820 3 0.0146 0.8081 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM39821 4 0.0000 0.9075 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39822 5 0.4038 0.6809 0.000 0.156 0.000 0.072 0.764 0.008
#> GSM39823 3 0.0547 0.8068 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM39824 6 0.4297 0.5661 0.000 0.000 0.176 0.000 0.100 0.724
#> GSM39825 6 0.3119 0.6399 0.000 0.000 0.032 0.076 0.036 0.856
#> GSM39826 4 0.0000 0.9075 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39827 4 0.1245 0.8680 0.000 0.000 0.000 0.952 0.016 0.032
#> GSM39846 3 0.5027 0.4185 0.000 0.000 0.596 0.000 0.100 0.304
#> GSM39847 4 0.0547 0.8974 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM39848 5 0.2558 0.7154 0.000 0.000 0.000 0.004 0.840 0.156
#> GSM39849 6 0.4444 0.5656 0.000 0.000 0.184 0.000 0.108 0.708
#> GSM39850 4 0.0000 0.9075 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39851 4 0.0000 0.9075 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39855 6 0.4414 0.5575 0.000 0.000 0.180 0.000 0.108 0.712
#> GSM39856 6 0.4358 0.5627 0.000 0.000 0.184 0.000 0.100 0.716
#> GSM39858 3 0.5282 0.1625 0.000 0.000 0.484 0.000 0.100 0.416
#> GSM39859 6 0.4143 0.5736 0.000 0.000 0.180 0.000 0.084 0.736
#> GSM39862 6 0.4024 0.5468 0.000 0.000 0.000 0.264 0.036 0.700
#> GSM39863 1 0.0146 0.8191 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM39865 5 0.2762 0.7010 0.000 0.000 0.000 0.000 0.804 0.196
#> GSM39866 3 0.3788 0.6440 0.004 0.000 0.808 0.068 0.016 0.104
#> GSM39867 1 0.1141 0.8102 0.948 0.000 0.000 0.000 0.052 0.000
#> GSM39869 5 0.2300 0.6529 0.000 0.144 0.000 0.000 0.856 0.000
#> GSM39870 3 0.0405 0.8080 0.000 0.000 0.988 0.000 0.004 0.008
#> GSM39871 6 0.4191 0.5714 0.000 0.000 0.180 0.000 0.088 0.732
#> GSM39872 6 0.1624 0.6484 0.000 0.000 0.044 0.008 0.012 0.936
#> GSM39828 6 0.4045 0.5422 0.000 0.000 0.000 0.268 0.036 0.696
#> GSM39829 3 0.1327 0.7875 0.000 0.000 0.936 0.000 0.000 0.064
#> GSM39830 3 0.4150 0.3286 0.000 0.000 0.616 0.008 0.008 0.368
#> GSM39832 1 0.0000 0.8200 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39833 6 0.3887 0.4658 0.000 0.000 0.000 0.360 0.008 0.632
#> GSM39834 6 0.3755 0.5846 0.000 0.000 0.000 0.220 0.036 0.744
#> GSM39835 1 0.6465 0.1928 0.464 0.000 0.000 0.112 0.072 0.352
#> GSM39836 4 0.0000 0.9075 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39837 5 0.4057 0.4708 0.000 0.012 0.000 0.388 0.600 0.000
#> GSM39838 5 0.4125 0.7146 0.000 0.000 0.000 0.128 0.748 0.124
#> GSM39839 3 0.0405 0.8048 0.000 0.000 0.988 0.000 0.008 0.004
#> GSM39840 1 0.3782 0.4278 0.636 0.000 0.000 0.360 0.004 0.000
#> GSM39841 6 0.5761 0.2615 0.032 0.000 0.040 0.424 0.020 0.484
#> GSM39842 1 0.0000 0.8200 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39843 4 0.0508 0.9008 0.004 0.000 0.000 0.984 0.000 0.012
#> GSM39844 1 0.0000 0.8200 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39845 3 0.0547 0.8068 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM39852 6 0.4201 0.4982 0.000 0.000 0.000 0.300 0.036 0.664
#> GSM39853 5 0.4926 0.6508 0.112 0.008 0.004 0.192 0.684 0.000
#> GSM39854 1 0.1141 0.8102 0.948 0.000 0.000 0.000 0.052 0.000
#> GSM39857 6 0.2613 0.6167 0.000 0.000 0.140 0.000 0.012 0.848
#> GSM39860 5 0.4434 0.4280 0.000 0.000 0.172 0.000 0.712 0.116
#> GSM39861 6 0.2402 0.6295 0.000 0.000 0.120 0.012 0.000 0.868
#> GSM39864 6 0.4781 0.5632 0.000 0.000 0.052 0.216 0.036 0.696
#> GSM39868 4 0.6100 0.0473 0.004 0.000 0.104 0.444 0.032 0.416
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> SD:pam 56 2.52e-06 1.21e-06 2
#> SD:pam 48 2.33e-07 1.98e-06 3
#> SD:pam 44 3.87e-06 3.51e-05 4
#> SD:pam 43 1.81e-05 3.77e-04 5
#> SD:pam 47 5.68e-09 1.47e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.460 0.844 0.903 0.3488 0.610 0.610
#> 3 3 0.944 0.931 0.961 0.5393 0.538 0.399
#> 4 4 0.669 0.708 0.823 0.2479 0.895 0.775
#> 5 5 0.731 0.669 0.845 0.1260 0.868 0.643
#> 6 6 0.761 0.669 0.795 0.0592 0.902 0.628
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0000 0.739 0.000 1.000
#> GSM39874 2 0.0000 0.739 0.000 1.000
#> GSM39875 2 0.0000 0.739 0.000 1.000
#> GSM39876 2 0.0000 0.739 0.000 1.000
#> GSM39831 1 0.3879 0.882 0.924 0.076
#> GSM39819 1 0.0000 0.920 1.000 0.000
#> GSM39820 1 0.0000 0.920 1.000 0.000
#> GSM39821 1 0.6973 0.759 0.812 0.188
#> GSM39822 2 0.7815 0.821 0.232 0.768
#> GSM39823 1 0.0000 0.920 1.000 0.000
#> GSM39824 1 0.0000 0.920 1.000 0.000
#> GSM39825 1 0.0000 0.920 1.000 0.000
#> GSM39826 2 0.9686 0.613 0.396 0.604
#> GSM39827 1 0.8608 0.569 0.716 0.284
#> GSM39846 1 0.0000 0.920 1.000 0.000
#> GSM39847 1 0.4562 0.868 0.904 0.096
#> GSM39848 2 0.6801 0.814 0.180 0.820
#> GSM39849 1 0.0000 0.920 1.000 0.000
#> GSM39850 1 0.7950 0.668 0.760 0.240
#> GSM39851 1 0.5294 0.845 0.880 0.120
#> GSM39855 1 0.0000 0.920 1.000 0.000
#> GSM39856 1 0.0000 0.920 1.000 0.000
#> GSM39858 1 0.0000 0.920 1.000 0.000
#> GSM39859 1 0.0000 0.920 1.000 0.000
#> GSM39862 1 0.0376 0.919 0.996 0.004
#> GSM39863 1 0.4815 0.860 0.896 0.104
#> GSM39865 2 0.8207 0.820 0.256 0.744
#> GSM39866 1 0.0672 0.918 0.992 0.008
#> GSM39867 2 0.8813 0.806 0.300 0.700
#> GSM39869 2 0.6801 0.814 0.180 0.820
#> GSM39870 1 0.0000 0.920 1.000 0.000
#> GSM39871 1 0.0000 0.920 1.000 0.000
#> GSM39872 1 0.0000 0.920 1.000 0.000
#> GSM39828 1 0.3274 0.894 0.940 0.060
#> GSM39829 1 0.0000 0.920 1.000 0.000
#> GSM39830 1 0.0000 0.920 1.000 0.000
#> GSM39832 1 0.6531 0.788 0.832 0.168
#> GSM39833 1 0.8144 0.643 0.748 0.252
#> GSM39834 1 0.0376 0.919 0.996 0.004
#> GSM39835 2 0.8813 0.806 0.300 0.700
#> GSM39836 1 0.4022 0.881 0.920 0.080
#> GSM39837 2 0.8813 0.806 0.300 0.700
#> GSM39838 2 0.8813 0.806 0.300 0.700
#> GSM39839 1 0.0000 0.920 1.000 0.000
#> GSM39840 1 0.5737 0.828 0.864 0.136
#> GSM39841 1 0.8608 0.569 0.716 0.284
#> GSM39842 1 0.5178 0.849 0.884 0.116
#> GSM39843 1 0.1414 0.913 0.980 0.020
#> GSM39844 1 0.6531 0.789 0.832 0.168
#> GSM39845 1 0.0000 0.920 1.000 0.000
#> GSM39852 1 0.1843 0.909 0.972 0.028
#> GSM39853 2 0.8813 0.806 0.300 0.700
#> GSM39854 2 0.8813 0.806 0.300 0.700
#> GSM39857 1 0.0000 0.920 1.000 0.000
#> GSM39860 1 0.5408 0.780 0.876 0.124
#> GSM39861 1 0.0000 0.920 1.000 0.000
#> GSM39864 1 0.0376 0.919 0.996 0.004
#> GSM39868 1 0.0000 0.920 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0747 1.0000 0.016 0.984 0.000
#> GSM39874 2 0.0747 1.0000 0.016 0.984 0.000
#> GSM39875 2 0.0747 1.0000 0.016 0.984 0.000
#> GSM39876 2 0.0747 1.0000 0.016 0.984 0.000
#> GSM39831 1 0.1774 0.9445 0.960 0.016 0.024
#> GSM39819 3 0.1289 0.9562 0.032 0.000 0.968
#> GSM39820 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39821 1 0.0592 0.9549 0.988 0.000 0.012
#> GSM39822 1 0.2096 0.9236 0.944 0.052 0.004
#> GSM39823 3 0.0592 0.9694 0.012 0.000 0.988
#> GSM39824 3 0.0747 0.9677 0.016 0.000 0.984
#> GSM39825 3 0.4235 0.7453 0.176 0.000 0.824
#> GSM39826 1 0.0592 0.9549 0.988 0.000 0.012
#> GSM39827 1 0.0747 0.9545 0.984 0.000 0.016
#> GSM39846 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39847 1 0.1129 0.9536 0.976 0.004 0.020
#> GSM39848 1 0.0475 0.9529 0.992 0.004 0.004
#> GSM39849 3 0.1289 0.9562 0.032 0.000 0.968
#> GSM39850 1 0.0592 0.9549 0.988 0.000 0.012
#> GSM39851 1 0.1774 0.9445 0.960 0.016 0.024
#> GSM39855 3 0.0892 0.9638 0.020 0.000 0.980
#> GSM39856 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39858 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39859 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39862 1 0.1482 0.9511 0.968 0.020 0.012
#> GSM39863 1 0.1774 0.9445 0.960 0.016 0.024
#> GSM39865 1 0.1765 0.9354 0.956 0.040 0.004
#> GSM39866 1 0.1832 0.9448 0.956 0.008 0.036
#> GSM39867 1 0.0237 0.9535 0.996 0.000 0.004
#> GSM39869 1 0.0983 0.9488 0.980 0.016 0.004
#> GSM39870 3 0.0592 0.9694 0.012 0.000 0.988
#> GSM39871 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39872 1 0.6516 0.0917 0.516 0.004 0.480
#> GSM39828 1 0.0829 0.9548 0.984 0.004 0.012
#> GSM39829 3 0.1031 0.9628 0.024 0.000 0.976
#> GSM39830 3 0.3038 0.8610 0.104 0.000 0.896
#> GSM39832 1 0.1636 0.9451 0.964 0.016 0.020
#> GSM39833 1 0.1482 0.9527 0.968 0.012 0.020
#> GSM39834 1 0.0829 0.9548 0.984 0.004 0.012
#> GSM39835 1 0.0237 0.9535 0.996 0.000 0.004
#> GSM39836 1 0.0829 0.9548 0.984 0.004 0.012
#> GSM39837 1 0.0661 0.9544 0.988 0.004 0.008
#> GSM39838 1 0.0475 0.9529 0.992 0.004 0.004
#> GSM39839 3 0.1163 0.9598 0.028 0.000 0.972
#> GSM39840 1 0.1774 0.9445 0.960 0.016 0.024
#> GSM39841 1 0.1129 0.9536 0.976 0.004 0.020
#> GSM39842 1 0.1774 0.9445 0.960 0.016 0.024
#> GSM39843 1 0.4209 0.8297 0.856 0.016 0.128
#> GSM39844 1 0.1636 0.9451 0.964 0.016 0.020
#> GSM39845 3 0.0424 0.9688 0.008 0.000 0.992
#> GSM39852 1 0.0829 0.9548 0.984 0.004 0.012
#> GSM39853 1 0.0661 0.9544 0.988 0.004 0.008
#> GSM39854 1 0.0237 0.9535 0.996 0.000 0.004
#> GSM39857 3 0.0592 0.9694 0.012 0.000 0.988
#> GSM39860 1 0.5578 0.6581 0.748 0.012 0.240
#> GSM39861 3 0.0592 0.9694 0.012 0.000 0.988
#> GSM39864 1 0.1482 0.9527 0.968 0.012 0.020
#> GSM39868 1 0.1182 0.9537 0.976 0.012 0.012
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39831 1 0.5000 0.993 0.504 0 0.000 0.496
#> GSM39819 3 0.0469 0.913 0.000 0 0.988 0.012
#> GSM39820 3 0.0000 0.914 0.000 0 1.000 0.000
#> GSM39821 4 0.0000 0.561 0.000 0 0.000 1.000
#> GSM39822 4 0.4996 0.592 0.484 0 0.000 0.516
#> GSM39823 3 0.0188 0.915 0.000 0 0.996 0.004
#> GSM39824 3 0.5356 0.648 0.072 0 0.728 0.200
#> GSM39825 3 0.4401 0.612 0.004 0 0.724 0.272
#> GSM39826 4 0.3907 0.591 0.232 0 0.000 0.768
#> GSM39827 4 0.0000 0.561 0.000 0 0.000 1.000
#> GSM39846 3 0.0000 0.914 0.000 0 1.000 0.000
#> GSM39847 4 0.0000 0.561 0.000 0 0.000 1.000
#> GSM39848 4 0.4996 0.592 0.484 0 0.000 0.516
#> GSM39849 3 0.0469 0.913 0.000 0 0.988 0.012
#> GSM39850 4 0.0188 0.556 0.004 0 0.000 0.996
#> GSM39851 1 0.4999 0.996 0.508 0 0.000 0.492
#> GSM39855 3 0.5356 0.648 0.072 0 0.728 0.200
#> GSM39856 3 0.0188 0.913 0.004 0 0.996 0.000
#> GSM39858 3 0.0188 0.913 0.004 0 0.996 0.000
#> GSM39859 3 0.0000 0.914 0.000 0 1.000 0.000
#> GSM39862 4 0.0707 0.556 0.020 0 0.000 0.980
#> GSM39863 1 0.4999 0.996 0.508 0 0.000 0.492
#> GSM39865 4 0.4996 0.592 0.484 0 0.000 0.516
#> GSM39866 4 0.0188 0.563 0.004 0 0.000 0.996
#> GSM39867 4 0.4967 0.602 0.452 0 0.000 0.548
#> GSM39869 4 0.4996 0.592 0.484 0 0.000 0.516
#> GSM39870 3 0.0188 0.915 0.000 0 0.996 0.004
#> GSM39871 3 0.0000 0.914 0.000 0 1.000 0.000
#> GSM39872 4 0.2174 0.518 0.020 0 0.052 0.928
#> GSM39828 4 0.0000 0.561 0.000 0 0.000 1.000
#> GSM39829 3 0.0469 0.913 0.000 0 0.988 0.012
#> GSM39830 3 0.3074 0.782 0.000 0 0.848 0.152
#> GSM39832 1 0.5000 0.994 0.504 0 0.000 0.496
#> GSM39833 4 0.3569 0.589 0.196 0 0.000 0.804
#> GSM39834 4 0.0188 0.563 0.004 0 0.000 0.996
#> GSM39835 4 0.4948 0.603 0.440 0 0.000 0.560
#> GSM39836 4 0.0000 0.561 0.000 0 0.000 1.000
#> GSM39837 4 0.4989 0.597 0.472 0 0.000 0.528
#> GSM39838 4 0.4981 0.600 0.464 0 0.000 0.536
#> GSM39839 3 0.0469 0.913 0.000 0 0.988 0.012
#> GSM39840 4 0.4996 -0.961 0.484 0 0.000 0.516
#> GSM39841 4 0.3975 0.351 0.240 0 0.000 0.760
#> GSM39842 1 0.4999 0.996 0.508 0 0.000 0.492
#> GSM39843 4 0.1970 0.433 0.060 0 0.008 0.932
#> GSM39844 1 0.5000 0.994 0.504 0 0.000 0.496
#> GSM39845 3 0.0000 0.914 0.000 0 1.000 0.000
#> GSM39852 4 0.0188 0.563 0.004 0 0.000 0.996
#> GSM39853 4 0.4985 0.598 0.468 0 0.000 0.532
#> GSM39854 4 0.4977 0.600 0.460 0 0.000 0.540
#> GSM39857 3 0.2714 0.820 0.004 0 0.884 0.112
#> GSM39860 4 0.5165 0.589 0.484 0 0.004 0.512
#> GSM39861 3 0.0188 0.915 0.000 0 0.996 0.004
#> GSM39864 4 0.0000 0.561 0.000 0 0.000 1.000
#> GSM39868 4 0.0188 0.562 0.000 0 0.004 0.996
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM39831 1 0.1478 0.865 0.936 0 0.000 0.064 0.000
#> GSM39819 3 0.1461 0.895 0.016 0 0.952 0.004 0.028
#> GSM39820 3 0.1310 0.895 0.024 0 0.956 0.000 0.020
#> GSM39821 4 0.3241 0.671 0.144 0 0.000 0.832 0.024
#> GSM39822 5 0.2629 0.705 0.004 0 0.000 0.136 0.860
#> GSM39823 3 0.0671 0.899 0.000 0 0.980 0.004 0.016
#> GSM39824 3 0.4705 0.210 0.004 0 0.504 0.008 0.484
#> GSM39825 3 0.3789 0.669 0.016 0 0.760 0.224 0.000
#> GSM39826 4 0.4906 0.556 0.076 0 0.000 0.692 0.232
#> GSM39827 4 0.4119 0.655 0.152 0 0.000 0.780 0.068
#> GSM39846 3 0.0000 0.902 0.000 0 1.000 0.000 0.000
#> GSM39847 4 0.1544 0.701 0.068 0 0.000 0.932 0.000
#> GSM39848 5 0.2605 0.703 0.000 0 0.000 0.148 0.852
#> GSM39849 3 0.0451 0.902 0.000 0 0.988 0.008 0.004
#> GSM39850 4 0.3578 0.671 0.132 0 0.000 0.820 0.048
#> GSM39851 1 0.0963 0.872 0.964 0 0.000 0.036 0.000
#> GSM39855 3 0.4706 0.199 0.004 0 0.500 0.008 0.488
#> GSM39856 3 0.0000 0.902 0.000 0 1.000 0.000 0.000
#> GSM39858 3 0.0000 0.902 0.000 0 1.000 0.000 0.000
#> GSM39859 3 0.0000 0.902 0.000 0 1.000 0.000 0.000
#> GSM39862 5 0.4796 0.273 0.012 0 0.004 0.468 0.516
#> GSM39863 1 0.1671 0.857 0.924 0 0.000 0.076 0.000
#> GSM39865 5 0.2471 0.705 0.000 0 0.000 0.136 0.864
#> GSM39866 4 0.1924 0.702 0.064 0 0.004 0.924 0.008
#> GSM39867 4 0.4893 0.333 0.028 0 0.000 0.568 0.404
#> GSM39869 5 0.2488 0.699 0.004 0 0.000 0.124 0.872
#> GSM39870 3 0.1377 0.897 0.020 0 0.956 0.004 0.020
#> GSM39871 3 0.0000 0.902 0.000 0 1.000 0.000 0.000
#> GSM39872 4 0.6677 -0.229 0.008 0 0.188 0.468 0.336
#> GSM39828 4 0.0671 0.699 0.016 0 0.004 0.980 0.000
#> GSM39829 3 0.1471 0.896 0.024 0 0.952 0.004 0.020
#> GSM39830 3 0.3013 0.840 0.028 0 0.880 0.068 0.024
#> GSM39832 1 0.0794 0.868 0.972 0 0.000 0.028 0.000
#> GSM39833 4 0.5002 0.381 0.044 0 0.000 0.612 0.344
#> GSM39834 4 0.0740 0.694 0.008 0 0.004 0.980 0.008
#> GSM39835 4 0.4800 0.396 0.028 0 0.000 0.604 0.368
#> GSM39836 4 0.1469 0.704 0.036 0 0.000 0.948 0.016
#> GSM39837 5 0.5109 -0.152 0.036 0 0.000 0.460 0.504
#> GSM39838 4 0.4219 0.197 0.000 0 0.000 0.584 0.416
#> GSM39839 3 0.1461 0.895 0.016 0 0.952 0.004 0.028
#> GSM39840 1 0.1608 0.854 0.928 0 0.000 0.072 0.000
#> GSM39841 1 0.6739 -0.133 0.392 0 0.000 0.260 0.348
#> GSM39842 1 0.0963 0.872 0.964 0 0.000 0.036 0.000
#> GSM39843 4 0.4049 0.586 0.124 0 0.084 0.792 0.000
#> GSM39844 1 0.0794 0.868 0.972 0 0.000 0.028 0.000
#> GSM39845 3 0.0290 0.902 0.008 0 0.992 0.000 0.000
#> GSM39852 4 0.0613 0.696 0.008 0 0.004 0.984 0.004
#> GSM39853 5 0.5109 -0.152 0.036 0 0.000 0.460 0.504
#> GSM39854 4 0.4894 0.222 0.024 0 0.000 0.520 0.456
#> GSM39857 3 0.1082 0.891 0.000 0 0.964 0.008 0.028
#> GSM39860 5 0.3733 0.671 0.004 0 0.032 0.160 0.804
#> GSM39861 3 0.0451 0.903 0.008 0 0.988 0.004 0.000
#> GSM39864 4 0.0771 0.698 0.020 0 0.004 0.976 0.000
#> GSM39868 4 0.0451 0.697 0.008 0 0.004 0.988 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39831 1 0.0632 0.895 0.976 0 0.000 0.024 0.000 0.000
#> GSM39819 6 0.3993 0.383 0.000 0 0.476 0.000 0.004 0.520
#> GSM39820 6 0.3866 0.378 0.000 0 0.484 0.000 0.000 0.516
#> GSM39821 4 0.2345 0.780 0.028 0 0.000 0.904 0.028 0.040
#> GSM39822 5 0.1649 0.706 0.000 0 0.000 0.032 0.932 0.036
#> GSM39823 3 0.1297 0.867 0.000 0 0.948 0.000 0.012 0.040
#> GSM39824 5 0.4731 0.336 0.000 0 0.428 0.000 0.524 0.048
#> GSM39825 3 0.4685 0.408 0.000 0 0.676 0.248 0.012 0.064
#> GSM39826 4 0.5201 0.708 0.044 0 0.000 0.664 0.072 0.220
#> GSM39827 4 0.4546 0.735 0.032 0 0.000 0.724 0.052 0.192
#> GSM39846 3 0.0000 0.903 0.000 0 1.000 0.000 0.000 0.000
#> GSM39847 4 0.1116 0.784 0.028 0 0.000 0.960 0.008 0.004
#> GSM39848 5 0.0865 0.724 0.000 0 0.000 0.036 0.964 0.000
#> GSM39849 3 0.1398 0.859 0.000 0 0.940 0.008 0.000 0.052
#> GSM39850 4 0.3485 0.770 0.040 0 0.000 0.832 0.040 0.088
#> GSM39851 1 0.0458 0.896 0.984 0 0.000 0.016 0.000 0.000
#> GSM39855 5 0.4731 0.336 0.000 0 0.428 0.000 0.524 0.048
#> GSM39856 3 0.0000 0.903 0.000 0 1.000 0.000 0.000 0.000
#> GSM39858 3 0.0000 0.903 0.000 0 1.000 0.000 0.000 0.000
#> GSM39859 3 0.0000 0.903 0.000 0 1.000 0.000 0.000 0.000
#> GSM39862 5 0.3244 0.600 0.000 0 0.000 0.268 0.732 0.000
#> GSM39863 1 0.0713 0.892 0.972 0 0.000 0.028 0.000 0.000
#> GSM39865 5 0.0790 0.724 0.000 0 0.000 0.032 0.968 0.000
#> GSM39866 4 0.1232 0.785 0.024 0 0.004 0.956 0.016 0.000
#> GSM39867 4 0.5989 0.576 0.036 0 0.000 0.488 0.104 0.372
#> GSM39869 5 0.0935 0.723 0.000 0 0.000 0.032 0.964 0.004
#> GSM39870 6 0.3860 0.392 0.000 0 0.472 0.000 0.000 0.528
#> GSM39871 3 0.0000 0.903 0.000 0 1.000 0.000 0.000 0.000
#> GSM39872 5 0.6053 0.367 0.000 0 0.308 0.280 0.412 0.000
#> GSM39828 4 0.0260 0.778 0.000 0 0.000 0.992 0.008 0.000
#> GSM39829 6 0.3991 0.391 0.000 0 0.472 0.000 0.004 0.524
#> GSM39830 6 0.4279 0.403 0.000 0 0.436 0.012 0.004 0.548
#> GSM39832 1 0.0458 0.896 0.984 0 0.000 0.016 0.000 0.000
#> GSM39833 4 0.6172 0.621 0.036 0 0.008 0.540 0.120 0.296
#> GSM39834 4 0.0260 0.778 0.000 0 0.000 0.992 0.008 0.000
#> GSM39835 4 0.5987 0.594 0.048 0 0.000 0.504 0.088 0.360
#> GSM39836 4 0.0717 0.782 0.016 0 0.000 0.976 0.008 0.000
#> GSM39837 6 0.6620 -0.499 0.032 0 0.000 0.352 0.236 0.380
#> GSM39838 4 0.6413 0.438 0.020 0 0.000 0.432 0.292 0.256
#> GSM39839 6 0.3993 0.383 0.000 0 0.476 0.000 0.004 0.520
#> GSM39840 1 0.1075 0.871 0.952 0 0.000 0.048 0.000 0.000
#> GSM39841 1 0.6997 0.113 0.460 0 0.000 0.220 0.100 0.220
#> GSM39842 1 0.0458 0.896 0.984 0 0.000 0.016 0.000 0.000
#> GSM39843 4 0.3806 0.697 0.144 0 0.024 0.792 0.000 0.040
#> GSM39844 1 0.0458 0.896 0.984 0 0.000 0.016 0.000 0.000
#> GSM39845 3 0.0790 0.884 0.000 0 0.968 0.000 0.000 0.032
#> GSM39852 4 0.0363 0.777 0.000 0 0.000 0.988 0.012 0.000
#> GSM39853 6 0.6620 -0.499 0.032 0 0.000 0.352 0.236 0.380
#> GSM39854 4 0.6464 0.497 0.036 0 0.000 0.416 0.176 0.372
#> GSM39857 3 0.2001 0.824 0.000 0 0.912 0.000 0.048 0.040
#> GSM39860 5 0.1644 0.708 0.000 0 0.000 0.028 0.932 0.040
#> GSM39861 3 0.1429 0.863 0.000 0 0.940 0.004 0.004 0.052
#> GSM39864 4 0.0622 0.781 0.012 0 0.000 0.980 0.008 0.000
#> GSM39868 4 0.0260 0.778 0.000 0 0.000 0.992 0.008 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> SD:mclust 58 3.53e-03 5.72e-03 2
#> SD:mclust 57 4.19e-13 2.62e-11 3
#> SD:mclust 55 6.87e-12 1.18e-10 4
#> SD:mclust 46 2.46e-09 1.61e-07 5
#> SD:mclust 43 1.03e-08 3.45e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.405 0.743 0.863 0.4505 0.552 0.552
#> 3 3 0.719 0.841 0.933 0.4631 0.675 0.463
#> 4 4 0.631 0.690 0.849 0.1208 0.835 0.572
#> 5 5 0.688 0.640 0.824 0.0812 0.897 0.642
#> 6 6 0.739 0.595 0.788 0.0366 0.927 0.684
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0000 0.840 0.000 1.000
#> GSM39874 2 0.0000 0.840 0.000 1.000
#> GSM39875 2 0.0000 0.840 0.000 1.000
#> GSM39876 2 0.0000 0.840 0.000 1.000
#> GSM39831 1 0.8081 0.787 0.752 0.248
#> GSM39819 1 0.0000 0.792 1.000 0.000
#> GSM39820 1 0.0376 0.791 0.996 0.004
#> GSM39821 1 0.8081 0.787 0.752 0.248
#> GSM39822 2 0.0000 0.840 0.000 1.000
#> GSM39823 1 0.8813 0.354 0.700 0.300
#> GSM39824 2 0.8813 0.612 0.300 0.700
#> GSM39825 1 0.0000 0.792 1.000 0.000
#> GSM39826 1 0.8327 0.770 0.736 0.264
#> GSM39827 1 0.8081 0.787 0.752 0.248
#> GSM39846 1 0.7299 0.574 0.796 0.204
#> GSM39847 1 0.8081 0.787 0.752 0.248
#> GSM39848 2 0.0376 0.839 0.004 0.996
#> GSM39849 1 0.4298 0.736 0.912 0.088
#> GSM39850 1 0.8081 0.787 0.752 0.248
#> GSM39851 1 0.8081 0.787 0.752 0.248
#> GSM39855 2 0.8499 0.631 0.276 0.724
#> GSM39856 1 0.5629 0.687 0.868 0.132
#> GSM39858 1 0.1633 0.784 0.976 0.024
#> GSM39859 1 0.1414 0.786 0.980 0.020
#> GSM39862 2 0.9460 0.411 0.364 0.636
#> GSM39863 1 0.8081 0.787 0.752 0.248
#> GSM39865 2 0.1843 0.828 0.028 0.972
#> GSM39866 1 0.4298 0.801 0.912 0.088
#> GSM39867 2 0.9944 -0.131 0.456 0.544
#> GSM39869 2 0.0000 0.840 0.000 1.000
#> GSM39870 1 0.0376 0.791 0.996 0.004
#> GSM39871 1 0.1843 0.782 0.972 0.028
#> GSM39872 1 0.1184 0.789 0.984 0.016
#> GSM39828 1 0.8081 0.787 0.752 0.248
#> GSM39829 1 0.0000 0.792 1.000 0.000
#> GSM39830 1 0.0000 0.792 1.000 0.000
#> GSM39832 1 0.8081 0.787 0.752 0.248
#> GSM39833 2 0.9087 0.333 0.324 0.676
#> GSM39834 1 0.8016 0.788 0.756 0.244
#> GSM39835 2 0.6438 0.699 0.164 0.836
#> GSM39836 1 0.8081 0.787 0.752 0.248
#> GSM39837 2 0.0938 0.837 0.012 0.988
#> GSM39838 2 0.0000 0.840 0.000 1.000
#> GSM39839 1 0.0000 0.792 1.000 0.000
#> GSM39840 1 0.8081 0.787 0.752 0.248
#> GSM39841 1 0.8081 0.787 0.752 0.248
#> GSM39842 1 0.8081 0.787 0.752 0.248
#> GSM39843 1 0.8016 0.788 0.756 0.244
#> GSM39844 1 0.8081 0.787 0.752 0.248
#> GSM39845 1 0.1414 0.786 0.980 0.020
#> GSM39852 1 0.8081 0.787 0.752 0.248
#> GSM39853 2 0.1184 0.835 0.016 0.984
#> GSM39854 2 0.4022 0.791 0.080 0.920
#> GSM39857 1 0.5178 0.707 0.884 0.116
#> GSM39860 2 0.8081 0.645 0.248 0.752
#> GSM39861 1 0.1184 0.788 0.984 0.016
#> GSM39864 1 0.6148 0.798 0.848 0.152
#> GSM39868 1 0.1184 0.796 0.984 0.016
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39831 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39819 3 0.4750 0.74824 0.216 0.000 0.784
#> GSM39820 3 0.3340 0.85541 0.120 0.000 0.880
#> GSM39821 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39822 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39823 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39824 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39825 3 0.2066 0.89196 0.060 0.000 0.940
#> GSM39826 1 0.3038 0.82417 0.896 0.104 0.000
#> GSM39827 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39846 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39847 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39848 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39849 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39850 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39851 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39855 3 0.0237 0.91426 0.000 0.004 0.996
#> GSM39856 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39862 3 0.4784 0.73939 0.200 0.004 0.796
#> GSM39863 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39865 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39866 1 0.3816 0.79407 0.852 0.000 0.148
#> GSM39867 1 0.6280 -0.00708 0.540 0.460 0.000
#> GSM39869 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39870 3 0.3340 0.85541 0.120 0.000 0.880
#> GSM39871 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39872 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39828 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39829 3 0.5591 0.60221 0.304 0.000 0.696
#> GSM39830 1 0.5291 0.60450 0.732 0.000 0.268
#> GSM39832 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39833 2 0.4750 0.70865 0.216 0.784 0.000
#> GSM39834 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39835 2 0.6309 0.09565 0.496 0.504 0.000
#> GSM39836 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39837 2 0.1411 0.88704 0.036 0.964 0.000
#> GSM39838 2 0.0000 0.90215 0.000 1.000 0.000
#> GSM39839 3 0.3267 0.85849 0.116 0.000 0.884
#> GSM39840 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39841 1 0.0592 0.92445 0.988 0.012 0.000
#> GSM39842 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39843 1 0.0237 0.93053 0.996 0.000 0.004
#> GSM39844 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39845 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39852 1 0.0000 0.93313 1.000 0.000 0.000
#> GSM39853 2 0.1860 0.87695 0.052 0.948 0.000
#> GSM39854 2 0.6045 0.43004 0.380 0.620 0.000
#> GSM39857 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39860 3 0.5835 0.48099 0.000 0.340 0.660
#> GSM39861 3 0.0000 0.91653 0.000 0.000 1.000
#> GSM39864 1 0.1031 0.91550 0.976 0.000 0.024
#> GSM39868 1 0.4654 0.71162 0.792 0.000 0.208
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.950 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.950 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.950 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.950 0.000 1.000 0.000 0.000
#> GSM39831 1 0.1174 0.810 0.968 0.000 0.020 0.012
#> GSM39819 3 0.3355 0.718 0.160 0.000 0.836 0.004
#> GSM39820 3 0.1902 0.788 0.064 0.000 0.932 0.004
#> GSM39821 1 0.3024 0.794 0.852 0.000 0.000 0.148
#> GSM39822 2 0.0000 0.950 0.000 1.000 0.000 0.000
#> GSM39823 3 0.4304 0.584 0.000 0.000 0.716 0.284
#> GSM39824 3 0.4888 0.351 0.000 0.000 0.588 0.412
#> GSM39825 3 0.5466 0.526 0.040 0.000 0.668 0.292
#> GSM39826 1 0.4328 0.718 0.748 0.008 0.000 0.244
#> GSM39827 1 0.2401 0.814 0.904 0.004 0.000 0.092
#> GSM39846 3 0.1211 0.805 0.000 0.000 0.960 0.040
#> GSM39847 1 0.2647 0.806 0.880 0.000 0.000 0.120
#> GSM39848 4 0.1377 0.665 0.008 0.020 0.008 0.964
#> GSM39849 3 0.1004 0.808 0.004 0.000 0.972 0.024
#> GSM39850 1 0.3626 0.771 0.812 0.004 0.000 0.184
#> GSM39851 1 0.1520 0.811 0.956 0.000 0.024 0.020
#> GSM39855 3 0.5000 0.121 0.000 0.000 0.500 0.500
#> GSM39856 3 0.1302 0.804 0.000 0.000 0.956 0.044
#> GSM39858 3 0.0921 0.807 0.000 0.000 0.972 0.028
#> GSM39859 3 0.1474 0.801 0.000 0.000 0.948 0.052
#> GSM39862 4 0.0937 0.667 0.012 0.000 0.012 0.976
#> GSM39863 1 0.1488 0.804 0.956 0.000 0.032 0.012
#> GSM39865 2 0.3219 0.795 0.000 0.836 0.000 0.164
#> GSM39866 1 0.4375 0.694 0.788 0.000 0.032 0.180
#> GSM39867 1 0.6289 0.593 0.648 0.236 0.000 0.116
#> GSM39869 2 0.1022 0.930 0.000 0.968 0.000 0.032
#> GSM39870 3 0.1978 0.787 0.068 0.000 0.928 0.004
#> GSM39871 3 0.1211 0.805 0.000 0.000 0.960 0.040
#> GSM39872 4 0.3764 0.471 0.000 0.000 0.216 0.784
#> GSM39828 1 0.4134 0.708 0.740 0.000 0.000 0.260
#> GSM39829 3 0.2944 0.748 0.128 0.000 0.868 0.004
#> GSM39830 3 0.5132 0.280 0.448 0.000 0.548 0.004
#> GSM39832 1 0.0707 0.817 0.980 0.000 0.000 0.020
#> GSM39833 2 0.3636 0.733 0.172 0.820 0.008 0.000
#> GSM39834 4 0.3024 0.589 0.148 0.000 0.000 0.852
#> GSM39835 1 0.5772 0.678 0.708 0.116 0.000 0.176
#> GSM39836 1 0.4643 0.588 0.656 0.000 0.000 0.344
#> GSM39837 2 0.0188 0.948 0.004 0.996 0.000 0.000
#> GSM39838 4 0.7172 0.154 0.140 0.376 0.000 0.484
#> GSM39839 3 0.2773 0.757 0.116 0.000 0.880 0.004
#> GSM39840 1 0.1022 0.819 0.968 0.000 0.000 0.032
#> GSM39841 1 0.1930 0.785 0.936 0.004 0.056 0.004
#> GSM39842 1 0.1059 0.813 0.972 0.000 0.016 0.012
#> GSM39843 1 0.2131 0.807 0.932 0.000 0.036 0.032
#> GSM39844 1 0.0937 0.814 0.976 0.000 0.012 0.012
#> GSM39845 3 0.1305 0.807 0.004 0.000 0.960 0.036
#> GSM39852 4 0.4941 -0.156 0.436 0.000 0.000 0.564
#> GSM39853 2 0.0000 0.950 0.000 1.000 0.000 0.000
#> GSM39854 1 0.6811 0.305 0.496 0.404 0.000 0.100
#> GSM39857 4 0.4992 -0.197 0.000 0.000 0.476 0.524
#> GSM39860 4 0.2704 0.589 0.000 0.000 0.124 0.876
#> GSM39861 3 0.0672 0.805 0.008 0.000 0.984 0.008
#> GSM39864 1 0.4018 0.723 0.772 0.000 0.004 0.224
#> GSM39868 4 0.3937 0.565 0.188 0.000 0.012 0.800
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.9099 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.9099 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.9099 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.9099 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.2773 0.7141 0.836 0.000 0.000 0.164 0.000
#> GSM39819 3 0.3072 0.7759 0.100 0.004 0.868 0.012 0.016
#> GSM39820 3 0.1597 0.8168 0.020 0.000 0.948 0.024 0.008
#> GSM39821 4 0.1082 0.6876 0.028 0.000 0.000 0.964 0.008
#> GSM39822 2 0.0451 0.9081 0.000 0.988 0.000 0.008 0.004
#> GSM39823 3 0.3975 0.5979 0.008 0.000 0.744 0.008 0.240
#> GSM39824 3 0.4238 0.3267 0.000 0.000 0.628 0.004 0.368
#> GSM39825 3 0.5682 0.5067 0.008 0.000 0.656 0.164 0.172
#> GSM39826 4 0.1728 0.6867 0.020 0.004 0.000 0.940 0.036
#> GSM39827 4 0.4035 0.5446 0.220 0.016 0.000 0.756 0.008
#> GSM39846 3 0.0451 0.8240 0.004 0.000 0.988 0.000 0.008
#> GSM39847 4 0.1041 0.6867 0.032 0.000 0.000 0.964 0.004
#> GSM39848 5 0.1997 0.7182 0.000 0.036 0.000 0.040 0.924
#> GSM39849 3 0.5733 0.4468 0.312 0.000 0.588 0.004 0.096
#> GSM39850 4 0.0898 0.6880 0.020 0.000 0.000 0.972 0.008
#> GSM39851 4 0.3720 0.5529 0.228 0.000 0.000 0.760 0.012
#> GSM39855 5 0.4698 0.0877 0.000 0.008 0.468 0.004 0.520
#> GSM39856 3 0.0963 0.8199 0.000 0.000 0.964 0.000 0.036
#> GSM39858 3 0.0290 0.8239 0.000 0.000 0.992 0.000 0.008
#> GSM39859 3 0.0963 0.8187 0.000 0.000 0.964 0.000 0.036
#> GSM39862 5 0.1329 0.7301 0.004 0.000 0.008 0.032 0.956
#> GSM39863 1 0.3906 0.5446 0.704 0.000 0.004 0.292 0.000
#> GSM39865 2 0.2011 0.8549 0.000 0.908 0.000 0.004 0.088
#> GSM39866 4 0.6347 0.0475 0.356 0.000 0.004 0.492 0.148
#> GSM39867 1 0.5736 0.6506 0.688 0.056 0.000 0.180 0.076
#> GSM39869 2 0.2230 0.8351 0.000 0.884 0.000 0.000 0.116
#> GSM39870 3 0.2936 0.7794 0.024 0.000 0.872 0.096 0.008
#> GSM39871 3 0.0609 0.8230 0.000 0.000 0.980 0.000 0.020
#> GSM39872 5 0.2206 0.7300 0.016 0.000 0.068 0.004 0.912
#> GSM39828 4 0.3922 0.6097 0.180 0.000 0.000 0.780 0.040
#> GSM39829 3 0.2237 0.8065 0.040 0.000 0.916 0.040 0.004
#> GSM39830 3 0.5987 0.5206 0.236 0.000 0.616 0.136 0.012
#> GSM39832 1 0.1205 0.7519 0.956 0.000 0.000 0.040 0.004
#> GSM39833 2 0.7103 0.1589 0.360 0.472 0.004 0.112 0.052
#> GSM39834 5 0.3181 0.6571 0.072 0.000 0.000 0.072 0.856
#> GSM39835 1 0.3689 0.6702 0.820 0.024 0.000 0.016 0.140
#> GSM39836 4 0.1628 0.6767 0.008 0.000 0.000 0.936 0.056
#> GSM39837 2 0.1124 0.8928 0.000 0.960 0.000 0.036 0.004
#> GSM39838 4 0.6035 0.3195 0.004 0.316 0.000 0.556 0.124
#> GSM39839 3 0.2678 0.7833 0.100 0.000 0.880 0.004 0.016
#> GSM39840 4 0.4546 0.1592 0.460 0.000 0.000 0.532 0.008
#> GSM39841 1 0.4878 0.6731 0.756 0.048 0.020 0.164 0.012
#> GSM39842 1 0.1455 0.7301 0.952 0.000 0.008 0.008 0.032
#> GSM39843 4 0.5259 0.3576 0.368 0.000 0.028 0.588 0.016
#> GSM39844 1 0.1831 0.7540 0.920 0.000 0.000 0.076 0.004
#> GSM39845 3 0.0880 0.8204 0.000 0.000 0.968 0.000 0.032
#> GSM39852 4 0.2763 0.6352 0.004 0.000 0.000 0.848 0.148
#> GSM39853 2 0.0566 0.9043 0.012 0.984 0.000 0.004 0.000
#> GSM39854 1 0.6709 0.4733 0.552 0.296 0.000 0.072 0.080
#> GSM39857 5 0.4227 0.2601 0.000 0.000 0.420 0.000 0.580
#> GSM39860 5 0.1652 0.7374 0.004 0.004 0.040 0.008 0.944
#> GSM39861 3 0.0324 0.8239 0.000 0.000 0.992 0.004 0.004
#> GSM39864 4 0.6332 -0.1064 0.424 0.000 0.004 0.436 0.136
#> GSM39868 5 0.5449 0.3757 0.104 0.000 0.000 0.264 0.632
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.0713 0.857 0.000 0.028 0.000 0.000 0.972 0.000
#> GSM39874 5 0.0790 0.856 0.000 0.032 0.000 0.000 0.968 0.000
#> GSM39875 5 0.0547 0.857 0.000 0.020 0.000 0.000 0.980 0.000
#> GSM39876 5 0.0790 0.856 0.000 0.032 0.000 0.000 0.968 0.000
#> GSM39831 1 0.1405 0.654 0.948 0.024 0.004 0.024 0.000 0.000
#> GSM39819 3 0.2800 0.753 0.068 0.020 0.880 0.024 0.000 0.008
#> GSM39820 3 0.1863 0.781 0.036 0.044 0.920 0.000 0.000 0.000
#> GSM39821 4 0.0405 0.833 0.008 0.004 0.000 0.988 0.000 0.000
#> GSM39822 5 0.0862 0.850 0.000 0.008 0.000 0.016 0.972 0.004
#> GSM39823 3 0.4766 0.332 0.000 0.072 0.612 0.000 0.000 0.316
#> GSM39824 3 0.3929 0.498 0.000 0.028 0.700 0.000 0.000 0.272
#> GSM39825 3 0.5868 0.393 0.004 0.048 0.612 0.220 0.000 0.116
#> GSM39826 4 0.0914 0.831 0.000 0.016 0.000 0.968 0.000 0.016
#> GSM39827 1 0.6274 0.321 0.480 0.124 0.000 0.348 0.048 0.000
#> GSM39846 3 0.0520 0.800 0.000 0.008 0.984 0.000 0.000 0.008
#> GSM39847 4 0.0665 0.832 0.004 0.008 0.000 0.980 0.000 0.008
#> GSM39848 6 0.3573 0.423 0.000 0.120 0.000 0.028 0.036 0.816
#> GSM39849 2 0.7154 0.233 0.080 0.464 0.264 0.016 0.000 0.176
#> GSM39850 4 0.0622 0.833 0.000 0.012 0.000 0.980 0.000 0.008
#> GSM39851 4 0.1340 0.823 0.040 0.008 0.000 0.948 0.000 0.004
#> GSM39855 6 0.4783 0.147 0.000 0.052 0.428 0.000 0.000 0.520
#> GSM39856 3 0.1845 0.783 0.000 0.052 0.920 0.000 0.000 0.028
#> GSM39858 3 0.0405 0.800 0.000 0.008 0.988 0.000 0.000 0.004
#> GSM39859 3 0.0725 0.800 0.000 0.012 0.976 0.000 0.000 0.012
#> GSM39862 6 0.4596 0.323 0.004 0.204 0.000 0.096 0.000 0.696
#> GSM39863 1 0.2913 0.663 0.860 0.092 0.012 0.036 0.000 0.000
#> GSM39865 5 0.4086 0.648 0.004 0.048 0.000 0.000 0.728 0.220
#> GSM39866 1 0.6243 0.466 0.504 0.372 0.020 0.036 0.008 0.060
#> GSM39867 1 0.4371 0.625 0.740 0.188 0.000 0.004 0.048 0.020
#> GSM39869 5 0.2631 0.799 0.004 0.044 0.000 0.000 0.876 0.076
#> GSM39870 3 0.3956 0.673 0.104 0.096 0.788 0.008 0.000 0.004
#> GSM39871 3 0.1225 0.795 0.000 0.036 0.952 0.000 0.000 0.012
#> GSM39872 6 0.4505 0.342 0.008 0.252 0.056 0.000 0.000 0.684
#> GSM39828 4 0.1592 0.825 0.008 0.032 0.000 0.940 0.000 0.020
#> GSM39829 3 0.2961 0.746 0.080 0.048 0.860 0.012 0.000 0.000
#> GSM39830 3 0.7163 -0.143 0.116 0.172 0.396 0.316 0.000 0.000
#> GSM39832 1 0.1387 0.621 0.932 0.068 0.000 0.000 0.000 0.000
#> GSM39833 4 0.7367 0.129 0.044 0.256 0.004 0.432 0.232 0.032
#> GSM39834 6 0.5073 0.380 0.096 0.292 0.000 0.004 0.000 0.608
#> GSM39835 2 0.6245 0.234 0.336 0.492 0.000 0.004 0.032 0.136
#> GSM39836 4 0.1232 0.824 0.004 0.016 0.000 0.956 0.000 0.024
#> GSM39837 5 0.2261 0.787 0.000 0.004 0.000 0.104 0.884 0.008
#> GSM39838 5 0.7796 0.112 0.016 0.244 0.000 0.156 0.372 0.212
#> GSM39839 3 0.2358 0.772 0.048 0.040 0.900 0.012 0.000 0.000
#> GSM39840 4 0.4215 0.583 0.244 0.056 0.000 0.700 0.000 0.000
#> GSM39841 1 0.3889 0.597 0.816 0.056 0.008 0.080 0.040 0.000
#> GSM39842 1 0.3921 0.207 0.676 0.308 0.000 0.004 0.000 0.012
#> GSM39843 4 0.2519 0.791 0.044 0.068 0.004 0.884 0.000 0.000
#> GSM39844 1 0.0777 0.646 0.972 0.024 0.000 0.004 0.000 0.000
#> GSM39845 3 0.0405 0.800 0.000 0.004 0.988 0.000 0.000 0.008
#> GSM39852 4 0.5926 0.404 0.032 0.184 0.000 0.580 0.000 0.204
#> GSM39853 5 0.0260 0.853 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM39854 1 0.4849 0.565 0.700 0.128 0.000 0.000 0.156 0.016
#> GSM39857 6 0.4774 0.154 0.000 0.052 0.420 0.000 0.000 0.528
#> GSM39860 6 0.1332 0.474 0.000 0.028 0.012 0.008 0.000 0.952
#> GSM39861 3 0.0508 0.799 0.004 0.012 0.984 0.000 0.000 0.000
#> GSM39864 1 0.5572 0.527 0.588 0.300 0.008 0.020 0.000 0.084
#> GSM39868 6 0.5556 0.345 0.112 0.332 0.000 0.012 0.000 0.544
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> SD:NMF 54 0.008435 0.014440 2
#> SD:NMF 54 0.000521 0.000928 3
#> SD:NMF 50 0.000587 0.008722 4
#> SD:NMF 46 0.001228 0.010724 5
#> SD:NMF 38 0.002402 0.013319 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.264 0.570 0.807 0.3531 0.646 0.646
#> 3 3 0.213 0.385 0.719 0.3567 0.784 0.687
#> 4 4 0.340 0.562 0.757 0.3301 0.712 0.496
#> 5 5 0.478 0.619 0.744 0.1290 0.920 0.773
#> 6 6 0.532 0.545 0.724 0.0551 0.977 0.920
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.2948 0.646535 0.052 0.948
#> GSM39874 2 0.2948 0.646535 0.052 0.948
#> GSM39875 2 0.2948 0.646535 0.052 0.948
#> GSM39876 2 0.2948 0.646535 0.052 0.948
#> GSM39831 1 0.0000 0.733250 1.000 0.000
#> GSM39819 1 0.8661 0.605918 0.712 0.288
#> GSM39820 1 0.8608 0.610612 0.716 0.284
#> GSM39821 1 0.0938 0.735736 0.988 0.012
#> GSM39822 2 0.9922 0.263347 0.448 0.552
#> GSM39823 1 0.9922 0.225297 0.552 0.448
#> GSM39824 2 0.9988 -0.000784 0.480 0.520
#> GSM39825 1 0.4815 0.728372 0.896 0.104
#> GSM39826 1 0.1184 0.731794 0.984 0.016
#> GSM39827 1 0.6887 0.679787 0.816 0.184
#> GSM39846 1 0.9815 0.343348 0.580 0.420
#> GSM39847 1 0.0938 0.735736 0.988 0.012
#> GSM39848 2 0.1633 0.620883 0.024 0.976
#> GSM39849 1 0.8861 0.563872 0.696 0.304
#> GSM39850 1 0.1184 0.731794 0.984 0.016
#> GSM39851 1 0.0000 0.733250 1.000 0.000
#> GSM39855 2 0.9209 0.445981 0.336 0.664
#> GSM39856 1 0.9795 0.356162 0.584 0.416
#> GSM39858 1 0.9248 0.522661 0.660 0.340
#> GSM39859 1 0.8955 0.571840 0.688 0.312
#> GSM39862 2 0.9933 0.255422 0.452 0.548
#> GSM39863 1 0.0000 0.733250 1.000 0.000
#> GSM39865 2 0.9922 0.243193 0.448 0.552
#> GSM39866 1 0.2603 0.740080 0.956 0.044
#> GSM39867 1 0.8713 0.536924 0.708 0.292
#> GSM39869 2 0.9866 0.322474 0.432 0.568
#> GSM39870 1 0.8499 0.618681 0.724 0.276
#> GSM39871 1 0.8955 0.571840 0.688 0.312
#> GSM39872 1 0.6531 0.698858 0.832 0.168
#> GSM39828 1 0.0000 0.733250 1.000 0.000
#> GSM39829 1 0.8555 0.614596 0.720 0.280
#> GSM39830 1 0.0938 0.736609 0.988 0.012
#> GSM39832 1 0.0000 0.733250 1.000 0.000
#> GSM39833 1 0.8661 0.593565 0.712 0.288
#> GSM39834 1 0.3733 0.737152 0.928 0.072
#> GSM39835 1 0.7376 0.630976 0.792 0.208
#> GSM39836 1 0.0938 0.735736 0.988 0.012
#> GSM39837 1 1.0000 -0.138118 0.504 0.496
#> GSM39838 1 0.9775 0.269570 0.588 0.412
#> GSM39839 1 0.8661 0.605918 0.712 0.288
#> GSM39840 1 0.0672 0.736847 0.992 0.008
#> GSM39841 1 0.4022 0.728554 0.920 0.080
#> GSM39842 1 0.0000 0.733250 1.000 0.000
#> GSM39843 1 0.0000 0.733250 1.000 0.000
#> GSM39844 1 0.0000 0.733250 1.000 0.000
#> GSM39845 1 0.8661 0.605918 0.712 0.288
#> GSM39852 1 0.2236 0.739832 0.964 0.036
#> GSM39853 2 0.9996 0.121806 0.488 0.512
#> GSM39854 1 0.8713 0.536924 0.708 0.292
#> GSM39857 1 0.9922 0.225297 0.552 0.448
#> GSM39860 2 0.0672 0.617143 0.008 0.992
#> GSM39861 1 0.8763 0.594640 0.704 0.296
#> GSM39864 1 0.1843 0.739457 0.972 0.028
#> GSM39868 1 0.3733 0.737152 0.928 0.072
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.3879 0.56065 0.000 0.848 0.152
#> GSM39874 2 0.3879 0.56065 0.000 0.848 0.152
#> GSM39875 2 0.3879 0.56065 0.000 0.848 0.152
#> GSM39876 2 0.3879 0.56065 0.000 0.848 0.152
#> GSM39831 1 0.0892 0.65261 0.980 0.000 0.020
#> GSM39819 1 0.6286 0.00665 0.536 0.000 0.464
#> GSM39820 1 0.6274 0.02123 0.544 0.000 0.456
#> GSM39821 1 0.1950 0.65719 0.952 0.008 0.040
#> GSM39822 2 0.9433 0.37215 0.356 0.460 0.184
#> GSM39823 3 0.7099 0.41771 0.384 0.028 0.588
#> GSM39824 3 0.6828 0.46867 0.312 0.032 0.656
#> GSM39825 1 0.5070 0.50689 0.772 0.004 0.224
#> GSM39826 1 0.2550 0.65075 0.936 0.024 0.040
#> GSM39827 1 0.5961 0.54967 0.792 0.112 0.096
#> GSM39846 3 0.6314 0.38256 0.392 0.004 0.604
#> GSM39847 1 0.1950 0.65719 0.952 0.008 0.040
#> GSM39848 3 0.6869 -0.14291 0.016 0.424 0.560
#> GSM39849 1 0.7410 0.12300 0.576 0.040 0.384
#> GSM39850 1 0.2550 0.65075 0.936 0.024 0.040
#> GSM39851 1 0.0892 0.65261 0.980 0.000 0.020
#> GSM39855 3 0.7739 0.35400 0.204 0.124 0.672
#> GSM39856 3 0.6330 0.37265 0.396 0.004 0.600
#> GSM39858 3 0.6518 0.08446 0.484 0.004 0.512
#> GSM39859 1 0.6307 -0.08900 0.512 0.000 0.488
#> GSM39862 3 0.9793 0.21761 0.376 0.236 0.388
#> GSM39863 1 0.0892 0.65261 0.980 0.000 0.020
#> GSM39865 1 0.9872 -0.34453 0.372 0.372 0.256
#> GSM39866 1 0.2486 0.65098 0.932 0.008 0.060
#> GSM39867 1 0.8245 0.27904 0.624 0.244 0.132
#> GSM39869 2 0.9641 0.32497 0.356 0.432 0.212
#> GSM39870 1 0.6215 0.08277 0.572 0.000 0.428
#> GSM39871 1 0.6307 -0.08900 0.512 0.000 0.488
#> GSM39872 1 0.5623 0.43527 0.716 0.004 0.280
#> GSM39828 1 0.0747 0.65344 0.984 0.000 0.016
#> GSM39829 1 0.6260 0.05351 0.552 0.000 0.448
#> GSM39830 1 0.1643 0.65888 0.956 0.000 0.044
#> GSM39832 1 0.1031 0.65123 0.976 0.000 0.024
#> GSM39833 1 0.8034 0.20963 0.584 0.080 0.336
#> GSM39834 1 0.3644 0.61614 0.872 0.004 0.124
#> GSM39835 1 0.7101 0.43193 0.704 0.216 0.080
#> GSM39836 1 0.1950 0.65626 0.952 0.008 0.040
#> GSM39837 2 0.9336 0.32058 0.412 0.424 0.164
#> GSM39838 1 0.9181 0.17821 0.540 0.236 0.224
#> GSM39839 1 0.6286 0.00665 0.536 0.000 0.464
#> GSM39840 1 0.1170 0.65476 0.976 0.008 0.016
#> GSM39841 1 0.3415 0.62254 0.900 0.080 0.020
#> GSM39842 1 0.1031 0.65123 0.976 0.000 0.024
#> GSM39843 1 0.0747 0.65344 0.984 0.000 0.016
#> GSM39844 1 0.1031 0.65123 0.976 0.000 0.024
#> GSM39845 1 0.6286 0.00665 0.536 0.000 0.464
#> GSM39852 1 0.2584 0.65209 0.928 0.008 0.064
#> GSM39853 2 0.9361 0.34770 0.396 0.436 0.168
#> GSM39854 1 0.8245 0.27904 0.624 0.244 0.132
#> GSM39857 3 0.7099 0.41771 0.384 0.028 0.588
#> GSM39860 3 0.6095 -0.10329 0.000 0.392 0.608
#> GSM39861 1 0.6291 -0.01191 0.532 0.000 0.468
#> GSM39864 1 0.1753 0.65353 0.952 0.000 0.048
#> GSM39868 1 0.3644 0.61614 0.872 0.004 0.124
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.48967 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.48967 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.48967 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.48967 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0779 0.75192 0.980 0.000 0.016 0.004
#> GSM39819 3 0.4072 0.72907 0.252 0.000 0.748 0.000
#> GSM39820 3 0.4222 0.71733 0.272 0.000 0.728 0.000
#> GSM39821 1 0.4239 0.73631 0.808 0.004 0.160 0.028
#> GSM39822 2 0.8523 0.54375 0.208 0.524 0.188 0.080
#> GSM39823 3 0.4274 0.57731 0.072 0.000 0.820 0.108
#> GSM39824 3 0.3401 0.47127 0.008 0.000 0.840 0.152
#> GSM39825 1 0.5535 0.00742 0.560 0.000 0.420 0.020
#> GSM39826 1 0.5139 0.69762 0.768 0.020 0.172 0.040
#> GSM39827 1 0.6385 0.60179 0.712 0.152 0.092 0.044
#> GSM39846 3 0.2313 0.60373 0.032 0.000 0.924 0.044
#> GSM39847 1 0.4239 0.73631 0.808 0.004 0.160 0.028
#> GSM39848 4 0.3144 0.64016 0.000 0.044 0.072 0.884
#> GSM39849 3 0.6355 0.40411 0.256 0.016 0.656 0.072
#> GSM39850 1 0.5139 0.69762 0.768 0.020 0.172 0.040
#> GSM39851 1 0.0592 0.75222 0.984 0.000 0.016 0.000
#> GSM39855 3 0.4661 0.03118 0.000 0.000 0.652 0.348
#> GSM39856 3 0.1936 0.61273 0.032 0.000 0.940 0.028
#> GSM39858 3 0.3486 0.71301 0.188 0.000 0.812 0.000
#> GSM39859 3 0.3801 0.72828 0.220 0.000 0.780 0.000
#> GSM39862 4 0.7901 0.28461 0.176 0.016 0.344 0.464
#> GSM39863 1 0.0779 0.75192 0.980 0.000 0.016 0.004
#> GSM39865 2 0.9677 0.42045 0.224 0.384 0.196 0.196
#> GSM39866 1 0.3880 0.71815 0.836 0.008 0.136 0.020
#> GSM39867 1 0.9075 0.04948 0.460 0.244 0.184 0.112
#> GSM39869 2 0.9650 0.45024 0.208 0.388 0.180 0.224
#> GSM39870 3 0.4605 0.65456 0.336 0.000 0.664 0.000
#> GSM39871 3 0.3688 0.72807 0.208 0.000 0.792 0.000
#> GSM39872 3 0.6204 -0.04215 0.448 0.000 0.500 0.052
#> GSM39828 1 0.1022 0.75203 0.968 0.000 0.032 0.000
#> GSM39829 3 0.4134 0.72630 0.260 0.000 0.740 0.000
#> GSM39830 1 0.2973 0.69301 0.856 0.000 0.144 0.000
#> GSM39832 1 0.1151 0.74963 0.968 0.000 0.024 0.008
#> GSM39833 3 0.7545 0.13604 0.344 0.052 0.532 0.072
#> GSM39834 1 0.5592 0.63536 0.680 0.000 0.264 0.056
#> GSM39835 1 0.8422 0.29565 0.560 0.128 0.156 0.156
#> GSM39836 1 0.4857 0.70749 0.764 0.004 0.192 0.040
#> GSM39837 2 0.8373 0.51090 0.260 0.504 0.184 0.052
#> GSM39838 1 0.9773 -0.15476 0.348 0.248 0.232 0.172
#> GSM39839 3 0.4072 0.72907 0.252 0.000 0.748 0.000
#> GSM39840 1 0.1356 0.75322 0.960 0.000 0.032 0.008
#> GSM39841 1 0.3319 0.71612 0.888 0.060 0.016 0.036
#> GSM39842 1 0.1151 0.74963 0.968 0.000 0.024 0.008
#> GSM39843 1 0.1022 0.75203 0.968 0.000 0.032 0.000
#> GSM39844 1 0.1151 0.74963 0.968 0.000 0.024 0.008
#> GSM39845 3 0.4008 0.73051 0.244 0.000 0.756 0.000
#> GSM39852 1 0.4513 0.73207 0.796 0.004 0.160 0.040
#> GSM39853 2 0.8291 0.53684 0.244 0.520 0.184 0.052
#> GSM39854 1 0.9075 0.04948 0.460 0.244 0.184 0.112
#> GSM39857 3 0.4274 0.57731 0.072 0.000 0.820 0.108
#> GSM39860 4 0.2831 0.65518 0.000 0.004 0.120 0.876
#> GSM39861 3 0.3975 0.73093 0.240 0.000 0.760 0.000
#> GSM39864 1 0.3166 0.72755 0.868 0.000 0.116 0.016
#> GSM39868 1 0.5592 0.63536 0.680 0.000 0.264 0.056
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM39831 4 0.1357 0.7229 0.048 0.000 0.004 0.948 0.000
#> GSM39819 3 0.3210 0.7349 0.000 0.000 0.788 0.212 0.000
#> GSM39820 3 0.3671 0.7169 0.008 0.000 0.756 0.236 0.000
#> GSM39821 4 0.4887 0.6152 0.288 0.000 0.052 0.660 0.000
#> GSM39822 1 0.6197 0.5764 0.492 0.428 0.020 0.020 0.040
#> GSM39823 3 0.4100 0.6007 0.008 0.000 0.792 0.052 0.148
#> GSM39824 3 0.3048 0.5300 0.004 0.000 0.820 0.000 0.176
#> GSM39825 4 0.6077 0.0990 0.088 0.000 0.392 0.508 0.012
#> GSM39826 4 0.4897 0.5270 0.352 0.004 0.028 0.616 0.000
#> GSM39827 4 0.6382 0.3690 0.300 0.096 0.036 0.568 0.000
#> GSM39846 3 0.1502 0.6301 0.004 0.000 0.940 0.000 0.056
#> GSM39847 4 0.4887 0.6152 0.288 0.000 0.052 0.660 0.000
#> GSM39848 5 0.2899 0.6598 0.056 0.032 0.024 0.000 0.888
#> GSM39849 3 0.5373 0.3860 0.244 0.000 0.676 0.048 0.032
#> GSM39850 4 0.4897 0.5270 0.352 0.004 0.028 0.616 0.000
#> GSM39851 4 0.0865 0.7214 0.024 0.000 0.004 0.972 0.000
#> GSM39855 3 0.4264 0.1490 0.004 0.000 0.620 0.000 0.376
#> GSM39856 3 0.0955 0.6420 0.004 0.000 0.968 0.000 0.028
#> GSM39858 3 0.3488 0.7324 0.000 0.000 0.808 0.168 0.024
#> GSM39859 3 0.3086 0.7385 0.000 0.000 0.816 0.180 0.004
#> GSM39862 5 0.7704 0.4225 0.116 0.000 0.284 0.140 0.460
#> GSM39863 4 0.1357 0.7229 0.048 0.000 0.004 0.948 0.000
#> GSM39865 1 0.7476 0.6072 0.476 0.300 0.016 0.036 0.172
#> GSM39866 4 0.5040 0.6703 0.200 0.004 0.072 0.716 0.008
#> GSM39867 1 0.5427 0.6454 0.688 0.120 0.012 0.180 0.000
#> GSM39869 1 0.6634 0.6006 0.564 0.272 0.012 0.016 0.136
#> GSM39870 3 0.4404 0.6442 0.024 0.000 0.684 0.292 0.000
#> GSM39871 3 0.2813 0.7384 0.000 0.000 0.832 0.168 0.000
#> GSM39872 3 0.6947 0.0575 0.160 0.000 0.460 0.352 0.028
#> GSM39828 4 0.1195 0.7265 0.028 0.000 0.012 0.960 0.000
#> GSM39829 3 0.3659 0.7306 0.012 0.000 0.768 0.220 0.000
#> GSM39830 4 0.2873 0.6760 0.020 0.000 0.120 0.860 0.000
#> GSM39832 4 0.1792 0.6988 0.084 0.000 0.000 0.916 0.000
#> GSM39833 3 0.6988 0.1193 0.360 0.028 0.496 0.092 0.024
#> GSM39834 4 0.6424 0.5023 0.316 0.000 0.124 0.540 0.020
#> GSM39835 1 0.4095 0.2349 0.752 0.000 0.004 0.220 0.024
#> GSM39836 4 0.5174 0.5420 0.340 0.000 0.056 0.604 0.000
#> GSM39837 1 0.5877 0.6180 0.520 0.404 0.020 0.056 0.000
#> GSM39838 1 0.8649 0.5811 0.460 0.196 0.052 0.152 0.140
#> GSM39839 3 0.3210 0.7349 0.000 0.000 0.788 0.212 0.000
#> GSM39840 4 0.1168 0.7258 0.032 0.000 0.008 0.960 0.000
#> GSM39841 4 0.3257 0.6582 0.124 0.028 0.004 0.844 0.000
#> GSM39842 4 0.1792 0.6988 0.084 0.000 0.000 0.916 0.000
#> GSM39843 4 0.0898 0.7254 0.020 0.000 0.008 0.972 0.000
#> GSM39844 4 0.1792 0.6988 0.084 0.000 0.000 0.916 0.000
#> GSM39845 3 0.3177 0.7367 0.000 0.000 0.792 0.208 0.000
#> GSM39852 4 0.5361 0.6188 0.284 0.000 0.060 0.644 0.012
#> GSM39853 1 0.5663 0.6042 0.520 0.420 0.020 0.040 0.000
#> GSM39854 1 0.5427 0.6454 0.688 0.120 0.012 0.180 0.000
#> GSM39857 3 0.4100 0.6007 0.008 0.000 0.792 0.052 0.148
#> GSM39860 5 0.0794 0.6696 0.000 0.000 0.028 0.000 0.972
#> GSM39861 3 0.3266 0.7381 0.004 0.000 0.796 0.200 0.000
#> GSM39864 4 0.4480 0.6866 0.180 0.000 0.064 0.752 0.004
#> GSM39868 4 0.6424 0.5023 0.316 0.000 0.124 0.540 0.020
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 4 0.2122 0.63147 0.076 0.000 0.000 0.900 0.024 0.000
#> GSM39819 3 0.2854 0.73008 0.000 0.000 0.792 0.208 0.000 0.000
#> GSM39820 3 0.3786 0.70747 0.008 0.000 0.748 0.220 0.024 0.000
#> GSM39821 4 0.5066 0.50077 0.064 0.000 0.012 0.588 0.336 0.000
#> GSM39822 5 0.4388 0.62143 0.000 0.312 0.000 0.004 0.648 0.036
#> GSM39823 3 0.3735 0.60213 0.008 0.000 0.792 0.044 0.004 0.152
#> GSM39824 3 0.2979 0.54226 0.004 0.000 0.804 0.000 0.004 0.188
#> GSM39825 4 0.6607 -0.00454 0.108 0.000 0.380 0.440 0.064 0.008
#> GSM39826 4 0.5183 0.38874 0.080 0.000 0.004 0.528 0.388 0.000
#> GSM39827 5 0.5343 -0.25674 0.060 0.004 0.012 0.452 0.472 0.000
#> GSM39846 3 0.1818 0.63574 0.004 0.000 0.920 0.004 0.004 0.068
#> GSM39847 4 0.5066 0.50077 0.064 0.000 0.012 0.588 0.336 0.000
#> GSM39848 6 0.2510 0.54236 0.060 0.024 0.000 0.000 0.024 0.892
#> GSM39849 3 0.4164 0.34923 0.308 0.000 0.668 0.012 0.008 0.004
#> GSM39850 4 0.5183 0.38874 0.080 0.000 0.004 0.528 0.388 0.000
#> GSM39851 4 0.0632 0.63720 0.024 0.000 0.000 0.976 0.000 0.000
#> GSM39855 3 0.4090 0.18238 0.008 0.000 0.604 0.000 0.004 0.384
#> GSM39856 3 0.1371 0.64720 0.004 0.000 0.948 0.004 0.004 0.040
#> GSM39858 3 0.3351 0.72927 0.004 0.000 0.800 0.168 0.000 0.028
#> GSM39859 3 0.2738 0.73466 0.000 0.000 0.820 0.176 0.000 0.004
#> GSM39862 6 0.7649 0.26864 0.140 0.000 0.268 0.104 0.048 0.440
#> GSM39863 4 0.2122 0.63147 0.076 0.000 0.000 0.900 0.024 0.000
#> GSM39865 5 0.5858 0.59617 0.036 0.188 0.000 0.004 0.612 0.160
#> GSM39866 4 0.6011 0.54287 0.168 0.000 0.032 0.560 0.240 0.000
#> GSM39867 5 0.2585 0.52936 0.048 0.004 0.000 0.068 0.880 0.000
#> GSM39869 5 0.5219 0.56578 0.028 0.164 0.000 0.000 0.672 0.136
#> GSM39870 3 0.4751 0.63147 0.024 0.000 0.672 0.256 0.048 0.000
#> GSM39871 3 0.2491 0.73388 0.000 0.000 0.836 0.164 0.000 0.000
#> GSM39872 3 0.7146 0.02167 0.208 0.000 0.436 0.260 0.092 0.004
#> GSM39828 4 0.1777 0.64871 0.044 0.000 0.004 0.928 0.024 0.000
#> GSM39829 3 0.3430 0.72791 0.016 0.000 0.772 0.208 0.004 0.000
#> GSM39830 4 0.2889 0.59342 0.020 0.000 0.116 0.852 0.012 0.000
#> GSM39832 4 0.2888 0.57847 0.092 0.000 0.000 0.852 0.056 0.000
#> GSM39833 3 0.7085 -0.00670 0.256 0.020 0.480 0.052 0.188 0.004
#> GSM39834 4 0.7118 0.29315 0.228 0.000 0.068 0.372 0.328 0.004
#> GSM39835 1 0.4431 0.00000 0.688 0.000 0.000 0.076 0.236 0.000
#> GSM39836 4 0.5497 0.39322 0.092 0.000 0.012 0.504 0.392 0.000
#> GSM39837 5 0.4009 0.63547 0.000 0.288 0.000 0.028 0.684 0.000
#> GSM39838 5 0.6295 0.53610 0.076 0.084 0.008 0.048 0.656 0.128
#> GSM39839 3 0.2854 0.73008 0.000 0.000 0.792 0.208 0.000 0.000
#> GSM39840 4 0.1405 0.64753 0.024 0.000 0.004 0.948 0.024 0.000
#> GSM39841 4 0.3564 0.56167 0.040 0.016 0.000 0.808 0.136 0.000
#> GSM39842 4 0.2888 0.57847 0.092 0.000 0.000 0.852 0.056 0.000
#> GSM39843 4 0.1148 0.64730 0.020 0.000 0.004 0.960 0.016 0.000
#> GSM39844 4 0.2888 0.57847 0.092 0.000 0.000 0.852 0.056 0.000
#> GSM39845 3 0.2823 0.73205 0.000 0.000 0.796 0.204 0.000 0.000
#> GSM39852 4 0.6002 0.47376 0.140 0.000 0.012 0.512 0.328 0.008
#> GSM39853 5 0.3853 0.63237 0.000 0.304 0.000 0.016 0.680 0.000
#> GSM39854 5 0.2585 0.52936 0.048 0.004 0.000 0.068 0.880 0.000
#> GSM39857 3 0.3735 0.60213 0.008 0.000 0.792 0.044 0.004 0.152
#> GSM39860 6 0.0146 0.55010 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM39861 3 0.2902 0.73386 0.000 0.000 0.800 0.196 0.004 0.000
#> GSM39864 4 0.5560 0.58036 0.140 0.000 0.028 0.624 0.208 0.000
#> GSM39868 4 0.7118 0.29315 0.228 0.000 0.068 0.372 0.328 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> CV:hclust 45 4.84e-06 2.77e-06 2
#> CV:hclust 27 9.26e-06 5.89e-06 3
#> CV:hclust 41 NA 7.46e-01 4
#> CV:hclust 50 3.61e-10 1.76e-07 5
#> CV:hclust 44 6.42e-09 2.16e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.246 0.684 0.830 0.4160 0.687 0.687
#> 3 3 0.688 0.808 0.904 0.5026 0.652 0.509
#> 4 4 0.543 0.507 0.745 0.1479 0.907 0.765
#> 5 5 0.550 0.469 0.713 0.0798 0.850 0.563
#> 6 6 0.621 0.392 0.640 0.0524 0.840 0.460
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.5629 0.899 0.132 0.868
#> GSM39874 2 0.5629 0.899 0.132 0.868
#> GSM39875 2 0.5629 0.899 0.132 0.868
#> GSM39876 2 0.5629 0.899 0.132 0.868
#> GSM39831 1 0.0000 0.776 1.000 0.000
#> GSM39819 1 0.7602 0.731 0.780 0.220
#> GSM39820 1 0.7602 0.731 0.780 0.220
#> GSM39821 1 0.0376 0.776 0.996 0.004
#> GSM39822 2 0.6531 0.876 0.168 0.832
#> GSM39823 1 0.9833 0.535 0.576 0.424
#> GSM39824 2 0.5737 0.678 0.136 0.864
#> GSM39825 1 0.7299 0.737 0.796 0.204
#> GSM39826 1 0.0672 0.774 0.992 0.008
#> GSM39827 1 0.0672 0.774 0.992 0.008
#> GSM39846 1 0.9833 0.535 0.576 0.424
#> GSM39847 1 0.0376 0.776 0.996 0.004
#> GSM39848 2 0.6343 0.881 0.160 0.840
#> GSM39849 1 0.9833 0.535 0.576 0.424
#> GSM39850 1 0.0672 0.774 0.992 0.008
#> GSM39851 1 0.0376 0.776 0.996 0.004
#> GSM39855 2 0.5737 0.678 0.136 0.864
#> GSM39856 1 0.9833 0.535 0.576 0.424
#> GSM39858 1 0.8813 0.680 0.700 0.300
#> GSM39859 1 0.8813 0.680 0.700 0.300
#> GSM39862 1 0.8955 0.567 0.688 0.312
#> GSM39863 1 0.0000 0.776 1.000 0.000
#> GSM39865 2 0.5629 0.897 0.132 0.868
#> GSM39866 1 0.0000 0.776 1.000 0.000
#> GSM39867 1 0.5946 0.640 0.856 0.144
#> GSM39869 2 0.6887 0.857 0.184 0.816
#> GSM39870 1 0.7602 0.731 0.780 0.220
#> GSM39871 1 0.8909 0.674 0.692 0.308
#> GSM39872 1 0.9732 0.564 0.596 0.404
#> GSM39828 1 0.1184 0.777 0.984 0.016
#> GSM39829 1 0.7299 0.736 0.796 0.204
#> GSM39830 1 0.5408 0.754 0.876 0.124
#> GSM39832 1 0.0672 0.774 0.992 0.008
#> GSM39833 1 0.6801 0.688 0.820 0.180
#> GSM39834 1 0.3584 0.773 0.932 0.068
#> GSM39835 1 0.7056 0.624 0.808 0.192
#> GSM39836 1 0.0376 0.776 0.996 0.004
#> GSM39837 1 0.9944 -0.170 0.544 0.456
#> GSM39838 1 0.9944 -0.170 0.544 0.456
#> GSM39839 1 0.7602 0.731 0.780 0.220
#> GSM39840 1 0.0672 0.774 0.992 0.008
#> GSM39841 1 0.0672 0.774 0.992 0.008
#> GSM39842 1 0.0672 0.774 0.992 0.008
#> GSM39843 1 0.1184 0.777 0.984 0.016
#> GSM39844 1 0.0672 0.774 0.992 0.008
#> GSM39845 1 0.8713 0.687 0.708 0.292
#> GSM39852 1 0.0000 0.776 1.000 0.000
#> GSM39853 1 0.9944 -0.170 0.544 0.456
#> GSM39854 1 0.8555 0.394 0.720 0.280
#> GSM39857 1 0.9833 0.535 0.576 0.424
#> GSM39860 2 0.1414 0.789 0.020 0.980
#> GSM39861 1 0.8713 0.687 0.708 0.292
#> GSM39864 1 0.1633 0.776 0.976 0.024
#> GSM39868 1 0.6801 0.745 0.820 0.180
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.1751 0.9187 0.012 0.960 0.028
#> GSM39874 2 0.1751 0.9187 0.012 0.960 0.028
#> GSM39875 2 0.1751 0.9187 0.012 0.960 0.028
#> GSM39876 2 0.1751 0.9187 0.012 0.960 0.028
#> GSM39831 1 0.1399 0.8885 0.968 0.004 0.028
#> GSM39819 3 0.4062 0.8112 0.164 0.000 0.836
#> GSM39820 3 0.4062 0.8112 0.164 0.000 0.836
#> GSM39821 1 0.1129 0.8856 0.976 0.020 0.004
#> GSM39822 2 0.2749 0.9033 0.064 0.924 0.012
#> GSM39823 3 0.1315 0.8787 0.008 0.020 0.972
#> GSM39824 3 0.1129 0.8759 0.004 0.020 0.976
#> GSM39825 3 0.5070 0.7382 0.224 0.004 0.772
#> GSM39826 1 0.1267 0.8814 0.972 0.024 0.004
#> GSM39827 1 0.1129 0.8856 0.976 0.020 0.004
#> GSM39846 3 0.0983 0.8803 0.004 0.016 0.980
#> GSM39847 1 0.1170 0.8874 0.976 0.016 0.008
#> GSM39848 2 0.2414 0.9132 0.040 0.940 0.020
#> GSM39849 3 0.1129 0.8759 0.004 0.020 0.976
#> GSM39850 1 0.1031 0.8833 0.976 0.024 0.000
#> GSM39851 1 0.1163 0.8888 0.972 0.000 0.028
#> GSM39855 3 0.1399 0.8713 0.004 0.028 0.968
#> GSM39856 3 0.0983 0.8803 0.004 0.016 0.980
#> GSM39858 3 0.0237 0.8832 0.004 0.000 0.996
#> GSM39859 3 0.0237 0.8832 0.004 0.000 0.996
#> GSM39862 1 0.7517 0.3877 0.588 0.048 0.364
#> GSM39863 1 0.1399 0.8885 0.968 0.004 0.028
#> GSM39865 2 0.2414 0.9141 0.040 0.940 0.020
#> GSM39866 1 0.1585 0.8881 0.964 0.008 0.028
#> GSM39867 1 0.1765 0.8777 0.956 0.040 0.004
#> GSM39869 2 0.2446 0.9106 0.052 0.936 0.012
#> GSM39870 3 0.4062 0.8112 0.164 0.000 0.836
#> GSM39871 3 0.0237 0.8832 0.004 0.000 0.996
#> GSM39872 3 0.1453 0.8779 0.008 0.024 0.968
#> GSM39828 1 0.1129 0.8894 0.976 0.004 0.020
#> GSM39829 3 0.4062 0.8112 0.164 0.000 0.836
#> GSM39830 3 0.6305 0.1511 0.484 0.000 0.516
#> GSM39832 1 0.1585 0.8884 0.964 0.008 0.028
#> GSM39833 1 0.4371 0.8129 0.860 0.032 0.108
#> GSM39834 1 0.4249 0.8240 0.864 0.028 0.108
#> GSM39835 1 0.1765 0.8750 0.956 0.040 0.004
#> GSM39836 1 0.1163 0.8834 0.972 0.028 0.000
#> GSM39837 1 0.6521 0.0692 0.500 0.496 0.004
#> GSM39838 1 0.5873 0.5496 0.684 0.312 0.004
#> GSM39839 3 0.3879 0.8183 0.152 0.000 0.848
#> GSM39840 1 0.0892 0.8894 0.980 0.000 0.020
#> GSM39841 1 0.1399 0.8885 0.968 0.004 0.028
#> GSM39842 1 0.1585 0.8884 0.964 0.008 0.028
#> GSM39843 1 0.1163 0.8888 0.972 0.000 0.028
#> GSM39844 1 0.1585 0.8884 0.964 0.008 0.028
#> GSM39845 3 0.0424 0.8828 0.008 0.000 0.992
#> GSM39852 1 0.1031 0.8847 0.976 0.024 0.000
#> GSM39853 1 0.6521 0.0692 0.500 0.496 0.004
#> GSM39854 1 0.2945 0.8421 0.908 0.088 0.004
#> GSM39857 3 0.1315 0.8787 0.008 0.020 0.972
#> GSM39860 2 0.6490 0.4829 0.012 0.628 0.360
#> GSM39861 3 0.0424 0.8828 0.008 0.000 0.992
#> GSM39864 1 0.1585 0.8881 0.964 0.008 0.028
#> GSM39868 1 0.5928 0.5377 0.696 0.008 0.296
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0188 0.6764 0.000 0.996 0.004 0.000
#> GSM39874 2 0.0188 0.6764 0.000 0.996 0.004 0.000
#> GSM39875 2 0.0188 0.6764 0.000 0.996 0.004 0.000
#> GSM39876 2 0.0188 0.6764 0.000 0.996 0.004 0.000
#> GSM39831 1 0.4964 0.4811 0.616 0.000 0.004 0.380
#> GSM39819 3 0.4901 0.7399 0.108 0.000 0.780 0.112
#> GSM39820 3 0.4784 0.7457 0.112 0.000 0.788 0.100
#> GSM39821 1 0.0817 0.5688 0.976 0.000 0.000 0.024
#> GSM39822 2 0.5055 0.6493 0.032 0.712 0.000 0.256
#> GSM39823 3 0.1792 0.8011 0.000 0.000 0.932 0.068
#> GSM39824 3 0.3610 0.7122 0.000 0.000 0.800 0.200
#> GSM39825 3 0.5051 0.6450 0.244 0.004 0.724 0.028
#> GSM39826 1 0.2281 0.5231 0.904 0.000 0.000 0.096
#> GSM39827 1 0.3123 0.5594 0.844 0.000 0.000 0.156
#> GSM39846 3 0.0469 0.8171 0.000 0.000 0.988 0.012
#> GSM39847 1 0.0000 0.5697 1.000 0.000 0.000 0.000
#> GSM39848 2 0.7093 0.3697 0.108 0.452 0.004 0.436
#> GSM39849 3 0.3945 0.7038 0.004 0.000 0.780 0.216
#> GSM39850 1 0.1792 0.5461 0.932 0.000 0.000 0.068
#> GSM39851 1 0.4428 0.5380 0.720 0.000 0.004 0.276
#> GSM39855 3 0.4364 0.6792 0.000 0.016 0.764 0.220
#> GSM39856 3 0.0469 0.8171 0.000 0.000 0.988 0.012
#> GSM39858 3 0.0657 0.8179 0.004 0.000 0.984 0.012
#> GSM39859 3 0.0188 0.8182 0.004 0.000 0.996 0.000
#> GSM39862 4 0.7052 0.0800 0.440 0.004 0.104 0.452
#> GSM39863 1 0.4964 0.4811 0.616 0.000 0.004 0.380
#> GSM39865 2 0.5337 0.6345 0.024 0.672 0.004 0.300
#> GSM39866 1 0.3908 0.5556 0.784 0.000 0.004 0.212
#> GSM39867 1 0.5126 0.2983 0.552 0.004 0.000 0.444
#> GSM39869 2 0.5010 0.6445 0.024 0.700 0.000 0.276
#> GSM39870 3 0.4784 0.7457 0.112 0.000 0.788 0.100
#> GSM39871 3 0.0376 0.8180 0.004 0.000 0.992 0.004
#> GSM39872 3 0.5536 0.6119 0.048 0.004 0.696 0.252
#> GSM39828 1 0.1847 0.5638 0.940 0.004 0.004 0.052
#> GSM39829 3 0.4956 0.7367 0.116 0.000 0.776 0.108
#> GSM39830 3 0.7248 0.2193 0.380 0.000 0.472 0.148
#> GSM39832 1 0.5161 0.3603 0.520 0.000 0.004 0.476
#> GSM39833 1 0.5312 0.2466 0.692 0.000 0.040 0.268
#> GSM39834 1 0.5536 0.2474 0.696 0.004 0.048 0.252
#> GSM39835 4 0.4877 -0.2371 0.408 0.000 0.000 0.592
#> GSM39836 1 0.1792 0.5425 0.932 0.000 0.000 0.068
#> GSM39837 2 0.7476 0.0727 0.408 0.416 0.000 0.176
#> GSM39838 1 0.6350 0.1213 0.636 0.112 0.000 0.252
#> GSM39839 3 0.4901 0.7399 0.108 0.000 0.780 0.112
#> GSM39840 1 0.4679 0.5061 0.648 0.000 0.000 0.352
#> GSM39841 1 0.5016 0.4695 0.600 0.000 0.004 0.396
#> GSM39842 4 0.5167 -0.5047 0.488 0.000 0.004 0.508
#> GSM39843 1 0.4372 0.5406 0.728 0.000 0.004 0.268
#> GSM39844 1 0.5161 0.3603 0.520 0.000 0.004 0.476
#> GSM39845 3 0.0657 0.8179 0.004 0.000 0.984 0.012
#> GSM39852 1 0.2197 0.5254 0.916 0.004 0.000 0.080
#> GSM39853 2 0.7792 0.1143 0.332 0.412 0.000 0.256
#> GSM39854 1 0.5112 0.2909 0.560 0.004 0.000 0.436
#> GSM39857 3 0.1867 0.7994 0.000 0.000 0.928 0.072
#> GSM39860 4 0.8542 -0.3413 0.032 0.336 0.236 0.396
#> GSM39861 3 0.0927 0.8166 0.016 0.000 0.976 0.008
#> GSM39864 1 0.4053 0.5502 0.768 0.000 0.004 0.228
#> GSM39868 1 0.6760 0.1606 0.628 0.004 0.180 0.188
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.81958 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.81958 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.81958 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.81958 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.2068 0.63726 0.904 0.000 0.000 0.092 0.004
#> GSM39819 3 0.4874 0.69587 0.148 0.000 0.756 0.056 0.040
#> GSM39820 3 0.4590 0.70958 0.124 0.000 0.780 0.064 0.032
#> GSM39821 4 0.3816 0.50939 0.304 0.000 0.000 0.696 0.000
#> GSM39822 2 0.6632 -0.06941 0.000 0.428 0.000 0.228 0.344
#> GSM39823 3 0.2583 0.70368 0.000 0.000 0.864 0.004 0.132
#> GSM39824 3 0.4060 0.43246 0.000 0.000 0.640 0.000 0.360
#> GSM39825 3 0.4671 0.62393 0.040 0.000 0.740 0.200 0.020
#> GSM39826 4 0.4181 0.52040 0.268 0.000 0.000 0.712 0.020
#> GSM39827 4 0.4639 0.40950 0.368 0.000 0.000 0.612 0.020
#> GSM39846 3 0.0963 0.75404 0.000 0.000 0.964 0.000 0.036
#> GSM39847 4 0.3928 0.50747 0.296 0.000 0.000 0.700 0.004
#> GSM39848 5 0.4159 0.38439 0.000 0.156 0.000 0.068 0.776
#> GSM39849 3 0.5985 0.09511 0.000 0.000 0.480 0.112 0.408
#> GSM39850 4 0.4130 0.51573 0.292 0.000 0.000 0.696 0.012
#> GSM39851 1 0.4130 0.44918 0.696 0.000 0.000 0.292 0.012
#> GSM39855 3 0.4415 0.27817 0.000 0.004 0.552 0.000 0.444
#> GSM39856 3 0.1043 0.75275 0.000 0.000 0.960 0.000 0.040
#> GSM39858 3 0.0609 0.75934 0.000 0.000 0.980 0.000 0.020
#> GSM39859 3 0.0000 0.76081 0.000 0.000 1.000 0.000 0.000
#> GSM39862 5 0.4405 0.39038 0.004 0.000 0.020 0.280 0.696
#> GSM39863 1 0.2068 0.63726 0.904 0.000 0.000 0.092 0.004
#> GSM39865 5 0.6304 -0.04875 0.000 0.384 0.000 0.156 0.460
#> GSM39866 1 0.4807 0.36678 0.632 0.000 0.008 0.340 0.020
#> GSM39867 1 0.6080 0.05409 0.520 0.000 0.000 0.344 0.136
#> GSM39869 5 0.6264 -0.07631 0.000 0.400 0.000 0.148 0.452
#> GSM39870 3 0.4590 0.70958 0.124 0.000 0.780 0.064 0.032
#> GSM39871 3 0.0324 0.76083 0.000 0.000 0.992 0.004 0.004
#> GSM39872 5 0.6368 -0.05939 0.000 0.000 0.400 0.164 0.436
#> GSM39828 4 0.5131 0.28053 0.364 0.000 0.000 0.588 0.048
#> GSM39829 3 0.4943 0.69477 0.140 0.000 0.752 0.076 0.032
#> GSM39830 3 0.7502 0.19957 0.292 0.000 0.428 0.232 0.048
#> GSM39832 1 0.1357 0.60578 0.948 0.000 0.000 0.004 0.048
#> GSM39833 4 0.5977 0.35418 0.104 0.000 0.032 0.644 0.220
#> GSM39834 4 0.6221 0.21597 0.088 0.000 0.032 0.580 0.300
#> GSM39835 5 0.6748 0.09886 0.308 0.000 0.000 0.284 0.408
#> GSM39836 4 0.3715 0.52414 0.260 0.000 0.000 0.736 0.004
#> GSM39837 4 0.7708 0.17245 0.136 0.296 0.000 0.452 0.116
#> GSM39838 4 0.5840 0.39511 0.112 0.016 0.000 0.636 0.236
#> GSM39839 3 0.4874 0.69587 0.148 0.000 0.756 0.056 0.040
#> GSM39840 1 0.3395 0.53517 0.764 0.000 0.000 0.236 0.000
#> GSM39841 1 0.1792 0.63651 0.916 0.000 0.000 0.084 0.000
#> GSM39842 1 0.3146 0.53122 0.856 0.000 0.000 0.092 0.052
#> GSM39843 1 0.4213 0.43901 0.680 0.000 0.000 0.308 0.012
#> GSM39844 1 0.1357 0.60578 0.948 0.000 0.000 0.004 0.048
#> GSM39845 3 0.0798 0.76111 0.000 0.000 0.976 0.008 0.016
#> GSM39852 4 0.4302 0.51347 0.248 0.000 0.000 0.720 0.032
#> GSM39853 4 0.8331 0.00811 0.188 0.292 0.000 0.352 0.168
#> GSM39854 1 0.6171 -0.01474 0.488 0.000 0.000 0.372 0.140
#> GSM39857 3 0.2848 0.68464 0.000 0.000 0.840 0.004 0.156
#> GSM39860 5 0.4166 0.39381 0.000 0.120 0.076 0.008 0.796
#> GSM39861 3 0.1173 0.75820 0.004 0.000 0.964 0.020 0.012
#> GSM39864 1 0.4520 0.44566 0.680 0.000 0.008 0.296 0.016
#> GSM39868 4 0.7949 0.23709 0.184 0.000 0.132 0.448 0.236
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 4 0.4002 0.3391 0.240 0.000 0.008 0.728 0.008 0.016
#> GSM39819 3 0.5599 0.6281 0.024 0.000 0.684 0.152 0.052 0.088
#> GSM39820 3 0.5339 0.6431 0.024 0.000 0.708 0.136 0.044 0.088
#> GSM39821 4 0.6093 0.1501 0.380 0.000 0.000 0.476 0.096 0.048
#> GSM39822 5 0.5875 0.1858 0.248 0.216 0.000 0.000 0.528 0.008
#> GSM39823 3 0.3892 0.6332 0.012 0.000 0.788 0.000 0.080 0.120
#> GSM39824 3 0.5616 0.3650 0.012 0.000 0.580 0.000 0.252 0.156
#> GSM39825 3 0.4986 0.5804 0.016 0.000 0.708 0.172 0.016 0.088
#> GSM39826 4 0.6268 0.1217 0.388 0.000 0.000 0.452 0.104 0.056
#> GSM39827 1 0.6054 -0.2220 0.436 0.000 0.000 0.424 0.100 0.040
#> GSM39846 3 0.1821 0.7211 0.008 0.000 0.928 0.000 0.024 0.040
#> GSM39847 4 0.6007 0.1748 0.364 0.000 0.000 0.500 0.084 0.052
#> GSM39848 5 0.5115 0.2372 0.020 0.048 0.000 0.000 0.560 0.372
#> GSM39849 6 0.4224 0.3910 0.016 0.000 0.312 0.000 0.012 0.660
#> GSM39850 4 0.6200 0.1356 0.388 0.000 0.000 0.460 0.096 0.056
#> GSM39851 4 0.0777 0.4021 0.024 0.000 0.000 0.972 0.000 0.004
#> GSM39855 3 0.6088 0.1548 0.012 0.000 0.440 0.000 0.368 0.180
#> GSM39856 3 0.2022 0.7159 0.008 0.000 0.916 0.000 0.024 0.052
#> GSM39858 3 0.0862 0.7370 0.004 0.000 0.972 0.000 0.016 0.008
#> GSM39859 3 0.0146 0.7389 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM39862 6 0.3934 0.2585 0.008 0.000 0.000 0.020 0.256 0.716
#> GSM39863 4 0.4002 0.3391 0.240 0.000 0.008 0.728 0.008 0.016
#> GSM39865 5 0.5081 0.5016 0.068 0.184 0.000 0.000 0.692 0.056
#> GSM39866 4 0.5894 0.3428 0.284 0.000 0.008 0.572 0.028 0.108
#> GSM39867 1 0.4705 0.3490 0.696 0.000 0.000 0.076 0.212 0.016
#> GSM39869 5 0.4992 0.4961 0.068 0.196 0.000 0.000 0.692 0.044
#> GSM39870 3 0.5430 0.6387 0.024 0.000 0.700 0.136 0.044 0.096
#> GSM39871 3 0.0653 0.7382 0.004 0.000 0.980 0.000 0.004 0.012
#> GSM39872 6 0.3152 0.4433 0.008 0.000 0.196 0.000 0.004 0.792
#> GSM39828 4 0.5759 0.2397 0.140 0.000 0.000 0.588 0.028 0.244
#> GSM39829 3 0.6030 0.5895 0.028 0.000 0.644 0.160 0.052 0.116
#> GSM39830 4 0.7000 -0.1252 0.024 0.000 0.340 0.440 0.056 0.140
#> GSM39832 4 0.4653 0.0668 0.480 0.000 0.000 0.488 0.012 0.020
#> GSM39833 6 0.7871 0.1767 0.160 0.000 0.036 0.264 0.144 0.396
#> GSM39834 6 0.5194 0.4630 0.148 0.000 0.020 0.084 0.036 0.712
#> GSM39835 6 0.6146 0.1570 0.376 0.000 0.000 0.028 0.140 0.456
#> GSM39836 4 0.6334 0.1360 0.388 0.000 0.000 0.448 0.096 0.068
#> GSM39837 1 0.7867 0.0733 0.336 0.168 0.000 0.132 0.332 0.032
#> GSM39838 5 0.6683 -0.1655 0.364 0.008 0.000 0.076 0.448 0.104
#> GSM39839 3 0.5599 0.6281 0.024 0.000 0.684 0.152 0.052 0.088
#> GSM39840 4 0.2269 0.3921 0.080 0.000 0.000 0.896 0.012 0.012
#> GSM39841 4 0.3981 0.3141 0.268 0.000 0.008 0.708 0.008 0.008
#> GSM39842 1 0.5487 -0.1816 0.488 0.000 0.000 0.416 0.016 0.080
#> GSM39843 4 0.0622 0.4039 0.012 0.000 0.000 0.980 0.000 0.008
#> GSM39844 4 0.4653 0.0668 0.480 0.000 0.000 0.488 0.012 0.020
#> GSM39845 3 0.1086 0.7400 0.012 0.000 0.964 0.000 0.012 0.012
#> GSM39852 4 0.7045 0.1306 0.340 0.000 0.000 0.396 0.104 0.160
#> GSM39853 1 0.6741 0.0656 0.420 0.168 0.000 0.044 0.360 0.008
#> GSM39854 1 0.4569 0.3509 0.700 0.000 0.000 0.052 0.228 0.020
#> GSM39857 3 0.4105 0.6047 0.008 0.000 0.760 0.000 0.080 0.152
#> GSM39860 5 0.5350 0.1132 0.004 0.044 0.028 0.000 0.544 0.380
#> GSM39861 3 0.1262 0.7336 0.008 0.000 0.956 0.000 0.016 0.020
#> GSM39864 4 0.5556 0.3590 0.228 0.000 0.008 0.632 0.024 0.108
#> GSM39868 6 0.6000 0.4502 0.144 0.000 0.048 0.100 0.048 0.660
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> CV:kmeans 54 5.32e-04 2.65e-04 2
#> CV:kmeans 53 5.19e-06 6.73e-06 3
#> CV:kmeans 39 3.76e-05 1.42e-04 4
#> CV:kmeans 32 5.23e-07 6.08e-06 5
#> CV:kmeans 20 4.54e-05 3.79e-04 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.321 0.564 0.814 0.4993 0.501 0.501
#> 3 3 0.896 0.896 0.954 0.3469 0.658 0.416
#> 4 4 0.607 0.677 0.823 0.1184 0.915 0.744
#> 5 5 0.623 0.546 0.744 0.0670 0.935 0.756
#> 6 6 0.644 0.425 0.671 0.0385 0.978 0.901
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.8661 0.596 0.288 0.712
#> GSM39874 2 0.8661 0.596 0.288 0.712
#> GSM39875 2 0.8661 0.596 0.288 0.712
#> GSM39876 2 0.8661 0.596 0.288 0.712
#> GSM39831 1 0.0000 0.746 1.000 0.000
#> GSM39819 1 0.9323 0.466 0.652 0.348
#> GSM39820 1 0.9323 0.466 0.652 0.348
#> GSM39821 1 0.0376 0.744 0.996 0.004
#> GSM39822 2 0.8813 0.583 0.300 0.700
#> GSM39823 2 0.4161 0.653 0.084 0.916
#> GSM39824 2 0.0000 0.668 0.000 1.000
#> GSM39825 1 0.9922 0.262 0.552 0.448
#> GSM39826 1 0.8608 0.404 0.716 0.284
#> GSM39827 1 0.1184 0.738 0.984 0.016
#> GSM39846 2 0.4161 0.652 0.084 0.916
#> GSM39847 1 0.0000 0.746 1.000 0.000
#> GSM39848 2 0.8713 0.592 0.292 0.708
#> GSM39849 2 0.0938 0.668 0.012 0.988
#> GSM39850 1 0.4161 0.686 0.916 0.084
#> GSM39851 1 0.0000 0.746 1.000 0.000
#> GSM39855 2 0.0000 0.668 0.000 1.000
#> GSM39856 2 0.4161 0.652 0.084 0.916
#> GSM39858 2 0.9323 0.303 0.348 0.652
#> GSM39859 2 0.9323 0.303 0.348 0.652
#> GSM39862 2 0.6048 0.645 0.148 0.852
#> GSM39863 1 0.0000 0.746 1.000 0.000
#> GSM39865 2 0.8661 0.596 0.288 0.712
#> GSM39866 1 0.1184 0.742 0.984 0.016
#> GSM39867 1 0.5408 0.647 0.876 0.124
#> GSM39869 2 0.9000 0.562 0.316 0.684
#> GSM39870 1 0.9323 0.466 0.652 0.348
#> GSM39871 2 0.7219 0.539 0.200 0.800
#> GSM39872 2 0.3274 0.660 0.060 0.940
#> GSM39828 1 0.2423 0.732 0.960 0.040
#> GSM39829 1 0.9044 0.498 0.680 0.320
#> GSM39830 1 0.8713 0.525 0.708 0.292
#> GSM39832 1 0.0000 0.746 1.000 0.000
#> GSM39833 2 0.9044 0.556 0.320 0.680
#> GSM39834 1 0.9922 0.321 0.552 0.448
#> GSM39835 2 0.9998 0.184 0.492 0.508
#> GSM39836 1 0.4022 0.689 0.920 0.080
#> GSM39837 1 0.9323 0.270 0.652 0.348
#> GSM39838 1 0.9970 -0.107 0.532 0.468
#> GSM39839 1 0.9323 0.466 0.652 0.348
#> GSM39840 1 0.0000 0.746 1.000 0.000
#> GSM39841 1 0.0000 0.746 1.000 0.000
#> GSM39842 1 0.0000 0.746 1.000 0.000
#> GSM39843 1 0.3431 0.718 0.936 0.064
#> GSM39844 1 0.0000 0.746 1.000 0.000
#> GSM39845 2 0.9323 0.303 0.348 0.652
#> GSM39852 1 0.0938 0.740 0.988 0.012
#> GSM39853 1 0.9460 0.230 0.636 0.364
#> GSM39854 1 0.9286 0.279 0.656 0.344
#> GSM39857 2 0.4298 0.650 0.088 0.912
#> GSM39860 2 0.0000 0.668 0.000 1.000
#> GSM39861 2 0.9358 0.293 0.352 0.648
#> GSM39864 1 0.2043 0.736 0.968 0.032
#> GSM39868 1 0.8861 0.518 0.696 0.304
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39831 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39819 3 0.1031 0.960 0.024 0.000 0.976
#> GSM39820 3 0.1031 0.960 0.024 0.000 0.976
#> GSM39821 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39822 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39823 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39824 3 0.0747 0.960 0.000 0.016 0.984
#> GSM39825 3 0.0892 0.959 0.020 0.000 0.980
#> GSM39826 1 0.3267 0.824 0.884 0.116 0.000
#> GSM39827 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39846 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39847 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39848 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39849 3 0.0747 0.960 0.000 0.016 0.984
#> GSM39850 1 0.0237 0.926 0.996 0.004 0.000
#> GSM39851 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39855 3 0.2711 0.891 0.000 0.088 0.912
#> GSM39856 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39862 2 0.4519 0.846 0.116 0.852 0.032
#> GSM39863 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39865 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39866 1 0.0424 0.924 0.992 0.008 0.000
#> GSM39867 1 0.5678 0.519 0.684 0.316 0.000
#> GSM39869 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39870 3 0.1163 0.957 0.028 0.000 0.972
#> GSM39871 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39872 3 0.0237 0.966 0.000 0.004 0.996
#> GSM39828 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39829 3 0.1031 0.960 0.024 0.000 0.976
#> GSM39830 3 0.5650 0.545 0.312 0.000 0.688
#> GSM39832 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39833 2 0.2031 0.932 0.016 0.952 0.032
#> GSM39834 1 0.8157 0.289 0.540 0.076 0.384
#> GSM39835 2 0.2878 0.882 0.096 0.904 0.000
#> GSM39836 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39837 2 0.0237 0.953 0.004 0.996 0.000
#> GSM39838 2 0.0000 0.954 0.000 1.000 0.000
#> GSM39839 3 0.1031 0.960 0.024 0.000 0.976
#> GSM39840 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39841 1 0.1964 0.885 0.944 0.056 0.000
#> GSM39842 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39843 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39844 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39845 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39852 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39853 2 0.0424 0.951 0.008 0.992 0.000
#> GSM39854 2 0.5327 0.625 0.272 0.728 0.000
#> GSM39857 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39860 2 0.2796 0.882 0.000 0.908 0.092
#> GSM39861 3 0.0000 0.967 0.000 0.000 1.000
#> GSM39864 1 0.0000 0.929 1.000 0.000 0.000
#> GSM39868 1 0.6235 0.235 0.564 0.000 0.436
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.841 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.841 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.841 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.841 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0707 0.766 0.980 0.000 0.000 0.020
#> GSM39819 3 0.4059 0.740 0.200 0.000 0.788 0.012
#> GSM39820 3 0.4136 0.741 0.196 0.000 0.788 0.016
#> GSM39821 4 0.4382 0.640 0.296 0.000 0.000 0.704
#> GSM39822 2 0.0188 0.840 0.000 0.996 0.000 0.004
#> GSM39823 3 0.1867 0.806 0.000 0.000 0.928 0.072
#> GSM39824 3 0.4487 0.744 0.000 0.092 0.808 0.100
#> GSM39825 3 0.4679 0.675 0.044 0.000 0.772 0.184
#> GSM39826 4 0.4692 0.648 0.212 0.032 0.000 0.756
#> GSM39827 1 0.4356 0.478 0.708 0.000 0.000 0.292
#> GSM39846 3 0.0336 0.821 0.000 0.000 0.992 0.008
#> GSM39847 4 0.4222 0.661 0.272 0.000 0.000 0.728
#> GSM39848 2 0.2921 0.776 0.000 0.860 0.000 0.140
#> GSM39849 3 0.4761 0.712 0.000 0.044 0.764 0.192
#> GSM39850 4 0.4283 0.670 0.256 0.004 0.000 0.740
#> GSM39851 1 0.4250 0.508 0.724 0.000 0.000 0.276
#> GSM39855 3 0.5351 0.685 0.000 0.152 0.744 0.104
#> GSM39856 3 0.0707 0.820 0.000 0.000 0.980 0.020
#> GSM39858 3 0.0336 0.822 0.000 0.000 0.992 0.008
#> GSM39859 3 0.0000 0.822 0.000 0.000 1.000 0.000
#> GSM39862 4 0.5470 0.416 0.000 0.168 0.100 0.732
#> GSM39863 1 0.0817 0.765 0.976 0.000 0.000 0.024
#> GSM39865 2 0.0336 0.839 0.000 0.992 0.000 0.008
#> GSM39866 1 0.4268 0.622 0.760 0.004 0.004 0.232
#> GSM39867 1 0.6634 0.294 0.592 0.292 0.000 0.116
#> GSM39869 2 0.0000 0.841 0.000 1.000 0.000 0.000
#> GSM39870 3 0.4406 0.738 0.192 0.000 0.780 0.028
#> GSM39871 3 0.0188 0.822 0.000 0.000 0.996 0.004
#> GSM39872 3 0.5290 0.580 0.012 0.008 0.656 0.324
#> GSM39828 4 0.4585 0.548 0.332 0.000 0.000 0.668
#> GSM39829 3 0.4542 0.711 0.228 0.000 0.752 0.020
#> GSM39830 3 0.7403 0.170 0.380 0.000 0.452 0.168
#> GSM39832 1 0.0188 0.765 0.996 0.000 0.000 0.004
#> GSM39833 2 0.7268 0.532 0.060 0.612 0.072 0.256
#> GSM39834 4 0.6781 0.447 0.136 0.060 0.112 0.692
#> GSM39835 2 0.7352 0.368 0.328 0.496 0.000 0.176
#> GSM39836 4 0.3975 0.680 0.240 0.000 0.000 0.760
#> GSM39837 2 0.1890 0.819 0.008 0.936 0.000 0.056
#> GSM39838 2 0.4283 0.636 0.004 0.740 0.000 0.256
#> GSM39839 3 0.4059 0.740 0.200 0.000 0.788 0.012
#> GSM39840 1 0.3528 0.651 0.808 0.000 0.000 0.192
#> GSM39841 1 0.0376 0.765 0.992 0.004 0.000 0.004
#> GSM39842 1 0.1022 0.751 0.968 0.000 0.000 0.032
#> GSM39843 1 0.5093 0.351 0.640 0.000 0.012 0.348
#> GSM39844 1 0.0188 0.765 0.996 0.000 0.000 0.004
#> GSM39845 3 0.0336 0.822 0.000 0.000 0.992 0.008
#> GSM39852 4 0.3837 0.680 0.224 0.000 0.000 0.776
#> GSM39853 2 0.2224 0.817 0.040 0.928 0.000 0.032
#> GSM39854 2 0.6778 0.386 0.336 0.552 0.000 0.112
#> GSM39857 3 0.2704 0.786 0.000 0.000 0.876 0.124
#> GSM39860 2 0.6170 0.587 0.000 0.672 0.136 0.192
#> GSM39861 3 0.0000 0.822 0.000 0.000 1.000 0.000
#> GSM39864 1 0.3172 0.696 0.840 0.000 0.000 0.160
#> GSM39868 4 0.7067 0.337 0.188 0.000 0.244 0.568
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0162 0.80398 0.000 0.996 0.000 0.004 0.000
#> GSM39874 2 0.0162 0.80398 0.000 0.996 0.000 0.004 0.000
#> GSM39875 2 0.0162 0.80398 0.000 0.996 0.000 0.004 0.000
#> GSM39876 2 0.0162 0.80398 0.000 0.996 0.000 0.004 0.000
#> GSM39831 1 0.1012 0.69777 0.968 0.000 0.000 0.020 0.012
#> GSM39819 3 0.5053 0.56849 0.164 0.000 0.728 0.016 0.092
#> GSM39820 3 0.4700 0.58935 0.120 0.000 0.764 0.016 0.100
#> GSM39821 4 0.1732 0.85568 0.080 0.000 0.000 0.920 0.000
#> GSM39822 2 0.0324 0.80300 0.000 0.992 0.000 0.004 0.004
#> GSM39823 3 0.4101 0.41065 0.000 0.000 0.664 0.004 0.332
#> GSM39824 3 0.5056 0.24850 0.000 0.044 0.596 0.000 0.360
#> GSM39825 3 0.6993 0.29740 0.096 0.000 0.584 0.156 0.164
#> GSM39826 4 0.2597 0.85184 0.040 0.020 0.000 0.904 0.036
#> GSM39827 1 0.5447 0.26379 0.532 0.008 0.000 0.416 0.044
#> GSM39846 3 0.2648 0.60094 0.000 0.000 0.848 0.000 0.152
#> GSM39847 4 0.2166 0.86079 0.072 0.000 0.004 0.912 0.012
#> GSM39848 2 0.4505 0.34614 0.000 0.604 0.000 0.012 0.384
#> GSM39849 5 0.5469 0.31497 0.008 0.024 0.348 0.020 0.600
#> GSM39850 4 0.2037 0.86387 0.064 0.004 0.000 0.920 0.012
#> GSM39851 1 0.5051 0.02746 0.492 0.000 0.004 0.480 0.024
#> GSM39855 3 0.5584 0.11193 0.000 0.076 0.532 0.000 0.392
#> GSM39856 3 0.2929 0.57504 0.000 0.000 0.820 0.000 0.180
#> GSM39858 3 0.0880 0.64542 0.000 0.000 0.968 0.000 0.032
#> GSM39859 3 0.1768 0.64182 0.000 0.000 0.924 0.004 0.072
#> GSM39862 5 0.5505 0.56480 0.000 0.056 0.072 0.160 0.712
#> GSM39863 1 0.1106 0.69714 0.964 0.000 0.000 0.024 0.012
#> GSM39865 2 0.1628 0.78332 0.000 0.936 0.000 0.008 0.056
#> GSM39866 1 0.6375 0.50284 0.624 0.008 0.032 0.220 0.116
#> GSM39867 1 0.6512 0.49802 0.636 0.152 0.000 0.120 0.092
#> GSM39869 2 0.1525 0.79192 0.004 0.948 0.000 0.012 0.036
#> GSM39870 3 0.5025 0.58442 0.124 0.000 0.744 0.024 0.108
#> GSM39871 3 0.2127 0.62946 0.000 0.000 0.892 0.000 0.108
#> GSM39872 5 0.4404 0.48820 0.000 0.000 0.264 0.032 0.704
#> GSM39828 4 0.5758 0.60748 0.200 0.000 0.008 0.644 0.148
#> GSM39829 3 0.5447 0.55176 0.156 0.000 0.700 0.020 0.124
#> GSM39830 3 0.8074 0.03417 0.328 0.000 0.372 0.172 0.128
#> GSM39832 1 0.1493 0.69815 0.948 0.000 0.000 0.024 0.028
#> GSM39833 2 0.8215 0.20308 0.060 0.472 0.048 0.188 0.232
#> GSM39834 5 0.6596 0.43599 0.100 0.012 0.060 0.196 0.632
#> GSM39835 1 0.7845 0.05374 0.360 0.232 0.000 0.072 0.336
#> GSM39836 4 0.1830 0.85979 0.028 0.000 0.000 0.932 0.040
#> GSM39837 2 0.2275 0.77592 0.012 0.912 0.000 0.064 0.012
#> GSM39838 2 0.5815 0.51417 0.008 0.624 0.000 0.244 0.124
#> GSM39839 3 0.5053 0.56827 0.164 0.000 0.728 0.016 0.092
#> GSM39840 1 0.3940 0.58891 0.756 0.000 0.000 0.220 0.024
#> GSM39841 1 0.1673 0.69516 0.944 0.008 0.000 0.032 0.016
#> GSM39842 1 0.2012 0.69460 0.920 0.000 0.000 0.020 0.060
#> GSM39843 1 0.5977 -0.02275 0.464 0.000 0.036 0.460 0.040
#> GSM39844 1 0.1579 0.69846 0.944 0.000 0.000 0.024 0.032
#> GSM39845 3 0.1282 0.64611 0.000 0.000 0.952 0.004 0.044
#> GSM39852 4 0.3370 0.76591 0.028 0.000 0.000 0.824 0.148
#> GSM39853 2 0.2188 0.78246 0.024 0.924 0.000 0.028 0.024
#> GSM39854 2 0.7460 -0.00477 0.380 0.408 0.000 0.136 0.076
#> GSM39857 3 0.4150 0.28891 0.000 0.000 0.612 0.000 0.388
#> GSM39860 5 0.5781 0.39249 0.000 0.308 0.116 0.000 0.576
#> GSM39861 3 0.1569 0.64562 0.008 0.000 0.944 0.004 0.044
#> GSM39864 1 0.5104 0.59086 0.720 0.000 0.012 0.164 0.104
#> GSM39868 5 0.7446 0.27370 0.104 0.000 0.120 0.288 0.488
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.0146 0.7293 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39874 5 0.0146 0.7293 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39875 5 0.0146 0.7293 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39876 5 0.0146 0.7293 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39831 1 0.1863 0.6114 0.920 0.060 0.000 0.016 0.000 0.004
#> GSM39819 3 0.5117 0.0643 0.076 0.376 0.544 0.000 0.000 0.004
#> GSM39820 3 0.4776 0.1862 0.052 0.356 0.588 0.000 0.000 0.004
#> GSM39821 4 0.1464 0.8247 0.036 0.016 0.000 0.944 0.000 0.004
#> GSM39822 5 0.1871 0.7252 0.000 0.032 0.000 0.024 0.928 0.016
#> GSM39823 3 0.4895 0.3780 0.000 0.104 0.632 0.000 0.000 0.264
#> GSM39824 3 0.5568 0.1777 0.000 0.044 0.544 0.000 0.056 0.356
#> GSM39825 3 0.7839 -0.0860 0.068 0.200 0.460 0.136 0.000 0.136
#> GSM39826 4 0.2265 0.8103 0.028 0.032 0.000 0.912 0.004 0.024
#> GSM39827 1 0.6248 0.1304 0.432 0.116 0.000 0.412 0.004 0.036
#> GSM39846 3 0.2956 0.5340 0.000 0.040 0.840 0.000 0.000 0.120
#> GSM39847 4 0.2512 0.8125 0.040 0.048 0.008 0.896 0.000 0.008
#> GSM39848 5 0.5174 0.1865 0.000 0.036 0.000 0.028 0.508 0.428
#> GSM39849 6 0.6490 0.1375 0.004 0.140 0.352 0.012 0.024 0.468
#> GSM39850 4 0.1458 0.8203 0.020 0.016 0.000 0.948 0.000 0.016
#> GSM39851 1 0.5458 0.2406 0.496 0.096 0.000 0.400 0.000 0.008
#> GSM39855 3 0.6058 -0.0283 0.000 0.032 0.452 0.000 0.116 0.400
#> GSM39856 3 0.2790 0.5261 0.000 0.024 0.844 0.000 0.000 0.132
#> GSM39858 3 0.1757 0.5196 0.000 0.076 0.916 0.000 0.000 0.008
#> GSM39859 3 0.2384 0.5390 0.000 0.064 0.888 0.000 0.000 0.048
#> GSM39862 6 0.5159 0.4669 0.004 0.060 0.036 0.112 0.048 0.740
#> GSM39863 1 0.1845 0.6064 0.916 0.072 0.000 0.008 0.000 0.004
#> GSM39865 5 0.3096 0.6847 0.000 0.048 0.004 0.000 0.840 0.108
#> GSM39866 1 0.7628 0.2309 0.460 0.228 0.040 0.200 0.012 0.060
#> GSM39867 1 0.6995 0.3583 0.568 0.168 0.000 0.080 0.120 0.064
#> GSM39869 5 0.3148 0.6902 0.000 0.064 0.000 0.004 0.840 0.092
#> GSM39870 3 0.5194 0.1993 0.056 0.340 0.584 0.016 0.000 0.004
#> GSM39871 3 0.2328 0.5372 0.000 0.056 0.892 0.000 0.000 0.052
#> GSM39872 6 0.5144 0.4204 0.000 0.108 0.188 0.016 0.008 0.680
#> GSM39828 4 0.6973 0.3771 0.208 0.156 0.000 0.488 0.000 0.148
#> GSM39829 3 0.5801 -0.0032 0.064 0.388 0.504 0.004 0.000 0.040
#> GSM39830 2 0.7954 0.0000 0.236 0.372 0.248 0.096 0.000 0.048
#> GSM39832 1 0.1483 0.6174 0.944 0.036 0.000 0.008 0.000 0.012
#> GSM39833 5 0.8722 -0.0930 0.048 0.176 0.036 0.136 0.332 0.272
#> GSM39834 6 0.7535 0.3199 0.068 0.252 0.052 0.140 0.008 0.480
#> GSM39835 6 0.8286 0.0580 0.288 0.152 0.000 0.060 0.176 0.324
#> GSM39836 4 0.1693 0.8212 0.012 0.020 0.000 0.936 0.000 0.032
#> GSM39837 5 0.4042 0.6661 0.012 0.056 0.000 0.116 0.796 0.020
#> GSM39838 5 0.7280 0.4064 0.020 0.140 0.000 0.192 0.496 0.152
#> GSM39839 3 0.5055 0.0824 0.072 0.368 0.556 0.000 0.000 0.004
#> GSM39840 1 0.4224 0.5264 0.736 0.040 0.000 0.204 0.000 0.020
#> GSM39841 1 0.3236 0.5863 0.848 0.092 0.000 0.040 0.012 0.008
#> GSM39842 1 0.1887 0.6152 0.924 0.048 0.000 0.012 0.000 0.016
#> GSM39843 1 0.6203 0.1604 0.460 0.112 0.004 0.388 0.000 0.036
#> GSM39844 1 0.1307 0.6179 0.952 0.032 0.000 0.008 0.000 0.008
#> GSM39845 3 0.2750 0.4979 0.000 0.136 0.844 0.000 0.000 0.020
#> GSM39852 4 0.4742 0.6627 0.028 0.140 0.000 0.724 0.000 0.108
#> GSM39853 5 0.4567 0.6656 0.032 0.084 0.000 0.060 0.780 0.044
#> GSM39854 5 0.8201 0.1027 0.312 0.176 0.000 0.112 0.328 0.072
#> GSM39857 3 0.4750 0.2951 0.000 0.064 0.596 0.000 0.000 0.340
#> GSM39860 6 0.5603 0.3405 0.000 0.016 0.120 0.008 0.244 0.612
#> GSM39861 3 0.3275 0.5029 0.000 0.144 0.816 0.004 0.000 0.036
#> GSM39864 1 0.5586 0.4425 0.640 0.228 0.008 0.080 0.000 0.044
#> GSM39868 6 0.8340 0.1835 0.064 0.292 0.116 0.200 0.004 0.324
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> CV:skmeans 41 0.10293 0.0090 2
#> CV:skmeans 56 0.00459 0.0158 3
#> CV:skmeans 49 0.00718 0.0135 4
#> CV:skmeans 39 0.01164 0.0526 5
#> CV:skmeans 28 0.01987 0.0235 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.963 0.936 0.966 0.2521 0.733 0.733
#> 3 3 0.365 0.575 0.820 1.2900 0.616 0.494
#> 4 4 0.643 0.784 0.881 0.2301 0.731 0.439
#> 5 5 0.677 0.723 0.778 0.0932 0.890 0.645
#> 6 6 0.762 0.755 0.859 0.0468 0.935 0.725
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.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.1414 0.860 0.020 0.980
#> GSM39874 2 0.1414 0.860 0.020 0.980
#> GSM39875 2 0.1414 0.860 0.020 0.980
#> GSM39876 2 0.1414 0.860 0.020 0.980
#> GSM39831 1 0.0000 0.982 1.000 0.000
#> GSM39819 1 0.1633 0.978 0.976 0.024
#> GSM39820 1 0.1633 0.978 0.976 0.024
#> GSM39821 1 0.0000 0.982 1.000 0.000
#> GSM39822 2 0.3584 0.847 0.068 0.932
#> GSM39823 1 0.1633 0.978 0.976 0.024
#> GSM39824 1 0.1633 0.978 0.976 0.024
#> GSM39825 1 0.0000 0.982 1.000 0.000
#> GSM39826 1 0.0000 0.982 1.000 0.000
#> GSM39827 1 0.0000 0.982 1.000 0.000
#> GSM39846 1 0.1633 0.978 0.976 0.024
#> GSM39847 1 0.0000 0.982 1.000 0.000
#> GSM39848 1 0.7219 0.696 0.800 0.200
#> GSM39849 1 0.1633 0.978 0.976 0.024
#> GSM39850 1 0.0000 0.982 1.000 0.000
#> GSM39851 1 0.0000 0.982 1.000 0.000
#> GSM39855 1 0.1633 0.978 0.976 0.024
#> GSM39856 1 0.1633 0.978 0.976 0.024
#> GSM39858 1 0.1633 0.978 0.976 0.024
#> GSM39859 1 0.1633 0.978 0.976 0.024
#> GSM39862 1 0.0000 0.982 1.000 0.000
#> GSM39863 1 0.0000 0.982 1.000 0.000
#> GSM39865 1 0.3584 0.911 0.932 0.068
#> GSM39866 1 0.0376 0.982 0.996 0.004
#> GSM39867 1 0.0000 0.982 1.000 0.000
#> GSM39869 2 0.1633 0.859 0.024 0.976
#> GSM39870 1 0.1633 0.978 0.976 0.024
#> GSM39871 1 0.1633 0.978 0.976 0.024
#> GSM39872 1 0.1414 0.979 0.980 0.020
#> GSM39828 1 0.0000 0.982 1.000 0.000
#> GSM39829 1 0.1414 0.979 0.980 0.020
#> GSM39830 1 0.1184 0.980 0.984 0.016
#> GSM39832 1 0.0000 0.982 1.000 0.000
#> GSM39833 1 0.0000 0.982 1.000 0.000
#> GSM39834 1 0.0672 0.982 0.992 0.008
#> GSM39835 1 0.0000 0.982 1.000 0.000
#> GSM39836 1 0.0000 0.982 1.000 0.000
#> GSM39837 2 1.0000 0.189 0.496 0.504
#> GSM39838 1 0.0000 0.982 1.000 0.000
#> GSM39839 1 0.1633 0.978 0.976 0.024
#> GSM39840 1 0.0000 0.982 1.000 0.000
#> GSM39841 1 0.0000 0.982 1.000 0.000
#> GSM39842 1 0.0000 0.982 1.000 0.000
#> GSM39843 1 0.0000 0.982 1.000 0.000
#> GSM39844 1 0.0376 0.982 0.996 0.004
#> GSM39845 1 0.1633 0.978 0.976 0.024
#> GSM39852 1 0.0000 0.982 1.000 0.000
#> GSM39853 2 0.8081 0.713 0.248 0.752
#> GSM39854 1 0.0376 0.980 0.996 0.004
#> GSM39857 1 0.1633 0.978 0.976 0.024
#> GSM39860 2 0.9129 0.565 0.328 0.672
#> GSM39861 1 0.1414 0.979 0.980 0.020
#> GSM39864 1 0.0000 0.982 1.000 0.000
#> GSM39868 1 0.1184 0.980 0.984 0.016
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.8748 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.8748 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.8748 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.8748 0.000 1.000 0.000
#> GSM39831 1 0.6045 0.2416 0.620 0.000 0.380
#> GSM39819 3 0.0237 0.7389 0.004 0.000 0.996
#> GSM39820 3 0.4399 0.5683 0.188 0.000 0.812
#> GSM39821 1 0.4931 0.6791 0.768 0.000 0.232
#> GSM39822 2 0.4346 0.6820 0.184 0.816 0.000
#> GSM39823 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39824 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39825 3 0.5291 0.5189 0.268 0.000 0.732
#> GSM39826 1 0.4605 0.6983 0.796 0.000 0.204
#> GSM39827 1 0.1860 0.7263 0.948 0.000 0.052
#> GSM39846 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39847 1 0.5098 0.6637 0.752 0.000 0.248
#> GSM39848 3 0.9843 -0.1642 0.372 0.248 0.380
#> GSM39849 3 0.2165 0.7232 0.064 0.000 0.936
#> GSM39850 1 0.4931 0.6791 0.768 0.000 0.232
#> GSM39851 1 0.1031 0.7197 0.976 0.000 0.024
#> GSM39855 3 0.0237 0.7404 0.004 0.000 0.996
#> GSM39856 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39862 3 0.6126 0.2451 0.400 0.000 0.600
#> GSM39863 1 0.2625 0.7071 0.916 0.000 0.084
#> GSM39865 3 0.8913 0.3489 0.220 0.208 0.572
#> GSM39866 1 0.5465 0.6284 0.712 0.000 0.288
#> GSM39867 1 0.0592 0.7126 0.988 0.000 0.012
#> GSM39869 2 0.0000 0.8748 0.000 1.000 0.000
#> GSM39870 3 0.5988 0.2444 0.368 0.000 0.632
#> GSM39871 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39872 3 0.1411 0.7319 0.036 0.000 0.964
#> GSM39828 3 0.6204 0.1750 0.424 0.000 0.576
#> GSM39829 3 0.3879 0.6385 0.152 0.000 0.848
#> GSM39830 3 0.5098 0.5332 0.248 0.000 0.752
#> GSM39832 1 0.0000 0.7074 1.000 0.000 0.000
#> GSM39833 3 0.6308 -0.0601 0.492 0.000 0.508
#> GSM39834 3 0.4842 0.5879 0.224 0.000 0.776
#> GSM39835 3 0.6305 0.0355 0.484 0.000 0.516
#> GSM39836 1 0.4931 0.6792 0.768 0.000 0.232
#> GSM39837 1 0.6451 0.5198 0.684 0.292 0.024
#> GSM39838 1 0.5098 0.6637 0.752 0.000 0.248
#> GSM39839 3 0.0237 0.7405 0.004 0.000 0.996
#> GSM39840 1 0.2356 0.7132 0.928 0.000 0.072
#> GSM39841 1 0.5327 0.6262 0.728 0.000 0.272
#> GSM39842 1 0.6140 0.1730 0.596 0.000 0.404
#> GSM39843 1 0.4504 0.7019 0.804 0.000 0.196
#> GSM39844 1 0.3816 0.6684 0.852 0.000 0.148
#> GSM39845 3 0.0000 0.7406 0.000 0.000 1.000
#> GSM39852 1 0.6286 0.1656 0.536 0.000 0.464
#> GSM39853 1 0.7001 0.2136 0.588 0.388 0.024
#> GSM39854 1 0.0237 0.7097 0.996 0.000 0.004
#> GSM39857 3 0.0424 0.7398 0.008 0.000 0.992
#> GSM39860 2 0.7262 0.1688 0.028 0.528 0.444
#> GSM39861 3 0.1643 0.7298 0.044 0.000 0.956
#> GSM39864 3 0.6154 0.2209 0.408 0.000 0.592
#> GSM39868 3 0.6140 0.1872 0.404 0.000 0.596
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.9287 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.9287 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.9287 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.9287 0.000 1.000 0.000 0.000
#> GSM39831 1 0.2662 0.8432 0.900 0.000 0.084 0.016
#> GSM39819 3 0.1661 0.8697 0.052 0.000 0.944 0.004
#> GSM39820 3 0.2867 0.8273 0.012 0.000 0.884 0.104
#> GSM39821 4 0.1211 0.8170 0.040 0.000 0.000 0.960
#> GSM39822 2 0.4546 0.6181 0.012 0.732 0.000 0.256
#> GSM39823 3 0.0804 0.8862 0.012 0.000 0.980 0.008
#> GSM39824 3 0.1004 0.8868 0.004 0.000 0.972 0.024
#> GSM39825 4 0.4978 0.4583 0.004 0.000 0.384 0.612
#> GSM39826 4 0.1716 0.8146 0.064 0.000 0.000 0.936
#> GSM39827 4 0.1474 0.8156 0.052 0.000 0.000 0.948
#> GSM39846 3 0.0336 0.8834 0.008 0.000 0.992 0.000
#> GSM39847 4 0.0592 0.8162 0.016 0.000 0.000 0.984
#> GSM39848 4 0.5996 0.5841 0.012 0.240 0.064 0.684
#> GSM39849 3 0.1610 0.8813 0.016 0.000 0.952 0.032
#> GSM39850 4 0.1716 0.8147 0.064 0.000 0.000 0.936
#> GSM39851 4 0.2737 0.7975 0.104 0.000 0.008 0.888
#> GSM39855 3 0.0779 0.8884 0.004 0.000 0.980 0.016
#> GSM39856 3 0.0657 0.8876 0.004 0.000 0.984 0.012
#> GSM39858 3 0.0188 0.8845 0.004 0.000 0.996 0.000
#> GSM39859 3 0.0779 0.8884 0.004 0.000 0.980 0.016
#> GSM39862 4 0.3583 0.7655 0.004 0.000 0.180 0.816
#> GSM39863 1 0.1118 0.9027 0.964 0.000 0.000 0.036
#> GSM39865 4 0.7327 0.5006 0.012 0.264 0.156 0.568
#> GSM39866 4 0.3143 0.7941 0.024 0.000 0.100 0.876
#> GSM39867 1 0.1389 0.9005 0.952 0.000 0.000 0.048
#> GSM39869 2 0.0804 0.9189 0.008 0.980 0.000 0.012
#> GSM39870 3 0.3479 0.7678 0.012 0.000 0.840 0.148
#> GSM39871 3 0.0657 0.8879 0.004 0.000 0.984 0.012
#> GSM39872 3 0.1824 0.8723 0.004 0.000 0.936 0.060
#> GSM39828 4 0.4105 0.7816 0.032 0.000 0.156 0.812
#> GSM39829 3 0.3529 0.7933 0.012 0.000 0.836 0.152
#> GSM39830 4 0.6149 0.2299 0.048 0.000 0.472 0.480
#> GSM39832 1 0.0817 0.8986 0.976 0.000 0.000 0.024
#> GSM39833 4 0.4562 0.7859 0.056 0.000 0.152 0.792
#> GSM39834 3 0.5760 0.0393 0.028 0.000 0.524 0.448
#> GSM39835 1 0.4417 0.7297 0.796 0.000 0.160 0.044
#> GSM39836 4 0.1151 0.8156 0.024 0.000 0.008 0.968
#> GSM39837 4 0.3342 0.7709 0.032 0.100 0.000 0.868
#> GSM39838 4 0.0336 0.8119 0.008 0.000 0.000 0.992
#> GSM39839 3 0.0937 0.8852 0.012 0.000 0.976 0.012
#> GSM39840 1 0.1209 0.9012 0.964 0.000 0.004 0.032
#> GSM39841 4 0.4514 0.7832 0.148 0.000 0.056 0.796
#> GSM39842 1 0.0927 0.9016 0.976 0.000 0.008 0.016
#> GSM39843 4 0.1716 0.8152 0.064 0.000 0.000 0.936
#> GSM39844 1 0.0779 0.8973 0.980 0.000 0.004 0.016
#> GSM39845 3 0.0804 0.8862 0.012 0.000 0.980 0.008
#> GSM39852 4 0.2714 0.8003 0.004 0.000 0.112 0.884
#> GSM39853 1 0.6412 0.5829 0.668 0.200 0.008 0.124
#> GSM39854 1 0.2081 0.8766 0.916 0.000 0.000 0.084
#> GSM39857 3 0.1305 0.8846 0.004 0.000 0.960 0.036
#> GSM39860 3 0.6148 0.2684 0.000 0.408 0.540 0.052
#> GSM39861 3 0.2125 0.8634 0.004 0.000 0.920 0.076
#> GSM39864 4 0.4893 0.7591 0.064 0.000 0.168 0.768
#> GSM39868 3 0.4746 0.5261 0.000 0.000 0.632 0.368
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.8981 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.8981 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.8981 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.8981 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.2136 0.8288 0.904 0.000 0.000 0.008 0.088
#> GSM39819 3 0.2891 0.8862 0.000 0.000 0.824 0.000 0.176
#> GSM39820 3 0.2605 0.8917 0.000 0.000 0.852 0.000 0.148
#> GSM39821 4 0.0000 0.7832 0.000 0.000 0.000 1.000 0.000
#> GSM39822 2 0.5665 0.5388 0.004 0.624 0.112 0.260 0.000
#> GSM39823 3 0.3177 0.8788 0.000 0.000 0.792 0.000 0.208
#> GSM39824 5 0.0000 0.7705 0.000 0.000 0.000 0.000 1.000
#> GSM39825 4 0.5341 0.5088 0.000 0.000 0.060 0.564 0.376
#> GSM39826 4 0.0000 0.7832 0.000 0.000 0.000 1.000 0.000
#> GSM39827 4 0.0000 0.7832 0.000 0.000 0.000 1.000 0.000
#> GSM39846 5 0.3274 0.5221 0.000 0.000 0.220 0.000 0.780
#> GSM39847 4 0.1386 0.7875 0.000 0.000 0.016 0.952 0.032
#> GSM39848 4 0.7969 0.4155 0.008 0.240 0.176 0.468 0.108
#> GSM39849 5 0.1907 0.7638 0.000 0.000 0.044 0.028 0.928
#> GSM39850 4 0.0162 0.7825 0.000 0.000 0.004 0.996 0.000
#> GSM39851 4 0.0898 0.7754 0.008 0.000 0.020 0.972 0.000
#> GSM39855 5 0.1043 0.7675 0.000 0.000 0.040 0.000 0.960
#> GSM39856 5 0.0703 0.7725 0.000 0.000 0.024 0.000 0.976
#> GSM39858 5 0.2648 0.6630 0.000 0.000 0.152 0.000 0.848
#> GSM39859 5 0.2605 0.6960 0.000 0.000 0.148 0.000 0.852
#> GSM39862 4 0.5015 0.6775 0.004 0.000 0.056 0.668 0.272
#> GSM39863 1 0.0510 0.8897 0.984 0.000 0.000 0.016 0.000
#> GSM39865 4 0.8145 0.5192 0.008 0.148 0.176 0.460 0.208
#> GSM39866 3 0.3326 0.7395 0.000 0.000 0.824 0.152 0.024
#> GSM39867 1 0.0451 0.8869 0.988 0.000 0.008 0.004 0.000
#> GSM39869 2 0.2722 0.8351 0.008 0.868 0.120 0.004 0.000
#> GSM39870 3 0.3074 0.8832 0.000 0.000 0.804 0.000 0.196
#> GSM39871 5 0.1043 0.7675 0.000 0.000 0.040 0.000 0.960
#> GSM39872 5 0.1485 0.7570 0.000 0.000 0.020 0.032 0.948
#> GSM39828 4 0.4742 0.7172 0.004 0.000 0.060 0.716 0.220
#> GSM39829 3 0.2488 0.8772 0.000 0.000 0.872 0.004 0.124
#> GSM39830 3 0.4382 0.6106 0.004 0.000 0.700 0.020 0.276
#> GSM39832 1 0.0290 0.8898 0.992 0.000 0.000 0.008 0.000
#> GSM39833 4 0.4021 0.7410 0.000 0.000 0.036 0.764 0.200
#> GSM39834 5 0.5752 -0.2929 0.012 0.000 0.056 0.452 0.480
#> GSM39835 1 0.5685 0.6449 0.692 0.000 0.060 0.068 0.180
#> GSM39836 4 0.0000 0.7832 0.000 0.000 0.000 1.000 0.000
#> GSM39837 4 0.2790 0.7413 0.000 0.052 0.068 0.880 0.000
#> GSM39838 4 0.3692 0.7682 0.000 0.000 0.136 0.812 0.052
#> GSM39839 3 0.2516 0.8888 0.000 0.000 0.860 0.000 0.140
#> GSM39840 1 0.0955 0.8862 0.968 0.000 0.000 0.028 0.004
#> GSM39841 4 0.5162 0.7560 0.080 0.000 0.072 0.752 0.096
#> GSM39842 1 0.0290 0.8898 0.992 0.000 0.000 0.008 0.000
#> GSM39843 4 0.1173 0.7874 0.004 0.000 0.012 0.964 0.020
#> GSM39844 1 0.0290 0.8898 0.992 0.000 0.000 0.008 0.000
#> GSM39845 3 0.3177 0.8794 0.000 0.000 0.792 0.000 0.208
#> GSM39852 4 0.4125 0.7518 0.000 0.000 0.056 0.772 0.172
#> GSM39853 1 0.7053 0.5044 0.568 0.084 0.196 0.152 0.000
#> GSM39854 1 0.2036 0.8595 0.920 0.000 0.024 0.056 0.000
#> GSM39857 5 0.0880 0.7611 0.000 0.000 0.032 0.000 0.968
#> GSM39860 5 0.5533 0.2836 0.008 0.320 0.068 0.000 0.604
#> GSM39861 5 0.4732 0.4765 0.000 0.000 0.076 0.208 0.716
#> GSM39864 4 0.5415 0.7087 0.036 0.000 0.056 0.688 0.220
#> GSM39868 4 0.6036 -0.0343 0.000 0.000 0.116 0.452 0.432
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.1327 0.838 0.936 0.000 0.064 0.000 0.000 0.000
#> GSM39819 6 0.0937 0.932 0.000 0.000 0.040 0.000 0.000 0.960
#> GSM39820 6 0.0632 0.936 0.000 0.000 0.024 0.000 0.000 0.976
#> GSM39821 4 0.0146 0.823 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM39822 5 0.5027 0.451 0.000 0.304 0.000 0.100 0.596 0.000
#> GSM39823 6 0.1663 0.918 0.000 0.000 0.088 0.000 0.000 0.912
#> GSM39824 3 0.0000 0.779 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM39825 4 0.5877 0.463 0.000 0.000 0.320 0.548 0.068 0.064
#> GSM39826 4 0.0146 0.823 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM39827 4 0.0146 0.823 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM39846 3 0.2300 0.699 0.000 0.000 0.856 0.000 0.000 0.144
#> GSM39847 4 0.1332 0.825 0.000 0.000 0.028 0.952 0.008 0.012
#> GSM39848 5 0.0146 0.706 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM39849 3 0.1864 0.772 0.000 0.000 0.924 0.032 0.004 0.040
#> GSM39850 4 0.0146 0.823 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM39851 4 0.0603 0.817 0.000 0.000 0.000 0.980 0.004 0.016
#> GSM39855 3 0.1007 0.778 0.000 0.000 0.956 0.000 0.000 0.044
#> GSM39856 3 0.0713 0.782 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM39858 3 0.2048 0.749 0.000 0.000 0.880 0.000 0.000 0.120
#> GSM39859 3 0.3588 0.718 0.000 0.000 0.776 0.000 0.044 0.180
#> GSM39862 4 0.5096 0.722 0.000 0.000 0.188 0.688 0.076 0.048
#> GSM39863 1 0.0291 0.890 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM39865 5 0.1644 0.695 0.000 0.004 0.052 0.012 0.932 0.000
#> GSM39866 6 0.0937 0.907 0.000 0.000 0.000 0.040 0.000 0.960
#> GSM39867 1 0.1700 0.842 0.916 0.000 0.000 0.004 0.080 0.000
#> GSM39869 5 0.2219 0.665 0.000 0.136 0.000 0.000 0.864 0.000
#> GSM39870 6 0.1327 0.930 0.000 0.000 0.064 0.000 0.000 0.936
#> GSM39871 3 0.1934 0.784 0.000 0.000 0.916 0.000 0.040 0.044
#> GSM39872 3 0.2459 0.760 0.000 0.000 0.896 0.032 0.052 0.020
#> GSM39828 4 0.4581 0.762 0.000 0.000 0.144 0.744 0.064 0.048
#> GSM39829 6 0.0363 0.930 0.000 0.000 0.012 0.000 0.000 0.988
#> GSM39830 6 0.2889 0.763 0.000 0.000 0.096 0.004 0.044 0.856
#> GSM39832 1 0.0000 0.891 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39833 4 0.3989 0.782 0.000 0.000 0.128 0.788 0.052 0.032
#> GSM39834 3 0.6318 -0.189 0.020 0.000 0.432 0.432 0.068 0.048
#> GSM39835 1 0.6579 0.170 0.492 0.000 0.100 0.076 0.324 0.008
#> GSM39836 4 0.0363 0.823 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM39837 4 0.3564 0.611 0.000 0.012 0.000 0.724 0.264 0.000
#> GSM39838 4 0.3668 0.551 0.000 0.000 0.004 0.668 0.328 0.000
#> GSM39839 6 0.0458 0.933 0.000 0.000 0.016 0.000 0.000 0.984
#> GSM39840 1 0.0692 0.885 0.976 0.000 0.004 0.020 0.000 0.000
#> GSM39841 4 0.5056 0.773 0.084 0.000 0.064 0.748 0.040 0.064
#> GSM39842 1 0.0000 0.891 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39843 4 0.1088 0.826 0.000 0.000 0.024 0.960 0.000 0.016
#> GSM39844 1 0.0000 0.891 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39845 6 0.1501 0.926 0.000 0.000 0.076 0.000 0.000 0.924
#> GSM39852 4 0.4210 0.789 0.000 0.000 0.108 0.780 0.068 0.044
#> GSM39853 5 0.5180 0.276 0.376 0.016 0.000 0.048 0.556 0.004
#> GSM39854 1 0.1856 0.852 0.920 0.000 0.000 0.048 0.032 0.000
#> GSM39857 3 0.1594 0.768 0.000 0.000 0.932 0.000 0.052 0.016
#> GSM39860 5 0.3198 0.553 0.000 0.000 0.260 0.000 0.740 0.000
#> GSM39861 3 0.5128 0.621 0.000 0.000 0.700 0.148 0.056 0.096
#> GSM39864 4 0.5256 0.753 0.032 0.000 0.144 0.716 0.064 0.044
#> GSM39868 3 0.6112 0.305 0.000 0.000 0.480 0.352 0.028 0.140
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> CV:pam 57 1.15e-05 7.82e-06 2
#> CV:pam 44 8.89e-07 6.45e-06 3
#> CV:pam 54 1.51e-07 9.26e-07 4
#> CV:pam 53 7.84e-07 2.69e-06 5
#> CV:pam 52 5.39e-10 4.01e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.332 0.798 0.861 0.3679 0.610 0.610
#> 3 3 0.877 0.934 0.961 0.4823 0.538 0.399
#> 4 4 0.733 0.788 0.863 0.2456 0.822 0.619
#> 5 5 0.582 0.556 0.714 0.0922 0.895 0.662
#> 6 6 0.630 0.647 0.769 0.0589 0.806 0.383
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.1633 0.769 0.024 0.976
#> GSM39874 2 0.1633 0.769 0.024 0.976
#> GSM39875 2 0.1633 0.769 0.024 0.976
#> GSM39876 2 0.1633 0.769 0.024 0.976
#> GSM39831 1 0.8016 0.747 0.756 0.244
#> GSM39819 1 0.0000 0.844 1.000 0.000
#> GSM39820 1 0.0000 0.844 1.000 0.000
#> GSM39821 1 0.8207 0.728 0.744 0.256
#> GSM39822 2 0.6887 0.846 0.184 0.816
#> GSM39823 1 0.0000 0.844 1.000 0.000
#> GSM39824 1 0.0000 0.844 1.000 0.000
#> GSM39825 1 0.0938 0.844 0.988 0.012
#> GSM39826 2 0.8386 0.819 0.268 0.732
#> GSM39827 1 0.8813 0.660 0.700 0.300
#> GSM39846 1 0.0000 0.844 1.000 0.000
#> GSM39847 1 0.7674 0.758 0.776 0.224
#> GSM39848 2 0.6048 0.837 0.148 0.852
#> GSM39849 1 0.0376 0.845 0.996 0.004
#> GSM39850 1 0.8813 0.660 0.700 0.300
#> GSM39851 1 0.8016 0.747 0.756 0.244
#> GSM39855 1 0.0000 0.844 1.000 0.000
#> GSM39856 1 0.0000 0.844 1.000 0.000
#> GSM39858 1 0.0000 0.844 1.000 0.000
#> GSM39859 1 0.0000 0.844 1.000 0.000
#> GSM39862 1 0.2423 0.838 0.960 0.040
#> GSM39863 1 0.8016 0.747 0.756 0.244
#> GSM39865 2 0.7674 0.845 0.224 0.776
#> GSM39866 1 0.6531 0.791 0.832 0.168
#> GSM39867 2 0.8267 0.832 0.260 0.740
#> GSM39869 2 0.6148 0.839 0.152 0.848
#> GSM39870 1 0.0000 0.844 1.000 0.000
#> GSM39871 1 0.0000 0.844 1.000 0.000
#> GSM39872 1 0.0938 0.844 0.988 0.012
#> GSM39828 1 0.8327 0.717 0.736 0.264
#> GSM39829 1 0.0000 0.844 1.000 0.000
#> GSM39830 1 0.0938 0.844 0.988 0.012
#> GSM39832 1 0.8207 0.735 0.744 0.256
#> GSM39833 1 0.8499 0.696 0.724 0.276
#> GSM39834 1 0.1414 0.843 0.980 0.020
#> GSM39835 2 0.8267 0.832 0.260 0.740
#> GSM39836 1 0.8443 0.706 0.728 0.272
#> GSM39837 2 0.8144 0.837 0.252 0.748
#> GSM39838 2 0.8207 0.835 0.256 0.744
#> GSM39839 1 0.0000 0.844 1.000 0.000
#> GSM39840 1 0.8016 0.747 0.756 0.244
#> GSM39841 1 0.9000 0.625 0.684 0.316
#> GSM39842 1 0.8016 0.747 0.756 0.244
#> GSM39843 1 0.6343 0.797 0.840 0.160
#> GSM39844 1 0.8081 0.743 0.752 0.248
#> GSM39845 1 0.0000 0.844 1.000 0.000
#> GSM39852 1 0.8267 0.722 0.740 0.260
#> GSM39853 2 0.8144 0.837 0.252 0.748
#> GSM39854 2 0.8267 0.832 0.260 0.740
#> GSM39857 1 0.0000 0.844 1.000 0.000
#> GSM39860 1 0.5408 0.735 0.876 0.124
#> GSM39861 1 0.0000 0.844 1.000 0.000
#> GSM39864 1 0.5294 0.813 0.880 0.120
#> GSM39868 1 0.0938 0.844 0.988 0.012
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39831 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39819 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39820 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39821 1 0.0237 0.949 0.996 0.000 0.004
#> GSM39822 1 0.3272 0.911 0.892 0.104 0.004
#> GSM39823 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39824 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39825 3 0.4346 0.723 0.184 0.000 0.816
#> GSM39826 1 0.0983 0.949 0.980 0.016 0.004
#> GSM39827 1 0.0237 0.949 0.996 0.000 0.004
#> GSM39846 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39847 1 0.0475 0.949 0.992 0.004 0.004
#> GSM39848 1 0.3193 0.916 0.896 0.100 0.004
#> GSM39849 3 0.0592 0.964 0.012 0.000 0.988
#> GSM39850 1 0.0237 0.949 0.996 0.000 0.004
#> GSM39851 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39855 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39856 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39858 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39859 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39862 1 0.2063 0.941 0.948 0.044 0.008
#> GSM39863 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39865 1 0.3715 0.895 0.868 0.128 0.004
#> GSM39866 1 0.1399 0.947 0.968 0.028 0.004
#> GSM39867 1 0.1878 0.939 0.952 0.044 0.004
#> GSM39869 1 0.3030 0.919 0.904 0.092 0.004
#> GSM39870 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39871 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39872 1 0.5291 0.645 0.732 0.000 0.268
#> GSM39828 1 0.0829 0.949 0.984 0.012 0.004
#> GSM39829 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39830 3 0.4235 0.736 0.176 0.000 0.824
#> GSM39832 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39833 1 0.1905 0.944 0.956 0.028 0.016
#> GSM39834 1 0.2313 0.934 0.944 0.024 0.032
#> GSM39835 1 0.1129 0.949 0.976 0.020 0.004
#> GSM39836 1 0.0829 0.949 0.984 0.012 0.004
#> GSM39837 1 0.2772 0.925 0.916 0.080 0.004
#> GSM39838 1 0.2590 0.929 0.924 0.072 0.004
#> GSM39839 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39840 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39841 1 0.0829 0.949 0.984 0.012 0.004
#> GSM39842 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39843 1 0.1289 0.936 0.968 0.000 0.032
#> GSM39844 1 0.0237 0.948 0.996 0.000 0.004
#> GSM39845 3 0.0237 0.968 0.004 0.000 0.996
#> GSM39852 1 0.0829 0.949 0.984 0.012 0.004
#> GSM39853 1 0.2772 0.925 0.916 0.080 0.004
#> GSM39854 1 0.2301 0.932 0.936 0.060 0.004
#> GSM39857 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39860 1 0.5202 0.722 0.772 0.008 0.220
#> GSM39861 3 0.0424 0.968 0.008 0.000 0.992
#> GSM39864 1 0.0983 0.949 0.980 0.016 0.004
#> GSM39868 1 0.3340 0.855 0.880 0.000 0.120
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM39831 1 0.0707 0.646 0.980 0 0.000 0.020
#> GSM39819 3 0.0524 0.947 0.008 0 0.988 0.004
#> GSM39820 3 0.0188 0.947 0.004 0 0.996 0.000
#> GSM39821 1 0.4643 0.741 0.656 0 0.000 0.344
#> GSM39822 4 0.0707 0.845 0.020 0 0.000 0.980
#> GSM39823 3 0.1209 0.936 0.004 0 0.964 0.032
#> GSM39824 3 0.2197 0.906 0.004 0 0.916 0.080
#> GSM39825 3 0.5174 0.683 0.092 0 0.756 0.152
#> GSM39826 4 0.4477 0.408 0.312 0 0.000 0.688
#> GSM39827 1 0.4643 0.741 0.656 0 0.000 0.344
#> GSM39846 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM39847 1 0.4543 0.748 0.676 0 0.000 0.324
#> GSM39848 4 0.0707 0.845 0.020 0 0.000 0.980
#> GSM39849 3 0.1388 0.934 0.012 0 0.960 0.028
#> GSM39850 1 0.4643 0.741 0.656 0 0.000 0.344
#> GSM39851 1 0.0817 0.632 0.976 0 0.000 0.024
#> GSM39855 3 0.2197 0.906 0.004 0 0.916 0.080
#> GSM39856 3 0.0188 0.947 0.000 0 0.996 0.004
#> GSM39858 3 0.0188 0.947 0.000 0 0.996 0.004
#> GSM39859 3 0.0188 0.947 0.000 0 0.996 0.004
#> GSM39862 1 0.4817 0.707 0.612 0 0.000 0.388
#> GSM39863 1 0.0707 0.629 0.980 0 0.000 0.020
#> GSM39865 4 0.0707 0.845 0.020 0 0.000 0.980
#> GSM39866 1 0.4679 0.737 0.648 0 0.000 0.352
#> GSM39867 4 0.2345 0.824 0.100 0 0.000 0.900
#> GSM39869 4 0.0707 0.845 0.020 0 0.000 0.980
#> GSM39870 3 0.0188 0.947 0.004 0 0.996 0.000
#> GSM39871 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM39872 1 0.6792 0.598 0.548 0 0.112 0.340
#> GSM39828 1 0.4643 0.742 0.656 0 0.000 0.344
#> GSM39829 3 0.0188 0.947 0.004 0 0.996 0.000
#> GSM39830 3 0.4718 0.732 0.092 0 0.792 0.116
#> GSM39832 1 0.0469 0.641 0.988 0 0.000 0.012
#> GSM39833 4 0.4331 0.427 0.288 0 0.000 0.712
#> GSM39834 1 0.4746 0.723 0.632 0 0.000 0.368
#> GSM39835 4 0.2530 0.810 0.112 0 0.000 0.888
#> GSM39836 1 0.4661 0.741 0.652 0 0.000 0.348
#> GSM39837 4 0.1302 0.837 0.044 0 0.000 0.956
#> GSM39838 4 0.1389 0.844 0.048 0 0.000 0.952
#> GSM39839 3 0.0524 0.947 0.008 0 0.988 0.004
#> GSM39840 1 0.2011 0.669 0.920 0 0.000 0.080
#> GSM39841 4 0.4994 -0.357 0.480 0 0.000 0.520
#> GSM39842 1 0.0592 0.643 0.984 0 0.000 0.016
#> GSM39843 1 0.4511 0.739 0.724 0 0.008 0.268
#> GSM39844 1 0.0469 0.641 0.988 0 0.000 0.012
#> GSM39845 3 0.0000 0.948 0.000 0 1.000 0.000
#> GSM39852 1 0.4730 0.727 0.636 0 0.000 0.364
#> GSM39853 4 0.1302 0.837 0.044 0 0.000 0.956
#> GSM39854 4 0.2081 0.834 0.084 0 0.000 0.916
#> GSM39857 3 0.1489 0.931 0.004 0 0.952 0.044
#> GSM39860 4 0.1624 0.829 0.028 0 0.020 0.952
#> GSM39861 3 0.0336 0.948 0.008 0 0.992 0.000
#> GSM39864 1 0.4741 0.747 0.668 0 0.004 0.328
#> GSM39868 1 0.5746 0.707 0.612 0 0.040 0.348
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39831 1 0.0162 0.6186 0.996 0 0.000 0.004 0.000
#> GSM39819 3 0.3474 0.8181 0.004 0 0.796 0.192 0.008
#> GSM39820 3 0.3333 0.8094 0.004 0 0.788 0.208 0.000
#> GSM39821 4 0.5893 0.4338 0.436 0 0.000 0.464 0.100
#> GSM39822 5 0.1544 0.6064 0.000 0 0.000 0.068 0.932
#> GSM39823 3 0.1952 0.8229 0.000 0 0.912 0.004 0.084
#> GSM39824 3 0.3728 0.6935 0.000 0 0.748 0.008 0.244
#> GSM39825 3 0.7031 0.4924 0.084 0 0.572 0.156 0.188
#> GSM39826 4 0.6468 0.1642 0.188 0 0.000 0.452 0.360
#> GSM39827 1 0.6242 -0.4589 0.448 0 0.000 0.408 0.144
#> GSM39846 3 0.0000 0.8447 0.000 0 1.000 0.000 0.000
#> GSM39847 1 0.6034 -0.5147 0.456 0 0.000 0.428 0.116
#> GSM39848 5 0.0290 0.6125 0.000 0 0.000 0.008 0.992
#> GSM39849 3 0.1956 0.8368 0.000 0 0.916 0.008 0.076
#> GSM39850 4 0.6188 0.5238 0.364 0 0.000 0.492 0.144
#> GSM39851 1 0.0510 0.6174 0.984 0 0.000 0.016 0.000
#> GSM39855 3 0.3642 0.7106 0.000 0 0.760 0.008 0.232
#> GSM39856 3 0.0162 0.8458 0.004 0 0.996 0.000 0.000
#> GSM39858 3 0.0162 0.8458 0.004 0 0.996 0.000 0.000
#> GSM39859 3 0.0162 0.8458 0.004 0 0.996 0.000 0.000
#> GSM39862 5 0.6801 -0.4534 0.244 0 0.004 0.324 0.428
#> GSM39863 1 0.1341 0.6050 0.944 0 0.000 0.056 0.000
#> GSM39865 5 0.1121 0.6112 0.000 0 0.000 0.044 0.956
#> GSM39866 1 0.6548 -0.6401 0.420 0 0.000 0.380 0.200
#> GSM39867 5 0.5341 0.4853 0.080 0 0.000 0.300 0.620
#> GSM39869 5 0.1608 0.6083 0.000 0 0.000 0.072 0.928
#> GSM39870 3 0.3521 0.7987 0.004 0 0.764 0.232 0.000
#> GSM39871 3 0.0162 0.8458 0.004 0 0.996 0.000 0.000
#> GSM39872 5 0.8286 -0.4405 0.240 0 0.128 0.308 0.324
#> GSM39828 4 0.6333 0.7439 0.288 0 0.000 0.516 0.196
#> GSM39829 3 0.3521 0.7987 0.004 0 0.764 0.232 0.000
#> GSM39830 3 0.6697 0.6046 0.104 0 0.588 0.236 0.072
#> GSM39832 1 0.0162 0.6184 0.996 0 0.000 0.004 0.000
#> GSM39833 5 0.6117 0.3389 0.148 0 0.016 0.224 0.612
#> GSM39834 4 0.6573 0.7289 0.272 0 0.004 0.500 0.224
#> GSM39835 5 0.5188 0.4752 0.060 0 0.000 0.328 0.612
#> GSM39836 4 0.6433 0.7300 0.312 0 0.000 0.488 0.200
#> GSM39837 5 0.4674 0.5971 0.060 0 0.000 0.232 0.708
#> GSM39838 5 0.3940 0.5781 0.024 0 0.000 0.220 0.756
#> GSM39839 3 0.3474 0.8181 0.004 0 0.796 0.192 0.008
#> GSM39840 1 0.2583 0.5216 0.864 0 0.000 0.132 0.004
#> GSM39841 5 0.6805 0.0292 0.380 0 0.024 0.144 0.452
#> GSM39842 1 0.0880 0.6118 0.968 0 0.000 0.032 0.000
#> GSM39843 1 0.6822 -0.5131 0.452 0 0.028 0.384 0.136
#> GSM39844 1 0.0162 0.6184 0.996 0 0.000 0.004 0.000
#> GSM39845 3 0.1704 0.8443 0.004 0 0.928 0.068 0.000
#> GSM39852 4 0.6371 0.7444 0.292 0 0.000 0.508 0.200
#> GSM39853 5 0.4674 0.5971 0.060 0 0.000 0.232 0.708
#> GSM39854 5 0.4793 0.5573 0.068 0 0.000 0.232 0.700
#> GSM39857 3 0.2445 0.8123 0.004 0 0.884 0.004 0.108
#> GSM39860 5 0.1981 0.5889 0.000 0 0.028 0.048 0.924
#> GSM39861 3 0.2228 0.8424 0.004 0 0.900 0.092 0.004
#> GSM39864 4 0.6410 0.6927 0.340 0 0.000 0.476 0.184
#> GSM39868 4 0.7279 0.6897 0.272 0 0.044 0.476 0.208
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39831 1 0.2595 0.9200 0.836 0 0.000 0.160 0.000 0.004
#> GSM39819 6 0.3482 0.7375 0.000 0 0.316 0.000 0.000 0.684
#> GSM39820 6 0.3175 0.7936 0.000 0 0.256 0.000 0.000 0.744
#> GSM39821 4 0.4165 0.6153 0.088 0 0.000 0.788 0.064 0.060
#> GSM39822 5 0.1866 0.7347 0.000 0 0.000 0.084 0.908 0.008
#> GSM39823 3 0.2051 0.7944 0.000 0 0.916 0.040 0.036 0.008
#> GSM39824 3 0.5118 0.5514 0.000 0 0.664 0.044 0.232 0.060
#> GSM39825 4 0.6239 0.0951 0.000 0 0.256 0.488 0.020 0.236
#> GSM39826 4 0.5648 0.5616 0.208 0 0.000 0.636 0.084 0.072
#> GSM39827 4 0.4935 0.6011 0.152 0 0.000 0.716 0.064 0.068
#> GSM39846 3 0.0146 0.8179 0.000 0 0.996 0.000 0.000 0.004
#> GSM39847 4 0.2670 0.6717 0.020 0 0.000 0.884 0.052 0.044
#> GSM39848 5 0.2668 0.7283 0.024 0 0.004 0.096 0.872 0.004
#> GSM39849 3 0.2585 0.7440 0.000 0 0.880 0.084 0.012 0.024
#> GSM39850 4 0.4483 0.6189 0.116 0 0.000 0.760 0.064 0.060
#> GSM39851 1 0.2520 0.9179 0.844 0 0.000 0.152 0.000 0.004
#> GSM39855 3 0.5208 0.5293 0.000 0 0.648 0.044 0.248 0.060
#> GSM39856 3 0.0146 0.8179 0.000 0 0.996 0.000 0.000 0.004
#> GSM39858 3 0.0547 0.8123 0.000 0 0.980 0.000 0.000 0.020
#> GSM39859 3 0.0508 0.8180 0.000 0 0.984 0.004 0.000 0.012
#> GSM39862 5 0.4477 0.3416 0.004 0 0.016 0.424 0.552 0.004
#> GSM39863 1 0.2527 0.9164 0.832 0 0.000 0.168 0.000 0.000
#> GSM39865 5 0.1610 0.7365 0.000 0 0.000 0.084 0.916 0.000
#> GSM39866 4 0.1426 0.6791 0.016 0 0.000 0.948 0.028 0.008
#> GSM39867 4 0.6251 0.4255 0.188 0 0.000 0.568 0.180 0.064
#> GSM39869 5 0.1610 0.7365 0.000 0 0.000 0.084 0.916 0.000
#> GSM39870 6 0.3101 0.7940 0.000 0 0.244 0.000 0.000 0.756
#> GSM39871 3 0.0260 0.8175 0.000 0 0.992 0.000 0.000 0.008
#> GSM39872 4 0.6260 -0.0092 0.004 0 0.148 0.524 0.288 0.036
#> GSM39828 4 0.0603 0.6750 0.000 0 0.000 0.980 0.016 0.004
#> GSM39829 6 0.3076 0.7940 0.000 0 0.240 0.000 0.000 0.760
#> GSM39830 6 0.5802 0.2943 0.012 0 0.108 0.352 0.008 0.520
#> GSM39832 1 0.2482 0.9194 0.848 0 0.000 0.148 0.000 0.004
#> GSM39833 4 0.5657 0.4842 0.056 0 0.008 0.648 0.204 0.084
#> GSM39834 4 0.0777 0.6731 0.000 0 0.000 0.972 0.024 0.004
#> GSM39835 4 0.6106 0.4819 0.148 0 0.000 0.600 0.172 0.080
#> GSM39836 4 0.1845 0.6804 0.072 0 0.000 0.916 0.008 0.004
#> GSM39837 5 0.6368 0.1721 0.048 0 0.000 0.352 0.464 0.136
#> GSM39838 4 0.5849 0.0824 0.116 0 0.000 0.480 0.384 0.020
#> GSM39839 6 0.3482 0.7375 0.000 0 0.316 0.000 0.000 0.684
#> GSM39840 1 0.3819 0.5804 0.624 0 0.000 0.372 0.000 0.004
#> GSM39841 4 0.7018 0.0392 0.368 0 0.000 0.380 0.124 0.128
#> GSM39842 1 0.3109 0.8646 0.772 0 0.000 0.224 0.000 0.004
#> GSM39843 4 0.3877 0.5832 0.136 0 0.008 0.792 0.008 0.056
#> GSM39844 1 0.2482 0.9194 0.848 0 0.000 0.148 0.000 0.004
#> GSM39845 3 0.2234 0.7256 0.000 0 0.872 0.004 0.000 0.124
#> GSM39852 4 0.0767 0.6779 0.008 0 0.000 0.976 0.012 0.004
#> GSM39853 5 0.6368 0.1721 0.048 0 0.000 0.352 0.464 0.136
#> GSM39854 4 0.6483 0.2541 0.152 0 0.000 0.508 0.276 0.064
#> GSM39857 3 0.1970 0.7943 0.000 0 0.920 0.044 0.028 0.008
#> GSM39860 5 0.4430 0.6570 0.004 0 0.068 0.104 0.772 0.052
#> GSM39861 3 0.3201 0.6001 0.000 0 0.780 0.012 0.000 0.208
#> GSM39864 4 0.0717 0.6751 0.000 0 0.000 0.976 0.016 0.008
#> GSM39868 4 0.1871 0.6602 0.000 0 0.032 0.928 0.024 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> CV:mclust 58 3.53e-03 5.72e-03 2
#> CV:mclust 58 2.54e-13 2.01e-11 3
#> CV:mclust 55 6.87e-12 1.78e-09 4
#> CV:mclust 45 3.98e-09 6.60e-08 5
#> CV:mclust 46 9.08e-09 9.54e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.355 0.772 0.870 0.4632 0.564 0.564
#> 3 3 0.756 0.833 0.925 0.4288 0.683 0.479
#> 4 4 0.659 0.706 0.843 0.1169 0.869 0.648
#> 5 5 0.663 0.629 0.797 0.0811 0.872 0.578
#> 6 6 0.716 0.638 0.788 0.0386 0.909 0.613
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0672 0.906 0.008 0.992
#> GSM39874 2 0.0938 0.906 0.012 0.988
#> GSM39875 2 0.0938 0.906 0.012 0.988
#> GSM39876 2 0.1184 0.905 0.016 0.984
#> GSM39831 1 0.6801 0.825 0.820 0.180
#> GSM39819 1 0.0376 0.803 0.996 0.004
#> GSM39820 1 0.0376 0.803 0.996 0.004
#> GSM39821 1 0.6887 0.823 0.816 0.184
#> GSM39822 2 0.0376 0.906 0.004 0.996
#> GSM39823 1 0.9998 -0.197 0.508 0.492
#> GSM39824 2 0.7453 0.757 0.212 0.788
#> GSM39825 1 0.0376 0.803 0.996 0.004
#> GSM39826 1 0.9000 0.699 0.684 0.316
#> GSM39827 1 0.7376 0.804 0.792 0.208
#> GSM39846 1 0.9248 0.352 0.660 0.340
#> GSM39847 1 0.6801 0.825 0.820 0.180
#> GSM39848 2 0.0376 0.906 0.004 0.996
#> GSM39849 1 0.9286 0.341 0.656 0.344
#> GSM39850 1 0.6887 0.823 0.816 0.184
#> GSM39851 1 0.6801 0.825 0.820 0.180
#> GSM39855 2 0.7602 0.751 0.220 0.780
#> GSM39856 1 0.8608 0.485 0.716 0.284
#> GSM39858 1 0.2603 0.787 0.956 0.044
#> GSM39859 1 0.2043 0.793 0.968 0.032
#> GSM39862 2 0.7745 0.708 0.228 0.772
#> GSM39863 1 0.6801 0.825 0.820 0.180
#> GSM39865 2 0.3114 0.882 0.056 0.944
#> GSM39866 1 0.6623 0.825 0.828 0.172
#> GSM39867 1 0.9896 0.465 0.560 0.440
#> GSM39869 2 0.0000 0.905 0.000 1.000
#> GSM39870 1 0.0376 0.803 0.996 0.004
#> GSM39871 1 0.2778 0.785 0.952 0.048
#> GSM39872 1 0.5294 0.730 0.880 0.120
#> GSM39828 1 0.6801 0.825 0.820 0.180
#> GSM39829 1 0.0000 0.804 1.000 0.000
#> GSM39830 1 0.0376 0.804 0.996 0.004
#> GSM39832 1 0.6801 0.825 0.820 0.180
#> GSM39833 2 0.5408 0.788 0.124 0.876
#> GSM39834 1 0.5059 0.823 0.888 0.112
#> GSM39835 2 0.5737 0.785 0.136 0.864
#> GSM39836 1 0.6801 0.825 0.820 0.180
#> GSM39837 2 0.0672 0.903 0.008 0.992
#> GSM39838 2 0.0376 0.903 0.004 0.996
#> GSM39839 1 0.0000 0.804 1.000 0.000
#> GSM39840 1 0.6801 0.825 0.820 0.180
#> GSM39841 1 0.7453 0.801 0.788 0.212
#> GSM39842 1 0.6801 0.825 0.820 0.180
#> GSM39843 1 0.6801 0.825 0.820 0.180
#> GSM39844 1 0.6801 0.825 0.820 0.180
#> GSM39845 1 0.2236 0.791 0.964 0.036
#> GSM39852 1 0.6801 0.825 0.820 0.180
#> GSM39853 2 0.0376 0.903 0.004 0.996
#> GSM39854 2 0.3431 0.862 0.064 0.936
#> GSM39857 1 0.8081 0.556 0.752 0.248
#> GSM39860 2 0.7139 0.767 0.196 0.804
#> GSM39861 1 0.1843 0.795 0.972 0.028
#> GSM39864 1 0.6801 0.825 0.820 0.180
#> GSM39868 1 0.0000 0.804 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.910 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.910 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.910 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.910 0.000 1.000 0.000
#> GSM39831 1 0.0237 0.935 0.996 0.000 0.004
#> GSM39819 3 0.4178 0.795 0.172 0.000 0.828
#> GSM39820 3 0.2625 0.864 0.084 0.000 0.916
#> GSM39821 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39822 2 0.0237 0.910 0.004 0.996 0.000
#> GSM39823 3 0.0237 0.892 0.000 0.004 0.996
#> GSM39824 3 0.0592 0.889 0.000 0.012 0.988
#> GSM39825 3 0.2537 0.868 0.080 0.000 0.920
#> GSM39826 1 0.4121 0.749 0.832 0.168 0.000
#> GSM39827 1 0.0237 0.934 0.996 0.004 0.000
#> GSM39846 3 0.0237 0.892 0.000 0.004 0.996
#> GSM39847 1 0.0237 0.935 0.996 0.000 0.004
#> GSM39848 2 0.0237 0.909 0.000 0.996 0.004
#> GSM39849 3 0.0237 0.892 0.000 0.004 0.996
#> GSM39850 1 0.0592 0.929 0.988 0.012 0.000
#> GSM39851 1 0.0237 0.935 0.996 0.000 0.004
#> GSM39855 3 0.1289 0.877 0.000 0.032 0.968
#> GSM39856 3 0.0237 0.892 0.000 0.004 0.996
#> GSM39858 3 0.0237 0.893 0.004 0.000 0.996
#> GSM39859 3 0.0000 0.892 0.000 0.000 1.000
#> GSM39862 3 0.7888 0.591 0.196 0.140 0.664
#> GSM39863 1 0.0237 0.935 0.996 0.000 0.004
#> GSM39865 2 0.0237 0.909 0.000 0.996 0.004
#> GSM39866 1 0.2564 0.902 0.936 0.028 0.036
#> GSM39867 1 0.5678 0.481 0.684 0.316 0.000
#> GSM39869 2 0.0237 0.910 0.004 0.996 0.000
#> GSM39870 3 0.3340 0.844 0.120 0.000 0.880
#> GSM39871 3 0.0000 0.892 0.000 0.000 1.000
#> GSM39872 3 0.0237 0.892 0.000 0.004 0.996
#> GSM39828 1 0.0424 0.934 0.992 0.000 0.008
#> GSM39829 3 0.4504 0.767 0.196 0.000 0.804
#> GSM39830 1 0.5497 0.545 0.708 0.000 0.292
#> GSM39832 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39833 2 0.2400 0.875 0.064 0.932 0.004
#> GSM39834 1 0.4452 0.738 0.808 0.000 0.192
#> GSM39835 2 0.6192 0.327 0.420 0.580 0.000
#> GSM39836 1 0.0424 0.931 0.992 0.008 0.000
#> GSM39837 2 0.2261 0.882 0.068 0.932 0.000
#> GSM39838 2 0.0592 0.909 0.012 0.988 0.000
#> GSM39839 3 0.3340 0.844 0.120 0.000 0.880
#> GSM39840 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39841 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39842 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39843 1 0.1163 0.922 0.972 0.000 0.028
#> GSM39844 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39845 3 0.0424 0.892 0.008 0.000 0.992
#> GSM39852 1 0.0000 0.936 1.000 0.000 0.000
#> GSM39853 2 0.2261 0.882 0.068 0.932 0.000
#> GSM39854 2 0.6225 0.299 0.432 0.568 0.000
#> GSM39857 3 0.0237 0.892 0.000 0.004 0.996
#> GSM39860 3 0.6280 0.166 0.000 0.460 0.540
#> GSM39861 3 0.0424 0.892 0.008 0.000 0.992
#> GSM39864 1 0.1529 0.912 0.960 0.000 0.040
#> GSM39868 3 0.6244 0.272 0.440 0.000 0.560
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.9599 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.9599 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.9599 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.9599 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0188 0.7560 0.996 0.000 0.004 0.000
#> GSM39819 3 0.4114 0.7019 0.200 0.004 0.788 0.008
#> GSM39820 3 0.2342 0.7937 0.080 0.000 0.912 0.008
#> GSM39821 1 0.3610 0.7228 0.800 0.000 0.000 0.200
#> GSM39822 2 0.0336 0.9582 0.000 0.992 0.000 0.008
#> GSM39823 3 0.4134 0.6854 0.000 0.000 0.740 0.260
#> GSM39824 3 0.5112 0.5147 0.000 0.008 0.608 0.384
#> GSM39825 3 0.4106 0.7737 0.084 0.000 0.832 0.084
#> GSM39826 1 0.5099 0.5250 0.612 0.008 0.000 0.380
#> GSM39827 1 0.2589 0.7582 0.884 0.000 0.000 0.116
#> GSM39846 3 0.1474 0.8158 0.000 0.000 0.948 0.052
#> GSM39847 1 0.3172 0.7458 0.840 0.000 0.000 0.160
#> GSM39848 4 0.1124 0.7351 0.012 0.012 0.004 0.972
#> GSM39849 3 0.3726 0.7272 0.000 0.000 0.788 0.212
#> GSM39850 1 0.4222 0.6628 0.728 0.000 0.000 0.272
#> GSM39851 1 0.0376 0.7545 0.992 0.000 0.004 0.004
#> GSM39855 3 0.5039 0.4866 0.000 0.004 0.592 0.404
#> GSM39856 3 0.1716 0.8124 0.000 0.000 0.936 0.064
#> GSM39858 3 0.0188 0.8192 0.000 0.000 0.996 0.004
#> GSM39859 3 0.1302 0.8180 0.000 0.000 0.956 0.044
#> GSM39862 4 0.1182 0.7362 0.016 0.000 0.016 0.968
#> GSM39863 1 0.1109 0.7414 0.968 0.000 0.028 0.004
#> GSM39865 2 0.2647 0.8676 0.000 0.880 0.000 0.120
#> GSM39866 1 0.4249 0.7172 0.800 0.016 0.008 0.176
#> GSM39867 1 0.6119 0.6215 0.680 0.168 0.000 0.152
#> GSM39869 2 0.1716 0.9242 0.000 0.936 0.000 0.064
#> GSM39870 3 0.2546 0.7878 0.092 0.000 0.900 0.008
#> GSM39871 3 0.0592 0.8201 0.000 0.000 0.984 0.016
#> GSM39872 4 0.3649 0.5299 0.000 0.000 0.204 0.796
#> GSM39828 1 0.4877 0.4898 0.592 0.000 0.000 0.408
#> GSM39829 3 0.3450 0.7465 0.156 0.000 0.836 0.008
#> GSM39830 1 0.5193 0.0935 0.580 0.000 0.412 0.008
#> GSM39832 1 0.1118 0.7655 0.964 0.000 0.000 0.036
#> GSM39833 2 0.3172 0.8541 0.088 0.884 0.008 0.020
#> GSM39834 4 0.2530 0.6881 0.100 0.000 0.004 0.896
#> GSM39835 1 0.6014 0.4939 0.588 0.052 0.000 0.360
#> GSM39836 1 0.4941 0.4274 0.564 0.000 0.000 0.436
#> GSM39837 2 0.0336 0.9578 0.008 0.992 0.000 0.000
#> GSM39838 4 0.7216 0.3453 0.180 0.284 0.000 0.536
#> GSM39839 3 0.3768 0.7212 0.184 0.000 0.808 0.008
#> GSM39840 1 0.1792 0.7652 0.932 0.000 0.000 0.068
#> GSM39841 1 0.2529 0.7120 0.920 0.024 0.048 0.008
#> GSM39842 1 0.1022 0.7653 0.968 0.000 0.000 0.032
#> GSM39843 1 0.1305 0.7417 0.960 0.000 0.036 0.004
#> GSM39844 1 0.0188 0.7586 0.996 0.000 0.000 0.004
#> GSM39845 3 0.0817 0.8205 0.000 0.000 0.976 0.024
#> GSM39852 4 0.4866 -0.0476 0.404 0.000 0.000 0.596
#> GSM39853 2 0.0469 0.9560 0.012 0.988 0.000 0.000
#> GSM39854 1 0.7053 0.3485 0.512 0.356 0.000 0.132
#> GSM39857 3 0.4843 0.5083 0.000 0.000 0.604 0.396
#> GSM39860 4 0.3636 0.5753 0.000 0.008 0.172 0.820
#> GSM39861 3 0.0336 0.8178 0.008 0.000 0.992 0.000
#> GSM39864 1 0.3625 0.7435 0.828 0.000 0.012 0.160
#> GSM39868 4 0.3453 0.7187 0.080 0.000 0.052 0.868
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0162 0.906 0.000 0.996 0.000 0.004 0.000
#> GSM39874 2 0.0000 0.906 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0162 0.906 0.000 0.996 0.000 0.004 0.000
#> GSM39876 2 0.0000 0.906 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.2966 0.587 0.816 0.000 0.000 0.184 0.000
#> GSM39819 3 0.3453 0.745 0.136 0.000 0.832 0.012 0.020
#> GSM39820 3 0.1716 0.821 0.016 0.000 0.944 0.016 0.024
#> GSM39821 4 0.2361 0.713 0.096 0.000 0.000 0.892 0.012
#> GSM39822 2 0.0703 0.901 0.000 0.976 0.000 0.024 0.000
#> GSM39823 3 0.4605 0.596 0.004 0.000 0.692 0.032 0.272
#> GSM39824 3 0.4498 0.494 0.004 0.004 0.632 0.004 0.356
#> GSM39825 3 0.4719 0.715 0.028 0.000 0.768 0.132 0.072
#> GSM39826 4 0.3134 0.700 0.120 0.000 0.000 0.848 0.032
#> GSM39827 4 0.3551 0.599 0.220 0.000 0.000 0.772 0.008
#> GSM39846 3 0.0510 0.827 0.000 0.000 0.984 0.000 0.016
#> GSM39847 4 0.1502 0.721 0.056 0.000 0.000 0.940 0.004
#> GSM39848 5 0.2950 0.739 0.020 0.028 0.004 0.060 0.888
#> GSM39849 5 0.7411 0.266 0.288 0.004 0.280 0.024 0.404
#> GSM39850 4 0.2773 0.709 0.112 0.000 0.000 0.868 0.020
#> GSM39851 1 0.4702 0.212 0.512 0.000 0.004 0.476 0.008
#> GSM39855 3 0.4390 0.350 0.000 0.004 0.568 0.000 0.428
#> GSM39856 3 0.1670 0.817 0.012 0.000 0.936 0.000 0.052
#> GSM39858 3 0.0451 0.828 0.004 0.000 0.988 0.000 0.008
#> GSM39859 3 0.0703 0.826 0.000 0.000 0.976 0.000 0.024
#> GSM39862 5 0.3080 0.737 0.060 0.000 0.008 0.060 0.872
#> GSM39863 1 0.3796 0.464 0.700 0.000 0.000 0.300 0.000
#> GSM39865 2 0.2873 0.806 0.000 0.860 0.000 0.020 0.120
#> GSM39866 4 0.5414 0.518 0.216 0.012 0.016 0.696 0.060
#> GSM39867 1 0.6793 0.263 0.524 0.128 0.000 0.308 0.040
#> GSM39869 2 0.2775 0.833 0.020 0.876 0.000 0.004 0.100
#> GSM39870 3 0.2414 0.802 0.008 0.000 0.900 0.080 0.012
#> GSM39871 3 0.0451 0.828 0.004 0.000 0.988 0.000 0.008
#> GSM39872 5 0.3536 0.725 0.052 0.000 0.072 0.024 0.852
#> GSM39828 4 0.5233 0.462 0.288 0.000 0.000 0.636 0.076
#> GSM39829 3 0.2993 0.797 0.044 0.000 0.884 0.048 0.024
#> GSM39830 1 0.6837 0.286 0.488 0.000 0.312 0.180 0.020
#> GSM39832 1 0.2127 0.607 0.892 0.000 0.000 0.108 0.000
#> GSM39833 1 0.7684 0.147 0.448 0.284 0.000 0.084 0.184
#> GSM39834 5 0.3419 0.654 0.016 0.000 0.000 0.180 0.804
#> GSM39835 1 0.5443 0.253 0.624 0.024 0.000 0.040 0.312
#> GSM39836 4 0.2221 0.719 0.036 0.000 0.000 0.912 0.052
#> GSM39837 2 0.0955 0.897 0.004 0.968 0.000 0.028 0.000
#> GSM39838 4 0.5787 0.396 0.000 0.204 0.000 0.616 0.180
#> GSM39839 3 0.3203 0.757 0.124 0.000 0.848 0.008 0.020
#> GSM39840 1 0.4150 0.387 0.612 0.000 0.000 0.388 0.000
#> GSM39841 1 0.4458 0.592 0.772 0.032 0.016 0.172 0.008
#> GSM39842 1 0.1942 0.564 0.920 0.000 0.000 0.012 0.068
#> GSM39843 1 0.4607 0.438 0.664 0.000 0.012 0.312 0.012
#> GSM39844 1 0.2471 0.604 0.864 0.000 0.000 0.136 0.000
#> GSM39845 3 0.0932 0.828 0.004 0.000 0.972 0.004 0.020
#> GSM39852 4 0.3013 0.650 0.008 0.000 0.000 0.832 0.160
#> GSM39853 2 0.0579 0.905 0.008 0.984 0.000 0.008 0.000
#> GSM39854 2 0.6947 0.222 0.300 0.520 0.000 0.128 0.052
#> GSM39857 3 0.4637 0.284 0.012 0.000 0.536 0.000 0.452
#> GSM39860 5 0.1412 0.740 0.000 0.004 0.036 0.008 0.952
#> GSM39861 3 0.0579 0.827 0.008 0.000 0.984 0.008 0.000
#> GSM39864 4 0.5297 0.436 0.292 0.000 0.008 0.640 0.060
#> GSM39868 5 0.4954 0.281 0.012 0.000 0.016 0.380 0.592
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0146 0.9103 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM39874 2 0.0000 0.9102 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0146 0.9103 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM39876 2 0.0000 0.9102 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.1226 0.7782 0.952 0.000 0.004 0.004 0.040 0.000
#> GSM39819 3 0.3651 0.7555 0.076 0.000 0.824 0.044 0.056 0.000
#> GSM39820 3 0.1413 0.8220 0.008 0.000 0.948 0.004 0.036 0.004
#> GSM39821 4 0.0692 0.7609 0.004 0.000 0.000 0.976 0.020 0.000
#> GSM39822 2 0.1655 0.8879 0.000 0.932 0.000 0.052 0.008 0.008
#> GSM39823 3 0.4922 0.5594 0.000 0.000 0.616 0.000 0.288 0.096
#> GSM39824 3 0.4566 0.6563 0.000 0.000 0.700 0.000 0.140 0.160
#> GSM39825 3 0.5121 0.6024 0.004 0.000 0.672 0.200 0.108 0.016
#> GSM39826 4 0.1829 0.7465 0.000 0.028 0.000 0.928 0.008 0.036
#> GSM39827 4 0.5197 0.3429 0.320 0.000 0.000 0.568 0.112 0.000
#> GSM39846 3 0.0508 0.8277 0.000 0.000 0.984 0.000 0.012 0.004
#> GSM39847 4 0.1152 0.7561 0.004 0.000 0.000 0.952 0.044 0.000
#> GSM39848 6 0.3679 0.5551 0.000 0.032 0.004 0.040 0.104 0.820
#> GSM39849 6 0.5907 0.5159 0.048 0.000 0.120 0.024 0.156 0.652
#> GSM39850 4 0.0881 0.7588 0.000 0.008 0.000 0.972 0.008 0.012
#> GSM39851 4 0.2250 0.7510 0.064 0.000 0.000 0.896 0.040 0.000
#> GSM39855 3 0.5120 0.5008 0.000 0.000 0.600 0.000 0.120 0.280
#> GSM39856 3 0.2294 0.8030 0.000 0.000 0.892 0.000 0.036 0.072
#> GSM39858 3 0.0146 0.8268 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM39859 3 0.0622 0.8273 0.000 0.000 0.980 0.000 0.012 0.008
#> GSM39862 6 0.2499 0.5893 0.000 0.000 0.000 0.048 0.072 0.880
#> GSM39863 1 0.2474 0.7439 0.884 0.000 0.004 0.032 0.080 0.000
#> GSM39865 2 0.4419 0.6286 0.004 0.704 0.000 0.000 0.220 0.072
#> GSM39866 5 0.5083 0.2336 0.364 0.008 0.016 0.028 0.580 0.004
#> GSM39867 1 0.3583 0.6210 0.784 0.024 0.000 0.000 0.180 0.012
#> GSM39869 2 0.3792 0.7808 0.024 0.808 0.000 0.004 0.048 0.116
#> GSM39870 3 0.3621 0.7468 0.044 0.000 0.804 0.008 0.140 0.004
#> GSM39871 3 0.0914 0.8266 0.000 0.000 0.968 0.000 0.016 0.016
#> GSM39872 6 0.2302 0.5871 0.008 0.000 0.060 0.000 0.032 0.900
#> GSM39828 4 0.2594 0.7444 0.028 0.000 0.000 0.884 0.016 0.072
#> GSM39829 3 0.2411 0.8109 0.032 0.000 0.900 0.024 0.044 0.000
#> GSM39830 4 0.7606 0.3066 0.124 0.000 0.232 0.464 0.136 0.044
#> GSM39832 1 0.0692 0.7772 0.976 0.000 0.000 0.000 0.020 0.004
#> GSM39833 6 0.8339 0.0762 0.060 0.200 0.000 0.296 0.148 0.296
#> GSM39834 5 0.4868 0.1631 0.052 0.000 0.000 0.004 0.548 0.396
#> GSM39835 6 0.5288 0.3934 0.264 0.004 0.000 0.000 0.132 0.600
#> GSM39836 4 0.2062 0.7197 0.004 0.000 0.000 0.900 0.088 0.008
#> GSM39837 2 0.2048 0.8272 0.000 0.880 0.000 0.120 0.000 0.000
#> GSM39838 5 0.6786 0.3786 0.016 0.196 0.000 0.212 0.520 0.056
#> GSM39839 3 0.3577 0.7636 0.068 0.000 0.832 0.028 0.068 0.004
#> GSM39840 4 0.4610 0.5877 0.272 0.000 0.000 0.664 0.056 0.008
#> GSM39841 1 0.4502 0.6299 0.756 0.020 0.008 0.124 0.092 0.000
#> GSM39842 1 0.4143 0.6146 0.756 0.000 0.000 0.004 0.124 0.116
#> GSM39843 4 0.5007 0.6559 0.152 0.000 0.008 0.712 0.100 0.028
#> GSM39844 1 0.0458 0.7784 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM39845 3 0.0363 0.8271 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM39852 5 0.5082 0.0557 0.008 0.000 0.000 0.460 0.476 0.056
#> GSM39853 2 0.0520 0.9082 0.000 0.984 0.000 0.008 0.000 0.008
#> GSM39854 1 0.5305 0.4834 0.660 0.204 0.000 0.004 0.108 0.024
#> GSM39857 3 0.5364 0.4283 0.000 0.000 0.560 0.000 0.140 0.300
#> GSM39860 6 0.3295 0.5002 0.000 0.004 0.012 0.004 0.184 0.796
#> GSM39861 3 0.0862 0.8281 0.000 0.000 0.972 0.008 0.016 0.004
#> GSM39864 5 0.4641 -0.0214 0.480 0.000 0.008 0.008 0.492 0.012
#> GSM39868 5 0.5723 0.3369 0.084 0.000 0.032 0.012 0.608 0.264
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> CV:NMF 53 0.018700 0.03184 2
#> CV:NMF 53 0.000617 0.00137 3
#> CV:NMF 50 0.000587 0.01428 4
#> CV:NMF 41 0.003359 0.00264 5
#> CV:NMF 46 0.001228 0.00592 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.249 0.694 0.840 0.2467 0.900 0.900
#> 3 3 0.147 0.494 0.686 1.2056 0.525 0.482
#> 4 4 0.362 0.578 0.746 0.2079 0.851 0.681
#> 5 5 0.471 0.461 0.708 0.1191 0.864 0.622
#> 6 6 0.528 0.582 0.743 0.0618 0.920 0.710
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 1 0.9580 0.496 0.620 0.380
#> GSM39874 1 0.9580 0.496 0.620 0.380
#> GSM39875 1 0.9580 0.496 0.620 0.380
#> GSM39876 1 0.9580 0.496 0.620 0.380
#> GSM39831 1 0.1843 0.781 0.972 0.028
#> GSM39819 1 0.6148 0.779 0.848 0.152
#> GSM39820 1 0.6343 0.777 0.840 0.160
#> GSM39821 1 0.0672 0.789 0.992 0.008
#> GSM39822 1 0.7528 0.741 0.784 0.216
#> GSM39823 1 0.9286 0.578 0.656 0.344
#> GSM39824 1 0.9815 0.389 0.580 0.420
#> GSM39825 1 0.1633 0.793 0.976 0.024
#> GSM39826 1 0.0672 0.789 0.992 0.008
#> GSM39827 1 0.2043 0.794 0.968 0.032
#> GSM39846 1 0.9522 0.517 0.628 0.372
#> GSM39847 1 0.0672 0.789 0.992 0.008
#> GSM39848 2 0.6973 0.607 0.188 0.812
#> GSM39849 1 0.7299 0.752 0.796 0.204
#> GSM39850 1 0.0672 0.789 0.992 0.008
#> GSM39851 1 0.1843 0.781 0.972 0.028
#> GSM39855 2 0.9922 -0.111 0.448 0.552
#> GSM39856 1 0.9323 0.569 0.652 0.348
#> GSM39858 1 0.9087 0.613 0.676 0.324
#> GSM39859 1 0.8144 0.712 0.748 0.252
#> GSM39862 1 0.5178 0.702 0.884 0.116
#> GSM39863 1 0.1843 0.781 0.972 0.028
#> GSM39865 1 0.9833 0.336 0.576 0.424
#> GSM39866 1 0.4161 0.799 0.916 0.084
#> GSM39867 1 0.3584 0.793 0.932 0.068
#> GSM39869 1 0.9286 0.446 0.656 0.344
#> GSM39870 1 0.6343 0.779 0.840 0.160
#> GSM39871 1 0.8081 0.712 0.752 0.248
#> GSM39872 1 0.4431 0.792 0.908 0.092
#> GSM39828 1 0.1414 0.789 0.980 0.020
#> GSM39829 1 0.5842 0.785 0.860 0.140
#> GSM39830 1 0.5946 0.783 0.856 0.144
#> GSM39832 1 0.1843 0.781 0.972 0.028
#> GSM39833 1 0.7602 0.743 0.780 0.220
#> GSM39834 1 0.1843 0.793 0.972 0.028
#> GSM39835 1 0.4022 0.787 0.920 0.080
#> GSM39836 1 0.0672 0.789 0.992 0.008
#> GSM39837 1 0.7453 0.744 0.788 0.212
#> GSM39838 1 0.9248 0.566 0.660 0.340
#> GSM39839 1 0.6148 0.779 0.848 0.152
#> GSM39840 1 0.1843 0.781 0.972 0.028
#> GSM39841 1 0.6148 0.785 0.848 0.152
#> GSM39842 1 0.1843 0.781 0.972 0.028
#> GSM39843 1 0.1414 0.783 0.980 0.020
#> GSM39844 1 0.1843 0.781 0.972 0.028
#> GSM39845 1 0.6343 0.777 0.840 0.160
#> GSM39852 1 0.1184 0.790 0.984 0.016
#> GSM39853 1 0.7453 0.744 0.788 0.212
#> GSM39854 1 0.3584 0.793 0.932 0.068
#> GSM39857 1 0.9248 0.584 0.660 0.340
#> GSM39860 2 0.1843 0.593 0.028 0.972
#> GSM39861 1 0.7139 0.755 0.804 0.196
#> GSM39864 1 0.3733 0.799 0.928 0.072
#> GSM39868 1 0.1843 0.793 0.972 0.028
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 3 0.554 0.28395 0.024 0.200 0.776
#> GSM39874 3 0.554 0.28395 0.024 0.200 0.776
#> GSM39875 3 0.554 0.28395 0.024 0.200 0.776
#> GSM39876 3 0.554 0.28395 0.024 0.200 0.776
#> GSM39831 1 0.232 0.72679 0.944 0.028 0.028
#> GSM39819 3 0.628 0.29634 0.460 0.000 0.540
#> GSM39820 3 0.629 0.27096 0.468 0.000 0.532
#> GSM39821 1 0.451 0.73644 0.832 0.012 0.156
#> GSM39822 3 0.679 0.41549 0.136 0.120 0.744
#> GSM39823 3 0.820 0.53933 0.200 0.160 0.640
#> GSM39824 3 0.743 0.46259 0.100 0.212 0.688
#> GSM39825 1 0.468 0.70881 0.804 0.004 0.192
#> GSM39826 1 0.512 0.71146 0.788 0.012 0.200
#> GSM39827 1 0.470 0.70172 0.812 0.008 0.180
#> GSM39846 3 0.740 0.52469 0.144 0.152 0.704
#> GSM39847 1 0.451 0.73644 0.832 0.012 0.156
#> GSM39848 2 0.598 0.66150 0.020 0.728 0.252
#> GSM39849 3 0.721 0.44093 0.360 0.036 0.604
#> GSM39850 1 0.512 0.71146 0.788 0.012 0.200
#> GSM39851 1 0.206 0.72777 0.952 0.024 0.024
#> GSM39855 3 0.684 0.21497 0.024 0.352 0.624
#> GSM39856 3 0.731 0.54421 0.168 0.124 0.708
#> GSM39858 3 0.725 0.55958 0.196 0.100 0.704
#> GSM39859 3 0.748 0.48982 0.308 0.060 0.632
#> GSM39862 1 0.664 0.67688 0.752 0.108 0.140
#> GSM39863 1 0.232 0.72679 0.944 0.028 0.028
#> GSM39865 3 0.806 0.00156 0.084 0.328 0.588
#> GSM39866 1 0.576 0.64946 0.764 0.028 0.208
#> GSM39867 3 0.775 0.30080 0.300 0.076 0.624
#> GSM39869 3 0.864 0.04545 0.128 0.308 0.564
#> GSM39870 1 0.648 -0.03657 0.544 0.004 0.452
#> GSM39871 3 0.694 0.50951 0.284 0.044 0.672
#> GSM39872 1 0.674 0.35267 0.600 0.016 0.384
#> GSM39828 1 0.309 0.74624 0.912 0.016 0.072
#> GSM39829 3 0.630 0.25834 0.476 0.000 0.524
#> GSM39830 1 0.599 0.10938 0.632 0.000 0.368
#> GSM39832 1 0.327 0.70945 0.912 0.044 0.044
#> GSM39833 3 0.756 0.46519 0.336 0.056 0.608
#> GSM39834 1 0.491 0.72047 0.796 0.008 0.196
#> GSM39835 1 0.822 0.11445 0.516 0.076 0.408
#> GSM39836 1 0.497 0.71847 0.800 0.012 0.188
#> GSM39837 3 0.635 0.43725 0.140 0.092 0.768
#> GSM39838 3 0.881 0.21296 0.172 0.252 0.576
#> GSM39839 3 0.628 0.29634 0.460 0.000 0.540
#> GSM39840 1 0.232 0.72520 0.944 0.028 0.028
#> GSM39841 1 0.596 0.59918 0.788 0.076 0.136
#> GSM39842 1 0.327 0.70945 0.912 0.044 0.044
#> GSM39843 1 0.117 0.73132 0.976 0.016 0.008
#> GSM39844 1 0.327 0.70945 0.912 0.044 0.044
#> GSM39845 3 0.650 0.27648 0.468 0.004 0.528
#> GSM39852 1 0.447 0.73355 0.828 0.008 0.164
#> GSM39853 3 0.635 0.43725 0.140 0.092 0.768
#> GSM39854 3 0.775 0.30080 0.300 0.076 0.624
#> GSM39857 3 0.824 0.54019 0.204 0.160 0.636
#> GSM39860 2 0.368 0.69715 0.008 0.876 0.116
#> GSM39861 3 0.678 0.43061 0.364 0.020 0.616
#> GSM39864 1 0.481 0.70603 0.832 0.028 0.140
#> GSM39868 1 0.491 0.72047 0.796 0.008 0.196
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.402 0.623 0.000 0.836 0.096 0.068
#> GSM39874 2 0.402 0.623 0.000 0.836 0.096 0.068
#> GSM39875 2 0.402 0.623 0.000 0.836 0.096 0.068
#> GSM39876 2 0.402 0.623 0.000 0.836 0.096 0.068
#> GSM39831 1 0.210 0.675 0.940 0.016 0.016 0.028
#> GSM39819 3 0.478 0.618 0.336 0.000 0.660 0.004
#> GSM39820 3 0.487 0.585 0.356 0.004 0.640 0.000
#> GSM39821 1 0.567 0.673 0.728 0.084 0.180 0.008
#> GSM39822 2 0.398 0.681 0.052 0.860 0.060 0.028
#> GSM39823 3 0.415 0.669 0.072 0.012 0.844 0.072
#> GSM39824 3 0.302 0.571 0.000 0.024 0.884 0.092
#> GSM39825 1 0.549 0.608 0.696 0.036 0.260 0.008
#> GSM39826 1 0.650 0.647 0.664 0.144 0.184 0.008
#> GSM39827 1 0.586 0.656 0.728 0.148 0.112 0.012
#> GSM39846 3 0.282 0.660 0.028 0.020 0.912 0.040
#> GSM39847 1 0.567 0.673 0.728 0.084 0.180 0.008
#> GSM39848 4 0.587 0.412 0.004 0.304 0.048 0.644
#> GSM39849 3 0.647 0.632 0.188 0.096 0.688 0.028
#> GSM39850 1 0.650 0.647 0.664 0.144 0.184 0.008
#> GSM39851 1 0.187 0.676 0.948 0.016 0.012 0.024
#> GSM39855 3 0.495 0.313 0.000 0.024 0.708 0.268
#> GSM39856 3 0.238 0.687 0.040 0.020 0.928 0.012
#> GSM39858 3 0.284 0.706 0.068 0.016 0.904 0.012
#> GSM39859 3 0.399 0.711 0.188 0.004 0.800 0.008
#> GSM39862 1 0.752 0.611 0.632 0.088 0.180 0.100
#> GSM39863 1 0.210 0.675 0.940 0.016 0.016 0.028
#> GSM39865 2 0.614 0.476 0.024 0.664 0.044 0.268
#> GSM39866 1 0.605 0.549 0.672 0.036 0.264 0.028
#> GSM39867 2 0.643 0.518 0.184 0.696 0.036 0.084
#> GSM39869 2 0.632 0.476 0.056 0.648 0.020 0.276
#> GSM39870 3 0.583 0.300 0.440 0.032 0.528 0.000
#> GSM39871 3 0.348 0.719 0.148 0.012 0.840 0.000
#> GSM39872 1 0.683 0.181 0.488 0.060 0.436 0.016
#> GSM39828 1 0.460 0.695 0.812 0.056 0.120 0.012
#> GSM39829 3 0.490 0.576 0.364 0.004 0.632 0.000
#> GSM39830 1 0.514 -0.244 0.540 0.000 0.456 0.004
#> GSM39832 1 0.334 0.642 0.880 0.032 0.008 0.080
#> GSM39833 3 0.719 0.558 0.180 0.184 0.616 0.020
#> GSM39834 1 0.616 0.648 0.680 0.092 0.220 0.008
#> GSM39835 1 0.761 -0.196 0.436 0.412 0.012 0.140
#> GSM39836 1 0.640 0.651 0.672 0.132 0.188 0.008
#> GSM39837 2 0.349 0.686 0.052 0.876 0.064 0.008
#> GSM39838 2 0.724 0.507 0.092 0.648 0.072 0.188
#> GSM39839 3 0.478 0.618 0.336 0.000 0.660 0.004
#> GSM39840 1 0.207 0.674 0.940 0.016 0.012 0.032
#> GSM39841 1 0.468 0.569 0.792 0.164 0.020 0.024
#> GSM39842 1 0.334 0.642 0.880 0.032 0.008 0.080
#> GSM39843 1 0.207 0.681 0.940 0.012 0.032 0.016
#> GSM39844 1 0.334 0.642 0.880 0.032 0.008 0.080
#> GSM39845 3 0.487 0.589 0.356 0.004 0.640 0.000
#> GSM39852 1 0.566 0.667 0.724 0.076 0.192 0.008
#> GSM39853 2 0.349 0.686 0.052 0.876 0.064 0.008
#> GSM39854 2 0.643 0.518 0.184 0.696 0.036 0.084
#> GSM39857 3 0.422 0.669 0.076 0.012 0.840 0.072
#> GSM39860 4 0.356 0.586 0.004 0.012 0.140 0.844
#> GSM39861 3 0.416 0.687 0.240 0.004 0.756 0.000
#> GSM39864 1 0.537 0.627 0.748 0.032 0.192 0.028
#> GSM39868 1 0.616 0.648 0.680 0.092 0.220 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0324 0.6407 0.000 0.992 0.004 0.000 0.004
#> GSM39874 2 0.0324 0.6407 0.000 0.992 0.004 0.000 0.004
#> GSM39875 2 0.0324 0.6407 0.000 0.992 0.004 0.000 0.004
#> GSM39876 2 0.0324 0.6407 0.000 0.992 0.004 0.000 0.004
#> GSM39831 4 0.5440 -0.0656 0.472 0.000 0.048 0.476 0.004
#> GSM39819 3 0.4656 0.6738 0.076 0.000 0.740 0.180 0.004
#> GSM39820 3 0.4904 0.6248 0.072 0.000 0.688 0.240 0.000
#> GSM39821 4 0.0960 0.6377 0.016 0.004 0.008 0.972 0.000
#> GSM39822 2 0.6147 0.6402 0.168 0.648 0.004 0.152 0.028
#> GSM39823 3 0.4631 0.6572 0.008 0.000 0.752 0.076 0.164
#> GSM39824 3 0.3583 0.5989 0.004 0.012 0.792 0.000 0.192
#> GSM39825 4 0.4062 0.5591 0.040 0.000 0.196 0.764 0.000
#> GSM39826 4 0.1924 0.5997 0.064 0.008 0.004 0.924 0.000
#> GSM39827 4 0.5644 0.4475 0.216 0.068 0.032 0.680 0.004
#> GSM39846 3 0.2621 0.6652 0.004 0.008 0.876 0.000 0.112
#> GSM39847 4 0.0854 0.6381 0.012 0.004 0.008 0.976 0.000
#> GSM39848 5 0.4151 0.3495 0.000 0.344 0.004 0.000 0.652
#> GSM39849 3 0.4365 0.6429 0.184 0.016 0.768 0.028 0.004
#> GSM39850 4 0.1990 0.5998 0.068 0.008 0.004 0.920 0.000
#> GSM39851 4 0.5380 -0.0419 0.464 0.000 0.044 0.488 0.004
#> GSM39855 3 0.4632 0.3745 0.004 0.012 0.608 0.000 0.376
#> GSM39856 3 0.1928 0.6816 0.004 0.004 0.920 0.000 0.072
#> GSM39858 3 0.2061 0.6992 0.004 0.004 0.924 0.012 0.056
#> GSM39859 3 0.4206 0.7357 0.024 0.000 0.800 0.128 0.048
#> GSM39862 4 0.5295 0.5335 0.100 0.004 0.060 0.748 0.088
#> GSM39863 4 0.5440 -0.0656 0.472 0.000 0.048 0.476 0.004
#> GSM39865 2 0.6858 0.4771 0.080 0.580 0.004 0.092 0.244
#> GSM39866 4 0.4374 0.5820 0.076 0.000 0.092 0.800 0.032
#> GSM39867 1 0.6550 -0.4515 0.436 0.388 0.000 0.172 0.004
#> GSM39869 2 0.7476 0.3593 0.260 0.468 0.000 0.060 0.212
#> GSM39870 4 0.5555 -0.1430 0.068 0.000 0.452 0.480 0.000
#> GSM39871 3 0.1591 0.7250 0.004 0.004 0.940 0.052 0.000
#> GSM39872 4 0.5865 0.3170 0.060 0.004 0.348 0.572 0.016
#> GSM39828 4 0.3953 0.5794 0.148 0.000 0.060 0.792 0.000
#> GSM39829 3 0.4959 0.6203 0.076 0.000 0.684 0.240 0.000
#> GSM39830 3 0.6488 0.3320 0.208 0.000 0.516 0.272 0.004
#> GSM39832 1 0.4748 0.3469 0.660 0.000 0.040 0.300 0.000
#> GSM39833 3 0.6033 0.5460 0.188 0.080 0.664 0.068 0.000
#> GSM39834 4 0.2673 0.6381 0.060 0.000 0.044 0.892 0.004
#> GSM39835 1 0.3248 0.1128 0.856 0.088 0.000 0.052 0.004
#> GSM39836 4 0.1914 0.6086 0.056 0.008 0.008 0.928 0.000
#> GSM39837 2 0.5457 0.6495 0.172 0.672 0.000 0.152 0.004
#> GSM39838 2 0.7114 0.4991 0.064 0.584 0.012 0.180 0.160
#> GSM39839 3 0.4656 0.6738 0.076 0.000 0.740 0.180 0.004
#> GSM39840 1 0.5382 -0.0891 0.480 0.000 0.044 0.472 0.004
#> GSM39841 1 0.7255 0.1975 0.460 0.160 0.040 0.336 0.004
#> GSM39842 1 0.4748 0.3469 0.660 0.000 0.040 0.300 0.000
#> GSM39843 4 0.5306 0.1263 0.400 0.000 0.044 0.552 0.004
#> GSM39844 1 0.4748 0.3469 0.660 0.000 0.040 0.300 0.000
#> GSM39845 3 0.4877 0.6312 0.072 0.000 0.692 0.236 0.000
#> GSM39852 4 0.1211 0.6408 0.016 0.000 0.024 0.960 0.000
#> GSM39853 2 0.5457 0.6495 0.172 0.672 0.000 0.152 0.004
#> GSM39854 1 0.6550 -0.4515 0.436 0.388 0.000 0.172 0.004
#> GSM39857 3 0.4391 0.6566 0.008 0.000 0.768 0.060 0.164
#> GSM39860 5 0.0451 0.5573 0.000 0.004 0.008 0.000 0.988
#> GSM39861 3 0.3276 0.7263 0.032 0.000 0.836 0.132 0.000
#> GSM39864 4 0.5127 0.5482 0.132 0.000 0.096 0.740 0.032
#> GSM39868 4 0.2673 0.6381 0.060 0.000 0.044 0.892 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.000 0.5752 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39874 5 0.000 0.5752 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39875 5 0.000 0.5752 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39876 5 0.000 0.5752 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39831 1 0.274 0.8281 0.840 0.000 0.016 0.144 0.000 0.000
#> GSM39819 3 0.415 0.6649 0.232 0.008 0.720 0.040 0.000 0.000
#> GSM39820 3 0.479 0.6371 0.220 0.004 0.672 0.104 0.000 0.000
#> GSM39821 4 0.273 0.7414 0.152 0.012 0.000 0.836 0.000 0.000
#> GSM39822 5 0.612 0.3622 0.004 0.232 0.000 0.180 0.556 0.028
#> GSM39823 3 0.467 0.6332 0.028 0.016 0.744 0.056 0.000 0.156
#> GSM39824 3 0.341 0.5876 0.000 0.024 0.788 0.000 0.004 0.184
#> GSM39825 4 0.480 0.5920 0.164 0.000 0.164 0.672 0.000 0.000
#> GSM39826 4 0.178 0.7105 0.048 0.028 0.000 0.924 0.000 0.000
#> GSM39827 4 0.613 0.3259 0.360 0.108 0.004 0.492 0.036 0.000
#> GSM39846 3 0.249 0.6506 0.000 0.020 0.876 0.000 0.004 0.100
#> GSM39847 4 0.269 0.7431 0.148 0.012 0.000 0.840 0.000 0.000
#> GSM39848 6 0.430 0.3383 0.000 0.020 0.008 0.000 0.336 0.636
#> GSM39849 3 0.417 0.6054 0.056 0.200 0.736 0.000 0.000 0.008
#> GSM39850 4 0.184 0.7103 0.052 0.028 0.000 0.920 0.000 0.000
#> GSM39851 1 0.249 0.8311 0.864 0.004 0.008 0.124 0.000 0.000
#> GSM39855 3 0.438 0.3718 0.000 0.024 0.604 0.000 0.004 0.368
#> GSM39856 3 0.189 0.6659 0.000 0.024 0.916 0.000 0.000 0.060
#> GSM39858 3 0.265 0.6813 0.024 0.024 0.888 0.004 0.000 0.060
#> GSM39859 3 0.415 0.7197 0.124 0.000 0.780 0.044 0.000 0.052
#> GSM39862 4 0.488 0.6356 0.020 0.088 0.052 0.752 0.000 0.088
#> GSM39863 1 0.274 0.8281 0.840 0.000 0.016 0.144 0.000 0.000
#> GSM39865 5 0.666 0.3952 0.000 0.124 0.000 0.120 0.520 0.236
#> GSM39866 4 0.519 0.6206 0.200 0.012 0.076 0.684 0.000 0.028
#> GSM39867 2 0.663 0.4433 0.060 0.484 0.000 0.188 0.268 0.000
#> GSM39869 5 0.737 -0.0197 0.012 0.328 0.000 0.084 0.368 0.208
#> GSM39870 3 0.593 0.1648 0.184 0.004 0.444 0.368 0.000 0.000
#> GSM39871 3 0.192 0.7076 0.056 0.012 0.920 0.012 0.000 0.000
#> GSM39872 4 0.612 0.3432 0.064 0.056 0.316 0.548 0.000 0.016
#> GSM39828 4 0.467 0.6023 0.220 0.052 0.028 0.700 0.000 0.000
#> GSM39829 3 0.473 0.6383 0.224 0.004 0.676 0.096 0.000 0.000
#> GSM39830 3 0.525 0.2325 0.456 0.016 0.472 0.056 0.000 0.000
#> GSM39832 1 0.201 0.7899 0.904 0.084 0.008 0.004 0.000 0.000
#> GSM39833 3 0.605 0.5215 0.052 0.200 0.644 0.032 0.064 0.008
#> GSM39834 4 0.254 0.7382 0.068 0.028 0.016 0.888 0.000 0.000
#> GSM39835 2 0.267 0.1385 0.156 0.836 0.000 0.000 0.000 0.008
#> GSM39836 4 0.153 0.7154 0.048 0.016 0.000 0.936 0.000 0.000
#> GSM39837 5 0.551 0.3713 0.004 0.236 0.000 0.180 0.580 0.000
#> GSM39838 5 0.662 0.3739 0.000 0.096 0.000 0.228 0.524 0.152
#> GSM39839 3 0.415 0.6649 0.232 0.008 0.720 0.040 0.000 0.000
#> GSM39840 1 0.235 0.8378 0.876 0.004 0.008 0.112 0.000 0.000
#> GSM39841 1 0.409 0.7429 0.776 0.016 0.008 0.048 0.152 0.000
#> GSM39842 1 0.201 0.7899 0.904 0.084 0.008 0.004 0.000 0.000
#> GSM39843 1 0.335 0.7254 0.776 0.008 0.008 0.208 0.000 0.000
#> GSM39844 1 0.201 0.7899 0.904 0.084 0.008 0.004 0.000 0.000
#> GSM39845 3 0.470 0.6415 0.220 0.004 0.680 0.096 0.000 0.000
#> GSM39852 4 0.230 0.7409 0.120 0.000 0.008 0.872 0.000 0.000
#> GSM39853 5 0.551 0.3713 0.004 0.236 0.000 0.180 0.580 0.000
#> GSM39854 2 0.663 0.4433 0.060 0.484 0.000 0.188 0.268 0.000
#> GSM39857 3 0.459 0.6322 0.028 0.024 0.752 0.040 0.000 0.156
#> GSM39860 6 0.026 0.4942 0.000 0.000 0.008 0.000 0.000 0.992
#> GSM39861 3 0.315 0.7147 0.132 0.000 0.824 0.044 0.000 0.000
#> GSM39864 4 0.552 0.5039 0.296 0.008 0.068 0.600 0.000 0.028
#> GSM39868 4 0.254 0.7382 0.068 0.028 0.016 0.888 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> MAD:hclust 50 NA 9.79e-01 2
#> MAD:hclust 31 NA 5.33e-01 3
#> MAD:hclust 50 5.87e-04 1.13e-02 4
#> MAD:hclust 37 2.46e-04 1.63e-03 5
#> MAD:hclust 42 4.01e-09 1.78e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.258 0.495 0.704 0.4463 0.627 0.627
#> 3 3 0.714 0.831 0.896 0.4117 0.687 0.517
#> 4 4 0.579 0.522 0.761 0.1393 0.915 0.779
#> 5 5 0.574 0.458 0.708 0.0838 0.849 0.577
#> 6 6 0.638 0.467 0.657 0.0452 0.878 0.565
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0672 0.6898 0.008 0.992
#> GSM39874 2 0.0672 0.6898 0.008 0.992
#> GSM39875 2 0.0672 0.6898 0.008 0.992
#> GSM39876 2 0.0672 0.6898 0.008 0.992
#> GSM39831 1 0.7219 0.6273 0.800 0.200
#> GSM39819 1 0.6887 0.4862 0.816 0.184
#> GSM39820 1 0.6887 0.4862 0.816 0.184
#> GSM39821 1 0.7376 0.6241 0.792 0.208
#> GSM39822 2 0.5946 0.6270 0.144 0.856
#> GSM39823 1 0.9732 0.2478 0.596 0.404
#> GSM39824 2 0.8327 0.4660 0.264 0.736
#> GSM39825 1 0.7139 0.4773 0.804 0.196
#> GSM39826 1 0.7528 0.6167 0.784 0.216
#> GSM39827 1 0.7528 0.6167 0.784 0.216
#> GSM39846 1 0.9732 0.2478 0.596 0.404
#> GSM39847 1 0.7219 0.6273 0.800 0.200
#> GSM39848 2 0.5842 0.6290 0.140 0.860
#> GSM39849 1 0.9732 0.2478 0.596 0.404
#> GSM39850 1 0.7376 0.6241 0.792 0.208
#> GSM39851 1 0.7376 0.6241 0.792 0.208
#> GSM39855 2 0.8327 0.4660 0.264 0.736
#> GSM39856 1 0.9732 0.2478 0.596 0.404
#> GSM39858 1 0.9491 0.3020 0.632 0.368
#> GSM39859 1 0.9491 0.3020 0.632 0.368
#> GSM39862 1 0.9970 0.2995 0.532 0.468
#> GSM39863 1 0.7219 0.6273 0.800 0.200
#> GSM39865 2 0.0376 0.6877 0.004 0.996
#> GSM39866 1 0.8327 0.6081 0.736 0.264
#> GSM39867 1 0.9323 0.4013 0.652 0.348
#> GSM39869 2 0.6148 0.6193 0.152 0.848
#> GSM39870 1 0.6887 0.4862 0.816 0.184
#> GSM39871 1 0.9580 0.2856 0.620 0.380
#> GSM39872 1 0.9661 0.2679 0.608 0.392
#> GSM39828 1 0.6973 0.6288 0.812 0.188
#> GSM39829 1 0.6048 0.5013 0.852 0.148
#> GSM39830 1 0.0376 0.5593 0.996 0.004
#> GSM39832 1 0.7376 0.6241 0.792 0.208
#> GSM39833 1 0.9358 0.5046 0.648 0.352
#> GSM39834 1 0.6973 0.6288 0.812 0.188
#> GSM39835 1 0.9170 0.4468 0.668 0.332
#> GSM39836 1 0.7376 0.6241 0.792 0.208
#> GSM39837 2 0.9933 0.1524 0.452 0.548
#> GSM39838 2 0.9754 0.2521 0.408 0.592
#> GSM39839 1 0.6887 0.4862 0.816 0.184
#> GSM39840 1 0.7376 0.6241 0.792 0.208
#> GSM39841 1 0.7602 0.6123 0.780 0.220
#> GSM39842 1 0.7376 0.6241 0.792 0.208
#> GSM39843 1 0.6623 0.6264 0.828 0.172
#> GSM39844 1 0.7376 0.6241 0.792 0.208
#> GSM39845 1 0.8763 0.3875 0.704 0.296
#> GSM39852 1 0.7219 0.6273 0.800 0.200
#> GSM39853 2 0.9944 0.1408 0.456 0.544
#> GSM39854 1 0.9993 -0.0116 0.516 0.484
#> GSM39857 1 0.9732 0.2478 0.596 0.404
#> GSM39860 2 0.7299 0.5156 0.204 0.796
#> GSM39861 1 0.8763 0.3875 0.704 0.296
#> GSM39864 1 0.6973 0.6288 0.812 0.188
#> GSM39868 1 0.6973 0.6288 0.812 0.188
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.304 0.777 0.000 0.896 0.104
#> GSM39874 2 0.304 0.777 0.000 0.896 0.104
#> GSM39875 2 0.304 0.777 0.000 0.896 0.104
#> GSM39876 2 0.304 0.777 0.000 0.896 0.104
#> GSM39831 1 0.140 0.908 0.968 0.004 0.028
#> GSM39819 3 0.348 0.887 0.128 0.000 0.872
#> GSM39820 3 0.341 0.889 0.124 0.000 0.876
#> GSM39821 1 0.238 0.911 0.940 0.044 0.016
#> GSM39822 2 0.293 0.792 0.040 0.924 0.036
#> GSM39823 3 0.101 0.926 0.008 0.012 0.980
#> GSM39824 3 0.134 0.905 0.016 0.012 0.972
#> GSM39825 3 0.385 0.890 0.108 0.016 0.876
#> GSM39826 1 0.199 0.901 0.948 0.048 0.004
#> GSM39827 1 0.227 0.912 0.944 0.040 0.016
#> GSM39846 3 0.134 0.930 0.016 0.012 0.972
#> GSM39847 1 0.238 0.911 0.940 0.044 0.016
#> GSM39848 2 0.304 0.793 0.036 0.920 0.044
#> GSM39849 3 0.134 0.930 0.016 0.012 0.972
#> GSM39850 1 0.175 0.903 0.952 0.048 0.000
#> GSM39851 1 0.158 0.910 0.964 0.008 0.028
#> GSM39855 3 0.134 0.905 0.016 0.012 0.972
#> GSM39856 3 0.134 0.930 0.016 0.012 0.972
#> GSM39858 3 0.116 0.934 0.028 0.000 0.972
#> GSM39859 3 0.116 0.934 0.028 0.000 0.972
#> GSM39862 1 0.751 0.533 0.644 0.068 0.288
#> GSM39863 1 0.140 0.908 0.968 0.004 0.028
#> GSM39865 2 0.318 0.792 0.024 0.912 0.064
#> GSM39866 1 0.318 0.885 0.912 0.024 0.064
#> GSM39867 1 0.383 0.855 0.868 0.124 0.008
#> GSM39869 2 0.243 0.791 0.024 0.940 0.036
#> GSM39870 3 0.341 0.889 0.124 0.000 0.876
#> GSM39871 3 0.116 0.934 0.028 0.000 0.972
#> GSM39872 3 0.219 0.917 0.024 0.028 0.948
#> GSM39828 1 0.178 0.914 0.960 0.020 0.020
#> GSM39829 3 0.424 0.827 0.176 0.000 0.824
#> GSM39830 1 0.614 0.244 0.596 0.000 0.404
#> GSM39832 1 0.268 0.902 0.932 0.040 0.028
#> GSM39833 1 0.327 0.886 0.912 0.044 0.044
#> GSM39834 1 0.321 0.904 0.912 0.060 0.028
#> GSM39835 1 0.345 0.868 0.888 0.104 0.008
#> GSM39836 1 0.199 0.901 0.948 0.048 0.004
#> GSM39837 2 0.627 0.278 0.452 0.548 0.000
#> GSM39838 2 0.729 0.347 0.408 0.560 0.032
#> GSM39839 3 0.341 0.890 0.124 0.000 0.876
#> GSM39840 1 0.162 0.911 0.964 0.012 0.024
#> GSM39841 1 0.175 0.910 0.960 0.012 0.028
#> GSM39842 1 0.268 0.902 0.932 0.040 0.028
#> GSM39843 1 0.116 0.908 0.972 0.000 0.028
#> GSM39844 1 0.268 0.902 0.932 0.040 0.028
#> GSM39845 3 0.153 0.932 0.040 0.000 0.960
#> GSM39852 1 0.249 0.902 0.932 0.060 0.008
#> GSM39853 2 0.619 0.302 0.420 0.580 0.000
#> GSM39854 1 0.410 0.836 0.852 0.140 0.008
#> GSM39857 3 0.101 0.926 0.008 0.012 0.980
#> GSM39860 2 0.657 0.472 0.016 0.636 0.348
#> GSM39861 3 0.153 0.932 0.040 0.000 0.960
#> GSM39864 1 0.219 0.906 0.948 0.024 0.028
#> GSM39868 1 0.255 0.910 0.936 0.040 0.024
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0469 0.7246 0.000 0.988 0.012 0.000
#> GSM39874 2 0.0469 0.7246 0.000 0.988 0.012 0.000
#> GSM39875 2 0.0469 0.7246 0.000 0.988 0.012 0.000
#> GSM39876 2 0.0469 0.7246 0.000 0.988 0.012 0.000
#> GSM39831 1 0.4713 0.4257 0.640 0.000 0.000 0.360
#> GSM39819 3 0.4467 0.7724 0.040 0.000 0.788 0.172
#> GSM39820 3 0.4417 0.7750 0.044 0.000 0.796 0.160
#> GSM39821 1 0.0000 0.5951 1.000 0.000 0.000 0.000
#> GSM39822 2 0.4019 0.7101 0.012 0.792 0.000 0.196
#> GSM39823 3 0.2081 0.8180 0.000 0.000 0.916 0.084
#> GSM39824 3 0.3726 0.7266 0.000 0.000 0.788 0.212
#> GSM39825 3 0.4985 0.7271 0.148 0.008 0.780 0.064
#> GSM39826 1 0.0817 0.5876 0.976 0.000 0.000 0.024
#> GSM39827 1 0.3074 0.5499 0.848 0.000 0.000 0.152
#> GSM39846 3 0.0336 0.8415 0.000 0.000 0.992 0.008
#> GSM39847 1 0.0336 0.5956 0.992 0.000 0.000 0.008
#> GSM39848 2 0.6055 0.5694 0.052 0.576 0.000 0.372
#> GSM39849 3 0.2408 0.8254 0.000 0.000 0.896 0.104
#> GSM39850 1 0.0469 0.5924 0.988 0.000 0.000 0.012
#> GSM39851 1 0.3837 0.5343 0.776 0.000 0.000 0.224
#> GSM39855 3 0.3837 0.7150 0.000 0.000 0.776 0.224
#> GSM39856 3 0.0336 0.8415 0.000 0.000 0.992 0.008
#> GSM39858 3 0.0000 0.8424 0.000 0.000 1.000 0.000
#> GSM39859 3 0.0000 0.8424 0.000 0.000 1.000 0.000
#> GSM39862 1 0.6882 0.0250 0.492 0.008 0.080 0.420
#> GSM39863 1 0.4713 0.4257 0.640 0.000 0.000 0.360
#> GSM39865 2 0.4746 0.6789 0.008 0.712 0.004 0.276
#> GSM39866 1 0.4923 0.5037 0.684 0.008 0.004 0.304
#> GSM39867 1 0.5543 0.1066 0.556 0.020 0.000 0.424
#> GSM39869 2 0.4228 0.6997 0.008 0.760 0.000 0.232
#> GSM39870 3 0.4417 0.7750 0.044 0.000 0.796 0.160
#> GSM39871 3 0.0469 0.8417 0.000 0.000 0.988 0.012
#> GSM39872 3 0.5137 0.7054 0.036 0.008 0.740 0.216
#> GSM39828 1 0.1716 0.5825 0.936 0.000 0.000 0.064
#> GSM39829 3 0.4893 0.7509 0.064 0.000 0.768 0.168
#> GSM39830 3 0.7613 0.1826 0.352 0.000 0.440 0.208
#> GSM39832 1 0.5158 0.1635 0.524 0.004 0.000 0.472
#> GSM39833 1 0.3224 0.5294 0.864 0.000 0.016 0.120
#> GSM39834 1 0.4049 0.5100 0.780 0.008 0.000 0.212
#> GSM39835 4 0.5409 -0.3259 0.492 0.012 0.000 0.496
#> GSM39836 1 0.1474 0.5803 0.948 0.000 0.000 0.052
#> GSM39837 2 0.6840 0.1609 0.432 0.468 0.000 0.100
#> GSM39838 1 0.7732 -0.2008 0.444 0.288 0.000 0.268
#> GSM39839 3 0.4467 0.7724 0.040 0.000 0.788 0.172
#> GSM39840 1 0.4356 0.4739 0.708 0.000 0.000 0.292
#> GSM39841 1 0.4746 0.4181 0.632 0.000 0.000 0.368
#> GSM39842 4 0.5158 -0.3906 0.472 0.004 0.000 0.524
#> GSM39843 1 0.3074 0.5654 0.848 0.000 0.000 0.152
#> GSM39844 1 0.5158 0.1635 0.524 0.004 0.000 0.472
#> GSM39845 3 0.0000 0.8424 0.000 0.000 1.000 0.000
#> GSM39852 1 0.2737 0.5510 0.888 0.008 0.000 0.104
#> GSM39853 2 0.7659 0.0964 0.332 0.444 0.000 0.224
#> GSM39854 1 0.5650 0.0817 0.544 0.024 0.000 0.432
#> GSM39857 3 0.2081 0.8180 0.000 0.000 0.916 0.084
#> GSM39860 4 0.8206 -0.4731 0.012 0.364 0.256 0.368
#> GSM39861 3 0.0921 0.8401 0.000 0.000 0.972 0.028
#> GSM39864 1 0.4722 0.5103 0.692 0.008 0.000 0.300
#> GSM39868 1 0.4011 0.5238 0.784 0.008 0.000 0.208
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0162 0.7309 0.000 0.996 0.004 0.000 0.000
#> GSM39874 2 0.0162 0.7309 0.000 0.996 0.004 0.000 0.000
#> GSM39875 2 0.0162 0.7309 0.000 0.996 0.004 0.000 0.000
#> GSM39876 2 0.0162 0.7309 0.000 0.996 0.004 0.000 0.000
#> GSM39831 1 0.0162 0.6064 0.996 0.000 0.000 0.004 0.000
#> GSM39819 3 0.5518 0.6647 0.176 0.000 0.704 0.048 0.072
#> GSM39820 3 0.4761 0.6901 0.160 0.000 0.756 0.028 0.056
#> GSM39821 4 0.3876 0.4745 0.316 0.000 0.000 0.684 0.000
#> GSM39822 2 0.5964 0.1326 0.000 0.536 0.000 0.124 0.340
#> GSM39823 3 0.3170 0.6832 0.000 0.004 0.828 0.008 0.160
#> GSM39824 3 0.4434 0.4409 0.000 0.004 0.640 0.008 0.348
#> GSM39825 3 0.4653 0.6466 0.028 0.000 0.776 0.116 0.080
#> GSM39826 4 0.4183 0.4715 0.324 0.000 0.000 0.668 0.008
#> GSM39827 1 0.4582 -0.1043 0.572 0.000 0.000 0.416 0.012
#> GSM39846 3 0.0798 0.7597 0.000 0.000 0.976 0.008 0.016
#> GSM39847 4 0.4047 0.4681 0.320 0.000 0.000 0.676 0.004
#> GSM39848 5 0.5164 0.4977 0.000 0.232 0.000 0.096 0.672
#> GSM39849 3 0.3758 0.7093 0.004 0.000 0.816 0.052 0.128
#> GSM39850 4 0.4183 0.4715 0.324 0.000 0.000 0.668 0.008
#> GSM39851 1 0.3579 0.3992 0.756 0.000 0.000 0.240 0.004
#> GSM39855 3 0.4530 0.3959 0.000 0.004 0.612 0.008 0.376
#> GSM39856 3 0.0898 0.7589 0.000 0.000 0.972 0.008 0.020
#> GSM39858 3 0.0671 0.7618 0.000 0.000 0.980 0.004 0.016
#> GSM39859 3 0.0404 0.7617 0.000 0.000 0.988 0.000 0.012
#> GSM39862 5 0.4920 0.3704 0.020 0.000 0.020 0.300 0.660
#> GSM39863 1 0.0162 0.6064 0.996 0.000 0.000 0.004 0.000
#> GSM39865 5 0.5546 -0.0431 0.000 0.436 0.000 0.068 0.496
#> GSM39866 1 0.5284 0.3063 0.660 0.000 0.000 0.236 0.104
#> GSM39867 4 0.6841 -0.0685 0.368 0.016 0.000 0.440 0.176
#> GSM39869 2 0.5836 -0.0319 0.000 0.492 0.000 0.096 0.412
#> GSM39870 3 0.4761 0.6901 0.160 0.000 0.756 0.028 0.056
#> GSM39871 3 0.0451 0.7620 0.000 0.000 0.988 0.008 0.004
#> GSM39872 3 0.6195 0.1977 0.000 0.000 0.488 0.144 0.368
#> GSM39828 4 0.5415 0.3243 0.384 0.000 0.000 0.552 0.064
#> GSM39829 3 0.5208 0.6713 0.180 0.000 0.720 0.032 0.068
#> GSM39830 3 0.7380 0.1423 0.396 0.000 0.404 0.124 0.076
#> GSM39832 1 0.4504 0.5252 0.748 0.000 0.000 0.168 0.084
#> GSM39833 4 0.5877 0.4201 0.288 0.000 0.008 0.596 0.108
#> GSM39834 4 0.6458 0.3412 0.240 0.000 0.000 0.500 0.260
#> GSM39835 1 0.6767 0.0980 0.388 0.000 0.000 0.336 0.276
#> GSM39836 4 0.3890 0.4984 0.252 0.000 0.000 0.736 0.012
#> GSM39837 4 0.7684 0.1852 0.164 0.340 0.000 0.412 0.084
#> GSM39838 4 0.6724 -0.0318 0.048 0.092 0.000 0.492 0.368
#> GSM39839 3 0.5518 0.6647 0.176 0.000 0.704 0.048 0.072
#> GSM39840 1 0.2127 0.5634 0.892 0.000 0.000 0.108 0.000
#> GSM39841 1 0.0404 0.6045 0.988 0.000 0.000 0.012 0.000
#> GSM39842 1 0.4867 0.5066 0.716 0.000 0.000 0.180 0.104
#> GSM39843 1 0.3990 0.2967 0.688 0.000 0.000 0.308 0.004
#> GSM39844 1 0.4504 0.5252 0.748 0.000 0.000 0.168 0.084
#> GSM39845 3 0.0992 0.7624 0.000 0.000 0.968 0.008 0.024
#> GSM39852 4 0.5312 0.4651 0.208 0.000 0.000 0.668 0.124
#> GSM39853 4 0.8286 0.0605 0.208 0.296 0.000 0.352 0.144
#> GSM39854 4 0.6871 -0.0490 0.356 0.016 0.000 0.444 0.184
#> GSM39857 3 0.3250 0.6769 0.000 0.004 0.820 0.008 0.168
#> GSM39860 5 0.5553 0.4656 0.000 0.180 0.132 0.012 0.676
#> GSM39861 3 0.0486 0.7619 0.004 0.000 0.988 0.004 0.004
#> GSM39864 1 0.4901 0.3711 0.708 0.000 0.000 0.196 0.096
#> GSM39868 4 0.6507 0.3384 0.268 0.000 0.000 0.488 0.244
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.5600 0.45584 0.572 0.000 0.000 0.256 0.008 0.164
#> GSM39819 3 0.5000 0.57962 0.080 0.000 0.628 0.004 0.004 0.284
#> GSM39820 3 0.4626 0.58650 0.076 0.000 0.652 0.000 0.000 0.272
#> GSM39821 4 0.0820 0.67081 0.012 0.000 0.000 0.972 0.000 0.016
#> GSM39822 5 0.5199 0.41128 0.000 0.300 0.000 0.120 0.580 0.000
#> GSM39823 3 0.4040 0.61402 0.020 0.000 0.784 0.000 0.092 0.104
#> GSM39824 3 0.5676 0.41433 0.028 0.000 0.604 0.000 0.228 0.140
#> GSM39825 3 0.5322 0.48871 0.004 0.000 0.696 0.076 0.084 0.140
#> GSM39826 4 0.0725 0.67167 0.012 0.000 0.000 0.976 0.000 0.012
#> GSM39827 4 0.4236 0.43682 0.184 0.000 0.000 0.744 0.016 0.056
#> GSM39846 3 0.1155 0.70221 0.004 0.000 0.956 0.000 0.004 0.036
#> GSM39847 4 0.0508 0.66942 0.004 0.000 0.000 0.984 0.000 0.012
#> GSM39848 5 0.4934 0.46031 0.012 0.084 0.000 0.020 0.712 0.172
#> GSM39849 3 0.4847 0.57552 0.040 0.000 0.708 0.004 0.052 0.196
#> GSM39850 4 0.0725 0.67167 0.012 0.000 0.000 0.976 0.000 0.012
#> GSM39851 4 0.4810 0.26360 0.292 0.000 0.000 0.624 0.000 0.084
#> GSM39855 3 0.6099 0.34891 0.032 0.000 0.540 0.000 0.260 0.168
#> GSM39856 3 0.1155 0.70221 0.004 0.000 0.956 0.000 0.004 0.036
#> GSM39858 3 0.0603 0.71170 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM39859 3 0.0000 0.71080 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM39862 5 0.5800 0.04917 0.012 0.000 0.012 0.100 0.532 0.344
#> GSM39863 1 0.5600 0.45584 0.572 0.000 0.000 0.256 0.008 0.164
#> GSM39865 5 0.3633 0.47718 0.000 0.252 0.000 0.004 0.732 0.012
#> GSM39866 6 0.7049 -0.18362 0.348 0.000 0.004 0.228 0.060 0.360
#> GSM39867 1 0.6666 0.16864 0.464 0.004 0.000 0.220 0.272 0.040
#> GSM39869 5 0.4302 0.46176 0.008 0.260 0.000 0.016 0.700 0.016
#> GSM39870 3 0.4788 0.57435 0.072 0.000 0.636 0.004 0.000 0.288
#> GSM39871 3 0.0603 0.70946 0.004 0.000 0.980 0.000 0.000 0.016
#> GSM39872 6 0.6968 0.00405 0.032 0.000 0.360 0.024 0.188 0.396
#> GSM39828 4 0.4116 0.54860 0.048 0.000 0.000 0.776 0.036 0.140
#> GSM39829 3 0.4950 0.51583 0.080 0.000 0.576 0.000 0.000 0.344
#> GSM39830 3 0.7277 0.15586 0.096 0.000 0.352 0.200 0.004 0.348
#> GSM39832 1 0.1910 0.53356 0.892 0.000 0.000 0.108 0.000 0.000
#> GSM39833 4 0.5315 0.48035 0.036 0.000 0.036 0.712 0.076 0.140
#> GSM39834 6 0.6616 0.43137 0.056 0.000 0.000 0.280 0.188 0.476
#> GSM39835 1 0.6556 0.16525 0.528 0.000 0.000 0.088 0.236 0.148
#> GSM39836 4 0.2056 0.61161 0.012 0.000 0.000 0.904 0.004 0.080
#> GSM39837 4 0.6357 -0.08351 0.016 0.212 0.000 0.488 0.276 0.008
#> GSM39838 5 0.6136 0.26853 0.008 0.032 0.000 0.304 0.536 0.120
#> GSM39839 3 0.5000 0.57962 0.080 0.000 0.628 0.004 0.004 0.284
#> GSM39840 1 0.5381 0.18926 0.476 0.000 0.000 0.424 0.004 0.096
#> GSM39841 1 0.5743 0.43178 0.556 0.000 0.000 0.284 0.016 0.144
#> GSM39842 1 0.2365 0.50058 0.896 0.000 0.000 0.068 0.012 0.024
#> GSM39843 4 0.4936 0.35227 0.244 0.000 0.004 0.656 0.004 0.092
#> GSM39844 1 0.1910 0.53356 0.892 0.000 0.000 0.108 0.000 0.000
#> GSM39845 3 0.1265 0.71035 0.000 0.000 0.948 0.000 0.008 0.044
#> GSM39852 4 0.5202 0.10479 0.008 0.000 0.000 0.628 0.124 0.240
#> GSM39853 5 0.8226 0.11353 0.200 0.196 0.000 0.260 0.308 0.036
#> GSM39854 1 0.6739 0.13465 0.444 0.004 0.000 0.236 0.276 0.040
#> GSM39857 3 0.4218 0.60200 0.020 0.000 0.768 0.000 0.096 0.116
#> GSM39860 5 0.6125 0.33007 0.024 0.076 0.076 0.000 0.624 0.200
#> GSM39861 3 0.1152 0.70901 0.000 0.000 0.952 0.000 0.004 0.044
#> GSM39864 1 0.6934 -0.09359 0.368 0.000 0.000 0.232 0.060 0.340
#> GSM39868 6 0.6610 0.41736 0.052 0.000 0.000 0.304 0.184 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> MAD:kmeans 33 3.91e-03 1.97e-03 2
#> MAD:kmeans 53 5.19e-06 1.28e-05 3
#> MAD:kmeans 42 8.32e-05 1.15e-04 4
#> MAD:kmeans 27 1.37e-06 4.20e-06 5
#> MAD:kmeans 28 3.63e-06 8.04e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.492 0.756 0.886 0.5030 0.501 0.501
#> 3 3 0.886 0.921 0.964 0.3340 0.658 0.416
#> 4 4 0.660 0.708 0.848 0.1207 0.883 0.665
#> 5 5 0.681 0.600 0.770 0.0653 0.940 0.774
#> 6 6 0.666 0.591 0.740 0.0402 0.953 0.784
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.4562 0.825 0.096 0.904
#> GSM39874 2 0.4562 0.825 0.096 0.904
#> GSM39875 2 0.4562 0.825 0.096 0.904
#> GSM39876 2 0.4562 0.825 0.096 0.904
#> GSM39831 1 0.0000 0.860 1.000 0.000
#> GSM39819 1 0.9866 0.352 0.568 0.432
#> GSM39820 1 0.9866 0.352 0.568 0.432
#> GSM39821 1 0.0376 0.859 0.996 0.004
#> GSM39822 2 0.9580 0.462 0.380 0.620
#> GSM39823 2 0.1414 0.857 0.020 0.980
#> GSM39824 2 0.0000 0.853 0.000 1.000
#> GSM39825 2 0.3879 0.831 0.076 0.924
#> GSM39826 1 0.1414 0.853 0.980 0.020
#> GSM39827 1 0.0000 0.860 1.000 0.000
#> GSM39846 2 0.1414 0.857 0.020 0.980
#> GSM39847 1 0.0000 0.860 1.000 0.000
#> GSM39848 2 0.9522 0.478 0.372 0.628
#> GSM39849 2 0.1414 0.857 0.020 0.980
#> GSM39850 1 0.1414 0.853 0.980 0.020
#> GSM39851 1 0.0000 0.860 1.000 0.000
#> GSM39855 2 0.0000 0.853 0.000 1.000
#> GSM39856 2 0.1414 0.857 0.020 0.980
#> GSM39858 2 0.3733 0.834 0.072 0.928
#> GSM39859 2 0.3733 0.834 0.072 0.928
#> GSM39862 2 0.8955 0.527 0.312 0.688
#> GSM39863 1 0.0000 0.860 1.000 0.000
#> GSM39865 2 0.4562 0.825 0.096 0.904
#> GSM39866 1 0.7745 0.666 0.772 0.228
#> GSM39867 1 0.1414 0.853 0.980 0.020
#> GSM39869 2 0.9732 0.409 0.404 0.596
#> GSM39870 1 0.9866 0.352 0.568 0.432
#> GSM39871 2 0.1414 0.857 0.020 0.980
#> GSM39872 2 0.1414 0.857 0.020 0.980
#> GSM39828 1 0.1843 0.850 0.972 0.028
#> GSM39829 1 0.9754 0.401 0.592 0.408
#> GSM39830 1 0.6973 0.731 0.812 0.188
#> GSM39832 1 0.0000 0.860 1.000 0.000
#> GSM39833 2 0.9635 0.445 0.388 0.612
#> GSM39834 1 0.4298 0.835 0.912 0.088
#> GSM39835 1 0.8608 0.527 0.716 0.284
#> GSM39836 1 0.1414 0.853 0.980 0.020
#> GSM39837 1 0.3733 0.822 0.928 0.072
#> GSM39838 1 0.8016 0.609 0.756 0.244
#> GSM39839 1 0.9866 0.352 0.568 0.432
#> GSM39840 1 0.0000 0.860 1.000 0.000
#> GSM39841 1 0.0000 0.860 1.000 0.000
#> GSM39842 1 0.0000 0.860 1.000 0.000
#> GSM39843 1 0.2423 0.844 0.960 0.040
#> GSM39844 1 0.0000 0.860 1.000 0.000
#> GSM39845 2 0.3733 0.834 0.072 0.928
#> GSM39852 1 0.1414 0.853 0.980 0.020
#> GSM39853 1 0.3733 0.822 0.928 0.072
#> GSM39854 1 0.3733 0.822 0.928 0.072
#> GSM39857 2 0.1414 0.857 0.020 0.980
#> GSM39860 2 0.0000 0.853 0.000 1.000
#> GSM39861 2 0.3733 0.834 0.072 0.928
#> GSM39864 1 0.4431 0.811 0.908 0.092
#> GSM39868 1 0.4562 0.807 0.904 0.096
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39831 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39819 3 0.0424 0.975 0.008 0.000 0.992
#> GSM39820 3 0.0424 0.975 0.008 0.000 0.992
#> GSM39821 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39822 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39823 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39824 3 0.0237 0.977 0.000 0.004 0.996
#> GSM39825 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39826 1 0.0237 0.957 0.996 0.004 0.000
#> GSM39827 1 0.0237 0.958 0.996 0.004 0.000
#> GSM39846 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39847 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39848 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39849 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39850 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39851 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39855 3 0.1411 0.948 0.000 0.036 0.964
#> GSM39856 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39862 2 0.5803 0.692 0.248 0.736 0.016
#> GSM39863 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39865 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39866 1 0.3752 0.811 0.856 0.000 0.144
#> GSM39867 1 0.6126 0.304 0.600 0.400 0.000
#> GSM39869 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39870 3 0.0424 0.975 0.008 0.000 0.992
#> GSM39871 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39872 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39828 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39829 3 0.1163 0.957 0.028 0.000 0.972
#> GSM39830 3 0.5291 0.639 0.268 0.000 0.732
#> GSM39832 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39833 2 0.1015 0.928 0.012 0.980 0.008
#> GSM39834 1 0.2846 0.899 0.924 0.056 0.020
#> GSM39835 2 0.4504 0.773 0.196 0.804 0.000
#> GSM39836 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39837 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39838 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39839 3 0.0237 0.977 0.004 0.000 0.996
#> GSM39840 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39841 1 0.3752 0.821 0.856 0.144 0.000
#> GSM39842 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39843 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39844 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39845 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39852 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39853 2 0.0000 0.938 0.000 1.000 0.000
#> GSM39854 2 0.5138 0.680 0.252 0.748 0.000
#> GSM39857 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39860 2 0.4399 0.756 0.000 0.812 0.188
#> GSM39861 3 0.0000 0.979 0.000 0.000 1.000
#> GSM39864 1 0.0000 0.960 1.000 0.000 0.000
#> GSM39868 1 0.0424 0.954 0.992 0.000 0.008
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.9027 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.9027 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.9027 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.9027 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0592 0.7129 0.984 0.000 0.000 0.016
#> GSM39819 3 0.3945 0.7473 0.216 0.000 0.780 0.004
#> GSM39820 3 0.4137 0.7502 0.208 0.000 0.780 0.012
#> GSM39821 4 0.3123 0.8133 0.156 0.000 0.000 0.844
#> GSM39822 2 0.0000 0.9027 0.000 1.000 0.000 0.000
#> GSM39823 3 0.1302 0.8602 0.000 0.000 0.956 0.044
#> GSM39824 3 0.2300 0.8465 0.000 0.028 0.924 0.048
#> GSM39825 3 0.2831 0.8075 0.004 0.000 0.876 0.120
#> GSM39826 4 0.3123 0.8135 0.156 0.000 0.000 0.844
#> GSM39827 1 0.3942 0.5531 0.764 0.000 0.000 0.236
#> GSM39846 3 0.0469 0.8658 0.000 0.000 0.988 0.012
#> GSM39847 4 0.2973 0.8171 0.144 0.000 0.000 0.856
#> GSM39848 2 0.1474 0.8825 0.000 0.948 0.000 0.052
#> GSM39849 3 0.1302 0.8607 0.000 0.000 0.956 0.044
#> GSM39850 4 0.3074 0.8154 0.152 0.000 0.000 0.848
#> GSM39851 1 0.4746 0.2543 0.632 0.000 0.000 0.368
#> GSM39855 3 0.3081 0.8233 0.000 0.064 0.888 0.048
#> GSM39856 3 0.0707 0.8649 0.000 0.000 0.980 0.020
#> GSM39858 3 0.0000 0.8663 0.000 0.000 1.000 0.000
#> GSM39859 3 0.0000 0.8663 0.000 0.000 1.000 0.000
#> GSM39862 4 0.5262 0.5787 0.008 0.128 0.096 0.768
#> GSM39863 1 0.0592 0.7129 0.984 0.000 0.000 0.016
#> GSM39865 2 0.0469 0.8999 0.000 0.988 0.000 0.012
#> GSM39866 1 0.4776 0.5963 0.776 0.000 0.060 0.164
#> GSM39867 1 0.6219 0.4560 0.640 0.264 0.000 0.096
#> GSM39869 2 0.0188 0.9019 0.000 0.996 0.000 0.004
#> GSM39870 3 0.4245 0.7562 0.196 0.000 0.784 0.020
#> GSM39871 3 0.0000 0.8663 0.000 0.000 1.000 0.000
#> GSM39872 3 0.4335 0.6939 0.004 0.004 0.752 0.240
#> GSM39828 4 0.3610 0.7678 0.200 0.000 0.000 0.800
#> GSM39829 3 0.4630 0.6993 0.252 0.000 0.732 0.016
#> GSM39830 3 0.7586 0.0552 0.388 0.000 0.416 0.196
#> GSM39832 1 0.0000 0.7136 1.000 0.000 0.000 0.000
#> GSM39833 2 0.8126 0.3032 0.108 0.528 0.072 0.292
#> GSM39834 4 0.4820 0.5080 0.296 0.000 0.012 0.692
#> GSM39835 1 0.6296 0.2609 0.548 0.388 0.000 0.064
#> GSM39836 4 0.2408 0.8118 0.104 0.000 0.000 0.896
#> GSM39837 2 0.1305 0.8873 0.004 0.960 0.000 0.036
#> GSM39838 2 0.3764 0.7214 0.000 0.784 0.000 0.216
#> GSM39839 3 0.3908 0.7507 0.212 0.000 0.784 0.004
#> GSM39840 1 0.3266 0.6145 0.832 0.000 0.000 0.168
#> GSM39841 1 0.1284 0.7114 0.964 0.012 0.000 0.024
#> GSM39842 1 0.0188 0.7128 0.996 0.000 0.000 0.004
#> GSM39843 1 0.4998 -0.1185 0.512 0.000 0.000 0.488
#> GSM39844 1 0.0000 0.7136 1.000 0.000 0.000 0.000
#> GSM39845 3 0.0000 0.8663 0.000 0.000 1.000 0.000
#> GSM39852 4 0.2011 0.7901 0.080 0.000 0.000 0.920
#> GSM39853 2 0.1820 0.8747 0.036 0.944 0.000 0.020
#> GSM39854 1 0.6503 0.0861 0.480 0.448 0.000 0.072
#> GSM39857 3 0.1389 0.8592 0.000 0.000 0.952 0.048
#> GSM39860 2 0.5783 0.6511 0.000 0.708 0.172 0.120
#> GSM39861 3 0.0188 0.8657 0.000 0.000 0.996 0.004
#> GSM39864 1 0.3172 0.6404 0.840 0.000 0.000 0.160
#> GSM39868 4 0.4431 0.5335 0.304 0.000 0.000 0.696
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.8455 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.8455 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.8455 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.8455 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.2782 0.7205 0.880 0.000 0.000 0.048 0.072
#> GSM39819 3 0.4737 0.6174 0.064 0.000 0.732 0.008 0.196
#> GSM39820 3 0.4404 0.6263 0.040 0.000 0.748 0.008 0.204
#> GSM39821 4 0.1484 0.7851 0.048 0.000 0.000 0.944 0.008
#> GSM39822 2 0.0290 0.8449 0.000 0.992 0.000 0.000 0.008
#> GSM39823 3 0.3661 0.5721 0.000 0.000 0.724 0.000 0.276
#> GSM39824 3 0.4503 0.4906 0.000 0.024 0.664 0.000 0.312
#> GSM39825 3 0.5112 0.4696 0.004 0.000 0.680 0.076 0.240
#> GSM39826 4 0.1710 0.7765 0.040 0.004 0.000 0.940 0.016
#> GSM39827 1 0.4787 0.4389 0.640 0.000 0.000 0.324 0.036
#> GSM39846 3 0.1732 0.7010 0.000 0.000 0.920 0.000 0.080
#> GSM39847 4 0.1408 0.7841 0.044 0.000 0.000 0.948 0.008
#> GSM39848 2 0.3790 0.6138 0.000 0.724 0.000 0.004 0.272
#> GSM39849 3 0.4066 0.5418 0.000 0.000 0.672 0.004 0.324
#> GSM39850 4 0.1124 0.7813 0.036 0.000 0.000 0.960 0.004
#> GSM39851 4 0.5470 0.3496 0.364 0.000 0.000 0.564 0.072
#> GSM39855 3 0.5053 0.4250 0.000 0.052 0.624 0.000 0.324
#> GSM39856 3 0.2230 0.6832 0.000 0.000 0.884 0.000 0.116
#> GSM39858 3 0.0404 0.7103 0.000 0.000 0.988 0.000 0.012
#> GSM39859 3 0.0794 0.7098 0.000 0.000 0.972 0.000 0.028
#> GSM39862 5 0.6220 0.4726 0.004 0.060 0.072 0.224 0.640
#> GSM39863 1 0.2843 0.7208 0.876 0.000 0.000 0.048 0.076
#> GSM39865 2 0.1965 0.8038 0.000 0.904 0.000 0.000 0.096
#> GSM39866 1 0.6698 0.4777 0.588 0.004 0.044 0.132 0.232
#> GSM39867 1 0.4785 0.6077 0.756 0.160 0.000 0.048 0.036
#> GSM39869 2 0.1121 0.8337 0.000 0.956 0.000 0.000 0.044
#> GSM39870 3 0.4774 0.6175 0.044 0.000 0.732 0.020 0.204
#> GSM39871 3 0.1197 0.7074 0.000 0.000 0.952 0.000 0.048
#> GSM39872 5 0.4763 0.2162 0.000 0.000 0.336 0.032 0.632
#> GSM39828 4 0.4069 0.7214 0.088 0.000 0.004 0.800 0.108
#> GSM39829 3 0.5223 0.5757 0.068 0.000 0.680 0.012 0.240
#> GSM39830 3 0.8459 0.0599 0.204 0.000 0.344 0.204 0.248
#> GSM39832 1 0.0324 0.7344 0.992 0.000 0.000 0.004 0.004
#> GSM39833 2 0.8636 -0.1105 0.100 0.336 0.024 0.300 0.240
#> GSM39834 5 0.6351 0.3173 0.156 0.004 0.004 0.288 0.548
#> GSM39835 1 0.6622 0.4284 0.584 0.220 0.000 0.040 0.156
#> GSM39836 4 0.1444 0.7513 0.012 0.000 0.000 0.948 0.040
#> GSM39837 2 0.2032 0.8140 0.004 0.924 0.000 0.052 0.020
#> GSM39838 2 0.4796 0.6452 0.000 0.728 0.000 0.152 0.120
#> GSM39839 3 0.4737 0.6174 0.064 0.000 0.732 0.008 0.196
#> GSM39840 1 0.4428 0.4972 0.700 0.000 0.000 0.268 0.032
#> GSM39841 1 0.3248 0.7166 0.856 0.004 0.000 0.052 0.088
#> GSM39842 1 0.0898 0.7306 0.972 0.000 0.000 0.008 0.020
#> GSM39843 4 0.5351 0.5396 0.280 0.000 0.008 0.644 0.068
#> GSM39844 1 0.0324 0.7344 0.992 0.000 0.000 0.004 0.004
#> GSM39845 3 0.1357 0.7043 0.000 0.000 0.948 0.004 0.048
#> GSM39852 4 0.3728 0.4754 0.008 0.000 0.000 0.748 0.244
#> GSM39853 2 0.3478 0.7485 0.100 0.848 0.000 0.028 0.024
#> GSM39854 1 0.6071 0.3148 0.556 0.352 0.000 0.048 0.044
#> GSM39857 3 0.3816 0.5310 0.000 0.000 0.696 0.000 0.304
#> GSM39860 5 0.6407 0.2938 0.000 0.304 0.176 0.004 0.516
#> GSM39861 3 0.1121 0.7115 0.000 0.000 0.956 0.000 0.044
#> GSM39864 1 0.5278 0.6074 0.696 0.000 0.008 0.116 0.180
#> GSM39868 5 0.6708 0.1579 0.168 0.000 0.012 0.368 0.452
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.0000 0.7733 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39874 5 0.0000 0.7733 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39875 5 0.0000 0.7733 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39876 5 0.0000 0.7733 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39831 1 0.3299 0.6824 0.820 0.140 0.000 0.028 0.000 0.012
#> GSM39819 2 0.4371 0.7901 0.036 0.620 0.344 0.000 0.000 0.000
#> GSM39820 2 0.4688 0.7683 0.028 0.572 0.388 0.000 0.000 0.012
#> GSM39821 4 0.0551 0.7521 0.004 0.004 0.000 0.984 0.000 0.008
#> GSM39822 5 0.1461 0.7665 0.000 0.016 0.000 0.000 0.940 0.044
#> GSM39823 3 0.3588 0.6751 0.000 0.060 0.788 0.000 0.000 0.152
#> GSM39824 3 0.3300 0.6666 0.000 0.016 0.812 0.000 0.016 0.156
#> GSM39825 3 0.6147 0.3807 0.008 0.160 0.584 0.040 0.000 0.208
#> GSM39826 4 0.1059 0.7463 0.016 0.004 0.000 0.964 0.000 0.016
#> GSM39827 1 0.5778 0.3546 0.544 0.060 0.000 0.336 0.000 0.060
#> GSM39846 3 0.1700 0.6915 0.000 0.080 0.916 0.000 0.000 0.004
#> GSM39847 4 0.1434 0.7509 0.008 0.024 0.000 0.948 0.000 0.020
#> GSM39848 5 0.5090 0.3047 0.000 0.040 0.008 0.008 0.508 0.436
#> GSM39849 3 0.4943 0.5278 0.004 0.148 0.680 0.004 0.000 0.164
#> GSM39850 4 0.0767 0.7516 0.012 0.004 0.000 0.976 0.000 0.008
#> GSM39851 4 0.5648 0.3524 0.312 0.120 0.000 0.552 0.000 0.016
#> GSM39855 3 0.3721 0.6421 0.000 0.016 0.784 0.000 0.032 0.168
#> GSM39856 3 0.1411 0.7058 0.000 0.060 0.936 0.000 0.000 0.004
#> GSM39858 3 0.2558 0.6137 0.000 0.156 0.840 0.000 0.000 0.004
#> GSM39859 3 0.2070 0.6866 0.000 0.092 0.896 0.000 0.000 0.012
#> GSM39862 6 0.4794 0.5474 0.000 0.016 0.112 0.076 0.044 0.752
#> GSM39863 1 0.3339 0.6804 0.816 0.144 0.000 0.028 0.000 0.012
#> GSM39865 5 0.3712 0.6687 0.000 0.032 0.004 0.000 0.760 0.204
#> GSM39866 1 0.7286 0.3256 0.420 0.288 0.008 0.104 0.000 0.180
#> GSM39867 1 0.5027 0.5961 0.744 0.060 0.000 0.032 0.056 0.108
#> GSM39869 5 0.3695 0.6923 0.004 0.044 0.000 0.000 0.776 0.176
#> GSM39870 2 0.4886 0.7488 0.024 0.576 0.376 0.004 0.000 0.020
#> GSM39871 3 0.1918 0.6968 0.000 0.088 0.904 0.000 0.000 0.008
#> GSM39872 6 0.5368 0.1718 0.004 0.084 0.396 0.004 0.000 0.512
#> GSM39828 4 0.5529 0.6224 0.084 0.100 0.000 0.668 0.000 0.148
#> GSM39829 2 0.5104 0.7541 0.032 0.628 0.288 0.000 0.000 0.052
#> GSM39830 2 0.6283 0.5338 0.112 0.616 0.144 0.116 0.000 0.012
#> GSM39832 1 0.0665 0.7027 0.980 0.008 0.000 0.008 0.000 0.004
#> GSM39833 5 0.8900 0.0063 0.076 0.108 0.056 0.260 0.356 0.144
#> GSM39834 6 0.5706 0.4738 0.052 0.172 0.004 0.112 0.004 0.656
#> GSM39835 1 0.6630 0.4362 0.576 0.084 0.000 0.028 0.104 0.208
#> GSM39836 4 0.1625 0.7243 0.000 0.012 0.000 0.928 0.000 0.060
#> GSM39837 5 0.2158 0.7422 0.012 0.016 0.000 0.056 0.912 0.004
#> GSM39838 5 0.6436 0.3727 0.000 0.060 0.000 0.148 0.508 0.284
#> GSM39839 2 0.4344 0.7864 0.032 0.612 0.356 0.000 0.000 0.000
#> GSM39840 1 0.4251 0.4888 0.700 0.032 0.000 0.256 0.000 0.012
#> GSM39841 1 0.4274 0.6636 0.768 0.156 0.000 0.040 0.020 0.016
#> GSM39842 1 0.0632 0.6989 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM39843 4 0.6224 0.4878 0.216 0.156 0.020 0.580 0.000 0.028
#> GSM39844 1 0.0551 0.7025 0.984 0.008 0.000 0.004 0.000 0.004
#> GSM39845 3 0.3694 0.4318 0.000 0.232 0.740 0.000 0.000 0.028
#> GSM39852 4 0.5262 0.2560 0.008 0.076 0.004 0.572 0.000 0.340
#> GSM39853 5 0.3467 0.7100 0.064 0.036 0.000 0.016 0.848 0.036
#> GSM39854 1 0.7043 0.4097 0.552 0.072 0.000 0.060 0.192 0.124
#> GSM39857 3 0.3456 0.6535 0.000 0.040 0.788 0.000 0.000 0.172
#> GSM39860 6 0.6366 0.3538 0.000 0.040 0.240 0.000 0.208 0.512
#> GSM39861 3 0.3370 0.6476 0.000 0.148 0.804 0.000 0.000 0.048
#> GSM39864 1 0.6514 0.4235 0.504 0.228 0.000 0.052 0.000 0.216
#> GSM39868 6 0.6676 0.3877 0.052 0.204 0.020 0.180 0.000 0.544
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> MAD:skmeans 49 0.05974 0.00302 2
#> MAD:skmeans 57 0.00404 0.00890 3
#> MAD:skmeans 51 0.00276 0.00636 4
#> MAD:skmeans 41 0.00709 0.02466 5
#> MAD:skmeans 40 0.00912 0.04584 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.928 0.931 0.973 0.2721 0.733 0.733
#> 3 3 0.565 0.756 0.886 1.2117 0.570 0.451
#> 4 4 0.533 0.673 0.819 0.1805 0.894 0.736
#> 5 5 0.671 0.664 0.821 0.0971 0.881 0.620
#> 6 6 0.731 0.757 0.848 0.0481 0.910 0.628
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.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0000 0.914700 0.000 1.000
#> GSM39874 2 0.0000 0.914700 0.000 1.000
#> GSM39875 2 0.0000 0.914700 0.000 1.000
#> GSM39876 2 0.0000 0.914700 0.000 1.000
#> GSM39831 1 0.0000 0.978825 1.000 0.000
#> GSM39819 1 0.0376 0.978884 0.996 0.004
#> GSM39820 1 0.0376 0.978884 0.996 0.004
#> GSM39821 1 0.0000 0.978825 1.000 0.000
#> GSM39822 2 0.0376 0.913994 0.004 0.996
#> GSM39823 1 0.0376 0.978884 0.996 0.004
#> GSM39824 1 0.0376 0.978884 0.996 0.004
#> GSM39825 1 0.0376 0.978884 0.996 0.004
#> GSM39826 1 0.0672 0.974257 0.992 0.008
#> GSM39827 1 0.0000 0.978825 1.000 0.000
#> GSM39846 1 0.0376 0.978884 0.996 0.004
#> GSM39847 1 0.0000 0.978825 1.000 0.000
#> GSM39848 1 0.8207 0.627013 0.744 0.256
#> GSM39849 1 0.0376 0.978884 0.996 0.004
#> GSM39850 1 0.0672 0.974257 0.992 0.008
#> GSM39851 1 0.0000 0.978825 1.000 0.000
#> GSM39855 1 0.0376 0.978884 0.996 0.004
#> GSM39856 1 0.0376 0.978884 0.996 0.004
#> GSM39858 1 0.0376 0.978884 0.996 0.004
#> GSM39859 1 0.0376 0.978884 0.996 0.004
#> GSM39862 1 0.0000 0.978825 1.000 0.000
#> GSM39863 1 0.0000 0.978825 1.000 0.000
#> GSM39865 1 0.6973 0.754801 0.812 0.188
#> GSM39866 1 0.0000 0.978825 1.000 0.000
#> GSM39867 1 0.1414 0.963893 0.980 0.020
#> GSM39869 2 0.0376 0.913994 0.004 0.996
#> GSM39870 1 0.0376 0.978884 0.996 0.004
#> GSM39871 1 0.0376 0.978884 0.996 0.004
#> GSM39872 1 0.0376 0.978884 0.996 0.004
#> GSM39828 1 0.0000 0.978825 1.000 0.000
#> GSM39829 1 0.0376 0.978884 0.996 0.004
#> GSM39830 1 0.0376 0.978884 0.996 0.004
#> GSM39832 1 0.0000 0.978825 1.000 0.000
#> GSM39833 1 0.0000 0.978825 1.000 0.000
#> GSM39834 1 0.0000 0.978825 1.000 0.000
#> GSM39835 1 0.0672 0.974257 0.992 0.008
#> GSM39836 1 0.0672 0.974257 0.992 0.008
#> GSM39837 2 0.6048 0.789713 0.148 0.852
#> GSM39838 1 0.0672 0.974257 0.992 0.008
#> GSM39839 1 0.0376 0.978884 0.996 0.004
#> GSM39840 1 0.0000 0.978825 1.000 0.000
#> GSM39841 1 0.0672 0.974257 0.992 0.008
#> GSM39842 1 0.0000 0.978825 1.000 0.000
#> GSM39843 1 0.0000 0.978825 1.000 0.000
#> GSM39844 1 0.0000 0.978825 1.000 0.000
#> GSM39845 1 0.0376 0.978884 0.996 0.004
#> GSM39852 1 0.0000 0.978825 1.000 0.000
#> GSM39853 2 0.0672 0.912967 0.008 0.992
#> GSM39854 1 0.9209 0.451012 0.664 0.336
#> GSM39857 1 0.0376 0.978884 0.996 0.004
#> GSM39860 2 1.0000 0.000893 0.496 0.504
#> GSM39861 1 0.0376 0.978884 0.996 0.004
#> GSM39864 1 0.0000 0.978825 1.000 0.000
#> GSM39868 1 0.0376 0.978884 0.996 0.004
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.906 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.906 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.906 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.906 0.000 1.000 0.000
#> GSM39831 1 0.5948 0.593 0.640 0.000 0.360
#> GSM39819 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39820 3 0.3192 0.812 0.112 0.000 0.888
#> GSM39821 1 0.0237 0.797 0.996 0.000 0.004
#> GSM39822 2 0.2356 0.844 0.072 0.928 0.000
#> GSM39823 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39824 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39825 3 0.4062 0.730 0.164 0.000 0.836
#> GSM39826 1 0.0237 0.797 0.996 0.000 0.004
#> GSM39827 1 0.0000 0.795 1.000 0.000 0.000
#> GSM39846 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39847 1 0.0237 0.797 0.996 0.000 0.004
#> GSM39848 1 0.9364 0.342 0.484 0.332 0.184
#> GSM39849 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39850 1 0.0237 0.797 0.996 0.000 0.004
#> GSM39851 1 0.0237 0.796 0.996 0.000 0.004
#> GSM39855 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39856 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39862 1 0.6235 0.458 0.564 0.000 0.436
#> GSM39863 1 0.4291 0.746 0.820 0.000 0.180
#> GSM39865 2 0.8109 0.261 0.080 0.568 0.352
#> GSM39866 1 0.0892 0.790 0.980 0.000 0.020
#> GSM39867 1 0.0000 0.795 1.000 0.000 0.000
#> GSM39869 2 0.0000 0.906 0.000 1.000 0.000
#> GSM39870 3 0.5760 0.490 0.328 0.000 0.672
#> GSM39871 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39872 3 0.0592 0.907 0.012 0.000 0.988
#> GSM39828 1 0.5926 0.600 0.644 0.000 0.356
#> GSM39829 3 0.2796 0.838 0.092 0.000 0.908
#> GSM39830 3 0.4399 0.684 0.188 0.000 0.812
#> GSM39832 1 0.0000 0.795 1.000 0.000 0.000
#> GSM39833 1 0.5650 0.647 0.688 0.000 0.312
#> GSM39834 1 0.6291 0.381 0.532 0.000 0.468
#> GSM39835 1 0.5926 0.600 0.644 0.000 0.356
#> GSM39836 1 0.0237 0.797 0.996 0.000 0.004
#> GSM39837 1 0.1163 0.783 0.972 0.028 0.000
#> GSM39838 1 0.0237 0.797 0.996 0.000 0.004
#> GSM39839 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39840 1 0.1031 0.794 0.976 0.000 0.024
#> GSM39841 1 0.4654 0.731 0.792 0.000 0.208
#> GSM39842 1 0.5926 0.599 0.644 0.000 0.356
#> GSM39843 1 0.0424 0.797 0.992 0.000 0.008
#> GSM39844 1 0.0237 0.794 0.996 0.000 0.004
#> GSM39845 3 0.0000 0.915 0.000 0.000 1.000
#> GSM39852 1 0.4235 0.750 0.824 0.000 0.176
#> GSM39853 1 0.5497 0.500 0.708 0.292 0.000
#> GSM39854 1 0.0000 0.795 1.000 0.000 0.000
#> GSM39857 3 0.0237 0.912 0.004 0.000 0.996
#> GSM39860 3 0.6247 0.319 0.004 0.376 0.620
#> GSM39861 3 0.0424 0.910 0.008 0.000 0.992
#> GSM39864 1 0.5926 0.600 0.644 0.000 0.356
#> GSM39868 1 0.5882 0.394 0.652 0.000 0.348
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.8676 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.8676 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.8676 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.8676 0.000 1.000 0.000 0.000
#> GSM39831 1 0.4225 0.7114 0.792 0.000 0.184 0.024
#> GSM39819 3 0.3942 0.7862 0.236 0.000 0.764 0.000
#> GSM39820 3 0.5312 0.7571 0.236 0.000 0.712 0.052
#> GSM39821 4 0.0188 0.7254 0.004 0.000 0.000 0.996
#> GSM39822 2 0.2197 0.8031 0.004 0.916 0.000 0.080
#> GSM39823 3 0.3873 0.7891 0.228 0.000 0.772 0.000
#> GSM39824 3 0.0000 0.8038 0.000 0.000 1.000 0.000
#> GSM39825 3 0.5690 0.4242 0.060 0.000 0.672 0.268
#> GSM39826 4 0.0817 0.7223 0.024 0.000 0.000 0.976
#> GSM39827 4 0.0921 0.7183 0.028 0.000 0.000 0.972
#> GSM39846 3 0.3219 0.7937 0.164 0.000 0.836 0.000
#> GSM39847 4 0.0000 0.7256 0.000 0.000 0.000 1.000
#> GSM39848 4 0.7864 0.2642 0.008 0.332 0.208 0.452
#> GSM39849 3 0.0336 0.8048 0.008 0.000 0.992 0.000
#> GSM39850 4 0.0817 0.7223 0.024 0.000 0.000 0.976
#> GSM39851 4 0.0817 0.7223 0.024 0.000 0.000 0.976
#> GSM39855 3 0.0000 0.8038 0.000 0.000 1.000 0.000
#> GSM39856 3 0.0188 0.8045 0.004 0.000 0.996 0.000
#> GSM39858 3 0.3172 0.7949 0.160 0.000 0.840 0.000
#> GSM39859 3 0.0000 0.8038 0.000 0.000 1.000 0.000
#> GSM39862 4 0.4769 0.6001 0.008 0.000 0.308 0.684
#> GSM39863 1 0.4856 0.7965 0.780 0.000 0.084 0.136
#> GSM39865 2 0.7793 0.1797 0.008 0.488 0.280 0.224
#> GSM39866 4 0.4706 0.5690 0.248 0.000 0.020 0.732
#> GSM39867 1 0.4008 0.7720 0.756 0.000 0.000 0.244
#> GSM39869 2 0.1452 0.8471 0.036 0.956 0.000 0.008
#> GSM39870 3 0.6187 0.7042 0.236 0.000 0.656 0.108
#> GSM39871 3 0.0000 0.8038 0.000 0.000 1.000 0.000
#> GSM39872 3 0.0817 0.7914 0.000 0.000 0.976 0.024
#> GSM39828 4 0.4831 0.6184 0.016 0.000 0.280 0.704
#> GSM39829 3 0.6245 0.7251 0.244 0.000 0.648 0.108
#> GSM39830 3 0.7782 0.3004 0.264 0.000 0.424 0.312
#> GSM39832 1 0.3942 0.7720 0.764 0.000 0.000 0.236
#> GSM39833 4 0.4955 0.6278 0.024 0.000 0.268 0.708
#> GSM39834 4 0.5024 0.5463 0.008 0.000 0.360 0.632
#> GSM39835 1 0.6685 0.6319 0.600 0.000 0.268 0.132
#> GSM39836 4 0.0000 0.7256 0.000 0.000 0.000 1.000
#> GSM39837 4 0.1211 0.7155 0.000 0.040 0.000 0.960
#> GSM39838 4 0.0336 0.7245 0.008 0.000 0.000 0.992
#> GSM39839 3 0.3942 0.7862 0.236 0.000 0.764 0.000
#> GSM39840 4 0.4941 -0.1192 0.436 0.000 0.000 0.564
#> GSM39841 4 0.5091 0.6616 0.068 0.000 0.180 0.752
#> GSM39842 1 0.5159 0.7758 0.756 0.000 0.156 0.088
#> GSM39843 4 0.0817 0.7223 0.024 0.000 0.000 0.976
#> GSM39844 1 0.2216 0.7446 0.908 0.000 0.000 0.092
#> GSM39845 3 0.3873 0.7891 0.228 0.000 0.772 0.000
#> GSM39852 4 0.3933 0.6704 0.008 0.000 0.200 0.792
#> GSM39853 4 0.6939 -0.0532 0.332 0.128 0.000 0.540
#> GSM39854 1 0.4406 0.7328 0.700 0.000 0.000 0.300
#> GSM39857 3 0.0188 0.8018 0.000 0.000 0.996 0.004
#> GSM39860 3 0.4817 0.3290 0.000 0.388 0.612 0.000
#> GSM39861 3 0.2198 0.7943 0.072 0.000 0.920 0.008
#> GSM39864 4 0.5901 0.5867 0.068 0.000 0.280 0.652
#> GSM39868 4 0.5272 0.4384 0.032 0.000 0.288 0.680
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.841 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.841 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.841 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.841 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.3053 0.766 0.828 0.000 0.000 0.008 0.164
#> GSM39819 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000
#> GSM39820 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000
#> GSM39821 4 0.0000 0.793 0.000 0.000 0.000 1.000 0.000
#> GSM39822 2 0.2864 0.778 0.000 0.852 0.000 0.012 0.136
#> GSM39823 3 0.0162 0.833 0.000 0.000 0.996 0.000 0.004
#> GSM39824 5 0.3305 0.747 0.000 0.000 0.224 0.000 0.776
#> GSM39825 5 0.6453 -0.364 0.000 0.000 0.180 0.388 0.432
#> GSM39826 4 0.0000 0.793 0.000 0.000 0.000 1.000 0.000
#> GSM39827 4 0.1943 0.781 0.056 0.000 0.000 0.924 0.020
#> GSM39846 5 0.4219 0.490 0.000 0.000 0.416 0.000 0.584
#> GSM39847 4 0.0290 0.794 0.000 0.000 0.000 0.992 0.008
#> GSM39848 5 0.6818 -0.348 0.000 0.336 0.000 0.312 0.352
#> GSM39849 5 0.3336 0.748 0.000 0.000 0.228 0.000 0.772
#> GSM39850 4 0.0000 0.793 0.000 0.000 0.000 1.000 0.000
#> GSM39851 4 0.0000 0.793 0.000 0.000 0.000 1.000 0.000
#> GSM39855 5 0.3336 0.748 0.000 0.000 0.228 0.000 0.772
#> GSM39856 5 0.3336 0.748 0.000 0.000 0.228 0.000 0.772
#> GSM39858 5 0.4030 0.600 0.000 0.000 0.352 0.000 0.648
#> GSM39859 5 0.3534 0.731 0.000 0.000 0.256 0.000 0.744
#> GSM39862 4 0.4262 0.590 0.000 0.000 0.000 0.560 0.440
#> GSM39863 1 0.2909 0.775 0.848 0.000 0.000 0.012 0.140
#> GSM39865 2 0.6625 0.118 0.000 0.456 0.000 0.268 0.276
#> GSM39866 3 0.3995 0.655 0.000 0.000 0.788 0.060 0.152
#> GSM39867 1 0.0000 0.835 1.000 0.000 0.000 0.000 0.000
#> GSM39869 2 0.3975 0.729 0.144 0.792 0.000 0.000 0.064
#> GSM39870 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000
#> GSM39871 5 0.3336 0.748 0.000 0.000 0.228 0.000 0.772
#> GSM39872 5 0.3013 0.700 0.000 0.000 0.160 0.008 0.832
#> GSM39828 4 0.4074 0.660 0.000 0.000 0.000 0.636 0.364
#> GSM39829 3 0.1478 0.797 0.000 0.000 0.936 0.000 0.064
#> GSM39830 3 0.3593 0.725 0.000 0.000 0.828 0.088 0.084
#> GSM39832 1 0.0000 0.835 1.000 0.000 0.000 0.000 0.000
#> GSM39833 4 0.2966 0.738 0.000 0.000 0.000 0.816 0.184
#> GSM39834 4 0.4138 0.642 0.000 0.000 0.000 0.616 0.384
#> GSM39835 1 0.4168 0.647 0.764 0.000 0.000 0.052 0.184
#> GSM39836 4 0.0290 0.794 0.000 0.000 0.000 0.992 0.008
#> GSM39837 4 0.1701 0.767 0.000 0.016 0.000 0.936 0.048
#> GSM39838 4 0.3210 0.740 0.000 0.000 0.000 0.788 0.212
#> GSM39839 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000
#> GSM39840 1 0.4283 0.272 0.544 0.000 0.000 0.456 0.000
#> GSM39841 4 0.3304 0.760 0.028 0.000 0.004 0.840 0.128
#> GSM39842 1 0.0000 0.835 1.000 0.000 0.000 0.000 0.000
#> GSM39843 4 0.0000 0.793 0.000 0.000 0.000 1.000 0.000
#> GSM39844 1 0.0000 0.835 1.000 0.000 0.000 0.000 0.000
#> GSM39845 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000
#> GSM39852 4 0.3816 0.710 0.000 0.000 0.000 0.696 0.304
#> GSM39853 4 0.7277 -0.246 0.372 0.160 0.000 0.420 0.048
#> GSM39854 1 0.1205 0.823 0.956 0.000 0.000 0.040 0.004
#> GSM39857 5 0.3305 0.744 0.000 0.000 0.224 0.000 0.776
#> GSM39860 5 0.5642 0.572 0.000 0.180 0.184 0.000 0.636
#> GSM39861 3 0.6748 -0.130 0.000 0.000 0.404 0.320 0.276
#> GSM39864 4 0.5760 0.564 0.000 0.000 0.096 0.536 0.368
#> GSM39868 4 0.3999 0.729 0.000 0.000 0.020 0.740 0.240
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.3041 0.7836 0.856 0.000 0.020 0.000 0.088 0.036
#> GSM39819 6 0.1663 0.9245 0.000 0.000 0.088 0.000 0.000 0.912
#> GSM39820 6 0.1663 0.9245 0.000 0.000 0.088 0.000 0.000 0.912
#> GSM39821 4 0.0000 0.7664 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39822 5 0.2482 0.7140 0.000 0.148 0.000 0.004 0.848 0.000
#> GSM39823 6 0.2416 0.9082 0.000 0.000 0.156 0.000 0.000 0.844
#> GSM39824 3 0.0000 0.8621 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM39825 4 0.7549 0.2806 0.000 0.000 0.288 0.336 0.176 0.200
#> GSM39826 4 0.0000 0.7664 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39827 4 0.1963 0.7559 0.044 0.000 0.004 0.924 0.016 0.012
#> GSM39846 3 0.2416 0.7054 0.000 0.000 0.844 0.000 0.000 0.156
#> GSM39847 4 0.0260 0.7685 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM39848 5 0.0000 0.7354 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39849 3 0.1444 0.8309 0.000 0.000 0.928 0.000 0.000 0.072
#> GSM39850 4 0.0000 0.7664 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39851 4 0.0000 0.7664 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39855 3 0.0146 0.8611 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM39856 3 0.0000 0.8621 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM39858 3 0.1863 0.7779 0.000 0.000 0.896 0.000 0.000 0.104
#> GSM39859 3 0.1480 0.8446 0.000 0.000 0.940 0.000 0.020 0.040
#> GSM39862 4 0.6228 0.5804 0.000 0.000 0.204 0.512 0.256 0.028
#> GSM39863 1 0.2600 0.7927 0.876 0.000 0.000 0.004 0.084 0.036
#> GSM39865 5 0.2445 0.7290 0.000 0.108 0.020 0.000 0.872 0.000
#> GSM39866 6 0.2618 0.8199 0.000 0.000 0.000 0.052 0.076 0.872
#> GSM39867 1 0.1074 0.8255 0.960 0.000 0.000 0.000 0.012 0.028
#> GSM39869 5 0.3787 0.6988 0.100 0.064 0.000 0.000 0.808 0.028
#> GSM39870 6 0.2219 0.9189 0.000 0.000 0.136 0.000 0.000 0.864
#> GSM39871 3 0.0000 0.8621 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM39872 3 0.2666 0.7747 0.000 0.000 0.872 0.008 0.092 0.028
#> GSM39828 4 0.5412 0.6970 0.000 0.000 0.148 0.648 0.176 0.028
#> GSM39829 6 0.2404 0.9158 0.000 0.000 0.112 0.000 0.016 0.872
#> GSM39830 6 0.1787 0.8525 0.000 0.000 0.068 0.008 0.004 0.920
#> GSM39832 1 0.0000 0.8329 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39833 4 0.3633 0.7428 0.000 0.000 0.140 0.804 0.028 0.028
#> GSM39834 4 0.5681 0.6775 0.000 0.000 0.184 0.612 0.176 0.028
#> GSM39835 1 0.5780 0.5959 0.676 0.000 0.144 0.076 0.076 0.028
#> GSM39836 4 0.0363 0.7669 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM39837 5 0.4051 0.3768 0.000 0.008 0.000 0.432 0.560 0.000
#> GSM39838 5 0.1765 0.7273 0.000 0.000 0.000 0.096 0.904 0.000
#> GSM39839 6 0.1663 0.9245 0.000 0.000 0.088 0.000 0.000 0.912
#> GSM39840 1 0.3843 0.2952 0.548 0.000 0.000 0.452 0.000 0.000
#> GSM39841 4 0.4971 0.7185 0.028 0.000 0.100 0.736 0.024 0.112
#> GSM39842 1 0.0000 0.8329 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39843 4 0.0260 0.7685 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM39844 1 0.0146 0.8326 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM39845 6 0.2454 0.9068 0.000 0.000 0.160 0.000 0.000 0.840
#> GSM39852 4 0.4958 0.7191 0.000 0.000 0.100 0.696 0.176 0.028
#> GSM39853 5 0.4340 0.6745 0.104 0.000 0.000 0.176 0.720 0.000
#> GSM39854 1 0.2183 0.8156 0.912 0.000 0.000 0.040 0.020 0.028
#> GSM39857 3 0.1092 0.8533 0.000 0.000 0.960 0.000 0.020 0.020
#> GSM39860 5 0.3428 0.5261 0.000 0.000 0.304 0.000 0.696 0.000
#> GSM39861 3 0.6615 -0.0101 0.000 0.000 0.384 0.268 0.028 0.320
#> GSM39864 4 0.6800 0.6069 0.000 0.000 0.148 0.520 0.176 0.156
#> GSM39868 4 0.5211 0.6760 0.000 0.000 0.124 0.684 0.152 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> MAD:pam 56 1.41e-05 9.91e-06 2
#> MAD:pam 51 8.53e-08 6.79e-07 3
#> MAD:pam 50 5.54e-07 2.17e-06 4
#> MAD:pam 51 1.47e-06 1.02e-05 5
#> MAD:pam 54 2.10e-10 9.86e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.403 0.859 0.889 0.3676 0.610 0.610
#> 3 3 0.939 0.931 0.964 0.4795 0.542 0.400
#> 4 4 0.673 0.710 0.846 0.2411 0.815 0.604
#> 5 5 0.688 0.718 0.835 0.1148 0.839 0.541
#> 6 6 0.761 0.731 0.797 0.0558 0.941 0.774
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.3879 0.820 0.076 0.924
#> GSM39874 2 0.3879 0.820 0.076 0.924
#> GSM39875 2 0.3879 0.820 0.076 0.924
#> GSM39876 2 0.3879 0.820 0.076 0.924
#> GSM39831 1 0.5178 0.869 0.884 0.116
#> GSM39819 1 0.0000 0.901 1.000 0.000
#> GSM39820 1 0.0000 0.901 1.000 0.000
#> GSM39821 1 0.7528 0.786 0.784 0.216
#> GSM39822 2 0.7745 0.895 0.228 0.772
#> GSM39823 1 0.0000 0.901 1.000 0.000
#> GSM39824 1 0.0000 0.901 1.000 0.000
#> GSM39825 1 0.0376 0.901 0.996 0.004
#> GSM39826 2 0.8443 0.807 0.272 0.728
#> GSM39827 1 0.8267 0.717 0.740 0.260
#> GSM39846 1 0.0000 0.901 1.000 0.000
#> GSM39847 1 0.5519 0.857 0.872 0.128
#> GSM39848 2 0.7219 0.887 0.200 0.800
#> GSM39849 1 0.0000 0.901 1.000 0.000
#> GSM39850 1 0.8267 0.726 0.740 0.260
#> GSM39851 1 0.7745 0.787 0.772 0.228
#> GSM39855 1 0.0000 0.901 1.000 0.000
#> GSM39856 1 0.0000 0.901 1.000 0.000
#> GSM39858 1 0.0000 0.901 1.000 0.000
#> GSM39859 1 0.0000 0.901 1.000 0.000
#> GSM39862 1 0.2236 0.896 0.964 0.036
#> GSM39863 1 0.6148 0.853 0.848 0.152
#> GSM39865 2 0.7745 0.895 0.228 0.772
#> GSM39866 1 0.3274 0.893 0.940 0.060
#> GSM39867 2 0.7815 0.882 0.232 0.768
#> GSM39869 2 0.7528 0.895 0.216 0.784
#> GSM39870 1 0.0000 0.901 1.000 0.000
#> GSM39871 1 0.0000 0.901 1.000 0.000
#> GSM39872 1 0.0376 0.901 0.996 0.004
#> GSM39828 1 0.4022 0.887 0.920 0.080
#> GSM39829 1 0.0000 0.901 1.000 0.000
#> GSM39830 1 0.0376 0.901 0.996 0.004
#> GSM39832 1 0.8386 0.736 0.732 0.268
#> GSM39833 1 0.6973 0.780 0.812 0.188
#> GSM39834 1 0.3114 0.894 0.944 0.056
#> GSM39835 2 0.7528 0.876 0.216 0.784
#> GSM39836 1 0.5408 0.861 0.876 0.124
#> GSM39837 2 0.8144 0.886 0.252 0.748
#> GSM39838 2 0.8144 0.886 0.252 0.748
#> GSM39839 1 0.0000 0.901 1.000 0.000
#> GSM39840 1 0.8016 0.769 0.756 0.244
#> GSM39841 1 0.8016 0.724 0.756 0.244
#> GSM39842 1 0.8016 0.769 0.756 0.244
#> GSM39843 1 0.4690 0.878 0.900 0.100
#> GSM39844 1 0.8327 0.742 0.736 0.264
#> GSM39845 1 0.0000 0.901 1.000 0.000
#> GSM39852 1 0.3274 0.893 0.940 0.060
#> GSM39853 2 0.8144 0.886 0.252 0.748
#> GSM39854 2 0.7815 0.882 0.232 0.768
#> GSM39857 1 0.0000 0.901 1.000 0.000
#> GSM39860 1 0.6623 0.711 0.828 0.172
#> GSM39861 1 0.0000 0.901 1.000 0.000
#> GSM39864 1 0.3274 0.893 0.940 0.060
#> GSM39868 1 0.3114 0.894 0.944 0.056
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1.000 0.000
#> GSM39831 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39819 3 0.0892 0.942 0.020 0.000 0.980
#> GSM39820 3 0.0237 0.951 0.004 0.000 0.996
#> GSM39821 1 0.0424 0.961 0.992 0.000 0.008
#> GSM39822 1 0.2173 0.938 0.944 0.048 0.008
#> GSM39823 3 0.0237 0.951 0.004 0.000 0.996
#> GSM39824 3 0.0424 0.949 0.008 0.000 0.992
#> GSM39825 3 0.3752 0.786 0.144 0.000 0.856
#> GSM39826 1 0.0424 0.961 0.992 0.000 0.008
#> GSM39827 1 0.0424 0.961 0.992 0.000 0.008
#> GSM39846 3 0.0000 0.949 0.000 0.000 1.000
#> GSM39847 1 0.1170 0.961 0.976 0.008 0.016
#> GSM39848 1 0.1453 0.954 0.968 0.024 0.008
#> GSM39849 3 0.0747 0.944 0.016 0.000 0.984
#> GSM39850 1 0.0424 0.961 0.992 0.000 0.008
#> GSM39851 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39855 3 0.0592 0.945 0.012 0.000 0.988
#> GSM39856 3 0.0000 0.949 0.000 0.000 1.000
#> GSM39858 3 0.0000 0.949 0.000 0.000 1.000
#> GSM39859 3 0.0237 0.951 0.004 0.000 0.996
#> GSM39862 1 0.2176 0.952 0.948 0.032 0.020
#> GSM39863 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39865 1 0.2384 0.931 0.936 0.056 0.008
#> GSM39866 1 0.3031 0.914 0.912 0.012 0.076
#> GSM39867 1 0.0237 0.960 0.996 0.000 0.004
#> GSM39869 1 0.1170 0.957 0.976 0.016 0.008
#> GSM39870 3 0.0000 0.949 0.000 0.000 1.000
#> GSM39871 3 0.0000 0.949 0.000 0.000 1.000
#> GSM39872 3 0.5560 0.529 0.300 0.000 0.700
#> GSM39828 1 0.1015 0.961 0.980 0.008 0.012
#> GSM39829 3 0.0747 0.944 0.016 0.000 0.984
#> GSM39830 3 0.2959 0.849 0.100 0.000 0.900
#> GSM39832 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39833 1 0.2050 0.953 0.952 0.020 0.028
#> GSM39834 1 0.1774 0.957 0.960 0.016 0.024
#> GSM39835 1 0.0237 0.958 0.996 0.004 0.000
#> GSM39836 1 0.1015 0.961 0.980 0.008 0.012
#> GSM39837 1 0.0829 0.959 0.984 0.012 0.004
#> GSM39838 1 0.1015 0.957 0.980 0.012 0.008
#> GSM39839 3 0.0892 0.942 0.020 0.000 0.980
#> GSM39840 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39841 1 0.1337 0.961 0.972 0.012 0.016
#> GSM39842 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39843 1 0.5443 0.642 0.736 0.004 0.260
#> GSM39844 1 0.0983 0.960 0.980 0.004 0.016
#> GSM39845 3 0.0237 0.951 0.004 0.000 0.996
#> GSM39852 1 0.1636 0.958 0.964 0.016 0.020
#> GSM39853 1 0.0592 0.958 0.988 0.012 0.000
#> GSM39854 1 0.0000 0.958 1.000 0.000 0.000
#> GSM39857 3 0.0237 0.951 0.004 0.000 0.996
#> GSM39860 1 0.6597 0.506 0.664 0.024 0.312
#> GSM39861 3 0.0000 0.949 0.000 0.000 1.000
#> GSM39864 1 0.1905 0.956 0.956 0.016 0.028
#> GSM39868 1 0.1636 0.958 0.964 0.016 0.020
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1 0.000 0.000
#> GSM39831 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39819 3 0.0657 0.9082 0.004 0 0.984 0.012
#> GSM39820 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39821 1 0.4925 0.5900 0.572 0 0.000 0.428
#> GSM39822 4 0.0469 0.8251 0.012 0 0.000 0.988
#> GSM39823 3 0.0921 0.8989 0.000 0 0.972 0.028
#> GSM39824 3 0.4193 0.6317 0.000 0 0.732 0.268
#> GSM39825 3 0.5507 0.6285 0.156 0 0.732 0.112
#> GSM39826 4 0.4164 0.4734 0.264 0 0.000 0.736
#> GSM39827 1 0.4925 0.5900 0.572 0 0.000 0.428
#> GSM39846 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39847 1 0.4925 0.5900 0.572 0 0.000 0.428
#> GSM39848 4 0.0707 0.8277 0.020 0 0.000 0.980
#> GSM39849 3 0.0657 0.9082 0.004 0 0.984 0.012
#> GSM39850 1 0.4916 0.5917 0.576 0 0.000 0.424
#> GSM39851 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39855 3 0.4193 0.6317 0.000 0 0.732 0.268
#> GSM39856 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39858 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39859 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39862 1 0.4977 0.5718 0.540 0 0.000 0.460
#> GSM39863 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39865 4 0.0469 0.8251 0.012 0 0.000 0.988
#> GSM39866 1 0.4972 0.5761 0.544 0 0.000 0.456
#> GSM39867 4 0.1557 0.8294 0.056 0 0.000 0.944
#> GSM39869 4 0.0469 0.8251 0.012 0 0.000 0.988
#> GSM39870 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39871 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39872 4 0.7115 -0.3877 0.420 0 0.128 0.452
#> GSM39828 1 0.4925 0.5900 0.572 0 0.000 0.428
#> GSM39829 3 0.0376 0.9105 0.004 0 0.992 0.004
#> GSM39830 3 0.3505 0.8017 0.048 0 0.864 0.088
#> GSM39832 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39833 4 0.4804 -0.0311 0.384 0 0.000 0.616
#> GSM39834 1 0.4977 0.5718 0.540 0 0.000 0.460
#> GSM39835 4 0.1637 0.8275 0.060 0 0.000 0.940
#> GSM39836 1 0.4933 0.5892 0.568 0 0.000 0.432
#> GSM39837 4 0.1474 0.8297 0.052 0 0.000 0.948
#> GSM39838 4 0.0817 0.8287 0.024 0 0.000 0.976
#> GSM39839 3 0.0657 0.9082 0.004 0 0.984 0.012
#> GSM39840 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39841 1 0.4564 0.4012 0.672 0 0.000 0.328
#> GSM39842 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39843 1 0.6319 0.5455 0.604 0 0.084 0.312
#> GSM39844 1 0.0000 0.5595 1.000 0 0.000 0.000
#> GSM39845 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39852 1 0.4977 0.5718 0.540 0 0.000 0.460
#> GSM39853 4 0.1474 0.8297 0.052 0 0.000 0.948
#> GSM39854 4 0.1557 0.8294 0.056 0 0.000 0.944
#> GSM39857 3 0.2868 0.7975 0.000 0 0.864 0.136
#> GSM39860 4 0.2081 0.7610 0.084 0 0.000 0.916
#> GSM39861 3 0.0000 0.9117 0.000 0 1.000 0.000
#> GSM39864 1 0.4967 0.5796 0.548 0 0.000 0.452
#> GSM39868 1 0.4967 0.5796 0.548 0 0.000 0.452
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM39831 1 0.2424 0.8382 0.868 0 0.000 0.132 0.000
#> GSM39819 3 0.2515 0.8653 0.044 0 0.904 0.008 0.044
#> GSM39820 3 0.1310 0.8838 0.024 0 0.956 0.000 0.020
#> GSM39821 4 0.2629 0.6996 0.136 0 0.000 0.860 0.004
#> GSM39822 5 0.2124 0.7933 0.004 0 0.000 0.096 0.900
#> GSM39823 3 0.0671 0.8853 0.004 0 0.980 0.000 0.016
#> GSM39824 3 0.4452 0.0357 0.004 0 0.500 0.000 0.496
#> GSM39825 3 0.4174 0.6890 0.016 0 0.776 0.180 0.028
#> GSM39826 4 0.4736 0.6604 0.072 0 0.000 0.712 0.216
#> GSM39827 4 0.4349 0.6823 0.176 0 0.000 0.756 0.068
#> GSM39846 3 0.0000 0.8893 0.000 0 1.000 0.000 0.000
#> GSM39847 4 0.1671 0.7133 0.076 0 0.000 0.924 0.000
#> GSM39848 5 0.2124 0.7917 0.004 0 0.000 0.096 0.900
#> GSM39849 3 0.1393 0.8798 0.012 0 0.956 0.024 0.008
#> GSM39850 4 0.3667 0.7015 0.140 0 0.000 0.812 0.048
#> GSM39851 1 0.1478 0.8773 0.936 0 0.000 0.064 0.000
#> GSM39855 3 0.4452 0.0357 0.004 0 0.500 0.000 0.496
#> GSM39856 3 0.0000 0.8893 0.000 0 1.000 0.000 0.000
#> GSM39858 3 0.0000 0.8893 0.000 0 1.000 0.000 0.000
#> GSM39859 3 0.0162 0.8892 0.000 0 0.996 0.000 0.004
#> GSM39862 5 0.4375 0.4936 0.000 0 0.004 0.420 0.576
#> GSM39863 1 0.2179 0.8542 0.888 0 0.000 0.112 0.000
#> GSM39865 5 0.1965 0.7923 0.000 0 0.000 0.096 0.904
#> GSM39866 4 0.2142 0.7047 0.048 0 0.004 0.920 0.028
#> GSM39867 4 0.4938 0.6056 0.048 0 0.000 0.640 0.312
#> GSM39869 5 0.2124 0.7933 0.004 0 0.000 0.096 0.900
#> GSM39870 3 0.1300 0.8838 0.028 0 0.956 0.000 0.016
#> GSM39871 3 0.0000 0.8893 0.000 0 1.000 0.000 0.000
#> GSM39872 5 0.6866 0.3552 0.004 0 0.252 0.364 0.380
#> GSM39828 4 0.1270 0.7131 0.052 0 0.000 0.948 0.000
#> GSM39829 3 0.1787 0.8788 0.032 0 0.940 0.012 0.016
#> GSM39830 3 0.3925 0.7805 0.056 0 0.828 0.088 0.028
#> GSM39832 1 0.1197 0.8802 0.952 0 0.000 0.048 0.000
#> GSM39833 4 0.5530 0.5136 0.076 0 0.000 0.556 0.368
#> GSM39834 4 0.0609 0.6943 0.000 0 0.000 0.980 0.020
#> GSM39835 4 0.4637 0.6164 0.036 0 0.000 0.672 0.292
#> GSM39836 4 0.1282 0.7145 0.044 0 0.000 0.952 0.004
#> GSM39837 4 0.5555 0.3876 0.068 0 0.000 0.480 0.452
#> GSM39838 4 0.4452 0.2954 0.004 0 0.000 0.500 0.496
#> GSM39839 3 0.2515 0.8653 0.044 0 0.904 0.008 0.044
#> GSM39840 1 0.1197 0.8802 0.952 0 0.000 0.048 0.000
#> GSM39841 1 0.6557 0.0290 0.472 0 0.000 0.288 0.240
#> GSM39842 1 0.1197 0.8802 0.952 0 0.000 0.048 0.000
#> GSM39843 4 0.5716 0.3752 0.108 0 0.256 0.628 0.008
#> GSM39844 1 0.1197 0.8802 0.952 0 0.000 0.048 0.000
#> GSM39845 3 0.0162 0.8892 0.000 0 0.996 0.000 0.004
#> GSM39852 4 0.0609 0.6943 0.000 0 0.000 0.980 0.020
#> GSM39853 4 0.5555 0.3876 0.068 0 0.000 0.480 0.452
#> GSM39854 4 0.5227 0.4380 0.044 0 0.000 0.508 0.448
#> GSM39857 3 0.1270 0.8659 0.000 0 0.948 0.000 0.052
#> GSM39860 5 0.3608 0.7546 0.000 0 0.040 0.148 0.812
#> GSM39861 3 0.0290 0.8892 0.000 0 0.992 0.000 0.008
#> GSM39864 4 0.1386 0.7000 0.032 0 0.000 0.952 0.016
#> GSM39868 4 0.0671 0.6960 0.004 0 0.000 0.980 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39831 1 0.0146 0.8967 0.996 0 0.000 0.004 0.000 0.000
#> GSM39819 6 0.3727 0.8876 0.000 0 0.388 0.000 0.000 0.612
#> GSM39820 6 0.3828 0.8975 0.000 0 0.440 0.000 0.000 0.560
#> GSM39821 4 0.3844 0.7551 0.072 0 0.000 0.812 0.056 0.060
#> GSM39822 5 0.1745 0.9308 0.000 0 0.000 0.068 0.920 0.012
#> GSM39823 3 0.1088 0.7170 0.000 0 0.960 0.000 0.016 0.024
#> GSM39824 3 0.4371 0.4108 0.000 0 0.620 0.000 0.344 0.036
#> GSM39825 3 0.4418 0.3111 0.000 0 0.700 0.228 0.004 0.068
#> GSM39826 4 0.4876 0.7414 0.056 0 0.000 0.720 0.072 0.152
#> GSM39827 4 0.4788 0.7480 0.072 0 0.000 0.732 0.060 0.136
#> GSM39846 3 0.0000 0.7283 0.000 0 1.000 0.000 0.000 0.000
#> GSM39847 4 0.1477 0.7628 0.048 0 0.000 0.940 0.008 0.004
#> GSM39848 5 0.1387 0.9327 0.000 0 0.000 0.068 0.932 0.000
#> GSM39849 3 0.1616 0.6710 0.000 0 0.932 0.020 0.000 0.048
#> GSM39850 4 0.4167 0.7514 0.072 0 0.000 0.788 0.056 0.084
#> GSM39851 1 0.0000 0.8990 1.000 0 0.000 0.000 0.000 0.000
#> GSM39855 3 0.4371 0.4108 0.000 0 0.620 0.000 0.344 0.036
#> GSM39856 3 0.0000 0.7283 0.000 0 1.000 0.000 0.000 0.000
#> GSM39858 3 0.0000 0.7283 0.000 0 1.000 0.000 0.000 0.000
#> GSM39859 3 0.0000 0.7283 0.000 0 1.000 0.000 0.000 0.000
#> GSM39862 5 0.3895 0.6960 0.008 0 0.000 0.280 0.700 0.012
#> GSM39863 1 0.0260 0.8939 0.992 0 0.000 0.008 0.000 0.000
#> GSM39865 5 0.1387 0.9327 0.000 0 0.000 0.068 0.932 0.000
#> GSM39866 4 0.1109 0.7528 0.016 0 0.004 0.964 0.004 0.012
#> GSM39867 4 0.5163 0.6937 0.044 0 0.000 0.636 0.048 0.272
#> GSM39869 5 0.1745 0.9308 0.000 0 0.000 0.068 0.920 0.012
#> GSM39870 6 0.3833 0.8937 0.000 0 0.444 0.000 0.000 0.556
#> GSM39871 3 0.0000 0.7283 0.000 0 1.000 0.000 0.000 0.000
#> GSM39872 3 0.6570 -0.0640 0.008 0 0.396 0.284 0.300 0.012
#> GSM39828 4 0.1555 0.7613 0.060 0 0.000 0.932 0.004 0.004
#> GSM39829 6 0.4051 0.9007 0.000 0 0.432 0.008 0.000 0.560
#> GSM39830 6 0.5462 0.8158 0.040 0 0.348 0.044 0.004 0.564
#> GSM39832 1 0.0000 0.8990 1.000 0 0.000 0.000 0.000 0.000
#> GSM39833 4 0.6299 0.6692 0.064 0 0.016 0.592 0.112 0.216
#> GSM39834 4 0.0862 0.7438 0.008 0 0.000 0.972 0.004 0.016
#> GSM39835 4 0.5637 0.6902 0.056 0 0.000 0.608 0.076 0.260
#> GSM39836 4 0.1382 0.7630 0.036 0 0.000 0.948 0.008 0.008
#> GSM39837 4 0.6760 0.4950 0.056 0 0.000 0.436 0.208 0.300
#> GSM39838 4 0.5348 0.2576 0.004 0 0.000 0.476 0.428 0.092
#> GSM39839 6 0.3727 0.8876 0.000 0 0.388 0.000 0.000 0.612
#> GSM39840 1 0.0000 0.8990 1.000 0 0.000 0.000 0.000 0.000
#> GSM39841 1 0.6483 -0.0948 0.444 0 0.000 0.288 0.028 0.240
#> GSM39842 1 0.0000 0.8990 1.000 0 0.000 0.000 0.000 0.000
#> GSM39843 4 0.5533 0.5847 0.184 0 0.028 0.632 0.000 0.156
#> GSM39844 1 0.0000 0.8990 1.000 0 0.000 0.000 0.000 0.000
#> GSM39845 3 0.0632 0.7107 0.000 0 0.976 0.000 0.000 0.024
#> GSM39852 4 0.0862 0.7438 0.008 0 0.000 0.972 0.004 0.016
#> GSM39853 4 0.6760 0.4950 0.056 0 0.000 0.436 0.208 0.300
#> GSM39854 4 0.6574 0.5276 0.044 0 0.000 0.468 0.216 0.272
#> GSM39857 3 0.1461 0.7045 0.000 0 0.940 0.000 0.044 0.016
#> GSM39860 5 0.1863 0.9150 0.000 0 0.004 0.060 0.920 0.016
#> GSM39861 3 0.1387 0.6496 0.000 0 0.932 0.000 0.000 0.068
#> GSM39864 4 0.0951 0.7435 0.008 0 0.000 0.968 0.004 0.020
#> GSM39868 4 0.0862 0.7438 0.008 0 0.000 0.972 0.004 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> MAD:mclust 58 3.53e-03 5.72e-03 2
#> MAD:mclust 58 2.54e-13 1.24e-11 3
#> MAD:mclust 54 1.12e-11 2.21e-09 4
#> MAD:mclust 48 9.44e-10 6.22e-08 5
#> MAD:mclust 50 1.39e-09 1.18e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.322 0.665 0.801 0.4881 0.506 0.506
#> 3 3 0.730 0.852 0.931 0.3580 0.659 0.421
#> 4 4 0.655 0.677 0.845 0.1191 0.868 0.640
#> 5 5 0.669 0.579 0.802 0.0764 0.860 0.541
#> 6 6 0.708 0.553 0.780 0.0391 0.895 0.565
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.7299 0.735 0.204 0.796
#> GSM39874 2 0.6343 0.749 0.160 0.840
#> GSM39875 2 0.5408 0.754 0.124 0.876
#> GSM39876 2 0.5178 0.754 0.116 0.884
#> GSM39831 1 0.0000 0.798 1.000 0.000
#> GSM39819 1 0.9000 0.621 0.684 0.316
#> GSM39820 1 0.9129 0.608 0.672 0.328
#> GSM39821 1 0.0000 0.798 1.000 0.000
#> GSM39822 2 0.8813 0.678 0.300 0.700
#> GSM39823 2 0.3274 0.716 0.060 0.940
#> GSM39824 2 0.0938 0.726 0.012 0.988
#> GSM39825 1 0.9044 0.617 0.680 0.320
#> GSM39826 1 0.2043 0.770 0.968 0.032
#> GSM39827 1 0.0000 0.798 1.000 0.000
#> GSM39846 2 0.4161 0.705 0.084 0.916
#> GSM39847 1 0.0000 0.798 1.000 0.000
#> GSM39848 2 0.8267 0.706 0.260 0.740
#> GSM39849 2 0.7219 0.583 0.200 0.800
#> GSM39850 1 0.0000 0.798 1.000 0.000
#> GSM39851 1 0.0000 0.798 1.000 0.000
#> GSM39855 2 0.0938 0.726 0.012 0.988
#> GSM39856 2 0.4298 0.702 0.088 0.912
#> GSM39858 1 0.9963 0.381 0.536 0.464
#> GSM39859 1 0.9944 0.399 0.544 0.456
#> GSM39862 2 0.7950 0.732 0.240 0.760
#> GSM39863 1 0.0000 0.798 1.000 0.000
#> GSM39865 2 0.2603 0.742 0.044 0.956
#> GSM39866 1 0.6712 0.718 0.824 0.176
#> GSM39867 1 0.4022 0.718 0.920 0.080
#> GSM39869 2 0.8861 0.675 0.304 0.696
#> GSM39870 1 0.9129 0.608 0.672 0.328
#> GSM39871 2 0.9850 -0.100 0.428 0.572
#> GSM39872 2 0.7056 0.596 0.192 0.808
#> GSM39828 1 0.0000 0.798 1.000 0.000
#> GSM39829 1 0.8909 0.628 0.692 0.308
#> GSM39830 1 0.8144 0.670 0.748 0.252
#> GSM39832 1 0.0000 0.798 1.000 0.000
#> GSM39833 2 0.9815 0.578 0.420 0.580
#> GSM39834 1 0.1414 0.784 0.980 0.020
#> GSM39835 2 0.9996 0.417 0.488 0.512
#> GSM39836 1 0.0000 0.798 1.000 0.000
#> GSM39837 2 0.9460 0.619 0.364 0.636
#> GSM39838 2 0.8955 0.668 0.312 0.688
#> GSM39839 1 0.8909 0.628 0.692 0.308
#> GSM39840 1 0.0000 0.798 1.000 0.000
#> GSM39841 1 0.0000 0.798 1.000 0.000
#> GSM39842 1 0.0000 0.798 1.000 0.000
#> GSM39843 1 0.0000 0.798 1.000 0.000
#> GSM39844 1 0.0000 0.798 1.000 0.000
#> GSM39845 1 0.9732 0.503 0.596 0.404
#> GSM39852 1 0.0000 0.798 1.000 0.000
#> GSM39853 2 0.9580 0.605 0.380 0.620
#> GSM39854 1 0.9998 -0.415 0.508 0.492
#> GSM39857 2 0.3879 0.710 0.076 0.924
#> GSM39860 2 0.0000 0.725 0.000 1.000
#> GSM39861 1 0.9732 0.504 0.596 0.404
#> GSM39864 1 0.0938 0.795 0.988 0.012
#> GSM39868 1 0.5842 0.739 0.860 0.140
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.892 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.892 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.892 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.892 0.000 1.000 0.000
#> GSM39831 1 0.0237 0.955 0.996 0.000 0.004
#> GSM39819 3 0.4931 0.716 0.232 0.000 0.768
#> GSM39820 3 0.3267 0.842 0.116 0.000 0.884
#> GSM39821 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39822 2 0.0237 0.892 0.004 0.996 0.000
#> GSM39823 3 0.0237 0.901 0.000 0.004 0.996
#> GSM39824 3 0.0424 0.900 0.000 0.008 0.992
#> GSM39825 3 0.1643 0.885 0.044 0.000 0.956
#> GSM39826 1 0.4887 0.636 0.772 0.228 0.000
#> GSM39827 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39846 3 0.0237 0.901 0.000 0.004 0.996
#> GSM39847 1 0.0237 0.955 0.996 0.000 0.004
#> GSM39848 2 0.0237 0.890 0.000 0.996 0.004
#> GSM39849 3 0.0237 0.901 0.000 0.004 0.996
#> GSM39850 1 0.0237 0.953 0.996 0.004 0.000
#> GSM39851 1 0.0237 0.955 0.996 0.000 0.004
#> GSM39855 3 0.1031 0.891 0.000 0.024 0.976
#> GSM39856 3 0.0237 0.901 0.000 0.004 0.996
#> GSM39858 3 0.0000 0.901 0.000 0.000 1.000
#> GSM39859 3 0.0000 0.901 0.000 0.000 1.000
#> GSM39862 3 0.8052 0.574 0.196 0.152 0.652
#> GSM39863 1 0.0237 0.955 0.996 0.000 0.004
#> GSM39865 2 0.0237 0.890 0.000 0.996 0.004
#> GSM39866 1 0.4235 0.767 0.824 0.000 0.176
#> GSM39867 2 0.6180 0.395 0.416 0.584 0.000
#> GSM39869 2 0.0237 0.892 0.004 0.996 0.000
#> GSM39870 3 0.3340 0.840 0.120 0.000 0.880
#> GSM39871 3 0.0000 0.901 0.000 0.000 1.000
#> GSM39872 3 0.0237 0.901 0.000 0.004 0.996
#> GSM39828 1 0.0237 0.955 0.996 0.000 0.004
#> GSM39829 3 0.5650 0.583 0.312 0.000 0.688
#> GSM39830 1 0.4931 0.672 0.768 0.000 0.232
#> GSM39832 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39833 2 0.4834 0.752 0.204 0.792 0.004
#> GSM39834 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39835 2 0.5905 0.550 0.352 0.648 0.000
#> GSM39836 1 0.0747 0.943 0.984 0.016 0.000
#> GSM39837 2 0.1529 0.882 0.040 0.960 0.000
#> GSM39838 2 0.0424 0.892 0.008 0.992 0.000
#> GSM39839 3 0.3619 0.827 0.136 0.000 0.864
#> GSM39840 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39841 1 0.0424 0.951 0.992 0.008 0.000
#> GSM39842 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39843 1 0.0747 0.947 0.984 0.000 0.016
#> GSM39844 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39845 3 0.0000 0.901 0.000 0.000 1.000
#> GSM39852 1 0.0000 0.955 1.000 0.000 0.000
#> GSM39853 2 0.2261 0.870 0.068 0.932 0.000
#> GSM39854 2 0.5397 0.667 0.280 0.720 0.000
#> GSM39857 3 0.0237 0.901 0.000 0.004 0.996
#> GSM39860 3 0.6286 0.181 0.000 0.464 0.536
#> GSM39861 3 0.0000 0.901 0.000 0.000 1.000
#> GSM39864 1 0.0592 0.950 0.988 0.000 0.012
#> GSM39868 1 0.2165 0.904 0.936 0.000 0.064
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.899 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.899 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.899 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.899 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0336 0.784 0.992 0.000 0.000 0.008
#> GSM39819 3 0.3975 0.640 0.240 0.000 0.760 0.000
#> GSM39820 3 0.1637 0.791 0.060 0.000 0.940 0.000
#> GSM39821 1 0.3688 0.728 0.792 0.000 0.000 0.208
#> GSM39822 2 0.0188 0.898 0.000 0.996 0.000 0.004
#> GSM39823 3 0.4564 0.562 0.000 0.000 0.672 0.328
#> GSM39824 3 0.5126 0.371 0.000 0.004 0.552 0.444
#> GSM39825 3 0.5036 0.614 0.024 0.000 0.696 0.280
#> GSM39826 1 0.4891 0.617 0.680 0.012 0.000 0.308
#> GSM39827 1 0.2216 0.777 0.908 0.000 0.000 0.092
#> GSM39846 3 0.0707 0.808 0.000 0.000 0.980 0.020
#> GSM39847 1 0.3528 0.741 0.808 0.000 0.000 0.192
#> GSM39848 4 0.0817 0.727 0.000 0.024 0.000 0.976
#> GSM39849 3 0.1059 0.809 0.012 0.000 0.972 0.016
#> GSM39850 1 0.3764 0.722 0.784 0.000 0.000 0.216
#> GSM39851 1 0.0376 0.781 0.992 0.000 0.004 0.004
#> GSM39855 3 0.5155 0.320 0.000 0.004 0.528 0.468
#> GSM39856 3 0.0817 0.807 0.000 0.000 0.976 0.024
#> GSM39858 3 0.0000 0.808 0.000 0.000 1.000 0.000
#> GSM39859 3 0.1389 0.800 0.000 0.000 0.952 0.048
#> GSM39862 4 0.0336 0.727 0.000 0.000 0.008 0.992
#> GSM39863 1 0.0188 0.780 0.996 0.000 0.004 0.000
#> GSM39865 2 0.2973 0.779 0.000 0.856 0.000 0.144
#> GSM39866 1 0.4399 0.667 0.760 0.000 0.016 0.224
#> GSM39867 1 0.6815 0.471 0.580 0.284 0.000 0.136
#> GSM39869 2 0.0707 0.891 0.000 0.980 0.000 0.020
#> GSM39870 3 0.1637 0.791 0.060 0.000 0.940 0.000
#> GSM39871 3 0.0336 0.808 0.000 0.000 0.992 0.008
#> GSM39872 4 0.4040 0.414 0.000 0.000 0.248 0.752
#> GSM39828 1 0.4454 0.628 0.692 0.000 0.000 0.308
#> GSM39829 3 0.3172 0.721 0.160 0.000 0.840 0.000
#> GSM39830 1 0.4996 -0.114 0.516 0.000 0.484 0.000
#> GSM39832 1 0.0817 0.786 0.976 0.000 0.000 0.024
#> GSM39833 2 0.4131 0.733 0.156 0.816 0.020 0.008
#> GSM39834 4 0.2868 0.667 0.136 0.000 0.000 0.864
#> GSM39835 1 0.6790 0.509 0.608 0.196 0.000 0.196
#> GSM39836 1 0.4989 0.311 0.528 0.000 0.000 0.472
#> GSM39837 2 0.0336 0.898 0.008 0.992 0.000 0.000
#> GSM39838 4 0.6307 0.413 0.092 0.288 0.000 0.620
#> GSM39839 3 0.3486 0.697 0.188 0.000 0.812 0.000
#> GSM39840 1 0.0921 0.786 0.972 0.000 0.000 0.028
#> GSM39841 1 0.1452 0.757 0.956 0.008 0.036 0.000
#> GSM39842 1 0.0188 0.783 0.996 0.000 0.000 0.004
#> GSM39843 1 0.1724 0.772 0.948 0.000 0.032 0.020
#> GSM39844 1 0.0469 0.785 0.988 0.000 0.000 0.012
#> GSM39845 3 0.1109 0.808 0.004 0.000 0.968 0.028
#> GSM39852 4 0.4746 0.117 0.368 0.000 0.000 0.632
#> GSM39853 2 0.0336 0.898 0.008 0.992 0.000 0.000
#> GSM39854 2 0.6881 0.175 0.340 0.540 0.000 0.120
#> GSM39857 3 0.4985 0.328 0.000 0.000 0.532 0.468
#> GSM39860 4 0.3401 0.583 0.000 0.008 0.152 0.840
#> GSM39861 3 0.0592 0.806 0.016 0.000 0.984 0.000
#> GSM39864 1 0.3764 0.716 0.784 0.000 0.000 0.216
#> GSM39868 4 0.2530 0.692 0.112 0.000 0.000 0.888
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.907838 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.907838 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.907838 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.907838 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.3586 0.611237 0.736 0.000 0.000 0.264 0.000
#> GSM39819 3 0.2457 0.773845 0.076 0.000 0.900 0.008 0.016
#> GSM39820 3 0.1372 0.797420 0.004 0.000 0.956 0.024 0.016
#> GSM39821 4 0.0510 0.638190 0.016 0.000 0.000 0.984 0.000
#> GSM39822 2 0.0290 0.906270 0.000 0.992 0.000 0.008 0.000
#> GSM39823 3 0.4166 0.371920 0.004 0.000 0.648 0.000 0.348
#> GSM39824 3 0.4546 0.024603 0.008 0.000 0.532 0.000 0.460
#> GSM39825 3 0.5946 0.482704 0.028 0.000 0.644 0.108 0.220
#> GSM39826 4 0.1329 0.639566 0.032 0.004 0.000 0.956 0.008
#> GSM39827 4 0.3243 0.511663 0.180 0.004 0.000 0.812 0.004
#> GSM39846 3 0.0404 0.804208 0.000 0.000 0.988 0.000 0.012
#> GSM39847 4 0.0451 0.640442 0.008 0.000 0.000 0.988 0.004
#> GSM39848 5 0.2064 0.711378 0.020 0.028 0.004 0.016 0.932
#> GSM39849 3 0.6149 0.364248 0.340 0.000 0.536 0.008 0.116
#> GSM39850 4 0.1041 0.637046 0.032 0.000 0.000 0.964 0.004
#> GSM39851 4 0.3550 0.396553 0.236 0.000 0.000 0.760 0.004
#> GSM39855 5 0.4510 0.165687 0.008 0.000 0.432 0.000 0.560
#> GSM39856 3 0.1216 0.801907 0.020 0.000 0.960 0.000 0.020
#> GSM39858 3 0.0451 0.804507 0.004 0.000 0.988 0.000 0.008
#> GSM39859 3 0.0693 0.803829 0.008 0.000 0.980 0.000 0.012
#> GSM39862 5 0.2283 0.712749 0.036 0.000 0.008 0.040 0.916
#> GSM39863 1 0.4333 0.495517 0.640 0.000 0.004 0.352 0.004
#> GSM39865 2 0.2329 0.818308 0.000 0.876 0.000 0.000 0.124
#> GSM39866 4 0.6568 0.203916 0.276 0.000 0.012 0.528 0.184
#> GSM39867 1 0.6612 0.499618 0.592 0.104 0.000 0.240 0.064
#> GSM39869 2 0.2124 0.849993 0.004 0.900 0.000 0.000 0.096
#> GSM39870 3 0.2586 0.763253 0.012 0.000 0.892 0.084 0.012
#> GSM39871 3 0.0912 0.804106 0.016 0.000 0.972 0.000 0.012
#> GSM39872 5 0.3090 0.708011 0.088 0.000 0.052 0.000 0.860
#> GSM39828 4 0.4901 0.471012 0.196 0.000 0.000 0.708 0.096
#> GSM39829 3 0.2251 0.781244 0.024 0.000 0.916 0.052 0.008
#> GSM39830 3 0.6926 0.125015 0.316 0.000 0.444 0.228 0.012
#> GSM39832 1 0.2732 0.652967 0.840 0.000 0.000 0.160 0.000
#> GSM39833 1 0.7504 0.092263 0.424 0.336 0.000 0.180 0.060
#> GSM39834 5 0.3579 0.632131 0.072 0.000 0.000 0.100 0.828
#> GSM39835 1 0.3599 0.515006 0.828 0.016 0.000 0.024 0.132
#> GSM39836 4 0.1792 0.623026 0.000 0.000 0.000 0.916 0.084
#> GSM39837 2 0.0609 0.898892 0.000 0.980 0.000 0.020 0.000
#> GSM39838 4 0.6945 0.194342 0.012 0.264 0.000 0.452 0.272
#> GSM39839 3 0.2332 0.778228 0.076 0.000 0.904 0.004 0.016
#> GSM39840 1 0.4305 0.203922 0.512 0.000 0.000 0.488 0.000
#> GSM39841 1 0.5309 0.584409 0.656 0.040 0.008 0.284 0.012
#> GSM39842 1 0.1364 0.597802 0.952 0.000 0.000 0.036 0.012
#> GSM39843 4 0.4875 0.127594 0.400 0.000 0.020 0.576 0.004
#> GSM39844 1 0.2929 0.652216 0.820 0.000 0.000 0.180 0.000
#> GSM39845 3 0.0451 0.804824 0.004 0.000 0.988 0.000 0.008
#> GSM39852 4 0.4152 0.479153 0.012 0.000 0.000 0.692 0.296
#> GSM39853 2 0.0324 0.906636 0.004 0.992 0.000 0.004 0.000
#> GSM39854 2 0.6887 -0.008361 0.388 0.464 0.000 0.080 0.068
#> GSM39857 5 0.4574 0.223424 0.012 0.000 0.412 0.000 0.576
#> GSM39860 5 0.1106 0.723235 0.012 0.000 0.024 0.000 0.964
#> GSM39861 3 0.0324 0.804129 0.000 0.000 0.992 0.004 0.004
#> GSM39864 4 0.6088 -0.000751 0.380 0.000 0.000 0.492 0.128
#> GSM39868 5 0.5087 0.345999 0.064 0.000 0.000 0.292 0.644
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.0000 0.9102 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM39874 5 0.0146 0.9105 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM39875 5 0.0146 0.9105 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM39876 5 0.0146 0.9105 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM39831 1 0.2357 0.5802 0.872 0.116 0.000 0.012 0.000 0.000
#> GSM39819 3 0.3234 0.7485 0.048 0.056 0.860 0.024 0.000 0.012
#> GSM39820 3 0.1973 0.7882 0.036 0.028 0.924 0.000 0.004 0.008
#> GSM39821 4 0.0405 0.7708 0.008 0.000 0.000 0.988 0.000 0.004
#> GSM39822 5 0.1176 0.8994 0.000 0.020 0.000 0.024 0.956 0.000
#> GSM39823 3 0.4658 0.2296 0.004 0.040 0.580 0.000 0.000 0.376
#> GSM39824 3 0.4289 0.3098 0.000 0.028 0.612 0.000 0.000 0.360
#> GSM39825 3 0.6172 0.3112 0.000 0.044 0.540 0.268 0.000 0.148
#> GSM39826 4 0.0922 0.7703 0.000 0.024 0.000 0.968 0.004 0.004
#> GSM39827 1 0.4644 0.1049 0.524 0.032 0.000 0.440 0.004 0.000
#> GSM39846 3 0.0717 0.8044 0.000 0.016 0.976 0.000 0.000 0.008
#> GSM39847 4 0.0767 0.7699 0.012 0.008 0.000 0.976 0.000 0.004
#> GSM39848 6 0.3504 0.4638 0.000 0.112 0.000 0.016 0.052 0.820
#> GSM39849 2 0.5262 0.2232 0.004 0.612 0.268 0.004 0.000 0.112
#> GSM39850 4 0.0653 0.7713 0.004 0.012 0.000 0.980 0.000 0.004
#> GSM39851 4 0.1749 0.7585 0.024 0.036 0.000 0.932 0.000 0.008
#> GSM39855 6 0.4532 -0.0345 0.000 0.032 0.468 0.000 0.000 0.500
#> GSM39856 3 0.1745 0.7927 0.000 0.056 0.924 0.000 0.000 0.020
#> GSM39858 3 0.0603 0.8045 0.000 0.016 0.980 0.000 0.000 0.004
#> GSM39859 3 0.0993 0.8038 0.000 0.024 0.964 0.000 0.000 0.012
#> GSM39862 6 0.3683 0.4049 0.000 0.192 0.000 0.044 0.000 0.764
#> GSM39863 1 0.1989 0.6066 0.916 0.052 0.004 0.028 0.000 0.000
#> GSM39865 5 0.4268 0.5513 0.004 0.040 0.000 0.000 0.684 0.272
#> GSM39866 1 0.6021 0.4240 0.636 0.160 0.032 0.008 0.016 0.148
#> GSM39867 1 0.3003 0.5836 0.860 0.084 0.000 0.000 0.028 0.028
#> GSM39869 5 0.2448 0.8465 0.000 0.052 0.000 0.000 0.884 0.064
#> GSM39870 3 0.4886 0.4458 0.300 0.076 0.620 0.000 0.004 0.000
#> GSM39871 3 0.1265 0.8001 0.000 0.044 0.948 0.000 0.000 0.008
#> GSM39872 6 0.4494 0.3887 0.004 0.224 0.076 0.000 0.000 0.696
#> GSM39828 4 0.1391 0.7654 0.000 0.040 0.000 0.944 0.000 0.016
#> GSM39829 3 0.3499 0.7311 0.108 0.036 0.832 0.012 0.004 0.008
#> GSM39830 4 0.6850 0.1141 0.032 0.252 0.272 0.432 0.000 0.012
#> GSM39832 1 0.3133 0.4912 0.780 0.212 0.000 0.008 0.000 0.000
#> GSM39833 4 0.6227 0.1686 0.004 0.420 0.016 0.448 0.088 0.024
#> GSM39834 6 0.5227 0.3799 0.232 0.144 0.000 0.004 0.000 0.620
#> GSM39835 2 0.4981 0.4098 0.136 0.700 0.000 0.000 0.028 0.136
#> GSM39836 4 0.1078 0.7619 0.012 0.008 0.000 0.964 0.000 0.016
#> GSM39837 5 0.2810 0.7743 0.000 0.008 0.000 0.156 0.832 0.004
#> GSM39838 6 0.8327 0.1423 0.120 0.108 0.000 0.136 0.288 0.348
#> GSM39839 3 0.2816 0.7644 0.044 0.064 0.876 0.004 0.000 0.012
#> GSM39840 4 0.5140 0.4614 0.164 0.192 0.000 0.640 0.000 0.004
#> GSM39841 1 0.5968 0.3375 0.632 0.196 0.008 0.112 0.044 0.008
#> GSM39842 2 0.4227 -0.0877 0.492 0.496 0.000 0.004 0.000 0.008
#> GSM39843 4 0.2292 0.7343 0.004 0.104 0.004 0.884 0.000 0.004
#> GSM39844 1 0.2848 0.5354 0.816 0.176 0.000 0.008 0.000 0.000
#> GSM39845 3 0.0520 0.8040 0.000 0.008 0.984 0.000 0.000 0.008
#> GSM39852 4 0.7055 -0.0956 0.140 0.120 0.000 0.392 0.000 0.348
#> GSM39853 5 0.0665 0.9074 0.004 0.008 0.000 0.008 0.980 0.000
#> GSM39854 1 0.4415 0.4719 0.732 0.048 0.000 0.000 0.192 0.028
#> GSM39857 6 0.4578 0.0230 0.000 0.036 0.444 0.000 0.000 0.520
#> GSM39860 6 0.1837 0.4955 0.000 0.044 0.020 0.004 0.004 0.928
#> GSM39861 3 0.0405 0.8051 0.000 0.008 0.988 0.000 0.000 0.004
#> GSM39864 1 0.4526 0.5054 0.740 0.116 0.012 0.004 0.000 0.128
#> GSM39868 6 0.5829 0.2929 0.284 0.168 0.012 0.000 0.000 0.536
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> MAD:NMF 53 0.052206 0.02885 2
#> MAD:NMF 56 0.001562 0.00174 3
#> MAD:NMF 48 0.000861 0.01101 4
#> MAD:NMF 38 0.006108 0.00454 5
#> MAD:NMF 33 0.006925 0.03581 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.731 0.907 0.955 0.3330 0.687 0.687
#> 3 3 0.414 0.633 0.815 0.6281 0.670 0.533
#> 4 4 0.419 0.505 0.754 0.1824 0.883 0.731
#> 5 5 0.484 0.587 0.755 0.0977 0.894 0.718
#> 6 6 0.596 0.273 0.611 0.0691 0.785 0.413
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0000 0.933 0.000 1.000
#> GSM39874 2 0.0000 0.933 0.000 1.000
#> GSM39875 2 0.0000 0.933 0.000 1.000
#> GSM39876 2 0.0000 0.933 0.000 1.000
#> GSM39831 1 0.0000 0.954 1.000 0.000
#> GSM39819 1 0.0000 0.954 1.000 0.000
#> GSM39820 1 0.0000 0.954 1.000 0.000
#> GSM39821 1 0.0000 0.954 1.000 0.000
#> GSM39822 2 0.9129 0.495 0.328 0.672
#> GSM39823 1 0.4815 0.887 0.896 0.104
#> GSM39824 2 0.0672 0.931 0.008 0.992
#> GSM39825 1 0.0000 0.954 1.000 0.000
#> GSM39826 1 0.1184 0.948 0.984 0.016
#> GSM39827 1 0.0376 0.953 0.996 0.004
#> GSM39846 1 0.4939 0.884 0.892 0.108
#> GSM39847 1 0.0000 0.954 1.000 0.000
#> GSM39848 2 0.0000 0.933 0.000 1.000
#> GSM39849 1 0.6973 0.795 0.812 0.188
#> GSM39850 1 0.1184 0.948 0.984 0.016
#> GSM39851 1 0.0000 0.954 1.000 0.000
#> GSM39855 2 0.0672 0.931 0.008 0.992
#> GSM39856 1 0.4939 0.884 0.892 0.108
#> GSM39858 1 0.0000 0.954 1.000 0.000
#> GSM39859 1 0.0000 0.954 1.000 0.000
#> GSM39862 1 0.8555 0.653 0.720 0.280
#> GSM39863 1 0.0000 0.954 1.000 0.000
#> GSM39865 2 0.8081 0.658 0.248 0.752
#> GSM39866 1 0.0000 0.954 1.000 0.000
#> GSM39867 1 0.0376 0.953 0.996 0.004
#> GSM39869 2 0.0938 0.929 0.012 0.988
#> GSM39870 1 0.0000 0.954 1.000 0.000
#> GSM39871 1 0.0938 0.950 0.988 0.012
#> GSM39872 1 0.4939 0.884 0.892 0.108
#> GSM39828 1 0.0000 0.954 1.000 0.000
#> GSM39829 1 0.0000 0.954 1.000 0.000
#> GSM39830 1 0.0000 0.954 1.000 0.000
#> GSM39832 1 0.0000 0.954 1.000 0.000
#> GSM39833 1 0.5842 0.852 0.860 0.140
#> GSM39834 1 0.1184 0.948 0.984 0.016
#> GSM39835 1 0.9358 0.504 0.648 0.352
#> GSM39836 1 0.3879 0.910 0.924 0.076
#> GSM39837 1 0.8443 0.667 0.728 0.272
#> GSM39838 1 0.3879 0.910 0.924 0.076
#> GSM39839 1 0.0000 0.954 1.000 0.000
#> GSM39840 1 0.0000 0.954 1.000 0.000
#> GSM39841 1 0.0000 0.954 1.000 0.000
#> GSM39842 1 0.0000 0.954 1.000 0.000
#> GSM39843 1 0.0000 0.954 1.000 0.000
#> GSM39844 1 0.0000 0.954 1.000 0.000
#> GSM39845 1 0.0000 0.954 1.000 0.000
#> GSM39852 1 0.0000 0.954 1.000 0.000
#> GSM39853 1 0.1633 0.944 0.976 0.024
#> GSM39854 1 0.1414 0.946 0.980 0.020
#> GSM39857 1 0.4815 0.887 0.896 0.104
#> GSM39860 2 0.0000 0.933 0.000 1.000
#> GSM39861 1 0.0000 0.954 1.000 0.000
#> GSM39864 1 0.0000 0.954 1.000 0.000
#> GSM39868 1 0.0000 0.954 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.3752 0.924 0.000 0.856 0.144
#> GSM39874 2 0.3752 0.924 0.000 0.856 0.144
#> GSM39875 2 0.3752 0.924 0.000 0.856 0.144
#> GSM39876 2 0.3752 0.924 0.000 0.856 0.144
#> GSM39831 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39819 1 0.1529 0.834 0.960 0.000 0.040
#> GSM39820 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39821 1 0.3752 0.752 0.856 0.000 0.144
#> GSM39822 3 0.6540 -0.352 0.008 0.408 0.584
#> GSM39823 3 0.6299 0.410 0.476 0.000 0.524
#> GSM39824 2 0.1964 0.903 0.000 0.944 0.056
#> GSM39825 1 0.3192 0.796 0.888 0.000 0.112
#> GSM39826 3 0.6286 0.380 0.464 0.000 0.536
#> GSM39827 1 0.6252 -0.134 0.556 0.000 0.444
#> GSM39846 3 0.6286 0.435 0.464 0.000 0.536
#> GSM39847 1 0.3686 0.757 0.860 0.000 0.140
#> GSM39848 2 0.0424 0.906 0.000 0.992 0.008
#> GSM39849 3 0.5706 0.566 0.320 0.000 0.680
#> GSM39850 3 0.6295 0.359 0.472 0.000 0.528
#> GSM39851 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39855 2 0.1964 0.903 0.000 0.944 0.056
#> GSM39856 3 0.6286 0.435 0.464 0.000 0.536
#> GSM39858 1 0.3116 0.799 0.892 0.000 0.108
#> GSM39859 1 0.3038 0.802 0.896 0.000 0.104
#> GSM39862 3 0.5852 0.569 0.152 0.060 0.788
#> GSM39863 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39865 3 0.6683 -0.524 0.008 0.496 0.496
#> GSM39866 1 0.0237 0.837 0.996 0.000 0.004
#> GSM39867 1 0.6252 -0.134 0.556 0.000 0.444
#> GSM39869 2 0.4842 0.878 0.000 0.776 0.224
#> GSM39870 1 0.0237 0.837 0.996 0.000 0.004
#> GSM39871 1 0.5098 0.560 0.752 0.000 0.248
#> GSM39872 3 0.6286 0.435 0.464 0.000 0.536
#> GSM39828 1 0.3816 0.760 0.852 0.000 0.148
#> GSM39829 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39830 1 0.0747 0.838 0.984 0.000 0.016
#> GSM39832 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39833 3 0.5016 0.604 0.240 0.000 0.760
#> GSM39834 1 0.6260 -0.175 0.552 0.000 0.448
#> GSM39835 3 0.0661 0.390 0.008 0.004 0.988
#> GSM39836 3 0.6045 0.518 0.380 0.000 0.620
#> GSM39837 3 0.5138 0.536 0.120 0.052 0.828
#> GSM39838 3 0.6045 0.518 0.380 0.000 0.620
#> GSM39839 1 0.1529 0.834 0.960 0.000 0.040
#> GSM39840 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39841 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39842 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39843 1 0.3192 0.795 0.888 0.000 0.112
#> GSM39844 1 0.0000 0.838 1.000 0.000 0.000
#> GSM39845 1 0.1031 0.838 0.976 0.000 0.024
#> GSM39852 1 0.3340 0.781 0.880 0.000 0.120
#> GSM39853 3 0.5926 0.557 0.356 0.000 0.644
#> GSM39854 3 0.5948 0.552 0.360 0.000 0.640
#> GSM39857 3 0.6299 0.410 0.476 0.000 0.524
#> GSM39860 2 0.0424 0.906 0.000 0.992 0.008
#> GSM39861 1 0.3038 0.802 0.896 0.000 0.104
#> GSM39864 1 0.1643 0.833 0.956 0.000 0.044
#> GSM39868 1 0.5621 0.361 0.692 0.000 0.308
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.3528 0.8785 0.000 0.808 0.000 0.192
#> GSM39874 2 0.3528 0.8785 0.000 0.808 0.000 0.192
#> GSM39875 2 0.3528 0.8785 0.000 0.808 0.000 0.192
#> GSM39876 2 0.3528 0.8785 0.000 0.808 0.000 0.192
#> GSM39831 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39819 1 0.2921 0.6865 0.860 0.000 0.140 0.000
#> GSM39820 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39821 1 0.4423 0.6471 0.788 0.000 0.176 0.036
#> GSM39822 4 0.5578 -0.2828 0.000 0.312 0.040 0.648
#> GSM39823 3 0.3401 0.7171 0.152 0.000 0.840 0.008
#> GSM39824 2 0.2563 0.8336 0.000 0.908 0.020 0.072
#> GSM39825 1 0.4936 0.4253 0.624 0.000 0.372 0.004
#> GSM39826 1 0.7921 -0.2696 0.348 0.000 0.328 0.324
#> GSM39827 1 0.7553 0.0715 0.476 0.000 0.216 0.308
#> GSM39846 3 0.3300 0.7236 0.144 0.000 0.848 0.008
#> GSM39847 1 0.4379 0.6507 0.792 0.000 0.172 0.036
#> GSM39848 2 0.0000 0.8514 0.000 1.000 0.000 0.000
#> GSM39849 3 0.2840 0.5654 0.044 0.000 0.900 0.056
#> GSM39850 1 0.7909 -0.2319 0.364 0.000 0.312 0.324
#> GSM39851 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39855 2 0.2563 0.8336 0.000 0.908 0.020 0.072
#> GSM39856 3 0.3300 0.7236 0.144 0.000 0.848 0.008
#> GSM39858 1 0.4907 0.3217 0.580 0.000 0.420 0.000
#> GSM39859 1 0.4898 0.3310 0.584 0.000 0.416 0.000
#> GSM39862 3 0.6377 0.1243 0.040 0.016 0.568 0.376
#> GSM39863 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39865 4 0.5487 -0.4529 0.000 0.400 0.020 0.580
#> GSM39866 1 0.0469 0.7246 0.988 0.000 0.000 0.012
#> GSM39867 1 0.7553 0.0715 0.476 0.000 0.216 0.308
#> GSM39869 2 0.4522 0.8113 0.000 0.680 0.000 0.320
#> GSM39870 1 0.0469 0.7246 0.988 0.000 0.000 0.012
#> GSM39871 3 0.5112 0.0490 0.436 0.000 0.560 0.004
#> GSM39872 3 0.3300 0.7236 0.144 0.000 0.848 0.008
#> GSM39828 1 0.5003 0.5292 0.676 0.000 0.308 0.016
#> GSM39829 1 0.0336 0.7271 0.992 0.000 0.008 0.000
#> GSM39830 1 0.1022 0.7265 0.968 0.000 0.032 0.000
#> GSM39832 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39833 3 0.5817 0.2680 0.076 0.000 0.676 0.248
#> GSM39834 1 0.7731 -0.0190 0.428 0.000 0.332 0.240
#> GSM39835 4 0.4713 0.1008 0.000 0.000 0.360 0.640
#> GSM39836 4 0.7799 0.1621 0.272 0.000 0.308 0.420
#> GSM39837 4 0.4767 0.2437 0.020 0.000 0.256 0.724
#> GSM39838 4 0.7799 0.1621 0.272 0.000 0.308 0.420
#> GSM39839 1 0.2921 0.6865 0.860 0.000 0.140 0.000
#> GSM39840 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39841 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39842 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39843 1 0.4605 0.4901 0.664 0.000 0.336 0.000
#> GSM39844 1 0.0000 0.7284 1.000 0.000 0.000 0.000
#> GSM39845 1 0.2345 0.7113 0.900 0.000 0.100 0.000
#> GSM39852 1 0.4057 0.6681 0.816 0.000 0.152 0.032
#> GSM39853 4 0.7731 0.1718 0.240 0.000 0.332 0.428
#> GSM39854 4 0.7748 0.1697 0.244 0.000 0.332 0.424
#> GSM39857 3 0.3401 0.7171 0.152 0.000 0.840 0.008
#> GSM39860 2 0.0000 0.8514 0.000 1.000 0.000 0.000
#> GSM39861 1 0.4804 0.3891 0.616 0.000 0.384 0.000
#> GSM39864 1 0.2198 0.7177 0.920 0.000 0.072 0.008
#> GSM39868 1 0.6897 0.3688 0.588 0.000 0.244 0.168
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.3366 0.7494 0.000 0.768 0.000 0.000 0.232
#> GSM39874 2 0.3366 0.7494 0.000 0.768 0.000 0.000 0.232
#> GSM39875 2 0.3366 0.7494 0.000 0.768 0.000 0.000 0.232
#> GSM39876 2 0.3366 0.7494 0.000 0.768 0.000 0.000 0.232
#> GSM39831 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39819 1 0.2763 0.7215 0.848 0.000 0.148 0.004 0.000
#> GSM39820 1 0.0566 0.7624 0.984 0.000 0.004 0.012 0.000
#> GSM39821 1 0.4504 0.5986 0.748 0.000 0.084 0.168 0.000
#> GSM39822 5 0.6905 0.2968 0.000 0.300 0.004 0.300 0.396
#> GSM39823 3 0.2540 0.7290 0.088 0.000 0.888 0.024 0.000
#> GSM39824 2 0.2824 0.6477 0.000 0.864 0.020 0.000 0.116
#> GSM39825 1 0.4574 0.3827 0.576 0.000 0.412 0.012 0.000
#> GSM39826 4 0.4974 0.7625 0.212 0.000 0.092 0.696 0.000
#> GSM39827 4 0.5750 0.6045 0.388 0.000 0.024 0.544 0.044
#> GSM39846 3 0.2017 0.7309 0.080 0.000 0.912 0.008 0.000
#> GSM39847 1 0.4449 0.6042 0.752 0.000 0.080 0.168 0.000
#> GSM39848 2 0.0162 0.7149 0.000 0.996 0.000 0.004 0.000
#> GSM39849 3 0.1914 0.5969 0.000 0.000 0.924 0.016 0.060
#> GSM39850 4 0.4879 0.7615 0.228 0.000 0.076 0.696 0.000
#> GSM39851 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39855 2 0.2824 0.6477 0.000 0.864 0.020 0.000 0.116
#> GSM39856 3 0.2017 0.7309 0.080 0.000 0.912 0.008 0.000
#> GSM39858 1 0.4443 0.2426 0.524 0.000 0.472 0.004 0.000
#> GSM39859 1 0.4440 0.2533 0.528 0.000 0.468 0.004 0.000
#> GSM39862 3 0.6503 0.0146 0.000 0.000 0.436 0.372 0.192
#> GSM39863 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39865 5 0.6605 0.1639 0.000 0.348 0.000 0.220 0.432
#> GSM39866 1 0.2389 0.6743 0.880 0.000 0.000 0.116 0.004
#> GSM39867 4 0.5750 0.6045 0.388 0.000 0.024 0.544 0.044
#> GSM39869 2 0.4135 0.6040 0.000 0.656 0.000 0.004 0.340
#> GSM39870 1 0.2392 0.6867 0.888 0.000 0.004 0.104 0.004
#> GSM39871 3 0.4276 0.1477 0.380 0.000 0.616 0.004 0.000
#> GSM39872 3 0.2017 0.7309 0.080 0.000 0.912 0.008 0.000
#> GSM39828 1 0.5508 0.5409 0.636 0.000 0.244 0.120 0.000
#> GSM39829 1 0.0609 0.7641 0.980 0.000 0.020 0.000 0.000
#> GSM39830 1 0.1493 0.7618 0.948 0.000 0.028 0.024 0.000
#> GSM39832 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39833 3 0.5396 -0.1085 0.012 0.000 0.492 0.464 0.032
#> GSM39834 4 0.6358 0.6938 0.300 0.000 0.088 0.572 0.040
#> GSM39835 5 0.5941 0.1939 0.000 0.000 0.160 0.256 0.584
#> GSM39836 4 0.5209 0.6957 0.136 0.000 0.056 0.740 0.068
#> GSM39837 4 0.5160 0.1413 0.000 0.004 0.060 0.648 0.288
#> GSM39838 4 0.5209 0.6957 0.136 0.000 0.056 0.740 0.068
#> GSM39839 1 0.2763 0.7215 0.848 0.000 0.148 0.004 0.000
#> GSM39840 1 0.0451 0.7636 0.988 0.000 0.000 0.008 0.004
#> GSM39841 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39842 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39843 1 0.4211 0.4928 0.636 0.000 0.360 0.004 0.000
#> GSM39844 1 0.0162 0.7649 0.996 0.000 0.000 0.000 0.004
#> GSM39845 1 0.2921 0.7343 0.856 0.000 0.124 0.020 0.000
#> GSM39852 1 0.4179 0.6331 0.776 0.000 0.072 0.152 0.000
#> GSM39853 4 0.5772 0.7281 0.160 0.000 0.092 0.692 0.056
#> GSM39854 4 0.5744 0.7324 0.164 0.000 0.092 0.692 0.052
#> GSM39857 3 0.2540 0.7290 0.088 0.000 0.888 0.024 0.000
#> GSM39860 2 0.0162 0.7149 0.000 0.996 0.000 0.004 0.000
#> GSM39861 1 0.4510 0.3199 0.560 0.000 0.432 0.008 0.000
#> GSM39864 1 0.2632 0.7327 0.888 0.000 0.040 0.072 0.000
#> GSM39868 1 0.6148 -0.4253 0.460 0.000 0.052 0.452 0.036
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.3868 0.3657 0.000 0.504 0.000 0.000 0.496 0.000
#> GSM39874 2 0.3868 0.3657 0.000 0.504 0.000 0.000 0.496 0.000
#> GSM39875 2 0.3868 0.3657 0.000 0.504 0.000 0.000 0.496 0.000
#> GSM39876 2 0.3868 0.3657 0.000 0.504 0.000 0.000 0.496 0.000
#> GSM39831 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39819 3 0.3668 -0.2590 0.328 0.000 0.668 0.004 0.000 0.000
#> GSM39820 1 0.4338 0.6190 0.496 0.000 0.484 0.020 0.000 0.000
#> GSM39821 3 0.6082 -0.2508 0.356 0.000 0.416 0.224 0.004 0.000
#> GSM39822 5 0.5572 0.6219 0.004 0.052 0.000 0.216 0.644 0.084
#> GSM39823 3 0.4408 0.0757 0.416 0.000 0.560 0.020 0.004 0.000
#> GSM39824 2 0.4689 0.1192 0.012 0.644 0.004 0.000 0.304 0.036
#> GSM39825 3 0.1895 0.2846 0.072 0.000 0.912 0.016 0.000 0.000
#> GSM39826 4 0.2217 0.6523 0.048 0.000 0.036 0.908 0.004 0.004
#> GSM39827 4 0.5492 0.5486 0.132 0.000 0.136 0.668 0.000 0.064
#> GSM39846 3 0.4629 0.0545 0.436 0.000 0.524 0.000 0.040 0.000
#> GSM39847 3 0.6068 -0.2558 0.356 0.000 0.420 0.220 0.004 0.000
#> GSM39848 2 0.0000 0.3927 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39849 1 0.6445 -0.4410 0.436 0.000 0.376 0.000 0.052 0.136
#> GSM39850 4 0.2483 0.6530 0.056 0.000 0.044 0.892 0.004 0.004
#> GSM39851 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39855 2 0.4689 0.1192 0.012 0.644 0.004 0.000 0.304 0.036
#> GSM39856 3 0.4629 0.0545 0.436 0.000 0.524 0.000 0.040 0.000
#> GSM39858 3 0.0146 0.3312 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM39859 3 0.0291 0.3299 0.004 0.000 0.992 0.004 0.000 0.000
#> GSM39862 4 0.8389 -0.0940 0.244 0.000 0.068 0.316 0.236 0.136
#> GSM39863 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39865 5 0.4796 0.6569 0.004 0.052 0.000 0.152 0.732 0.060
#> GSM39866 1 0.6004 0.4298 0.488 0.000 0.296 0.208 0.000 0.008
#> GSM39867 4 0.5492 0.5486 0.132 0.000 0.136 0.668 0.000 0.064
#> GSM39869 5 0.3934 0.1488 0.000 0.376 0.000 0.000 0.616 0.008
#> GSM39870 1 0.5945 0.4501 0.496 0.000 0.304 0.192 0.000 0.008
#> GSM39871 3 0.2544 0.3502 0.140 0.000 0.852 0.004 0.004 0.000
#> GSM39872 3 0.4629 0.0545 0.436 0.000 0.524 0.000 0.040 0.000
#> GSM39828 3 0.5297 0.0420 0.212 0.000 0.616 0.168 0.004 0.000
#> GSM39829 3 0.3854 -0.5864 0.464 0.000 0.536 0.000 0.000 0.000
#> GSM39830 3 0.4584 -0.5595 0.452 0.000 0.512 0.036 0.000 0.000
#> GSM39832 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39833 4 0.6991 0.1983 0.268 0.000 0.076 0.516 0.044 0.096
#> GSM39834 4 0.4628 0.6195 0.108 0.000 0.064 0.768 0.032 0.028
#> GSM39835 6 0.2074 0.0000 0.004 0.000 0.000 0.048 0.036 0.912
#> GSM39836 4 0.3207 0.5855 0.004 0.000 0.004 0.840 0.100 0.052
#> GSM39837 4 0.5236 0.2162 0.004 0.000 0.008 0.612 0.284 0.092
#> GSM39838 4 0.3207 0.5855 0.004 0.000 0.004 0.840 0.100 0.052
#> GSM39839 3 0.3668 -0.2590 0.328 0.000 0.668 0.004 0.000 0.000
#> GSM39840 1 0.4067 0.7082 0.548 0.000 0.444 0.008 0.000 0.000
#> GSM39841 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39842 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39843 3 0.2442 0.2050 0.144 0.000 0.852 0.004 0.000 0.000
#> GSM39844 1 0.3838 0.7168 0.552 0.000 0.448 0.000 0.000 0.000
#> GSM39845 3 0.4332 -0.3335 0.352 0.000 0.616 0.032 0.000 0.000
#> GSM39852 3 0.5975 -0.2891 0.360 0.000 0.440 0.196 0.004 0.000
#> GSM39853 4 0.2901 0.6183 0.036 0.000 0.012 0.868 0.004 0.080
#> GSM39854 4 0.2758 0.6192 0.036 0.000 0.012 0.872 0.000 0.080
#> GSM39857 3 0.4408 0.0757 0.416 0.000 0.560 0.020 0.004 0.000
#> GSM39860 2 0.0000 0.3927 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39861 3 0.1367 0.3084 0.044 0.000 0.944 0.012 0.000 0.000
#> GSM39864 3 0.5209 -0.4779 0.416 0.000 0.492 0.092 0.000 0.000
#> GSM39868 4 0.6020 0.4868 0.196 0.000 0.128 0.620 0.032 0.024
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> ATC:hclust 57 0.000136 5.93e-05 2
#> ATC:hclust 44 0.000192 2.11e-03 3
#> ATC:hclust 36 0.001171 3.99e-03 4
#> ATC:hclust 45 0.000542 4.80e-03 5
#> ATC:hclust 20 NA 4.13e-01 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.963 0.987 0.3372 0.666 0.666
#> 3 3 0.595 0.761 0.880 0.7662 0.687 0.548
#> 4 4 0.603 0.733 0.834 0.2063 0.752 0.460
#> 5 5 0.711 0.679 0.826 0.0873 0.889 0.624
#> 6 6 0.745 0.595 0.776 0.0443 0.929 0.702
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.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.000 0.971 0.000 1.000
#> GSM39874 2 0.000 0.971 0.000 1.000
#> GSM39875 2 0.000 0.971 0.000 1.000
#> GSM39876 2 0.000 0.971 0.000 1.000
#> GSM39831 1 0.000 0.989 1.000 0.000
#> GSM39819 1 0.000 0.989 1.000 0.000
#> GSM39820 1 0.000 0.989 1.000 0.000
#> GSM39821 1 0.000 0.989 1.000 0.000
#> GSM39822 2 0.000 0.971 0.000 1.000
#> GSM39823 1 0.000 0.989 1.000 0.000
#> GSM39824 2 0.000 0.971 0.000 1.000
#> GSM39825 1 0.000 0.989 1.000 0.000
#> GSM39826 1 0.000 0.989 1.000 0.000
#> GSM39827 1 0.000 0.989 1.000 0.000
#> GSM39846 1 0.000 0.989 1.000 0.000
#> GSM39847 1 0.000 0.989 1.000 0.000
#> GSM39848 2 0.000 0.971 0.000 1.000
#> GSM39849 1 0.000 0.989 1.000 0.000
#> GSM39850 1 0.000 0.989 1.000 0.000
#> GSM39851 1 0.000 0.989 1.000 0.000
#> GSM39855 2 0.000 0.971 0.000 1.000
#> GSM39856 1 0.000 0.989 1.000 0.000
#> GSM39858 1 0.000 0.989 1.000 0.000
#> GSM39859 1 0.000 0.989 1.000 0.000
#> GSM39862 2 0.891 0.545 0.308 0.692
#> GSM39863 1 0.000 0.989 1.000 0.000
#> GSM39865 2 0.000 0.971 0.000 1.000
#> GSM39866 1 0.000 0.989 1.000 0.000
#> GSM39867 1 0.000 0.989 1.000 0.000
#> GSM39869 2 0.000 0.971 0.000 1.000
#> GSM39870 1 0.000 0.989 1.000 0.000
#> GSM39871 1 0.000 0.989 1.000 0.000
#> GSM39872 1 0.000 0.989 1.000 0.000
#> GSM39828 1 0.000 0.989 1.000 0.000
#> GSM39829 1 0.000 0.989 1.000 0.000
#> GSM39830 1 0.000 0.989 1.000 0.000
#> GSM39832 1 0.000 0.989 1.000 0.000
#> GSM39833 1 0.000 0.989 1.000 0.000
#> GSM39834 1 0.000 0.989 1.000 0.000
#> GSM39835 1 0.994 0.113 0.544 0.456
#> GSM39836 1 0.000 0.989 1.000 0.000
#> GSM39837 1 0.000 0.989 1.000 0.000
#> GSM39838 1 0.000 0.989 1.000 0.000
#> GSM39839 1 0.000 0.989 1.000 0.000
#> GSM39840 1 0.000 0.989 1.000 0.000
#> GSM39841 1 0.000 0.989 1.000 0.000
#> GSM39842 1 0.000 0.989 1.000 0.000
#> GSM39843 1 0.000 0.989 1.000 0.000
#> GSM39844 1 0.000 0.989 1.000 0.000
#> GSM39845 1 0.000 0.989 1.000 0.000
#> GSM39852 1 0.000 0.989 1.000 0.000
#> GSM39853 1 0.000 0.989 1.000 0.000
#> GSM39854 1 0.000 0.989 1.000 0.000
#> GSM39857 1 0.000 0.989 1.000 0.000
#> GSM39860 2 0.000 0.971 0.000 1.000
#> GSM39861 1 0.000 0.989 1.000 0.000
#> GSM39864 1 0.000 0.989 1.000 0.000
#> GSM39868 1 0.000 0.989 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.000 0.951 0.000 1.000 0.000
#> GSM39874 2 0.000 0.951 0.000 1.000 0.000
#> GSM39875 2 0.000 0.951 0.000 1.000 0.000
#> GSM39876 2 0.000 0.951 0.000 1.000 0.000
#> GSM39831 1 0.000 0.869 1.000 0.000 0.000
#> GSM39819 1 0.141 0.859 0.964 0.000 0.036
#> GSM39820 1 0.116 0.862 0.972 0.000 0.028
#> GSM39821 1 0.129 0.855 0.968 0.000 0.032
#> GSM39822 2 0.400 0.838 0.000 0.840 0.160
#> GSM39823 3 0.216 0.781 0.064 0.000 0.936
#> GSM39824 3 0.263 0.685 0.000 0.084 0.916
#> GSM39825 1 0.588 0.508 0.652 0.000 0.348
#> GSM39826 1 0.614 0.130 0.596 0.000 0.404
#> GSM39827 1 0.164 0.853 0.956 0.000 0.044
#> GSM39846 3 0.216 0.781 0.064 0.000 0.936
#> GSM39847 1 0.196 0.848 0.944 0.000 0.056
#> GSM39848 2 0.141 0.950 0.000 0.964 0.036
#> GSM39849 3 0.216 0.781 0.064 0.000 0.936
#> GSM39850 1 0.312 0.807 0.892 0.000 0.108
#> GSM39851 1 0.000 0.869 1.000 0.000 0.000
#> GSM39855 2 0.406 0.846 0.000 0.836 0.164
#> GSM39856 3 0.216 0.781 0.064 0.000 0.936
#> GSM39858 1 0.576 0.526 0.672 0.000 0.328
#> GSM39859 1 0.588 0.508 0.652 0.000 0.348
#> GSM39862 3 0.116 0.730 0.000 0.028 0.972
#> GSM39863 1 0.000 0.869 1.000 0.000 0.000
#> GSM39865 3 0.559 0.409 0.000 0.304 0.696
#> GSM39866 1 0.000 0.869 1.000 0.000 0.000
#> GSM39867 1 0.153 0.854 0.960 0.000 0.040
#> GSM39869 2 0.141 0.950 0.000 0.964 0.036
#> GSM39870 1 0.116 0.862 0.972 0.000 0.028
#> GSM39871 3 0.216 0.781 0.064 0.000 0.936
#> GSM39872 3 0.216 0.781 0.064 0.000 0.936
#> GSM39828 1 0.226 0.841 0.932 0.000 0.068
#> GSM39829 1 0.116 0.862 0.972 0.000 0.028
#> GSM39830 1 0.116 0.862 0.972 0.000 0.028
#> GSM39832 1 0.000 0.869 1.000 0.000 0.000
#> GSM39833 3 0.216 0.769 0.064 0.000 0.936
#> GSM39834 1 0.614 0.130 0.596 0.000 0.404
#> GSM39835 3 0.382 0.720 0.148 0.000 0.852
#> GSM39836 3 0.617 0.477 0.412 0.000 0.588
#> GSM39837 3 0.597 0.558 0.364 0.000 0.636
#> GSM39838 3 0.576 0.582 0.328 0.000 0.672
#> GSM39839 1 0.418 0.750 0.828 0.000 0.172
#> GSM39840 1 0.000 0.869 1.000 0.000 0.000
#> GSM39841 1 0.000 0.869 1.000 0.000 0.000
#> GSM39842 1 0.000 0.869 1.000 0.000 0.000
#> GSM39843 1 0.388 0.781 0.848 0.000 0.152
#> GSM39844 1 0.000 0.869 1.000 0.000 0.000
#> GSM39845 1 0.450 0.728 0.804 0.000 0.196
#> GSM39852 1 0.312 0.807 0.892 0.000 0.108
#> GSM39853 3 0.617 0.477 0.412 0.000 0.588
#> GSM39854 3 0.617 0.477 0.412 0.000 0.588
#> GSM39857 3 0.216 0.781 0.064 0.000 0.936
#> GSM39860 2 0.141 0.950 0.000 0.964 0.036
#> GSM39861 1 0.450 0.728 0.804 0.000 0.196
#> GSM39864 1 0.000 0.869 1.000 0.000 0.000
#> GSM39868 1 0.288 0.816 0.904 0.000 0.096
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0188 0.8975 0.000 0.996 0.000 0.004
#> GSM39874 2 0.0188 0.8975 0.000 0.996 0.000 0.004
#> GSM39875 2 0.0188 0.8975 0.000 0.996 0.000 0.004
#> GSM39876 2 0.0188 0.8975 0.000 0.996 0.000 0.004
#> GSM39831 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39819 1 0.1637 0.8205 0.940 0.000 0.060 0.000
#> GSM39820 1 0.0188 0.8500 0.996 0.000 0.004 0.000
#> GSM39821 4 0.4761 0.6273 0.372 0.000 0.000 0.628
#> GSM39822 2 0.6027 0.7465 0.000 0.684 0.124 0.192
#> GSM39823 3 0.3617 0.7779 0.064 0.000 0.860 0.076
#> GSM39824 3 0.3443 0.6375 0.000 0.016 0.848 0.136
#> GSM39825 1 0.6396 0.3070 0.548 0.000 0.380 0.072
#> GSM39826 4 0.3142 0.8140 0.132 0.000 0.008 0.860
#> GSM39827 4 0.4072 0.7857 0.252 0.000 0.000 0.748
#> GSM39846 3 0.2926 0.7919 0.048 0.000 0.896 0.056
#> GSM39847 4 0.4978 0.7058 0.324 0.000 0.012 0.664
#> GSM39848 2 0.3885 0.8810 0.000 0.844 0.092 0.064
#> GSM39849 3 0.2926 0.7919 0.048 0.000 0.896 0.056
#> GSM39850 4 0.3933 0.8173 0.200 0.000 0.008 0.792
#> GSM39851 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39855 3 0.6290 0.0577 0.000 0.364 0.568 0.068
#> GSM39856 3 0.2926 0.7919 0.048 0.000 0.896 0.056
#> GSM39858 1 0.5203 0.3072 0.576 0.000 0.416 0.008
#> GSM39859 3 0.6310 0.2617 0.352 0.000 0.576 0.072
#> GSM39862 3 0.3975 0.6136 0.000 0.000 0.760 0.240
#> GSM39863 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39865 3 0.7442 0.1520 0.000 0.200 0.496 0.304
#> GSM39866 1 0.1389 0.8490 0.952 0.000 0.000 0.048
#> GSM39867 4 0.4072 0.7856 0.252 0.000 0.000 0.748
#> GSM39869 2 0.4292 0.8719 0.000 0.820 0.100 0.080
#> GSM39870 1 0.0188 0.8500 0.996 0.000 0.004 0.000
#> GSM39871 3 0.3834 0.7713 0.076 0.000 0.848 0.076
#> GSM39872 3 0.2926 0.7919 0.048 0.000 0.896 0.056
#> GSM39828 4 0.4936 0.7171 0.316 0.000 0.012 0.672
#> GSM39829 1 0.0188 0.8500 0.996 0.000 0.004 0.000
#> GSM39830 1 0.0188 0.8500 0.996 0.000 0.004 0.000
#> GSM39832 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39833 4 0.4182 0.5836 0.024 0.000 0.180 0.796
#> GSM39834 4 0.3852 0.8198 0.180 0.000 0.012 0.808
#> GSM39835 4 0.4584 0.2954 0.000 0.004 0.300 0.696
#> GSM39836 4 0.2542 0.7915 0.084 0.000 0.012 0.904
#> GSM39837 4 0.2944 0.7400 0.044 0.004 0.052 0.900
#> GSM39838 4 0.2021 0.6905 0.012 0.000 0.056 0.932
#> GSM39839 1 0.2281 0.7917 0.904 0.000 0.096 0.000
#> GSM39840 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39841 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39842 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39843 1 0.4829 0.7040 0.776 0.000 0.156 0.068
#> GSM39844 1 0.1637 0.8505 0.940 0.000 0.000 0.060
#> GSM39845 1 0.5627 0.5936 0.692 0.000 0.240 0.068
#> GSM39852 4 0.4212 0.8131 0.216 0.000 0.012 0.772
#> GSM39853 4 0.2053 0.7895 0.072 0.004 0.000 0.924
#> GSM39854 4 0.2053 0.7895 0.072 0.004 0.000 0.924
#> GSM39857 3 0.2926 0.7919 0.048 0.000 0.896 0.056
#> GSM39860 2 0.3687 0.8846 0.000 0.856 0.080 0.064
#> GSM39861 1 0.5791 0.5365 0.656 0.000 0.284 0.060
#> GSM39864 1 0.1302 0.8488 0.956 0.000 0.000 0.044
#> GSM39868 4 0.4319 0.8069 0.228 0.000 0.012 0.760
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.7890 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.7890 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.7890 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.7890 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.0510 0.8828 0.984 0.000 0.000 0.016 0.000
#> GSM39819 1 0.3752 0.6738 0.708 0.000 0.292 0.000 0.000
#> GSM39820 1 0.2891 0.8092 0.824 0.000 0.176 0.000 0.000
#> GSM39821 4 0.2964 0.8600 0.120 0.000 0.024 0.856 0.000
#> GSM39822 5 0.5635 -0.3466 0.000 0.428 0.000 0.076 0.496
#> GSM39823 3 0.3250 0.5554 0.008 0.000 0.820 0.004 0.168
#> GSM39824 5 0.3461 0.4343 0.000 0.000 0.224 0.004 0.772
#> GSM39825 3 0.3192 0.5896 0.112 0.000 0.848 0.040 0.000
#> GSM39826 4 0.0955 0.8750 0.028 0.000 0.000 0.968 0.004
#> GSM39827 4 0.2463 0.8811 0.100 0.000 0.008 0.888 0.004
#> GSM39846 3 0.4192 0.3777 0.000 0.000 0.596 0.000 0.404
#> GSM39847 4 0.3390 0.8520 0.100 0.000 0.060 0.840 0.000
#> GSM39848 2 0.4066 0.6367 0.000 0.672 0.000 0.004 0.324
#> GSM39849 3 0.4403 0.3381 0.000 0.000 0.560 0.004 0.436
#> GSM39850 4 0.1991 0.8874 0.076 0.000 0.004 0.916 0.004
#> GSM39851 1 0.0510 0.8828 0.984 0.000 0.000 0.016 0.000
#> GSM39855 5 0.4171 0.4996 0.000 0.112 0.104 0.000 0.784
#> GSM39856 3 0.4192 0.3777 0.000 0.000 0.596 0.000 0.404
#> GSM39858 3 0.3391 0.5753 0.188 0.000 0.800 0.000 0.012
#> GSM39859 3 0.2546 0.5979 0.048 0.000 0.904 0.036 0.012
#> GSM39862 5 0.3321 0.5340 0.000 0.000 0.136 0.032 0.832
#> GSM39863 1 0.0510 0.8828 0.984 0.000 0.000 0.016 0.000
#> GSM39865 5 0.3107 0.5285 0.000 0.032 0.012 0.088 0.868
#> GSM39866 1 0.1211 0.8794 0.960 0.000 0.024 0.016 0.000
#> GSM39867 4 0.2477 0.8846 0.092 0.000 0.008 0.892 0.008
#> GSM39869 2 0.4542 0.4183 0.000 0.536 0.000 0.008 0.456
#> GSM39870 1 0.2891 0.8092 0.824 0.000 0.176 0.000 0.000
#> GSM39871 3 0.1764 0.5885 0.008 0.000 0.928 0.000 0.064
#> GSM39872 3 0.4367 0.3687 0.000 0.000 0.580 0.004 0.416
#> GSM39828 4 0.3401 0.8532 0.096 0.000 0.064 0.840 0.000
#> GSM39829 1 0.2891 0.8092 0.824 0.000 0.176 0.000 0.000
#> GSM39830 1 0.2966 0.8036 0.816 0.000 0.184 0.000 0.000
#> GSM39832 1 0.0671 0.8811 0.980 0.000 0.000 0.016 0.004
#> GSM39833 4 0.3779 0.7375 0.000 0.000 0.052 0.804 0.144
#> GSM39834 4 0.2046 0.8877 0.068 0.000 0.016 0.916 0.000
#> GSM39835 5 0.4907 -0.0915 0.000 0.000 0.024 0.484 0.492
#> GSM39836 4 0.0671 0.8685 0.016 0.000 0.000 0.980 0.004
#> GSM39837 4 0.3320 0.7633 0.012 0.000 0.004 0.820 0.164
#> GSM39838 4 0.2964 0.7660 0.004 0.000 0.004 0.840 0.152
#> GSM39839 1 0.4150 0.5008 0.612 0.000 0.388 0.000 0.000
#> GSM39840 1 0.0510 0.8828 0.984 0.000 0.000 0.016 0.000
#> GSM39841 1 0.0510 0.8828 0.984 0.000 0.000 0.016 0.000
#> GSM39842 1 0.0671 0.8811 0.980 0.000 0.000 0.016 0.004
#> GSM39843 3 0.4666 0.3734 0.284 0.000 0.676 0.040 0.000
#> GSM39844 1 0.0671 0.8811 0.980 0.000 0.000 0.016 0.004
#> GSM39845 3 0.5105 0.4014 0.264 0.000 0.660 0.076 0.000
#> GSM39852 4 0.2331 0.8856 0.080 0.000 0.020 0.900 0.000
#> GSM39853 4 0.2520 0.8262 0.012 0.000 0.004 0.888 0.096
#> GSM39854 4 0.2520 0.8262 0.012 0.000 0.004 0.888 0.096
#> GSM39857 3 0.3612 0.4930 0.000 0.000 0.732 0.000 0.268
#> GSM39860 2 0.3928 0.6619 0.000 0.700 0.000 0.004 0.296
#> GSM39861 3 0.4429 0.5372 0.192 0.000 0.744 0.064 0.000
#> GSM39864 1 0.1800 0.8708 0.932 0.000 0.048 0.020 0.000
#> GSM39868 4 0.2423 0.8849 0.080 0.000 0.024 0.896 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.3608 0.667 0.000 0.716 0.012 0.000 0.272 0.000
#> GSM39874 2 0.3608 0.667 0.000 0.716 0.012 0.000 0.272 0.000
#> GSM39875 2 0.3608 0.667 0.000 0.716 0.012 0.000 0.272 0.000
#> GSM39876 2 0.3608 0.667 0.000 0.716 0.012 0.000 0.272 0.000
#> GSM39831 1 0.0146 0.841 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM39819 3 0.4739 0.014 0.436 0.000 0.516 0.000 0.048 0.000
#> GSM39820 1 0.4788 0.583 0.648 0.000 0.276 0.008 0.068 0.000
#> GSM39821 4 0.2475 0.770 0.060 0.000 0.036 0.892 0.012 0.000
#> GSM39822 2 0.6119 -0.276 0.000 0.444 0.000 0.024 0.388 0.144
#> GSM39823 3 0.3937 -0.210 0.000 0.000 0.572 0.004 0.000 0.424
#> GSM39824 6 0.3008 0.532 0.000 0.032 0.036 0.000 0.068 0.864
#> GSM39825 3 0.2450 0.690 0.064 0.000 0.896 0.024 0.004 0.012
#> GSM39826 4 0.0508 0.786 0.004 0.000 0.000 0.984 0.012 0.000
#> GSM39827 4 0.1461 0.787 0.044 0.000 0.000 0.940 0.016 0.000
#> GSM39846 6 0.2941 0.722 0.000 0.000 0.220 0.000 0.000 0.780
#> GSM39847 4 0.2764 0.747 0.028 0.000 0.100 0.864 0.008 0.000
#> GSM39848 2 0.2979 0.536 0.000 0.848 0.032 0.000 0.008 0.112
#> GSM39849 6 0.3136 0.713 0.000 0.000 0.188 0.000 0.016 0.796
#> GSM39850 4 0.0717 0.788 0.016 0.000 0.000 0.976 0.008 0.000
#> GSM39851 1 0.0000 0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39855 6 0.5324 0.112 0.000 0.248 0.052 0.000 0.060 0.640
#> GSM39856 6 0.2941 0.722 0.000 0.000 0.220 0.000 0.000 0.780
#> GSM39858 3 0.2555 0.694 0.096 0.000 0.876 0.000 0.008 0.020
#> GSM39859 3 0.2570 0.647 0.024 0.000 0.888 0.024 0.000 0.064
#> GSM39862 6 0.3454 0.360 0.000 0.024 0.008 0.004 0.160 0.804
#> GSM39863 1 0.0000 0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39865 5 0.6511 0.334 0.000 0.216 0.000 0.028 0.380 0.376
#> GSM39866 1 0.3067 0.796 0.864 0.000 0.040 0.024 0.068 0.004
#> GSM39867 4 0.2265 0.772 0.076 0.000 0.000 0.896 0.024 0.004
#> GSM39869 2 0.5300 0.217 0.000 0.632 0.016 0.000 0.232 0.120
#> GSM39870 1 0.4825 0.570 0.640 0.000 0.284 0.008 0.068 0.000
#> GSM39871 3 0.3499 0.170 0.000 0.000 0.680 0.000 0.000 0.320
#> GSM39872 6 0.3133 0.719 0.000 0.000 0.212 0.000 0.008 0.780
#> GSM39828 4 0.2815 0.747 0.028 0.000 0.096 0.864 0.012 0.000
#> GSM39829 1 0.4632 0.587 0.656 0.000 0.276 0.004 0.064 0.000
#> GSM39830 1 0.4756 0.558 0.636 0.000 0.292 0.004 0.068 0.000
#> GSM39832 1 0.0146 0.841 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM39833 4 0.4892 0.418 0.000 0.000 0.012 0.592 0.348 0.048
#> GSM39834 4 0.2389 0.778 0.016 0.000 0.020 0.904 0.052 0.008
#> GSM39835 5 0.5935 0.422 0.000 0.000 0.028 0.204 0.572 0.196
#> GSM39836 4 0.1196 0.781 0.000 0.000 0.008 0.952 0.040 0.000
#> GSM39837 4 0.3838 0.288 0.000 0.000 0.000 0.552 0.448 0.000
#> GSM39838 4 0.4124 0.502 0.000 0.000 0.008 0.648 0.332 0.012
#> GSM39839 3 0.4511 0.362 0.332 0.000 0.620 0.000 0.048 0.000
#> GSM39840 1 0.0146 0.841 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM39841 1 0.0000 0.841 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39842 1 0.0291 0.840 0.992 0.000 0.000 0.004 0.004 0.000
#> GSM39843 3 0.3349 0.683 0.164 0.000 0.804 0.024 0.008 0.000
#> GSM39844 1 0.0146 0.841 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM39845 3 0.4180 0.674 0.096 0.000 0.784 0.076 0.044 0.000
#> GSM39852 4 0.2186 0.783 0.024 0.000 0.024 0.916 0.032 0.004
#> GSM39853 4 0.3563 0.525 0.000 0.000 0.000 0.664 0.336 0.000
#> GSM39854 4 0.3547 0.530 0.000 0.000 0.000 0.668 0.332 0.000
#> GSM39857 6 0.3838 0.399 0.000 0.000 0.448 0.000 0.000 0.552
#> GSM39860 2 0.2487 0.554 0.000 0.876 0.032 0.000 0.000 0.092
#> GSM39861 3 0.2404 0.699 0.080 0.000 0.884 0.036 0.000 0.000
#> GSM39864 1 0.3505 0.773 0.824 0.000 0.092 0.016 0.068 0.000
#> GSM39868 4 0.2869 0.771 0.024 0.000 0.036 0.880 0.052 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> ATC:kmeans 57 7.23e-04 2.01e-04 2
#> ATC:kmeans 52 3.19e-05 8.23e-04 3
#> ATC:kmeans 52 2.71e-05 5.49e-05 4
#> ATC:kmeans 46 7.10e-06 1.55e-04 5
#> ATC:kmeans 45 9.71e-06 1.97e-04 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.999 0.949 0.980 0.4967 0.506 0.506
#> 3 3 0.935 0.918 0.965 0.3109 0.792 0.609
#> 4 4 0.768 0.770 0.901 0.1183 0.833 0.577
#> 5 5 0.639 0.580 0.736 0.0685 0.855 0.548
#> 6 6 0.684 0.608 0.788 0.0381 0.955 0.806
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.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.000 0.984 0.000 1.000
#> GSM39874 2 0.000 0.984 0.000 1.000
#> GSM39875 2 0.000 0.984 0.000 1.000
#> GSM39876 2 0.000 0.984 0.000 1.000
#> GSM39831 1 0.000 0.974 1.000 0.000
#> GSM39819 1 0.000 0.974 1.000 0.000
#> GSM39820 1 0.000 0.974 1.000 0.000
#> GSM39821 1 0.000 0.974 1.000 0.000
#> GSM39822 2 0.000 0.984 0.000 1.000
#> GSM39823 1 0.985 0.268 0.572 0.428
#> GSM39824 2 0.000 0.984 0.000 1.000
#> GSM39825 1 0.000 0.974 1.000 0.000
#> GSM39826 1 0.163 0.952 0.976 0.024
#> GSM39827 1 0.000 0.974 1.000 0.000
#> GSM39846 2 0.000 0.984 0.000 1.000
#> GSM39847 1 0.000 0.974 1.000 0.000
#> GSM39848 2 0.000 0.984 0.000 1.000
#> GSM39849 2 0.000 0.984 0.000 1.000
#> GSM39850 1 0.000 0.974 1.000 0.000
#> GSM39851 1 0.000 0.974 1.000 0.000
#> GSM39855 2 0.000 0.984 0.000 1.000
#> GSM39856 2 0.000 0.984 0.000 1.000
#> GSM39858 1 0.000 0.974 1.000 0.000
#> GSM39859 1 0.000 0.974 1.000 0.000
#> GSM39862 2 0.000 0.984 0.000 1.000
#> GSM39863 1 0.000 0.974 1.000 0.000
#> GSM39865 2 0.000 0.984 0.000 1.000
#> GSM39866 1 0.000 0.974 1.000 0.000
#> GSM39867 1 0.000 0.974 1.000 0.000
#> GSM39869 2 0.000 0.984 0.000 1.000
#> GSM39870 1 0.000 0.974 1.000 0.000
#> GSM39871 1 0.952 0.418 0.628 0.372
#> GSM39872 2 0.000 0.984 0.000 1.000
#> GSM39828 1 0.000 0.974 1.000 0.000
#> GSM39829 1 0.000 0.974 1.000 0.000
#> GSM39830 1 0.000 0.974 1.000 0.000
#> GSM39832 1 0.000 0.974 1.000 0.000
#> GSM39833 2 0.000 0.984 0.000 1.000
#> GSM39834 1 0.000 0.974 1.000 0.000
#> GSM39835 2 0.000 0.984 0.000 1.000
#> GSM39836 2 0.814 0.653 0.252 0.748
#> GSM39837 2 0.000 0.984 0.000 1.000
#> GSM39838 2 0.000 0.984 0.000 1.000
#> GSM39839 1 0.000 0.974 1.000 0.000
#> GSM39840 1 0.000 0.974 1.000 0.000
#> GSM39841 1 0.000 0.974 1.000 0.000
#> GSM39842 1 0.000 0.974 1.000 0.000
#> GSM39843 1 0.000 0.974 1.000 0.000
#> GSM39844 1 0.000 0.974 1.000 0.000
#> GSM39845 1 0.000 0.974 1.000 0.000
#> GSM39852 1 0.000 0.974 1.000 0.000
#> GSM39853 2 0.456 0.885 0.096 0.904
#> GSM39854 2 0.000 0.984 0.000 1.000
#> GSM39857 2 0.000 0.984 0.000 1.000
#> GSM39860 2 0.000 0.984 0.000 1.000
#> GSM39861 1 0.000 0.974 1.000 0.000
#> GSM39864 1 0.000 0.974 1.000 0.000
#> GSM39868 1 0.000 0.974 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39831 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39819 1 0.5882 0.4054 0.652 0.000 0.348
#> GSM39820 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39821 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39822 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39823 3 0.0424 0.9384 0.008 0.000 0.992
#> GSM39824 2 0.1411 0.9445 0.000 0.964 0.036
#> GSM39825 3 0.2165 0.9318 0.064 0.000 0.936
#> GSM39826 1 0.0848 0.9494 0.984 0.008 0.008
#> GSM39827 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39846 3 0.0424 0.9372 0.000 0.008 0.992
#> GSM39847 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39848 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39849 3 0.0424 0.9372 0.000 0.008 0.992
#> GSM39850 1 0.0424 0.9561 0.992 0.000 0.008
#> GSM39851 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39855 2 0.0747 0.9628 0.000 0.984 0.016
#> GSM39856 3 0.0424 0.9372 0.000 0.008 0.992
#> GSM39858 3 0.2165 0.9318 0.064 0.000 0.936
#> GSM39859 3 0.2165 0.9318 0.064 0.000 0.936
#> GSM39862 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39863 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39865 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39866 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39867 1 0.0237 0.9587 0.996 0.000 0.004
#> GSM39869 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39870 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39871 3 0.0424 0.9384 0.008 0.000 0.992
#> GSM39872 3 0.0424 0.9372 0.000 0.008 0.992
#> GSM39828 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39829 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39830 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39832 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39833 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39834 1 0.0424 0.9561 0.992 0.000 0.008
#> GSM39835 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39836 2 0.6047 0.5433 0.312 0.680 0.008
#> GSM39837 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39838 2 0.0424 0.9700 0.000 0.992 0.008
#> GSM39839 3 0.3267 0.8932 0.116 0.000 0.884
#> GSM39840 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39841 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39842 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39843 3 0.3116 0.9018 0.108 0.000 0.892
#> GSM39844 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39845 1 0.6308 -0.0697 0.508 0.000 0.492
#> GSM39852 1 0.0424 0.9561 0.992 0.000 0.008
#> GSM39853 2 0.0848 0.9643 0.008 0.984 0.008
#> GSM39854 2 0.0424 0.9700 0.000 0.992 0.008
#> GSM39857 3 0.0424 0.9372 0.000 0.008 0.992
#> GSM39860 2 0.0000 0.9744 0.000 1.000 0.000
#> GSM39861 3 0.5216 0.6865 0.260 0.000 0.740
#> GSM39864 1 0.0000 0.9609 1.000 0.000 0.000
#> GSM39868 1 0.0237 0.9587 0.996 0.000 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39819 1 0.1004 0.8486 0.972 0.000 0.004 0.024
#> GSM39820 1 0.0000 0.8622 1.000 0.000 0.000 0.000
#> GSM39821 1 0.4981 0.1851 0.536 0.000 0.000 0.464
#> GSM39822 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39823 3 0.0000 0.8819 0.000 0.000 1.000 0.000
#> GSM39824 2 0.4222 0.6392 0.000 0.728 0.272 0.000
#> GSM39825 3 0.4955 0.6479 0.268 0.000 0.708 0.024
#> GSM39826 4 0.0921 0.8028 0.028 0.000 0.000 0.972
#> GSM39827 1 0.3873 0.6545 0.772 0.000 0.000 0.228
#> GSM39846 3 0.0000 0.8819 0.000 0.000 1.000 0.000
#> GSM39847 1 0.4697 0.4701 0.644 0.000 0.000 0.356
#> GSM39848 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39849 3 0.0188 0.8789 0.000 0.004 0.996 0.000
#> GSM39850 4 0.0921 0.8028 0.028 0.000 0.000 0.972
#> GSM39851 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39855 2 0.2469 0.8578 0.000 0.892 0.108 0.000
#> GSM39856 3 0.0000 0.8819 0.000 0.000 1.000 0.000
#> GSM39858 3 0.4927 0.6552 0.264 0.000 0.712 0.024
#> GSM39859 3 0.4387 0.7359 0.200 0.000 0.776 0.024
#> GSM39862 2 0.1792 0.8948 0.000 0.932 0.068 0.000
#> GSM39863 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39865 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39866 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39867 4 0.4977 0.1129 0.460 0.000 0.000 0.540
#> GSM39869 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39870 1 0.0188 0.8608 0.996 0.000 0.000 0.004
#> GSM39871 3 0.0188 0.8805 0.000 0.000 0.996 0.004
#> GSM39872 3 0.0000 0.8819 0.000 0.000 1.000 0.000
#> GSM39828 1 0.4776 0.4305 0.624 0.000 0.000 0.376
#> GSM39829 1 0.0000 0.8622 1.000 0.000 0.000 0.000
#> GSM39830 1 0.0188 0.8610 0.996 0.000 0.000 0.004
#> GSM39832 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39833 2 0.1724 0.9128 0.000 0.948 0.032 0.020
#> GSM39834 4 0.1389 0.8036 0.048 0.000 0.000 0.952
#> GSM39835 2 0.0188 0.9359 0.000 0.996 0.000 0.004
#> GSM39836 4 0.1302 0.7885 0.000 0.044 0.000 0.956
#> GSM39837 2 0.0469 0.9321 0.000 0.988 0.000 0.012
#> GSM39838 2 0.4522 0.4762 0.000 0.680 0.000 0.320
#> GSM39839 1 0.1733 0.8348 0.948 0.000 0.028 0.024
#> GSM39840 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39841 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39842 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39843 1 0.3080 0.7815 0.880 0.000 0.096 0.024
#> GSM39844 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39845 1 0.5159 0.3364 0.624 0.000 0.364 0.012
#> GSM39852 4 0.2345 0.7847 0.100 0.000 0.000 0.900
#> GSM39853 4 0.4991 0.3210 0.004 0.388 0.000 0.608
#> GSM39854 4 0.3569 0.6701 0.000 0.196 0.000 0.804
#> GSM39857 3 0.0000 0.8819 0.000 0.000 1.000 0.000
#> GSM39860 2 0.0000 0.9376 0.000 1.000 0.000 0.000
#> GSM39861 1 0.5696 -0.0988 0.492 0.000 0.484 0.024
#> GSM39864 1 0.0469 0.8650 0.988 0.000 0.000 0.012
#> GSM39868 4 0.2921 0.7545 0.140 0.000 0.000 0.860
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.8100 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.8100 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.8100 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.8100 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.0000 0.8604 1.000 0.000 0.000 0.000 0.000
#> GSM39819 1 0.4030 0.3974 0.648 0.000 0.352 0.000 0.000
#> GSM39820 1 0.2732 0.7585 0.840 0.000 0.160 0.000 0.000
#> GSM39821 4 0.4610 0.4934 0.388 0.000 0.000 0.596 0.016
#> GSM39822 2 0.0000 0.8100 0.000 1.000 0.000 0.000 0.000
#> GSM39823 3 0.4192 -0.7154 0.000 0.000 0.596 0.000 0.404
#> GSM39824 2 0.4752 0.4015 0.000 0.568 0.020 0.000 0.412
#> GSM39825 3 0.2843 0.4668 0.144 0.000 0.848 0.000 0.008
#> GSM39826 4 0.2293 0.6770 0.016 0.000 0.000 0.900 0.084
#> GSM39827 1 0.4849 0.5437 0.724 0.000 0.000 0.136 0.140
#> GSM39846 5 0.4242 0.9693 0.000 0.000 0.428 0.000 0.572
#> GSM39847 4 0.5933 0.4435 0.388 0.000 0.076 0.524 0.012
#> GSM39848 2 0.1121 0.8054 0.000 0.956 0.000 0.000 0.044
#> GSM39849 5 0.4331 0.9527 0.000 0.004 0.400 0.000 0.596
#> GSM39850 4 0.2278 0.6930 0.032 0.000 0.000 0.908 0.060
#> GSM39851 1 0.0162 0.8603 0.996 0.000 0.000 0.000 0.004
#> GSM39855 2 0.4268 0.5366 0.000 0.648 0.008 0.000 0.344
#> GSM39856 5 0.4256 0.9617 0.000 0.000 0.436 0.000 0.564
#> GSM39858 3 0.2583 0.4640 0.132 0.000 0.864 0.000 0.004
#> GSM39859 3 0.2653 0.4011 0.096 0.000 0.880 0.000 0.024
#> GSM39862 2 0.4333 0.5467 0.000 0.640 0.004 0.004 0.352
#> GSM39863 1 0.0000 0.8604 1.000 0.000 0.000 0.000 0.000
#> GSM39865 2 0.0963 0.8066 0.000 0.964 0.000 0.000 0.036
#> GSM39866 1 0.1074 0.8521 0.968 0.000 0.012 0.004 0.016
#> GSM39867 1 0.5733 0.3262 0.620 0.000 0.000 0.160 0.220
#> GSM39869 2 0.0404 0.8094 0.000 0.988 0.000 0.000 0.012
#> GSM39870 1 0.2970 0.7479 0.828 0.000 0.168 0.000 0.004
#> GSM39871 3 0.4015 -0.5779 0.000 0.000 0.652 0.000 0.348
#> GSM39872 5 0.4219 0.9691 0.000 0.000 0.416 0.000 0.584
#> GSM39828 4 0.6636 0.4657 0.356 0.000 0.104 0.504 0.036
#> GSM39829 1 0.2690 0.7629 0.844 0.000 0.156 0.000 0.000
#> GSM39830 1 0.2561 0.7700 0.856 0.000 0.144 0.000 0.000
#> GSM39832 1 0.0290 0.8597 0.992 0.000 0.000 0.000 0.008
#> GSM39833 2 0.5873 0.5842 0.000 0.556 0.024 0.056 0.364
#> GSM39834 4 0.4226 0.6997 0.140 0.000 0.000 0.776 0.084
#> GSM39835 2 0.3359 0.7453 0.000 0.816 0.000 0.020 0.164
#> GSM39836 4 0.0798 0.6751 0.000 0.016 0.000 0.976 0.008
#> GSM39837 2 0.4413 0.6540 0.000 0.724 0.000 0.044 0.232
#> GSM39838 2 0.5446 0.5313 0.000 0.628 0.000 0.272 0.100
#> GSM39839 3 0.4307 -0.0463 0.500 0.000 0.500 0.000 0.000
#> GSM39840 1 0.0290 0.8597 0.992 0.000 0.000 0.000 0.008
#> GSM39841 1 0.0000 0.8604 1.000 0.000 0.000 0.000 0.000
#> GSM39842 1 0.0404 0.8582 0.988 0.000 0.000 0.000 0.012
#> GSM39843 3 0.4855 0.2038 0.436 0.000 0.544 0.004 0.016
#> GSM39844 1 0.0290 0.8597 0.992 0.000 0.000 0.000 0.008
#> GSM39845 3 0.4560 0.0335 0.484 0.000 0.508 0.000 0.008
#> GSM39852 4 0.3241 0.7127 0.144 0.000 0.000 0.832 0.024
#> GSM39853 2 0.6808 0.0537 0.000 0.360 0.000 0.300 0.340
#> GSM39854 4 0.6657 0.1166 0.000 0.236 0.000 0.424 0.340
#> GSM39857 3 0.4304 -0.8512 0.000 0.000 0.516 0.000 0.484
#> GSM39860 2 0.1121 0.8054 0.000 0.956 0.000 0.000 0.044
#> GSM39861 3 0.3607 0.4979 0.244 0.000 0.752 0.000 0.004
#> GSM39864 1 0.0693 0.8564 0.980 0.000 0.012 0.000 0.008
#> GSM39868 4 0.3513 0.7056 0.180 0.000 0.000 0.800 0.020
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 5 0.1082 0.7634 0.000 0.040 0.000 0.000 0.956 0.004
#> GSM39874 5 0.1082 0.7634 0.000 0.040 0.000 0.000 0.956 0.004
#> GSM39875 5 0.1082 0.7634 0.000 0.040 0.000 0.000 0.956 0.004
#> GSM39876 5 0.1082 0.7634 0.000 0.040 0.000 0.000 0.956 0.004
#> GSM39831 1 0.0000 0.8005 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39819 1 0.4693 0.2172 0.564 0.040 0.392 0.004 0.000 0.000
#> GSM39820 1 0.4320 0.5817 0.704 0.048 0.240 0.008 0.000 0.000
#> GSM39821 4 0.5399 0.5135 0.360 0.032 0.056 0.552 0.000 0.000
#> GSM39822 5 0.0937 0.7632 0.000 0.040 0.000 0.000 0.960 0.000
#> GSM39823 6 0.4761 0.6000 0.000 0.032 0.312 0.024 0.000 0.632
#> GSM39824 5 0.4450 0.3901 0.000 0.016 0.012 0.000 0.592 0.380
#> GSM39825 3 0.4643 0.6484 0.096 0.024 0.728 0.000 0.000 0.152
#> GSM39826 4 0.4555 0.5111 0.016 0.272 0.040 0.672 0.000 0.000
#> GSM39827 1 0.5295 0.3851 0.656 0.208 0.032 0.104 0.000 0.000
#> GSM39846 6 0.0632 0.8272 0.000 0.000 0.024 0.000 0.000 0.976
#> GSM39847 4 0.6235 0.5678 0.264 0.052 0.144 0.540 0.000 0.000
#> GSM39848 5 0.0725 0.7581 0.000 0.012 0.012 0.000 0.976 0.000
#> GSM39849 6 0.1232 0.8122 0.000 0.024 0.016 0.004 0.000 0.956
#> GSM39850 4 0.4771 0.5353 0.032 0.256 0.040 0.672 0.000 0.000
#> GSM39851 1 0.0000 0.8005 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39855 5 0.3665 0.5968 0.000 0.016 0.012 0.000 0.760 0.212
#> GSM39856 6 0.0632 0.8274 0.000 0.000 0.024 0.000 0.000 0.976
#> GSM39858 3 0.4166 0.6553 0.088 0.004 0.748 0.000 0.000 0.160
#> GSM39859 3 0.4176 0.5845 0.064 0.004 0.732 0.000 0.000 0.200
#> GSM39862 5 0.5153 0.4892 0.000 0.040 0.024 0.020 0.656 0.260
#> GSM39863 1 0.0000 0.8005 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39865 5 0.0508 0.7602 0.000 0.004 0.012 0.000 0.984 0.000
#> GSM39866 1 0.2585 0.7622 0.888 0.016 0.048 0.048 0.000 0.000
#> GSM39867 1 0.5275 0.2329 0.556 0.364 0.024 0.056 0.000 0.000
#> GSM39869 5 0.0260 0.7629 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM39870 1 0.4415 0.5779 0.700 0.048 0.240 0.012 0.000 0.000
#> GSM39871 6 0.3634 0.5296 0.000 0.000 0.356 0.000 0.000 0.644
#> GSM39872 6 0.0551 0.8182 0.000 0.008 0.004 0.000 0.004 0.984
#> GSM39828 4 0.6584 0.5382 0.256 0.068 0.172 0.504 0.000 0.000
#> GSM39829 1 0.4094 0.6107 0.728 0.040 0.224 0.008 0.000 0.000
#> GSM39830 1 0.3595 0.6605 0.780 0.036 0.180 0.004 0.000 0.000
#> GSM39832 1 0.0000 0.8005 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39833 2 0.7441 0.2057 0.000 0.404 0.068 0.052 0.348 0.128
#> GSM39834 4 0.5855 0.5007 0.140 0.176 0.052 0.628 0.000 0.004
#> GSM39835 5 0.4944 0.2376 0.000 0.332 0.016 0.012 0.612 0.028
#> GSM39836 4 0.2069 0.5555 0.000 0.068 0.020 0.908 0.004 0.000
#> GSM39837 5 0.4841 -0.0634 0.000 0.424 0.024 0.020 0.532 0.000
#> GSM39838 5 0.5695 0.2428 0.000 0.136 0.024 0.252 0.588 0.000
#> GSM39839 3 0.4400 0.4633 0.332 0.032 0.632 0.004 0.000 0.000
#> GSM39840 1 0.0291 0.7976 0.992 0.000 0.004 0.004 0.000 0.000
#> GSM39841 1 0.0146 0.7997 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM39842 1 0.0508 0.7963 0.984 0.012 0.000 0.004 0.000 0.000
#> GSM39843 3 0.4486 0.6344 0.272 0.032 0.680 0.008 0.000 0.008
#> GSM39844 1 0.0000 0.8005 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM39845 3 0.5736 0.1764 0.424 0.036 0.476 0.004 0.000 0.060
#> GSM39852 4 0.2133 0.6201 0.052 0.016 0.020 0.912 0.000 0.000
#> GSM39853 2 0.3390 0.6144 0.008 0.808 0.000 0.032 0.152 0.000
#> GSM39854 2 0.3967 0.5288 0.000 0.776 0.008 0.132 0.084 0.000
#> GSM39857 6 0.3558 0.7637 0.000 0.028 0.168 0.012 0.000 0.792
#> GSM39860 5 0.0870 0.7570 0.000 0.012 0.012 0.000 0.972 0.004
#> GSM39861 3 0.4188 0.6902 0.140 0.008 0.756 0.000 0.000 0.096
#> GSM39864 1 0.1787 0.7816 0.932 0.016 0.020 0.032 0.000 0.000
#> GSM39868 4 0.4498 0.6050 0.160 0.052 0.036 0.748 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> ATC:skmeans 56 0.06116 0.0871 2
#> ATC:skmeans 56 0.01508 0.0719 3
#> ATC:skmeans 50 0.01737 0.0119 4
#> ATC:skmeans 40 0.05999 0.1024 5
#> ATC:skmeans 47 0.00636 0.0253 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.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.990 0.996 0.2660 0.733 0.733
#> 3 3 0.473 0.607 0.783 1.0578 0.691 0.579
#> 4 4 0.549 0.587 0.827 0.2524 0.796 0.571
#> 5 5 0.657 0.686 0.855 0.1026 0.822 0.509
#> 6 6 0.669 0.641 0.820 0.0456 0.895 0.603
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.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.000 0.980 0.000 1.000
#> GSM39874 2 0.000 0.980 0.000 1.000
#> GSM39875 2 0.000 0.980 0.000 1.000
#> GSM39876 2 0.000 0.980 0.000 1.000
#> GSM39831 1 0.000 0.998 1.000 0.000
#> GSM39819 1 0.000 0.998 1.000 0.000
#> GSM39820 1 0.000 0.998 1.000 0.000
#> GSM39821 1 0.000 0.998 1.000 0.000
#> GSM39822 2 0.000 0.980 0.000 1.000
#> GSM39823 1 0.000 0.998 1.000 0.000
#> GSM39824 1 0.469 0.886 0.900 0.100
#> GSM39825 1 0.000 0.998 1.000 0.000
#> GSM39826 1 0.000 0.998 1.000 0.000
#> GSM39827 1 0.000 0.998 1.000 0.000
#> GSM39846 1 0.000 0.998 1.000 0.000
#> GSM39847 1 0.000 0.998 1.000 0.000
#> GSM39848 2 0.000 0.980 0.000 1.000
#> GSM39849 1 0.000 0.998 1.000 0.000
#> GSM39850 1 0.000 0.998 1.000 0.000
#> GSM39851 1 0.000 0.998 1.000 0.000
#> GSM39855 2 0.625 0.814 0.156 0.844
#> GSM39856 1 0.000 0.998 1.000 0.000
#> GSM39858 1 0.000 0.998 1.000 0.000
#> GSM39859 1 0.000 0.998 1.000 0.000
#> GSM39862 1 0.000 0.998 1.000 0.000
#> GSM39863 1 0.000 0.998 1.000 0.000
#> GSM39865 1 0.000 0.998 1.000 0.000
#> GSM39866 1 0.000 0.998 1.000 0.000
#> GSM39867 1 0.000 0.998 1.000 0.000
#> GSM39869 2 0.000 0.980 0.000 1.000
#> GSM39870 1 0.000 0.998 1.000 0.000
#> GSM39871 1 0.000 0.998 1.000 0.000
#> GSM39872 1 0.000 0.998 1.000 0.000
#> GSM39828 1 0.000 0.998 1.000 0.000
#> GSM39829 1 0.000 0.998 1.000 0.000
#> GSM39830 1 0.000 0.998 1.000 0.000
#> GSM39832 1 0.000 0.998 1.000 0.000
#> GSM39833 1 0.000 0.998 1.000 0.000
#> GSM39834 1 0.000 0.998 1.000 0.000
#> GSM39835 1 0.000 0.998 1.000 0.000
#> GSM39836 1 0.000 0.998 1.000 0.000
#> GSM39837 1 0.000 0.998 1.000 0.000
#> GSM39838 1 0.000 0.998 1.000 0.000
#> GSM39839 1 0.000 0.998 1.000 0.000
#> GSM39840 1 0.000 0.998 1.000 0.000
#> GSM39841 1 0.000 0.998 1.000 0.000
#> GSM39842 1 0.000 0.998 1.000 0.000
#> GSM39843 1 0.000 0.998 1.000 0.000
#> GSM39844 1 0.000 0.998 1.000 0.000
#> GSM39845 1 0.000 0.998 1.000 0.000
#> GSM39852 1 0.000 0.998 1.000 0.000
#> GSM39853 1 0.000 0.998 1.000 0.000
#> GSM39854 1 0.000 0.998 1.000 0.000
#> GSM39857 1 0.000 0.998 1.000 0.000
#> GSM39860 2 0.000 0.980 0.000 1.000
#> GSM39861 1 0.000 0.998 1.000 0.000
#> GSM39864 1 0.000 0.998 1.000 0.000
#> GSM39868 1 0.000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.000 0.9376 0.000 1.000 0.000
#> GSM39874 2 0.000 0.9376 0.000 1.000 0.000
#> GSM39875 2 0.000 0.9376 0.000 1.000 0.000
#> GSM39876 2 0.000 0.9376 0.000 1.000 0.000
#> GSM39831 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39819 1 0.556 0.1806 0.700 0.000 0.300
#> GSM39820 1 0.254 0.7257 0.920 0.000 0.080
#> GSM39821 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39822 2 0.175 0.9273 0.000 0.952 0.048
#> GSM39823 3 0.394 0.5791 0.156 0.000 0.844
#> GSM39824 3 0.296 0.4123 0.000 0.100 0.900
#> GSM39825 3 0.445 0.5838 0.192 0.000 0.808
#> GSM39826 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39827 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39846 3 0.175 0.5354 0.048 0.000 0.952
#> GSM39847 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39848 2 0.129 0.9321 0.000 0.968 0.032
#> GSM39849 3 0.153 0.5303 0.040 0.000 0.960
#> GSM39850 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39851 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39855 2 0.631 0.5266 0.000 0.504 0.496
#> GSM39856 3 0.175 0.5354 0.048 0.000 0.952
#> GSM39858 3 0.412 0.4408 0.168 0.000 0.832
#> GSM39859 3 0.334 0.5690 0.120 0.000 0.880
#> GSM39862 3 0.529 0.5319 0.268 0.000 0.732
#> GSM39863 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39865 3 0.624 0.5041 0.440 0.000 0.560
#> GSM39866 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39867 1 0.475 0.4685 0.784 0.000 0.216
#> GSM39869 2 0.175 0.9273 0.000 0.952 0.048
#> GSM39870 3 0.601 0.3063 0.372 0.000 0.628
#> GSM39871 3 0.236 0.5488 0.072 0.000 0.928
#> GSM39872 3 0.175 0.5354 0.048 0.000 0.952
#> GSM39828 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39829 1 0.186 0.7647 0.948 0.000 0.052
#> GSM39830 1 0.579 0.0138 0.668 0.000 0.332
#> GSM39832 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39833 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39834 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39835 3 0.624 0.5041 0.440 0.000 0.560
#> GSM39836 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39837 3 0.631 0.5318 0.492 0.000 0.508
#> GSM39838 3 0.626 0.5038 0.448 0.000 0.552
#> GSM39839 3 0.595 0.3300 0.360 0.000 0.640
#> GSM39840 1 0.103 0.7993 0.976 0.000 0.024
#> GSM39841 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39842 1 0.236 0.7472 0.928 0.000 0.072
#> GSM39843 3 0.617 0.5635 0.412 0.000 0.588
#> GSM39844 1 0.000 0.8137 1.000 0.000 0.000
#> GSM39845 3 0.553 0.5722 0.296 0.000 0.704
#> GSM39852 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39853 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39854 3 0.631 0.5336 0.496 0.000 0.504
#> GSM39857 3 0.362 0.5748 0.136 0.000 0.864
#> GSM39860 2 0.000 0.9376 0.000 1.000 0.000
#> GSM39861 3 0.400 0.5792 0.160 0.000 0.840
#> GSM39864 1 0.565 0.0961 0.688 0.000 0.312
#> GSM39868 3 0.617 0.5635 0.412 0.000 0.588
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.87623 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.87623 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.87623 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.87623 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0000 0.88193 1.000 0.000 0.000 0.000
#> GSM39819 4 0.4319 0.51512 0.228 0.000 0.012 0.760
#> GSM39820 1 0.4204 0.73516 0.788 0.000 0.020 0.192
#> GSM39821 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39822 2 0.4746 0.70708 0.000 0.632 0.368 0.000
#> GSM39823 4 0.4804 0.05678 0.000 0.000 0.384 0.616
#> GSM39824 3 0.0000 0.39243 0.000 0.000 1.000 0.000
#> GSM39825 4 0.4431 0.27227 0.000 0.000 0.304 0.696
#> GSM39826 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39827 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39846 3 0.4746 0.60104 0.000 0.000 0.632 0.368
#> GSM39847 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39848 2 0.3688 0.80433 0.000 0.792 0.208 0.000
#> GSM39849 3 0.4564 0.61015 0.000 0.000 0.672 0.328
#> GSM39850 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39851 1 0.0000 0.88193 1.000 0.000 0.000 0.000
#> GSM39855 3 0.0000 0.39243 0.000 0.000 1.000 0.000
#> GSM39856 3 0.4746 0.60104 0.000 0.000 0.632 0.368
#> GSM39858 3 0.6783 0.50225 0.124 0.000 0.572 0.304
#> GSM39859 4 0.4776 0.06260 0.000 0.000 0.376 0.624
#> GSM39862 3 0.4855 0.02044 0.000 0.000 0.600 0.400
#> GSM39863 1 0.0000 0.88193 1.000 0.000 0.000 0.000
#> GSM39865 4 0.4916 0.22402 0.000 0.000 0.424 0.576
#> GSM39866 1 0.2345 0.83240 0.900 0.000 0.000 0.100
#> GSM39867 1 0.3942 0.60986 0.764 0.000 0.000 0.236
#> GSM39869 2 0.4746 0.70708 0.000 0.632 0.368 0.000
#> GSM39870 4 0.7667 -0.01637 0.224 0.000 0.336 0.440
#> GSM39871 3 0.4996 0.34337 0.000 0.000 0.516 0.484
#> GSM39872 3 0.4746 0.60104 0.000 0.000 0.632 0.368
#> GSM39828 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39829 1 0.4630 0.65782 0.732 0.000 0.016 0.252
#> GSM39830 4 0.3356 0.57101 0.176 0.000 0.000 0.824
#> GSM39832 1 0.0000 0.88193 1.000 0.000 0.000 0.000
#> GSM39833 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39834 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39835 4 0.4888 0.24227 0.000 0.000 0.412 0.588
#> GSM39836 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39837 4 0.2814 0.59968 0.000 0.000 0.132 0.868
#> GSM39838 4 0.4679 0.32384 0.000 0.000 0.352 0.648
#> GSM39839 4 0.7605 0.00341 0.212 0.000 0.336 0.452
#> GSM39840 1 0.1022 0.87065 0.968 0.000 0.000 0.032
#> GSM39841 1 0.0188 0.88148 0.996 0.000 0.000 0.004
#> GSM39842 1 0.2081 0.82943 0.916 0.000 0.000 0.084
#> GSM39843 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39844 1 0.0000 0.88193 1.000 0.000 0.000 0.000
#> GSM39845 4 0.4323 0.46791 0.020 0.000 0.204 0.776
#> GSM39852 4 0.0000 0.69180 0.000 0.000 0.000 1.000
#> GSM39853 4 0.4164 0.43600 0.264 0.000 0.000 0.736
#> GSM39854 4 0.2345 0.62732 0.100 0.000 0.000 0.900
#> GSM39857 4 0.4713 0.11973 0.000 0.000 0.360 0.640
#> GSM39860 2 0.0000 0.87623 0.000 1.000 0.000 0.000
#> GSM39861 4 0.4605 0.19127 0.000 0.000 0.336 0.664
#> GSM39864 4 0.3649 0.54415 0.204 0.000 0.000 0.796
#> GSM39868 4 0.0000 0.69180 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0000 0.919 0.000 1.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.919 0.000 1.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.919 0.000 1.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.919 0.000 1.000 0.000 0.000 0.000
#> GSM39831 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM39819 4 0.4555 0.527 0.224 0.000 0.056 0.720 0.000
#> GSM39820 1 0.3675 0.744 0.788 0.000 0.024 0.188 0.000
#> GSM39821 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39822 5 0.0162 0.813 0.000 0.004 0.000 0.000 0.996
#> GSM39823 3 0.4300 0.470 0.000 0.000 0.524 0.476 0.000
#> GSM39824 5 0.4114 0.512 0.000 0.000 0.376 0.000 0.624
#> GSM39825 4 0.4297 -0.420 0.000 0.000 0.472 0.528 0.000
#> GSM39826 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39827 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39846 3 0.0000 0.565 0.000 0.000 1.000 0.000 0.000
#> GSM39847 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39848 5 0.2813 0.661 0.000 0.168 0.000 0.000 0.832
#> GSM39849 3 0.0000 0.565 0.000 0.000 1.000 0.000 0.000
#> GSM39850 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39851 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM39855 5 0.3074 0.719 0.000 0.000 0.196 0.000 0.804
#> GSM39856 3 0.0000 0.565 0.000 0.000 1.000 0.000 0.000
#> GSM39858 3 0.5299 0.637 0.120 0.000 0.668 0.212 0.000
#> GSM39859 3 0.4287 0.496 0.000 0.000 0.540 0.460 0.000
#> GSM39862 5 0.5115 0.576 0.000 0.000 0.092 0.232 0.676
#> GSM39863 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM39865 5 0.0162 0.814 0.000 0.000 0.000 0.004 0.996
#> GSM39866 1 0.2124 0.838 0.900 0.000 0.004 0.096 0.000
#> GSM39867 1 0.3366 0.648 0.768 0.000 0.000 0.232 0.000
#> GSM39869 5 0.0000 0.813 0.000 0.000 0.000 0.000 1.000
#> GSM39870 3 0.6408 0.531 0.220 0.000 0.508 0.272 0.000
#> GSM39871 3 0.3395 0.645 0.000 0.000 0.764 0.236 0.000
#> GSM39872 3 0.0000 0.565 0.000 0.000 1.000 0.000 0.000
#> GSM39828 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39829 1 0.4054 0.676 0.732 0.000 0.020 0.248 0.000
#> GSM39830 4 0.3048 0.640 0.176 0.000 0.004 0.820 0.000
#> GSM39832 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM39833 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39834 4 0.0162 0.804 0.000 0.000 0.004 0.996 0.000
#> GSM39835 5 0.0963 0.811 0.000 0.000 0.000 0.036 0.964
#> GSM39836 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39837 4 0.4268 0.274 0.000 0.000 0.000 0.556 0.444
#> GSM39838 5 0.1197 0.805 0.000 0.000 0.000 0.048 0.952
#> GSM39839 3 0.6454 0.501 0.208 0.000 0.488 0.304 0.000
#> GSM39840 1 0.0794 0.875 0.972 0.000 0.000 0.028 0.000
#> GSM39841 1 0.0162 0.884 0.996 0.000 0.000 0.004 0.000
#> GSM39842 1 0.1792 0.831 0.916 0.000 0.000 0.084 0.000
#> GSM39843 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39844 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM39845 4 0.4065 0.338 0.016 0.000 0.264 0.720 0.000
#> GSM39852 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
#> GSM39853 4 0.5804 0.370 0.120 0.000 0.000 0.576 0.304
#> GSM39854 4 0.4462 0.575 0.064 0.000 0.000 0.740 0.196
#> GSM39857 3 0.4287 0.495 0.000 0.000 0.540 0.460 0.000
#> GSM39860 2 0.3816 0.557 0.000 0.696 0.000 0.000 0.304
#> GSM39861 3 0.4304 0.455 0.000 0.000 0.516 0.484 0.000
#> GSM39864 4 0.3109 0.614 0.200 0.000 0.000 0.800 0.000
#> GSM39868 4 0.0000 0.807 0.000 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 0.8641 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 0.8641 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 0.8641 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 0.8641 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.3804 0.8573 0.576 0.000 0.424 0.000 0.000 0.000
#> GSM39819 3 0.3037 0.7084 0.000 0.000 0.808 0.176 0.000 0.016
#> GSM39820 3 0.1075 0.5815 0.048 0.000 0.952 0.000 0.000 0.000
#> GSM39821 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39822 5 0.0146 0.7260 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM39823 4 0.5987 -0.1355 0.000 0.000 0.240 0.424 0.000 0.336
#> GSM39824 5 0.4141 0.4308 0.016 0.000 0.000 0.000 0.596 0.388
#> GSM39825 4 0.4344 0.3626 0.000 0.000 0.044 0.652 0.000 0.304
#> GSM39826 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39827 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39846 6 0.0146 0.7153 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM39847 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39848 5 0.4107 0.5445 0.280 0.036 0.000 0.000 0.684 0.000
#> GSM39849 6 0.0146 0.7153 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM39850 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39851 1 0.3706 0.9024 0.620 0.000 0.380 0.000 0.000 0.000
#> GSM39855 5 0.3934 0.5519 0.020 0.000 0.000 0.000 0.676 0.304
#> GSM39856 6 0.0146 0.7153 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM39858 6 0.5066 0.5238 0.000 0.000 0.176 0.188 0.000 0.636
#> GSM39859 6 0.5821 0.0878 0.000 0.000 0.184 0.408 0.000 0.408
#> GSM39862 5 0.4949 0.5244 0.000 0.000 0.000 0.208 0.648 0.144
#> GSM39863 1 0.3706 0.9024 0.620 0.000 0.380 0.000 0.000 0.000
#> GSM39865 5 0.0146 0.7274 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM39866 3 0.1075 0.5815 0.048 0.000 0.952 0.000 0.000 0.000
#> GSM39867 1 0.5217 0.5484 0.608 0.000 0.160 0.232 0.000 0.000
#> GSM39869 5 0.3198 0.5983 0.260 0.000 0.000 0.000 0.740 0.000
#> GSM39870 3 0.3236 0.7166 0.004 0.000 0.820 0.140 0.000 0.036
#> GSM39871 6 0.3920 0.6237 0.000 0.000 0.048 0.216 0.000 0.736
#> GSM39872 6 0.0363 0.7147 0.000 0.000 0.012 0.000 0.000 0.988
#> GSM39828 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39829 3 0.1075 0.5815 0.048 0.000 0.952 0.000 0.000 0.000
#> GSM39830 4 0.3190 0.5324 0.008 0.000 0.220 0.772 0.000 0.000
#> GSM39832 1 0.3706 0.9024 0.620 0.000 0.380 0.000 0.000 0.000
#> GSM39833 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39834 4 0.0260 0.7814 0.000 0.000 0.008 0.992 0.000 0.000
#> GSM39835 5 0.2404 0.7108 0.080 0.000 0.000 0.036 0.884 0.000
#> GSM39836 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39837 4 0.3854 0.2202 0.000 0.000 0.000 0.536 0.464 0.000
#> GSM39838 5 0.1564 0.7233 0.024 0.000 0.000 0.040 0.936 0.000
#> GSM39839 3 0.3172 0.7083 0.000 0.000 0.816 0.148 0.000 0.036
#> GSM39840 1 0.4264 0.8829 0.620 0.000 0.352 0.028 0.000 0.000
#> GSM39841 1 0.3841 0.9009 0.616 0.000 0.380 0.004 0.000 0.000
#> GSM39842 1 0.4827 0.8077 0.620 0.000 0.296 0.084 0.000 0.000
#> GSM39843 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39844 1 0.3706 0.9024 0.620 0.000 0.380 0.000 0.000 0.000
#> GSM39845 3 0.4246 0.2938 0.000 0.000 0.580 0.400 0.000 0.020
#> GSM39852 4 0.0000 0.7855 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM39853 4 0.5625 0.2733 0.164 0.000 0.000 0.504 0.332 0.000
#> GSM39854 4 0.4655 0.5436 0.112 0.000 0.000 0.680 0.208 0.000
#> GSM39857 4 0.4640 0.1812 0.000 0.000 0.048 0.576 0.000 0.376
#> GSM39860 2 0.6048 0.1314 0.296 0.416 0.000 0.000 0.288 0.000
#> GSM39861 4 0.4482 0.3122 0.000 0.000 0.048 0.628 0.000 0.324
#> GSM39864 4 0.3373 0.4812 0.008 0.000 0.248 0.744 0.000 0.000
#> GSM39868 4 0.0000 0.7855 0.000 0.000 0.000 1.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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> ATC:pam 58 3.78e-05 1.94e-05 2
#> ATC:pam 50 5.00e-05 3.66e-04 3
#> ATC:pam 42 3.02e-04 5.94e-04 4
#> ATC:pam 50 6.55e-08 9.24e-07 5
#> ATC:pam 47 5.68e-09 1.20e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.762 0.860 0.937 0.2742 0.710 0.710
#> 3 3 0.367 0.497 0.709 0.9580 0.681 0.576
#> 4 4 0.622 0.746 0.860 0.3056 0.659 0.385
#> 5 5 0.630 0.603 0.757 0.0983 0.915 0.710
#> 6 6 0.710 0.588 0.763 0.0647 0.892 0.563
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0000 0.764 0.000 1.000
#> GSM39874 2 0.0000 0.764 0.000 1.000
#> GSM39875 2 0.0000 0.764 0.000 1.000
#> GSM39876 2 0.0000 0.764 0.000 1.000
#> GSM39831 1 0.0000 0.953 1.000 0.000
#> GSM39819 1 0.0000 0.953 1.000 0.000
#> GSM39820 1 0.0000 0.953 1.000 0.000
#> GSM39821 1 0.0000 0.953 1.000 0.000
#> GSM39822 2 0.8499 0.724 0.276 0.724
#> GSM39823 1 0.0376 0.952 0.996 0.004
#> GSM39824 1 0.2043 0.933 0.968 0.032
#> GSM39825 1 0.0376 0.952 0.996 0.004
#> GSM39826 1 0.2236 0.924 0.964 0.036
#> GSM39827 1 0.0000 0.953 1.000 0.000
#> GSM39846 1 0.2043 0.933 0.968 0.032
#> GSM39847 1 0.0000 0.953 1.000 0.000
#> GSM39848 2 0.7602 0.758 0.220 0.780
#> GSM39849 1 0.2043 0.933 0.968 0.032
#> GSM39850 1 0.0000 0.953 1.000 0.000
#> GSM39851 1 0.0000 0.953 1.000 0.000
#> GSM39855 1 0.3114 0.911 0.944 0.056
#> GSM39856 1 0.2043 0.933 0.968 0.032
#> GSM39858 1 0.0376 0.952 0.996 0.004
#> GSM39859 1 0.0376 0.952 0.996 0.004
#> GSM39862 1 0.2043 0.933 0.968 0.032
#> GSM39863 1 0.0000 0.953 1.000 0.000
#> GSM39865 1 0.9087 0.375 0.676 0.324
#> GSM39866 1 0.0000 0.953 1.000 0.000
#> GSM39867 1 0.0000 0.953 1.000 0.000
#> GSM39869 2 0.9248 0.653 0.340 0.660
#> GSM39870 1 0.0000 0.953 1.000 0.000
#> GSM39871 1 0.0376 0.952 0.996 0.004
#> GSM39872 1 0.2043 0.933 0.968 0.032
#> GSM39828 1 0.0672 0.950 0.992 0.008
#> GSM39829 1 0.0000 0.953 1.000 0.000
#> GSM39830 1 0.0000 0.953 1.000 0.000
#> GSM39832 1 0.0000 0.953 1.000 0.000
#> GSM39833 1 0.1184 0.945 0.984 0.016
#> GSM39834 1 0.0000 0.953 1.000 0.000
#> GSM39835 1 0.9044 0.388 0.680 0.320
#> GSM39836 1 0.0376 0.952 0.996 0.004
#> GSM39837 2 0.9833 0.494 0.424 0.576
#> GSM39838 1 0.9087 0.375 0.676 0.324
#> GSM39839 1 0.0376 0.952 0.996 0.004
#> GSM39840 1 0.0000 0.953 1.000 0.000
#> GSM39841 1 0.0000 0.953 1.000 0.000
#> GSM39842 1 0.0376 0.952 0.996 0.004
#> GSM39843 1 0.0376 0.952 0.996 0.004
#> GSM39844 1 0.0000 0.953 1.000 0.000
#> GSM39845 1 0.0000 0.953 1.000 0.000
#> GSM39852 1 0.0000 0.953 1.000 0.000
#> GSM39853 2 0.9933 0.444 0.452 0.548
#> GSM39854 1 0.9580 0.155 0.620 0.380
#> GSM39857 1 0.2043 0.933 0.968 0.032
#> GSM39860 2 0.7883 0.746 0.236 0.764
#> GSM39861 1 0.0000 0.953 1.000 0.000
#> GSM39864 1 0.0000 0.953 1.000 0.000
#> GSM39868 1 0.0000 0.953 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0237 1.000 0.004 0.996 0.000
#> GSM39874 2 0.0237 1.000 0.004 0.996 0.000
#> GSM39875 2 0.0237 1.000 0.004 0.996 0.000
#> GSM39876 2 0.0237 1.000 0.004 0.996 0.000
#> GSM39831 3 0.0747 0.621 0.016 0.000 0.984
#> GSM39819 3 0.5873 0.572 0.312 0.004 0.684
#> GSM39820 3 0.0424 0.627 0.008 0.000 0.992
#> GSM39821 3 0.3752 0.421 0.144 0.000 0.856
#> GSM39822 1 0.8650 0.696 0.572 0.136 0.292
#> GSM39823 3 0.6104 0.562 0.348 0.004 0.648
#> GSM39824 1 0.7389 -0.426 0.504 0.032 0.464
#> GSM39825 3 0.6033 0.565 0.336 0.004 0.660
#> GSM39826 1 0.8721 0.665 0.504 0.112 0.384
#> GSM39827 3 0.6307 -0.569 0.488 0.000 0.512
#> GSM39846 3 0.6295 0.452 0.472 0.000 0.528
#> GSM39847 3 0.1163 0.610 0.028 0.000 0.972
#> GSM39848 1 0.7287 0.551 0.696 0.092 0.212
#> GSM39849 3 0.6252 0.484 0.444 0.000 0.556
#> GSM39850 1 0.7188 0.579 0.492 0.024 0.484
#> GSM39851 3 0.0747 0.621 0.016 0.000 0.984
#> GSM39855 1 0.7480 -0.415 0.508 0.036 0.456
#> GSM39856 3 0.6280 0.466 0.460 0.000 0.540
#> GSM39858 3 0.6209 0.548 0.368 0.004 0.628
#> GSM39859 3 0.6057 0.565 0.340 0.004 0.656
#> GSM39862 1 0.6688 0.594 0.580 0.012 0.408
#> GSM39863 3 0.0892 0.621 0.020 0.000 0.980
#> GSM39865 1 0.5803 0.647 0.736 0.016 0.248
#> GSM39866 3 0.0747 0.621 0.016 0.000 0.984
#> GSM39867 1 0.7187 0.584 0.496 0.024 0.480
#> GSM39869 1 0.6967 0.670 0.668 0.044 0.288
#> GSM39870 3 0.0592 0.628 0.012 0.000 0.988
#> GSM39871 3 0.6228 0.546 0.372 0.004 0.624
#> GSM39872 3 0.5948 0.556 0.360 0.000 0.640
#> GSM39828 1 0.6286 0.574 0.536 0.000 0.464
#> GSM39829 3 0.0237 0.627 0.004 0.000 0.996
#> GSM39830 3 0.0000 0.627 0.000 0.000 1.000
#> GSM39832 3 0.0747 0.621 0.016 0.000 0.984
#> GSM39833 3 0.5465 0.290 0.288 0.000 0.712
#> GSM39834 3 0.6307 -0.570 0.488 0.000 0.512
#> GSM39835 1 0.8404 0.696 0.592 0.120 0.288
#> GSM39836 1 0.7838 0.609 0.488 0.052 0.460
#> GSM39837 1 0.8742 0.697 0.556 0.136 0.308
#> GSM39838 1 0.8570 0.698 0.564 0.120 0.316
#> GSM39839 3 0.6057 0.565 0.340 0.004 0.656
#> GSM39840 3 0.1860 0.580 0.052 0.000 0.948
#> GSM39841 3 0.0747 0.621 0.016 0.000 0.984
#> GSM39842 3 0.2625 0.549 0.084 0.000 0.916
#> GSM39843 3 0.6033 0.565 0.336 0.004 0.660
#> GSM39844 3 0.0747 0.621 0.016 0.000 0.984
#> GSM39845 3 0.1289 0.627 0.032 0.000 0.968
#> GSM39852 3 0.6305 -0.564 0.484 0.000 0.516
#> GSM39853 1 0.8803 0.696 0.544 0.136 0.320
#> GSM39854 1 0.8841 0.691 0.536 0.136 0.328
#> GSM39857 3 0.5948 0.556 0.360 0.000 0.640
#> GSM39860 1 0.3918 0.119 0.868 0.120 0.012
#> GSM39861 3 0.3192 0.615 0.112 0.000 0.888
#> GSM39864 3 0.0237 0.625 0.004 0.000 0.996
#> GSM39868 3 0.6305 -0.564 0.484 0.000 0.516
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM39831 1 0.0000 0.7566 1.000 0.000 0.000 0.000
#> GSM39819 3 0.4277 0.6482 0.280 0.000 0.720 0.000
#> GSM39820 1 0.4907 0.1171 0.580 0.000 0.420 0.000
#> GSM39821 4 0.5329 0.3980 0.420 0.000 0.012 0.568
#> GSM39822 4 0.1610 0.8394 0.000 0.016 0.032 0.952
#> GSM39823 3 0.0895 0.8658 0.020 0.000 0.976 0.004
#> GSM39824 3 0.1406 0.8508 0.000 0.016 0.960 0.024
#> GSM39825 3 0.4095 0.7569 0.172 0.000 0.804 0.024
#> GSM39826 4 0.2987 0.8455 0.104 0.000 0.016 0.880
#> GSM39827 4 0.5244 0.4802 0.388 0.000 0.012 0.600
#> GSM39846 3 0.1042 0.8665 0.020 0.000 0.972 0.008
#> GSM39847 1 0.5025 0.5309 0.716 0.000 0.032 0.252
#> GSM39848 4 0.2662 0.8185 0.000 0.016 0.084 0.900
#> GSM39849 3 0.1406 0.8508 0.000 0.016 0.960 0.024
#> GSM39850 4 0.3161 0.8353 0.124 0.000 0.012 0.864
#> GSM39851 1 0.0188 0.7568 0.996 0.000 0.000 0.004
#> GSM39855 3 0.1406 0.8508 0.000 0.016 0.960 0.024
#> GSM39856 3 0.1520 0.8640 0.020 0.000 0.956 0.024
#> GSM39858 3 0.1151 0.8646 0.024 0.000 0.968 0.008
#> GSM39859 3 0.2596 0.8377 0.068 0.000 0.908 0.024
#> GSM39862 4 0.3946 0.8390 0.048 0.016 0.080 0.856
#> GSM39863 1 0.4898 0.6362 0.772 0.000 0.072 0.156
#> GSM39865 4 0.2593 0.8212 0.000 0.016 0.080 0.904
#> GSM39866 1 0.0524 0.7590 0.988 0.000 0.008 0.004
#> GSM39867 4 0.3324 0.8284 0.136 0.000 0.012 0.852
#> GSM39869 4 0.2142 0.8323 0.000 0.016 0.056 0.928
#> GSM39870 1 0.4989 -0.0871 0.528 0.000 0.472 0.000
#> GSM39871 3 0.1520 0.8565 0.020 0.000 0.956 0.024
#> GSM39872 3 0.1004 0.8592 0.004 0.000 0.972 0.024
#> GSM39828 4 0.3984 0.8409 0.132 0.000 0.040 0.828
#> GSM39829 1 0.4843 0.1931 0.604 0.000 0.396 0.000
#> GSM39830 1 0.5785 0.5280 0.664 0.000 0.272 0.064
#> GSM39832 1 0.0000 0.7566 1.000 0.000 0.000 0.000
#> GSM39833 4 0.4153 0.8411 0.132 0.000 0.048 0.820
#> GSM39834 4 0.3718 0.8077 0.168 0.000 0.012 0.820
#> GSM39835 4 0.2222 0.8320 0.000 0.016 0.060 0.924
#> GSM39836 4 0.2805 0.8452 0.100 0.000 0.012 0.888
#> GSM39837 4 0.1943 0.8467 0.008 0.016 0.032 0.944
#> GSM39838 4 0.1356 0.8498 0.008 0.000 0.032 0.960
#> GSM39839 3 0.0817 0.8662 0.024 0.000 0.976 0.000
#> GSM39840 1 0.3224 0.7229 0.864 0.000 0.016 0.120
#> GSM39841 1 0.1022 0.7558 0.968 0.000 0.000 0.032
#> GSM39842 1 0.3978 0.7161 0.836 0.000 0.056 0.108
#> GSM39843 3 0.4050 0.7611 0.168 0.000 0.808 0.024
#> GSM39844 1 0.0000 0.7566 1.000 0.000 0.000 0.000
#> GSM39845 3 0.6306 0.2116 0.392 0.000 0.544 0.064
#> GSM39852 4 0.4175 0.7635 0.212 0.000 0.012 0.776
#> GSM39853 4 0.0992 0.8490 0.008 0.004 0.012 0.976
#> GSM39854 4 0.0927 0.8497 0.008 0.000 0.016 0.976
#> GSM39857 3 0.1004 0.8592 0.004 0.000 0.972 0.024
#> GSM39860 4 0.2909 0.8121 0.000 0.020 0.092 0.888
#> GSM39861 3 0.5453 0.4909 0.320 0.000 0.648 0.032
#> GSM39864 1 0.3128 0.7444 0.884 0.000 0.076 0.040
#> GSM39868 4 0.4059 0.7775 0.200 0.000 0.012 0.788
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.3966 0.773 0.000 0.664 0.000 0.336 0.000
#> GSM39874 2 0.3966 0.773 0.000 0.664 0.000 0.336 0.000
#> GSM39875 2 0.3966 0.773 0.000 0.664 0.000 0.336 0.000
#> GSM39876 2 0.3966 0.773 0.000 0.664 0.000 0.336 0.000
#> GSM39831 1 0.0000 0.750 1.000 0.000 0.000 0.000 0.000
#> GSM39819 3 0.1732 0.721 0.080 0.000 0.920 0.000 0.000
#> GSM39820 1 0.4954 0.478 0.628 0.336 0.028 0.008 0.000
#> GSM39821 4 0.4733 0.725 0.348 0.000 0.000 0.624 0.028
#> GSM39822 5 0.0510 0.687 0.000 0.000 0.000 0.016 0.984
#> GSM39823 3 0.0000 0.753 0.000 0.000 1.000 0.000 0.000
#> GSM39824 3 0.4420 0.421 0.000 0.000 0.548 0.004 0.448
#> GSM39825 3 0.4353 0.483 0.008 0.328 0.660 0.004 0.000
#> GSM39826 4 0.5555 0.847 0.204 0.000 0.000 0.644 0.152
#> GSM39827 4 0.4805 0.770 0.312 0.000 0.000 0.648 0.040
#> GSM39846 3 0.0162 0.753 0.000 0.000 0.996 0.004 0.000
#> GSM39847 1 0.4287 -0.311 0.540 0.000 0.000 0.460 0.000
#> GSM39848 5 0.0162 0.688 0.000 0.000 0.000 0.004 0.996
#> GSM39849 3 0.2966 0.710 0.000 0.000 0.816 0.000 0.184
#> GSM39850 4 0.5482 0.849 0.204 0.000 0.000 0.652 0.144
#> GSM39851 1 0.0000 0.750 1.000 0.000 0.000 0.000 0.000
#> GSM39855 3 0.4420 0.421 0.000 0.000 0.548 0.004 0.448
#> GSM39856 3 0.2848 0.723 0.000 0.000 0.840 0.004 0.156
#> GSM39858 3 0.0000 0.753 0.000 0.000 1.000 0.000 0.000
#> GSM39859 3 0.0162 0.752 0.000 0.000 0.996 0.004 0.000
#> GSM39862 5 0.5631 0.201 0.200 0.000 0.000 0.164 0.636
#> GSM39863 1 0.0404 0.745 0.988 0.000 0.000 0.012 0.000
#> GSM39865 5 0.0162 0.689 0.000 0.000 0.000 0.004 0.996
#> GSM39866 1 0.0162 0.749 0.996 0.000 0.000 0.004 0.000
#> GSM39867 4 0.5462 0.852 0.212 0.000 0.000 0.652 0.136
#> GSM39869 5 0.0162 0.689 0.000 0.000 0.000 0.004 0.996
#> GSM39870 1 0.5171 0.465 0.616 0.336 0.040 0.008 0.000
#> GSM39871 3 0.0000 0.753 0.000 0.000 1.000 0.000 0.000
#> GSM39872 3 0.4193 0.637 0.024 0.000 0.720 0.000 0.256
#> GSM39828 4 0.6436 0.687 0.232 0.000 0.000 0.504 0.264
#> GSM39829 1 0.4875 0.481 0.632 0.336 0.024 0.008 0.000
#> GSM39830 1 0.6474 0.456 0.472 0.328 0.000 0.200 0.000
#> GSM39832 1 0.0000 0.750 1.000 0.000 0.000 0.000 0.000
#> GSM39833 4 0.6148 0.705 0.160 0.000 0.004 0.568 0.268
#> GSM39834 4 0.5450 0.852 0.228 0.000 0.000 0.648 0.124
#> GSM39835 5 0.4354 0.344 0.008 0.000 0.000 0.368 0.624
#> GSM39836 4 0.5692 0.834 0.204 0.000 0.000 0.628 0.168
#> GSM39837 5 0.4171 0.295 0.000 0.000 0.000 0.396 0.604
#> GSM39838 4 0.5548 0.183 0.068 0.000 0.000 0.492 0.440
#> GSM39839 3 0.0794 0.745 0.028 0.000 0.972 0.000 0.000
#> GSM39840 1 0.3242 0.534 0.784 0.000 0.000 0.216 0.000
#> GSM39841 1 0.0162 0.748 0.996 0.000 0.000 0.004 0.000
#> GSM39842 1 0.3530 0.540 0.784 0.000 0.000 0.204 0.012
#> GSM39843 3 0.4675 0.467 0.020 0.336 0.640 0.004 0.000
#> GSM39844 1 0.0000 0.750 1.000 0.000 0.000 0.000 0.000
#> GSM39845 2 0.8272 -0.245 0.172 0.336 0.328 0.164 0.000
#> GSM39852 4 0.5500 0.850 0.236 0.000 0.000 0.640 0.124
#> GSM39853 5 0.4242 0.212 0.000 0.000 0.000 0.428 0.572
#> GSM39854 5 0.4262 0.175 0.000 0.000 0.000 0.440 0.560
#> GSM39857 3 0.2891 0.714 0.000 0.000 0.824 0.000 0.176
#> GSM39860 5 0.0162 0.688 0.000 0.000 0.000 0.004 0.996
#> GSM39861 3 0.7816 0.142 0.136 0.336 0.408 0.120 0.000
#> GSM39864 1 0.3656 0.636 0.800 0.000 0.168 0.032 0.000
#> GSM39868 4 0.5549 0.846 0.244 0.000 0.000 0.632 0.124
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39874 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39875 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39876 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> GSM39831 1 0.0000 0.777 1.000 0 0.000 0.000 0.000 0.000
#> GSM39819 3 0.3052 0.628 0.004 0 0.780 0.000 0.000 0.216
#> GSM39820 1 0.3765 0.411 0.596 0 0.000 0.000 0.000 0.404
#> GSM39821 4 0.1367 0.732 0.012 0 0.000 0.944 0.000 0.044
#> GSM39822 5 0.0405 0.739 0.000 0 0.000 0.008 0.988 0.004
#> GSM39823 3 0.0547 0.760 0.000 0 0.980 0.000 0.000 0.020
#> GSM39824 5 0.4758 0.270 0.000 0 0.360 0.000 0.580 0.060
#> GSM39825 6 0.3866 0.134 0.000 0 0.484 0.000 0.000 0.516
#> GSM39826 4 0.2830 0.738 0.000 0 0.000 0.836 0.020 0.144
#> GSM39827 4 0.2772 0.628 0.180 0 0.000 0.816 0.000 0.004
#> GSM39846 3 0.0000 0.760 0.000 0 1.000 0.000 0.000 0.000
#> GSM39847 4 0.4408 0.401 0.320 0 0.000 0.636 0.000 0.044
#> GSM39848 5 0.0000 0.739 0.000 0 0.000 0.000 1.000 0.000
#> GSM39849 3 0.3211 0.703 0.000 0 0.824 0.000 0.120 0.056
#> GSM39850 4 0.1267 0.753 0.000 0 0.000 0.940 0.000 0.060
#> GSM39851 1 0.0000 0.777 1.000 0 0.000 0.000 0.000 0.000
#> GSM39855 5 0.4758 0.270 0.000 0 0.360 0.000 0.580 0.060
#> GSM39856 3 0.3032 0.714 0.000 0 0.840 0.000 0.104 0.056
#> GSM39858 3 0.2793 0.651 0.000 0 0.800 0.000 0.000 0.200
#> GSM39859 3 0.2092 0.718 0.000 0 0.876 0.000 0.000 0.124
#> GSM39862 5 0.2730 0.587 0.000 0 0.000 0.192 0.808 0.000
#> GSM39863 1 0.0000 0.777 1.000 0 0.000 0.000 0.000 0.000
#> GSM39865 5 0.0363 0.740 0.000 0 0.000 0.012 0.988 0.000
#> GSM39866 1 0.0458 0.773 0.984 0 0.000 0.000 0.000 0.016
#> GSM39867 4 0.1387 0.753 0.000 0 0.000 0.932 0.000 0.068
#> GSM39869 5 0.0260 0.740 0.000 0 0.000 0.008 0.992 0.000
#> GSM39870 1 0.4093 0.268 0.516 0 0.008 0.000 0.000 0.476
#> GSM39871 3 0.0547 0.760 0.000 0 0.980 0.000 0.000 0.020
#> GSM39872 3 0.4435 0.529 0.000 0 0.672 0.000 0.264 0.064
#> GSM39828 4 0.3580 0.688 0.000 0 0.036 0.808 0.136 0.020
#> GSM39829 1 0.3756 0.417 0.600 0 0.000 0.000 0.000 0.400
#> GSM39830 6 0.5807 -0.133 0.324 0 0.000 0.200 0.000 0.476
#> GSM39832 1 0.0000 0.777 1.000 0 0.000 0.000 0.000 0.000
#> GSM39833 4 0.5414 0.274 0.000 0 0.000 0.468 0.416 0.116
#> GSM39834 4 0.0260 0.748 0.000 0 0.000 0.992 0.000 0.008
#> GSM39835 4 0.5011 0.260 0.000 0 0.000 0.508 0.420 0.072
#> GSM39836 4 0.3168 0.722 0.000 0 0.000 0.792 0.016 0.192
#> GSM39837 5 0.6129 -0.272 0.000 0 0.000 0.320 0.340 0.340
#> GSM39838 4 0.4099 0.680 0.000 0 0.000 0.708 0.048 0.244
#> GSM39839 3 0.2912 0.633 0.000 0 0.784 0.000 0.000 0.216
#> GSM39840 1 0.3679 0.597 0.760 0 0.000 0.200 0.000 0.040
#> GSM39841 1 0.0000 0.777 1.000 0 0.000 0.000 0.000 0.000
#> GSM39842 1 0.4233 0.558 0.720 0 0.000 0.216 0.004 0.060
#> GSM39843 6 0.3866 0.134 0.000 0 0.484 0.000 0.000 0.516
#> GSM39844 1 0.0000 0.777 1.000 0 0.000 0.000 0.000 0.000
#> GSM39845 6 0.5866 0.417 0.024 0 0.204 0.196 0.000 0.576
#> GSM39852 4 0.0790 0.742 0.000 0 0.000 0.968 0.000 0.032
#> GSM39853 6 0.6129 -0.426 0.000 0 0.000 0.320 0.340 0.340
#> GSM39854 4 0.5608 0.517 0.000 0 0.000 0.540 0.200 0.260
#> GSM39857 3 0.3123 0.709 0.000 0 0.832 0.000 0.112 0.056
#> GSM39860 5 0.0000 0.739 0.000 0 0.000 0.000 1.000 0.000
#> GSM39861 6 0.5629 0.372 0.012 0 0.292 0.136 0.000 0.560
#> GSM39864 1 0.5992 0.402 0.580 0 0.092 0.072 0.000 0.256
#> GSM39868 4 0.0865 0.742 0.000 0 0.000 0.964 0.000 0.036
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> ATC:mclust 52 3.17e-05 2.25e-05 2
#> ATC:mclust 46 1.03e-10 2.18e-08 3
#> ATC:mclust 51 4.89e-11 5.94e-10 4
#> ATC:mclust 41 2.69e-08 8.43e-07 5
#> ATC:mclust 42 1.67e-08 3.70e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 7957 rows and 58 columns.
#> Top rows (796, 1592, 2387, 3182, 3978) 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)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.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:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).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)
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.966 0.962 0.983 0.3908 0.610 0.610
#> 3 3 0.657 0.761 0.895 0.5387 0.745 0.596
#> 4 4 0.661 0.789 0.888 0.1425 0.815 0.591
#> 5 5 0.606 0.587 0.792 0.1030 0.871 0.626
#> 6 6 0.571 0.437 0.698 0.0563 0.892 0.600
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM39873 2 0.0000 0.967 0.000 1.000
#> GSM39874 2 0.0000 0.967 0.000 1.000
#> GSM39875 2 0.0000 0.967 0.000 1.000
#> GSM39876 2 0.0000 0.967 0.000 1.000
#> GSM39831 1 0.0000 0.987 1.000 0.000
#> GSM39819 1 0.0000 0.987 1.000 0.000
#> GSM39820 1 0.0000 0.987 1.000 0.000
#> GSM39821 1 0.0000 0.987 1.000 0.000
#> GSM39822 2 0.0000 0.967 0.000 1.000
#> GSM39823 1 0.0000 0.987 1.000 0.000
#> GSM39824 2 0.0000 0.967 0.000 1.000
#> GSM39825 1 0.0000 0.987 1.000 0.000
#> GSM39826 1 0.0000 0.987 1.000 0.000
#> GSM39827 1 0.0000 0.987 1.000 0.000
#> GSM39846 1 0.3584 0.926 0.932 0.068
#> GSM39847 1 0.0000 0.987 1.000 0.000
#> GSM39848 2 0.0000 0.967 0.000 1.000
#> GSM39849 1 0.8081 0.671 0.752 0.248
#> GSM39850 1 0.0000 0.987 1.000 0.000
#> GSM39851 1 0.0000 0.987 1.000 0.000
#> GSM39855 2 0.0000 0.967 0.000 1.000
#> GSM39856 1 0.0000 0.987 1.000 0.000
#> GSM39858 1 0.0000 0.987 1.000 0.000
#> GSM39859 1 0.0000 0.987 1.000 0.000
#> GSM39862 2 0.0376 0.964 0.004 0.996
#> GSM39863 1 0.0000 0.987 1.000 0.000
#> GSM39865 2 0.0000 0.967 0.000 1.000
#> GSM39866 1 0.0000 0.987 1.000 0.000
#> GSM39867 1 0.0000 0.987 1.000 0.000
#> GSM39869 2 0.0000 0.967 0.000 1.000
#> GSM39870 1 0.0000 0.987 1.000 0.000
#> GSM39871 1 0.0000 0.987 1.000 0.000
#> GSM39872 1 0.0000 0.987 1.000 0.000
#> GSM39828 1 0.0000 0.987 1.000 0.000
#> GSM39829 1 0.0000 0.987 1.000 0.000
#> GSM39830 1 0.0000 0.987 1.000 0.000
#> GSM39832 1 0.0000 0.987 1.000 0.000
#> GSM39833 1 0.3431 0.930 0.936 0.064
#> GSM39834 1 0.0000 0.987 1.000 0.000
#> GSM39835 2 0.0672 0.962 0.008 0.992
#> GSM39836 1 0.0000 0.987 1.000 0.000
#> GSM39837 2 0.5294 0.853 0.120 0.880
#> GSM39838 2 0.9044 0.529 0.320 0.680
#> GSM39839 1 0.0000 0.987 1.000 0.000
#> GSM39840 1 0.0000 0.987 1.000 0.000
#> GSM39841 1 0.0000 0.987 1.000 0.000
#> GSM39842 1 0.0000 0.987 1.000 0.000
#> GSM39843 1 0.0000 0.987 1.000 0.000
#> GSM39844 1 0.0000 0.987 1.000 0.000
#> GSM39845 1 0.0000 0.987 1.000 0.000
#> GSM39852 1 0.0000 0.987 1.000 0.000
#> GSM39853 1 0.2948 0.942 0.948 0.052
#> GSM39854 1 0.4690 0.891 0.900 0.100
#> GSM39857 1 0.0938 0.977 0.988 0.012
#> GSM39860 2 0.0000 0.967 0.000 1.000
#> GSM39861 1 0.0000 0.987 1.000 0.000
#> GSM39864 1 0.0000 0.987 1.000 0.000
#> GSM39868 1 0.0000 0.987 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM39873 2 0.0000 0.8734 0.000 1.000 0.000
#> GSM39874 2 0.0000 0.8734 0.000 1.000 0.000
#> GSM39875 2 0.0000 0.8734 0.000 1.000 0.000
#> GSM39876 2 0.0000 0.8734 0.000 1.000 0.000
#> GSM39831 1 0.0424 0.8957 0.992 0.000 0.008
#> GSM39819 1 0.2537 0.8481 0.920 0.000 0.080
#> GSM39820 1 0.1163 0.8904 0.972 0.000 0.028
#> GSM39821 1 0.0000 0.8952 1.000 0.000 0.000
#> GSM39822 2 0.0000 0.8734 0.000 1.000 0.000
#> GSM39823 3 0.3551 0.7985 0.132 0.000 0.868
#> GSM39824 3 0.1529 0.7493 0.000 0.040 0.960
#> GSM39825 3 0.5882 0.5481 0.348 0.000 0.652
#> GSM39826 1 0.2945 0.8212 0.908 0.088 0.004
#> GSM39827 1 0.0000 0.8952 1.000 0.000 0.000
#> GSM39846 3 0.2448 0.8083 0.076 0.000 0.924
#> GSM39847 1 0.0747 0.8947 0.984 0.000 0.016
#> GSM39848 2 0.4654 0.7724 0.000 0.792 0.208
#> GSM39849 3 0.0424 0.7783 0.008 0.000 0.992
#> GSM39850 1 0.0237 0.8936 0.996 0.000 0.004
#> GSM39851 1 0.0424 0.8954 0.992 0.000 0.008
#> GSM39855 3 0.2878 0.7015 0.000 0.096 0.904
#> GSM39856 3 0.1643 0.8050 0.044 0.000 0.956
#> GSM39858 3 0.5591 0.6287 0.304 0.000 0.696
#> GSM39859 3 0.4291 0.7721 0.180 0.000 0.820
#> GSM39862 3 0.2959 0.6998 0.000 0.100 0.900
#> GSM39863 1 0.0424 0.8957 0.992 0.000 0.008
#> GSM39865 2 0.3879 0.8159 0.000 0.848 0.152
#> GSM39866 1 0.0424 0.8957 0.992 0.000 0.008
#> GSM39867 1 0.0475 0.8924 0.992 0.004 0.004
#> GSM39869 2 0.0747 0.8713 0.000 0.984 0.016
#> GSM39870 1 0.1753 0.8769 0.952 0.000 0.048
#> GSM39871 3 0.3752 0.7939 0.144 0.000 0.856
#> GSM39872 3 0.1753 0.8062 0.048 0.000 0.952
#> GSM39828 1 0.1411 0.8872 0.964 0.000 0.036
#> GSM39829 1 0.1163 0.8906 0.972 0.000 0.028
#> GSM39830 1 0.1163 0.8904 0.972 0.000 0.028
#> GSM39832 1 0.0424 0.8954 0.992 0.000 0.008
#> GSM39833 1 0.3832 0.8196 0.880 0.100 0.020
#> GSM39834 1 0.0000 0.8952 1.000 0.000 0.000
#> GSM39835 2 0.3112 0.8480 0.004 0.900 0.096
#> GSM39836 1 0.0829 0.8935 0.984 0.004 0.012
#> GSM39837 2 0.4409 0.7241 0.172 0.824 0.004
#> GSM39838 2 0.6155 0.4863 0.328 0.664 0.008
#> GSM39839 1 0.6204 0.1252 0.576 0.000 0.424
#> GSM39840 1 0.0424 0.8957 0.992 0.000 0.008
#> GSM39841 1 0.0424 0.8920 0.992 0.000 0.008
#> GSM39842 1 0.1529 0.8842 0.960 0.000 0.040
#> GSM39843 1 0.6215 0.1123 0.572 0.000 0.428
#> GSM39844 1 0.0000 0.8952 1.000 0.000 0.000
#> GSM39845 1 0.6267 0.0118 0.548 0.000 0.452
#> GSM39852 1 0.0237 0.8957 0.996 0.000 0.004
#> GSM39853 1 0.6565 0.2318 0.576 0.416 0.008
#> GSM39854 1 0.6398 0.3480 0.620 0.372 0.008
#> GSM39857 3 0.1411 0.8008 0.036 0.000 0.964
#> GSM39860 2 0.5397 0.6859 0.000 0.720 0.280
#> GSM39861 3 0.6307 0.1546 0.488 0.000 0.512
#> GSM39864 1 0.1411 0.8870 0.964 0.000 0.036
#> GSM39868 1 0.0747 0.8947 0.984 0.000 0.016
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM39873 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM39874 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM39875 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM39876 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM39831 1 0.1798 0.885 0.944 0.000 0.040 0.016
#> GSM39819 3 0.3634 0.804 0.048 0.000 0.856 0.096
#> GSM39820 1 0.5792 0.299 0.552 0.000 0.416 0.032
#> GSM39821 1 0.0188 0.890 0.996 0.000 0.000 0.004
#> GSM39822 2 0.0336 0.953 0.000 0.992 0.000 0.008
#> GSM39823 3 0.2053 0.852 0.004 0.000 0.924 0.072
#> GSM39824 4 0.5097 0.142 0.000 0.004 0.428 0.568
#> GSM39825 3 0.1004 0.861 0.004 0.000 0.972 0.024
#> GSM39826 1 0.0188 0.890 0.996 0.000 0.000 0.004
#> GSM39827 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> GSM39846 3 0.0921 0.863 0.000 0.000 0.972 0.028
#> GSM39847 1 0.0895 0.892 0.976 0.000 0.020 0.004
#> GSM39848 4 0.2814 0.740 0.000 0.132 0.000 0.868
#> GSM39849 3 0.2216 0.836 0.000 0.000 0.908 0.092
#> GSM39850 1 0.0188 0.890 0.996 0.000 0.000 0.004
#> GSM39851 1 0.1284 0.889 0.964 0.000 0.024 0.012
#> GSM39855 4 0.3401 0.700 0.000 0.008 0.152 0.840
#> GSM39856 3 0.1211 0.858 0.000 0.000 0.960 0.040
#> GSM39858 3 0.1118 0.857 0.000 0.000 0.964 0.036
#> GSM39859 3 0.1302 0.860 0.000 0.000 0.956 0.044
#> GSM39862 4 0.2943 0.737 0.000 0.032 0.076 0.892
#> GSM39863 1 0.2542 0.864 0.904 0.000 0.084 0.012
#> GSM39865 4 0.4155 0.674 0.000 0.240 0.004 0.756
#> GSM39866 1 0.0524 0.892 0.988 0.000 0.008 0.004
#> GSM39867 1 0.0000 0.891 1.000 0.000 0.000 0.000
#> GSM39869 4 0.4661 0.534 0.000 0.348 0.000 0.652
#> GSM39870 1 0.5682 0.178 0.520 0.000 0.456 0.024
#> GSM39871 3 0.0336 0.863 0.000 0.000 0.992 0.008
#> GSM39872 3 0.4661 0.472 0.000 0.000 0.652 0.348
#> GSM39828 1 0.1059 0.891 0.972 0.000 0.012 0.016
#> GSM39829 1 0.5882 0.474 0.608 0.000 0.344 0.048
#> GSM39830 1 0.4290 0.740 0.772 0.000 0.212 0.016
#> GSM39832 1 0.1520 0.889 0.956 0.000 0.024 0.020
#> GSM39833 1 0.5212 0.791 0.792 0.036 0.104 0.068
#> GSM39834 1 0.0817 0.885 0.976 0.000 0.000 0.024
#> GSM39835 4 0.6388 0.545 0.192 0.156 0.000 0.652
#> GSM39836 1 0.3123 0.784 0.844 0.000 0.000 0.156
#> GSM39837 2 0.0188 0.955 0.004 0.996 0.000 0.000
#> GSM39838 1 0.3591 0.763 0.824 0.008 0.000 0.168
#> GSM39839 3 0.2011 0.839 0.000 0.000 0.920 0.080
#> GSM39840 1 0.0376 0.892 0.992 0.000 0.004 0.004
#> GSM39841 1 0.2089 0.882 0.932 0.000 0.048 0.020
#> GSM39842 1 0.3205 0.846 0.872 0.000 0.104 0.024
#> GSM39843 3 0.2976 0.789 0.120 0.000 0.872 0.008
#> GSM39844 1 0.0672 0.892 0.984 0.000 0.008 0.008
#> GSM39845 3 0.4343 0.585 0.264 0.000 0.732 0.004
#> GSM39852 1 0.0188 0.890 0.996 0.000 0.000 0.004
#> GSM39853 2 0.3219 0.764 0.112 0.868 0.000 0.020
#> GSM39854 1 0.3105 0.797 0.856 0.140 0.000 0.004
#> GSM39857 3 0.3356 0.768 0.000 0.000 0.824 0.176
#> GSM39860 4 0.3166 0.746 0.000 0.116 0.016 0.868
#> GSM39861 3 0.2944 0.776 0.128 0.000 0.868 0.004
#> GSM39864 1 0.1576 0.886 0.948 0.000 0.048 0.004
#> GSM39868 1 0.0336 0.890 0.992 0.000 0.000 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM39873 2 0.0451 0.8648 0.000 0.988 0.004 0.000 0.008
#> GSM39874 2 0.0451 0.8648 0.000 0.988 0.004 0.000 0.008
#> GSM39875 2 0.0451 0.8648 0.000 0.988 0.004 0.000 0.008
#> GSM39876 2 0.0451 0.8648 0.000 0.988 0.004 0.000 0.008
#> GSM39831 4 0.4517 0.4540 0.388 0.000 0.012 0.600 0.000
#> GSM39819 3 0.6409 0.4071 0.304 0.004 0.576 0.064 0.052
#> GSM39820 4 0.5370 0.5955 0.048 0.004 0.184 0.716 0.048
#> GSM39821 4 0.1082 0.7711 0.028 0.000 0.000 0.964 0.008
#> GSM39822 2 0.0609 0.8573 0.000 0.980 0.000 0.000 0.020
#> GSM39823 3 0.2721 0.7344 0.012 0.000 0.892 0.028 0.068
#> GSM39824 3 0.4283 0.3662 0.008 0.000 0.644 0.000 0.348
#> GSM39825 3 0.3636 0.6256 0.272 0.000 0.728 0.000 0.000
#> GSM39826 4 0.1281 0.7706 0.032 0.000 0.000 0.956 0.012
#> GSM39827 4 0.3209 0.7133 0.180 0.000 0.008 0.812 0.000
#> GSM39846 3 0.0833 0.7513 0.004 0.004 0.976 0.000 0.016
#> GSM39847 4 0.1883 0.7735 0.048 0.000 0.012 0.932 0.008
#> GSM39848 5 0.2230 0.7448 0.000 0.116 0.000 0.000 0.884
#> GSM39849 1 0.6297 0.1025 0.532 0.000 0.256 0.000 0.212
#> GSM39850 4 0.1041 0.7720 0.032 0.000 0.000 0.964 0.004
#> GSM39851 1 0.4735 -0.2111 0.516 0.004 0.004 0.472 0.004
#> GSM39855 5 0.4367 0.2994 0.000 0.008 0.372 0.000 0.620
#> GSM39856 3 0.2561 0.7396 0.096 0.000 0.884 0.000 0.020
#> GSM39858 3 0.1365 0.7551 0.040 0.000 0.952 0.004 0.004
#> GSM39859 3 0.0981 0.7534 0.008 0.000 0.972 0.012 0.008
#> GSM39862 5 0.2353 0.6924 0.028 0.008 0.044 0.004 0.916
#> GSM39863 4 0.4314 0.6245 0.280 0.004 0.016 0.700 0.000
#> GSM39865 5 0.5674 0.5387 0.008 0.332 0.008 0.056 0.596
#> GSM39866 4 0.1153 0.7602 0.024 0.000 0.008 0.964 0.004
#> GSM39867 4 0.2642 0.7585 0.104 0.008 0.008 0.880 0.000
#> GSM39869 5 0.4934 0.4778 0.036 0.364 0.000 0.000 0.600
#> GSM39870 4 0.3908 0.6854 0.032 0.004 0.108 0.828 0.028
#> GSM39871 3 0.0865 0.7571 0.024 0.000 0.972 0.004 0.000
#> GSM39872 3 0.5650 0.0470 0.076 0.000 0.464 0.000 0.460
#> GSM39828 1 0.6515 0.1388 0.440 0.000 0.000 0.364 0.196
#> GSM39829 4 0.5999 0.5611 0.116 0.004 0.184 0.664 0.032
#> GSM39830 1 0.5583 0.1977 0.572 0.000 0.072 0.352 0.004
#> GSM39832 4 0.4805 0.3371 0.432 0.004 0.004 0.552 0.008
#> GSM39833 1 0.3795 0.4876 0.844 0.024 0.008 0.044 0.080
#> GSM39834 4 0.1918 0.7609 0.036 0.000 0.000 0.928 0.036
#> GSM39835 1 0.4891 0.1231 0.640 0.044 0.000 0.000 0.316
#> GSM39836 4 0.2358 0.6949 0.008 0.000 0.000 0.888 0.104
#> GSM39837 2 0.0566 0.8543 0.012 0.984 0.000 0.000 0.004
#> GSM39838 4 0.2845 0.6874 0.020 0.008 0.000 0.876 0.096
#> GSM39839 3 0.3828 0.6838 0.184 0.000 0.788 0.008 0.020
#> GSM39840 4 0.3752 0.6130 0.292 0.000 0.000 0.708 0.000
#> GSM39841 4 0.4541 0.4627 0.380 0.004 0.008 0.608 0.000
#> GSM39842 1 0.1483 0.5007 0.952 0.000 0.012 0.028 0.008
#> GSM39843 1 0.4517 0.0882 0.600 0.000 0.388 0.012 0.000
#> GSM39844 4 0.4286 0.5415 0.340 0.004 0.004 0.652 0.000
#> GSM39845 3 0.5364 0.3902 0.072 0.000 0.648 0.272 0.008
#> GSM39852 4 0.0854 0.7592 0.012 0.000 0.004 0.976 0.008
#> GSM39853 2 0.2067 0.7929 0.028 0.924 0.000 0.044 0.004
#> GSM39854 2 0.5191 0.2000 0.036 0.552 0.000 0.408 0.004
#> GSM39857 3 0.3154 0.6814 0.012 0.000 0.836 0.004 0.148
#> GSM39860 5 0.2522 0.7457 0.000 0.108 0.012 0.000 0.880
#> GSM39861 3 0.3863 0.6348 0.052 0.000 0.796 0.152 0.000
#> GSM39864 4 0.2351 0.7648 0.088 0.000 0.016 0.896 0.000
#> GSM39868 4 0.1200 0.7549 0.012 0.000 0.008 0.964 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM39873 2 0.0146 0.84918 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM39874 2 0.0146 0.84979 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM39875 2 0.0146 0.84979 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM39876 2 0.0000 0.84936 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM39831 1 0.5773 -0.23523 0.452 0.000 0.000 0.392 0.004 0.152
#> GSM39819 3 0.7737 -0.04550 0.168 0.004 0.352 0.344 0.024 0.108
#> GSM39820 1 0.5466 0.44927 0.704 0.000 0.120 0.100 0.032 0.044
#> GSM39821 1 0.5258 0.09182 0.524 0.000 0.000 0.384 0.004 0.088
#> GSM39822 2 0.2255 0.81553 0.000 0.908 0.000 0.044 0.024 0.024
#> GSM39823 3 0.4335 0.59561 0.112 0.000 0.784 0.016 0.040 0.048
#> GSM39824 3 0.4002 0.46775 0.000 0.008 0.748 0.016 0.212 0.016
#> GSM39825 3 0.4719 0.52356 0.000 0.000 0.644 0.272 0.000 0.084
#> GSM39826 1 0.4602 0.44970 0.704 0.000 0.000 0.196 0.008 0.092
#> GSM39827 4 0.4886 0.47968 0.300 0.000 0.000 0.620 0.004 0.076
#> GSM39846 3 0.3156 0.64908 0.004 0.004 0.860 0.028 0.024 0.080
#> GSM39847 4 0.6196 0.38286 0.308 0.000 0.036 0.536 0.012 0.108
#> GSM39848 5 0.2265 0.55291 0.000 0.068 0.000 0.024 0.900 0.008
#> GSM39849 6 0.6325 0.44770 0.000 0.000 0.172 0.160 0.092 0.576
#> GSM39850 1 0.4820 0.37207 0.652 0.000 0.000 0.256 0.004 0.088
#> GSM39851 4 0.4527 0.58984 0.256 0.000 0.000 0.680 0.008 0.056
#> GSM39855 5 0.4370 0.16300 0.000 0.012 0.428 0.008 0.552 0.000
#> GSM39856 3 0.3785 0.63393 0.000 0.000 0.788 0.088 0.004 0.120
#> GSM39858 3 0.1483 0.68818 0.008 0.000 0.944 0.036 0.000 0.012
#> GSM39859 3 0.1167 0.68078 0.020 0.000 0.960 0.012 0.000 0.008
#> GSM39862 5 0.3489 0.49892 0.008 0.008 0.012 0.060 0.844 0.068
#> GSM39863 4 0.4663 0.26906 0.472 0.000 0.004 0.492 0.000 0.032
#> GSM39865 2 0.7925 -0.00419 0.092 0.428 0.024 0.116 0.296 0.044
#> GSM39866 1 0.1714 0.53936 0.936 0.000 0.024 0.024 0.000 0.016
#> GSM39867 1 0.5387 0.32360 0.612 0.048 0.000 0.292 0.004 0.044
#> GSM39869 5 0.6095 0.06354 0.000 0.376 0.000 0.124 0.468 0.032
#> GSM39870 1 0.4267 0.49290 0.772 0.000 0.140 0.056 0.008 0.024
#> GSM39871 3 0.1590 0.68832 0.008 0.000 0.936 0.048 0.000 0.008
#> GSM39872 5 0.6525 -0.04227 0.004 0.000 0.308 0.012 0.364 0.312
#> GSM39828 4 0.5733 0.51967 0.164 0.000 0.004 0.652 0.072 0.108
#> GSM39829 1 0.6584 0.21804 0.560 0.000 0.152 0.208 0.016 0.064
#> GSM39830 4 0.5667 0.50044 0.248 0.000 0.020 0.588 0.000 0.144
#> GSM39832 1 0.5901 -0.23452 0.436 0.000 0.000 0.384 0.004 0.176
#> GSM39833 4 0.4264 0.21731 0.004 0.024 0.028 0.768 0.012 0.164
#> GSM39834 1 0.2736 0.52450 0.876 0.000 0.000 0.020 0.028 0.076
#> GSM39835 6 0.5645 0.54158 0.004 0.008 0.000 0.212 0.184 0.592
#> GSM39836 1 0.5962 0.38880 0.624 0.000 0.000 0.160 0.108 0.108
#> GSM39837 2 0.3481 0.69232 0.000 0.776 0.000 0.192 0.000 0.032
#> GSM39838 1 0.5558 0.38621 0.652 0.000 0.000 0.176 0.056 0.116
#> GSM39839 3 0.5260 0.52365 0.012 0.000 0.628 0.260 0.004 0.096
#> GSM39840 4 0.4511 0.53038 0.332 0.000 0.000 0.620 0.000 0.048
#> GSM39841 4 0.4247 0.57749 0.268 0.004 0.000 0.688 0.000 0.040
#> GSM39842 6 0.4151 0.59381 0.040 0.000 0.000 0.276 0.000 0.684
#> GSM39843 4 0.4853 0.18513 0.004 0.000 0.224 0.664 0.000 0.108
#> GSM39844 1 0.5034 -0.32782 0.468 0.000 0.000 0.460 0.000 0.072
#> GSM39845 3 0.5165 0.43452 0.284 0.000 0.632 0.032 0.004 0.048
#> GSM39852 1 0.2796 0.52149 0.868 0.000 0.000 0.080 0.008 0.044
#> GSM39853 2 0.1524 0.82266 0.000 0.932 0.000 0.060 0.000 0.008
#> GSM39854 1 0.6507 0.07783 0.424 0.388 0.000 0.044 0.004 0.140
#> GSM39857 3 0.3501 0.62294 0.012 0.000 0.832 0.036 0.104 0.016
#> GSM39860 5 0.1901 0.55277 0.000 0.076 0.004 0.000 0.912 0.008
#> GSM39861 3 0.4775 0.49159 0.060 0.000 0.636 0.296 0.000 0.008
#> GSM39864 1 0.2933 0.48817 0.844 0.000 0.012 0.128 0.000 0.016
#> GSM39868 1 0.0984 0.54080 0.968 0.000 0.012 0.000 0.008 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)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
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)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
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:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.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")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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) other(p) k
#> ATC:NMF 58 3.53e-03 4.44e-03 2
#> ATC:NMF 51 3.74e-04 3.30e-04 3
#> ATC:NMF 53 2.95e-06 9.37e-05 4
#> ATC:NMF 41 2.49e-04 1.65e-03 5
#> ATC:NMF 29 1.23e-02 9.43e-03 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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