Date: 2019-12-25 22:21:48 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 21288 rows and 52 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] 21288 52
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 | ||
---|---|---|---|---|---|---|
SD:kmeans | 3 | 1.000 | 0.993 | 0.984 | ** | |
SD:pam | 3 | 1.000 | 0.986 | 0.994 | ** | 2 |
CV:kmeans | 3 | 1.000 | 0.979 | 0.969 | ** | |
CV:pam | 2 | 1.000 | 0.966 | 0.988 | ** | |
MAD:kmeans | 3 | 1.000 | 0.971 | 0.975 | ** | |
MAD:pam | 3 | 1.000 | 0.965 | 0.986 | ** | 2 |
MAD:NMF | 3 | 1.000 | 0.970 | 0.988 | ** | 2 |
ATC:kmeans | 3 | 1.000 | 0.981 | 0.993 | ** | |
ATC:pam | 3 | 1.000 | 0.959 | 0.987 | ** | 2 |
ATC:NMF | 3 | 1.000 | 0.947 | 0.982 | ** | 2 |
SD:mclust | 3 | 0.999 | 0.964 | 0.979 | ** | |
SD:hclust | 3 | 0.939 | 0.908 | 0.967 | * | |
SD:skmeans | 5 | 0.935 | 0.916 | 0.959 | * | 3 |
ATC:hclust | 6 | 0.926 | 0.877 | 0.938 | * | 2,3,4 |
MAD:skmeans | 5 | 0.922 | 0.860 | 0.938 | * | 3 |
ATC:skmeans | 3 | 0.912 | 0.923 | 0.967 | * | 2 |
CV:NMF | 6 | 0.906 | 0.854 | 0.915 | * | 2,3,5 |
SD:NMF | 5 | 0.905 | 0.863 | 0.937 | * | 2,3 |
CV:skmeans | 6 | 0.905 | 0.799 | 0.894 | * | 2,3,5 |
CV:mclust | 3 | 0.891 | 0.882 | 0.949 | ||
MAD:hclust | 3 | 0.887 | 0.952 | 0.979 | ||
MAD:mclust | 3 | 0.747 | 0.857 | 0.935 | ||
ATC:mclust | 3 | 0.743 | 0.819 | 0.916 | ||
CV:hclust | 3 | 0.650 | 0.875 | 0.917 |
**: 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 1.000 0.966 0.986 0.386 0.618 0.618
#> CV:NMF 2 1.000 0.951 0.983 0.382 0.618 0.618
#> MAD:NMF 2 1.000 0.980 0.991 0.395 0.599 0.599
#> ATC:NMF 2 0.919 0.924 0.968 0.441 0.566 0.566
#> SD:skmeans 2 0.753 0.811 0.916 0.441 0.517 0.517
#> CV:skmeans 2 0.964 0.970 0.985 0.410 0.599 0.599
#> MAD:skmeans 2 0.720 0.890 0.950 0.434 0.581 0.581
#> ATC:skmeans 2 1.000 0.933 0.974 0.439 0.581 0.581
#> SD:mclust 2 0.699 0.935 0.958 0.466 0.509 0.509
#> CV:mclust 2 0.699 0.743 0.879 0.426 0.509 0.509
#> MAD:mclust 2 0.656 0.758 0.897 0.422 0.638 0.638
#> ATC:mclust 2 0.629 0.840 0.926 0.419 0.618 0.618
#> SD:kmeans 2 0.509 0.806 0.828 0.339 0.638 0.638
#> CV:kmeans 2 0.393 0.825 0.834 0.355 0.638 0.638
#> MAD:kmeans 2 0.369 0.788 0.812 0.364 0.638 0.638
#> ATC:kmeans 2 0.514 0.747 0.798 0.331 0.660 0.660
#> SD:pam 2 1.000 0.988 0.994 0.383 0.618 0.618
#> CV:pam 2 1.000 0.966 0.988 0.375 0.638 0.638
#> MAD:pam 2 1.000 0.995 0.998 0.385 0.618 0.618
#> ATC:pam 2 1.000 0.979 0.992 0.331 0.660 0.660
#> SD:hclust 2 0.485 0.720 0.805 0.320 0.660 0.660
#> CV:hclust 2 0.494 0.911 0.903 0.351 0.638 0.638
#> MAD:hclust 2 0.591 0.945 0.949 0.347 0.660 0.660
#> ATC:hclust 2 1.000 0.997 0.997 0.293 0.708 0.708
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 1.000 0.997 0.998 0.487 0.765 0.633
#> CV:NMF 3 0.937 0.931 0.974 0.553 0.750 0.610
#> MAD:NMF 3 1.000 0.970 0.988 0.485 0.729 0.576
#> ATC:NMF 3 1.000 0.947 0.982 0.364 0.681 0.502
#> SD:skmeans 3 0.940 0.959 0.982 0.452 0.762 0.571
#> CV:skmeans 3 0.967 0.909 0.964 0.595 0.687 0.501
#> MAD:skmeans 3 0.969 0.912 0.966 0.508 0.703 0.512
#> ATC:skmeans 3 0.912 0.923 0.967 0.458 0.736 0.567
#> SD:mclust 3 0.999 0.964 0.979 0.258 0.919 0.840
#> CV:mclust 3 0.891 0.882 0.949 0.422 0.829 0.686
#> MAD:mclust 3 0.747 0.857 0.935 0.443 0.759 0.623
#> ATC:mclust 3 0.743 0.819 0.916 0.425 0.750 0.601
#> SD:kmeans 3 1.000 0.993 0.984 0.662 0.790 0.670
#> CV:kmeans 3 1.000 0.979 0.969 0.608 0.790 0.670
#> MAD:kmeans 3 1.000 0.971 0.975 0.525 0.790 0.670
#> ATC:kmeans 3 1.000 0.981 0.993 0.625 0.738 0.621
#> SD:pam 3 1.000 0.986 0.994 0.454 0.817 0.706
#> CV:pam 3 0.881 0.941 0.976 0.543 0.790 0.670
#> MAD:pam 3 1.000 0.965 0.986 0.484 0.798 0.676
#> ATC:pam 3 1.000 0.959 0.987 0.591 0.801 0.698
#> SD:hclust 3 0.939 0.908 0.967 0.717 0.783 0.671
#> CV:hclust 3 0.650 0.875 0.917 0.585 0.826 0.727
#> MAD:hclust 3 0.887 0.952 0.979 0.554 0.821 0.728
#> ATC:hclust 3 0.908 0.962 0.983 0.903 0.719 0.604
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.751 0.801 0.871 0.2560 0.861 0.675
#> CV:NMF 4 0.755 0.762 0.867 0.2333 0.854 0.652
#> MAD:NMF 4 0.723 0.780 0.884 0.2428 0.880 0.712
#> ATC:NMF 4 0.713 0.763 0.876 0.1524 0.905 0.767
#> SD:skmeans 4 0.781 0.761 0.880 0.1711 0.848 0.596
#> CV:skmeans 4 0.753 0.643 0.846 0.1527 0.834 0.557
#> MAD:skmeans 4 0.783 0.785 0.901 0.1587 0.845 0.576
#> ATC:skmeans 4 0.807 0.778 0.904 0.1717 0.833 0.571
#> SD:mclust 4 0.736 0.807 0.887 0.2251 0.873 0.704
#> CV:mclust 4 0.740 0.781 0.855 0.2018 0.854 0.661
#> MAD:mclust 4 0.771 0.806 0.894 0.1628 0.848 0.647
#> ATC:mclust 4 0.575 0.653 0.824 0.1702 0.880 0.721
#> SD:kmeans 4 0.728 0.677 0.844 0.2345 0.919 0.810
#> CV:kmeans 4 0.731 0.755 0.828 0.2373 0.873 0.704
#> MAD:kmeans 4 0.696 0.561 0.802 0.2567 0.902 0.771
#> ATC:kmeans 4 0.684 0.704 0.861 0.2173 0.953 0.899
#> SD:pam 4 0.683 0.724 0.875 0.2297 0.898 0.771
#> CV:pam 4 0.659 0.575 0.781 0.2331 0.834 0.612
#> MAD:pam 4 0.744 0.803 0.892 0.2448 0.839 0.633
#> ATC:pam 4 0.665 0.692 0.815 0.2014 0.940 0.873
#> SD:hclust 4 0.751 0.781 0.877 0.1521 0.989 0.976
#> CV:hclust 4 0.651 0.731 0.858 0.2695 0.810 0.590
#> MAD:hclust 4 0.777 0.892 0.924 0.2761 0.857 0.703
#> ATC:hclust 4 0.956 0.930 0.973 0.0889 0.977 0.947
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.905 0.863 0.937 0.1058 0.881 0.611
#> CV:NMF 5 0.923 0.875 0.943 0.1004 0.896 0.639
#> MAD:NMF 5 0.820 0.804 0.898 0.0917 0.881 0.619
#> ATC:NMF 5 0.687 0.587 0.784 0.1124 0.876 0.640
#> SD:skmeans 5 0.935 0.916 0.959 0.0764 0.888 0.594
#> CV:skmeans 5 0.940 0.906 0.955 0.0755 0.904 0.634
#> MAD:skmeans 5 0.922 0.860 0.938 0.0653 0.916 0.674
#> ATC:skmeans 5 0.764 0.690 0.806 0.0592 0.889 0.593
#> SD:mclust 5 0.713 0.540 0.801 0.0596 0.983 0.942
#> CV:mclust 5 0.730 0.651 0.821 0.0827 0.878 0.601
#> MAD:mclust 5 0.685 0.741 0.822 0.0964 0.865 0.583
#> ATC:mclust 5 0.543 0.533 0.718 0.0548 0.860 0.649
#> SD:kmeans 5 0.711 0.838 0.823 0.0977 0.835 0.535
#> CV:kmeans 5 0.722 0.814 0.851 0.0990 0.910 0.702
#> MAD:kmeans 5 0.669 0.747 0.808 0.1037 0.830 0.514
#> ATC:kmeans 5 0.630 0.619 0.778 0.1189 0.851 0.651
#> SD:pam 5 0.741 0.621 0.845 0.1196 0.916 0.758
#> CV:pam 5 0.729 0.614 0.807 0.0847 0.842 0.514
#> MAD:pam 5 0.725 0.627 0.817 0.0846 0.913 0.714
#> ATC:pam 5 0.708 0.766 0.889 0.0812 0.894 0.756
#> SD:hclust 5 0.704 0.761 0.870 0.0928 0.919 0.816
#> CV:hclust 5 0.695 0.706 0.817 0.0794 0.907 0.674
#> MAD:hclust 5 0.717 0.611 0.821 0.0898 0.893 0.691
#> ATC:hclust 5 0.915 0.841 0.912 0.0223 0.986 0.966
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.876 0.770 0.888 0.0410 0.956 0.790
#> CV:NMF 6 0.906 0.854 0.915 0.0402 0.952 0.759
#> MAD:NMF 6 0.855 0.729 0.869 0.0450 0.943 0.741
#> ATC:NMF 6 0.721 0.644 0.794 0.0456 0.931 0.736
#> SD:skmeans 6 0.885 0.847 0.911 0.0372 0.953 0.765
#> CV:skmeans 6 0.905 0.799 0.894 0.0357 0.943 0.714
#> MAD:skmeans 6 0.859 0.767 0.866 0.0358 0.953 0.765
#> ATC:skmeans 6 0.782 0.557 0.773 0.0342 0.914 0.637
#> SD:mclust 6 0.740 0.502 0.736 0.0259 0.840 0.499
#> CV:mclust 6 0.698 0.525 0.711 0.0280 0.950 0.749
#> MAD:mclust 6 0.725 0.642 0.740 0.0430 0.934 0.720
#> ATC:mclust 6 0.604 0.509 0.721 0.0479 0.864 0.598
#> SD:kmeans 6 0.726 0.768 0.831 0.0659 1.000 1.000
#> CV:kmeans 6 0.814 0.771 0.811 0.0555 1.000 1.000
#> MAD:kmeans 6 0.746 0.669 0.812 0.0557 0.992 0.958
#> ATC:kmeans 6 0.665 0.640 0.782 0.0622 0.899 0.659
#> SD:pam 6 0.745 0.689 0.830 0.0611 0.885 0.590
#> CV:pam 6 0.821 0.768 0.890 0.0600 0.894 0.589
#> MAD:pam 6 0.787 0.789 0.828 0.0606 0.854 0.497
#> ATC:pam 6 0.727 0.722 0.876 0.0254 0.971 0.913
#> SD:hclust 6 0.834 0.792 0.894 0.1295 0.873 0.654
#> CV:hclust 6 0.784 0.797 0.836 0.0674 0.954 0.781
#> MAD:hclust 6 0.764 0.654 0.825 0.0655 0.902 0.637
#> ATC:hclust 6 0.926 0.877 0.938 0.0356 0.958 0.892
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 = 1000, method = "euler")
top_rows_overlap(res_list, top_n = 2000, method = "euler")
top_rows_overlap(res_list, top_n = 3000, method = "euler")
top_rows_overlap(res_list, top_n = 4000, method = "euler")
top_rows_overlap(res_list, top_n = 5000, method = "euler")
Also visualize the correspondance of rankings between different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "correspondance")
top_rows_overlap(res_list, top_n = 2000, method = "correspondance")
top_rows_overlap(res_list, top_n = 3000, method = "correspondance")
top_rows_overlap(res_list, top_n = 4000, method = "correspondance")
top_rows_overlap(res_list, top_n = 5000, method = "correspondance")
Heatmaps of the top rows:
top_rows_heatmap(res_list, top_n = 1000)
top_rows_heatmap(res_list, top_n = 2000)
top_rows_heatmap(res_list, top_n = 3000)
top_rows_heatmap(res_list, top_n = 4000)
top_rows_heatmap(res_list, top_n = 5000)
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 tissue(p) k
#> SD:NMF 51 0.395 2
#> CV:NMF 50 0.394 2
#> MAD:NMF 52 0.396 2
#> ATC:NMF 51 0.395 2
#> SD:skmeans 43 0.386 2
#> CV:skmeans 52 0.396 2
#> MAD:skmeans 52 0.396 2
#> ATC:skmeans 49 0.393 2
#> SD:mclust 52 0.396 2
#> CV:mclust 41 0.383 2
#> MAD:mclust 42 0.384 2
#> ATC:mclust 50 0.394 2
#> SD:kmeans 43 0.386 2
#> CV:kmeans 52 0.396 2
#> MAD:kmeans 52 0.396 2
#> ATC:kmeans 42 0.384 2
#> SD:pam 52 0.396 2
#> CV:pam 51 0.395 2
#> MAD:pam 52 0.396 2
#> ATC:pam 51 0.395 2
#> SD:hclust 42 0.384 2
#> CV:hclust 52 0.396 2
#> MAD:hclust 51 0.395 2
#> ATC:hclust 52 0.396 2
test_to_known_factors(res_list, k = 3)
#> n tissue(p) k
#> SD:NMF 52 0.372 3
#> CV:NMF 51 0.371 3
#> MAD:NMF 51 0.371 3
#> ATC:NMF 50 0.370 3
#> SD:skmeans 52 0.450 3
#> CV:skmeans 49 0.446 3
#> MAD:skmeans 49 0.446 3
#> ATC:skmeans 50 0.370 3
#> SD:mclust 52 0.372 3
#> CV:mclust 49 0.368 3
#> MAD:mclust 49 0.368 3
#> ATC:mclust 47 0.366 3
#> SD:kmeans 52 0.372 3
#> CV:kmeans 52 0.372 3
#> MAD:kmeans 51 0.371 3
#> ATC:kmeans 52 0.372 3
#> SD:pam 52 0.372 3
#> CV:pam 52 0.372 3
#> MAD:pam 51 0.371 3
#> ATC:pam 51 0.371 3
#> SD:hclust 49 0.368 3
#> CV:hclust 50 0.370 3
#> MAD:hclust 51 0.371 3
#> ATC:hclust 52 0.372 3
test_to_known_factors(res_list, k = 4)
#> n tissue(p) k
#> SD:NMF 50 0.454 4
#> CV:NMF 48 0.451 4
#> MAD:NMF 47 0.462 4
#> ATC:NMF 45 0.341 4
#> SD:skmeans 47 0.453 4
#> CV:skmeans 39 0.473 4
#> MAD:skmeans 46 0.412 4
#> ATC:skmeans 47 0.440 4
#> SD:mclust 46 0.447 4
#> CV:mclust 47 0.450 4
#> MAD:mclust 48 0.462 4
#> ATC:mclust 39 0.405 4
#> SD:kmeans 44 0.500 4
#> CV:kmeans 47 0.450 4
#> MAD:kmeans 23 0.389 4
#> ATC:kmeans 45 0.363 4
#> SD:pam 48 0.508 4
#> CV:pam 24 0.392 4
#> MAD:pam 48 0.448 4
#> ATC:pam 38 0.351 4
#> SD:hclust 44 0.410 4
#> CV:hclust 44 0.497 4
#> MAD:hclust 51 0.453 4
#> ATC:hclust 51 0.371 4
test_to_known_factors(res_list, k = 5)
#> n tissue(p) k
#> SD:NMF 48 0.425 5
#> CV:NMF 49 0.436 5
#> MAD:NMF 47 0.424 5
#> ATC:NMF 34 0.398 5
#> SD:skmeans 51 0.442 5
#> CV:skmeans 51 0.437 5
#> MAD:skmeans 48 0.449 5
#> ATC:skmeans 43 0.400 5
#> SD:mclust 35 0.456 5
#> CV:mclust 38 0.417 5
#> MAD:mclust 42 0.428 5
#> ATC:mclust 30 0.403 5
#> SD:kmeans 51 0.434 5
#> CV:kmeans 50 0.431 5
#> MAD:kmeans 44 0.451 5
#> ATC:kmeans 40 0.332 5
#> SD:pam 34 0.388 5
#> CV:pam 34 0.398 5
#> MAD:pam 41 0.488 5
#> ATC:pam 48 0.328 5
#> SD:hclust 46 0.498 5
#> CV:hclust 42 0.499 5
#> MAD:hclust 40 0.414 5
#> ATC:hclust 50 0.349 5
test_to_known_factors(res_list, k = 6)
#> n tissue(p) k
#> SD:NMF 43 0.425 6
#> CV:NMF 50 0.422 6
#> MAD:NMF 41 0.423 6
#> ATC:NMF 39 0.431 6
#> SD:skmeans 49 0.436 6
#> CV:skmeans 43 0.436 6
#> MAD:skmeans 43 0.441 6
#> ATC:skmeans 29 0.379 6
#> SD:mclust 28 0.388 6
#> CV:mclust 26 0.384 6
#> MAD:mclust 42 0.452 6
#> ATC:mclust 24 0.392 6
#> SD:kmeans 49 0.428 6
#> CV:kmeans 46 0.431 6
#> MAD:kmeans 41 0.501 6
#> ATC:kmeans 42 0.423 6
#> SD:pam 41 0.492 6
#> CV:pam 45 0.475 6
#> MAD:pam 47 0.484 6
#> ATC:pam 47 0.326 6
#> SD:hclust 47 0.471 6
#> CV:hclust 48 0.398 6
#> MAD:hclust 35 0.394 6
#> ATC:hclust 50 0.331 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.485 0.720 0.805 0.3205 0.660 0.660
#> 3 3 0.939 0.908 0.967 0.7169 0.783 0.671
#> 4 4 0.751 0.781 0.877 0.1521 0.989 0.976
#> 5 5 0.704 0.761 0.870 0.0928 0.919 0.816
#> 6 6 0.834 0.792 0.894 0.1295 0.873 0.654
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
#> GSM28788 1 0.0000 0.770 1.000 0.000
#> GSM28789 1 0.0000 0.770 1.000 0.000
#> GSM28790 1 0.0000 0.770 1.000 0.000
#> GSM11300 1 0.9522 0.434 0.628 0.372
#> GSM28798 2 1.0000 1.000 0.496 0.504
#> GSM11296 2 1.0000 1.000 0.496 0.504
#> GSM28801 2 1.0000 1.000 0.496 0.504
#> GSM11319 2 1.0000 1.000 0.496 0.504
#> GSM28781 2 1.0000 1.000 0.496 0.504
#> GSM11305 2 1.0000 1.000 0.496 0.504
#> GSM28784 2 1.0000 1.000 0.496 0.504
#> GSM11307 2 1.0000 1.000 0.496 0.504
#> GSM11313 2 1.0000 1.000 0.496 0.504
#> GSM28785 2 1.0000 1.000 0.496 0.504
#> GSM11318 1 0.0000 0.770 1.000 0.000
#> GSM28792 1 0.0000 0.770 1.000 0.000
#> GSM11295 1 0.9998 0.362 0.508 0.492
#> GSM28793 1 0.0000 0.770 1.000 0.000
#> GSM11312 1 0.0000 0.770 1.000 0.000
#> GSM28778 1 0.0000 0.770 1.000 0.000
#> GSM28796 1 0.0000 0.770 1.000 0.000
#> GSM11309 1 0.0376 0.767 0.996 0.004
#> GSM11315 1 0.0000 0.770 1.000 0.000
#> GSM11306 1 0.0000 0.770 1.000 0.000
#> GSM28776 1 0.0000 0.770 1.000 0.000
#> GSM28777 1 1.0000 0.360 0.504 0.496
#> GSM11316 1 1.0000 0.360 0.504 0.496
#> GSM11320 1 1.0000 0.360 0.504 0.496
#> GSM28797 1 0.0376 0.767 0.996 0.004
#> GSM28786 1 0.0376 0.767 0.996 0.004
#> GSM28800 1 0.0000 0.770 1.000 0.000
#> GSM11310 1 0.0000 0.770 1.000 0.000
#> GSM28787 1 0.9998 0.362 0.508 0.492
#> GSM11304 1 0.2236 0.737 0.964 0.036
#> GSM11303 1 1.0000 0.360 0.504 0.496
#> GSM11317 1 1.0000 0.360 0.504 0.496
#> GSM11311 1 0.0376 0.767 0.996 0.004
#> GSM28799 1 0.0000 0.770 1.000 0.000
#> GSM28791 1 0.0000 0.770 1.000 0.000
#> GSM28794 1 0.9686 -0.748 0.604 0.396
#> GSM28780 1 0.0000 0.770 1.000 0.000
#> GSM28795 1 0.0000 0.770 1.000 0.000
#> GSM11301 2 1.0000 1.000 0.496 0.504
#> GSM11297 1 0.2236 0.737 0.964 0.036
#> GSM11298 1 0.0000 0.770 1.000 0.000
#> GSM11314 1 0.0000 0.770 1.000 0.000
#> GSM11299 1 0.9522 0.434 0.628 0.372
#> GSM28783 1 0.0000 0.770 1.000 0.000
#> GSM11308 1 0.0000 0.770 1.000 0.000
#> GSM28782 1 0.0000 0.770 1.000 0.000
#> GSM28779 1 0.0000 0.770 1.000 0.000
#> GSM11302 1 0.0000 0.770 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28789 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28790 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11300 3 0.6509 0.185 0.472 0.004 0.524
#> GSM28798 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11296 2 0.0237 1.000 0.004 0.996 0.000
#> GSM28801 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11319 2 0.0237 1.000 0.004 0.996 0.000
#> GSM28781 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11305 2 0.0237 1.000 0.004 0.996 0.000
#> GSM28784 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11307 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11313 2 0.0237 1.000 0.004 0.996 0.000
#> GSM28785 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11318 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11295 3 0.0424 0.822 0.008 0.000 0.992
#> GSM28793 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11309 1 0.0237 0.970 0.996 0.004 0.000
#> GSM11315 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.824 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.824 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.824 0.000 0.000 1.000
#> GSM28797 1 0.0237 0.970 0.996 0.004 0.000
#> GSM28786 1 0.0237 0.970 0.996 0.004 0.000
#> GSM28800 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28787 3 0.0424 0.822 0.008 0.000 0.992
#> GSM11304 1 0.3784 0.815 0.864 0.004 0.132
#> GSM11303 3 0.0000 0.824 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.824 0.000 0.000 1.000
#> GSM11311 1 0.0237 0.970 0.996 0.004 0.000
#> GSM28799 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28794 1 0.6225 0.249 0.568 0.432 0.000
#> GSM28780 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11301 2 0.0237 1.000 0.004 0.996 0.000
#> GSM11297 1 0.3784 0.815 0.864 0.004 0.132
#> GSM11298 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11314 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11299 3 0.6509 0.185 0.472 0.004 0.524
#> GSM28783 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.973 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.1118 0.819 0.964 0.000 0.000 0.036
#> GSM28789 1 0.1118 0.819 0.964 0.000 0.000 0.036
#> GSM28790 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM11300 4 0.6096 1.000 0.184 0.000 0.136 0.680
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM28792 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM11295 3 0.0188 0.492 0.000 0.000 0.996 0.004
#> GSM28793 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM11312 1 0.0707 0.827 0.980 0.000 0.000 0.020
#> GSM28778 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM28796 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM11309 1 0.4522 0.458 0.680 0.000 0.000 0.320
#> GSM11315 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM11306 1 0.1118 0.819 0.964 0.000 0.000 0.036
#> GSM28776 1 0.1118 0.819 0.964 0.000 0.000 0.036
#> GSM28777 3 0.4985 0.788 0.000 0.000 0.532 0.468
#> GSM11316 3 0.4985 0.788 0.000 0.000 0.532 0.468
#> GSM11320 3 0.4985 0.788 0.000 0.000 0.532 0.468
#> GSM28797 1 0.4522 0.458 0.680 0.000 0.000 0.320
#> GSM28786 1 0.4522 0.458 0.680 0.000 0.000 0.320
#> GSM28800 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM11310 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM28787 3 0.0336 0.488 0.000 0.000 0.992 0.008
#> GSM11304 1 0.6739 0.150 0.576 0.000 0.120 0.304
#> GSM11303 3 0.4985 0.788 0.000 0.000 0.532 0.468
#> GSM11317 3 0.4985 0.788 0.000 0.000 0.532 0.468
#> GSM11311 1 0.2149 0.776 0.912 0.000 0.000 0.088
#> GSM28799 1 0.0000 0.830 1.000 0.000 0.000 0.000
#> GSM28791 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM28794 1 0.4933 0.296 0.568 0.432 0.000 0.000
#> GSM28780 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM28795 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11297 1 0.6739 0.150 0.576 0.000 0.120 0.304
#> GSM11298 1 0.0188 0.829 0.996 0.000 0.000 0.004
#> GSM11314 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM11299 4 0.6096 1.000 0.184 0.000 0.136 0.680
#> GSM28783 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM11308 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM28782 1 0.3688 0.738 0.792 0.000 0.000 0.208
#> GSM28779 1 0.0188 0.829 0.996 0.000 0.000 0.004
#> GSM11302 1 0.0188 0.829 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.3452 0.657 0.756 0.000 0.000 0.244 0.000
#> GSM28789 1 0.3452 0.657 0.756 0.000 0.000 0.244 0.000
#> GSM28790 1 0.0000 0.806 1.000 0.000 0.000 0.000 0.000
#> GSM11300 3 0.7766 0.101 0.148 0.000 0.412 0.336 0.104
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.0000 0.806 1.000 0.000 0.000 0.000 0.000
#> GSM28792 1 0.0000 0.806 1.000 0.000 0.000 0.000 0.000
#> GSM11295 5 0.3074 0.936 0.000 0.000 0.196 0.000 0.804
#> GSM28793 1 0.0000 0.806 1.000 0.000 0.000 0.000 0.000
#> GSM11312 1 0.0898 0.805 0.972 0.000 0.000 0.020 0.008
#> GSM28778 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM28796 1 0.0000 0.806 1.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.2074 1.000 0.104 0.000 0.000 0.896 0.000
#> GSM11315 1 0.0000 0.806 1.000 0.000 0.000 0.000 0.000
#> GSM11306 1 0.3452 0.657 0.756 0.000 0.000 0.244 0.000
#> GSM28776 1 0.3452 0.657 0.756 0.000 0.000 0.244 0.000
#> GSM28777 3 0.0000 0.704 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.704 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.704 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.2074 1.000 0.104 0.000 0.000 0.896 0.000
#> GSM28786 4 0.2074 1.000 0.104 0.000 0.000 0.896 0.000
#> GSM28800 1 0.0290 0.805 0.992 0.000 0.000 0.008 0.000
#> GSM11310 1 0.0290 0.805 0.992 0.000 0.000 0.008 0.000
#> GSM28787 5 0.2843 0.938 0.000 0.000 0.144 0.008 0.848
#> GSM11304 1 0.6305 0.074 0.536 0.000 0.020 0.340 0.104
#> GSM11303 3 0.0000 0.704 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.704 0.000 0.000 1.000 0.000 0.000
#> GSM11311 1 0.3774 0.448 0.704 0.000 0.000 0.296 0.000
#> GSM28799 1 0.0290 0.805 0.992 0.000 0.000 0.008 0.000
#> GSM28791 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM28794 1 0.4249 0.367 0.568 0.432 0.000 0.000 0.000
#> GSM28780 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM28795 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11297 1 0.6305 0.074 0.536 0.000 0.020 0.340 0.104
#> GSM11298 1 0.0290 0.805 0.992 0.000 0.000 0.008 0.000
#> GSM11314 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM11299 3 0.7766 0.101 0.148 0.000 0.412 0.336 0.104
#> GSM28783 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM11308 1 0.4457 0.739 0.756 0.000 0.000 0.092 0.152
#> GSM28782 1 0.4350 0.743 0.764 0.000 0.000 0.084 0.152
#> GSM28779 1 0.0510 0.803 0.984 0.000 0.000 0.016 0.000
#> GSM11302 1 0.0404 0.804 0.988 0.000 0.000 0.012 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 1 0.4062 0.568 0.660 0.000 0.000 0.316 0.024 0.000
#> GSM28789 1 0.4062 0.568 0.660 0.000 0.000 0.316 0.024 0.000
#> GSM28790 1 0.0000 0.815 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11300 3 0.7520 0.143 0.136 0.000 0.392 0.348 0.048 0.076
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0000 0.815 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28792 1 0.0000 0.815 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11295 6 0.2378 0.826 0.000 0.000 0.152 0.000 0.000 0.848
#> GSM28793 1 0.0000 0.815 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11312 1 0.2060 0.775 0.900 0.000 0.000 0.016 0.084 0.000
#> GSM28778 5 0.1296 0.951 0.044 0.000 0.000 0.004 0.948 0.004
#> GSM28796 1 0.0000 0.815 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.0547 1.000 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM11315 1 0.0000 0.815 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11306 1 0.4062 0.568 0.660 0.000 0.000 0.316 0.024 0.000
#> GSM28776 1 0.4045 0.573 0.664 0.000 0.000 0.312 0.024 0.000
#> GSM28777 3 0.0000 0.727 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.727 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.727 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.0547 1.000 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM28786 4 0.0547 1.000 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM28800 1 0.0363 0.815 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM11310 1 0.0363 0.815 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM28787 6 0.0146 0.833 0.000 0.000 0.004 0.000 0.000 0.996
#> GSM11304 1 0.5848 0.189 0.524 0.000 0.000 0.352 0.048 0.076
#> GSM11303 3 0.0000 0.727 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.727 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 1 0.3446 0.510 0.692 0.000 0.000 0.308 0.000 0.000
#> GSM28799 1 0.0363 0.815 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM28791 5 0.1663 0.950 0.088 0.000 0.000 0.000 0.912 0.000
#> GSM28794 1 0.3817 0.323 0.568 0.432 0.000 0.000 0.000 0.000
#> GSM28780 5 0.1387 0.956 0.068 0.000 0.000 0.000 0.932 0.000
#> GSM28795 5 0.1296 0.951 0.044 0.000 0.000 0.004 0.948 0.004
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 1 0.5848 0.189 0.524 0.000 0.000 0.352 0.048 0.076
#> GSM11298 1 0.0260 0.816 0.992 0.000 0.000 0.008 0.000 0.000
#> GSM11314 5 0.1296 0.951 0.044 0.000 0.000 0.004 0.948 0.004
#> GSM11299 3 0.7520 0.143 0.136 0.000 0.392 0.348 0.048 0.076
#> GSM28783 5 0.1814 0.936 0.100 0.000 0.000 0.000 0.900 0.000
#> GSM11308 5 0.1387 0.956 0.068 0.000 0.000 0.000 0.932 0.000
#> GSM28782 5 0.2219 0.896 0.136 0.000 0.000 0.000 0.864 0.000
#> GSM28779 1 0.1176 0.806 0.956 0.000 0.000 0.020 0.024 0.000
#> GSM11302 1 0.1088 0.807 0.960 0.000 0.000 0.016 0.024 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> SD:hclust 42 0.384 2
#> SD:hclust 49 0.368 3
#> SD:hclust 44 0.410 4
#> SD:hclust 46 0.498 5
#> SD:hclust 47 0.471 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.509 0.806 0.828 0.3385 0.638 0.638
#> 3 3 1.000 0.993 0.984 0.6617 0.790 0.670
#> 4 4 0.728 0.677 0.844 0.2345 0.919 0.810
#> 5 5 0.711 0.838 0.823 0.0977 0.835 0.535
#> 6 6 0.726 0.768 0.831 0.0659 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
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
#> GSM28788 1 0.9795 0.827 0.584 0.416
#> GSM28789 1 0.9795 0.827 0.584 0.416
#> GSM28790 1 0.9795 0.827 0.584 0.416
#> GSM11300 1 0.0000 0.494 1.000 0.000
#> GSM28798 2 0.0000 0.999 0.000 1.000
#> GSM11296 2 0.0000 0.999 0.000 1.000
#> GSM28801 2 0.0000 0.999 0.000 1.000
#> GSM11319 2 0.0000 0.999 0.000 1.000
#> GSM28781 2 0.0000 0.999 0.000 1.000
#> GSM11305 2 0.0000 0.999 0.000 1.000
#> GSM28784 2 0.0000 0.999 0.000 1.000
#> GSM11307 2 0.0000 0.999 0.000 1.000
#> GSM11313 2 0.0000 0.999 0.000 1.000
#> GSM28785 2 0.0000 0.999 0.000 1.000
#> GSM11318 1 0.9795 0.827 0.584 0.416
#> GSM28792 1 0.9795 0.827 0.584 0.416
#> GSM11295 1 0.1184 0.483 0.984 0.016
#> GSM28793 1 0.9795 0.827 0.584 0.416
#> GSM11312 1 0.9795 0.827 0.584 0.416
#> GSM28778 1 0.9795 0.827 0.584 0.416
#> GSM28796 1 0.9795 0.827 0.584 0.416
#> GSM11309 1 0.9635 0.813 0.612 0.388
#> GSM11315 1 0.9795 0.827 0.584 0.416
#> GSM11306 1 0.9795 0.827 0.584 0.416
#> GSM28776 1 0.9795 0.827 0.584 0.416
#> GSM28777 1 0.1184 0.483 0.984 0.016
#> GSM11316 1 0.1184 0.483 0.984 0.016
#> GSM11320 1 0.1184 0.483 0.984 0.016
#> GSM28797 1 0.9635 0.813 0.612 0.388
#> GSM28786 1 0.9635 0.813 0.612 0.388
#> GSM28800 1 0.9795 0.827 0.584 0.416
#> GSM11310 1 0.9795 0.827 0.584 0.416
#> GSM28787 1 0.1184 0.483 0.984 0.016
#> GSM11304 1 0.9635 0.813 0.612 0.388
#> GSM11303 1 0.1184 0.483 0.984 0.016
#> GSM11317 1 0.1184 0.483 0.984 0.016
#> GSM11311 1 0.9754 0.824 0.592 0.408
#> GSM28799 1 0.9754 0.824 0.592 0.408
#> GSM28791 1 0.9795 0.827 0.584 0.416
#> GSM28794 2 0.0672 0.986 0.008 0.992
#> GSM28780 1 0.9795 0.827 0.584 0.416
#> GSM28795 1 0.9795 0.827 0.584 0.416
#> GSM11301 2 0.0000 0.999 0.000 1.000
#> GSM11297 1 0.9661 0.816 0.608 0.392
#> GSM11298 1 0.9795 0.827 0.584 0.416
#> GSM11314 1 0.9795 0.827 0.584 0.416
#> GSM11299 1 0.0000 0.494 1.000 0.000
#> GSM28783 1 0.9795 0.827 0.584 0.416
#> GSM11308 1 0.9732 0.822 0.596 0.404
#> GSM28782 1 0.9795 0.827 0.584 0.416
#> GSM28779 1 0.9795 0.827 0.584 0.416
#> GSM11302 1 0.9795 0.827 0.584 0.416
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0424 0.993 0.992 0.000 0.008
#> GSM28789 1 0.0424 0.993 0.992 0.000 0.008
#> GSM28790 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11300 3 0.1860 0.999 0.052 0.000 0.948
#> GSM28798 2 0.1585 0.982 0.008 0.964 0.028
#> GSM11296 2 0.0424 0.986 0.008 0.992 0.000
#> GSM28801 2 0.0424 0.986 0.008 0.992 0.000
#> GSM11319 2 0.0424 0.986 0.008 0.992 0.000
#> GSM28781 2 0.0424 0.986 0.008 0.992 0.000
#> GSM11305 2 0.1585 0.982 0.008 0.964 0.028
#> GSM28784 2 0.1170 0.982 0.008 0.976 0.016
#> GSM11307 2 0.1585 0.982 0.008 0.964 0.028
#> GSM11313 2 0.1585 0.982 0.008 0.964 0.028
#> GSM28785 2 0.0424 0.986 0.008 0.992 0.000
#> GSM11318 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11295 3 0.2096 0.998 0.052 0.004 0.944
#> GSM28793 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11309 1 0.0661 0.990 0.988 0.004 0.008
#> GSM11315 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11306 1 0.0424 0.993 0.992 0.000 0.008
#> GSM28776 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28777 3 0.1860 0.999 0.052 0.000 0.948
#> GSM11316 3 0.1860 0.999 0.052 0.000 0.948
#> GSM11320 3 0.1860 0.999 0.052 0.000 0.948
#> GSM28797 1 0.0661 0.990 0.988 0.004 0.008
#> GSM28786 1 0.0661 0.990 0.988 0.004 0.008
#> GSM28800 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28787 3 0.2096 0.998 0.052 0.004 0.944
#> GSM11304 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11303 3 0.1860 0.999 0.052 0.000 0.948
#> GSM11317 3 0.1860 0.999 0.052 0.000 0.948
#> GSM11311 1 0.0661 0.990 0.988 0.004 0.008
#> GSM28799 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28794 2 0.2569 0.957 0.032 0.936 0.032
#> GSM28780 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11301 2 0.1170 0.982 0.008 0.976 0.016
#> GSM11297 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11298 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11314 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11299 3 0.1860 0.999 0.052 0.000 0.948
#> GSM28783 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.998 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.998 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.998 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.4998 -0.730 0.512 0.000 0.000 0.488
#> GSM28789 1 0.4998 -0.730 0.512 0.000 0.000 0.488
#> GSM28790 1 0.3172 0.641 0.840 0.000 0.000 0.160
#> GSM11300 3 0.0524 0.982 0.004 0.000 0.988 0.008
#> GSM28798 2 0.1824 0.956 0.000 0.936 0.004 0.060
#> GSM11296 2 0.0000 0.965 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0188 0.964 0.000 0.996 0.000 0.004
#> GSM11319 2 0.0000 0.965 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.965 0.000 1.000 0.000 0.000
#> GSM11305 2 0.1824 0.956 0.000 0.936 0.004 0.060
#> GSM28784 2 0.0921 0.958 0.000 0.972 0.000 0.028
#> GSM11307 2 0.1824 0.956 0.000 0.936 0.004 0.060
#> GSM11313 2 0.1824 0.956 0.000 0.936 0.004 0.060
#> GSM28785 2 0.0000 0.965 0.000 1.000 0.000 0.000
#> GSM11318 1 0.3444 0.635 0.816 0.000 0.000 0.184
#> GSM28792 1 0.1557 0.614 0.944 0.000 0.000 0.056
#> GSM11295 3 0.1824 0.960 0.004 0.000 0.936 0.060
#> GSM28793 1 0.1557 0.614 0.944 0.000 0.000 0.056
#> GSM11312 1 0.3873 0.631 0.772 0.000 0.000 0.228
#> GSM28778 1 0.4250 0.612 0.724 0.000 0.000 0.276
#> GSM28796 1 0.1557 0.614 0.944 0.000 0.000 0.056
#> GSM11309 4 0.4955 0.941 0.444 0.000 0.000 0.556
#> GSM11315 1 0.1557 0.614 0.944 0.000 0.000 0.056
#> GSM11306 1 0.5000 -0.745 0.504 0.000 0.000 0.496
#> GSM28776 1 0.2973 0.422 0.856 0.000 0.000 0.144
#> GSM28777 3 0.0188 0.984 0.004 0.000 0.996 0.000
#> GSM11316 3 0.0524 0.985 0.004 0.000 0.988 0.008
#> GSM11320 3 0.0524 0.985 0.004 0.000 0.988 0.008
#> GSM28797 4 0.4955 0.941 0.444 0.000 0.000 0.556
#> GSM28786 4 0.4955 0.941 0.444 0.000 0.000 0.556
#> GSM28800 1 0.0000 0.624 1.000 0.000 0.000 0.000
#> GSM11310 1 0.3873 0.158 0.772 0.000 0.000 0.228
#> GSM28787 3 0.2125 0.952 0.004 0.000 0.920 0.076
#> GSM11304 1 0.3123 0.420 0.844 0.000 0.000 0.156
#> GSM11303 3 0.0524 0.985 0.004 0.000 0.988 0.008
#> GSM11317 3 0.0524 0.985 0.004 0.000 0.988 0.008
#> GSM11311 4 0.4977 0.815 0.460 0.000 0.000 0.540
#> GSM28799 1 0.3356 0.343 0.824 0.000 0.000 0.176
#> GSM28791 1 0.3975 0.626 0.760 0.000 0.000 0.240
#> GSM28794 2 0.4296 0.870 0.060 0.824 0.004 0.112
#> GSM28780 1 0.4193 0.618 0.732 0.000 0.000 0.268
#> GSM28795 1 0.4277 0.609 0.720 0.000 0.000 0.280
#> GSM11301 2 0.1389 0.950 0.000 0.952 0.000 0.048
#> GSM11297 1 0.3172 0.411 0.840 0.000 0.000 0.160
#> GSM11298 1 0.1637 0.616 0.940 0.000 0.000 0.060
#> GSM11314 1 0.4277 0.609 0.720 0.000 0.000 0.280
#> GSM11299 3 0.0524 0.982 0.004 0.000 0.988 0.008
#> GSM28783 1 0.4193 0.618 0.732 0.000 0.000 0.268
#> GSM11308 1 0.4193 0.618 0.732 0.000 0.000 0.268
#> GSM28782 1 0.3649 0.635 0.796 0.000 0.000 0.204
#> GSM28779 1 0.0921 0.627 0.972 0.000 0.000 0.028
#> GSM11302 1 0.1022 0.632 0.968 0.000 0.000 0.032
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.6084 0.772 0.208 0.000 0.000 0.572 0.220
#> GSM28789 4 0.6084 0.772 0.208 0.000 0.000 0.572 0.220
#> GSM28790 1 0.4288 0.760 0.612 0.000 0.000 0.004 0.384
#> GSM11300 3 0.1568 0.933 0.020 0.000 0.944 0.036 0.000
#> GSM28798 2 0.2645 0.916 0.068 0.888 0.000 0.044 0.000
#> GSM11296 2 0.0162 0.930 0.004 0.996 0.000 0.000 0.000
#> GSM28801 2 0.0451 0.929 0.008 0.988 0.000 0.004 0.000
#> GSM11319 2 0.0000 0.931 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0162 0.930 0.004 0.996 0.000 0.000 0.000
#> GSM11305 2 0.2645 0.916 0.068 0.888 0.000 0.044 0.000
#> GSM28784 2 0.2149 0.905 0.048 0.916 0.000 0.036 0.000
#> GSM11307 2 0.2645 0.916 0.068 0.888 0.000 0.044 0.000
#> GSM11313 2 0.2645 0.916 0.068 0.888 0.000 0.044 0.000
#> GSM28785 2 0.0000 0.931 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.4367 0.686 0.580 0.000 0.000 0.004 0.416
#> GSM28792 1 0.4066 0.826 0.672 0.000 0.000 0.004 0.324
#> GSM11295 3 0.3702 0.872 0.084 0.000 0.820 0.096 0.000
#> GSM28793 1 0.4066 0.826 0.672 0.000 0.000 0.004 0.324
#> GSM11312 5 0.2852 0.685 0.172 0.000 0.000 0.000 0.828
#> GSM28778 5 0.0000 0.899 0.000 0.000 0.000 0.000 1.000
#> GSM28796 1 0.4066 0.826 0.672 0.000 0.000 0.004 0.324
#> GSM11309 4 0.4113 0.827 0.140 0.000 0.000 0.784 0.076
#> GSM11315 1 0.4066 0.826 0.672 0.000 0.000 0.004 0.324
#> GSM11306 4 0.6035 0.773 0.204 0.000 0.000 0.580 0.216
#> GSM28776 1 0.5873 0.749 0.564 0.000 0.000 0.124 0.312
#> GSM28777 3 0.0566 0.944 0.012 0.000 0.984 0.004 0.000
#> GSM11316 3 0.0451 0.947 0.008 0.000 0.988 0.004 0.000
#> GSM11320 3 0.0451 0.947 0.008 0.000 0.988 0.004 0.000
#> GSM28797 4 0.4113 0.827 0.140 0.000 0.000 0.784 0.076
#> GSM28786 4 0.4113 0.827 0.140 0.000 0.000 0.784 0.076
#> GSM28800 1 0.4639 0.792 0.612 0.000 0.000 0.020 0.368
#> GSM11310 1 0.5887 0.709 0.596 0.000 0.000 0.164 0.240
#> GSM28787 3 0.4459 0.846 0.104 0.000 0.780 0.104 0.012
#> GSM11304 1 0.6152 0.655 0.524 0.000 0.000 0.152 0.324
#> GSM11303 3 0.0451 0.947 0.008 0.000 0.988 0.004 0.000
#> GSM11317 3 0.0451 0.947 0.008 0.000 0.988 0.004 0.000
#> GSM11311 4 0.4817 0.688 0.300 0.000 0.000 0.656 0.044
#> GSM28799 1 0.5923 0.725 0.572 0.000 0.000 0.140 0.288
#> GSM28791 5 0.0671 0.892 0.016 0.000 0.000 0.004 0.980
#> GSM28794 2 0.5849 0.766 0.160 0.688 0.000 0.084 0.068
#> GSM28780 5 0.0798 0.894 0.016 0.000 0.000 0.008 0.976
#> GSM28795 5 0.0000 0.899 0.000 0.000 0.000 0.000 1.000
#> GSM11301 2 0.2645 0.891 0.068 0.888 0.000 0.044 0.000
#> GSM11297 1 0.6152 0.655 0.524 0.000 0.000 0.152 0.324
#> GSM11298 1 0.4047 0.825 0.676 0.000 0.000 0.004 0.320
#> GSM11314 5 0.0404 0.894 0.012 0.000 0.000 0.000 0.988
#> GSM11299 3 0.1830 0.928 0.028 0.000 0.932 0.040 0.000
#> GSM28783 5 0.0955 0.884 0.028 0.000 0.000 0.004 0.968
#> GSM11308 5 0.1281 0.881 0.032 0.000 0.000 0.012 0.956
#> GSM28782 5 0.3700 0.472 0.240 0.000 0.000 0.008 0.752
#> GSM28779 1 0.4592 0.814 0.644 0.000 0.000 0.024 0.332
#> GSM11302 1 0.3966 0.820 0.664 0.000 0.000 0.000 0.336
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.6310 0.675 0.068 0.000 0.000 0.556 0.152 NA
#> GSM28789 4 0.6310 0.675 0.068 0.000 0.000 0.556 0.152 NA
#> GSM28790 1 0.0713 0.762 0.972 0.000 0.000 0.000 0.028 NA
#> GSM11300 3 0.3043 0.832 0.000 0.000 0.828 0.012 0.012 NA
#> GSM28798 2 0.2300 0.869 0.000 0.856 0.000 0.000 0.000 NA
#> GSM11296 2 0.0000 0.890 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28801 2 0.1082 0.880 0.000 0.956 0.000 0.000 0.004 NA
#> GSM11319 2 0.0146 0.889 0.000 0.996 0.000 0.000 0.000 NA
#> GSM28781 2 0.0000 0.890 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11305 2 0.2300 0.869 0.000 0.856 0.000 0.000 0.000 NA
#> GSM28784 2 0.2278 0.844 0.000 0.868 0.000 0.000 0.004 NA
#> GSM11307 2 0.2300 0.869 0.000 0.856 0.000 0.000 0.000 NA
#> GSM11313 2 0.2300 0.869 0.000 0.856 0.000 0.000 0.000 NA
#> GSM28785 2 0.0000 0.890 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11318 1 0.0790 0.759 0.968 0.000 0.000 0.000 0.032 NA
#> GSM28792 1 0.0458 0.770 0.984 0.000 0.000 0.000 0.016 NA
#> GSM11295 3 0.4138 0.793 0.000 0.000 0.752 0.020 0.044 NA
#> GSM28793 1 0.0458 0.770 0.984 0.000 0.000 0.000 0.016 NA
#> GSM11312 5 0.5628 0.448 0.276 0.000 0.000 0.008 0.560 NA
#> GSM28778 5 0.2741 0.849 0.092 0.000 0.000 0.008 0.868 NA
#> GSM28796 1 0.0458 0.770 0.984 0.000 0.000 0.000 0.016 NA
#> GSM11309 4 0.0891 0.765 0.024 0.000 0.000 0.968 0.008 NA
#> GSM11315 1 0.0458 0.770 0.984 0.000 0.000 0.000 0.016 NA
#> GSM11306 4 0.6339 0.671 0.068 0.000 0.000 0.552 0.156 NA
#> GSM28776 1 0.5644 0.680 0.640 0.000 0.000 0.100 0.064 NA
#> GSM28777 3 0.0665 0.898 0.000 0.000 0.980 0.004 0.008 NA
#> GSM11316 3 0.0000 0.900 0.000 0.000 1.000 0.000 0.000 NA
#> GSM11320 3 0.0000 0.900 0.000 0.000 1.000 0.000 0.000 NA
#> GSM28797 4 0.0891 0.765 0.024 0.000 0.000 0.968 0.008 NA
#> GSM28786 4 0.0891 0.765 0.024 0.000 0.000 0.968 0.008 NA
#> GSM28800 1 0.4717 0.721 0.704 0.000 0.000 0.032 0.056 NA
#> GSM11310 1 0.5735 0.672 0.620 0.000 0.000 0.124 0.048 NA
#> GSM28787 3 0.4731 0.739 0.000 0.000 0.684 0.020 0.060 NA
#> GSM11304 1 0.6581 0.533 0.472 0.000 0.000 0.088 0.112 NA
#> GSM11303 3 0.0000 0.900 0.000 0.000 1.000 0.000 0.000 NA
#> GSM11317 3 0.0000 0.900 0.000 0.000 1.000 0.000 0.000 NA
#> GSM11311 4 0.2994 0.626 0.208 0.000 0.000 0.788 0.004 NA
#> GSM28799 1 0.5847 0.663 0.604 0.000 0.000 0.092 0.068 NA
#> GSM28791 5 0.2170 0.851 0.100 0.000 0.000 0.000 0.888 NA
#> GSM28794 2 0.5845 0.485 0.028 0.488 0.000 0.004 0.084 NA
#> GSM28780 5 0.2301 0.849 0.096 0.000 0.000 0.000 0.884 NA
#> GSM28795 5 0.2588 0.849 0.092 0.000 0.000 0.008 0.876 NA
#> GSM11301 2 0.2669 0.825 0.000 0.836 0.000 0.000 0.008 NA
#> GSM11297 1 0.6581 0.533 0.472 0.000 0.000 0.088 0.112 NA
#> GSM11298 1 0.0508 0.770 0.984 0.000 0.000 0.000 0.012 NA
#> GSM11314 5 0.2510 0.846 0.080 0.000 0.000 0.008 0.884 NA
#> GSM11299 3 0.3394 0.804 0.000 0.000 0.788 0.012 0.012 NA
#> GSM28783 5 0.2264 0.838 0.096 0.000 0.000 0.004 0.888 NA
#> GSM11308 5 0.2383 0.843 0.096 0.000 0.000 0.000 0.880 NA
#> GSM28782 5 0.4962 0.255 0.416 0.000 0.000 0.000 0.516 NA
#> GSM28779 1 0.4701 0.722 0.712 0.000 0.000 0.036 0.056 NA
#> GSM11302 1 0.3249 0.743 0.824 0.000 0.000 0.004 0.044 NA
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 tissue(p) k
#> SD:kmeans 43 0.386 2
#> SD:kmeans 52 0.372 3
#> SD:kmeans 44 0.500 4
#> SD:kmeans 51 0.434 5
#> SD:kmeans 49 0.428 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.753 0.811 0.916 0.4414 0.517 0.517
#> 3 3 0.940 0.959 0.982 0.4516 0.762 0.571
#> 4 4 0.781 0.761 0.880 0.1711 0.848 0.596
#> 5 5 0.935 0.916 0.959 0.0764 0.888 0.594
#> 6 6 0.885 0.847 0.911 0.0372 0.953 0.765
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 3
There is also optional best \(k\) = 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.2423 0.9270 0.960 0.040
#> GSM28789 2 0.9998 0.0464 0.492 0.508
#> GSM28790 1 0.0000 0.9750 1.000 0.000
#> GSM11300 1 0.0376 0.9709 0.996 0.004
#> GSM28798 2 0.0000 0.7769 0.000 1.000
#> GSM11296 2 0.0000 0.7769 0.000 1.000
#> GSM28801 2 0.0000 0.7769 0.000 1.000
#> GSM11319 2 0.0000 0.7769 0.000 1.000
#> GSM28781 2 0.0000 0.7769 0.000 1.000
#> GSM11305 2 0.0000 0.7769 0.000 1.000
#> GSM28784 2 0.0000 0.7769 0.000 1.000
#> GSM11307 2 0.0000 0.7769 0.000 1.000
#> GSM11313 2 0.0000 0.7769 0.000 1.000
#> GSM28785 2 0.0000 0.7769 0.000 1.000
#> GSM11318 1 0.0000 0.9750 1.000 0.000
#> GSM28792 1 0.0000 0.9750 1.000 0.000
#> GSM11295 2 0.9977 0.3848 0.472 0.528
#> GSM28793 1 0.0000 0.9750 1.000 0.000
#> GSM11312 1 0.0000 0.9750 1.000 0.000
#> GSM28778 1 0.9963 0.0102 0.536 0.464
#> GSM28796 1 0.0000 0.9750 1.000 0.000
#> GSM11309 1 0.0000 0.9750 1.000 0.000
#> GSM11315 1 0.0000 0.9750 1.000 0.000
#> GSM11306 1 0.0000 0.9750 1.000 0.000
#> GSM28776 1 0.0000 0.9750 1.000 0.000
#> GSM28777 2 0.9977 0.3848 0.472 0.528
#> GSM11316 2 0.9963 0.3962 0.464 0.536
#> GSM11320 2 0.9977 0.3848 0.472 0.528
#> GSM28797 1 0.0000 0.9750 1.000 0.000
#> GSM28786 1 0.0000 0.9750 1.000 0.000
#> GSM28800 1 0.0000 0.9750 1.000 0.000
#> GSM11310 1 0.0000 0.9750 1.000 0.000
#> GSM28787 2 0.9977 0.3848 0.472 0.528
#> GSM11304 1 0.0000 0.9750 1.000 0.000
#> GSM11303 2 0.9977 0.3848 0.472 0.528
#> GSM11317 2 0.9977 0.3848 0.472 0.528
#> GSM11311 1 0.0000 0.9750 1.000 0.000
#> GSM28799 1 0.0000 0.9750 1.000 0.000
#> GSM28791 1 0.0000 0.9750 1.000 0.000
#> GSM28794 2 0.0000 0.7769 0.000 1.000
#> GSM28780 1 0.0000 0.9750 1.000 0.000
#> GSM28795 1 0.0000 0.9750 1.000 0.000
#> GSM11301 2 0.0000 0.7769 0.000 1.000
#> GSM11297 1 0.0000 0.9750 1.000 0.000
#> GSM11298 1 0.0000 0.9750 1.000 0.000
#> GSM11314 1 0.3733 0.8797 0.928 0.072
#> GSM11299 1 0.0376 0.9709 0.996 0.004
#> GSM28783 1 0.0000 0.9750 1.000 0.000
#> GSM11308 1 0.0000 0.9750 1.000 0.000
#> GSM28782 1 0.0000 0.9750 1.000 0.000
#> GSM28779 1 0.0000 0.9750 1.000 0.000
#> GSM11302 1 0.0000 0.9750 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.177 0.958 0.960 0.024 0.016
#> GSM28789 2 0.575 0.577 0.296 0.700 0.004
#> GSM28790 1 0.000 0.992 1.000 0.000 0.000
#> GSM11300 3 0.000 0.959 0.000 0.000 1.000
#> GSM28798 2 0.000 0.970 0.000 1.000 0.000
#> GSM11296 2 0.000 0.970 0.000 1.000 0.000
#> GSM28801 2 0.000 0.970 0.000 1.000 0.000
#> GSM11319 2 0.000 0.970 0.000 1.000 0.000
#> GSM28781 2 0.000 0.970 0.000 1.000 0.000
#> GSM11305 2 0.000 0.970 0.000 1.000 0.000
#> GSM28784 2 0.000 0.970 0.000 1.000 0.000
#> GSM11307 2 0.000 0.970 0.000 1.000 0.000
#> GSM11313 2 0.000 0.970 0.000 1.000 0.000
#> GSM28785 2 0.000 0.970 0.000 1.000 0.000
#> GSM11318 1 0.000 0.992 1.000 0.000 0.000
#> GSM28792 1 0.000 0.992 1.000 0.000 0.000
#> GSM11295 3 0.000 0.959 0.000 0.000 1.000
#> GSM28793 1 0.000 0.992 1.000 0.000 0.000
#> GSM11312 1 0.000 0.992 1.000 0.000 0.000
#> GSM28778 1 0.000 0.992 1.000 0.000 0.000
#> GSM28796 1 0.000 0.992 1.000 0.000 0.000
#> GSM11309 3 0.382 0.839 0.148 0.000 0.852
#> GSM11315 1 0.000 0.992 1.000 0.000 0.000
#> GSM11306 1 0.000 0.992 1.000 0.000 0.000
#> GSM28776 1 0.000 0.992 1.000 0.000 0.000
#> GSM28777 3 0.000 0.959 0.000 0.000 1.000
#> GSM11316 3 0.000 0.959 0.000 0.000 1.000
#> GSM11320 3 0.000 0.959 0.000 0.000 1.000
#> GSM28797 3 0.382 0.839 0.148 0.000 0.852
#> GSM28786 3 0.369 0.846 0.140 0.000 0.860
#> GSM28800 1 0.000 0.992 1.000 0.000 0.000
#> GSM11310 1 0.000 0.992 1.000 0.000 0.000
#> GSM28787 3 0.000 0.959 0.000 0.000 1.000
#> GSM11304 3 0.000 0.959 0.000 0.000 1.000
#> GSM11303 3 0.000 0.959 0.000 0.000 1.000
#> GSM11317 3 0.000 0.959 0.000 0.000 1.000
#> GSM11311 1 0.000 0.992 1.000 0.000 0.000
#> GSM28799 1 0.000 0.992 1.000 0.000 0.000
#> GSM28791 1 0.000 0.992 1.000 0.000 0.000
#> GSM28794 2 0.000 0.970 0.000 1.000 0.000
#> GSM28780 1 0.000 0.992 1.000 0.000 0.000
#> GSM28795 1 0.000 0.992 1.000 0.000 0.000
#> GSM11301 2 0.000 0.970 0.000 1.000 0.000
#> GSM11297 3 0.000 0.959 0.000 0.000 1.000
#> GSM11298 1 0.000 0.992 1.000 0.000 0.000
#> GSM11314 1 0.129 0.963 0.968 0.000 0.032
#> GSM11299 3 0.000 0.959 0.000 0.000 1.000
#> GSM28783 1 0.000 0.992 1.000 0.000 0.000
#> GSM11308 1 0.334 0.857 0.880 0.000 0.120
#> GSM28782 1 0.000 0.992 1.000 0.000 0.000
#> GSM28779 1 0.000 0.992 1.000 0.000 0.000
#> GSM11302 1 0.000 0.992 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.0469 0.660 0.012 0.000 0.000 0.988
#> GSM28789 4 0.2081 0.607 0.000 0.084 0.000 0.916
#> GSM28790 1 0.0469 0.693 0.988 0.000 0.000 0.012
#> GSM11300 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0000 0.691 1.000 0.000 0.000 0.000
#> GSM28792 1 0.3074 0.683 0.848 0.000 0.000 0.152
#> GSM11295 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM28793 1 0.3074 0.683 0.848 0.000 0.000 0.152
#> GSM11312 1 0.3726 0.624 0.788 0.000 0.000 0.212
#> GSM28778 1 0.4643 0.502 0.656 0.000 0.000 0.344
#> GSM28796 1 0.3074 0.683 0.848 0.000 0.000 0.152
#> GSM11309 4 0.2466 0.673 0.004 0.000 0.096 0.900
#> GSM11315 1 0.3074 0.683 0.848 0.000 0.000 0.152
#> GSM11306 4 0.0469 0.657 0.012 0.000 0.000 0.988
#> GSM28776 4 0.4996 0.271 0.484 0.000 0.000 0.516
#> GSM28777 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM28797 4 0.2466 0.673 0.004 0.000 0.096 0.900
#> GSM28786 4 0.2999 0.657 0.004 0.000 0.132 0.864
#> GSM28800 1 0.3074 0.683 0.848 0.000 0.000 0.152
#> GSM11310 4 0.4948 0.374 0.440 0.000 0.000 0.560
#> GSM28787 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM11304 3 0.0592 0.983 0.000 0.000 0.984 0.016
#> GSM11303 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM11311 4 0.4164 0.569 0.264 0.000 0.000 0.736
#> GSM28799 4 0.4941 0.378 0.436 0.000 0.000 0.564
#> GSM28791 1 0.3528 0.631 0.808 0.000 0.000 0.192
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28780 1 0.4564 0.522 0.672 0.000 0.000 0.328
#> GSM28795 1 0.4643 0.502 0.656 0.000 0.000 0.344
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11297 3 0.1109 0.968 0.004 0.000 0.968 0.028
#> GSM11298 1 0.3074 0.683 0.848 0.000 0.000 0.152
#> GSM11314 4 0.5861 -0.213 0.476 0.000 0.032 0.492
#> GSM11299 3 0.0000 0.995 0.000 0.000 1.000 0.000
#> GSM28783 1 0.4543 0.527 0.676 0.000 0.000 0.324
#> GSM11308 1 0.5792 0.497 0.648 0.000 0.056 0.296
#> GSM28782 1 0.1474 0.684 0.948 0.000 0.000 0.052
#> GSM28779 1 0.3123 0.679 0.844 0.000 0.000 0.156
#> GSM11302 1 0.3074 0.683 0.848 0.000 0.000 0.152
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.0162 0.947 0.004 0.000 0.000 0.996 0.000
#> GSM28789 4 0.0162 0.947 0.000 0.000 0.000 0.996 0.004
#> GSM28790 1 0.0703 0.897 0.976 0.000 0.000 0.000 0.024
#> GSM11300 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.0880 0.892 0.968 0.000 0.000 0.000 0.032
#> GSM28792 1 0.0162 0.901 0.996 0.000 0.000 0.000 0.004
#> GSM11295 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM28793 1 0.0162 0.901 0.996 0.000 0.000 0.000 0.004
#> GSM11312 5 0.3209 0.786 0.180 0.000 0.000 0.008 0.812
#> GSM28778 5 0.0290 0.942 0.008 0.000 0.000 0.000 0.992
#> GSM28796 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.0162 0.947 0.000 0.000 0.004 0.996 0.000
#> GSM11315 1 0.0000 0.900 1.000 0.000 0.000 0.000 0.000
#> GSM11306 4 0.0671 0.938 0.004 0.000 0.000 0.980 0.016
#> GSM28776 1 0.4114 0.641 0.712 0.000 0.000 0.272 0.016
#> GSM28777 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.0000 0.947 0.000 0.000 0.000 1.000 0.000
#> GSM28786 4 0.0162 0.947 0.000 0.000 0.004 0.996 0.000
#> GSM28800 1 0.1121 0.882 0.956 0.000 0.000 0.000 0.044
#> GSM11310 1 0.4184 0.622 0.700 0.000 0.000 0.284 0.016
#> GSM28787 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM11304 3 0.2673 0.901 0.020 0.000 0.900 0.036 0.044
#> GSM11303 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.3534 0.633 0.256 0.000 0.000 0.744 0.000
#> GSM28799 1 0.4734 0.442 0.604 0.000 0.000 0.372 0.024
#> GSM28791 5 0.0162 0.944 0.004 0.000 0.000 0.000 0.996
#> GSM28794 2 0.0162 0.996 0.000 0.996 0.000 0.004 0.000
#> GSM28780 5 0.0000 0.944 0.000 0.000 0.000 0.000 1.000
#> GSM28795 5 0.0000 0.944 0.000 0.000 0.000 0.000 1.000
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11297 3 0.4452 0.795 0.048 0.000 0.796 0.104 0.052
#> GSM11298 1 0.0579 0.900 0.984 0.000 0.000 0.008 0.008
#> GSM11314 5 0.1012 0.926 0.000 0.000 0.012 0.020 0.968
#> GSM11299 3 0.0000 0.972 0.000 0.000 1.000 0.000 0.000
#> GSM28783 5 0.0000 0.944 0.000 0.000 0.000 0.000 1.000
#> GSM11308 5 0.0000 0.944 0.000 0.000 0.000 0.000 1.000
#> GSM28782 5 0.2773 0.813 0.164 0.000 0.000 0.000 0.836
#> GSM28779 1 0.0693 0.900 0.980 0.000 0.000 0.008 0.012
#> GSM11302 1 0.0693 0.900 0.980 0.000 0.000 0.008 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.1970 0.819 0.000 0.000 0.000 0.900 0.008 0.092
#> GSM28789 4 0.1970 0.819 0.000 0.000 0.000 0.900 0.008 0.092
#> GSM28790 1 0.0405 0.903 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM11300 3 0.1556 0.921 0.000 0.000 0.920 0.000 0.000 0.080
#> GSM28798 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0146 0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11307 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0291 0.908 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM28792 1 0.0146 0.909 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11295 3 0.0603 0.961 0.000 0.000 0.980 0.000 0.004 0.016
#> GSM28793 1 0.0146 0.909 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11312 5 0.5598 0.540 0.108 0.000 0.000 0.044 0.628 0.220
#> GSM28778 5 0.0260 0.883 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM28796 1 0.0260 0.909 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM11309 4 0.1588 0.843 0.000 0.000 0.004 0.924 0.000 0.072
#> GSM11315 1 0.0260 0.909 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM11306 4 0.1913 0.801 0.000 0.000 0.000 0.908 0.012 0.080
#> GSM28776 6 0.6193 0.236 0.360 0.000 0.000 0.228 0.008 0.404
#> GSM28777 3 0.0000 0.969 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.969 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0146 0.969 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM28797 4 0.1471 0.844 0.000 0.000 0.004 0.932 0.000 0.064
#> GSM28786 4 0.1588 0.843 0.000 0.000 0.004 0.924 0.000 0.072
#> GSM28800 6 0.3445 0.568 0.260 0.000 0.000 0.008 0.000 0.732
#> GSM11310 6 0.4154 0.654 0.144 0.000 0.000 0.112 0.000 0.744
#> GSM28787 3 0.0692 0.958 0.000 0.000 0.976 0.000 0.004 0.020
#> GSM11304 6 0.4248 0.549 0.008 0.000 0.220 0.036 0.008 0.728
#> GSM11303 3 0.0146 0.969 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM11317 3 0.0146 0.969 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM11311 4 0.4810 0.477 0.292 0.000 0.000 0.624 0.000 0.084
#> GSM28799 6 0.3815 0.659 0.132 0.000 0.000 0.092 0.000 0.776
#> GSM28791 5 0.1176 0.879 0.024 0.000 0.000 0.000 0.956 0.020
#> GSM28794 2 0.0520 0.986 0.000 0.984 0.000 0.008 0.000 0.008
#> GSM28780 5 0.0858 0.883 0.004 0.000 0.000 0.000 0.968 0.028
#> GSM28795 5 0.0260 0.883 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM11301 2 0.0146 0.996 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11297 6 0.4085 0.581 0.012 0.000 0.176 0.040 0.008 0.764
#> GSM11298 1 0.0935 0.893 0.964 0.000 0.000 0.004 0.000 0.032
#> GSM11314 5 0.0951 0.877 0.000 0.000 0.004 0.008 0.968 0.020
#> GSM11299 3 0.1957 0.892 0.000 0.000 0.888 0.000 0.000 0.112
#> GSM28783 5 0.1411 0.876 0.000 0.000 0.000 0.004 0.936 0.060
#> GSM11308 5 0.1531 0.874 0.004 0.000 0.000 0.000 0.928 0.068
#> GSM28782 5 0.4895 0.574 0.108 0.000 0.000 0.000 0.636 0.256
#> GSM28779 1 0.4359 0.448 0.652 0.000 0.000 0.028 0.008 0.312
#> GSM11302 1 0.3280 0.741 0.808 0.000 0.000 0.028 0.004 0.160
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 tissue(p) k
#> SD:skmeans 43 0.386 2
#> SD:skmeans 52 0.450 3
#> SD:skmeans 47 0.453 4
#> SD:skmeans 51 0.442 5
#> SD:skmeans 49 0.436 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.988 0.994 0.3835 0.618 0.618
#> 3 3 1.000 0.986 0.994 0.4541 0.817 0.706
#> 4 4 0.683 0.724 0.875 0.2297 0.898 0.771
#> 5 5 0.741 0.621 0.845 0.1196 0.916 0.758
#> 6 6 0.745 0.689 0.830 0.0611 0.885 0.590
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
#> GSM28788 1 0.000 0.996 1.000 0.000
#> GSM28789 1 0.000 0.996 1.000 0.000
#> GSM28790 1 0.000 0.996 1.000 0.000
#> GSM11300 1 0.000 0.996 1.000 0.000
#> GSM28798 2 0.000 0.989 0.000 1.000
#> GSM11296 2 0.000 0.989 0.000 1.000
#> GSM28801 2 0.000 0.989 0.000 1.000
#> GSM11319 2 0.000 0.989 0.000 1.000
#> GSM28781 2 0.000 0.989 0.000 1.000
#> GSM11305 2 0.000 0.989 0.000 1.000
#> GSM28784 2 0.000 0.989 0.000 1.000
#> GSM11307 2 0.000 0.989 0.000 1.000
#> GSM11313 2 0.000 0.989 0.000 1.000
#> GSM28785 2 0.000 0.989 0.000 1.000
#> GSM11318 1 0.000 0.996 1.000 0.000
#> GSM28792 1 0.000 0.996 1.000 0.000
#> GSM11295 1 0.000 0.996 1.000 0.000
#> GSM28793 1 0.000 0.996 1.000 0.000
#> GSM11312 1 0.000 0.996 1.000 0.000
#> GSM28778 1 0.000 0.996 1.000 0.000
#> GSM28796 1 0.000 0.996 1.000 0.000
#> GSM11309 1 0.000 0.996 1.000 0.000
#> GSM11315 1 0.000 0.996 1.000 0.000
#> GSM11306 1 0.000 0.996 1.000 0.000
#> GSM28776 1 0.000 0.996 1.000 0.000
#> GSM28777 1 0.000 0.996 1.000 0.000
#> GSM11316 2 0.552 0.852 0.128 0.872
#> GSM11320 1 0.000 0.996 1.000 0.000
#> GSM28797 1 0.000 0.996 1.000 0.000
#> GSM28786 1 0.000 0.996 1.000 0.000
#> GSM28800 1 0.000 0.996 1.000 0.000
#> GSM11310 1 0.000 0.996 1.000 0.000
#> GSM28787 1 0.000 0.996 1.000 0.000
#> GSM11304 1 0.000 0.996 1.000 0.000
#> GSM11303 1 0.204 0.964 0.968 0.032
#> GSM11317 1 0.574 0.842 0.864 0.136
#> GSM11311 1 0.000 0.996 1.000 0.000
#> GSM28799 1 0.000 0.996 1.000 0.000
#> GSM28791 1 0.000 0.996 1.000 0.000
#> GSM28794 2 0.000 0.989 0.000 1.000
#> GSM28780 1 0.000 0.996 1.000 0.000
#> GSM28795 1 0.000 0.996 1.000 0.000
#> GSM11301 2 0.000 0.989 0.000 1.000
#> GSM11297 1 0.000 0.996 1.000 0.000
#> GSM11298 1 0.000 0.996 1.000 0.000
#> GSM11314 1 0.000 0.996 1.000 0.000
#> GSM11299 1 0.000 0.996 1.000 0.000
#> GSM28783 1 0.000 0.996 1.000 0.000
#> GSM11308 1 0.000 0.996 1.000 0.000
#> GSM28782 1 0.000 0.996 1.000 0.000
#> GSM28779 1 0.000 0.996 1.000 0.000
#> GSM11302 1 0.000 0.996 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28789 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28790 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.999 0.000 0.000 1.000
#> GSM28798 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.989 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.989 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.989 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.989 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.999 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11309 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11315 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.999 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.999 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.999 0.000 0.000 1.000
#> GSM28797 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28786 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28800 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28787 1 0.4555 0.750 0.800 0.000 0.200
#> GSM11304 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11303 3 0.0000 0.999 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.999 0.000 0.000 1.000
#> GSM11311 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28799 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28794 2 0.2625 0.870 0.084 0.916 0.000
#> GSM28780 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11301 2 0.0000 0.989 0.000 1.000 0.000
#> GSM11297 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11298 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11314 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11299 3 0.0237 0.994 0.004 0.000 0.996
#> GSM28783 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.993 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.993 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.993 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.4955 -0.4017 0.556 0.000 0.000 0.444
#> GSM28789 1 0.4790 -0.2239 0.620 0.000 0.000 0.380
#> GSM28790 1 0.3172 0.7106 0.840 0.000 0.000 0.160
#> GSM11300 3 0.3873 0.7678 0.000 0.000 0.772 0.228
#> GSM28798 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11318 1 0.3172 0.7106 0.840 0.000 0.000 0.160
#> GSM28792 1 0.3172 0.7106 0.840 0.000 0.000 0.160
#> GSM11295 3 0.0000 0.9299 0.000 0.000 1.000 0.000
#> GSM28793 1 0.3172 0.7106 0.840 0.000 0.000 0.160
#> GSM11312 1 0.0000 0.7475 1.000 0.000 0.000 0.000
#> GSM28778 1 0.0000 0.7475 1.000 0.000 0.000 0.000
#> GSM28796 1 0.3172 0.7106 0.840 0.000 0.000 0.160
#> GSM11309 4 0.2973 0.5568 0.144 0.000 0.000 0.856
#> GSM11315 1 0.3172 0.7106 0.840 0.000 0.000 0.160
#> GSM11306 4 0.4981 0.5978 0.464 0.000 0.000 0.536
#> GSM28776 1 0.2408 0.7348 0.896 0.000 0.000 0.104
#> GSM28777 3 0.0000 0.9299 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.9299 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9299 0.000 0.000 1.000 0.000
#> GSM28797 4 0.4643 0.7021 0.344 0.000 0.000 0.656
#> GSM28786 4 0.4406 0.7073 0.300 0.000 0.000 0.700
#> GSM28800 1 0.4713 0.5492 0.640 0.000 0.000 0.360
#> GSM11310 1 0.2011 0.7235 0.920 0.000 0.000 0.080
#> GSM28787 1 0.4630 0.4417 0.768 0.000 0.196 0.036
#> GSM11304 1 0.4843 0.5235 0.604 0.000 0.000 0.396
#> GSM11303 3 0.0000 0.9299 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9299 0.000 0.000 1.000 0.000
#> GSM11311 4 0.4996 0.0619 0.484 0.000 0.000 0.516
#> GSM28799 1 0.3942 0.5748 0.764 0.000 0.000 0.236
#> GSM28791 1 0.0000 0.7475 1.000 0.000 0.000 0.000
#> GSM28794 2 0.3219 0.7377 0.164 0.836 0.000 0.000
#> GSM28780 1 0.0000 0.7475 1.000 0.000 0.000 0.000
#> GSM28795 1 0.3444 0.6269 0.816 0.000 0.000 0.184
#> GSM11301 2 0.0000 0.9801 0.000 1.000 0.000 0.000
#> GSM11297 1 0.4843 0.5235 0.604 0.000 0.000 0.396
#> GSM11298 1 0.0000 0.7475 1.000 0.000 0.000 0.000
#> GSM11314 1 0.1474 0.7474 0.948 0.000 0.000 0.052
#> GSM11299 3 0.4122 0.7556 0.004 0.000 0.760 0.236
#> GSM28783 1 0.1302 0.7323 0.956 0.000 0.000 0.044
#> GSM11308 1 0.3837 0.5901 0.776 0.000 0.000 0.224
#> GSM28782 1 0.0592 0.7432 0.984 0.000 0.000 0.016
#> GSM28779 1 0.0000 0.7475 1.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.7475 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.4909 -0.045348 0.560 0.000 0.000 0.412 0.028
#> GSM28789 1 0.4620 0.038436 0.592 0.000 0.000 0.392 0.016
#> GSM28790 1 0.4430 0.403083 0.540 0.000 0.000 0.004 0.456
#> GSM11300 5 0.4287 0.180135 0.000 0.000 0.460 0.000 0.540
#> GSM28798 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.4430 0.403083 0.540 0.000 0.000 0.004 0.456
#> GSM28792 1 0.4434 0.400483 0.536 0.000 0.000 0.004 0.460
#> GSM11295 3 0.0000 1.000000 0.000 0.000 1.000 0.000 0.000
#> GSM28793 1 0.4434 0.400483 0.536 0.000 0.000 0.004 0.460
#> GSM11312 1 0.0000 0.660729 1.000 0.000 0.000 0.000 0.000
#> GSM28778 1 0.0000 0.660729 1.000 0.000 0.000 0.000 0.000
#> GSM28796 1 0.4434 0.400483 0.536 0.000 0.000 0.004 0.460
#> GSM11309 4 0.0162 0.704071 0.000 0.000 0.000 0.996 0.004
#> GSM11315 1 0.4434 0.400483 0.536 0.000 0.000 0.004 0.460
#> GSM11306 4 0.4294 0.116864 0.468 0.000 0.000 0.532 0.000
#> GSM28776 1 0.4135 0.489466 0.656 0.000 0.000 0.004 0.340
#> GSM28777 3 0.0000 1.000000 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 1.000000 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 1.000000 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.0162 0.703447 0.004 0.000 0.000 0.996 0.000
#> GSM28786 4 0.0162 0.704071 0.000 0.000 0.000 0.996 0.004
#> GSM28800 5 0.1965 0.546415 0.096 0.000 0.000 0.000 0.904
#> GSM11310 1 0.3707 0.422755 0.716 0.000 0.000 0.000 0.284
#> GSM28787 1 0.5354 0.345833 0.668 0.000 0.192 0.000 0.140
#> GSM11304 5 0.0000 0.554744 0.000 0.000 0.000 0.000 1.000
#> GSM11303 3 0.0000 1.000000 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 1.000000 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.4404 0.430915 0.264 0.000 0.000 0.704 0.032
#> GSM28799 1 0.4262 -0.000992 0.560 0.000 0.000 0.000 0.440
#> GSM28791 1 0.0000 0.660729 1.000 0.000 0.000 0.000 0.000
#> GSM28794 2 0.4138 0.321019 0.384 0.616 0.000 0.000 0.000
#> GSM28780 1 0.0290 0.660489 0.992 0.000 0.000 0.000 0.008
#> GSM28795 1 0.0794 0.655442 0.972 0.000 0.000 0.000 0.028
#> GSM11301 2 0.0000 0.952320 0.000 1.000 0.000 0.000 0.000
#> GSM11297 5 0.0000 0.554744 0.000 0.000 0.000 0.000 1.000
#> GSM11298 1 0.0162 0.660639 0.996 0.000 0.000 0.000 0.004
#> GSM11314 1 0.2230 0.631429 0.884 0.000 0.000 0.000 0.116
#> GSM11299 5 0.4287 0.180135 0.000 0.000 0.460 0.000 0.540
#> GSM28783 1 0.2605 0.568305 0.852 0.000 0.000 0.000 0.148
#> GSM11308 5 0.4287 0.073284 0.460 0.000 0.000 0.000 0.540
#> GSM28782 1 0.2074 0.610884 0.896 0.000 0.000 0.000 0.104
#> GSM28779 1 0.0000 0.660729 1.000 0.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.660729 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 5 0.3554 0.6416 0.108 0.000 0.000 0.080 0.808 0.004
#> GSM28789 5 0.3598 0.6395 0.112 0.000 0.000 0.080 0.804 0.004
#> GSM28790 1 0.4819 0.8832 0.664 0.000 0.000 0.000 0.132 0.204
#> GSM11300 6 0.2969 0.6057 0.000 0.000 0.224 0.000 0.000 0.776
#> GSM28798 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.4819 0.8832 0.664 0.000 0.000 0.000 0.132 0.204
#> GSM28792 1 0.4783 0.8843 0.668 0.000 0.000 0.000 0.128 0.204
#> GSM11295 3 0.2454 0.7815 0.160 0.000 0.840 0.000 0.000 0.000
#> GSM28793 1 0.4957 0.8587 0.648 0.000 0.000 0.000 0.148 0.204
#> GSM11312 5 0.3390 0.6117 0.296 0.000 0.000 0.000 0.704 0.000
#> GSM28778 5 0.1765 0.7455 0.096 0.000 0.000 0.000 0.904 0.000
#> GSM28796 1 0.4707 0.8828 0.676 0.000 0.000 0.000 0.120 0.204
#> GSM11309 4 0.0000 0.6610 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM11315 1 0.4707 0.8828 0.676 0.000 0.000 0.000 0.120 0.204
#> GSM11306 4 0.5959 -0.0937 0.224 0.000 0.000 0.416 0.360 0.000
#> GSM28776 1 0.3563 0.0868 0.664 0.000 0.000 0.000 0.336 0.000
#> GSM28777 3 0.0000 0.9590 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.9590 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.9590 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.0000 0.6610 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28786 4 0.0000 0.6610 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28800 6 0.4503 0.4532 0.192 0.000 0.000 0.000 0.108 0.700
#> GSM11310 5 0.4787 0.3850 0.432 0.000 0.000 0.000 0.516 0.052
#> GSM28787 6 0.7586 0.2045 0.224 0.000 0.188 0.000 0.240 0.348
#> GSM11304 6 0.0146 0.6493 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM11303 3 0.0000 0.9590 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.9590 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.5873 -0.1415 0.376 0.000 0.000 0.492 0.104 0.028
#> GSM28799 6 0.5377 0.4466 0.272 0.000 0.000 0.000 0.156 0.572
#> GSM28791 5 0.0713 0.7474 0.028 0.000 0.000 0.000 0.972 0.000
#> GSM28794 2 0.3817 0.1683 0.000 0.568 0.000 0.000 0.432 0.000
#> GSM28780 5 0.4377 -0.0737 0.024 0.000 0.000 0.000 0.540 0.436
#> GSM28795 5 0.4905 0.4471 0.096 0.000 0.000 0.000 0.620 0.284
#> GSM11301 2 0.0000 0.9500 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.0146 0.6493 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM11298 5 0.1556 0.7523 0.080 0.000 0.000 0.000 0.920 0.000
#> GSM11314 5 0.4468 0.4747 0.408 0.000 0.000 0.000 0.560 0.032
#> GSM11299 6 0.2854 0.6166 0.000 0.000 0.208 0.000 0.000 0.792
#> GSM28783 5 0.2985 0.7406 0.100 0.000 0.000 0.000 0.844 0.056
#> GSM11308 6 0.3266 0.5618 0.000 0.000 0.000 0.000 0.272 0.728
#> GSM28782 5 0.1010 0.7366 0.004 0.000 0.000 0.000 0.960 0.036
#> GSM28779 5 0.1444 0.7532 0.072 0.000 0.000 0.000 0.928 0.000
#> GSM11302 5 0.1387 0.7538 0.068 0.000 0.000 0.000 0.932 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 tissue(p) k
#> SD:pam 52 0.396 2
#> SD:pam 52 0.372 3
#> SD:pam 48 0.508 4
#> SD:pam 34 0.388 5
#> SD:pam 41 0.492 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.699 0.935 0.958 0.4658 0.509 0.509
#> 3 3 0.999 0.964 0.979 0.2579 0.919 0.840
#> 4 4 0.736 0.807 0.887 0.2251 0.873 0.704
#> 5 5 0.713 0.540 0.801 0.0596 0.983 0.942
#> 6 6 0.740 0.502 0.736 0.0259 0.840 0.499
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
#> GSM28788 1 0.000 0.994 1.000 0.000
#> GSM28789 1 0.000 0.994 1.000 0.000
#> GSM28790 1 0.000 0.994 1.000 0.000
#> GSM11300 2 0.697 0.854 0.188 0.812
#> GSM28798 2 0.000 0.892 0.000 1.000
#> GSM11296 2 0.000 0.892 0.000 1.000
#> GSM28801 2 0.000 0.892 0.000 1.000
#> GSM11319 2 0.000 0.892 0.000 1.000
#> GSM28781 2 0.000 0.892 0.000 1.000
#> GSM11305 2 0.000 0.892 0.000 1.000
#> GSM28784 2 0.000 0.892 0.000 1.000
#> GSM11307 2 0.000 0.892 0.000 1.000
#> GSM11313 2 0.000 0.892 0.000 1.000
#> GSM28785 2 0.000 0.892 0.000 1.000
#> GSM11318 1 0.000 0.994 1.000 0.000
#> GSM28792 1 0.000 0.994 1.000 0.000
#> GSM11295 2 0.697 0.854 0.188 0.812
#> GSM28793 1 0.000 0.994 1.000 0.000
#> GSM11312 1 0.000 0.994 1.000 0.000
#> GSM28778 1 0.000 0.994 1.000 0.000
#> GSM28796 1 0.000 0.994 1.000 0.000
#> GSM11309 1 0.000 0.994 1.000 0.000
#> GSM11315 1 0.000 0.994 1.000 0.000
#> GSM11306 1 0.000 0.994 1.000 0.000
#> GSM28776 1 0.000 0.994 1.000 0.000
#> GSM28777 2 0.697 0.854 0.188 0.812
#> GSM11316 2 0.697 0.854 0.188 0.812
#> GSM11320 2 0.697 0.854 0.188 0.812
#> GSM28797 1 0.000 0.994 1.000 0.000
#> GSM28786 1 0.000 0.994 1.000 0.000
#> GSM28800 1 0.000 0.994 1.000 0.000
#> GSM11310 1 0.000 0.994 1.000 0.000
#> GSM28787 2 0.697 0.854 0.188 0.812
#> GSM11304 1 0.625 0.781 0.844 0.156
#> GSM11303 2 0.697 0.854 0.188 0.812
#> GSM11317 2 0.697 0.854 0.188 0.812
#> GSM11311 1 0.000 0.994 1.000 0.000
#> GSM28799 1 0.000 0.994 1.000 0.000
#> GSM28791 1 0.000 0.994 1.000 0.000
#> GSM28794 2 0.900 0.543 0.316 0.684
#> GSM28780 1 0.000 0.994 1.000 0.000
#> GSM28795 1 0.000 0.994 1.000 0.000
#> GSM11301 2 0.000 0.892 0.000 1.000
#> GSM11297 1 0.000 0.994 1.000 0.000
#> GSM11298 1 0.000 0.994 1.000 0.000
#> GSM11314 1 0.000 0.994 1.000 0.000
#> GSM11299 2 0.697 0.854 0.188 0.812
#> GSM28783 1 0.000 0.994 1.000 0.000
#> GSM11308 1 0.000 0.994 1.000 0.000
#> GSM28782 1 0.000 0.994 1.000 0.000
#> GSM28779 1 0.000 0.994 1.000 0.000
#> GSM11302 1 0.000 0.994 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.2939 0.926 0.916 0.012 0.072
#> GSM28789 1 0.4370 0.888 0.868 0.056 0.076
#> GSM28790 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11300 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28798 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.996 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.996 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.996 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.996 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11295 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28778 1 0.1411 0.952 0.964 0.000 0.036
#> GSM28796 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11309 1 0.2356 0.932 0.928 0.000 0.072
#> GSM11315 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11306 1 0.2774 0.928 0.920 0.008 0.072
#> GSM28776 1 0.0424 0.961 0.992 0.008 0.000
#> GSM28777 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11316 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11320 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28797 1 0.2356 0.932 0.928 0.000 0.072
#> GSM28786 1 0.2356 0.932 0.928 0.000 0.072
#> GSM28800 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28787 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11304 1 0.4750 0.741 0.784 0.000 0.216
#> GSM11303 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11317 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11311 1 0.2584 0.934 0.928 0.008 0.064
#> GSM28799 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28794 2 0.1647 0.952 0.004 0.960 0.036
#> GSM28780 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11301 2 0.0000 0.996 0.000 1.000 0.000
#> GSM11297 1 0.3412 0.865 0.876 0.000 0.124
#> GSM11298 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11314 1 0.2711 0.921 0.912 0.000 0.088
#> GSM11299 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11308 1 0.0747 0.958 0.984 0.000 0.016
#> GSM28782 1 0.0000 0.965 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.965 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.965 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.4277 0.753 0.280 0.00 0.000 0.720
#> GSM28789 4 0.3900 0.810 0.164 0.02 0.000 0.816
#> GSM28790 1 0.0707 0.801 0.980 0.00 0.000 0.020
#> GSM11300 3 0.0188 0.995 0.000 0.00 0.996 0.004
#> GSM28798 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11296 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM28801 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11319 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM28781 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11305 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM28784 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11307 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11313 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM28785 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11318 1 0.1716 0.781 0.936 0.00 0.000 0.064
#> GSM28792 1 0.1792 0.799 0.932 0.00 0.000 0.068
#> GSM11295 3 0.0000 0.997 0.000 0.00 1.000 0.000
#> GSM28793 1 0.1867 0.798 0.928 0.00 0.000 0.072
#> GSM11312 1 0.0000 0.798 1.000 0.00 0.000 0.000
#> GSM28778 1 0.3569 0.668 0.804 0.00 0.000 0.196
#> GSM28796 1 0.1792 0.799 0.932 0.00 0.000 0.068
#> GSM11309 4 0.2149 0.818 0.088 0.00 0.000 0.912
#> GSM11315 1 0.1867 0.797 0.928 0.00 0.000 0.072
#> GSM11306 4 0.4585 0.691 0.332 0.00 0.000 0.668
#> GSM28776 1 0.3444 0.722 0.816 0.00 0.000 0.184
#> GSM28777 3 0.0000 0.997 0.000 0.00 1.000 0.000
#> GSM11316 3 0.0188 0.997 0.000 0.00 0.996 0.004
#> GSM11320 3 0.0188 0.997 0.000 0.00 0.996 0.004
#> GSM28797 4 0.2149 0.818 0.088 0.00 0.000 0.912
#> GSM28786 4 0.2149 0.818 0.088 0.00 0.000 0.912
#> GSM28800 1 0.1716 0.800 0.936 0.00 0.000 0.064
#> GSM11310 1 0.3528 0.664 0.808 0.00 0.000 0.192
#> GSM28787 3 0.0188 0.994 0.004 0.00 0.996 0.000
#> GSM11304 1 0.6991 0.301 0.524 0.00 0.128 0.348
#> GSM11303 3 0.0188 0.997 0.000 0.00 0.996 0.004
#> GSM11317 3 0.0188 0.997 0.000 0.00 0.996 0.004
#> GSM11311 4 0.4730 0.633 0.364 0.00 0.000 0.636
#> GSM28799 1 0.5174 0.474 0.620 0.00 0.012 0.368
#> GSM28791 1 0.2081 0.773 0.916 0.00 0.000 0.084
#> GSM28794 2 0.4907 0.311 0.000 0.58 0.000 0.420
#> GSM28780 1 0.2216 0.773 0.908 0.00 0.000 0.092
#> GSM28795 1 0.2814 0.763 0.868 0.00 0.000 0.132
#> GSM11301 2 0.0000 0.961 0.000 1.00 0.000 0.000
#> GSM11297 1 0.6296 0.367 0.548 0.00 0.064 0.388
#> GSM11298 1 0.1792 0.799 0.932 0.00 0.000 0.068
#> GSM11314 1 0.5055 0.497 0.624 0.00 0.008 0.368
#> GSM11299 3 0.0188 0.995 0.000 0.00 0.996 0.004
#> GSM28783 1 0.2149 0.774 0.912 0.00 0.000 0.088
#> GSM11308 1 0.4855 0.465 0.600 0.00 0.000 0.400
#> GSM28782 1 0.2011 0.774 0.920 0.00 0.000 0.080
#> GSM28779 1 0.2081 0.791 0.916 0.00 0.000 0.084
#> GSM11302 1 0.1792 0.799 0.932 0.00 0.000 0.068
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.3061 0.79454 0.136 0.000 0.000 0.844 0.020
#> GSM28789 4 0.3059 0.79974 0.120 0.008 0.000 0.856 0.016
#> GSM28790 1 0.2127 0.46794 0.892 0.000 0.000 0.000 0.108
#> GSM11300 3 0.3750 0.84035 0.000 0.000 0.756 0.012 0.232
#> GSM28798 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.2471 0.43189 0.864 0.000 0.000 0.000 0.136
#> GSM28792 1 0.1981 0.52687 0.924 0.000 0.000 0.028 0.048
#> GSM11295 3 0.3857 0.81957 0.000 0.000 0.688 0.000 0.312
#> GSM28793 1 0.1830 0.52886 0.924 0.000 0.000 0.068 0.008
#> GSM11312 1 0.2331 0.49801 0.900 0.000 0.000 0.020 0.080
#> GSM28778 1 0.4597 0.15912 0.696 0.000 0.000 0.044 0.260
#> GSM28796 1 0.1386 0.53304 0.952 0.000 0.000 0.032 0.016
#> GSM11309 4 0.1914 0.79824 0.016 0.000 0.000 0.924 0.060
#> GSM11315 1 0.2470 0.51202 0.884 0.000 0.000 0.104 0.012
#> GSM11306 4 0.3690 0.73304 0.200 0.000 0.000 0.780 0.020
#> GSM28776 1 0.4823 0.21409 0.672 0.000 0.000 0.276 0.052
#> GSM28777 3 0.1908 0.86096 0.000 0.000 0.908 0.000 0.092
#> GSM11316 3 0.0162 0.85987 0.000 0.000 0.996 0.000 0.004
#> GSM11320 3 0.0000 0.85985 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.1914 0.79824 0.016 0.000 0.000 0.924 0.060
#> GSM28786 4 0.1914 0.79824 0.016 0.000 0.000 0.924 0.060
#> GSM28800 1 0.1195 0.53362 0.960 0.000 0.000 0.028 0.012
#> GSM11310 1 0.5087 0.18442 0.644 0.000 0.000 0.292 0.064
#> GSM28787 3 0.4713 0.72852 0.000 0.000 0.544 0.016 0.440
#> GSM11304 1 0.7532 -0.23361 0.448 0.000 0.072 0.168 0.312
#> GSM11303 3 0.0000 0.85985 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.85985 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.5255 0.32764 0.388 0.000 0.000 0.560 0.052
#> GSM28799 1 0.5840 -0.00614 0.604 0.000 0.000 0.232 0.164
#> GSM28791 1 0.4150 -0.23553 0.612 0.000 0.000 0.000 0.388
#> GSM28794 2 0.5636 0.56951 0.072 0.680 0.000 0.208 0.040
#> GSM28780 1 0.4235 -0.35935 0.576 0.000 0.000 0.000 0.424
#> GSM28795 1 0.4291 -0.48810 0.536 0.000 0.000 0.000 0.464
#> GSM11301 2 0.0000 0.97134 0.000 1.000 0.000 0.000 0.000
#> GSM11297 1 0.7291 -0.20908 0.460 0.000 0.044 0.192 0.304
#> GSM11298 1 0.1469 0.53063 0.948 0.000 0.000 0.036 0.016
#> GSM11314 1 0.6392 -0.65756 0.472 0.000 0.012 0.120 0.396
#> GSM11299 3 0.4444 0.79101 0.000 0.000 0.624 0.012 0.364
#> GSM28783 1 0.3837 -0.02753 0.692 0.000 0.000 0.000 0.308
#> GSM11308 5 0.5488 0.00000 0.428 0.000 0.000 0.064 0.508
#> GSM28782 1 0.2773 0.37060 0.836 0.000 0.000 0.000 0.164
#> GSM28779 1 0.2362 0.51559 0.900 0.000 0.000 0.076 0.024
#> GSM11302 1 0.1648 0.53063 0.940 0.000 0.000 0.040 0.020
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 1 0.5595 -0.1549 0.536 0.000 0.000 0.148 0.004 0.312
#> GSM28789 1 0.5317 -0.1113 0.568 0.000 0.000 0.112 0.004 0.316
#> GSM28790 5 0.2762 0.5421 0.196 0.000 0.000 0.000 0.804 0.000
#> GSM11300 3 0.0000 0.7947 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28798 2 0.0000 0.9612 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9612 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0146 0.9601 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM11319 2 0.0000 0.9612 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9612 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0146 0.9603 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM28784 2 0.0146 0.9601 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM11307 2 0.0146 0.9603 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11313 2 0.0146 0.9603 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM28785 2 0.0000 0.9612 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 5 0.2048 0.5883 0.120 0.000 0.000 0.000 0.880 0.000
#> GSM28792 5 0.4018 0.1042 0.412 0.000 0.000 0.008 0.580 0.000
#> GSM11295 3 0.1814 0.7395 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM28793 1 0.4929 0.3488 0.556 0.000 0.000 0.024 0.392 0.028
#> GSM11312 5 0.3797 0.0337 0.420 0.000 0.000 0.000 0.580 0.000
#> GSM28778 5 0.2593 0.5702 0.148 0.000 0.008 0.000 0.844 0.000
#> GSM28796 1 0.4002 0.3284 0.588 0.000 0.000 0.008 0.404 0.000
#> GSM11309 4 0.0547 0.9936 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM11315 1 0.6591 0.1636 0.408 0.000 0.000 0.124 0.396 0.072
#> GSM11306 1 0.5317 -0.1077 0.568 0.000 0.000 0.112 0.004 0.316
#> GSM28776 1 0.6269 0.3175 0.456 0.000 0.000 0.076 0.388 0.080
#> GSM28777 3 0.3578 0.1944 0.000 0.000 0.660 0.000 0.000 0.340
#> GSM11316 6 0.3866 0.2508 0.000 0.000 0.484 0.000 0.000 0.516
#> GSM11320 6 0.3866 0.2508 0.000 0.000 0.484 0.000 0.000 0.516
#> GSM28797 4 0.0458 0.9968 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM28786 4 0.0458 0.9968 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM28800 1 0.3804 0.2982 0.576 0.000 0.000 0.000 0.424 0.000
#> GSM11310 5 0.7335 -0.0233 0.160 0.000 0.000 0.164 0.392 0.284
#> GSM28787 3 0.1856 0.7459 0.048 0.000 0.920 0.000 0.000 0.032
#> GSM11304 5 0.6244 -0.2721 0.424 0.000 0.096 0.008 0.432 0.040
#> GSM11303 6 0.3866 0.2508 0.000 0.000 0.484 0.000 0.000 0.516
#> GSM11317 6 0.3866 0.2508 0.000 0.000 0.484 0.000 0.000 0.516
#> GSM11311 6 0.7567 -0.5478 0.256 0.000 0.000 0.152 0.296 0.296
#> GSM28799 1 0.6150 0.3313 0.492 0.000 0.020 0.056 0.384 0.048
#> GSM28791 5 0.2553 0.5996 0.000 0.000 0.000 0.008 0.848 0.144
#> GSM28794 2 0.4631 0.4682 0.364 0.600 0.000 0.008 0.008 0.020
#> GSM28780 5 0.2805 0.5936 0.000 0.000 0.000 0.012 0.828 0.160
#> GSM28795 5 0.3056 0.5949 0.008 0.000 0.000 0.012 0.820 0.160
#> GSM11301 2 0.0260 0.9572 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM11297 1 0.6302 0.2819 0.472 0.000 0.072 0.024 0.392 0.040
#> GSM11298 1 0.3915 0.3408 0.584 0.000 0.000 0.004 0.412 0.000
#> GSM11314 5 0.3610 0.5564 0.136 0.000 0.024 0.020 0.812 0.008
#> GSM11299 3 0.0000 0.7947 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28783 5 0.2631 0.5566 0.152 0.000 0.000 0.000 0.840 0.008
#> GSM11308 5 0.3465 0.5948 0.024 0.000 0.000 0.016 0.804 0.156
#> GSM28782 5 0.2373 0.6055 0.084 0.000 0.000 0.004 0.888 0.024
#> GSM28779 1 0.4018 0.3432 0.580 0.000 0.000 0.008 0.412 0.000
#> GSM11302 1 0.3804 0.3192 0.576 0.000 0.000 0.000 0.424 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 tissue(p) k
#> SD:mclust 52 0.396 2
#> SD:mclust 52 0.372 3
#> SD:mclust 46 0.447 4
#> SD:mclust 35 0.456 5
#> SD:mclust 28 0.388 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.966 0.986 0.386 0.618 0.618
#> 3 3 1.000 0.997 0.998 0.487 0.765 0.633
#> 4 4 0.751 0.801 0.871 0.256 0.861 0.675
#> 5 5 0.905 0.863 0.937 0.106 0.881 0.611
#> 6 6 0.876 0.770 0.888 0.041 0.956 0.790
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.1184 0.973 0.984 0.016
#> GSM28789 2 0.8327 0.631 0.264 0.736
#> GSM28790 1 0.0000 0.988 1.000 0.000
#> GSM11300 1 0.0000 0.988 1.000 0.000
#> GSM28798 2 0.0000 0.977 0.000 1.000
#> GSM11296 2 0.0000 0.977 0.000 1.000
#> GSM28801 2 0.0000 0.977 0.000 1.000
#> GSM11319 2 0.0000 0.977 0.000 1.000
#> GSM28781 2 0.0000 0.977 0.000 1.000
#> GSM11305 2 0.0000 0.977 0.000 1.000
#> GSM28784 2 0.0000 0.977 0.000 1.000
#> GSM11307 2 0.0000 0.977 0.000 1.000
#> GSM11313 2 0.0000 0.977 0.000 1.000
#> GSM28785 2 0.0000 0.977 0.000 1.000
#> GSM11318 1 0.0000 0.988 1.000 0.000
#> GSM28792 1 0.0000 0.988 1.000 0.000
#> GSM11295 1 0.0000 0.988 1.000 0.000
#> GSM28793 1 0.0000 0.988 1.000 0.000
#> GSM11312 1 0.0000 0.988 1.000 0.000
#> GSM28778 1 0.9170 0.488 0.668 0.332
#> GSM28796 1 0.0000 0.988 1.000 0.000
#> GSM11309 1 0.0000 0.988 1.000 0.000
#> GSM11315 1 0.0000 0.988 1.000 0.000
#> GSM11306 1 0.0000 0.988 1.000 0.000
#> GSM28776 1 0.0000 0.988 1.000 0.000
#> GSM28777 1 0.0000 0.988 1.000 0.000
#> GSM11316 1 0.4690 0.882 0.900 0.100
#> GSM11320 1 0.0000 0.988 1.000 0.000
#> GSM28797 1 0.0000 0.988 1.000 0.000
#> GSM28786 1 0.0000 0.988 1.000 0.000
#> GSM28800 1 0.0000 0.988 1.000 0.000
#> GSM11310 1 0.0000 0.988 1.000 0.000
#> GSM28787 1 0.0376 0.984 0.996 0.004
#> GSM11304 1 0.0000 0.988 1.000 0.000
#> GSM11303 1 0.0000 0.988 1.000 0.000
#> GSM11317 1 0.0000 0.988 1.000 0.000
#> GSM11311 1 0.0000 0.988 1.000 0.000
#> GSM28799 1 0.0000 0.988 1.000 0.000
#> GSM28791 1 0.0000 0.988 1.000 0.000
#> GSM28794 2 0.0000 0.977 0.000 1.000
#> GSM28780 1 0.0000 0.988 1.000 0.000
#> GSM28795 1 0.0000 0.988 1.000 0.000
#> GSM11301 2 0.0000 0.977 0.000 1.000
#> GSM11297 1 0.0000 0.988 1.000 0.000
#> GSM11298 1 0.0000 0.988 1.000 0.000
#> GSM11314 1 0.0000 0.988 1.000 0.000
#> GSM11299 1 0.0000 0.988 1.000 0.000
#> GSM28783 1 0.0000 0.988 1.000 0.000
#> GSM11308 1 0.0000 0.988 1.000 0.000
#> GSM28782 1 0.0000 0.988 1.000 0.000
#> GSM28779 1 0.0000 0.988 1.000 0.000
#> GSM11302 1 0.0000 0.988 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28789 1 0.1753 0.949 0.952 0.048 0.000
#> GSM28790 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11300 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11295 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11309 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11315 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28777 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11316 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11320 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28797 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28786 1 0.0747 0.984 0.984 0.000 0.016
#> GSM28800 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28787 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11304 1 0.0592 0.987 0.988 0.000 0.012
#> GSM11303 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11317 3 0.0000 1.000 0.000 0.000 1.000
#> GSM11311 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28799 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28780 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11297 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11298 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11314 1 0.0424 0.991 0.992 0.000 0.008
#> GSM11299 3 0.0000 1.000 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.997 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.0336 0.885 0.008 0.000 0.000 0.992
#> GSM28789 4 0.3048 0.756 0.016 0.108 0.000 0.876
#> GSM28790 1 0.4250 0.702 0.724 0.000 0.000 0.276
#> GSM11300 3 0.0188 0.971 0.000 0.000 0.996 0.004
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.2345 0.696 0.900 0.000 0.000 0.100
#> GSM28792 1 0.4624 0.690 0.660 0.000 0.000 0.340
#> GSM11295 3 0.2300 0.924 0.064 0.000 0.920 0.016
#> GSM28793 1 0.4679 0.683 0.648 0.000 0.000 0.352
#> GSM11312 1 0.3726 0.697 0.788 0.000 0.000 0.212
#> GSM28778 1 0.2216 0.641 0.908 0.000 0.000 0.092
#> GSM28796 1 0.4679 0.683 0.648 0.000 0.000 0.352
#> GSM11309 4 0.0336 0.886 0.008 0.000 0.000 0.992
#> GSM11315 1 0.4713 0.675 0.640 0.000 0.000 0.360
#> GSM11306 4 0.0707 0.877 0.020 0.000 0.000 0.980
#> GSM28776 1 0.4948 0.541 0.560 0.000 0.000 0.440
#> GSM28777 3 0.0188 0.971 0.000 0.000 0.996 0.004
#> GSM11316 3 0.0188 0.971 0.000 0.000 0.996 0.004
#> GSM11320 3 0.0000 0.970 0.000 0.000 1.000 0.000
#> GSM28797 4 0.0188 0.885 0.004 0.000 0.000 0.996
#> GSM28786 4 0.0336 0.886 0.008 0.000 0.000 0.992
#> GSM28800 1 0.4643 0.687 0.656 0.000 0.000 0.344
#> GSM11310 4 0.4661 0.133 0.348 0.000 0.000 0.652
#> GSM28787 3 0.4150 0.843 0.120 0.000 0.824 0.056
#> GSM11304 1 0.4459 0.692 0.780 0.000 0.032 0.188
#> GSM11303 3 0.0000 0.970 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0188 0.971 0.000 0.000 0.996 0.004
#> GSM11311 4 0.1302 0.854 0.044 0.000 0.000 0.956
#> GSM28799 1 0.4992 0.472 0.524 0.000 0.000 0.476
#> GSM28791 1 0.1211 0.654 0.960 0.000 0.000 0.040
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28780 1 0.2149 0.629 0.912 0.000 0.000 0.088
#> GSM28795 1 0.2530 0.610 0.888 0.000 0.000 0.112
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11297 1 0.5193 0.601 0.580 0.000 0.008 0.412
#> GSM11298 1 0.4643 0.687 0.656 0.000 0.000 0.344
#> GSM11314 1 0.2859 0.604 0.880 0.000 0.008 0.112
#> GSM11299 3 0.0000 0.970 0.000 0.000 1.000 0.000
#> GSM28783 1 0.2647 0.602 0.880 0.000 0.000 0.120
#> GSM11308 1 0.2081 0.632 0.916 0.000 0.000 0.084
#> GSM28782 1 0.1716 0.687 0.936 0.000 0.000 0.064
#> GSM28779 1 0.4643 0.687 0.656 0.000 0.000 0.344
#> GSM11302 1 0.4661 0.686 0.652 0.000 0.000 0.348
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.0324 0.9860 0.004 0 0.000 0.992 0.004
#> GSM28789 4 0.0324 0.9860 0.004 0 0.000 0.992 0.004
#> GSM28790 1 0.0880 0.8821 0.968 0 0.000 0.000 0.032
#> GSM11300 3 0.0290 0.9429 0.000 0 0.992 0.008 0.000
#> GSM28798 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11318 1 0.0703 0.8844 0.976 0 0.000 0.000 0.024
#> GSM28792 1 0.0404 0.8852 0.988 0 0.000 0.000 0.012
#> GSM11295 3 0.4135 0.4924 0.000 0 0.656 0.004 0.340
#> GSM28793 1 0.0000 0.8866 1.000 0 0.000 0.000 0.000
#> GSM11312 5 0.4709 0.3196 0.364 0 0.000 0.024 0.612
#> GSM28778 5 0.2561 0.7744 0.144 0 0.000 0.000 0.856
#> GSM28796 1 0.0000 0.8866 1.000 0 0.000 0.000 0.000
#> GSM11309 4 0.0162 0.9843 0.000 0 0.000 0.996 0.004
#> GSM11315 1 0.0000 0.8866 1.000 0 0.000 0.000 0.000
#> GSM11306 4 0.0451 0.9842 0.004 0 0.000 0.988 0.008
#> GSM28776 1 0.2236 0.8623 0.908 0 0.000 0.068 0.024
#> GSM28777 3 0.0162 0.9447 0.000 0 0.996 0.004 0.000
#> GSM11316 3 0.0566 0.9387 0.000 0 0.984 0.004 0.012
#> GSM11320 3 0.0000 0.9448 0.000 0 1.000 0.000 0.000
#> GSM28797 4 0.0000 0.9852 0.000 0 0.000 1.000 0.000
#> GSM28786 4 0.0000 0.9852 0.000 0 0.000 1.000 0.000
#> GSM28800 1 0.0671 0.8859 0.980 0 0.000 0.004 0.016
#> GSM11310 1 0.3452 0.7115 0.756 0 0.000 0.244 0.000
#> GSM28787 5 0.4621 0.0648 0.004 0 0.412 0.008 0.576
#> GSM11304 1 0.5418 0.6173 0.684 0 0.092 0.016 0.208
#> GSM11303 3 0.0000 0.9448 0.000 0 1.000 0.000 0.000
#> GSM11317 3 0.0162 0.9447 0.000 0 0.996 0.004 0.000
#> GSM11311 4 0.1197 0.9423 0.048 0 0.000 0.952 0.000
#> GSM28799 1 0.3086 0.7899 0.816 0 0.000 0.180 0.004
#> GSM28791 5 0.1270 0.8437 0.052 0 0.000 0.000 0.948
#> GSM28794 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28780 5 0.0880 0.8508 0.032 0 0.000 0.000 0.968
#> GSM28795 5 0.0510 0.8486 0.016 0 0.000 0.000 0.984
#> GSM11301 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11297 1 0.4301 0.7946 0.800 0 0.052 0.116 0.032
#> GSM11298 1 0.0404 0.8862 0.988 0 0.000 0.000 0.012
#> GSM11314 5 0.0510 0.8486 0.016 0 0.000 0.000 0.984
#> GSM11299 3 0.0000 0.9448 0.000 0 1.000 0.000 0.000
#> GSM28783 5 0.0794 0.8511 0.028 0 0.000 0.000 0.972
#> GSM11308 5 0.0510 0.8486 0.016 0 0.000 0.000 0.984
#> GSM28782 1 0.4306 0.0307 0.508 0 0.000 0.000 0.492
#> GSM28779 1 0.1117 0.8859 0.964 0 0.000 0.016 0.020
#> GSM11302 1 0.1117 0.8864 0.964 0 0.000 0.016 0.020
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.0551 0.9841 0.004 0.004 0.000 0.984 0.000 0.008
#> GSM28789 4 0.0405 0.9842 0.000 0.004 0.000 0.988 0.000 0.008
#> GSM28790 1 0.0972 0.8024 0.964 0.000 0.000 0.000 0.008 0.028
#> GSM11300 3 0.2362 0.7044 0.000 0.000 0.860 0.004 0.000 0.136
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.1049 0.7907 0.960 0.000 0.000 0.000 0.008 0.032
#> GSM28792 1 0.1765 0.7473 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM11295 3 0.6127 0.0867 0.036 0.000 0.432 0.004 0.100 0.428
#> GSM28793 1 0.0547 0.7972 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM11312 5 0.4220 0.6782 0.104 0.000 0.000 0.032 0.776 0.088
#> GSM28778 5 0.1010 0.8604 0.004 0.000 0.000 0.000 0.960 0.036
#> GSM28796 1 0.0713 0.8022 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM11309 4 0.0508 0.9854 0.004 0.000 0.000 0.984 0.000 0.012
#> GSM11315 1 0.0632 0.8018 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM11306 4 0.0603 0.9793 0.004 0.000 0.000 0.980 0.000 0.016
#> GSM28776 1 0.3248 0.6682 0.804 0.000 0.000 0.032 0.000 0.164
#> GSM28777 3 0.2100 0.7348 0.004 0.000 0.884 0.000 0.000 0.112
#> GSM11316 3 0.1075 0.7667 0.000 0.000 0.952 0.000 0.000 0.048
#> GSM11320 3 0.0458 0.7804 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM28797 4 0.0146 0.9863 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM28786 4 0.0291 0.9865 0.004 0.000 0.000 0.992 0.000 0.004
#> GSM28800 1 0.4543 0.2903 0.576 0.000 0.000 0.000 0.040 0.384
#> GSM11310 1 0.5812 0.1631 0.488 0.000 0.000 0.172 0.004 0.336
#> GSM28787 6 0.7255 -0.1724 0.068 0.000 0.256 0.016 0.232 0.428
#> GSM11304 6 0.6936 0.4529 0.192 0.000 0.156 0.004 0.136 0.512
#> GSM11303 3 0.0713 0.7777 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM11317 3 0.0146 0.7799 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM11311 4 0.0820 0.9741 0.016 0.000 0.000 0.972 0.000 0.012
#> GSM28799 1 0.5305 0.3261 0.564 0.000 0.000 0.108 0.004 0.324
#> GSM28791 5 0.0508 0.8723 0.004 0.000 0.000 0.000 0.984 0.012
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28780 5 0.0363 0.8730 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM28795 5 0.0260 0.8715 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.6880 0.3866 0.248 0.000 0.168 0.024 0.052 0.508
#> GSM11298 1 0.0713 0.8027 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM11314 5 0.1267 0.8373 0.000 0.000 0.000 0.000 0.940 0.060
#> GSM11299 3 0.3847 0.3748 0.000 0.000 0.644 0.000 0.008 0.348
#> GSM28783 5 0.0632 0.8719 0.000 0.000 0.000 0.000 0.976 0.024
#> GSM11308 5 0.0547 0.8710 0.000 0.000 0.000 0.000 0.980 0.020
#> GSM28782 5 0.5450 0.2063 0.164 0.000 0.000 0.000 0.560 0.276
#> GSM28779 1 0.1843 0.7819 0.912 0.000 0.000 0.004 0.004 0.080
#> GSM11302 1 0.1411 0.7906 0.936 0.000 0.000 0.000 0.004 0.060
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> SD:NMF 51 0.395 2
#> SD:NMF 52 0.372 3
#> SD:NMF 50 0.454 4
#> SD:NMF 48 0.425 5
#> SD:NMF 43 0.425 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.494 0.911 0.903 0.3513 0.638 0.638
#> 3 3 0.650 0.875 0.917 0.5853 0.826 0.727
#> 4 4 0.651 0.731 0.858 0.2695 0.810 0.590
#> 5 5 0.695 0.706 0.817 0.0794 0.907 0.674
#> 6 6 0.784 0.797 0.836 0.0674 0.954 0.781
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
#> GSM28788 1 0.6712 0.915 0.824 0.176
#> GSM28789 1 0.6712 0.915 0.824 0.176
#> GSM28790 1 0.6438 0.925 0.836 0.164
#> GSM11300 1 0.0672 0.820 0.992 0.008
#> GSM28798 2 0.3274 0.992 0.060 0.940
#> GSM11296 2 0.3274 0.992 0.060 0.940
#> GSM28801 2 0.3274 0.992 0.060 0.940
#> GSM11319 2 0.3274 0.992 0.060 0.940
#> GSM28781 2 0.3274 0.992 0.060 0.940
#> GSM11305 2 0.3274 0.992 0.060 0.940
#> GSM28784 2 0.3274 0.992 0.060 0.940
#> GSM11307 2 0.3274 0.992 0.060 0.940
#> GSM11313 2 0.3274 0.992 0.060 0.940
#> GSM28785 2 0.3274 0.992 0.060 0.940
#> GSM11318 1 0.6438 0.925 0.836 0.164
#> GSM28792 1 0.6438 0.925 0.836 0.164
#> GSM11295 1 0.3274 0.780 0.940 0.060
#> GSM28793 1 0.6438 0.925 0.836 0.164
#> GSM11312 1 0.6438 0.925 0.836 0.164
#> GSM28778 1 0.6438 0.925 0.836 0.164
#> GSM28796 1 0.6438 0.925 0.836 0.164
#> GSM11309 1 0.6438 0.925 0.836 0.164
#> GSM11315 1 0.6438 0.925 0.836 0.164
#> GSM11306 1 0.6712 0.915 0.824 0.176
#> GSM28776 1 0.6712 0.915 0.824 0.176
#> GSM28777 1 0.3274 0.780 0.940 0.060
#> GSM11316 1 0.3274 0.780 0.940 0.060
#> GSM11320 1 0.3274 0.780 0.940 0.060
#> GSM28797 1 0.6438 0.925 0.836 0.164
#> GSM28786 1 0.6438 0.925 0.836 0.164
#> GSM28800 1 0.6438 0.925 0.836 0.164
#> GSM11310 1 0.6438 0.925 0.836 0.164
#> GSM28787 1 0.3274 0.780 0.940 0.060
#> GSM11304 1 0.0000 0.826 1.000 0.000
#> GSM11303 1 0.3274 0.780 0.940 0.060
#> GSM11317 1 0.3274 0.780 0.940 0.060
#> GSM11311 1 0.6438 0.925 0.836 0.164
#> GSM28799 1 0.6438 0.925 0.836 0.164
#> GSM28791 1 0.6438 0.925 0.836 0.164
#> GSM28794 2 0.5519 0.904 0.128 0.872
#> GSM28780 1 0.6438 0.925 0.836 0.164
#> GSM28795 1 0.6438 0.925 0.836 0.164
#> GSM11301 2 0.3274 0.992 0.060 0.940
#> GSM11297 1 0.0000 0.826 1.000 0.000
#> GSM11298 1 0.6438 0.925 0.836 0.164
#> GSM11314 1 0.6438 0.925 0.836 0.164
#> GSM11299 1 0.0672 0.820 0.992 0.008
#> GSM28783 1 0.6438 0.925 0.836 0.164
#> GSM11308 1 0.6438 0.925 0.836 0.164
#> GSM28782 1 0.6438 0.925 0.836 0.164
#> GSM28779 1 0.6438 0.925 0.836 0.164
#> GSM11302 1 0.6438 0.925 0.836 0.164
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0592 0.885 0.988 0.012 0.000
#> GSM28789 1 0.0592 0.885 0.988 0.012 0.000
#> GSM28790 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11300 1 0.5465 0.495 0.712 0.000 0.288
#> GSM28798 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.984 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.984 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.984 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.984 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11318 1 0.0592 0.889 0.988 0.000 0.012
#> GSM28792 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11295 3 0.4452 0.995 0.192 0.000 0.808
#> GSM28793 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11312 1 0.0237 0.888 0.996 0.000 0.004
#> GSM28778 1 0.4291 0.784 0.820 0.000 0.180
#> GSM28796 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11309 1 0.0000 0.888 1.000 0.000 0.000
#> GSM11315 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11306 1 0.0592 0.885 0.988 0.012 0.000
#> GSM28776 1 0.0592 0.885 0.988 0.012 0.000
#> GSM28777 3 0.4399 0.998 0.188 0.000 0.812
#> GSM11316 3 0.4399 0.998 0.188 0.000 0.812
#> GSM11320 3 0.4399 0.998 0.188 0.000 0.812
#> GSM28797 1 0.0000 0.888 1.000 0.000 0.000
#> GSM28786 1 0.0000 0.888 1.000 0.000 0.000
#> GSM28800 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11310 1 0.0592 0.889 0.988 0.000 0.012
#> GSM28787 3 0.4452 0.995 0.192 0.000 0.808
#> GSM11304 1 0.5397 0.514 0.720 0.000 0.280
#> GSM11303 3 0.4399 0.998 0.188 0.000 0.812
#> GSM11317 3 0.4399 0.998 0.188 0.000 0.812
#> GSM11311 1 0.0000 0.888 1.000 0.000 0.000
#> GSM28799 1 0.0592 0.889 0.988 0.000 0.012
#> GSM28791 1 0.4399 0.778 0.812 0.000 0.188
#> GSM28794 2 0.3412 0.801 0.124 0.876 0.000
#> GSM28780 1 0.4399 0.778 0.812 0.000 0.188
#> GSM28795 1 0.4399 0.778 0.812 0.000 0.188
#> GSM11301 2 0.0000 0.984 0.000 1.000 0.000
#> GSM11297 1 0.5397 0.514 0.720 0.000 0.280
#> GSM11298 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11314 1 0.4291 0.784 0.820 0.000 0.180
#> GSM11299 1 0.5465 0.495 0.712 0.000 0.288
#> GSM28783 1 0.4399 0.778 0.812 0.000 0.188
#> GSM11308 1 0.4399 0.778 0.812 0.000 0.188
#> GSM28782 1 0.3941 0.804 0.844 0.000 0.156
#> GSM28779 1 0.0592 0.889 0.988 0.000 0.012
#> GSM11302 1 0.0592 0.889 0.988 0.000 0.012
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.5290 0.30628 0.324 0.012 0.008 0.656
#> GSM28789 4 0.5290 0.30628 0.324 0.012 0.008 0.656
#> GSM28790 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM11300 4 0.6211 0.09369 0.052 0.000 0.460 0.488
#> GSM28798 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11318 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM28792 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM11295 3 0.0188 0.99472 0.004 0.000 0.996 0.000
#> GSM28793 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM11312 1 0.5179 0.73231 0.728 0.000 0.052 0.220
#> GSM28778 1 0.1474 0.76379 0.948 0.000 0.000 0.052
#> GSM28796 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM11309 4 0.0188 0.52506 0.000 0.000 0.004 0.996
#> GSM11315 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM11306 4 0.5673 0.00336 0.444 0.012 0.008 0.536
#> GSM28776 4 0.5697 -0.08114 0.468 0.012 0.008 0.512
#> GSM28777 3 0.0000 0.99789 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.99789 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.99789 0.000 0.000 1.000 0.000
#> GSM28797 4 0.0188 0.52506 0.000 0.000 0.004 0.996
#> GSM28786 4 0.0188 0.52506 0.000 0.000 0.004 0.996
#> GSM28800 1 0.5185 0.77097 0.748 0.000 0.076 0.176
#> GSM11310 1 0.5185 0.77097 0.748 0.000 0.076 0.176
#> GSM28787 3 0.0188 0.99472 0.004 0.000 0.996 0.000
#> GSM11304 4 0.6332 0.11069 0.060 0.000 0.452 0.488
#> GSM11303 3 0.0000 0.99789 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.99789 0.000 0.000 1.000 0.000
#> GSM11311 4 0.3626 0.51754 0.184 0.000 0.004 0.812
#> GSM28799 1 0.5267 0.76449 0.740 0.000 0.076 0.184
#> GSM28791 1 0.0469 0.77775 0.988 0.000 0.000 0.012
#> GSM28794 2 0.3043 0.81163 0.112 0.876 0.004 0.008
#> GSM28780 1 0.0469 0.77775 0.988 0.000 0.000 0.012
#> GSM28795 1 0.1302 0.76405 0.956 0.000 0.000 0.044
#> GSM11301 2 0.0000 0.98470 0.000 1.000 0.000 0.000
#> GSM11297 4 0.6332 0.11069 0.060 0.000 0.452 0.488
#> GSM11298 1 0.4267 0.80153 0.788 0.000 0.188 0.024
#> GSM11314 1 0.1474 0.76379 0.948 0.000 0.000 0.052
#> GSM11299 4 0.6211 0.09369 0.052 0.000 0.460 0.488
#> GSM28783 1 0.0592 0.77986 0.984 0.000 0.000 0.016
#> GSM11308 1 0.0336 0.77911 0.992 0.000 0.000 0.008
#> GSM28782 1 0.1833 0.79918 0.944 0.000 0.032 0.024
#> GSM28779 1 0.5410 0.75641 0.728 0.000 0.080 0.192
#> GSM11302 1 0.5434 0.75929 0.728 0.000 0.084 0.188
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.519 0.176 0.356 0.004 0.000 0.596 0.044
#> GSM28789 4 0.519 0.176 0.356 0.004 0.000 0.596 0.044
#> GSM28790 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM11300 4 0.769 0.356 0.112 0.000 0.172 0.484 0.232
#> GSM28798 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM28792 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM11295 3 0.429 0.661 0.004 0.000 0.612 0.000 0.384
#> GSM28793 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM11312 1 0.313 0.699 0.820 0.000 0.000 0.172 0.008
#> GSM28778 5 0.444 0.936 0.396 0.000 0.000 0.008 0.596
#> GSM28796 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM11309 4 0.000 0.552 0.000 0.000 0.000 1.000 0.000
#> GSM11315 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM11306 4 0.526 -0.181 0.476 0.004 0.000 0.484 0.036
#> GSM28776 1 0.525 0.125 0.500 0.004 0.000 0.460 0.036
#> GSM28777 3 0.000 0.883 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.000 0.883 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.000 0.883 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.000 0.552 0.000 0.000 0.000 1.000 0.000
#> GSM28786 4 0.000 0.552 0.000 0.000 0.000 1.000 0.000
#> GSM28800 1 0.256 0.736 0.856 0.000 0.000 0.144 0.000
#> GSM11310 1 0.256 0.736 0.856 0.000 0.000 0.144 0.000
#> GSM28787 3 0.430 0.658 0.004 0.000 0.608 0.000 0.388
#> GSM11304 4 0.771 0.364 0.120 0.000 0.164 0.484 0.232
#> GSM11303 3 0.000 0.883 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.000 0.883 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.300 0.497 0.188 0.000 0.000 0.812 0.000
#> GSM28799 1 0.265 0.730 0.848 0.000 0.000 0.152 0.000
#> GSM28791 5 0.426 0.950 0.440 0.000 0.000 0.000 0.560
#> GSM28794 2 0.233 0.809 0.124 0.876 0.000 0.000 0.000
#> GSM28780 5 0.426 0.950 0.440 0.000 0.000 0.000 0.560
#> GSM28795 5 0.417 0.938 0.396 0.000 0.000 0.000 0.604
#> GSM11301 2 0.000 0.984 0.000 1.000 0.000 0.000 0.000
#> GSM11297 4 0.771 0.364 0.120 0.000 0.164 0.484 0.232
#> GSM11298 1 0.051 0.749 0.984 0.000 0.000 0.000 0.016
#> GSM11314 5 0.444 0.936 0.396 0.000 0.000 0.008 0.596
#> GSM11299 4 0.769 0.356 0.112 0.000 0.172 0.484 0.232
#> GSM28783 5 0.442 0.943 0.448 0.000 0.000 0.004 0.548
#> GSM11308 5 0.427 0.946 0.444 0.000 0.000 0.000 0.556
#> GSM28782 1 0.464 -0.746 0.532 0.000 0.000 0.012 0.456
#> GSM28779 1 0.284 0.729 0.848 0.000 0.000 0.144 0.008
#> GSM11302 1 0.280 0.732 0.852 0.000 0.000 0.140 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.344 0.838 0.172 0.000 0.000 0.796 0.020 0.012
#> GSM28789 4 0.344 0.838 0.172 0.000 0.000 0.796 0.020 0.012
#> GSM28790 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11300 6 0.391 0.604 0.076 0.000 0.164 0.000 0.000 0.760
#> GSM28798 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28792 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11295 3 0.616 0.517 0.000 0.000 0.500 0.200 0.020 0.280
#> GSM28793 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11312 1 0.390 0.712 0.748 0.000 0.000 0.212 0.012 0.028
#> GSM28778 5 0.261 0.860 0.020 0.000 0.000 0.044 0.888 0.048
#> GSM28796 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11309 6 0.381 0.497 0.000 0.000 0.000 0.428 0.000 0.572
#> GSM11315 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11306 4 0.388 0.831 0.292 0.000 0.000 0.688 0.020 0.000
#> GSM28776 4 0.399 0.795 0.316 0.000 0.000 0.664 0.020 0.000
#> GSM28777 3 0.000 0.844 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.000 0.844 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.000 0.844 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 6 0.381 0.497 0.000 0.000 0.000 0.428 0.000 0.572
#> GSM28786 6 0.381 0.497 0.000 0.000 0.000 0.428 0.000 0.572
#> GSM28800 1 0.359 0.776 0.788 0.000 0.000 0.152 0.000 0.060
#> GSM11310 1 0.359 0.776 0.788 0.000 0.000 0.152 0.000 0.060
#> GSM28787 3 0.618 0.513 0.000 0.000 0.496 0.204 0.020 0.280
#> GSM11304 6 0.394 0.608 0.084 0.000 0.156 0.000 0.000 0.760
#> GSM11303 3 0.000 0.844 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.000 0.844 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 6 0.563 0.345 0.188 0.000 0.000 0.284 0.000 0.528
#> GSM28799 1 0.372 0.769 0.780 0.000 0.000 0.148 0.000 0.072
#> GSM28791 5 0.279 0.813 0.140 0.000 0.000 0.000 0.840 0.020
#> GSM28794 2 0.252 0.824 0.100 0.876 0.000 0.012 0.012 0.000
#> GSM28780 5 0.142 0.864 0.032 0.000 0.000 0.000 0.944 0.024
#> GSM28795 5 0.247 0.861 0.020 0.000 0.000 0.036 0.896 0.048
#> GSM11301 2 0.000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.394 0.608 0.084 0.000 0.156 0.000 0.000 0.760
#> GSM11298 1 0.000 0.840 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11314 5 0.261 0.860 0.020 0.000 0.000 0.044 0.888 0.048
#> GSM11299 6 0.391 0.604 0.076 0.000 0.164 0.000 0.000 0.760
#> GSM28783 5 0.256 0.825 0.120 0.000 0.000 0.008 0.864 0.008
#> GSM11308 5 0.150 0.864 0.032 0.000 0.000 0.000 0.940 0.028
#> GSM28782 5 0.455 0.615 0.244 0.000 0.000 0.020 0.692 0.044
#> GSM28779 1 0.403 0.742 0.756 0.000 0.000 0.184 0.012 0.048
#> GSM11302 1 0.400 0.746 0.760 0.000 0.000 0.180 0.012 0.048
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 tissue(p) k
#> CV:hclust 52 0.396 2
#> CV:hclust 50 0.370 3
#> CV:hclust 44 0.497 4
#> CV:hclust 42 0.499 5
#> CV:hclust 48 0.398 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.393 0.825 0.834 0.3547 0.638 0.638
#> 3 3 1.000 0.979 0.969 0.6077 0.790 0.670
#> 4 4 0.731 0.755 0.828 0.2373 0.873 0.704
#> 5 5 0.722 0.814 0.851 0.0990 0.910 0.702
#> 6 6 0.814 0.771 0.811 0.0555 1.000 1.000
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
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
#> GSM28788 1 0.961 0.827 0.616 0.384
#> GSM28789 1 0.961 0.827 0.616 0.384
#> GSM28790 1 0.961 0.827 0.616 0.384
#> GSM11300 1 0.000 0.612 1.000 0.000
#> GSM28798 2 0.000 1.000 0.000 1.000
#> GSM11296 2 0.000 1.000 0.000 1.000
#> GSM28801 2 0.000 1.000 0.000 1.000
#> GSM11319 2 0.000 1.000 0.000 1.000
#> GSM28781 2 0.000 1.000 0.000 1.000
#> GSM11305 2 0.000 1.000 0.000 1.000
#> GSM28784 2 0.000 1.000 0.000 1.000
#> GSM11307 2 0.000 1.000 0.000 1.000
#> GSM11313 2 0.000 1.000 0.000 1.000
#> GSM28785 2 0.000 1.000 0.000 1.000
#> GSM11318 1 0.961 0.827 0.616 0.384
#> GSM28792 1 0.961 0.827 0.616 0.384
#> GSM11295 1 0.000 0.612 1.000 0.000
#> GSM28793 1 0.961 0.827 0.616 0.384
#> GSM11312 1 0.961 0.827 0.616 0.384
#> GSM28778 1 0.961 0.827 0.616 0.384
#> GSM28796 1 0.961 0.827 0.616 0.384
#> GSM11309 1 0.827 0.795 0.740 0.260
#> GSM11315 1 0.961 0.827 0.616 0.384
#> GSM11306 1 0.961 0.827 0.616 0.384
#> GSM28776 1 0.961 0.827 0.616 0.384
#> GSM28777 1 0.000 0.612 1.000 0.000
#> GSM11316 1 0.000 0.612 1.000 0.000
#> GSM11320 1 0.000 0.612 1.000 0.000
#> GSM28797 1 0.844 0.801 0.728 0.272
#> GSM28786 1 0.814 0.791 0.748 0.252
#> GSM28800 1 0.961 0.827 0.616 0.384
#> GSM11310 1 0.925 0.820 0.660 0.340
#> GSM28787 1 0.000 0.612 1.000 0.000
#> GSM11304 1 0.827 0.795 0.740 0.260
#> GSM11303 1 0.000 0.612 1.000 0.000
#> GSM11317 1 0.000 0.612 1.000 0.000
#> GSM11311 1 0.844 0.801 0.728 0.272
#> GSM28799 1 0.881 0.809 0.700 0.300
#> GSM28791 1 0.961 0.827 0.616 0.384
#> GSM28794 2 0.000 1.000 0.000 1.000
#> GSM28780 1 0.958 0.827 0.620 0.380
#> GSM28795 1 0.958 0.827 0.620 0.380
#> GSM11301 2 0.000 1.000 0.000 1.000
#> GSM11297 1 0.827 0.795 0.740 0.260
#> GSM11298 1 0.961 0.827 0.616 0.384
#> GSM11314 1 0.958 0.827 0.620 0.380
#> GSM11299 1 0.000 0.612 1.000 0.000
#> GSM28783 1 0.958 0.827 0.620 0.380
#> GSM11308 1 0.844 0.801 0.728 0.272
#> GSM28782 1 0.958 0.827 0.620 0.380
#> GSM28779 1 0.961 0.827 0.616 0.384
#> GSM11302 1 0.961 0.827 0.616 0.384
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.2496 0.961 0.928 0.004 0.068
#> GSM28789 1 0.2496 0.961 0.928 0.004 0.068
#> GSM28790 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11300 3 0.1964 1.000 0.056 0.000 0.944
#> GSM28798 2 0.0661 0.994 0.004 0.988 0.008
#> GSM11296 2 0.0237 0.995 0.004 0.996 0.000
#> GSM28801 2 0.0237 0.995 0.004 0.996 0.000
#> GSM11319 2 0.0237 0.995 0.004 0.996 0.000
#> GSM28781 2 0.0237 0.995 0.004 0.996 0.000
#> GSM11305 2 0.0661 0.994 0.004 0.988 0.008
#> GSM28784 2 0.0661 0.992 0.004 0.988 0.008
#> GSM11307 2 0.0661 0.994 0.004 0.988 0.008
#> GSM11313 2 0.0661 0.994 0.004 0.988 0.008
#> GSM28785 2 0.0237 0.995 0.004 0.996 0.000
#> GSM11318 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28792 1 0.1031 0.975 0.976 0.000 0.024
#> GSM11295 3 0.1964 1.000 0.056 0.000 0.944
#> GSM28793 1 0.1031 0.975 0.976 0.000 0.024
#> GSM11312 1 0.0424 0.971 0.992 0.000 0.008
#> GSM28778 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28796 1 0.1031 0.975 0.976 0.000 0.024
#> GSM11309 1 0.2496 0.961 0.928 0.004 0.068
#> GSM11315 1 0.1163 0.975 0.972 0.000 0.028
#> GSM11306 1 0.2096 0.966 0.944 0.004 0.052
#> GSM28776 1 0.1289 0.975 0.968 0.000 0.032
#> GSM28777 3 0.1964 1.000 0.056 0.000 0.944
#> GSM11316 3 0.1964 1.000 0.056 0.000 0.944
#> GSM11320 3 0.1964 1.000 0.056 0.000 0.944
#> GSM28797 1 0.2496 0.961 0.928 0.004 0.068
#> GSM28786 1 0.2496 0.961 0.928 0.004 0.068
#> GSM28800 1 0.1031 0.975 0.976 0.000 0.024
#> GSM11310 1 0.1753 0.970 0.952 0.000 0.048
#> GSM28787 3 0.1964 1.000 0.056 0.000 0.944
#> GSM11304 1 0.2261 0.950 0.932 0.000 0.068
#> GSM11303 3 0.1964 1.000 0.056 0.000 0.944
#> GSM11317 3 0.1964 1.000 0.056 0.000 0.944
#> GSM11311 1 0.2096 0.966 0.944 0.004 0.052
#> GSM28799 1 0.1529 0.969 0.960 0.000 0.040
#> GSM28791 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28794 2 0.1267 0.986 0.004 0.972 0.024
#> GSM28780 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11301 2 0.1129 0.987 0.004 0.976 0.020
#> GSM11297 1 0.3038 0.912 0.896 0.000 0.104
#> GSM11298 1 0.1031 0.975 0.976 0.000 0.024
#> GSM11314 1 0.0237 0.972 0.996 0.000 0.004
#> GSM11299 3 0.1964 1.000 0.056 0.000 0.944
#> GSM28783 1 0.0000 0.973 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.973 1.000 0.000 0.000
#> GSM28779 1 0.1031 0.975 0.976 0.000 0.024
#> GSM11302 1 0.1031 0.975 0.976 0.000 0.024
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.5163 0.8964 0.480 0.000 0.004 0.516
#> GSM28789 4 0.5163 0.8964 0.480 0.000 0.004 0.516
#> GSM28790 1 0.4008 0.6257 0.756 0.000 0.000 0.244
#> GSM11300 3 0.0779 0.9809 0.004 0.000 0.980 0.016
#> GSM28798 2 0.1004 0.9800 0.004 0.972 0.000 0.024
#> GSM11296 2 0.0376 0.9814 0.004 0.992 0.000 0.004
#> GSM28801 2 0.0376 0.9814 0.004 0.992 0.000 0.004
#> GSM11319 2 0.0188 0.9816 0.004 0.996 0.000 0.000
#> GSM28781 2 0.0376 0.9814 0.004 0.992 0.000 0.004
#> GSM11305 2 0.1004 0.9800 0.004 0.972 0.000 0.024
#> GSM28784 2 0.1209 0.9723 0.004 0.964 0.000 0.032
#> GSM11307 2 0.1004 0.9800 0.004 0.972 0.000 0.024
#> GSM11313 2 0.1004 0.9800 0.004 0.972 0.000 0.024
#> GSM28785 2 0.0188 0.9816 0.004 0.996 0.000 0.000
#> GSM11318 1 0.4008 0.6253 0.756 0.000 0.000 0.244
#> GSM28792 1 0.0817 0.5983 0.976 0.000 0.000 0.024
#> GSM11295 3 0.1576 0.9690 0.004 0.000 0.948 0.048
#> GSM28793 1 0.1118 0.5872 0.964 0.000 0.000 0.036
#> GSM11312 1 0.4164 0.6025 0.736 0.000 0.000 0.264
#> GSM28778 1 0.4855 0.5801 0.600 0.000 0.000 0.400
#> GSM28796 1 0.0921 0.5951 0.972 0.000 0.000 0.028
#> GSM11309 4 0.5080 0.9199 0.420 0.000 0.004 0.576
#> GSM11315 1 0.1118 0.5872 0.964 0.000 0.000 0.036
#> GSM11306 4 0.4994 0.8929 0.480 0.000 0.000 0.520
#> GSM28776 1 0.2530 0.4340 0.888 0.000 0.000 0.112
#> GSM28777 3 0.0188 0.9853 0.004 0.000 0.996 0.000
#> GSM11316 3 0.0564 0.9863 0.004 0.004 0.988 0.004
#> GSM11320 3 0.0564 0.9863 0.004 0.004 0.988 0.004
#> GSM28797 4 0.5080 0.9199 0.420 0.000 0.004 0.576
#> GSM28786 4 0.5080 0.9199 0.420 0.000 0.004 0.576
#> GSM28800 1 0.0469 0.5983 0.988 0.000 0.000 0.012
#> GSM11310 1 0.3908 0.1179 0.784 0.000 0.004 0.212
#> GSM28787 3 0.1576 0.9690 0.004 0.000 0.948 0.048
#> GSM11304 1 0.5714 0.2097 0.716 0.000 0.128 0.156
#> GSM11303 3 0.0564 0.9863 0.004 0.004 0.988 0.004
#> GSM11317 3 0.0564 0.9863 0.004 0.004 0.988 0.004
#> GSM11311 4 0.4925 0.8789 0.428 0.000 0.000 0.572
#> GSM28799 1 0.4053 0.0973 0.768 0.000 0.004 0.228
#> GSM28791 1 0.4679 0.6060 0.648 0.000 0.000 0.352
#> GSM28794 2 0.2382 0.9540 0.004 0.912 0.004 0.080
#> GSM28780 1 0.4830 0.5873 0.608 0.000 0.000 0.392
#> GSM28795 1 0.4855 0.5801 0.600 0.000 0.000 0.400
#> GSM11301 2 0.1930 0.9583 0.004 0.936 0.004 0.056
#> GSM11297 1 0.5859 0.1813 0.704 0.000 0.140 0.156
#> GSM11298 1 0.0921 0.6004 0.972 0.000 0.000 0.028
#> GSM11314 1 0.4866 0.5773 0.596 0.000 0.000 0.404
#> GSM11299 3 0.0779 0.9809 0.004 0.000 0.980 0.016
#> GSM28783 1 0.4830 0.5873 0.608 0.000 0.000 0.392
#> GSM11308 1 0.4830 0.5873 0.608 0.000 0.000 0.392
#> GSM28782 1 0.4277 0.6247 0.720 0.000 0.000 0.280
#> GSM28779 1 0.0188 0.6041 0.996 0.000 0.000 0.004
#> GSM11302 1 0.0188 0.6041 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.5322 0.839 0.188 0.000 0.000 0.672 0.140
#> GSM28789 4 0.5322 0.839 0.188 0.000 0.000 0.672 0.140
#> GSM28790 1 0.2329 0.639 0.876 0.000 0.000 0.000 0.124
#> GSM11300 3 0.1525 0.939 0.004 0.000 0.948 0.036 0.012
#> GSM28798 2 0.1661 0.949 0.000 0.940 0.000 0.024 0.036
#> GSM11296 2 0.0000 0.957 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.957 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.957 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.957 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.1661 0.949 0.000 0.940 0.000 0.024 0.036
#> GSM28784 2 0.1992 0.930 0.000 0.924 0.000 0.044 0.032
#> GSM11307 2 0.1661 0.949 0.000 0.940 0.000 0.024 0.036
#> GSM11313 2 0.1661 0.949 0.000 0.940 0.000 0.024 0.036
#> GSM28785 2 0.0000 0.957 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.2966 0.555 0.816 0.000 0.000 0.000 0.184
#> GSM28792 1 0.1106 0.742 0.964 0.000 0.000 0.024 0.012
#> GSM11295 3 0.2645 0.917 0.000 0.000 0.888 0.044 0.068
#> GSM28793 1 0.1106 0.742 0.964 0.000 0.000 0.024 0.012
#> GSM11312 1 0.5548 -0.208 0.492 0.000 0.000 0.068 0.440
#> GSM28778 5 0.3942 0.977 0.232 0.000 0.000 0.020 0.748
#> GSM28796 1 0.1106 0.742 0.964 0.000 0.000 0.024 0.012
#> GSM11309 4 0.2824 0.893 0.116 0.000 0.000 0.864 0.020
#> GSM11315 1 0.1106 0.742 0.964 0.000 0.000 0.024 0.012
#> GSM11306 4 0.5264 0.835 0.196 0.000 0.000 0.676 0.128
#> GSM28776 1 0.4017 0.681 0.788 0.000 0.000 0.148 0.064
#> GSM28777 3 0.0290 0.955 0.000 0.000 0.992 0.008 0.000
#> GSM11316 3 0.1211 0.956 0.000 0.000 0.960 0.016 0.024
#> GSM11320 3 0.0865 0.957 0.000 0.000 0.972 0.004 0.024
#> GSM28797 4 0.2824 0.893 0.116 0.000 0.000 0.864 0.020
#> GSM28786 4 0.2824 0.893 0.116 0.000 0.000 0.864 0.020
#> GSM28800 1 0.2740 0.726 0.876 0.000 0.000 0.028 0.096
#> GSM11310 1 0.4823 0.567 0.700 0.000 0.000 0.228 0.072
#> GSM28787 3 0.2708 0.916 0.000 0.000 0.884 0.044 0.072
#> GSM11304 1 0.6859 0.527 0.604 0.000 0.128 0.152 0.116
#> GSM11303 3 0.0865 0.957 0.000 0.000 0.972 0.004 0.024
#> GSM11317 3 0.0865 0.957 0.000 0.000 0.972 0.004 0.024
#> GSM11311 4 0.2723 0.885 0.124 0.000 0.000 0.864 0.012
#> GSM28799 1 0.5043 0.572 0.692 0.000 0.000 0.208 0.100
#> GSM28791 5 0.3689 0.963 0.256 0.000 0.000 0.004 0.740
#> GSM28794 2 0.3701 0.882 0.004 0.824 0.000 0.060 0.112
#> GSM28780 5 0.3835 0.974 0.244 0.000 0.000 0.012 0.744
#> GSM28795 5 0.3942 0.977 0.232 0.000 0.000 0.020 0.748
#> GSM11301 2 0.2859 0.903 0.000 0.876 0.000 0.056 0.068
#> GSM11297 1 0.6897 0.521 0.600 0.000 0.132 0.152 0.116
#> GSM11298 1 0.0992 0.743 0.968 0.000 0.000 0.024 0.008
#> GSM11314 5 0.3970 0.970 0.224 0.000 0.000 0.024 0.752
#> GSM11299 3 0.1525 0.939 0.004 0.000 0.948 0.036 0.012
#> GSM28783 5 0.3756 0.962 0.248 0.000 0.000 0.008 0.744
#> GSM11308 5 0.3728 0.971 0.244 0.000 0.000 0.008 0.748
#> GSM28782 1 0.4383 -0.102 0.572 0.000 0.000 0.004 0.424
#> GSM28779 1 0.1638 0.737 0.932 0.000 0.000 0.004 0.064
#> GSM11302 1 0.1357 0.738 0.948 0.000 0.000 0.004 0.048
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.5859 0.7451 0.176 0.000 0.000 0.628 0.080 NA
#> GSM28789 4 0.5859 0.7451 0.176 0.000 0.000 0.628 0.080 NA
#> GSM28790 1 0.4361 0.6666 0.700 0.000 0.000 0.016 0.036 NA
#> GSM11300 3 0.2265 0.8901 0.004 0.000 0.896 0.024 0.000 NA
#> GSM28798 2 0.1701 0.9058 0.000 0.920 0.000 0.000 0.008 NA
#> GSM11296 2 0.0146 0.9150 0.000 0.996 0.000 0.000 0.000 NA
#> GSM28801 2 0.0291 0.9147 0.000 0.992 0.000 0.000 0.004 NA
#> GSM11319 2 0.0000 0.9153 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28781 2 0.0291 0.9147 0.000 0.992 0.000 0.000 0.004 NA
#> GSM11305 2 0.1701 0.9058 0.000 0.920 0.000 0.000 0.008 NA
#> GSM28784 2 0.2595 0.8426 0.000 0.836 0.000 0.000 0.004 NA
#> GSM11307 2 0.1701 0.9058 0.000 0.920 0.000 0.000 0.008 NA
#> GSM11313 2 0.1701 0.9058 0.000 0.920 0.000 0.000 0.008 NA
#> GSM28785 2 0.0000 0.9153 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11318 1 0.4874 0.6418 0.664 0.000 0.000 0.016 0.072 NA
#> GSM28792 1 0.4207 0.6716 0.712 0.000 0.000 0.020 0.024 NA
#> GSM11295 3 0.3349 0.8496 0.000 0.000 0.804 0.008 0.024 NA
#> GSM28793 1 0.4050 0.6759 0.728 0.000 0.000 0.016 0.024 NA
#> GSM11312 1 0.5456 0.0805 0.500 0.000 0.000 0.044 0.416 NA
#> GSM28778 5 0.1934 0.9621 0.044 0.000 0.000 0.000 0.916 NA
#> GSM28796 1 0.4050 0.6759 0.728 0.000 0.000 0.016 0.024 NA
#> GSM11309 4 0.0520 0.8343 0.008 0.000 0.000 0.984 0.008 NA
#> GSM11315 1 0.4050 0.6759 0.728 0.000 0.000 0.016 0.024 NA
#> GSM11306 4 0.5718 0.7485 0.172 0.000 0.000 0.644 0.084 NA
#> GSM28776 1 0.3053 0.6245 0.856 0.000 0.000 0.080 0.048 NA
#> GSM28777 3 0.0405 0.9301 0.000 0.000 0.988 0.000 0.004 NA
#> GSM11316 3 0.0632 0.9268 0.000 0.000 0.976 0.000 0.000 NA
#> GSM11320 3 0.0146 0.9309 0.000 0.000 0.996 0.000 0.000 NA
#> GSM28797 4 0.0520 0.8343 0.008 0.000 0.000 0.984 0.008 NA
#> GSM28786 4 0.0520 0.8343 0.008 0.000 0.000 0.984 0.008 NA
#> GSM28800 1 0.2823 0.6415 0.872 0.000 0.000 0.016 0.068 NA
#> GSM11310 1 0.4684 0.4981 0.716 0.000 0.000 0.192 0.048 NA
#> GSM28787 3 0.3536 0.8388 0.000 0.000 0.784 0.012 0.020 NA
#> GSM11304 1 0.7136 0.4060 0.564 0.000 0.080 0.140 0.092 NA
#> GSM11303 3 0.0146 0.9309 0.000 0.000 0.996 0.000 0.000 NA
#> GSM11317 3 0.0146 0.9309 0.000 0.000 0.996 0.000 0.000 NA
#> GSM11311 4 0.0653 0.8298 0.012 0.000 0.000 0.980 0.004 NA
#> GSM28799 1 0.5295 0.4792 0.676 0.000 0.000 0.180 0.056 NA
#> GSM28791 5 0.1528 0.9628 0.048 0.000 0.000 0.000 0.936 NA
#> GSM28794 2 0.4859 0.6527 0.056 0.604 0.000 0.000 0.008 NA
#> GSM28780 5 0.1398 0.9621 0.052 0.000 0.000 0.000 0.940 NA
#> GSM28795 5 0.1934 0.9621 0.044 0.000 0.000 0.000 0.916 NA
#> GSM11301 2 0.2996 0.7994 0.000 0.772 0.000 0.000 0.000 NA
#> GSM11297 1 0.7136 0.4060 0.564 0.000 0.080 0.140 0.092 NA
#> GSM11298 1 0.3831 0.6768 0.744 0.000 0.000 0.012 0.020 NA
#> GSM11314 5 0.2070 0.9594 0.048 0.000 0.000 0.000 0.908 NA
#> GSM11299 3 0.2510 0.8839 0.008 0.000 0.884 0.028 0.000 NA
#> GSM28783 5 0.2163 0.9158 0.092 0.000 0.000 0.000 0.892 NA
#> GSM11308 5 0.1542 0.9605 0.052 0.000 0.000 0.004 0.936 NA
#> GSM28782 1 0.4527 0.0765 0.516 0.000 0.000 0.004 0.456 NA
#> GSM28779 1 0.1672 0.6623 0.932 0.000 0.000 0.004 0.048 NA
#> GSM11302 1 0.2279 0.6710 0.900 0.000 0.000 0.004 0.048 NA
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 tissue(p) k
#> CV:kmeans 52 0.396 2
#> CV:kmeans 52 0.372 3
#> CV:kmeans 47 0.450 4
#> CV:kmeans 50 0.431 5
#> CV:kmeans 46 0.431 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.970 0.985 0.4096 0.599 0.599
#> 3 3 0.967 0.909 0.964 0.5951 0.687 0.501
#> 4 4 0.753 0.643 0.846 0.1527 0.834 0.557
#> 5 5 0.940 0.906 0.955 0.0755 0.904 0.634
#> 6 6 0.905 0.799 0.894 0.0357 0.943 0.714
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 5
There is also optional best \(k\) = 2 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.000 0.982 1.000 0.000
#> GSM28789 2 0.204 0.961 0.032 0.968
#> GSM28790 1 0.000 0.982 1.000 0.000
#> GSM11300 1 0.000 0.982 1.000 0.000
#> GSM28798 2 0.000 0.988 0.000 1.000
#> GSM11296 2 0.000 0.988 0.000 1.000
#> GSM28801 2 0.000 0.988 0.000 1.000
#> GSM11319 2 0.000 0.988 0.000 1.000
#> GSM28781 2 0.000 0.988 0.000 1.000
#> GSM11305 2 0.000 0.988 0.000 1.000
#> GSM28784 2 0.000 0.988 0.000 1.000
#> GSM11307 2 0.000 0.988 0.000 1.000
#> GSM11313 2 0.000 0.988 0.000 1.000
#> GSM28785 2 0.000 0.988 0.000 1.000
#> GSM11318 1 0.000 0.982 1.000 0.000
#> GSM28792 1 0.000 0.982 1.000 0.000
#> GSM11295 1 0.204 0.961 0.968 0.032
#> GSM28793 1 0.000 0.982 1.000 0.000
#> GSM11312 1 0.000 0.982 1.000 0.000
#> GSM28778 2 0.541 0.864 0.124 0.876
#> GSM28796 1 0.000 0.982 1.000 0.000
#> GSM11309 1 0.000 0.982 1.000 0.000
#> GSM11315 1 0.000 0.982 1.000 0.000
#> GSM11306 1 0.000 0.982 1.000 0.000
#> GSM28776 1 0.000 0.982 1.000 0.000
#> GSM28777 1 0.204 0.961 0.968 0.032
#> GSM11316 1 0.671 0.806 0.824 0.176
#> GSM11320 1 0.204 0.961 0.968 0.032
#> GSM28797 1 0.000 0.982 1.000 0.000
#> GSM28786 1 0.000 0.982 1.000 0.000
#> GSM28800 1 0.000 0.982 1.000 0.000
#> GSM11310 1 0.000 0.982 1.000 0.000
#> GSM28787 1 0.662 0.811 0.828 0.172
#> GSM11304 1 0.000 0.982 1.000 0.000
#> GSM11303 1 0.204 0.961 0.968 0.032
#> GSM11317 1 0.204 0.961 0.968 0.032
#> GSM11311 1 0.000 0.982 1.000 0.000
#> GSM28799 1 0.000 0.982 1.000 0.000
#> GSM28791 1 0.000 0.982 1.000 0.000
#> GSM28794 2 0.000 0.988 0.000 1.000
#> GSM28780 1 0.000 0.982 1.000 0.000
#> GSM28795 1 0.000 0.982 1.000 0.000
#> GSM11301 2 0.000 0.988 0.000 1.000
#> GSM11297 1 0.000 0.982 1.000 0.000
#> GSM11298 1 0.000 0.982 1.000 0.000
#> GSM11314 1 0.584 0.841 0.860 0.140
#> GSM11299 1 0.000 0.982 1.000 0.000
#> GSM28783 1 0.000 0.982 1.000 0.000
#> GSM11308 1 0.000 0.982 1.000 0.000
#> GSM28782 1 0.000 0.982 1.000 0.000
#> GSM28779 1 0.000 0.982 1.000 0.000
#> GSM11302 1 0.000 0.982 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 3 0.6309 0.0601 0.496 0.000 0.504
#> GSM28789 3 0.8275 0.0788 0.076 0.452 0.472
#> GSM28790 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11309 3 0.0424 0.8946 0.008 0.000 0.992
#> GSM11315 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11306 1 0.0592 0.9741 0.988 0.000 0.012
#> GSM28776 1 0.0592 0.9741 0.988 0.000 0.012
#> GSM28777 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM28797 3 0.1643 0.8675 0.044 0.000 0.956
#> GSM28786 3 0.0424 0.8946 0.008 0.000 0.992
#> GSM28800 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11310 1 0.4235 0.7711 0.824 0.000 0.176
#> GSM28787 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11304 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11303 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11311 1 0.2625 0.9032 0.916 0.000 0.084
#> GSM28799 3 0.6095 0.3721 0.392 0.000 0.608
#> GSM28791 1 0.0237 0.9797 0.996 0.000 0.004
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28780 1 0.0237 0.9797 0.996 0.000 0.004
#> GSM28795 1 0.0237 0.9797 0.996 0.000 0.004
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11297 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM11298 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11314 1 0.1315 0.9637 0.972 0.008 0.020
#> GSM11299 3 0.0000 0.8983 0.000 0.000 1.000
#> GSM28783 1 0.0237 0.9797 0.996 0.000 0.004
#> GSM11308 1 0.1860 0.9383 0.948 0.000 0.052
#> GSM28782 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.9812 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.9812 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.3852 0.5238 0.180 0.000 0.012 0.808
#> GSM28789 4 0.4410 0.5203 0.144 0.032 0.012 0.812
#> GSM28790 1 0.3266 0.6085 0.832 0.000 0.000 0.168
#> GSM11300 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.3219 0.6116 0.836 0.000 0.000 0.164
#> GSM28792 1 0.1474 0.6677 0.948 0.000 0.000 0.052
#> GSM11295 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM28793 1 0.0000 0.6801 1.000 0.000 0.000 0.000
#> GSM11312 4 0.4999 -0.1411 0.492 0.000 0.000 0.508
#> GSM28778 4 0.4996 -0.2266 0.484 0.000 0.000 0.516
#> GSM28796 1 0.0000 0.6801 1.000 0.000 0.000 0.000
#> GSM11309 4 0.5897 0.5104 0.164 0.000 0.136 0.700
#> GSM11315 1 0.0000 0.6801 1.000 0.000 0.000 0.000
#> GSM11306 4 0.3649 0.5167 0.204 0.000 0.000 0.796
#> GSM28776 1 0.4730 -0.0342 0.636 0.000 0.000 0.364
#> GSM28777 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM28797 4 0.5332 0.5234 0.184 0.000 0.080 0.736
#> GSM28786 4 0.6469 0.4790 0.164 0.000 0.192 0.644
#> GSM28800 1 0.0707 0.6778 0.980 0.000 0.000 0.020
#> GSM11310 1 0.4977 -0.2222 0.540 0.000 0.000 0.460
#> GSM28787 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM11304 3 0.0657 0.9846 0.004 0.000 0.984 0.012
#> GSM11303 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM11311 4 0.5060 0.3283 0.412 0.000 0.004 0.584
#> GSM28799 4 0.7300 0.3078 0.372 0.000 0.156 0.472
#> GSM28791 1 0.4933 0.2851 0.568 0.000 0.000 0.432
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28780 4 0.5000 -0.2580 0.500 0.000 0.000 0.500
#> GSM28795 4 0.4996 -0.2266 0.484 0.000 0.000 0.516
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11297 3 0.0921 0.9723 0.000 0.000 0.972 0.028
#> GSM11298 1 0.0000 0.6801 1.000 0.000 0.000 0.000
#> GSM11314 4 0.5035 0.1305 0.284 0.004 0.016 0.696
#> GSM11299 3 0.0000 0.9956 0.000 0.000 1.000 0.000
#> GSM28783 1 0.5000 0.1528 0.504 0.000 0.000 0.496
#> GSM11308 1 0.6011 0.1501 0.484 0.000 0.040 0.476
#> GSM28782 1 0.4040 0.5425 0.752 0.000 0.000 0.248
#> GSM28779 1 0.0000 0.6801 1.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.6801 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.0613 0.8729 0.008 0 0.004 0.984 0.004
#> GSM28789 4 0.0613 0.8729 0.008 0 0.004 0.984 0.004
#> GSM28790 1 0.1571 0.9013 0.936 0 0.000 0.004 0.060
#> GSM11300 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM28798 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11318 1 0.2439 0.8510 0.876 0 0.000 0.004 0.120
#> GSM28792 1 0.0290 0.9284 0.992 0 0.000 0.008 0.000
#> GSM11295 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM28793 1 0.0290 0.9284 0.992 0 0.000 0.008 0.000
#> GSM11312 5 0.4300 0.7498 0.132 0 0.000 0.096 0.772
#> GSM28778 5 0.0693 0.9368 0.012 0 0.000 0.008 0.980
#> GSM28796 1 0.0290 0.9284 0.992 0 0.000 0.008 0.000
#> GSM11309 4 0.0290 0.8738 0.000 0 0.008 0.992 0.000
#> GSM11315 1 0.0290 0.9284 0.992 0 0.000 0.008 0.000
#> GSM11306 4 0.0898 0.8645 0.008 0 0.000 0.972 0.020
#> GSM28776 1 0.3934 0.5782 0.716 0 0.000 0.276 0.008
#> GSM28777 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM28797 4 0.0404 0.8735 0.000 0 0.012 0.988 0.000
#> GSM28786 4 0.0404 0.8735 0.000 0 0.012 0.988 0.000
#> GSM28800 1 0.2464 0.8609 0.888 0 0.000 0.016 0.096
#> GSM11310 4 0.4656 0.0752 0.480 0 0.000 0.508 0.012
#> GSM28787 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM11304 3 0.2483 0.9143 0.028 0 0.908 0.048 0.016
#> GSM11303 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM11311 4 0.1121 0.8600 0.044 0 0.000 0.956 0.000
#> GSM28799 4 0.5463 0.5175 0.292 0 0.052 0.636 0.020
#> GSM28791 5 0.0000 0.9402 0.000 0 0.000 0.000 1.000
#> GSM28794 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28780 5 0.0162 0.9405 0.004 0 0.000 0.000 0.996
#> GSM28795 5 0.0451 0.9393 0.004 0 0.000 0.008 0.988
#> GSM11301 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11297 3 0.3110 0.8857 0.044 0 0.876 0.060 0.020
#> GSM11298 1 0.0451 0.9274 0.988 0 0.000 0.008 0.004
#> GSM11314 5 0.0451 0.9388 0.000 0 0.004 0.008 0.988
#> GSM11299 3 0.0000 0.9801 0.000 0 1.000 0.000 0.000
#> GSM28783 5 0.0162 0.9395 0.000 0 0.000 0.004 0.996
#> GSM11308 5 0.0162 0.9398 0.000 0 0.004 0.000 0.996
#> GSM28782 5 0.3086 0.7800 0.180 0 0.000 0.004 0.816
#> GSM28779 1 0.0912 0.9225 0.972 0 0.000 0.016 0.012
#> GSM11302 1 0.0807 0.9240 0.976 0 0.000 0.012 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.2482 0.85990 0.000 0.000 0.000 0.848 0.004 0.148
#> GSM28789 4 0.2442 0.86099 0.000 0.000 0.000 0.852 0.004 0.144
#> GSM28790 1 0.1967 0.79934 0.904 0.000 0.000 0.000 0.084 0.012
#> GSM11300 3 0.1204 0.94138 0.000 0.000 0.944 0.000 0.000 0.056
#> GSM28798 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.1700 0.80130 0.916 0.000 0.000 0.000 0.080 0.004
#> GSM28792 1 0.0405 0.84326 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM11295 3 0.0146 0.97907 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM28793 1 0.0000 0.84640 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11312 6 0.6164 -0.14887 0.080 0.000 0.000 0.064 0.424 0.432
#> GSM28778 5 0.1152 0.87434 0.004 0.000 0.000 0.000 0.952 0.044
#> GSM28796 1 0.0000 0.84640 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.0363 0.88959 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM11315 1 0.0000 0.84640 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11306 4 0.2838 0.80145 0.000 0.000 0.000 0.808 0.004 0.188
#> GSM28776 6 0.5880 0.00902 0.384 0.000 0.000 0.172 0.004 0.440
#> GSM28777 3 0.0000 0.98101 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.98101 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.98101 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.0291 0.89086 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM28786 4 0.0291 0.89086 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM28800 6 0.3622 0.41606 0.212 0.000 0.000 0.004 0.024 0.760
#> GSM11310 6 0.4144 0.48686 0.072 0.000 0.000 0.200 0.000 0.728
#> GSM28787 3 0.0260 0.97712 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM11304 6 0.6207 0.26648 0.020 0.000 0.360 0.092 0.028 0.500
#> GSM11303 3 0.0000 0.98101 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.98101 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.2147 0.82597 0.084 0.000 0.000 0.896 0.000 0.020
#> GSM28799 6 0.5703 0.45749 0.108 0.000 0.032 0.188 0.020 0.652
#> GSM28791 5 0.1152 0.87330 0.004 0.000 0.000 0.000 0.952 0.044
#> GSM28794 2 0.0146 0.99570 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM28780 5 0.0363 0.88175 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM28795 5 0.0458 0.88003 0.000 0.000 0.000 0.000 0.984 0.016
#> GSM11301 2 0.0000 0.99961 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.6227 0.33208 0.020 0.000 0.324 0.096 0.032 0.528
#> GSM11298 1 0.1863 0.80078 0.896 0.000 0.000 0.000 0.000 0.104
#> GSM11314 5 0.1493 0.86475 0.000 0.000 0.004 0.004 0.936 0.056
#> GSM11299 3 0.1531 0.92673 0.000 0.000 0.928 0.004 0.000 0.068
#> GSM28783 5 0.1866 0.85432 0.000 0.000 0.000 0.008 0.908 0.084
#> GSM11308 5 0.1219 0.87352 0.000 0.000 0.000 0.004 0.948 0.048
#> GSM28782 5 0.4852 0.21600 0.048 0.000 0.000 0.004 0.528 0.420
#> GSM28779 1 0.4211 0.26508 0.532 0.000 0.000 0.008 0.004 0.456
#> GSM11302 1 0.3448 0.62245 0.716 0.000 0.000 0.004 0.000 0.280
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 tissue(p) k
#> CV:skmeans 52 0.396 2
#> CV:skmeans 49 0.446 3
#> CV:skmeans 39 0.473 4
#> CV:skmeans 51 0.437 5
#> CV:skmeans 43 0.436 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.966 0.988 0.3754 0.638 0.638
#> 3 3 0.881 0.941 0.976 0.5426 0.790 0.670
#> 4 4 0.659 0.575 0.781 0.2331 0.834 0.612
#> 5 5 0.729 0.614 0.807 0.0847 0.842 0.514
#> 6 6 0.821 0.768 0.890 0.0600 0.894 0.589
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
#> GSM28788 1 0.0000 0.9835 1.000 0.000
#> GSM28789 1 0.0000 0.9835 1.000 0.000
#> GSM28790 1 0.0000 0.9835 1.000 0.000
#> GSM11300 1 0.0000 0.9835 1.000 0.000
#> GSM28798 2 0.0000 0.9996 0.000 1.000
#> GSM11296 2 0.0000 0.9996 0.000 1.000
#> GSM28801 2 0.0000 0.9996 0.000 1.000
#> GSM11319 2 0.0000 0.9996 0.000 1.000
#> GSM28781 2 0.0000 0.9996 0.000 1.000
#> GSM11305 2 0.0000 0.9996 0.000 1.000
#> GSM28784 2 0.0000 0.9996 0.000 1.000
#> GSM11307 2 0.0000 0.9996 0.000 1.000
#> GSM11313 2 0.0000 0.9996 0.000 1.000
#> GSM28785 2 0.0000 0.9996 0.000 1.000
#> GSM11318 1 0.0000 0.9835 1.000 0.000
#> GSM28792 1 0.0000 0.9835 1.000 0.000
#> GSM11295 1 0.0000 0.9835 1.000 0.000
#> GSM28793 1 0.0000 0.9835 1.000 0.000
#> GSM11312 1 0.0000 0.9835 1.000 0.000
#> GSM28778 1 0.5629 0.8392 0.868 0.132
#> GSM28796 1 0.0000 0.9835 1.000 0.000
#> GSM11309 1 0.0000 0.9835 1.000 0.000
#> GSM11315 1 0.0000 0.9835 1.000 0.000
#> GSM11306 1 0.0000 0.9835 1.000 0.000
#> GSM28776 1 0.0000 0.9835 1.000 0.000
#> GSM28777 1 0.0000 0.9835 1.000 0.000
#> GSM11316 1 1.0000 0.0153 0.504 0.496
#> GSM11320 1 0.0000 0.9835 1.000 0.000
#> GSM28797 1 0.0000 0.9835 1.000 0.000
#> GSM28786 1 0.0000 0.9835 1.000 0.000
#> GSM28800 1 0.0000 0.9835 1.000 0.000
#> GSM11310 1 0.0000 0.9835 1.000 0.000
#> GSM28787 1 0.0376 0.9800 0.996 0.004
#> GSM11304 1 0.0000 0.9835 1.000 0.000
#> GSM11303 1 0.0000 0.9835 1.000 0.000
#> GSM11317 1 0.0376 0.9800 0.996 0.004
#> GSM11311 1 0.0000 0.9835 1.000 0.000
#> GSM28799 1 0.0000 0.9835 1.000 0.000
#> GSM28791 1 0.0000 0.9835 1.000 0.000
#> GSM28794 2 0.0376 0.9959 0.004 0.996
#> GSM28780 1 0.0000 0.9835 1.000 0.000
#> GSM28795 1 0.0000 0.9835 1.000 0.000
#> GSM11301 2 0.0000 0.9996 0.000 1.000
#> GSM11297 1 0.0000 0.9835 1.000 0.000
#> GSM11298 1 0.0000 0.9835 1.000 0.000
#> GSM11314 1 0.0000 0.9835 1.000 0.000
#> GSM11299 1 0.0000 0.9835 1.000 0.000
#> GSM28783 1 0.0000 0.9835 1.000 0.000
#> GSM11308 1 0.0000 0.9835 1.000 0.000
#> GSM28782 1 0.0000 0.9835 1.000 0.000
#> GSM28779 1 0.0000 0.9835 1.000 0.000
#> GSM11302 1 0.0000 0.9835 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.000 0.968 1.000 0.0 0.000
#> GSM28789 1 0.000 0.968 1.000 0.0 0.000
#> GSM28790 1 0.000 0.968 1.000 0.0 0.000
#> GSM11300 3 0.000 0.954 0.000 0.0 1.000
#> GSM28798 2 0.000 0.987 0.000 1.0 0.000
#> GSM11296 2 0.000 0.987 0.000 1.0 0.000
#> GSM28801 2 0.000 0.987 0.000 1.0 0.000
#> GSM11319 2 0.000 0.987 0.000 1.0 0.000
#> GSM28781 2 0.000 0.987 0.000 1.0 0.000
#> GSM11305 2 0.000 0.987 0.000 1.0 0.000
#> GSM28784 2 0.000 0.987 0.000 1.0 0.000
#> GSM11307 2 0.000 0.987 0.000 1.0 0.000
#> GSM11313 2 0.000 0.987 0.000 1.0 0.000
#> GSM28785 2 0.000 0.987 0.000 1.0 0.000
#> GSM11318 1 0.000 0.968 1.000 0.0 0.000
#> GSM28792 1 0.000 0.968 1.000 0.0 0.000
#> GSM11295 3 0.000 0.954 0.000 0.0 1.000
#> GSM28793 1 0.000 0.968 1.000 0.0 0.000
#> GSM11312 1 0.000 0.968 1.000 0.0 0.000
#> GSM28778 1 0.000 0.968 1.000 0.0 0.000
#> GSM28796 1 0.000 0.968 1.000 0.0 0.000
#> GSM11309 1 0.455 0.758 0.800 0.0 0.200
#> GSM11315 1 0.000 0.968 1.000 0.0 0.000
#> GSM11306 1 0.000 0.968 1.000 0.0 0.000
#> GSM28776 1 0.000 0.968 1.000 0.0 0.000
#> GSM28777 3 0.000 0.954 0.000 0.0 1.000
#> GSM11316 3 0.000 0.954 0.000 0.0 1.000
#> GSM11320 3 0.000 0.954 0.000 0.0 1.000
#> GSM28797 1 0.000 0.968 1.000 0.0 0.000
#> GSM28786 1 0.571 0.549 0.680 0.0 0.320
#> GSM28800 1 0.000 0.968 1.000 0.0 0.000
#> GSM11310 1 0.000 0.968 1.000 0.0 0.000
#> GSM28787 3 0.525 0.612 0.264 0.0 0.736
#> GSM11304 1 0.455 0.758 0.800 0.0 0.200
#> GSM11303 3 0.000 0.954 0.000 0.0 1.000
#> GSM11317 3 0.000 0.954 0.000 0.0 1.000
#> GSM11311 1 0.000 0.968 1.000 0.0 0.000
#> GSM28799 1 0.000 0.968 1.000 0.0 0.000
#> GSM28791 1 0.000 0.968 1.000 0.0 0.000
#> GSM28794 2 0.296 0.847 0.100 0.9 0.000
#> GSM28780 1 0.000 0.968 1.000 0.0 0.000
#> GSM28795 1 0.000 0.968 1.000 0.0 0.000
#> GSM11301 2 0.000 0.987 0.000 1.0 0.000
#> GSM11297 1 0.418 0.794 0.828 0.0 0.172
#> GSM11298 1 0.000 0.968 1.000 0.0 0.000
#> GSM11314 1 0.000 0.968 1.000 0.0 0.000
#> GSM11299 3 0.000 0.954 0.000 0.0 1.000
#> GSM28783 1 0.000 0.968 1.000 0.0 0.000
#> GSM11308 1 0.000 0.968 1.000 0.0 0.000
#> GSM28782 1 0.000 0.968 1.000 0.0 0.000
#> GSM28779 1 0.000 0.968 1.000 0.0 0.000
#> GSM11302 1 0.000 0.968 1.000 0.0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.4382 0.49304 0.296 0.000 0.000 0.704
#> GSM28789 4 0.4277 0.50983 0.280 0.000 0.000 0.720
#> GSM28790 1 0.2149 0.43547 0.912 0.000 0.000 0.088
#> GSM11300 3 0.3764 0.79241 0.000 0.000 0.784 0.216
#> GSM28798 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0000 0.43527 1.000 0.000 0.000 0.000
#> GSM28792 1 0.0000 0.43527 1.000 0.000 0.000 0.000
#> GSM11295 3 0.0000 0.90624 0.000 0.000 1.000 0.000
#> GSM28793 1 0.0188 0.43466 0.996 0.000 0.000 0.004
#> GSM11312 1 0.4877 0.32547 0.592 0.000 0.000 0.408
#> GSM28778 1 0.4679 0.38983 0.648 0.000 0.000 0.352
#> GSM28796 1 0.0000 0.43527 1.000 0.000 0.000 0.000
#> GSM11309 4 0.0524 0.45011 0.008 0.000 0.004 0.988
#> GSM11315 1 0.0000 0.43527 1.000 0.000 0.000 0.000
#> GSM11306 4 0.4830 0.34839 0.392 0.000 0.000 0.608
#> GSM28776 1 0.3610 0.40447 0.800 0.000 0.000 0.200
#> GSM28777 3 0.0000 0.90624 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.90624 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.90624 0.000 0.000 1.000 0.000
#> GSM28797 4 0.4193 0.49800 0.268 0.000 0.000 0.732
#> GSM28786 4 0.3172 0.54191 0.160 0.000 0.000 0.840
#> GSM28800 1 0.4992 0.00338 0.524 0.000 0.000 0.476
#> GSM11310 4 0.3528 0.51962 0.192 0.000 0.000 0.808
#> GSM28787 3 0.5650 0.66040 0.104 0.000 0.716 0.180
#> GSM11304 1 0.7299 0.01242 0.520 0.000 0.184 0.296
#> GSM11303 3 0.0000 0.90624 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.90624 0.000 0.000 1.000 0.000
#> GSM11311 4 0.4998 0.23547 0.488 0.000 0.000 0.512
#> GSM28799 4 0.4605 0.18233 0.336 0.000 0.000 0.664
#> GSM28791 1 0.4804 0.36404 0.616 0.000 0.000 0.384
#> GSM28794 2 0.2888 0.81525 0.004 0.872 0.000 0.124
#> GSM28780 1 0.4804 0.36298 0.616 0.000 0.000 0.384
#> GSM28795 4 0.4830 0.08400 0.392 0.000 0.000 0.608
#> GSM11301 2 0.0000 0.98435 0.000 1.000 0.000 0.000
#> GSM11297 1 0.7344 -0.00576 0.504 0.000 0.180 0.316
#> GSM11298 1 0.4679 0.38983 0.648 0.000 0.000 0.352
#> GSM11314 1 0.4730 0.37219 0.636 0.000 0.000 0.364
#> GSM11299 3 0.4331 0.73317 0.000 0.000 0.712 0.288
#> GSM28783 1 0.4898 0.30275 0.584 0.000 0.000 0.416
#> GSM11308 4 0.4790 0.12584 0.380 0.000 0.000 0.620
#> GSM28782 1 0.4877 0.32020 0.592 0.000 0.000 0.408
#> GSM28779 1 0.4679 0.38983 0.648 0.000 0.000 0.352
#> GSM11302 1 0.4679 0.38983 0.648 0.000 0.000 0.352
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 5 0.3662 0.4775 0.252 0.000 0.000 0.004 0.744
#> GSM28789 5 0.4698 0.4898 0.172 0.000 0.000 0.096 0.732
#> GSM28790 5 0.4430 -0.2287 0.456 0.000 0.000 0.004 0.540
#> GSM11300 3 0.4211 0.5883 0.360 0.000 0.636 0.004 0.000
#> GSM28798 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.4383 0.3741 0.572 0.000 0.000 0.004 0.424
#> GSM28792 1 0.4383 0.3741 0.572 0.000 0.000 0.004 0.424
#> GSM11295 3 0.0000 0.8470 0.000 0.000 1.000 0.000 0.000
#> GSM28793 5 0.4446 -0.3858 0.476 0.000 0.000 0.004 0.520
#> GSM11312 5 0.0404 0.6121 0.012 0.000 0.000 0.000 0.988
#> GSM28778 5 0.1608 0.5928 0.072 0.000 0.000 0.000 0.928
#> GSM28796 1 0.4383 0.3741 0.572 0.000 0.000 0.004 0.424
#> GSM11309 4 0.0162 0.9928 0.004 0.000 0.000 0.996 0.000
#> GSM11315 1 0.4430 0.3430 0.540 0.000 0.000 0.004 0.456
#> GSM11306 5 0.3109 0.5196 0.000 0.000 0.000 0.200 0.800
#> GSM28776 5 0.3790 0.1293 0.272 0.000 0.000 0.004 0.724
#> GSM28777 3 0.0000 0.8470 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.8470 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.8470 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.0290 0.9891 0.000 0.000 0.000 0.992 0.008
#> GSM28786 4 0.0162 0.9928 0.004 0.000 0.000 0.996 0.000
#> GSM28800 1 0.4101 0.0713 0.664 0.000 0.000 0.004 0.332
#> GSM11310 5 0.6303 0.2850 0.268 0.000 0.000 0.204 0.528
#> GSM28787 3 0.4816 0.6289 0.096 0.000 0.732 0.004 0.168
#> GSM11304 1 0.2813 0.3442 0.880 0.000 0.084 0.004 0.032
#> GSM11303 3 0.0000 0.8470 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.8470 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.0162 0.9892 0.004 0.000 0.000 0.996 0.000
#> GSM28799 5 0.4403 0.2370 0.436 0.000 0.000 0.004 0.560
#> GSM28791 5 0.1608 0.5958 0.072 0.000 0.000 0.000 0.928
#> GSM28794 2 0.2690 0.7607 0.000 0.844 0.000 0.000 0.156
#> GSM28780 5 0.2179 0.5803 0.100 0.000 0.000 0.004 0.896
#> GSM28795 5 0.3661 0.4570 0.276 0.000 0.000 0.000 0.724
#> GSM11301 2 0.0000 0.9801 0.000 1.000 0.000 0.000 0.000
#> GSM11297 1 0.2888 0.3728 0.880 0.000 0.060 0.004 0.056
#> GSM11298 5 0.0000 0.6118 0.000 0.000 0.000 0.000 1.000
#> GSM11314 5 0.2648 0.5340 0.152 0.000 0.000 0.000 0.848
#> GSM11299 3 0.4383 0.5189 0.424 0.000 0.572 0.004 0.000
#> GSM28783 5 0.3949 0.4810 0.332 0.000 0.000 0.000 0.668
#> GSM11308 1 0.4450 -0.3496 0.508 0.000 0.000 0.004 0.488
#> GSM28782 5 0.3689 0.4796 0.256 0.000 0.000 0.004 0.740
#> GSM28779 5 0.0000 0.6118 0.000 0.000 0.000 0.000 1.000
#> GSM11302 5 0.0000 0.6118 0.000 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 5 0.2378 0.7188 0.000 0.000 0.000 0.000 0.848 0.152
#> GSM28789 5 0.1341 0.7885 0.000 0.000 0.000 0.024 0.948 0.028
#> GSM28790 1 0.3244 0.5831 0.732 0.000 0.000 0.000 0.268 0.000
#> GSM11300 6 0.3050 0.5708 0.000 0.000 0.236 0.000 0.000 0.764
#> GSM28798 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.1075 0.8855 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM28792 1 0.0937 0.8905 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM11295 3 0.0000 0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28793 1 0.0790 0.8779 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM11312 5 0.0000 0.7983 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM28778 5 0.1196 0.7909 0.040 0.000 0.000 0.000 0.952 0.008
#> GSM28796 1 0.0146 0.8960 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11309 4 0.0000 0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM11315 1 0.0146 0.8960 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11306 5 0.1421 0.7903 0.028 0.000 0.000 0.028 0.944 0.000
#> GSM28776 5 0.3867 0.0539 0.488 0.000 0.000 0.000 0.512 0.000
#> GSM28777 3 0.0000 0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.0000 0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28786 4 0.0000 0.9984 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28800 6 0.5799 0.2616 0.192 0.000 0.000 0.000 0.340 0.468
#> GSM11310 6 0.6708 0.2667 0.048 0.000 0.000 0.204 0.336 0.412
#> GSM28787 3 0.5575 0.1171 0.000 0.000 0.528 0.000 0.168 0.304
#> GSM11304 6 0.2320 0.7061 0.080 0.000 0.024 0.000 0.004 0.892
#> GSM11303 3 0.0000 0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.9122 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.0146 0.9952 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM28799 6 0.3175 0.5861 0.000 0.000 0.000 0.000 0.256 0.744
#> GSM28791 5 0.2350 0.7628 0.036 0.000 0.000 0.000 0.888 0.076
#> GSM28794 2 0.3288 0.5512 0.000 0.724 0.000 0.000 0.276 0.000
#> GSM28780 6 0.4127 0.4359 0.036 0.000 0.000 0.000 0.284 0.680
#> GSM28795 5 0.4463 0.4144 0.036 0.000 0.000 0.000 0.588 0.376
#> GSM11301 2 0.0000 0.9666 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.2113 0.7003 0.092 0.000 0.008 0.000 0.004 0.896
#> GSM11298 5 0.1327 0.7899 0.064 0.000 0.000 0.000 0.936 0.000
#> GSM11314 5 0.4442 0.6438 0.120 0.000 0.000 0.000 0.712 0.168
#> GSM11299 6 0.1910 0.6771 0.000 0.000 0.108 0.000 0.000 0.892
#> GSM28783 5 0.3756 0.4357 0.000 0.000 0.000 0.000 0.600 0.400
#> GSM11308 6 0.0000 0.6951 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM28782 5 0.2823 0.6467 0.000 0.000 0.000 0.000 0.796 0.204
#> GSM28779 5 0.0260 0.7986 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM11302 5 0.0632 0.7991 0.024 0.000 0.000 0.000 0.976 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 tissue(p) k
#> CV:pam 51 0.395 2
#> CV:pam 52 0.372 3
#> CV:pam 24 0.392 4
#> CV:pam 34 0.398 5
#> CV:pam 45 0.475 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.699 0.743 0.879 0.4260 0.509 0.509
#> 3 3 0.891 0.882 0.949 0.4216 0.829 0.686
#> 4 4 0.740 0.781 0.855 0.2018 0.854 0.661
#> 5 5 0.730 0.651 0.821 0.0827 0.878 0.601
#> 6 6 0.698 0.525 0.711 0.0280 0.950 0.749
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
#> GSM28788 1 1.000 0.963 0.504 0.496
#> GSM28789 1 1.000 0.958 0.500 0.500
#> GSM28790 1 1.000 0.963 0.504 0.496
#> GSM11300 2 0.000 0.401 0.000 1.000
#> GSM28798 2 1.000 0.695 0.496 0.504
#> GSM11296 2 1.000 0.695 0.496 0.504
#> GSM28801 2 1.000 0.695 0.496 0.504
#> GSM11319 2 1.000 0.695 0.496 0.504
#> GSM28781 2 1.000 0.695 0.496 0.504
#> GSM11305 2 1.000 0.695 0.496 0.504
#> GSM28784 2 1.000 0.695 0.496 0.504
#> GSM11307 2 1.000 0.695 0.496 0.504
#> GSM11313 2 1.000 0.695 0.496 0.504
#> GSM28785 2 1.000 0.695 0.496 0.504
#> GSM11318 1 1.000 0.963 0.504 0.496
#> GSM28792 1 1.000 0.963 0.504 0.496
#> GSM11295 2 0.000 0.401 0.000 1.000
#> GSM28793 1 1.000 0.963 0.504 0.496
#> GSM11312 1 1.000 0.963 0.504 0.496
#> GSM28778 1 1.000 0.963 0.504 0.496
#> GSM28796 1 1.000 0.963 0.504 0.496
#> GSM11309 1 1.000 0.963 0.504 0.496
#> GSM11315 1 1.000 0.963 0.504 0.496
#> GSM11306 1 1.000 0.963 0.504 0.496
#> GSM28776 1 1.000 0.963 0.504 0.496
#> GSM28777 2 0.000 0.401 0.000 1.000
#> GSM11316 2 0.000 0.401 0.000 1.000
#> GSM11320 2 0.000 0.401 0.000 1.000
#> GSM28797 1 1.000 0.963 0.504 0.496
#> GSM28786 1 1.000 0.963 0.504 0.496
#> GSM28800 1 1.000 0.963 0.504 0.496
#> GSM11310 1 1.000 0.963 0.504 0.496
#> GSM28787 2 0.000 0.401 0.000 1.000
#> GSM11304 1 1.000 0.963 0.504 0.496
#> GSM11303 2 0.000 0.401 0.000 1.000
#> GSM11317 2 0.000 0.401 0.000 1.000
#> GSM11311 1 1.000 0.963 0.504 0.496
#> GSM28799 1 1.000 0.963 0.504 0.496
#> GSM28791 1 1.000 0.963 0.504 0.496
#> GSM28794 1 0.917 -0.594 0.668 0.332
#> GSM28780 1 1.000 0.963 0.504 0.496
#> GSM28795 1 1.000 0.963 0.504 0.496
#> GSM11301 2 1.000 0.694 0.492 0.508
#> GSM11297 1 1.000 0.963 0.504 0.496
#> GSM11298 1 1.000 0.963 0.504 0.496
#> GSM11314 2 1.000 -0.950 0.492 0.508
#> GSM11299 2 0.000 0.401 0.000 1.000
#> GSM28783 1 1.000 0.963 0.504 0.496
#> GSM11308 1 1.000 0.963 0.504 0.496
#> GSM28782 1 1.000 0.963 0.504 0.496
#> GSM28779 1 1.000 0.963 0.504 0.496
#> GSM11302 1 1.000 0.963 0.504 0.496
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.2448 0.8913 0.924 0.000 0.076
#> GSM28789 1 0.4642 0.8387 0.856 0.060 0.084
#> GSM28790 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11318 1 0.0237 0.9179 0.996 0.000 0.004
#> GSM28792 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM28778 1 0.0661 0.9155 0.988 0.008 0.004
#> GSM28796 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11309 1 0.2448 0.8913 0.924 0.000 0.076
#> GSM11315 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11306 1 0.2448 0.8913 0.924 0.000 0.076
#> GSM28776 1 0.0892 0.9146 0.980 0.000 0.020
#> GSM28777 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM28797 1 0.2448 0.8913 0.924 0.000 0.076
#> GSM28786 1 0.2448 0.8913 0.924 0.000 0.076
#> GSM28800 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11310 1 0.0892 0.9146 0.980 0.000 0.020
#> GSM28787 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM11304 1 0.6154 0.3620 0.592 0.000 0.408
#> GSM11303 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM11311 1 0.2356 0.8953 0.928 0.000 0.072
#> GSM28799 1 0.4796 0.7311 0.780 0.000 0.220
#> GSM28791 1 0.0424 0.9173 0.992 0.000 0.008
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM28780 1 0.1289 0.9080 0.968 0.000 0.032
#> GSM28795 1 0.4121 0.7849 0.832 0.000 0.168
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000
#> GSM11297 3 0.6299 -0.0716 0.476 0.000 0.524
#> GSM11298 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11314 1 0.6154 0.3596 0.592 0.000 0.408
#> GSM11299 3 0.0000 0.9314 0.000 0.000 1.000
#> GSM28783 1 0.0747 0.9150 0.984 0.000 0.016
#> GSM11308 1 0.5363 0.6277 0.724 0.000 0.276
#> GSM28782 1 0.0424 0.9173 0.992 0.000 0.008
#> GSM28779 1 0.0000 0.9182 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.9182 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.2197 0.850 0.080 0.004 0.000 0.916
#> GSM28789 4 0.2300 0.842 0.028 0.048 0.000 0.924
#> GSM28790 1 0.0336 0.718 0.992 0.000 0.000 0.008
#> GSM11300 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM28798 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0592 0.720 0.984 0.000 0.000 0.016
#> GSM28792 1 0.3377 0.728 0.848 0.000 0.012 0.140
#> GSM11295 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM28793 1 0.4431 0.654 0.696 0.000 0.000 0.304
#> GSM11312 1 0.3400 0.721 0.820 0.000 0.000 0.180
#> GSM28778 1 0.4730 0.178 0.636 0.000 0.000 0.364
#> GSM28796 1 0.3942 0.704 0.764 0.000 0.000 0.236
#> GSM11309 4 0.0000 0.879 0.000 0.000 0.000 1.000
#> GSM11315 1 0.4222 0.683 0.728 0.000 0.000 0.272
#> GSM11306 4 0.3982 0.663 0.220 0.004 0.000 0.776
#> GSM28776 1 0.4905 0.575 0.632 0.004 0.000 0.364
#> GSM28777 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM28797 4 0.0000 0.879 0.000 0.000 0.000 1.000
#> GSM28786 4 0.0000 0.879 0.000 0.000 0.000 1.000
#> GSM28800 1 0.3975 0.702 0.760 0.000 0.000 0.240
#> GSM11310 1 0.4999 0.359 0.508 0.000 0.000 0.492
#> GSM28787 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM11304 1 0.7762 0.300 0.428 0.000 0.316 0.256
#> GSM11303 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM11311 4 0.3024 0.778 0.148 0.000 0.000 0.852
#> GSM28799 1 0.7740 0.292 0.428 0.000 0.244 0.328
#> GSM28791 1 0.0000 0.715 1.000 0.000 0.000 0.000
#> GSM28794 2 0.4277 0.611 0.000 0.720 0.000 0.280
#> GSM28780 1 0.0000 0.715 1.000 0.000 0.000 0.000
#> GSM28795 1 0.0921 0.710 0.972 0.000 0.000 0.028
#> GSM11301 2 0.0000 0.973 0.000 1.000 0.000 0.000
#> GSM11297 1 0.7762 0.299 0.428 0.000 0.316 0.256
#> GSM11298 1 0.3907 0.706 0.768 0.000 0.000 0.232
#> GSM11314 1 0.4890 0.584 0.776 0.000 0.080 0.144
#> GSM11299 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM28783 1 0.0000 0.715 1.000 0.000 0.000 0.000
#> GSM11308 1 0.3024 0.634 0.852 0.000 0.000 0.148
#> GSM28782 1 0.0921 0.722 0.972 0.000 0.000 0.028
#> GSM28779 1 0.4193 0.686 0.732 0.000 0.000 0.268
#> GSM11302 1 0.3907 0.706 0.768 0.000 0.000 0.232
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.3861 0.65738 0.284 0.000 0.000 0.712 0.004
#> GSM28789 4 0.4687 0.69080 0.200 0.052 0.000 0.736 0.012
#> GSM28790 5 0.4450 0.17112 0.488 0.000 0.000 0.004 0.508
#> GSM11300 3 0.0404 0.96880 0.000 0.000 0.988 0.000 0.012
#> GSM28798 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.95661 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.4367 -0.10995 0.580 0.000 0.000 0.004 0.416
#> GSM28792 1 0.3906 0.36480 0.744 0.000 0.000 0.016 0.240
#> GSM11295 3 0.0703 0.96449 0.000 0.000 0.976 0.000 0.024
#> GSM28793 1 0.2419 0.64665 0.904 0.000 0.004 0.064 0.028
#> GSM11312 1 0.3421 0.62112 0.788 0.000 0.000 0.008 0.204
#> GSM28778 5 0.5341 0.27950 0.356 0.000 0.000 0.064 0.580
#> GSM28796 1 0.0324 0.66627 0.992 0.000 0.000 0.004 0.004
#> GSM11309 4 0.0566 0.71664 0.012 0.000 0.000 0.984 0.004
#> GSM11315 1 0.1768 0.65457 0.924 0.000 0.000 0.072 0.004
#> GSM11306 4 0.4196 0.56527 0.356 0.000 0.000 0.640 0.004
#> GSM28776 1 0.5740 0.40748 0.616 0.000 0.000 0.152 0.232
#> GSM28777 3 0.0000 0.97173 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.97173 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.97173 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.1608 0.72520 0.072 0.000 0.000 0.928 0.000
#> GSM28786 4 0.0451 0.71467 0.008 0.000 0.000 0.988 0.004
#> GSM28800 1 0.0451 0.66825 0.988 0.000 0.000 0.004 0.008
#> GSM11310 4 0.6224 0.26910 0.152 0.000 0.000 0.496 0.352
#> GSM28787 3 0.2929 0.81151 0.000 0.000 0.820 0.000 0.180
#> GSM11304 5 0.7640 0.03170 0.228 0.000 0.080 0.224 0.468
#> GSM11303 3 0.0000 0.97173 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.97173 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.5769 0.58543 0.144 0.000 0.004 0.628 0.224
#> GSM28799 5 0.7307 0.03498 0.264 0.000 0.036 0.248 0.452
#> GSM28791 5 0.4074 0.37217 0.364 0.000 0.000 0.000 0.636
#> GSM28794 2 0.4763 0.44286 0.000 0.632 0.000 0.336 0.032
#> GSM28780 5 0.3521 0.51063 0.232 0.000 0.000 0.004 0.764
#> GSM28795 5 0.3048 0.52424 0.176 0.000 0.000 0.004 0.820
#> GSM11301 2 0.2193 0.87601 0.000 0.912 0.000 0.060 0.028
#> GSM11297 5 0.8029 0.00739 0.192 0.000 0.144 0.224 0.440
#> GSM11298 1 0.2970 0.64934 0.828 0.000 0.000 0.004 0.168
#> GSM11314 5 0.3804 0.49673 0.160 0.000 0.000 0.044 0.796
#> GSM11299 3 0.0880 0.96194 0.000 0.000 0.968 0.000 0.032
#> GSM28783 5 0.3814 0.49160 0.276 0.000 0.000 0.004 0.720
#> GSM11308 5 0.3264 0.52414 0.164 0.000 0.000 0.016 0.820
#> GSM28782 5 0.4443 0.19120 0.472 0.000 0.000 0.004 0.524
#> GSM28779 1 0.3209 0.64787 0.812 0.000 0.000 0.008 0.180
#> GSM11302 1 0.3010 0.64923 0.824 0.000 0.000 0.004 0.172
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.377 0.5067 0.204 0.000 0.000 0.752 0.000 0.044
#> GSM28789 4 0.389 0.5101 0.192 0.000 0.000 0.756 0.004 0.048
#> GSM28790 5 0.553 0.4563 0.336 0.000 0.000 0.000 0.516 0.148
#> GSM11300 3 0.347 0.9034 0.000 0.000 0.804 0.000 0.068 0.128
#> GSM28798 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.238 0.8702 0.000 0.884 0.000 0.000 0.084 0.032
#> GSM11319 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.026 0.9164 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM11305 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.238 0.8702 0.000 0.884 0.000 0.000 0.084 0.032
#> GSM11307 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.000 0.9186 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 5 0.386 0.2602 0.480 0.000 0.000 0.000 0.520 0.000
#> GSM28792 1 0.408 -0.0760 0.648 0.000 0.004 0.008 0.336 0.004
#> GSM11295 3 0.330 0.9088 0.000 0.000 0.820 0.000 0.068 0.112
#> GSM28793 1 0.407 0.4588 0.756 0.000 0.004 0.160 0.000 0.080
#> GSM11312 1 0.442 0.3366 0.604 0.000 0.000 0.000 0.036 0.360
#> GSM28778 5 0.633 0.3498 0.160 0.000 0.000 0.036 0.468 0.336
#> GSM28796 1 0.079 0.4882 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM11309 4 0.514 0.5589 0.000 0.000 0.000 0.612 0.248 0.140
#> GSM11315 1 0.310 0.4290 0.800 0.000 0.000 0.184 0.000 0.016
#> GSM11306 4 0.367 0.4488 0.268 0.000 0.000 0.716 0.000 0.016
#> GSM28776 6 0.617 0.0426 0.368 0.000 0.000 0.252 0.004 0.376
#> GSM28777 3 0.186 0.9193 0.000 0.000 0.920 0.000 0.032 0.048
#> GSM11316 3 0.000 0.9172 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.000 0.9172 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.543 0.5663 0.024 0.000 0.000 0.620 0.248 0.108
#> GSM28786 4 0.514 0.5589 0.000 0.000 0.000 0.612 0.248 0.140
#> GSM28800 1 0.026 0.5100 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM11310 4 0.530 -0.1253 0.076 0.000 0.000 0.540 0.012 0.372
#> GSM28787 3 0.334 0.9075 0.000 0.000 0.816 0.000 0.068 0.116
#> GSM11304 6 0.615 0.2740 0.208 0.000 0.024 0.248 0.000 0.520
#> GSM11303 3 0.000 0.9172 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.000 0.9172 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.449 0.3489 0.072 0.000 0.000 0.692 0.004 0.232
#> GSM28799 6 0.594 0.2587 0.220 0.000 0.008 0.260 0.000 0.512
#> GSM28791 6 0.533 -0.3168 0.104 0.000 0.000 0.000 0.444 0.452
#> GSM28794 2 0.625 0.3437 0.004 0.512 0.000 0.332 0.092 0.060
#> GSM28780 6 0.502 -0.2005 0.076 0.000 0.000 0.000 0.396 0.528
#> GSM28795 6 0.450 -0.1526 0.036 0.000 0.000 0.000 0.392 0.572
#> GSM11301 2 0.448 0.7452 0.000 0.756 0.000 0.120 0.084 0.040
#> GSM11297 6 0.651 0.2815 0.168 0.000 0.068 0.244 0.000 0.520
#> GSM11298 1 0.365 0.3746 0.640 0.000 0.000 0.000 0.000 0.360
#> GSM11314 5 0.594 0.3127 0.084 0.000 0.000 0.044 0.484 0.388
#> GSM11299 3 0.363 0.8957 0.000 0.000 0.788 0.000 0.068 0.144
#> GSM28783 5 0.511 0.3678 0.088 0.000 0.000 0.000 0.536 0.376
#> GSM11308 6 0.457 -0.1342 0.028 0.000 0.000 0.008 0.376 0.588
#> GSM28782 5 0.568 0.4593 0.200 0.000 0.000 0.000 0.520 0.280
#> GSM28779 1 0.401 0.3711 0.632 0.000 0.000 0.004 0.008 0.356
#> GSM11302 1 0.365 0.3746 0.640 0.000 0.000 0.000 0.000 0.360
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 tissue(p) k
#> CV:mclust 41 0.383 2
#> CV:mclust 49 0.368 3
#> CV:mclust 47 0.450 4
#> CV:mclust 38 0.417 5
#> CV:mclust 26 0.384 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.951 0.983 0.3819 0.618 0.618
#> 3 3 0.937 0.931 0.974 0.5529 0.750 0.610
#> 4 4 0.755 0.762 0.867 0.2333 0.854 0.652
#> 5 5 0.923 0.875 0.943 0.1004 0.896 0.639
#> 6 6 0.906 0.854 0.915 0.0402 0.952 0.759
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 5
There is also optional best \(k\) = 2 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.0000 0.988 1.000 0.000
#> GSM28789 1 0.9775 0.254 0.588 0.412
#> GSM28790 1 0.0000 0.988 1.000 0.000
#> GSM11300 1 0.0000 0.988 1.000 0.000
#> GSM28798 2 0.0000 0.961 0.000 1.000
#> GSM11296 2 0.0000 0.961 0.000 1.000
#> GSM28801 2 0.0000 0.961 0.000 1.000
#> GSM11319 2 0.0000 0.961 0.000 1.000
#> GSM28781 2 0.0000 0.961 0.000 1.000
#> GSM11305 2 0.0000 0.961 0.000 1.000
#> GSM28784 2 0.0000 0.961 0.000 1.000
#> GSM11307 2 0.0000 0.961 0.000 1.000
#> GSM11313 2 0.0000 0.961 0.000 1.000
#> GSM28785 2 0.0000 0.961 0.000 1.000
#> GSM11318 1 0.0000 0.988 1.000 0.000
#> GSM28792 1 0.0000 0.988 1.000 0.000
#> GSM11295 1 0.0000 0.988 1.000 0.000
#> GSM28793 1 0.0000 0.988 1.000 0.000
#> GSM11312 1 0.0000 0.988 1.000 0.000
#> GSM28778 2 0.9933 0.152 0.452 0.548
#> GSM28796 1 0.0000 0.988 1.000 0.000
#> GSM11309 1 0.0000 0.988 1.000 0.000
#> GSM11315 1 0.0000 0.988 1.000 0.000
#> GSM11306 1 0.0000 0.988 1.000 0.000
#> GSM28776 1 0.0000 0.988 1.000 0.000
#> GSM28777 1 0.0000 0.988 1.000 0.000
#> GSM11316 1 0.1184 0.972 0.984 0.016
#> GSM11320 1 0.0000 0.988 1.000 0.000
#> GSM28797 1 0.0000 0.988 1.000 0.000
#> GSM28786 1 0.0000 0.988 1.000 0.000
#> GSM28800 1 0.0000 0.988 1.000 0.000
#> GSM11310 1 0.0000 0.988 1.000 0.000
#> GSM28787 1 0.0376 0.984 0.996 0.004
#> GSM11304 1 0.0000 0.988 1.000 0.000
#> GSM11303 1 0.0000 0.988 1.000 0.000
#> GSM11317 1 0.0000 0.988 1.000 0.000
#> GSM11311 1 0.0000 0.988 1.000 0.000
#> GSM28799 1 0.0000 0.988 1.000 0.000
#> GSM28791 1 0.0000 0.988 1.000 0.000
#> GSM28794 2 0.0000 0.961 0.000 1.000
#> GSM28780 1 0.0000 0.988 1.000 0.000
#> GSM28795 1 0.0000 0.988 1.000 0.000
#> GSM11301 2 0.0000 0.961 0.000 1.000
#> GSM11297 1 0.0000 0.988 1.000 0.000
#> GSM11298 1 0.0000 0.988 1.000 0.000
#> GSM11314 1 0.0000 0.988 1.000 0.000
#> GSM11299 1 0.0000 0.988 1.000 0.000
#> GSM28783 1 0.0000 0.988 1.000 0.000
#> GSM11308 1 0.0000 0.988 1.000 0.000
#> GSM28782 1 0.0000 0.988 1.000 0.000
#> GSM28779 1 0.0000 0.988 1.000 0.000
#> GSM11302 1 0.0000 0.988 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28789 1 0.3267 0.853 0.884 0.116 0.000
#> GSM28790 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.932 0.000 0.000 1.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.932 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11309 1 0.5621 0.556 0.692 0.000 0.308
#> GSM11315 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.932 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.932 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.932 0.000 0.000 1.000
#> GSM28797 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28786 3 0.6267 0.105 0.452 0.000 0.548
#> GSM28800 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.932 0.000 0.000 1.000
#> GSM11304 1 0.3619 0.829 0.864 0.000 0.136
#> GSM11303 3 0.0000 0.932 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.932 0.000 0.000 1.000
#> GSM11311 1 0.0237 0.964 0.996 0.000 0.004
#> GSM28799 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28780 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11297 1 0.5706 0.531 0.680 0.000 0.320
#> GSM11298 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11314 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11299 3 0.0000 0.932 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.967 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.967 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.967 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.0000 0.7964 0.000 0.000 0.000 1.000
#> GSM28789 4 0.2635 0.7415 0.016 0.072 0.004 0.908
#> GSM28790 1 0.2281 0.6764 0.904 0.000 0.000 0.096
#> GSM11300 3 0.0000 0.9934 0.000 0.000 1.000 0.000
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.2149 0.6762 0.912 0.000 0.000 0.088
#> GSM28792 1 0.4164 0.6467 0.736 0.000 0.000 0.264
#> GSM11295 3 0.0592 0.9832 0.016 0.000 0.984 0.000
#> GSM28793 1 0.4543 0.6133 0.676 0.000 0.000 0.324
#> GSM11312 1 0.4454 0.5867 0.692 0.000 0.000 0.308
#> GSM28778 1 0.3311 0.6030 0.828 0.000 0.000 0.172
#> GSM28796 1 0.4500 0.6202 0.684 0.000 0.000 0.316
#> GSM11309 4 0.2216 0.7525 0.000 0.000 0.092 0.908
#> GSM11315 1 0.4624 0.5935 0.660 0.000 0.000 0.340
#> GSM11306 4 0.0592 0.7934 0.016 0.000 0.000 0.984
#> GSM28776 1 0.4761 0.5421 0.628 0.000 0.000 0.372
#> GSM28777 3 0.0188 0.9903 0.000 0.000 0.996 0.004
#> GSM11316 3 0.0000 0.9934 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9934 0.000 0.000 1.000 0.000
#> GSM28797 4 0.0000 0.7964 0.000 0.000 0.000 1.000
#> GSM28786 4 0.2216 0.7571 0.000 0.000 0.092 0.908
#> GSM28800 1 0.4564 0.6089 0.672 0.000 0.000 0.328
#> GSM11310 4 0.4730 0.2203 0.364 0.000 0.000 0.636
#> GSM28787 3 0.1109 0.9699 0.028 0.000 0.968 0.004
#> GSM11304 1 0.7084 0.4560 0.560 0.000 0.264 0.176
#> GSM11303 3 0.0000 0.9934 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9934 0.000 0.000 1.000 0.000
#> GSM11311 4 0.1557 0.7644 0.056 0.000 0.000 0.944
#> GSM28799 4 0.5244 0.0428 0.388 0.000 0.012 0.600
#> GSM28791 1 0.2011 0.6451 0.920 0.000 0.000 0.080
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28780 1 0.3306 0.6037 0.840 0.000 0.004 0.156
#> GSM28795 1 0.3448 0.5922 0.828 0.000 0.004 0.168
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11297 1 0.7398 0.2181 0.424 0.000 0.412 0.164
#> GSM11298 1 0.4454 0.6262 0.692 0.000 0.000 0.308
#> GSM11314 1 0.3545 0.5940 0.828 0.000 0.008 0.164
#> GSM11299 3 0.0000 0.9934 0.000 0.000 1.000 0.000
#> GSM28783 1 0.3157 0.6125 0.852 0.000 0.004 0.144
#> GSM11308 1 0.2988 0.6286 0.876 0.000 0.012 0.112
#> GSM28782 1 0.1118 0.6649 0.964 0.000 0.000 0.036
#> GSM28779 1 0.4543 0.6133 0.676 0.000 0.000 0.324
#> GSM11302 1 0.4454 0.6313 0.692 0.000 0.000 0.308
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.0000 0.9145 0.000 0 0.000 1.000 0.000
#> GSM28789 4 0.0000 0.9145 0.000 0 0.000 1.000 0.000
#> GSM28790 1 0.1908 0.8361 0.908 0 0.000 0.000 0.092
#> GSM11300 3 0.0000 0.9792 0.000 0 1.000 0.000 0.000
#> GSM28798 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11318 1 0.1608 0.8454 0.928 0 0.000 0.000 0.072
#> GSM28792 1 0.0404 0.8725 0.988 0 0.000 0.000 0.012
#> GSM11295 3 0.0794 0.9642 0.000 0 0.972 0.000 0.028
#> GSM28793 1 0.0162 0.8717 0.996 0 0.000 0.004 0.000
#> GSM11312 5 0.5006 0.6655 0.116 0 0.000 0.180 0.704
#> GSM28778 5 0.0609 0.9193 0.020 0 0.000 0.000 0.980
#> GSM28796 1 0.0000 0.8718 1.000 0 0.000 0.000 0.000
#> GSM11309 4 0.0000 0.9145 0.000 0 0.000 1.000 0.000
#> GSM11315 1 0.0000 0.8718 1.000 0 0.000 0.000 0.000
#> GSM11306 4 0.0290 0.9109 0.000 0 0.000 0.992 0.008
#> GSM28776 1 0.1774 0.8514 0.932 0 0.000 0.052 0.016
#> GSM28777 3 0.0000 0.9792 0.000 0 1.000 0.000 0.000
#> GSM11316 3 0.0290 0.9758 0.000 0 0.992 0.000 0.008
#> GSM11320 3 0.0000 0.9792 0.000 0 1.000 0.000 0.000
#> GSM28797 4 0.0000 0.9145 0.000 0 0.000 1.000 0.000
#> GSM28786 4 0.0000 0.9145 0.000 0 0.000 1.000 0.000
#> GSM28800 1 0.0798 0.8725 0.976 0 0.000 0.008 0.016
#> GSM11310 1 0.4166 0.4212 0.648 0 0.000 0.348 0.004
#> GSM28787 3 0.3053 0.8549 0.012 0 0.852 0.008 0.128
#> GSM11304 1 0.4848 0.5303 0.644 0 0.320 0.004 0.032
#> GSM11303 3 0.0000 0.9792 0.000 0 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.9792 0.000 0 1.000 0.000 0.000
#> GSM11311 4 0.1197 0.8815 0.048 0 0.000 0.952 0.000
#> GSM28799 4 0.4684 0.0849 0.452 0 0.004 0.536 0.008
#> GSM28791 5 0.0609 0.9196 0.020 0 0.000 0.000 0.980
#> GSM28794 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28780 5 0.0404 0.9217 0.012 0 0.000 0.000 0.988
#> GSM28795 5 0.0290 0.9206 0.008 0 0.000 0.000 0.992
#> GSM11301 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11297 1 0.5042 0.1954 0.512 0 0.460 0.004 0.024
#> GSM11298 1 0.0798 0.8732 0.976 0 0.000 0.008 0.016
#> GSM11314 5 0.0162 0.9175 0.004 0 0.000 0.000 0.996
#> GSM11299 3 0.0000 0.9792 0.000 0 1.000 0.000 0.000
#> GSM28783 5 0.0404 0.9217 0.012 0 0.000 0.000 0.988
#> GSM11308 5 0.0290 0.9206 0.008 0 0.000 0.000 0.992
#> GSM28782 5 0.3730 0.6079 0.288 0 0.000 0.000 0.712
#> GSM28779 1 0.1331 0.8691 0.952 0 0.000 0.008 0.040
#> GSM11302 1 0.1469 0.8691 0.948 0 0.000 0.016 0.036
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.0717 0.980 0.008 0.000 0.000 0.976 0.000 0.016
#> GSM28789 4 0.0291 0.981 0.004 0.000 0.000 0.992 0.000 0.004
#> GSM28790 1 0.1713 0.843 0.928 0.000 0.000 0.000 0.044 0.028
#> GSM11300 3 0.2003 0.857 0.000 0.000 0.884 0.000 0.000 0.116
#> GSM28798 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0837 0.866 0.972 0.000 0.004 0.000 0.004 0.020
#> GSM28792 1 0.0922 0.864 0.968 0.000 0.004 0.000 0.004 0.024
#> GSM11295 3 0.2981 0.826 0.020 0.000 0.848 0.000 0.016 0.116
#> GSM28793 1 0.0146 0.876 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11312 5 0.4636 0.528 0.048 0.000 0.000 0.016 0.672 0.264
#> GSM28778 5 0.0547 0.922 0.000 0.000 0.000 0.000 0.980 0.020
#> GSM28796 1 0.0363 0.876 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM11309 4 0.0363 0.980 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM11315 1 0.0260 0.876 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM11306 4 0.0603 0.976 0.004 0.000 0.000 0.980 0.000 0.016
#> GSM28776 1 0.3017 0.784 0.848 0.000 0.000 0.052 0.004 0.096
#> GSM28777 3 0.0551 0.897 0.004 0.000 0.984 0.004 0.000 0.008
#> GSM11316 3 0.0405 0.897 0.000 0.000 0.988 0.004 0.000 0.008
#> GSM11320 3 0.0713 0.898 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM28797 4 0.0405 0.983 0.004 0.000 0.000 0.988 0.000 0.008
#> GSM28786 4 0.0777 0.979 0.004 0.000 0.000 0.972 0.000 0.024
#> GSM28800 6 0.4027 0.598 0.308 0.000 0.000 0.008 0.012 0.672
#> GSM11310 6 0.4386 0.690 0.200 0.000 0.000 0.092 0.000 0.708
#> GSM28787 3 0.5953 0.645 0.056 0.000 0.648 0.020 0.128 0.148
#> GSM11304 6 0.3832 0.718 0.072 0.000 0.108 0.000 0.020 0.800
#> GSM11303 3 0.0865 0.899 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM11317 3 0.0363 0.899 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM11311 4 0.1176 0.970 0.020 0.000 0.000 0.956 0.000 0.024
#> GSM28799 6 0.5460 0.603 0.256 0.000 0.016 0.124 0.000 0.604
#> GSM28791 5 0.0146 0.920 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM28794 2 0.1204 0.942 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM28780 5 0.0632 0.921 0.000 0.000 0.000 0.000 0.976 0.024
#> GSM28795 5 0.0146 0.920 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM11301 2 0.0146 0.991 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11297 6 0.4029 0.715 0.064 0.000 0.112 0.012 0.016 0.796
#> GSM11298 1 0.0777 0.872 0.972 0.000 0.000 0.000 0.004 0.024
#> GSM11314 5 0.0260 0.916 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM11299 3 0.2597 0.812 0.000 0.000 0.824 0.000 0.000 0.176
#> GSM28783 5 0.1806 0.872 0.004 0.000 0.000 0.000 0.908 0.088
#> GSM11308 5 0.1075 0.913 0.000 0.000 0.000 0.000 0.952 0.048
#> GSM28782 6 0.4598 0.313 0.048 0.000 0.000 0.000 0.360 0.592
#> GSM28779 1 0.4122 -0.165 0.520 0.000 0.000 0.004 0.004 0.472
#> GSM11302 1 0.2373 0.806 0.880 0.000 0.000 0.008 0.008 0.104
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 tissue(p) k
#> CV:NMF 50 0.394 2
#> CV:NMF 51 0.371 3
#> CV:NMF 48 0.451 4
#> CV:NMF 49 0.436 5
#> CV:NMF 50 0.422 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.591 0.945 0.949 0.3466 0.660 0.660
#> 3 3 0.887 0.952 0.979 0.5536 0.821 0.728
#> 4 4 0.777 0.892 0.924 0.2761 0.857 0.703
#> 5 5 0.717 0.611 0.821 0.0898 0.893 0.691
#> 6 6 0.764 0.654 0.825 0.0655 0.902 0.637
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
#> GSM28788 1 0.000 0.959 1.000 0.000
#> GSM28789 1 0.000 0.959 1.000 0.000
#> GSM28790 1 0.000 0.959 1.000 0.000
#> GSM11300 1 0.443 0.911 0.908 0.092
#> GSM28798 2 0.494 1.000 0.108 0.892
#> GSM11296 2 0.494 1.000 0.108 0.892
#> GSM28801 2 0.494 1.000 0.108 0.892
#> GSM11319 2 0.494 1.000 0.108 0.892
#> GSM28781 2 0.494 1.000 0.108 0.892
#> GSM11305 2 0.494 1.000 0.108 0.892
#> GSM28784 2 0.494 1.000 0.108 0.892
#> GSM11307 2 0.494 1.000 0.108 0.892
#> GSM11313 2 0.494 1.000 0.108 0.892
#> GSM28785 2 0.494 1.000 0.108 0.892
#> GSM11318 1 0.000 0.959 1.000 0.000
#> GSM28792 1 0.000 0.959 1.000 0.000
#> GSM11295 1 0.494 0.900 0.892 0.108
#> GSM28793 1 0.000 0.959 1.000 0.000
#> GSM11312 1 0.000 0.959 1.000 0.000
#> GSM28778 1 0.000 0.959 1.000 0.000
#> GSM28796 1 0.000 0.959 1.000 0.000
#> GSM11309 1 0.000 0.959 1.000 0.000
#> GSM11315 1 0.000 0.959 1.000 0.000
#> GSM11306 1 0.000 0.959 1.000 0.000
#> GSM28776 1 0.000 0.959 1.000 0.000
#> GSM28777 1 0.494 0.900 0.892 0.108
#> GSM11316 1 0.494 0.900 0.892 0.108
#> GSM11320 1 0.494 0.900 0.892 0.108
#> GSM28797 1 0.000 0.959 1.000 0.000
#> GSM28786 1 0.000 0.959 1.000 0.000
#> GSM28800 1 0.000 0.959 1.000 0.000
#> GSM11310 1 0.000 0.959 1.000 0.000
#> GSM28787 1 0.494 0.900 0.892 0.108
#> GSM11304 1 0.443 0.911 0.908 0.092
#> GSM11303 1 0.494 0.900 0.892 0.108
#> GSM11317 1 0.494 0.900 0.892 0.108
#> GSM11311 1 0.000 0.959 1.000 0.000
#> GSM28799 1 0.000 0.959 1.000 0.000
#> GSM28791 1 0.000 0.959 1.000 0.000
#> GSM28794 1 0.925 0.383 0.660 0.340
#> GSM28780 1 0.000 0.959 1.000 0.000
#> GSM28795 1 0.000 0.959 1.000 0.000
#> GSM11301 2 0.494 1.000 0.108 0.892
#> GSM11297 1 0.443 0.911 0.908 0.092
#> GSM11298 1 0.000 0.959 1.000 0.000
#> GSM11314 1 0.000 0.959 1.000 0.000
#> GSM11299 1 0.443 0.911 0.908 0.092
#> GSM28783 1 0.000 0.959 1.000 0.000
#> GSM11308 1 0.000 0.959 1.000 0.000
#> GSM28782 1 0.000 0.959 1.000 0.000
#> GSM28779 1 0.000 0.959 1.000 0.000
#> GSM11302 1 0.000 0.959 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.000 0.965 1.000 0.00 0.000
#> GSM28789 1 0.000 0.965 1.000 0.00 0.000
#> GSM28790 1 0.000 0.965 1.000 0.00 0.000
#> GSM11300 1 0.418 0.806 0.828 0.00 0.172
#> GSM28798 2 0.000 1.000 0.000 1.00 0.000
#> GSM11296 2 0.000 1.000 0.000 1.00 0.000
#> GSM28801 2 0.000 1.000 0.000 1.00 0.000
#> GSM11319 2 0.000 1.000 0.000 1.00 0.000
#> GSM28781 2 0.000 1.000 0.000 1.00 0.000
#> GSM11305 2 0.000 1.000 0.000 1.00 0.000
#> GSM28784 2 0.000 1.000 0.000 1.00 0.000
#> GSM11307 2 0.000 1.000 0.000 1.00 0.000
#> GSM11313 2 0.000 1.000 0.000 1.00 0.000
#> GSM28785 2 0.000 1.000 0.000 1.00 0.000
#> GSM11318 1 0.000 0.965 1.000 0.00 0.000
#> GSM28792 1 0.000 0.965 1.000 0.00 0.000
#> GSM11295 3 0.000 1.000 0.000 0.00 1.000
#> GSM28793 1 0.000 0.965 1.000 0.00 0.000
#> GSM11312 1 0.000 0.965 1.000 0.00 0.000
#> GSM28778 1 0.000 0.965 1.000 0.00 0.000
#> GSM28796 1 0.000 0.965 1.000 0.00 0.000
#> GSM11309 1 0.000 0.965 1.000 0.00 0.000
#> GSM11315 1 0.000 0.965 1.000 0.00 0.000
#> GSM11306 1 0.000 0.965 1.000 0.00 0.000
#> GSM28776 1 0.000 0.965 1.000 0.00 0.000
#> GSM28777 3 0.000 1.000 0.000 0.00 1.000
#> GSM11316 3 0.000 1.000 0.000 0.00 1.000
#> GSM11320 3 0.000 1.000 0.000 0.00 1.000
#> GSM28797 1 0.000 0.965 1.000 0.00 0.000
#> GSM28786 1 0.000 0.965 1.000 0.00 0.000
#> GSM28800 1 0.000 0.965 1.000 0.00 0.000
#> GSM11310 1 0.000 0.965 1.000 0.00 0.000
#> GSM28787 3 0.000 1.000 0.000 0.00 1.000
#> GSM11304 1 0.418 0.806 0.828 0.00 0.172
#> GSM11303 3 0.000 1.000 0.000 0.00 1.000
#> GSM11317 3 0.000 1.000 0.000 0.00 1.000
#> GSM11311 1 0.000 0.965 1.000 0.00 0.000
#> GSM28799 1 0.000 0.965 1.000 0.00 0.000
#> GSM28791 1 0.000 0.965 1.000 0.00 0.000
#> GSM28794 1 0.619 0.311 0.580 0.42 0.000
#> GSM28780 1 0.000 0.965 1.000 0.00 0.000
#> GSM28795 1 0.000 0.965 1.000 0.00 0.000
#> GSM11301 2 0.000 1.000 0.000 1.00 0.000
#> GSM11297 1 0.418 0.806 0.828 0.00 0.172
#> GSM11298 1 0.000 0.965 1.000 0.00 0.000
#> GSM11314 1 0.000 0.965 1.000 0.00 0.000
#> GSM11299 1 0.418 0.806 0.828 0.00 0.172
#> GSM28783 1 0.000 0.965 1.000 0.00 0.000
#> GSM11308 1 0.000 0.965 1.000 0.00 0.000
#> GSM28782 1 0.000 0.965 1.000 0.00 0.000
#> GSM28779 1 0.000 0.965 1.000 0.00 0.000
#> GSM11302 1 0.000 0.965 1.000 0.00 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.3123 0.813 0.844 0.00 0.000 0.156
#> GSM28789 1 0.3123 0.813 0.844 0.00 0.000 0.156
#> GSM28790 1 0.1940 0.876 0.924 0.00 0.000 0.076
#> GSM11300 4 0.3402 0.877 0.004 0.00 0.164 0.832
#> GSM28798 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11318 1 0.1940 0.876 0.924 0.00 0.000 0.076
#> GSM28792 1 0.1940 0.876 0.924 0.00 0.000 0.076
#> GSM11295 3 0.0921 0.980 0.000 0.00 0.972 0.028
#> GSM28793 1 0.2149 0.874 0.912 0.00 0.000 0.088
#> GSM11312 1 0.0707 0.882 0.980 0.00 0.000 0.020
#> GSM28778 1 0.1557 0.870 0.944 0.00 0.000 0.056
#> GSM28796 1 0.2149 0.874 0.912 0.00 0.000 0.088
#> GSM11309 4 0.2081 0.854 0.084 0.00 0.000 0.916
#> GSM11315 1 0.2149 0.874 0.912 0.00 0.000 0.088
#> GSM11306 1 0.2760 0.835 0.872 0.00 0.000 0.128
#> GSM28776 1 0.2760 0.835 0.872 0.00 0.000 0.128
#> GSM28777 3 0.0000 0.992 0.000 0.00 1.000 0.000
#> GSM11316 3 0.0000 0.992 0.000 0.00 1.000 0.000
#> GSM11320 3 0.0000 0.992 0.000 0.00 1.000 0.000
#> GSM28797 4 0.2081 0.854 0.084 0.00 0.000 0.916
#> GSM28786 4 0.2081 0.854 0.084 0.00 0.000 0.916
#> GSM28800 1 0.3444 0.814 0.816 0.00 0.000 0.184
#> GSM11310 1 0.3444 0.814 0.816 0.00 0.000 0.184
#> GSM28787 3 0.0921 0.980 0.000 0.00 0.972 0.028
#> GSM11304 4 0.3402 0.877 0.004 0.00 0.164 0.832
#> GSM11303 3 0.0000 0.992 0.000 0.00 1.000 0.000
#> GSM11317 3 0.0000 0.992 0.000 0.00 1.000 0.000
#> GSM11311 1 0.4522 0.590 0.680 0.00 0.000 0.320
#> GSM28799 1 0.3907 0.761 0.768 0.00 0.000 0.232
#> GSM28791 1 0.1389 0.876 0.952 0.00 0.000 0.048
#> GSM28794 1 0.4907 0.334 0.580 0.42 0.000 0.000
#> GSM28780 1 0.1637 0.876 0.940 0.00 0.000 0.060
#> GSM28795 1 0.1637 0.871 0.940 0.00 0.000 0.060
#> GSM11301 2 0.0000 1.000 0.000 1.00 0.000 0.000
#> GSM11297 4 0.3402 0.877 0.004 0.00 0.164 0.832
#> GSM11298 1 0.2081 0.875 0.916 0.00 0.000 0.084
#> GSM11314 1 0.1716 0.872 0.936 0.00 0.000 0.064
#> GSM11299 4 0.3402 0.877 0.004 0.00 0.164 0.832
#> GSM28783 1 0.1637 0.876 0.940 0.00 0.000 0.060
#> GSM11308 1 0.1637 0.876 0.940 0.00 0.000 0.060
#> GSM28782 1 0.1389 0.879 0.952 0.00 0.000 0.048
#> GSM28779 1 0.0707 0.882 0.980 0.00 0.000 0.020
#> GSM11302 1 0.0707 0.882 0.980 0.00 0.000 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 5 0.5473 0.650 0.416 0.00 0.000 0.064 0.520
#> GSM28789 5 0.5473 0.650 0.416 0.00 0.000 0.064 0.520
#> GSM28790 1 0.1522 0.628 0.944 0.00 0.000 0.044 0.012
#> GSM11300 4 0.1041 0.871 0.004 0.00 0.032 0.964 0.000
#> GSM28798 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11318 1 0.1522 0.628 0.944 0.00 0.000 0.044 0.012
#> GSM28792 1 0.1522 0.628 0.944 0.00 0.000 0.044 0.012
#> GSM11295 3 0.0404 0.662 0.000 0.00 0.988 0.012 0.000
#> GSM28793 1 0.1197 0.629 0.952 0.00 0.000 0.048 0.000
#> GSM11312 1 0.4251 -0.170 0.672 0.00 0.000 0.012 0.316
#> GSM28778 5 0.4256 0.737 0.436 0.00 0.000 0.000 0.564
#> GSM28796 1 0.1197 0.629 0.952 0.00 0.000 0.048 0.000
#> GSM11309 4 0.3454 0.841 0.064 0.00 0.000 0.836 0.100
#> GSM11315 1 0.1197 0.629 0.952 0.00 0.000 0.048 0.000
#> GSM11306 1 0.5286 -0.587 0.504 0.00 0.000 0.048 0.448
#> GSM28776 1 0.5286 -0.587 0.504 0.00 0.000 0.048 0.448
#> GSM28777 3 0.5825 0.872 0.000 0.00 0.564 0.116 0.320
#> GSM11316 3 0.5825 0.872 0.000 0.00 0.564 0.116 0.320
#> GSM11320 3 0.5825 0.872 0.000 0.00 0.564 0.116 0.320
#> GSM28797 4 0.3454 0.841 0.064 0.00 0.000 0.836 0.100
#> GSM28786 4 0.3454 0.841 0.064 0.00 0.000 0.836 0.100
#> GSM28800 1 0.2674 0.577 0.856 0.00 0.000 0.140 0.004
#> GSM11310 1 0.2674 0.577 0.856 0.00 0.000 0.140 0.004
#> GSM28787 3 0.0404 0.662 0.000 0.00 0.988 0.012 0.000
#> GSM11304 4 0.1041 0.871 0.004 0.00 0.032 0.964 0.000
#> GSM11303 3 0.5825 0.872 0.000 0.00 0.564 0.116 0.320
#> GSM11317 3 0.5825 0.872 0.000 0.00 0.564 0.116 0.320
#> GSM11311 1 0.4644 0.346 0.680 0.00 0.000 0.280 0.040
#> GSM28799 1 0.3621 0.513 0.788 0.00 0.000 0.192 0.020
#> GSM28791 1 0.3857 0.105 0.688 0.00 0.000 0.000 0.312
#> GSM28794 2 0.6671 -0.385 0.340 0.42 0.000 0.000 0.240
#> GSM28780 1 0.3177 0.423 0.792 0.00 0.000 0.000 0.208
#> GSM28795 5 0.4242 0.731 0.428 0.00 0.000 0.000 0.572
#> GSM11301 2 0.0000 0.933 0.000 1.00 0.000 0.000 0.000
#> GSM11297 4 0.1041 0.871 0.004 0.00 0.032 0.964 0.000
#> GSM11298 1 0.1597 0.626 0.940 0.00 0.000 0.048 0.012
#> GSM11314 5 0.4403 0.740 0.436 0.00 0.000 0.004 0.560
#> GSM11299 4 0.1041 0.871 0.004 0.00 0.032 0.964 0.000
#> GSM28783 1 0.3143 0.423 0.796 0.00 0.000 0.000 0.204
#> GSM11308 1 0.3177 0.423 0.792 0.00 0.000 0.000 0.208
#> GSM28782 1 0.2813 0.477 0.832 0.00 0.000 0.000 0.168
#> GSM28779 1 0.4313 -0.343 0.636 0.00 0.000 0.008 0.356
#> GSM11302 1 0.3783 0.115 0.740 0.00 0.000 0.008 0.252
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 5 0.6301 0.236 0.304 0.00 0.000 0.096 0.520 0.080
#> GSM28789 5 0.6301 0.236 0.304 0.00 0.000 0.096 0.520 0.080
#> GSM28790 1 0.0508 0.731 0.984 0.00 0.000 0.000 0.004 0.012
#> GSM11300 4 0.1967 0.869 0.000 0.00 0.084 0.904 0.000 0.012
#> GSM28798 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0508 0.731 0.984 0.00 0.000 0.000 0.004 0.012
#> GSM28792 1 0.0508 0.731 0.984 0.00 0.000 0.000 0.004 0.012
#> GSM11295 6 0.3409 1.000 0.000 0.00 0.300 0.000 0.000 0.700
#> GSM28793 1 0.0000 0.735 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11312 1 0.4141 0.209 0.596 0.00 0.000 0.000 0.388 0.016
#> GSM28778 5 0.3364 0.397 0.024 0.00 0.000 0.000 0.780 0.196
#> GSM28796 1 0.0000 0.735 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11309 4 0.2816 0.827 0.028 0.00 0.000 0.876 0.060 0.036
#> GSM11315 1 0.0000 0.735 1.000 0.00 0.000 0.000 0.000 0.000
#> GSM11306 5 0.5989 0.128 0.404 0.00 0.000 0.068 0.468 0.060
#> GSM28776 5 0.5989 0.128 0.404 0.00 0.000 0.068 0.468 0.060
#> GSM28777 3 0.0000 1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM28797 4 0.2816 0.827 0.028 0.00 0.000 0.876 0.060 0.036
#> GSM28786 4 0.2816 0.827 0.028 0.00 0.000 0.876 0.060 0.036
#> GSM28800 1 0.2162 0.692 0.896 0.00 0.000 0.088 0.012 0.004
#> GSM11310 1 0.2162 0.692 0.896 0.00 0.000 0.088 0.012 0.004
#> GSM28787 6 0.3409 1.000 0.000 0.00 0.300 0.000 0.000 0.700
#> GSM11304 4 0.1967 0.869 0.000 0.00 0.084 0.904 0.000 0.012
#> GSM11303 3 0.0000 1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 1.000 0.000 0.00 1.000 0.000 0.000 0.000
#> GSM11311 1 0.4433 0.384 0.668 0.00 0.000 0.288 0.016 0.028
#> GSM28799 1 0.3147 0.632 0.828 0.00 0.000 0.140 0.016 0.016
#> GSM28791 5 0.4167 0.334 0.344 0.00 0.000 0.000 0.632 0.024
#> GSM28794 2 0.6243 -0.152 0.276 0.42 0.000 0.000 0.296 0.008
#> GSM28780 5 0.4325 0.233 0.456 0.00 0.000 0.000 0.524 0.020
#> GSM28795 5 0.3424 0.394 0.024 0.00 0.000 0.000 0.772 0.204
#> GSM11301 2 0.0000 0.934 0.000 1.00 0.000 0.000 0.000 0.000
#> GSM11297 4 0.1967 0.869 0.000 0.00 0.084 0.904 0.000 0.012
#> GSM11298 1 0.0458 0.731 0.984 0.00 0.000 0.000 0.016 0.000
#> GSM11314 5 0.3333 0.404 0.024 0.00 0.000 0.000 0.784 0.192
#> GSM11299 4 0.1967 0.869 0.000 0.00 0.084 0.904 0.000 0.012
#> GSM28783 5 0.4335 0.209 0.472 0.00 0.000 0.000 0.508 0.020
#> GSM11308 5 0.4325 0.233 0.456 0.00 0.000 0.000 0.524 0.020
#> GSM28782 1 0.4333 -0.236 0.512 0.00 0.000 0.000 0.468 0.020
#> GSM28779 1 0.4269 0.146 0.568 0.00 0.000 0.000 0.412 0.020
#> GSM11302 1 0.3619 0.361 0.680 0.00 0.000 0.000 0.316 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 tissue(p) k
#> MAD:hclust 51 0.395 2
#> MAD:hclust 51 0.371 3
#> MAD:hclust 51 0.453 4
#> MAD:hclust 40 0.414 5
#> MAD:hclust 35 0.394 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.369 0.788 0.812 0.3639 0.638 0.638
#> 3 3 1.000 0.971 0.975 0.5249 0.790 0.670
#> 4 4 0.696 0.561 0.802 0.2567 0.902 0.771
#> 5 5 0.669 0.747 0.808 0.1037 0.830 0.514
#> 6 6 0.746 0.669 0.812 0.0557 0.992 0.958
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
#> GSM28788 1 0.980 0.783 0.584 0.416
#> GSM28789 1 0.980 0.783 0.584 0.416
#> GSM28790 1 0.980 0.783 0.584 0.416
#> GSM11300 1 0.000 0.584 1.000 0.000
#> GSM28798 2 0.000 0.997 0.000 1.000
#> GSM11296 2 0.000 0.997 0.000 1.000
#> GSM28801 2 0.000 0.997 0.000 1.000
#> GSM11319 2 0.000 0.997 0.000 1.000
#> GSM28781 2 0.000 0.997 0.000 1.000
#> GSM11305 2 0.000 0.997 0.000 1.000
#> GSM28784 2 0.000 0.997 0.000 1.000
#> GSM11307 2 0.000 0.997 0.000 1.000
#> GSM11313 2 0.000 0.997 0.000 1.000
#> GSM28785 2 0.000 0.997 0.000 1.000
#> GSM11318 1 0.980 0.783 0.584 0.416
#> GSM28792 1 0.980 0.783 0.584 0.416
#> GSM11295 1 0.141 0.572 0.980 0.020
#> GSM28793 1 0.980 0.783 0.584 0.416
#> GSM11312 1 0.980 0.783 0.584 0.416
#> GSM28778 1 0.980 0.783 0.584 0.416
#> GSM28796 1 0.980 0.783 0.584 0.416
#> GSM11309 1 0.802 0.738 0.756 0.244
#> GSM11315 1 0.980 0.783 0.584 0.416
#> GSM11306 1 0.980 0.783 0.584 0.416
#> GSM28776 1 0.980 0.783 0.584 0.416
#> GSM28777 1 0.141 0.572 0.980 0.020
#> GSM11316 1 0.141 0.572 0.980 0.020
#> GSM11320 1 0.141 0.572 0.980 0.020
#> GSM28797 1 0.802 0.738 0.756 0.244
#> GSM28786 1 0.671 0.699 0.824 0.176
#> GSM28800 1 0.978 0.784 0.588 0.412
#> GSM11310 1 0.975 0.783 0.592 0.408
#> GSM28787 1 0.141 0.572 0.980 0.020
#> GSM11304 1 0.753 0.724 0.784 0.216
#> GSM11303 1 0.141 0.572 0.980 0.020
#> GSM11317 1 0.141 0.572 0.980 0.020
#> GSM11311 1 0.866 0.753 0.712 0.288
#> GSM28799 1 0.871 0.754 0.708 0.292
#> GSM28791 1 0.980 0.783 0.584 0.416
#> GSM28794 2 0.141 0.966 0.020 0.980
#> GSM28780 1 0.978 0.784 0.588 0.412
#> GSM28795 1 0.978 0.784 0.588 0.412
#> GSM11301 2 0.000 0.997 0.000 1.000
#> GSM11297 1 0.753 0.724 0.784 0.216
#> GSM11298 1 0.980 0.783 0.584 0.416
#> GSM11314 1 0.978 0.784 0.588 0.412
#> GSM11299 1 0.000 0.584 1.000 0.000
#> GSM28783 1 0.978 0.784 0.588 0.412
#> GSM11308 1 0.827 0.744 0.740 0.260
#> GSM28782 1 0.978 0.784 0.588 0.412
#> GSM28779 1 0.980 0.783 0.584 0.416
#> GSM11302 1 0.980 0.783 0.584 0.416
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0592 0.989 0.988 0.000 0.012
#> GSM28789 1 0.0592 0.989 0.988 0.000 0.012
#> GSM28790 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11300 3 0.1289 0.995 0.032 0.000 0.968
#> GSM28798 2 0.1289 0.946 0.032 0.968 0.000
#> GSM11296 2 0.1289 0.946 0.032 0.968 0.000
#> GSM28801 2 0.1711 0.943 0.032 0.960 0.008
#> GSM11319 2 0.1289 0.946 0.032 0.968 0.000
#> GSM28781 2 0.1289 0.946 0.032 0.968 0.000
#> GSM11305 2 0.1289 0.946 0.032 0.968 0.000
#> GSM28784 2 0.2176 0.937 0.032 0.948 0.020
#> GSM11307 2 0.1289 0.946 0.032 0.968 0.000
#> GSM11313 2 0.1289 0.946 0.032 0.968 0.000
#> GSM28785 2 0.1289 0.946 0.032 0.968 0.000
#> GSM11318 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11295 3 0.2569 0.981 0.032 0.032 0.936
#> GSM28793 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11309 1 0.0592 0.989 0.988 0.000 0.012
#> GSM11315 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11306 1 0.0592 0.989 0.988 0.000 0.012
#> GSM28776 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28777 3 0.1289 0.995 0.032 0.000 0.968
#> GSM11316 3 0.1289 0.995 0.032 0.000 0.968
#> GSM11320 3 0.1289 0.995 0.032 0.000 0.968
#> GSM28797 1 0.0592 0.989 0.988 0.000 0.012
#> GSM28786 1 0.1289 0.974 0.968 0.000 0.032
#> GSM28800 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28787 3 0.2569 0.981 0.032 0.032 0.936
#> GSM11304 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11303 3 0.1289 0.995 0.032 0.000 0.968
#> GSM11317 3 0.1289 0.995 0.032 0.000 0.968
#> GSM11311 1 0.0592 0.989 0.988 0.000 0.012
#> GSM28799 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28794 2 0.6962 0.340 0.412 0.568 0.020
#> GSM28780 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11301 2 0.2176 0.937 0.032 0.948 0.020
#> GSM11297 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11298 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11314 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11299 3 0.1289 0.995 0.032 0.000 0.968
#> GSM28783 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.997 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.997 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.997 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.4925 -0.2172 0.572 0.000 0.000 0.428
#> GSM28789 1 0.4916 -0.2114 0.576 0.000 0.000 0.424
#> GSM28790 1 0.4522 0.4723 0.680 0.000 0.000 0.320
#> GSM11300 3 0.1940 0.9468 0.000 0.000 0.924 0.076
#> GSM28798 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0336 0.9372 0.000 0.992 0.000 0.008
#> GSM11319 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM28784 2 0.1557 0.9137 0.000 0.944 0.000 0.056
#> GSM11307 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.9402 0.000 1.000 0.000 0.000
#> GSM11318 1 0.4679 0.4556 0.648 0.000 0.000 0.352
#> GSM28792 1 0.4790 0.4417 0.620 0.000 0.000 0.380
#> GSM11295 3 0.2011 0.9526 0.000 0.000 0.920 0.080
#> GSM28793 1 0.4804 0.4389 0.616 0.000 0.000 0.384
#> GSM11312 1 0.2281 0.4253 0.904 0.000 0.000 0.096
#> GSM28778 1 0.1867 0.4050 0.928 0.000 0.000 0.072
#> GSM28796 1 0.4804 0.4389 0.616 0.000 0.000 0.384
#> GSM11309 4 0.4605 0.6352 0.336 0.000 0.000 0.664
#> GSM11315 1 0.4804 0.4389 0.616 0.000 0.000 0.384
#> GSM11306 1 0.4776 -0.0673 0.624 0.000 0.000 0.376
#> GSM28776 1 0.4543 0.3532 0.676 0.000 0.000 0.324
#> GSM28777 3 0.0592 0.9698 0.000 0.000 0.984 0.016
#> GSM11316 3 0.0000 0.9717 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9717 0.000 0.000 1.000 0.000
#> GSM28797 4 0.4605 0.6352 0.336 0.000 0.000 0.664
#> GSM28786 4 0.4677 0.6204 0.316 0.000 0.004 0.680
#> GSM28800 1 0.4730 0.4337 0.636 0.000 0.000 0.364
#> GSM11310 4 0.5000 -0.2802 0.500 0.000 0.000 0.500
#> GSM28787 3 0.2011 0.9526 0.000 0.000 0.920 0.080
#> GSM11304 1 0.4999 -0.0516 0.508 0.000 0.000 0.492
#> GSM11303 3 0.0000 0.9717 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9717 0.000 0.000 1.000 0.000
#> GSM11311 4 0.4164 0.4018 0.264 0.000 0.000 0.736
#> GSM28799 1 0.4955 0.0153 0.556 0.000 0.000 0.444
#> GSM28791 1 0.0188 0.4530 0.996 0.000 0.000 0.004
#> GSM28794 2 0.6988 0.2223 0.380 0.500 0.000 0.120
#> GSM28780 1 0.1302 0.4305 0.956 0.000 0.000 0.044
#> GSM28795 1 0.1940 0.4030 0.924 0.000 0.000 0.076
#> GSM11301 2 0.2345 0.8871 0.000 0.900 0.000 0.100
#> GSM11297 1 0.5000 -0.0627 0.504 0.000 0.000 0.496
#> GSM11298 1 0.4804 0.4389 0.616 0.000 0.000 0.384
#> GSM11314 1 0.2647 0.3532 0.880 0.000 0.000 0.120
#> GSM11299 3 0.1940 0.9468 0.000 0.000 0.924 0.076
#> GSM28783 1 0.1792 0.4154 0.932 0.000 0.000 0.068
#> GSM11308 1 0.1867 0.4422 0.928 0.000 0.000 0.072
#> GSM28782 1 0.3356 0.4721 0.824 0.000 0.000 0.176
#> GSM28779 1 0.4679 0.4640 0.648 0.000 0.000 0.352
#> GSM11302 1 0.4679 0.4640 0.648 0.000 0.000 0.352
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.5928 0.547 0.108 0.000 0.000 0.500 0.392
#> GSM28789 4 0.5928 0.547 0.108 0.000 0.000 0.500 0.392
#> GSM28790 1 0.3561 0.759 0.740 0.000 0.000 0.000 0.260
#> GSM11300 3 0.3085 0.851 0.032 0.000 0.852 0.116 0.000
#> GSM28798 2 0.0290 0.930 0.000 0.992 0.000 0.008 0.000
#> GSM11296 2 0.0000 0.931 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0404 0.928 0.000 0.988 0.000 0.012 0.000
#> GSM11319 2 0.0000 0.931 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0290 0.929 0.000 0.992 0.000 0.008 0.000
#> GSM11305 2 0.0290 0.930 0.000 0.992 0.000 0.008 0.000
#> GSM28784 2 0.2569 0.877 0.040 0.892 0.000 0.068 0.000
#> GSM11307 2 0.0290 0.930 0.000 0.992 0.000 0.008 0.000
#> GSM11313 2 0.0290 0.930 0.000 0.992 0.000 0.008 0.000
#> GSM28785 2 0.0000 0.931 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.3491 0.779 0.768 0.000 0.000 0.004 0.228
#> GSM28792 1 0.3461 0.781 0.772 0.000 0.000 0.004 0.224
#> GSM11295 3 0.4089 0.850 0.100 0.000 0.804 0.088 0.008
#> GSM28793 1 0.3461 0.781 0.772 0.000 0.000 0.004 0.224
#> GSM11312 5 0.4648 0.602 0.156 0.000 0.000 0.104 0.740
#> GSM28778 5 0.0703 0.848 0.024 0.000 0.000 0.000 0.976
#> GSM28796 1 0.3461 0.781 0.772 0.000 0.000 0.004 0.224
#> GSM11309 4 0.4262 0.708 0.100 0.000 0.000 0.776 0.124
#> GSM11315 1 0.3461 0.781 0.772 0.000 0.000 0.004 0.224
#> GSM11306 4 0.5844 0.494 0.096 0.000 0.000 0.484 0.420
#> GSM28776 1 0.6492 0.470 0.456 0.000 0.000 0.196 0.348
#> GSM28777 3 0.0290 0.924 0.008 0.000 0.992 0.000 0.000
#> GSM11316 3 0.0451 0.923 0.008 0.000 0.988 0.004 0.000
#> GSM11320 3 0.0000 0.925 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.4262 0.708 0.100 0.000 0.000 0.776 0.124
#> GSM28786 4 0.4325 0.704 0.100 0.000 0.004 0.780 0.116
#> GSM28800 1 0.4794 0.682 0.624 0.000 0.000 0.032 0.344
#> GSM11310 1 0.5983 0.644 0.580 0.000 0.000 0.168 0.252
#> GSM28787 3 0.4089 0.850 0.100 0.000 0.804 0.088 0.008
#> GSM11304 1 0.6961 0.306 0.424 0.000 0.012 0.228 0.336
#> GSM11303 3 0.0000 0.925 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.925 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.5193 0.369 0.364 0.000 0.000 0.584 0.052
#> GSM28799 1 0.6621 0.438 0.448 0.000 0.000 0.240 0.312
#> GSM28791 5 0.1544 0.828 0.068 0.000 0.000 0.000 0.932
#> GSM28794 2 0.7646 0.271 0.160 0.484 0.000 0.108 0.248
#> GSM28780 5 0.0865 0.848 0.024 0.000 0.000 0.004 0.972
#> GSM28795 5 0.0671 0.845 0.016 0.000 0.000 0.004 0.980
#> GSM11301 2 0.3506 0.838 0.064 0.832 0.000 0.104 0.000
#> GSM11297 1 0.6961 0.306 0.424 0.000 0.012 0.228 0.336
#> GSM11298 1 0.3305 0.780 0.776 0.000 0.000 0.000 0.224
#> GSM11314 5 0.1331 0.805 0.008 0.000 0.000 0.040 0.952
#> GSM11299 3 0.3085 0.851 0.032 0.000 0.852 0.116 0.000
#> GSM28783 5 0.0771 0.844 0.020 0.000 0.000 0.004 0.976
#> GSM11308 5 0.1965 0.796 0.052 0.000 0.000 0.024 0.924
#> GSM28782 5 0.3949 0.197 0.332 0.000 0.000 0.000 0.668
#> GSM28779 1 0.3790 0.754 0.724 0.000 0.000 0.004 0.272
#> GSM11302 1 0.3814 0.753 0.720 0.000 0.000 0.004 0.276
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.6630 0.402 0.064 0.000 0.000 0.472 0.300 0.164
#> GSM28789 4 0.6630 0.402 0.064 0.000 0.000 0.472 0.300 0.164
#> GSM28790 1 0.0632 0.704 0.976 0.000 0.000 0.000 0.024 0.000
#> GSM11300 3 0.4623 0.749 0.000 0.000 0.736 0.104 0.028 0.132
#> GSM28798 2 0.0551 0.931 0.000 0.984 0.000 0.004 0.004 0.008
#> GSM11296 2 0.0000 0.933 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0405 0.928 0.000 0.988 0.000 0.008 0.000 0.004
#> GSM11319 2 0.0000 0.933 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0260 0.930 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM11305 2 0.0551 0.931 0.000 0.984 0.000 0.004 0.004 0.008
#> GSM28784 2 0.2219 0.782 0.000 0.864 0.000 0.000 0.000 0.136
#> GSM11307 2 0.0551 0.931 0.000 0.984 0.000 0.004 0.004 0.008
#> GSM11313 2 0.0551 0.931 0.000 0.984 0.000 0.004 0.004 0.008
#> GSM28785 2 0.0000 0.933 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0508 0.708 0.984 0.000 0.000 0.004 0.012 0.000
#> GSM28792 1 0.0405 0.709 0.988 0.000 0.000 0.004 0.008 0.000
#> GSM11295 3 0.3837 0.789 0.000 0.000 0.752 0.016 0.020 0.212
#> GSM28793 1 0.0520 0.710 0.984 0.000 0.000 0.008 0.008 0.000
#> GSM11312 5 0.6242 0.418 0.208 0.000 0.000 0.072 0.572 0.148
#> GSM28778 5 0.2900 0.767 0.088 0.000 0.000 0.008 0.860 0.044
#> GSM28796 1 0.0520 0.710 0.984 0.000 0.000 0.008 0.008 0.000
#> GSM11309 4 0.1320 0.603 0.036 0.000 0.000 0.948 0.016 0.000
#> GSM11315 1 0.0520 0.710 0.984 0.000 0.000 0.008 0.008 0.000
#> GSM11306 4 0.6778 0.299 0.084 0.000 0.000 0.440 0.332 0.144
#> GSM28776 1 0.7026 0.284 0.484 0.000 0.000 0.180 0.176 0.160
#> GSM28777 3 0.1478 0.871 0.000 0.000 0.944 0.004 0.032 0.020
#> GSM11316 3 0.0146 0.877 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM11320 3 0.0000 0.878 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.1320 0.603 0.036 0.000 0.000 0.948 0.016 0.000
#> GSM28786 4 0.1010 0.596 0.036 0.000 0.000 0.960 0.004 0.000
#> GSM28800 1 0.5145 0.568 0.660 0.000 0.000 0.024 0.096 0.220
#> GSM11310 1 0.6115 0.518 0.588 0.000 0.000 0.160 0.064 0.188
#> GSM28787 3 0.3837 0.789 0.000 0.000 0.752 0.016 0.020 0.212
#> GSM11304 1 0.7830 0.192 0.324 0.000 0.020 0.212 0.132 0.312
#> GSM11303 3 0.0000 0.878 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.878 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.3151 0.430 0.252 0.000 0.000 0.748 0.000 0.000
#> GSM28799 1 0.6873 0.406 0.484 0.000 0.000 0.204 0.096 0.216
#> GSM28791 5 0.1910 0.777 0.108 0.000 0.000 0.000 0.892 0.000
#> GSM28794 6 0.7459 0.000 0.140 0.304 0.000 0.016 0.132 0.408
#> GSM28780 5 0.2860 0.770 0.100 0.000 0.000 0.000 0.852 0.048
#> GSM28795 5 0.2711 0.769 0.084 0.000 0.000 0.008 0.872 0.036
#> GSM11301 2 0.3448 0.503 0.000 0.716 0.000 0.004 0.000 0.280
#> GSM11297 1 0.7830 0.192 0.324 0.000 0.020 0.212 0.132 0.312
#> GSM11298 1 0.0291 0.707 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM11314 5 0.3300 0.747 0.076 0.000 0.000 0.016 0.840 0.068
#> GSM11299 3 0.4873 0.724 0.000 0.000 0.708 0.104 0.028 0.160
#> GSM28783 5 0.3424 0.751 0.096 0.000 0.000 0.000 0.812 0.092
#> GSM11308 5 0.3891 0.669 0.072 0.000 0.000 0.008 0.780 0.140
#> GSM28782 5 0.5623 0.263 0.372 0.000 0.000 0.000 0.476 0.152
#> GSM28779 1 0.3207 0.660 0.844 0.000 0.000 0.016 0.048 0.092
#> GSM11302 1 0.2945 0.664 0.864 0.000 0.000 0.016 0.048 0.072
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 tissue(p) k
#> MAD:kmeans 52 0.396 2
#> MAD:kmeans 51 0.371 3
#> MAD:kmeans 23 0.389 4
#> MAD:kmeans 44 0.451 5
#> MAD:kmeans 41 0.501 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.720 0.890 0.950 0.4335 0.581 0.581
#> 3 3 0.969 0.912 0.966 0.5080 0.703 0.512
#> 4 4 0.783 0.785 0.901 0.1587 0.845 0.576
#> 5 5 0.922 0.860 0.938 0.0653 0.916 0.674
#> 6 6 0.859 0.767 0.866 0.0358 0.953 0.765
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 3
There is also optional best \(k\) = 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.000 0.941 1.000 0.000
#> GSM28789 2 0.827 0.662 0.260 0.740
#> GSM28790 1 0.000 0.941 1.000 0.000
#> GSM11300 1 0.000 0.941 1.000 0.000
#> GSM28798 2 0.000 0.942 0.000 1.000
#> GSM11296 2 0.000 0.942 0.000 1.000
#> GSM28801 2 0.000 0.942 0.000 1.000
#> GSM11319 2 0.000 0.942 0.000 1.000
#> GSM28781 2 0.000 0.942 0.000 1.000
#> GSM11305 2 0.000 0.942 0.000 1.000
#> GSM28784 2 0.000 0.942 0.000 1.000
#> GSM11307 2 0.000 0.942 0.000 1.000
#> GSM11313 2 0.000 0.942 0.000 1.000
#> GSM28785 2 0.000 0.942 0.000 1.000
#> GSM11318 1 0.000 0.941 1.000 0.000
#> GSM28792 1 0.000 0.941 1.000 0.000
#> GSM11295 1 0.827 0.687 0.740 0.260
#> GSM28793 1 0.000 0.941 1.000 0.000
#> GSM11312 1 0.000 0.941 1.000 0.000
#> GSM28778 2 0.827 0.662 0.260 0.740
#> GSM28796 1 0.000 0.941 1.000 0.000
#> GSM11309 1 0.000 0.941 1.000 0.000
#> GSM11315 1 0.000 0.941 1.000 0.000
#> GSM11306 1 0.000 0.941 1.000 0.000
#> GSM28776 1 0.000 0.941 1.000 0.000
#> GSM28777 1 0.827 0.687 0.740 0.260
#> GSM11316 1 0.876 0.634 0.704 0.296
#> GSM11320 1 0.827 0.687 0.740 0.260
#> GSM28797 1 0.000 0.941 1.000 0.000
#> GSM28786 1 0.000 0.941 1.000 0.000
#> GSM28800 1 0.000 0.941 1.000 0.000
#> GSM11310 1 0.000 0.941 1.000 0.000
#> GSM28787 1 0.886 0.621 0.696 0.304
#> GSM11304 1 0.000 0.941 1.000 0.000
#> GSM11303 1 0.827 0.687 0.740 0.260
#> GSM11317 1 0.827 0.687 0.740 0.260
#> GSM11311 1 0.000 0.941 1.000 0.000
#> GSM28799 1 0.000 0.941 1.000 0.000
#> GSM28791 1 0.000 0.941 1.000 0.000
#> GSM28794 2 0.000 0.942 0.000 1.000
#> GSM28780 1 0.000 0.941 1.000 0.000
#> GSM28795 1 0.000 0.941 1.000 0.000
#> GSM11301 2 0.000 0.942 0.000 1.000
#> GSM11297 1 0.000 0.941 1.000 0.000
#> GSM11298 1 0.000 0.941 1.000 0.000
#> GSM11314 2 0.722 0.713 0.200 0.800
#> GSM11299 1 0.000 0.941 1.000 0.000
#> GSM28783 1 0.000 0.941 1.000 0.000
#> GSM11308 1 0.000 0.941 1.000 0.000
#> GSM28782 1 0.000 0.941 1.000 0.000
#> GSM28779 1 0.000 0.941 1.000 0.000
#> GSM11302 1 0.000 0.941 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.2356 0.9145 0.928 0.000 0.072
#> GSM28789 2 0.7203 0.2429 0.416 0.556 0.028
#> GSM28790 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM28798 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28778 1 0.0424 0.9797 0.992 0.008 0.000
#> GSM28796 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11309 3 0.0424 0.9194 0.008 0.000 0.992
#> GSM11315 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM28797 3 0.0424 0.9194 0.008 0.000 0.992
#> GSM28786 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM28800 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11304 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11303 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11311 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28799 1 0.4504 0.7474 0.804 0.000 0.196
#> GSM28791 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28794 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM28780 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11301 2 0.0000 0.9573 0.000 1.000 0.000
#> GSM11297 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM11298 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11314 3 0.9955 0.0901 0.348 0.288 0.364
#> GSM11299 3 0.0000 0.9253 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11308 3 0.6180 0.3086 0.416 0.000 0.584
#> GSM28782 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.9867 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.9867 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.1209 0.690 0.032 0.000 0.004 0.964
#> GSM28789 4 0.0712 0.693 0.004 0.008 0.004 0.984
#> GSM28790 1 0.0188 0.873 0.996 0.000 0.000 0.004
#> GSM11300 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0188 0.873 0.996 0.000 0.000 0.004
#> GSM28792 1 0.0188 0.873 0.996 0.000 0.000 0.004
#> GSM11295 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM28793 1 0.0000 0.875 1.000 0.000 0.000 0.000
#> GSM11312 4 0.4697 0.527 0.356 0.000 0.000 0.644
#> GSM28778 4 0.4250 0.649 0.276 0.000 0.000 0.724
#> GSM28796 1 0.0000 0.875 1.000 0.000 0.000 0.000
#> GSM11309 4 0.4456 0.411 0.004 0.000 0.280 0.716
#> GSM11315 1 0.0000 0.875 1.000 0.000 0.000 0.000
#> GSM11306 4 0.0707 0.695 0.020 0.000 0.000 0.980
#> GSM28776 1 0.4585 0.527 0.668 0.000 0.000 0.332
#> GSM28777 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM28797 4 0.4456 0.411 0.004 0.000 0.280 0.716
#> GSM28786 3 0.5097 0.291 0.004 0.000 0.568 0.428
#> GSM28800 1 0.0000 0.875 1.000 0.000 0.000 0.000
#> GSM11310 1 0.3801 0.676 0.780 0.000 0.000 0.220
#> GSM28787 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM11304 3 0.0188 0.905 0.000 0.000 0.996 0.004
#> GSM11303 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM11311 1 0.4277 0.594 0.720 0.000 0.000 0.280
#> GSM28799 1 0.5736 0.466 0.628 0.000 0.044 0.328
#> GSM28791 4 0.4961 0.417 0.448 0.000 0.000 0.552
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM28780 4 0.4804 0.538 0.384 0.000 0.000 0.616
#> GSM28795 4 0.4164 0.657 0.264 0.000 0.000 0.736
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM11297 3 0.0336 0.902 0.000 0.000 0.992 0.008
#> GSM11298 1 0.0000 0.875 1.000 0.000 0.000 0.000
#> GSM11314 4 0.3937 0.682 0.024 0.024 0.100 0.852
#> GSM11299 3 0.0000 0.908 0.000 0.000 1.000 0.000
#> GSM28783 4 0.4304 0.644 0.284 0.000 0.000 0.716
#> GSM11308 3 0.7603 -0.168 0.204 0.000 0.436 0.360
#> GSM28782 1 0.2814 0.722 0.868 0.000 0.000 0.132
#> GSM28779 1 0.0000 0.875 1.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.875 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.1270 0.8678 0.000 0.000 0.000 0.948 0.052
#> GSM28789 4 0.1270 0.8678 0.000 0.000 0.000 0.948 0.052
#> GSM28790 1 0.0290 0.8834 0.992 0.000 0.000 0.000 0.008
#> GSM11300 3 0.0324 0.9713 0.000 0.000 0.992 0.004 0.004
#> GSM28798 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.0290 0.8836 0.992 0.000 0.000 0.000 0.008
#> GSM28792 1 0.0162 0.8850 0.996 0.000 0.000 0.000 0.004
#> GSM11295 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM28793 1 0.0000 0.8859 1.000 0.000 0.000 0.000 0.000
#> GSM11312 5 0.5577 0.5515 0.184 0.000 0.000 0.172 0.644
#> GSM28778 5 0.1211 0.8618 0.016 0.000 0.000 0.024 0.960
#> GSM28796 1 0.0000 0.8859 1.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.0451 0.8756 0.000 0.000 0.008 0.988 0.004
#> GSM11315 1 0.0000 0.8859 1.000 0.000 0.000 0.000 0.000
#> GSM11306 4 0.2563 0.7941 0.008 0.000 0.000 0.872 0.120
#> GSM28776 1 0.5195 0.3098 0.564 0.000 0.000 0.388 0.048
#> GSM28777 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.0451 0.8756 0.000 0.000 0.008 0.988 0.004
#> GSM28786 4 0.0404 0.8737 0.000 0.000 0.012 0.988 0.000
#> GSM28800 1 0.1597 0.8563 0.940 0.000 0.000 0.012 0.048
#> GSM11310 1 0.3961 0.6850 0.760 0.000 0.000 0.212 0.028
#> GSM28787 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM11304 3 0.2938 0.8883 0.008 0.000 0.876 0.084 0.032
#> GSM11303 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.9741 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.4171 0.2621 0.396 0.000 0.000 0.604 0.000
#> GSM28799 1 0.5696 0.0746 0.472 0.000 0.020 0.468 0.040
#> GSM28791 5 0.0963 0.8611 0.036 0.000 0.000 0.000 0.964
#> GSM28794 2 0.0162 0.9961 0.000 0.996 0.000 0.004 0.000
#> GSM28780 5 0.0162 0.8646 0.004 0.000 0.000 0.000 0.996
#> GSM28795 5 0.0671 0.8635 0.004 0.000 0.000 0.016 0.980
#> GSM11301 2 0.0000 0.9996 0.000 1.000 0.000 0.000 0.000
#> GSM11297 3 0.3218 0.8738 0.012 0.000 0.860 0.096 0.032
#> GSM11298 1 0.0000 0.8859 1.000 0.000 0.000 0.000 0.000
#> GSM11314 5 0.1195 0.8564 0.000 0.000 0.012 0.028 0.960
#> GSM11299 3 0.0451 0.9695 0.000 0.000 0.988 0.008 0.004
#> GSM28783 5 0.0566 0.8645 0.012 0.000 0.000 0.004 0.984
#> GSM11308 5 0.1557 0.8346 0.000 0.000 0.052 0.008 0.940
#> GSM28782 5 0.4359 0.3244 0.412 0.000 0.000 0.004 0.584
#> GSM28779 1 0.0404 0.8833 0.988 0.000 0.000 0.012 0.000
#> GSM11302 1 0.0290 0.8841 0.992 0.000 0.000 0.008 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.4024 0.6807 0.000 0.000 0.000 0.700 0.036 0.264
#> GSM28789 4 0.4151 0.6755 0.000 0.000 0.000 0.692 0.044 0.264
#> GSM28790 1 0.0622 0.9116 0.980 0.000 0.000 0.000 0.008 0.012
#> GSM11300 3 0.2630 0.8576 0.000 0.000 0.872 0.032 0.004 0.092
#> GSM28798 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0291 0.9144 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM28792 1 0.0146 0.9166 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM11295 3 0.0547 0.9489 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM28793 1 0.0000 0.9177 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11312 5 0.6085 0.2914 0.092 0.000 0.000 0.048 0.448 0.412
#> GSM28778 5 0.2325 0.7620 0.008 0.000 0.000 0.008 0.884 0.100
#> GSM28796 1 0.0000 0.9177 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.0146 0.7328 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM11315 1 0.0000 0.9177 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11306 4 0.4565 0.5755 0.000 0.000 0.000 0.664 0.076 0.260
#> GSM28776 6 0.6938 0.1482 0.260 0.000 0.000 0.264 0.064 0.412
#> GSM28777 3 0.0260 0.9541 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM11316 3 0.0260 0.9541 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM11320 3 0.0000 0.9546 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.0000 0.7339 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28786 4 0.0405 0.7292 0.000 0.000 0.004 0.988 0.000 0.008
#> GSM28800 6 0.5279 0.2258 0.376 0.000 0.000 0.040 0.036 0.548
#> GSM11310 6 0.5964 0.4067 0.216 0.000 0.000 0.248 0.012 0.524
#> GSM28787 3 0.0632 0.9464 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM11304 6 0.6343 0.0817 0.012 0.000 0.404 0.140 0.020 0.424
#> GSM11303 3 0.0000 0.9546 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.9546 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.3861 0.3165 0.352 0.000 0.000 0.640 0.000 0.008
#> GSM28799 6 0.6038 0.3714 0.176 0.000 0.008 0.264 0.012 0.540
#> GSM28791 5 0.1908 0.7766 0.028 0.000 0.000 0.000 0.916 0.056
#> GSM28794 2 0.0458 0.9833 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM28780 5 0.1010 0.7757 0.004 0.000 0.000 0.000 0.960 0.036
#> GSM28795 5 0.1285 0.7749 0.004 0.000 0.000 0.000 0.944 0.052
#> GSM11301 2 0.0000 0.9985 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.6477 0.1462 0.016 0.000 0.376 0.152 0.020 0.436
#> GSM11298 1 0.0790 0.9033 0.968 0.000 0.000 0.000 0.000 0.032
#> GSM11314 5 0.3407 0.7264 0.000 0.000 0.016 0.016 0.800 0.168
#> GSM11299 3 0.2747 0.8456 0.000 0.000 0.860 0.028 0.004 0.108
#> GSM28783 5 0.3056 0.7319 0.004 0.000 0.000 0.008 0.804 0.184
#> GSM11308 5 0.2573 0.7354 0.000 0.000 0.004 0.008 0.856 0.132
#> GSM28782 5 0.5655 0.3823 0.164 0.000 0.000 0.004 0.536 0.296
#> GSM28779 1 0.3518 0.6309 0.732 0.000 0.000 0.000 0.012 0.256
#> GSM11302 1 0.3014 0.7419 0.804 0.000 0.000 0.000 0.012 0.184
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 tissue(p) k
#> MAD:skmeans 52 0.396 2
#> MAD:skmeans 49 0.446 3
#> MAD:skmeans 46 0.412 4
#> MAD:skmeans 48 0.449 5
#> MAD:skmeans 43 0.441 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.995 0.998 0.3850 0.618 0.618
#> 3 3 1.000 0.965 0.986 0.4838 0.798 0.676
#> 4 4 0.744 0.803 0.892 0.2448 0.839 0.633
#> 5 5 0.725 0.627 0.817 0.0846 0.913 0.714
#> 6 6 0.787 0.789 0.828 0.0606 0.854 0.497
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
#> GSM28788 1 0.0000 0.997 1.000 0.000
#> GSM28789 1 0.0000 0.997 1.000 0.000
#> GSM28790 1 0.0000 0.997 1.000 0.000
#> GSM11300 1 0.0000 0.997 1.000 0.000
#> GSM28798 2 0.0000 1.000 0.000 1.000
#> GSM11296 2 0.0000 1.000 0.000 1.000
#> GSM28801 2 0.0000 1.000 0.000 1.000
#> GSM11319 2 0.0000 1.000 0.000 1.000
#> GSM28781 2 0.0000 1.000 0.000 1.000
#> GSM11305 2 0.0000 1.000 0.000 1.000
#> GSM28784 2 0.0000 1.000 0.000 1.000
#> GSM11307 2 0.0000 1.000 0.000 1.000
#> GSM11313 2 0.0000 1.000 0.000 1.000
#> GSM28785 2 0.0000 1.000 0.000 1.000
#> GSM11318 1 0.0000 0.997 1.000 0.000
#> GSM28792 1 0.0000 0.997 1.000 0.000
#> GSM11295 1 0.0000 0.997 1.000 0.000
#> GSM28793 1 0.0000 0.997 1.000 0.000
#> GSM11312 1 0.0000 0.997 1.000 0.000
#> GSM28778 1 0.0000 0.997 1.000 0.000
#> GSM28796 1 0.0000 0.997 1.000 0.000
#> GSM11309 1 0.0000 0.997 1.000 0.000
#> GSM11315 1 0.0000 0.997 1.000 0.000
#> GSM11306 1 0.0000 0.997 1.000 0.000
#> GSM28776 1 0.0000 0.997 1.000 0.000
#> GSM28777 1 0.0000 0.997 1.000 0.000
#> GSM11316 2 0.0000 1.000 0.000 1.000
#> GSM11320 1 0.0000 0.997 1.000 0.000
#> GSM28797 1 0.0000 0.997 1.000 0.000
#> GSM28786 1 0.0000 0.997 1.000 0.000
#> GSM28800 1 0.0000 0.997 1.000 0.000
#> GSM11310 1 0.0000 0.997 1.000 0.000
#> GSM28787 1 0.4690 0.889 0.900 0.100
#> GSM11304 1 0.0000 0.997 1.000 0.000
#> GSM11303 1 0.0000 0.997 1.000 0.000
#> GSM11317 1 0.0938 0.986 0.988 0.012
#> GSM11311 1 0.0000 0.997 1.000 0.000
#> GSM28799 1 0.0000 0.997 1.000 0.000
#> GSM28791 1 0.0000 0.997 1.000 0.000
#> GSM28794 2 0.0376 0.996 0.004 0.996
#> GSM28780 1 0.0000 0.997 1.000 0.000
#> GSM28795 1 0.0000 0.997 1.000 0.000
#> GSM11301 2 0.0000 1.000 0.000 1.000
#> GSM11297 1 0.0000 0.997 1.000 0.000
#> GSM11298 1 0.0000 0.997 1.000 0.000
#> GSM11314 1 0.0000 0.997 1.000 0.000
#> GSM11299 1 0.0000 0.997 1.000 0.000
#> GSM28783 1 0.0000 0.997 1.000 0.000
#> GSM11308 1 0.0000 0.997 1.000 0.000
#> GSM28782 1 0.0000 0.997 1.000 0.000
#> GSM28779 1 0.0000 0.997 1.000 0.000
#> GSM11302 1 0.0000 0.997 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28789 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28790 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.938 0.000 0.000 1.000
#> GSM28798 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.998 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.998 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.998 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.998 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.938 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11309 1 0.2261 0.933 0.932 0.000 0.068
#> GSM11315 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.938 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.938 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.938 0.000 0.000 1.000
#> GSM28797 1 0.1411 0.960 0.964 0.000 0.036
#> GSM28786 1 0.3038 0.893 0.896 0.000 0.104
#> GSM28800 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28787 3 0.5905 0.434 0.352 0.000 0.648
#> GSM11304 1 0.2261 0.933 0.932 0.000 0.068
#> GSM11303 3 0.0000 0.938 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.938 0.000 0.000 1.000
#> GSM11311 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28799 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28794 2 0.0747 0.976 0.016 0.984 0.000
#> GSM28780 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11301 2 0.0000 0.998 0.000 1.000 0.000
#> GSM11297 1 0.2261 0.933 0.932 0.000 0.068
#> GSM11298 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11314 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11299 3 0.0000 0.938 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11308 1 0.0892 0.973 0.980 0.000 0.020
#> GSM28782 1 0.0000 0.987 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.987 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.987 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.3688 0.7794 0.792 0.000 0.000 0.208
#> GSM28789 1 0.3942 0.7577 0.764 0.000 0.000 0.236
#> GSM28790 1 0.2216 0.8234 0.908 0.000 0.000 0.092
#> GSM11300 4 0.4522 0.4550 0.000 0.000 0.320 0.680
#> GSM28798 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11318 1 0.2216 0.8234 0.908 0.000 0.000 0.092
#> GSM28792 1 0.2216 0.8234 0.908 0.000 0.000 0.092
#> GSM11295 3 0.0000 0.8958 0.000 0.000 1.000 0.000
#> GSM28793 1 0.1940 0.8301 0.924 0.000 0.000 0.076
#> GSM11312 1 0.3649 0.7811 0.796 0.000 0.000 0.204
#> GSM28778 1 0.0336 0.8419 0.992 0.000 0.000 0.008
#> GSM28796 1 0.2216 0.8234 0.908 0.000 0.000 0.092
#> GSM11309 4 0.1302 0.6680 0.044 0.000 0.000 0.956
#> GSM11315 1 0.2216 0.8234 0.908 0.000 0.000 0.092
#> GSM11306 1 0.3649 0.7811 0.796 0.000 0.000 0.204
#> GSM28776 1 0.3764 0.7819 0.784 0.000 0.000 0.216
#> GSM28777 3 0.0000 0.8958 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.8958 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.8958 0.000 0.000 1.000 0.000
#> GSM28797 1 0.3942 0.7676 0.764 0.000 0.000 0.236
#> GSM28786 4 0.4761 -0.0045 0.372 0.000 0.000 0.628
#> GSM28800 4 0.4193 0.6810 0.268 0.000 0.000 0.732
#> GSM11310 1 0.4072 0.7780 0.748 0.000 0.000 0.252
#> GSM28787 3 0.6171 0.2579 0.348 0.000 0.588 0.064
#> GSM11304 4 0.3873 0.6896 0.228 0.000 0.000 0.772
#> GSM11303 3 0.0000 0.8958 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.8958 0.000 0.000 1.000 0.000
#> GSM11311 1 0.2589 0.8114 0.884 0.000 0.000 0.116
#> GSM28799 4 0.3172 0.6534 0.160 0.000 0.000 0.840
#> GSM28791 1 0.0592 0.8441 0.984 0.000 0.000 0.016
#> GSM28794 2 0.1389 0.9384 0.048 0.952 0.000 0.000
#> GSM28780 1 0.0707 0.8434 0.980 0.000 0.000 0.020
#> GSM28795 4 0.4356 0.7057 0.292 0.000 0.000 0.708
#> GSM11301 2 0.0000 0.9946 0.000 1.000 0.000 0.000
#> GSM11297 4 0.1389 0.6891 0.048 0.000 0.000 0.952
#> GSM11298 1 0.0000 0.8435 1.000 0.000 0.000 0.000
#> GSM11314 1 0.4072 0.7767 0.748 0.000 0.000 0.252
#> GSM11299 4 0.4522 0.4550 0.000 0.000 0.320 0.680
#> GSM28783 1 0.4103 0.6595 0.744 0.000 0.000 0.256
#> GSM11308 4 0.4500 0.7041 0.316 0.000 0.000 0.684
#> GSM28782 1 0.0188 0.8430 0.996 0.000 0.000 0.004
#> GSM28779 1 0.0592 0.8441 0.984 0.000 0.000 0.016
#> GSM11302 1 0.0000 0.8435 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.642 0.604 0.416 0.000 0.000 0.172 0.412
#> GSM28789 5 0.646 -0.655 0.408 0.000 0.000 0.180 0.412
#> GSM28790 1 0.000 0.503 1.000 0.000 0.000 0.000 0.000
#> GSM11300 5 0.595 0.269 0.000 0.000 0.312 0.132 0.556
#> GSM28798 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.000 0.503 1.000 0.000 0.000 0.000 0.000
#> GSM28792 1 0.000 0.503 1.000 0.000 0.000 0.000 0.000
#> GSM11295 3 0.000 0.918 0.000 0.000 1.000 0.000 0.000
#> GSM28793 1 0.000 0.503 1.000 0.000 0.000 0.000 0.000
#> GSM11312 1 0.642 0.604 0.416 0.000 0.000 0.172 0.412
#> GSM28778 1 0.426 0.661 0.564 0.000 0.000 0.000 0.436
#> GSM28796 1 0.000 0.503 1.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.207 0.674 0.000 0.000 0.000 0.896 0.104
#> GSM11315 1 0.000 0.503 1.000 0.000 0.000 0.000 0.000
#> GSM11306 1 0.652 0.601 0.416 0.000 0.000 0.192 0.392
#> GSM28776 1 0.639 0.615 0.472 0.000 0.000 0.176 0.352
#> GSM28777 3 0.000 0.918 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.000 0.918 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.000 0.918 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.283 0.704 0.044 0.000 0.000 0.876 0.080
#> GSM28786 4 0.000 0.733 0.000 0.000 0.000 1.000 0.000
#> GSM28800 5 0.516 0.286 0.440 0.000 0.000 0.040 0.520
#> GSM11310 1 0.596 0.601 0.588 0.000 0.000 0.176 0.236
#> GSM28787 3 0.495 0.424 0.256 0.000 0.676 0.068 0.000
#> GSM11304 5 0.595 0.349 0.312 0.000 0.000 0.132 0.556
#> GSM11303 3 0.000 0.918 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.000 0.918 0.000 0.000 1.000 0.000 0.000
#> GSM11311 4 0.397 0.575 0.336 0.000 0.000 0.664 0.000
#> GSM28799 5 0.489 0.287 0.052 0.000 0.000 0.288 0.660
#> GSM28791 1 0.522 0.655 0.512 0.000 0.000 0.044 0.444
#> GSM28794 2 0.385 0.599 0.016 0.752 0.000 0.000 0.232
#> GSM28780 1 0.456 0.638 0.512 0.000 0.000 0.008 0.480
#> GSM28795 5 0.412 0.369 0.100 0.000 0.000 0.112 0.788
#> GSM11301 2 0.000 0.969 0.000 1.000 0.000 0.000 0.000
#> GSM11297 5 0.595 0.349 0.312 0.000 0.000 0.132 0.556
#> GSM11298 1 0.421 0.666 0.588 0.000 0.000 0.000 0.412
#> GSM11314 1 0.633 0.577 0.588 0.016 0.000 0.188 0.208
#> GSM11299 5 0.595 0.269 0.000 0.000 0.312 0.132 0.556
#> GSM28783 5 0.558 -0.380 0.352 0.000 0.000 0.084 0.564
#> GSM11308 5 0.282 0.393 0.012 0.000 0.000 0.132 0.856
#> GSM28782 1 0.431 0.638 0.508 0.000 0.000 0.000 0.492
#> GSM28779 1 0.562 0.657 0.512 0.000 0.000 0.076 0.412
#> GSM11302 1 0.421 0.666 0.588 0.000 0.000 0.000 0.412
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 5 0.2519 0.692 0.048 0.000 0.000 0.056 0.888 0.008
#> GSM28789 5 0.3142 0.681 0.044 0.000 0.000 0.108 0.840 0.008
#> GSM28790 1 0.0000 0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11300 6 0.2092 0.858 0.000 0.000 0.124 0.000 0.000 0.876
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.0000 0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28792 1 0.0000 0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11295 3 0.0972 0.919 0.000 0.000 0.964 0.000 0.028 0.008
#> GSM28793 1 0.0260 0.923 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM11312 5 0.4129 0.682 0.092 0.000 0.000 0.020 0.776 0.112
#> GSM28778 5 0.2006 0.695 0.104 0.000 0.000 0.000 0.892 0.004
#> GSM28796 1 0.0000 0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11309 4 0.2092 0.765 0.000 0.000 0.000 0.876 0.000 0.124
#> GSM11315 1 0.0000 0.933 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11306 5 0.6159 0.595 0.092 0.000 0.000 0.208 0.588 0.112
#> GSM28776 5 0.6129 0.614 0.136 0.000 0.000 0.144 0.608 0.112
#> GSM28777 3 0.0000 0.942 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.942 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.942 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.0000 0.827 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM28786 4 0.0458 0.832 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM28800 1 0.3330 0.491 0.716 0.000 0.000 0.000 0.000 0.284
#> GSM11310 5 0.6643 0.562 0.208 0.000 0.000 0.148 0.532 0.112
#> GSM28787 3 0.4954 0.651 0.000 0.000 0.724 0.084 0.076 0.116
#> GSM11304 6 0.2092 0.857 0.124 0.000 0.000 0.000 0.000 0.876
#> GSM11303 3 0.0000 0.942 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.942 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 4 0.3309 0.613 0.280 0.000 0.000 0.720 0.000 0.000
#> GSM28799 5 0.5990 0.333 0.016 0.000 0.000 0.144 0.436 0.404
#> GSM28791 5 0.2805 0.708 0.184 0.000 0.000 0.000 0.812 0.004
#> GSM28794 5 0.3997 0.165 0.004 0.488 0.000 0.000 0.508 0.000
#> GSM28780 5 0.5039 0.592 0.184 0.000 0.000 0.000 0.640 0.176
#> GSM28795 5 0.4824 0.277 0.056 0.000 0.000 0.000 0.524 0.420
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.2092 0.857 0.124 0.000 0.000 0.000 0.000 0.876
#> GSM11298 5 0.2697 0.708 0.188 0.000 0.000 0.000 0.812 0.000
#> GSM11314 5 0.7833 0.466 0.224 0.056 0.000 0.144 0.444 0.132
#> GSM11299 6 0.2092 0.858 0.000 0.000 0.124 0.000 0.000 0.876
#> GSM28783 5 0.5393 0.504 0.068 0.000 0.000 0.028 0.576 0.328
#> GSM11308 6 0.2146 0.803 0.004 0.000 0.000 0.000 0.116 0.880
#> GSM28782 5 0.2882 0.709 0.180 0.000 0.000 0.000 0.812 0.008
#> GSM28779 5 0.2664 0.709 0.184 0.000 0.000 0.000 0.816 0.000
#> GSM11302 5 0.2697 0.708 0.188 0.000 0.000 0.000 0.812 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 tissue(p) k
#> MAD:pam 52 0.396 2
#> MAD:pam 51 0.371 3
#> MAD:pam 48 0.448 4
#> MAD:pam 41 0.488 5
#> MAD:pam 47 0.484 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.656 0.758 0.897 0.4224 0.638 0.638
#> 3 3 0.747 0.857 0.935 0.4427 0.759 0.623
#> 4 4 0.771 0.806 0.894 0.1628 0.848 0.647
#> 5 5 0.685 0.741 0.822 0.0964 0.865 0.583
#> 6 6 0.725 0.642 0.740 0.0430 0.934 0.720
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
#> GSM28788 1 0.2948 0.8294 0.948 0.052
#> GSM28789 1 0.2948 0.8294 0.948 0.052
#> GSM28790 1 0.0000 0.8547 1.000 0.000
#> GSM11300 1 0.9954 0.3150 0.540 0.460
#> GSM28798 2 0.0000 0.9543 0.000 1.000
#> GSM11296 2 0.0000 0.9543 0.000 1.000
#> GSM28801 2 0.0000 0.9543 0.000 1.000
#> GSM11319 2 0.0000 0.9543 0.000 1.000
#> GSM28781 2 0.0000 0.9543 0.000 1.000
#> GSM11305 2 0.0000 0.9543 0.000 1.000
#> GSM28784 2 0.0000 0.9543 0.000 1.000
#> GSM11307 2 0.0000 0.9543 0.000 1.000
#> GSM11313 2 0.0000 0.9543 0.000 1.000
#> GSM28785 2 0.0000 0.9543 0.000 1.000
#> GSM11318 1 0.0000 0.8547 1.000 0.000
#> GSM28792 1 0.0000 0.8547 1.000 0.000
#> GSM11295 1 0.9954 0.3150 0.540 0.460
#> GSM28793 1 0.0000 0.8547 1.000 0.000
#> GSM11312 1 0.0000 0.8547 1.000 0.000
#> GSM28778 1 0.0000 0.8547 1.000 0.000
#> GSM28796 1 0.0000 0.8547 1.000 0.000
#> GSM11309 1 0.2778 0.8321 0.952 0.048
#> GSM11315 1 0.0000 0.8547 1.000 0.000
#> GSM11306 1 0.2603 0.8344 0.956 0.044
#> GSM28776 1 0.0000 0.8547 1.000 0.000
#> GSM28777 1 0.9963 0.3057 0.536 0.464
#> GSM11316 1 0.9963 0.3057 0.536 0.464
#> GSM11320 1 0.9963 0.3057 0.536 0.464
#> GSM28797 1 0.2778 0.8321 0.952 0.048
#> GSM28786 1 0.2778 0.8321 0.952 0.048
#> GSM28800 1 0.0000 0.8547 1.000 0.000
#> GSM11310 1 0.0000 0.8547 1.000 0.000
#> GSM28787 1 0.9954 0.3150 0.540 0.460
#> GSM11304 1 0.4161 0.8108 0.916 0.084
#> GSM11303 1 0.9963 0.3057 0.536 0.464
#> GSM11317 1 0.9963 0.3057 0.536 0.464
#> GSM11311 1 0.1184 0.8483 0.984 0.016
#> GSM28799 1 0.0000 0.8547 1.000 0.000
#> GSM28791 1 0.0000 0.8547 1.000 0.000
#> GSM28794 2 0.9850 0.0594 0.428 0.572
#> GSM28780 1 0.0000 0.8547 1.000 0.000
#> GSM28795 1 0.0376 0.8535 0.996 0.004
#> GSM11301 2 0.0000 0.9543 0.000 1.000
#> GSM11297 1 0.4298 0.8079 0.912 0.088
#> GSM11298 1 0.0000 0.8547 1.000 0.000
#> GSM11314 1 0.7453 0.6923 0.788 0.212
#> GSM11299 1 0.9954 0.3150 0.540 0.460
#> GSM28783 1 0.0000 0.8547 1.000 0.000
#> GSM11308 1 0.3274 0.8264 0.940 0.060
#> GSM28782 1 0.0000 0.8547 1.000 0.000
#> GSM28779 1 0.0000 0.8547 1.000 0.000
#> GSM11302 1 0.0000 0.8547 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.3375 0.8798 0.892 0.008 0.100
#> GSM28789 1 0.4139 0.8574 0.860 0.016 0.124
#> GSM28790 1 0.0000 0.9132 1.000 0.000 0.000
#> GSM11300 3 0.0424 0.8931 0.008 0.000 0.992
#> GSM28798 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.9708 0.000 1.000 0.000
#> GSM11318 1 0.0237 0.9139 0.996 0.000 0.004
#> GSM28792 1 0.0424 0.9137 0.992 0.000 0.008
#> GSM11295 3 0.0237 0.8940 0.004 0.000 0.996
#> GSM28793 1 0.0592 0.9122 0.988 0.012 0.000
#> GSM11312 1 0.0747 0.9109 0.984 0.016 0.000
#> GSM28778 1 0.7525 0.6397 0.684 0.208 0.108
#> GSM28796 1 0.0237 0.9135 0.996 0.000 0.004
#> GSM11309 1 0.3192 0.8757 0.888 0.000 0.112
#> GSM11315 1 0.0661 0.9130 0.988 0.008 0.004
#> GSM11306 1 0.2959 0.8825 0.900 0.000 0.100
#> GSM28776 1 0.1643 0.9077 0.956 0.000 0.044
#> GSM28777 3 0.0000 0.8952 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.8952 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.8952 0.000 0.000 1.000
#> GSM28797 1 0.3192 0.8757 0.888 0.000 0.112
#> GSM28786 1 0.3192 0.8757 0.888 0.000 0.112
#> GSM28800 1 0.0829 0.9119 0.984 0.012 0.004
#> GSM11310 1 0.1643 0.9077 0.956 0.000 0.044
#> GSM28787 3 0.0661 0.8909 0.008 0.004 0.988
#> GSM11304 3 0.5905 0.4369 0.352 0.000 0.648
#> GSM11303 3 0.0000 0.8952 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.8952 0.000 0.000 1.000
#> GSM11311 1 0.2165 0.9001 0.936 0.000 0.064
#> GSM28799 1 0.1643 0.9077 0.956 0.000 0.044
#> GSM28791 1 0.0237 0.9135 0.996 0.000 0.004
#> GSM28794 2 0.5292 0.7255 0.172 0.800 0.028
#> GSM28780 1 0.0892 0.9118 0.980 0.000 0.020
#> GSM28795 1 0.3682 0.8485 0.876 0.008 0.116
#> GSM11301 2 0.1989 0.9166 0.048 0.948 0.004
#> GSM11297 3 0.6225 0.2047 0.432 0.000 0.568
#> GSM11298 1 0.0237 0.9133 0.996 0.004 0.000
#> GSM11314 1 0.8892 -0.0143 0.444 0.120 0.436
#> GSM11299 3 0.0424 0.8931 0.008 0.000 0.992
#> GSM28783 1 0.0424 0.9139 0.992 0.000 0.008
#> GSM11308 1 0.6357 0.5145 0.684 0.020 0.296
#> GSM28782 1 0.0000 0.9132 1.000 0.000 0.000
#> GSM28779 1 0.0424 0.9131 0.992 0.008 0.000
#> GSM11302 1 0.0892 0.9092 0.980 0.020 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.1389 0.9212 0.048 0.000 0.000 0.952
#> GSM28789 4 0.1022 0.9229 0.032 0.000 0.000 0.968
#> GSM28790 1 0.0188 0.8033 0.996 0.000 0.000 0.004
#> GSM11300 3 0.0779 0.9772 0.016 0.000 0.980 0.004
#> GSM28798 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.9306 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0592 0.8043 0.984 0.000 0.000 0.016
#> GSM28792 1 0.0921 0.8076 0.972 0.000 0.000 0.028
#> GSM11295 3 0.0817 0.9772 0.000 0.000 0.976 0.024
#> GSM28793 1 0.0188 0.8041 0.996 0.000 0.000 0.004
#> GSM11312 1 0.2345 0.7973 0.900 0.000 0.000 0.100
#> GSM28778 1 0.5883 0.6369 0.648 0.064 0.000 0.288
#> GSM28796 1 0.0188 0.8041 0.996 0.000 0.000 0.004
#> GSM11309 4 0.0921 0.9294 0.028 0.000 0.000 0.972
#> GSM11315 1 0.0336 0.8047 0.992 0.000 0.000 0.008
#> GSM11306 4 0.3764 0.6750 0.216 0.000 0.000 0.784
#> GSM28776 1 0.4431 0.6827 0.696 0.000 0.000 0.304
#> GSM28777 3 0.0000 0.9872 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.9872 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9872 0.000 0.000 1.000 0.000
#> GSM28797 4 0.0921 0.9294 0.028 0.000 0.000 0.972
#> GSM28786 4 0.0592 0.9209 0.016 0.000 0.000 0.984
#> GSM28800 1 0.0188 0.8041 0.996 0.000 0.000 0.004
#> GSM11310 1 0.4428 0.6985 0.720 0.000 0.004 0.276
#> GSM28787 3 0.1211 0.9665 0.000 0.000 0.960 0.040
#> GSM11304 1 0.7499 0.2394 0.420 0.000 0.400 0.180
#> GSM11303 3 0.0000 0.9872 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9872 0.000 0.000 1.000 0.000
#> GSM11311 1 0.4713 0.5915 0.640 0.000 0.000 0.360
#> GSM28799 1 0.5432 0.6373 0.652 0.000 0.032 0.316
#> GSM28791 1 0.2081 0.8008 0.916 0.000 0.000 0.084
#> GSM28794 2 0.7660 -0.0651 0.324 0.448 0.000 0.228
#> GSM28780 1 0.3356 0.7719 0.824 0.000 0.000 0.176
#> GSM28795 1 0.3975 0.7350 0.760 0.000 0.000 0.240
#> GSM11301 2 0.1716 0.8648 0.000 0.936 0.000 0.064
#> GSM11297 1 0.7530 0.2755 0.436 0.000 0.376 0.188
#> GSM11298 1 0.0336 0.8056 0.992 0.000 0.000 0.008
#> GSM11314 1 0.8040 0.4788 0.524 0.060 0.112 0.304
#> GSM11299 3 0.0779 0.9772 0.016 0.000 0.980 0.004
#> GSM28783 1 0.3444 0.7677 0.816 0.000 0.000 0.184
#> GSM11308 1 0.5156 0.7137 0.720 0.000 0.044 0.236
#> GSM28782 1 0.0469 0.8064 0.988 0.000 0.000 0.012
#> GSM28779 1 0.0592 0.8065 0.984 0.000 0.000 0.016
#> GSM11302 1 0.0469 0.8068 0.988 0.000 0.000 0.012
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.4168 0.7806 0.052 0.000 0.000 0.764 0.184
#> GSM28789 4 0.3694 0.8008 0.032 0.000 0.000 0.796 0.172
#> GSM28790 1 0.2806 0.7303 0.844 0.000 0.000 0.004 0.152
#> GSM11300 3 0.2104 0.9338 0.000 0.000 0.916 0.024 0.060
#> GSM28798 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0162 0.9851 0.000 0.996 0.000 0.000 0.004
#> GSM11307 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9883 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.2513 0.7167 0.876 0.000 0.000 0.008 0.116
#> GSM28792 1 0.3163 0.6816 0.824 0.000 0.000 0.012 0.164
#> GSM11295 3 0.2561 0.9217 0.000 0.000 0.884 0.020 0.096
#> GSM28793 1 0.0579 0.7508 0.984 0.000 0.000 0.008 0.008
#> GSM11312 1 0.4251 0.3633 0.672 0.000 0.000 0.012 0.316
#> GSM28778 5 0.4916 0.6150 0.192 0.008 0.008 0.060 0.732
#> GSM28796 1 0.0798 0.7488 0.976 0.000 0.000 0.016 0.008
#> GSM11309 4 0.0798 0.8312 0.008 0.000 0.000 0.976 0.016
#> GSM11315 1 0.0693 0.7507 0.980 0.000 0.000 0.012 0.008
#> GSM11306 4 0.5417 0.6223 0.116 0.000 0.000 0.648 0.236
#> GSM28776 5 0.5447 0.6050 0.248 0.000 0.000 0.112 0.640
#> GSM28777 3 0.0000 0.9513 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.9513 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.9513 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.0771 0.8318 0.004 0.000 0.000 0.976 0.020
#> GSM28786 4 0.0451 0.8271 0.004 0.000 0.000 0.988 0.008
#> GSM28800 1 0.1124 0.7440 0.960 0.000 0.000 0.004 0.036
#> GSM11310 5 0.6012 0.4564 0.376 0.000 0.000 0.120 0.504
#> GSM28787 3 0.2921 0.9037 0.000 0.000 0.856 0.020 0.124
#> GSM11304 5 0.7831 0.4696 0.196 0.000 0.240 0.108 0.456
#> GSM11303 3 0.0000 0.9513 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.9513 0.000 0.000 1.000 0.000 0.000
#> GSM11311 5 0.6391 0.4891 0.316 0.000 0.004 0.168 0.512
#> GSM28799 5 0.6296 0.5721 0.304 0.000 0.016 0.124 0.556
#> GSM28791 1 0.4504 0.3076 0.564 0.000 0.000 0.008 0.428
#> GSM28794 5 0.5963 0.4497 0.084 0.180 0.000 0.064 0.672
#> GSM28780 5 0.4627 0.0657 0.444 0.000 0.000 0.012 0.544
#> GSM28795 5 0.4516 0.5228 0.264 0.000 0.008 0.024 0.704
#> GSM11301 2 0.2700 0.8777 0.004 0.884 0.000 0.024 0.088
#> GSM11297 5 0.7793 0.4764 0.192 0.000 0.236 0.108 0.464
#> GSM11298 1 0.2516 0.7164 0.860 0.000 0.000 0.000 0.140
#> GSM11314 5 0.4970 0.6149 0.132 0.008 0.024 0.076 0.760
#> GSM11299 3 0.3197 0.9002 0.008 0.000 0.852 0.024 0.116
#> GSM28783 5 0.5460 0.3097 0.420 0.000 0.004 0.052 0.524
#> GSM11308 5 0.6810 0.4340 0.344 0.000 0.068 0.080 0.508
#> GSM28782 1 0.3550 0.6904 0.760 0.000 0.000 0.004 0.236
#> GSM28779 1 0.2966 0.6811 0.816 0.000 0.000 0.000 0.184
#> GSM11302 1 0.2929 0.6810 0.820 0.000 0.000 0.000 0.180
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.4614 0.78734 0.028 0.000 0.000 0.728 0.168 NA
#> GSM28789 4 0.4345 0.79511 0.016 0.000 0.000 0.744 0.164 NA
#> GSM28790 1 0.1493 0.62615 0.936 0.000 0.000 0.004 0.056 NA
#> GSM11300 3 0.2009 0.78046 0.000 0.000 0.904 0.004 0.008 NA
#> GSM28798 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11296 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28801 2 0.1333 0.94512 0.000 0.944 0.000 0.008 0.000 NA
#> GSM11319 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28781 2 0.0146 0.97149 0.000 0.996 0.000 0.004 0.000 NA
#> GSM11305 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28784 2 0.1196 0.94981 0.000 0.952 0.000 0.008 0.000 NA
#> GSM11307 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11313 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM28785 2 0.0000 0.97286 0.000 1.000 0.000 0.000 0.000 NA
#> GSM11318 1 0.1410 0.62659 0.944 0.000 0.000 0.004 0.044 NA
#> GSM28792 1 0.2056 0.60246 0.904 0.000 0.000 0.004 0.080 NA
#> GSM11295 3 0.1774 0.78676 0.004 0.000 0.936 0.016 0.020 NA
#> GSM28793 1 0.5365 0.57739 0.616 0.000 0.000 0.008 0.160 NA
#> GSM11312 5 0.5445 0.48468 0.188 0.000 0.000 0.020 0.632 NA
#> GSM28778 5 0.3411 0.59143 0.092 0.004 0.000 0.016 0.836 NA
#> GSM28796 1 0.3658 0.63317 0.800 0.000 0.000 0.004 0.092 NA
#> GSM11309 4 0.1053 0.81762 0.004 0.000 0.000 0.964 0.020 NA
#> GSM11315 1 0.5359 0.57257 0.604 0.000 0.000 0.004 0.164 NA
#> GSM11306 4 0.6384 0.55694 0.072 0.000 0.000 0.528 0.272 NA
#> GSM28776 5 0.4584 0.58151 0.112 0.000 0.000 0.040 0.748 NA
#> GSM28777 3 0.2048 0.81741 0.000 0.000 0.880 0.000 0.000 NA
#> GSM11316 3 0.3446 0.80895 0.000 0.000 0.692 0.000 0.000 NA
#> GSM11320 3 0.3482 0.80891 0.000 0.000 0.684 0.000 0.000 NA
#> GSM28797 4 0.0972 0.81851 0.000 0.000 0.000 0.964 0.028 NA
#> GSM28786 4 0.0632 0.81668 0.000 0.000 0.000 0.976 0.024 NA
#> GSM28800 1 0.5453 0.55865 0.592 0.000 0.000 0.004 0.184 NA
#> GSM11310 5 0.4901 0.57198 0.144 0.000 0.000 0.028 0.708 NA
#> GSM28787 3 0.2838 0.76364 0.008 0.000 0.880 0.016 0.044 NA
#> GSM11304 5 0.5131 0.50374 0.048 0.000 0.016 0.032 0.680 NA
#> GSM11303 3 0.3482 0.80891 0.000 0.000 0.684 0.000 0.000 NA
#> GSM11317 3 0.3446 0.80895 0.000 0.000 0.692 0.000 0.000 NA
#> GSM11311 5 0.4579 0.58032 0.076 0.000 0.000 0.068 0.756 NA
#> GSM28799 5 0.4371 0.58242 0.040 0.000 0.004 0.044 0.760 NA
#> GSM28791 1 0.4959 -0.05346 0.556 0.000 0.000 0.016 0.388 NA
#> GSM28794 5 0.5659 0.44996 0.044 0.184 0.000 0.012 0.656 NA
#> GSM28780 5 0.5197 0.18675 0.452 0.000 0.000 0.016 0.480 NA
#> GSM28795 5 0.4900 0.45911 0.296 0.000 0.000 0.032 0.636 NA
#> GSM11301 2 0.3945 0.80981 0.020 0.808 0.000 0.012 0.088 NA
#> GSM11297 5 0.5062 0.50293 0.048 0.000 0.016 0.028 0.684 NA
#> GSM11298 5 0.6060 -0.13631 0.364 0.000 0.000 0.004 0.416 NA
#> GSM11314 5 0.3508 0.58598 0.076 0.000 0.008 0.032 0.840 NA
#> GSM11299 3 0.2633 0.75866 0.000 0.000 0.864 0.004 0.020 NA
#> GSM28783 5 0.3890 0.55503 0.200 0.000 0.004 0.020 0.760 NA
#> GSM11308 5 0.6202 0.31152 0.332 0.000 0.004 0.028 0.496 NA
#> GSM28782 1 0.4289 0.24131 0.660 0.000 0.000 0.004 0.304 NA
#> GSM28779 5 0.6032 -0.03072 0.320 0.000 0.000 0.004 0.452 NA
#> GSM11302 5 0.6015 -0.00472 0.312 0.000 0.000 0.004 0.460 NA
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 tissue(p) k
#> MAD:mclust 42 0.384 2
#> MAD:mclust 49 0.368 3
#> MAD:mclust 48 0.462 4
#> MAD:mclust 42 0.428 5
#> MAD:mclust 42 0.452 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.980 0.991 0.3953 0.599 0.599
#> 3 3 1.000 0.970 0.988 0.4846 0.729 0.576
#> 4 4 0.723 0.780 0.884 0.2428 0.880 0.712
#> 5 5 0.820 0.804 0.898 0.0917 0.881 0.619
#> 6 6 0.855 0.729 0.869 0.0450 0.943 0.741
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
#> GSM28788 1 0.0376 0.995 0.996 0.004
#> GSM28789 2 0.8443 0.641 0.272 0.728
#> GSM28790 1 0.0000 0.998 1.000 0.000
#> GSM11300 1 0.0000 0.998 1.000 0.000
#> GSM28798 2 0.0000 0.969 0.000 1.000
#> GSM11296 2 0.0000 0.969 0.000 1.000
#> GSM28801 2 0.0000 0.969 0.000 1.000
#> GSM11319 2 0.0000 0.969 0.000 1.000
#> GSM28781 2 0.0000 0.969 0.000 1.000
#> GSM11305 2 0.0000 0.969 0.000 1.000
#> GSM28784 2 0.0000 0.969 0.000 1.000
#> GSM11307 2 0.0000 0.969 0.000 1.000
#> GSM11313 2 0.0000 0.969 0.000 1.000
#> GSM28785 2 0.0000 0.969 0.000 1.000
#> GSM11318 1 0.0000 0.998 1.000 0.000
#> GSM28792 1 0.0000 0.998 1.000 0.000
#> GSM11295 1 0.0000 0.998 1.000 0.000
#> GSM28793 1 0.0000 0.998 1.000 0.000
#> GSM11312 1 0.0000 0.998 1.000 0.000
#> GSM28778 2 0.5519 0.850 0.128 0.872
#> GSM28796 1 0.0000 0.998 1.000 0.000
#> GSM11309 1 0.0000 0.998 1.000 0.000
#> GSM11315 1 0.0000 0.998 1.000 0.000
#> GSM11306 1 0.0000 0.998 1.000 0.000
#> GSM28776 1 0.0000 0.998 1.000 0.000
#> GSM28777 1 0.0000 0.998 1.000 0.000
#> GSM11316 1 0.0672 0.991 0.992 0.008
#> GSM11320 1 0.0000 0.998 1.000 0.000
#> GSM28797 1 0.0000 0.998 1.000 0.000
#> GSM28786 1 0.0000 0.998 1.000 0.000
#> GSM28800 1 0.0000 0.998 1.000 0.000
#> GSM11310 1 0.0000 0.998 1.000 0.000
#> GSM28787 1 0.2423 0.958 0.960 0.040
#> GSM11304 1 0.0000 0.998 1.000 0.000
#> GSM11303 1 0.0000 0.998 1.000 0.000
#> GSM11317 1 0.0000 0.998 1.000 0.000
#> GSM11311 1 0.0000 0.998 1.000 0.000
#> GSM28799 1 0.0000 0.998 1.000 0.000
#> GSM28791 1 0.0000 0.998 1.000 0.000
#> GSM28794 2 0.0000 0.969 0.000 1.000
#> GSM28780 1 0.0000 0.998 1.000 0.000
#> GSM28795 1 0.0000 0.998 1.000 0.000
#> GSM11301 2 0.0000 0.969 0.000 1.000
#> GSM11297 1 0.0000 0.998 1.000 0.000
#> GSM11298 1 0.0000 0.998 1.000 0.000
#> GSM11314 1 0.1414 0.979 0.980 0.020
#> GSM11299 1 0.0000 0.998 1.000 0.000
#> GSM28783 1 0.0000 0.998 1.000 0.000
#> GSM11308 1 0.0000 0.998 1.000 0.000
#> GSM28782 1 0.0000 0.998 1.000 0.000
#> GSM28779 1 0.0000 0.998 1.000 0.000
#> GSM11302 1 0.0000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28789 1 0.1289 0.962 0.968 0.032 0.000
#> GSM28790 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.948 0.000 0.000 1.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28792 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.948 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11309 1 0.0237 0.987 0.996 0.000 0.004
#> GSM11315 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.948 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.948 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.948 0.000 0.000 1.000
#> GSM28797 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28786 3 0.5859 0.461 0.344 0.000 0.656
#> GSM28800 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.948 0.000 0.000 1.000
#> GSM11304 1 0.1753 0.947 0.952 0.000 0.048
#> GSM11303 3 0.0000 0.948 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.948 0.000 0.000 1.000
#> GSM11311 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28799 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28780 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28795 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11297 1 0.3879 0.818 0.848 0.000 0.152
#> GSM11298 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11314 1 0.1482 0.965 0.968 0.012 0.020
#> GSM11299 3 0.0000 0.948 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.990 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.990 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.990 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.2216 0.8896 0.092 0.000 0.000 0.908
#> GSM28789 4 0.2179 0.8848 0.064 0.012 0.000 0.924
#> GSM28790 1 0.0188 0.7599 0.996 0.000 0.000 0.004
#> GSM11300 3 0.0188 0.9381 0.000 0.000 0.996 0.004
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0188 0.7582 0.996 0.000 0.000 0.004
#> GSM28792 1 0.0707 0.7615 0.980 0.000 0.000 0.020
#> GSM11295 3 0.3569 0.7843 0.000 0.000 0.804 0.196
#> GSM28793 1 0.1474 0.7605 0.948 0.000 0.000 0.052
#> GSM11312 1 0.4072 0.6599 0.748 0.000 0.000 0.252
#> GSM28778 1 0.4072 0.6373 0.748 0.000 0.000 0.252
#> GSM28796 1 0.1474 0.7605 0.948 0.000 0.000 0.052
#> GSM11309 4 0.2530 0.8840 0.100 0.000 0.004 0.896
#> GSM11315 1 0.1557 0.7592 0.944 0.000 0.000 0.056
#> GSM11306 4 0.1389 0.8659 0.048 0.000 0.000 0.952
#> GSM28776 1 0.4277 0.5616 0.720 0.000 0.000 0.280
#> GSM28777 3 0.0188 0.9370 0.000 0.000 0.996 0.004
#> GSM11316 3 0.0000 0.9386 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9386 0.000 0.000 1.000 0.000
#> GSM28797 4 0.2081 0.8910 0.084 0.000 0.000 0.916
#> GSM28786 4 0.3307 0.8185 0.028 0.000 0.104 0.868
#> GSM28800 1 0.1940 0.7519 0.924 0.000 0.000 0.076
#> GSM11310 1 0.4985 -0.0198 0.532 0.000 0.000 0.468
#> GSM28787 3 0.4313 0.7044 0.004 0.000 0.736 0.260
#> GSM11304 1 0.5076 0.6224 0.756 0.000 0.172 0.072
#> GSM11303 3 0.0188 0.9381 0.000 0.000 0.996 0.004
#> GSM11317 3 0.0000 0.9386 0.000 0.000 1.000 0.000
#> GSM11311 4 0.4746 0.4486 0.368 0.000 0.000 0.632
#> GSM28799 1 0.4855 0.2550 0.600 0.000 0.000 0.400
#> GSM28791 1 0.3942 0.6561 0.764 0.000 0.000 0.236
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28780 1 0.4356 0.6040 0.708 0.000 0.000 0.292
#> GSM28795 1 0.4746 0.5014 0.632 0.000 0.000 0.368
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11297 1 0.6640 0.3173 0.552 0.000 0.352 0.096
#> GSM11298 1 0.1302 0.7616 0.956 0.000 0.000 0.044
#> GSM11314 1 0.6557 0.3992 0.548 0.004 0.072 0.376
#> GSM11299 3 0.0188 0.9381 0.000 0.000 0.996 0.004
#> GSM28783 1 0.4564 0.5576 0.672 0.000 0.000 0.328
#> GSM11308 1 0.3355 0.7058 0.836 0.000 0.004 0.160
#> GSM28782 1 0.0817 0.7546 0.976 0.000 0.000 0.024
#> GSM28779 1 0.1474 0.7605 0.948 0.000 0.000 0.052
#> GSM11302 1 0.1474 0.7614 0.948 0.000 0.000 0.052
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.0671 0.9501 0.016 0 0.000 0.980 0.004
#> GSM28789 4 0.0579 0.9467 0.008 0 0.000 0.984 0.008
#> GSM28790 1 0.2280 0.7809 0.880 0 0.000 0.000 0.120
#> GSM11300 3 0.0898 0.9687 0.008 0 0.972 0.000 0.020
#> GSM28798 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11318 1 0.2280 0.7788 0.880 0 0.000 0.000 0.120
#> GSM28792 1 0.2068 0.7998 0.904 0 0.000 0.004 0.092
#> GSM11295 5 0.5318 0.0102 0.004 0 0.460 0.040 0.496
#> GSM28793 1 0.1041 0.8127 0.964 0 0.000 0.004 0.032
#> GSM11312 5 0.6643 -0.0233 0.372 0 0.000 0.224 0.404
#> GSM28778 5 0.3366 0.6574 0.212 0 0.000 0.004 0.784
#> GSM28796 1 0.0703 0.8112 0.976 0 0.000 0.000 0.024
#> GSM11309 4 0.0771 0.9488 0.020 0 0.000 0.976 0.004
#> GSM11315 1 0.0510 0.8097 0.984 0 0.000 0.000 0.016
#> GSM11306 4 0.1809 0.9080 0.012 0 0.000 0.928 0.060
#> GSM28776 1 0.5570 0.5154 0.608 0 0.000 0.288 0.104
#> GSM28777 3 0.0798 0.9703 0.000 0 0.976 0.008 0.016
#> GSM11316 3 0.0794 0.9664 0.000 0 0.972 0.000 0.028
#> GSM11320 3 0.0000 0.9804 0.000 0 1.000 0.000 0.000
#> GSM28797 4 0.0671 0.9501 0.016 0 0.000 0.980 0.004
#> GSM28786 4 0.0865 0.9462 0.024 0 0.004 0.972 0.000
#> GSM28800 1 0.0794 0.8030 0.972 0 0.000 0.000 0.028
#> GSM11310 1 0.3398 0.6576 0.780 0 0.000 0.216 0.004
#> GSM28787 5 0.5480 0.3034 0.012 0 0.340 0.052 0.596
#> GSM11304 1 0.5098 0.5356 0.660 0 0.276 0.004 0.060
#> GSM11303 3 0.0000 0.9804 0.000 0 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.9804 0.000 0 1.000 0.000 0.000
#> GSM11311 4 0.3171 0.7842 0.176 0 0.000 0.816 0.008
#> GSM28799 1 0.4138 0.3627 0.616 0 0.000 0.384 0.000
#> GSM28791 5 0.2179 0.7616 0.112 0 0.000 0.000 0.888
#> GSM28794 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM28780 5 0.1965 0.7675 0.096 0 0.000 0.000 0.904
#> GSM28795 5 0.1205 0.7644 0.040 0 0.000 0.004 0.956
#> GSM11301 2 0.0000 1.0000 0.000 1 0.000 0.000 0.000
#> GSM11297 1 0.5707 0.3488 0.564 0 0.364 0.016 0.056
#> GSM11298 1 0.1430 0.8111 0.944 0 0.000 0.004 0.052
#> GSM11314 5 0.1074 0.7463 0.012 0 0.016 0.004 0.968
#> GSM11299 3 0.1117 0.9629 0.016 0 0.964 0.000 0.020
#> GSM28783 5 0.1831 0.7701 0.076 0 0.000 0.004 0.920
#> GSM11308 5 0.2179 0.7615 0.112 0 0.000 0.000 0.888
#> GSM28782 1 0.3586 0.6184 0.736 0 0.000 0.000 0.264
#> GSM28779 1 0.1121 0.8129 0.956 0 0.000 0.000 0.044
#> GSM11302 1 0.1638 0.8093 0.932 0 0.000 0.004 0.064
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.0603 0.9541 0.004 0.000 0.000 0.980 0.000 0.016
#> GSM28789 4 0.0748 0.9534 0.004 0.000 0.000 0.976 0.004 0.016
#> GSM28790 1 0.0909 0.7805 0.968 0.000 0.000 0.000 0.020 0.012
#> GSM11300 3 0.2996 0.5572 0.000 0.000 0.772 0.000 0.000 0.228
#> GSM28798 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0146 0.9956 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM28781 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.0146 0.9956 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11307 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9964 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0146 0.9956 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11318 1 0.1297 0.7725 0.948 0.000 0.000 0.000 0.012 0.040
#> GSM28792 1 0.2118 0.7268 0.888 0.000 0.000 0.000 0.008 0.104
#> GSM11295 3 0.6133 0.0947 0.008 0.000 0.484 0.016 0.140 0.352
#> GSM28793 1 0.0692 0.7806 0.976 0.000 0.000 0.000 0.004 0.020
#> GSM11312 5 0.6027 0.4441 0.184 0.000 0.000 0.200 0.576 0.040
#> GSM28778 5 0.1225 0.8126 0.036 0.000 0.000 0.000 0.952 0.012
#> GSM28796 1 0.0547 0.7824 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM11309 4 0.0508 0.9543 0.004 0.000 0.000 0.984 0.000 0.012
#> GSM11315 1 0.0405 0.7824 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM11306 4 0.1152 0.9313 0.000 0.000 0.000 0.952 0.004 0.044
#> GSM28776 1 0.5840 0.3503 0.536 0.000 0.000 0.216 0.008 0.240
#> GSM28777 3 0.1588 0.7252 0.000 0.000 0.924 0.000 0.004 0.072
#> GSM11316 3 0.1265 0.7389 0.000 0.000 0.948 0.000 0.008 0.044
#> GSM11320 3 0.0363 0.7552 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM28797 4 0.0291 0.9555 0.004 0.000 0.000 0.992 0.000 0.004
#> GSM28786 4 0.0748 0.9517 0.004 0.000 0.004 0.976 0.000 0.016
#> GSM28800 1 0.4333 0.1846 0.512 0.000 0.000 0.000 0.020 0.468
#> GSM11310 1 0.4988 0.1721 0.484 0.000 0.000 0.068 0.000 0.448
#> GSM28787 6 0.7214 -0.2731 0.032 0.000 0.348 0.032 0.228 0.360
#> GSM11304 6 0.5742 0.4495 0.152 0.000 0.236 0.000 0.024 0.588
#> GSM11303 3 0.0260 0.7550 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM11317 3 0.0363 0.7552 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM11311 4 0.2771 0.8310 0.116 0.000 0.000 0.852 0.000 0.032
#> GSM28799 1 0.5956 0.2643 0.488 0.000 0.004 0.236 0.000 0.272
#> GSM28791 5 0.1434 0.8077 0.048 0.000 0.000 0.000 0.940 0.012
#> GSM28794 2 0.0713 0.9755 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM28780 5 0.0622 0.8118 0.012 0.000 0.000 0.000 0.980 0.008
#> GSM28795 5 0.0146 0.8076 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM11301 2 0.0146 0.9956 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM11297 6 0.5747 0.4564 0.156 0.000 0.220 0.004 0.020 0.600
#> GSM11298 1 0.0146 0.7831 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11314 5 0.1367 0.7852 0.000 0.000 0.012 0.000 0.944 0.044
#> GSM11299 3 0.3684 0.3621 0.000 0.000 0.664 0.000 0.004 0.332
#> GSM28783 5 0.2070 0.7872 0.012 0.000 0.000 0.000 0.896 0.092
#> GSM11308 5 0.2263 0.7734 0.016 0.000 0.000 0.000 0.884 0.100
#> GSM28782 5 0.5984 0.1271 0.280 0.000 0.000 0.000 0.444 0.276
#> GSM28779 1 0.1411 0.7662 0.936 0.000 0.000 0.000 0.004 0.060
#> GSM11302 1 0.1168 0.7793 0.956 0.000 0.000 0.000 0.016 0.028
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 tissue(p) k
#> MAD:NMF 52 0.396 2
#> MAD:NMF 51 0.371 3
#> MAD:NMF 47 0.462 4
#> MAD:NMF 47 0.424 5
#> MAD:NMF 41 0.423 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.997 0.997 0.2930 0.708 0.708
#> 3 3 0.908 0.962 0.983 0.9035 0.719 0.604
#> 4 4 0.956 0.930 0.973 0.0889 0.977 0.947
#> 5 5 0.915 0.841 0.912 0.0223 0.986 0.966
#> 6 6 0.926 0.877 0.938 0.0356 0.958 0.892
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4
There is also optional best \(k\) = 2 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.0000 0.998 1.000 0.000
#> GSM28789 1 0.0000 0.998 1.000 0.000
#> GSM28790 1 0.0000 0.998 1.000 0.000
#> GSM11300 2 0.0672 1.000 0.008 0.992
#> GSM28798 1 0.0672 0.994 0.992 0.008
#> GSM11296 1 0.0672 0.994 0.992 0.008
#> GSM28801 1 0.0672 0.994 0.992 0.008
#> GSM11319 1 0.0672 0.994 0.992 0.008
#> GSM28781 1 0.0672 0.994 0.992 0.008
#> GSM11305 1 0.0672 0.994 0.992 0.008
#> GSM28784 1 0.0672 0.994 0.992 0.008
#> GSM11307 1 0.0672 0.994 0.992 0.008
#> GSM11313 1 0.0672 0.994 0.992 0.008
#> GSM28785 1 0.0672 0.994 0.992 0.008
#> GSM11318 1 0.0000 0.998 1.000 0.000
#> GSM28792 1 0.0000 0.998 1.000 0.000
#> GSM11295 2 0.0672 1.000 0.008 0.992
#> GSM28793 1 0.0000 0.998 1.000 0.000
#> GSM11312 1 0.0000 0.998 1.000 0.000
#> GSM28778 1 0.0000 0.998 1.000 0.000
#> GSM28796 1 0.0000 0.998 1.000 0.000
#> GSM11309 1 0.0000 0.998 1.000 0.000
#> GSM11315 1 0.0000 0.998 1.000 0.000
#> GSM11306 1 0.0000 0.998 1.000 0.000
#> GSM28776 1 0.0000 0.998 1.000 0.000
#> GSM28777 2 0.0672 1.000 0.008 0.992
#> GSM11316 2 0.0672 1.000 0.008 0.992
#> GSM11320 2 0.0672 1.000 0.008 0.992
#> GSM28797 1 0.0000 0.998 1.000 0.000
#> GSM28786 1 0.0000 0.998 1.000 0.000
#> GSM28800 1 0.0000 0.998 1.000 0.000
#> GSM11310 1 0.0000 0.998 1.000 0.000
#> GSM28787 2 0.0672 1.000 0.008 0.992
#> GSM11304 1 0.0000 0.998 1.000 0.000
#> GSM11303 2 0.0672 1.000 0.008 0.992
#> GSM11317 2 0.0672 1.000 0.008 0.992
#> GSM11311 1 0.0000 0.998 1.000 0.000
#> GSM28799 1 0.0000 0.998 1.000 0.000
#> GSM28791 1 0.0000 0.998 1.000 0.000
#> GSM28794 1 0.0376 0.996 0.996 0.004
#> GSM28780 1 0.0000 0.998 1.000 0.000
#> GSM28795 1 0.0000 0.998 1.000 0.000
#> GSM11301 1 0.0672 0.994 0.992 0.008
#> GSM11297 1 0.0000 0.998 1.000 0.000
#> GSM11298 1 0.0000 0.998 1.000 0.000
#> GSM11314 1 0.0000 0.998 1.000 0.000
#> GSM11299 2 0.0672 1.000 0.008 0.992
#> GSM28783 1 0.0000 0.998 1.000 0.000
#> GSM11308 1 0.0000 0.998 1.000 0.000
#> GSM28782 1 0.0000 0.998 1.000 0.000
#> GSM28779 1 0.0000 0.998 1.000 0.000
#> GSM11302 1 0.0000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28789 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28790 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11300 3 0.0424 0.990 0.008 0.000 0.992
#> GSM28798 2 0.0000 0.883 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.883 0.000 1.000 0.000
#> GSM28801 2 0.4555 0.772 0.200 0.800 0.000
#> GSM11319 2 0.0000 0.883 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.883 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.883 0.000 1.000 0.000
#> GSM28784 2 0.4555 0.772 0.200 0.800 0.000
#> GSM11307 2 0.0000 0.883 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.883 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.883 0.000 1.000 0.000
#> GSM11318 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28792 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.997 0.000 0.000 1.000
#> GSM28793 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11312 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28778 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28796 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11309 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11315 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11306 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28776 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.997 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.997 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.997 0.000 0.000 1.000
#> GSM28797 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28786 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28800 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11310 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.997 0.000 0.000 1.000
#> GSM11304 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11303 3 0.0000 0.997 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.997 0.000 0.000 1.000
#> GSM11311 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28799 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28791 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28794 2 0.5327 0.681 0.272 0.728 0.000
#> GSM28780 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28795 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11301 2 0.4555 0.772 0.200 0.800 0.000
#> GSM11297 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11298 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11314 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11299 3 0.0424 0.990 0.008 0.000 0.992
#> GSM28783 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11308 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28782 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28779 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11302 1 0.0000 1.000 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.0336 0.980 0.992 0.000 0.000 0.008
#> GSM28789 1 0.0336 0.980 0.992 0.000 0.000 0.008
#> GSM28790 1 0.0188 0.982 0.996 0.000 0.000 0.004
#> GSM11300 3 0.0336 0.992 0.000 0.000 0.992 0.008
#> GSM28798 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM28801 2 0.3688 0.794 0.000 0.792 0.000 0.208
#> GSM11319 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM28784 2 0.3688 0.794 0.000 0.792 0.000 0.208
#> GSM11307 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.909 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28792 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11295 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM28793 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11312 1 0.0188 0.982 0.996 0.000 0.000 0.004
#> GSM28778 1 0.3610 0.763 0.800 0.000 0.000 0.200
#> GSM28796 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11309 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11315 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11306 1 0.0817 0.966 0.976 0.000 0.000 0.024
#> GSM28776 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28777 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM28797 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28786 1 0.0336 0.980 0.992 0.000 0.000 0.008
#> GSM28800 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11310 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28787 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM11304 1 0.0336 0.980 0.992 0.000 0.000 0.008
#> GSM11303 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.998 0.000 0.000 1.000 0.000
#> GSM11311 1 0.0188 0.982 0.996 0.000 0.000 0.004
#> GSM28799 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28791 1 0.0188 0.982 0.996 0.000 0.000 0.004
#> GSM28794 2 0.5458 0.680 0.076 0.720 0.000 0.204
#> GSM28780 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28795 1 0.3266 0.802 0.832 0.000 0.000 0.168
#> GSM11301 2 0.3688 0.794 0.000 0.792 0.000 0.208
#> GSM11297 1 0.0336 0.980 0.992 0.000 0.000 0.008
#> GSM11298 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11314 4 0.0469 0.000 0.012 0.000 0.000 0.988
#> GSM11299 3 0.0336 0.992 0.000 0.000 0.992 0.008
#> GSM28783 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM11308 1 0.0336 0.980 0.992 0.000 0.000 0.008
#> GSM28782 1 0.0000 0.984 1.000 0.000 0.000 0.000
#> GSM28779 1 0.0188 0.982 0.996 0.000 0.000 0.004
#> GSM11302 1 0.0188 0.982 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.0290 0.974 0.992 0.008 0.000 0.000 0
#> GSM28789 1 0.0290 0.974 0.992 0.008 0.000 0.000 0
#> GSM28790 1 0.0162 0.976 0.996 0.004 0.000 0.000 0
#> GSM11300 4 0.3612 0.627 0.000 0.000 0.268 0.732 0
#> GSM28798 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM11296 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM28801 2 0.0000 0.632 0.000 1.000 0.000 0.000 0
#> GSM11319 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM28781 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM11305 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM28784 2 0.0000 0.632 0.000 1.000 0.000 0.000 0
#> GSM11307 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM11313 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM28785 2 0.4171 0.846 0.000 0.604 0.396 0.000 0
#> GSM11318 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28792 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11295 3 0.4300 0.551 0.000 0.000 0.524 0.476 0
#> GSM28793 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11312 1 0.0162 0.976 0.996 0.004 0.000 0.000 0
#> GSM28778 1 0.4428 0.620 0.700 0.032 0.000 0.268 0
#> GSM28796 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11309 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11315 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11306 1 0.0703 0.960 0.976 0.024 0.000 0.000 0
#> GSM28776 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28777 3 0.4171 0.933 0.000 0.000 0.604 0.396 0
#> GSM11316 3 0.4171 0.933 0.000 0.000 0.604 0.396 0
#> GSM11320 3 0.4171 0.933 0.000 0.000 0.604 0.396 0
#> GSM28797 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28786 1 0.0290 0.973 0.992 0.000 0.000 0.008 0
#> GSM28800 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11310 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28787 4 0.4305 -0.555 0.000 0.000 0.488 0.512 0
#> GSM11304 1 0.0290 0.973 0.992 0.000 0.000 0.008 0
#> GSM11303 3 0.4171 0.933 0.000 0.000 0.604 0.396 0
#> GSM11317 3 0.4171 0.933 0.000 0.000 0.604 0.396 0
#> GSM11311 1 0.0162 0.976 0.996 0.000 0.000 0.004 0
#> GSM28799 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28791 1 0.0162 0.976 0.996 0.004 0.000 0.000 0
#> GSM28794 2 0.1671 0.579 0.076 0.924 0.000 0.000 0
#> GSM28780 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28795 1 0.3612 0.665 0.732 0.000 0.000 0.268 0
#> GSM11301 2 0.0000 0.632 0.000 1.000 0.000 0.000 0
#> GSM11297 1 0.0290 0.973 0.992 0.000 0.000 0.008 0
#> GSM11298 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11314 5 0.0000 0.000 0.000 0.000 0.000 0.000 1
#> GSM11299 4 0.3612 0.627 0.000 0.000 0.268 0.732 0
#> GSM28783 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM11308 1 0.0290 0.973 0.992 0.000 0.000 0.008 0
#> GSM28782 1 0.0000 0.977 1.000 0.000 0.000 0.000 0
#> GSM28779 1 0.0162 0.976 0.996 0.004 0.000 0.000 0
#> GSM11302 1 0.0162 0.976 0.996 0.004 0.000 0.000 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 1 0.0260 0.987 0.992 0.008 0.000 0.000 0.000 0
#> GSM28789 1 0.0260 0.987 0.992 0.008 0.000 0.000 0.000 0
#> GSM28790 1 0.0146 0.992 0.996 0.004 0.000 0.000 0.000 0
#> GSM11300 4 0.0000 0.654 0.000 0.000 0.000 1.000 0.000 0
#> GSM28798 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM11296 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM28801 2 0.0000 0.605 0.000 1.000 0.000 0.000 0.000 0
#> GSM11319 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM28781 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM11305 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM28784 2 0.0000 0.605 0.000 1.000 0.000 0.000 0.000 0
#> GSM11307 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM11313 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM28785 2 0.3797 0.836 0.000 0.580 0.000 0.000 0.420 0
#> GSM11318 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28792 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11295 3 0.2823 0.673 0.000 0.000 0.796 0.204 0.000 0
#> GSM28793 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11312 1 0.0146 0.992 0.996 0.004 0.000 0.000 0.000 0
#> GSM28778 5 0.4445 0.946 0.396 0.032 0.000 0.000 0.572 0
#> GSM28796 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11309 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11315 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11306 1 0.0632 0.961 0.976 0.024 0.000 0.000 0.000 0
#> GSM28776 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28777 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000 0
#> GSM11316 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000 0
#> GSM11320 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000 0
#> GSM28797 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28786 1 0.0260 0.987 0.992 0.000 0.000 0.008 0.000 0
#> GSM28800 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11310 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28787 4 0.3804 0.180 0.000 0.000 0.424 0.576 0.000 0
#> GSM11304 1 0.0260 0.987 0.992 0.000 0.000 0.008 0.000 0
#> GSM11303 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000 0
#> GSM11317 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000 0
#> GSM11311 1 0.0146 0.991 0.996 0.000 0.000 0.004 0.000 0
#> GSM28799 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28791 1 0.0146 0.992 0.996 0.004 0.000 0.000 0.000 0
#> GSM28794 2 0.1501 0.559 0.076 0.924 0.000 0.000 0.000 0
#> GSM28780 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28795 5 0.3797 0.948 0.420 0.000 0.000 0.000 0.580 0
#> GSM11301 2 0.0000 0.605 0.000 1.000 0.000 0.000 0.000 0
#> GSM11297 1 0.0260 0.987 0.992 0.000 0.000 0.008 0.000 0
#> GSM11298 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11314 6 0.0000 0.000 0.000 0.000 0.000 0.000 0.000 1
#> GSM11299 4 0.0000 0.654 0.000 0.000 0.000 1.000 0.000 0
#> GSM28783 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM11308 1 0.0260 0.987 0.992 0.000 0.000 0.008 0.000 0
#> GSM28782 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000 0
#> GSM28779 1 0.0146 0.992 0.996 0.004 0.000 0.000 0.000 0
#> GSM11302 1 0.0146 0.992 0.996 0.004 0.000 0.000 0.000 0
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> ATC:hclust 52 0.396 2
#> ATC:hclust 52 0.372 3
#> ATC:hclust 51 0.371 4
#> ATC:hclust 50 0.349 5
#> ATC:hclust 50 0.331 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.514 0.747 0.798 0.3313 0.660 0.660
#> 3 3 1.000 0.981 0.993 0.6252 0.738 0.621
#> 4 4 0.684 0.704 0.861 0.2173 0.953 0.899
#> 5 5 0.630 0.619 0.778 0.1189 0.851 0.651
#> 6 6 0.665 0.640 0.782 0.0622 0.899 0.659
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
#> GSM28788 1 0.0000 0.800 1.000 0.000
#> GSM28789 1 0.0000 0.800 1.000 0.000
#> GSM28790 1 0.0000 0.800 1.000 0.000
#> GSM11300 1 0.9881 0.440 0.564 0.436
#> GSM28798 2 0.9881 0.998 0.436 0.564
#> GSM11296 2 0.9881 0.998 0.436 0.564
#> GSM28801 1 0.9970 -0.804 0.532 0.468
#> GSM11319 2 0.9881 0.998 0.436 0.564
#> GSM28781 2 0.9881 0.998 0.436 0.564
#> GSM11305 2 0.9881 0.998 0.436 0.564
#> GSM28784 2 0.9881 0.998 0.436 0.564
#> GSM11307 2 0.9881 0.998 0.436 0.564
#> GSM11313 2 0.9881 0.998 0.436 0.564
#> GSM28785 2 0.9881 0.998 0.436 0.564
#> GSM11318 1 0.0000 0.800 1.000 0.000
#> GSM28792 1 0.0000 0.800 1.000 0.000
#> GSM11295 1 0.9922 0.432 0.552 0.448
#> GSM28793 1 0.0000 0.800 1.000 0.000
#> GSM11312 1 0.0000 0.800 1.000 0.000
#> GSM28778 1 0.0000 0.800 1.000 0.000
#> GSM28796 1 0.0000 0.800 1.000 0.000
#> GSM11309 1 0.0000 0.800 1.000 0.000
#> GSM11315 1 0.0000 0.800 1.000 0.000
#> GSM11306 1 0.0000 0.800 1.000 0.000
#> GSM28776 1 0.0000 0.800 1.000 0.000
#> GSM28777 1 0.9922 0.432 0.552 0.448
#> GSM11316 1 0.9922 0.432 0.552 0.448
#> GSM11320 1 0.9922 0.432 0.552 0.448
#> GSM28797 1 0.0000 0.800 1.000 0.000
#> GSM28786 1 0.0000 0.800 1.000 0.000
#> GSM28800 1 0.0000 0.800 1.000 0.000
#> GSM11310 1 0.0000 0.800 1.000 0.000
#> GSM28787 1 0.9922 0.432 0.552 0.448
#> GSM11304 1 0.0000 0.800 1.000 0.000
#> GSM11303 1 0.9922 0.432 0.552 0.448
#> GSM11317 1 0.9922 0.432 0.552 0.448
#> GSM11311 1 0.0000 0.800 1.000 0.000
#> GSM28799 1 0.0000 0.800 1.000 0.000
#> GSM28791 1 0.0000 0.800 1.000 0.000
#> GSM28794 2 0.9922 0.978 0.448 0.552
#> GSM28780 1 0.0000 0.800 1.000 0.000
#> GSM28795 1 0.0000 0.800 1.000 0.000
#> GSM11301 2 0.9881 0.998 0.436 0.564
#> GSM11297 1 0.0000 0.800 1.000 0.000
#> GSM11298 1 0.0000 0.800 1.000 0.000
#> GSM11314 1 0.0938 0.784 0.988 0.012
#> GSM11299 1 0.9881 0.440 0.564 0.436
#> GSM28783 1 0.0000 0.800 1.000 0.000
#> GSM11308 1 0.0000 0.800 1.000 0.000
#> GSM28782 1 0.0000 0.800 1.000 0.000
#> GSM28779 1 0.0000 0.800 1.000 0.000
#> GSM11302 1 0.0000 0.800 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.000 0.996 1.000 0.000 0.000
#> GSM28789 1 0.000 0.996 1.000 0.000 0.000
#> GSM28790 1 0.000 0.996 1.000 0.000 0.000
#> GSM11300 3 0.000 1.000 0.000 0.000 1.000
#> GSM28798 2 0.000 0.968 0.000 1.000 0.000
#> GSM11296 2 0.000 0.968 0.000 1.000 0.000
#> GSM28801 2 0.470 0.657 0.212 0.788 0.000
#> GSM11319 2 0.000 0.968 0.000 1.000 0.000
#> GSM28781 2 0.000 0.968 0.000 1.000 0.000
#> GSM11305 2 0.000 0.968 0.000 1.000 0.000
#> GSM28784 2 0.000 0.968 0.000 1.000 0.000
#> GSM11307 2 0.000 0.968 0.000 1.000 0.000
#> GSM11313 2 0.000 0.968 0.000 1.000 0.000
#> GSM28785 2 0.000 0.968 0.000 1.000 0.000
#> GSM11318 1 0.000 0.996 1.000 0.000 0.000
#> GSM28792 1 0.000 0.996 1.000 0.000 0.000
#> GSM11295 3 0.000 1.000 0.000 0.000 1.000
#> GSM28793 1 0.000 0.996 1.000 0.000 0.000
#> GSM11312 1 0.000 0.996 1.000 0.000 0.000
#> GSM28778 1 0.000 0.996 1.000 0.000 0.000
#> GSM28796 1 0.000 0.996 1.000 0.000 0.000
#> GSM11309 1 0.000 0.996 1.000 0.000 0.000
#> GSM11315 1 0.000 0.996 1.000 0.000 0.000
#> GSM11306 1 0.000 0.996 1.000 0.000 0.000
#> GSM28776 1 0.000 0.996 1.000 0.000 0.000
#> GSM28777 3 0.000 1.000 0.000 0.000 1.000
#> GSM11316 3 0.000 1.000 0.000 0.000 1.000
#> GSM11320 3 0.000 1.000 0.000 0.000 1.000
#> GSM28797 1 0.000 0.996 1.000 0.000 0.000
#> GSM28786 1 0.000 0.996 1.000 0.000 0.000
#> GSM28800 1 0.000 0.996 1.000 0.000 0.000
#> GSM11310 1 0.000 0.996 1.000 0.000 0.000
#> GSM28787 3 0.000 1.000 0.000 0.000 1.000
#> GSM11304 1 0.000 0.996 1.000 0.000 0.000
#> GSM11303 3 0.000 1.000 0.000 0.000 1.000
#> GSM11317 3 0.000 1.000 0.000 0.000 1.000
#> GSM11311 1 0.000 0.996 1.000 0.000 0.000
#> GSM28799 1 0.000 0.996 1.000 0.000 0.000
#> GSM28791 1 0.000 0.996 1.000 0.000 0.000
#> GSM28794 1 0.000 0.996 1.000 0.000 0.000
#> GSM28780 1 0.000 0.996 1.000 0.000 0.000
#> GSM28795 1 0.000 0.996 1.000 0.000 0.000
#> GSM11301 2 0.000 0.968 0.000 1.000 0.000
#> GSM11297 1 0.000 0.996 1.000 0.000 0.000
#> GSM11298 1 0.000 0.996 1.000 0.000 0.000
#> GSM11314 1 0.000 0.996 1.000 0.000 0.000
#> GSM11299 1 0.362 0.843 0.864 0.000 0.136
#> GSM28783 1 0.000 0.996 1.000 0.000 0.000
#> GSM11308 1 0.000 0.996 1.000 0.000 0.000
#> GSM28782 1 0.000 0.996 1.000 0.000 0.000
#> GSM28779 1 0.000 0.996 1.000 0.000 0.000
#> GSM11302 1 0.000 0.996 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.3528 0.688 0.808 0.000 0.000 0.192
#> GSM28789 1 0.4008 0.613 0.756 0.000 0.000 0.244
#> GSM28790 1 0.2760 0.743 0.872 0.000 0.000 0.128
#> GSM11300 3 0.4454 0.660 0.000 0.000 0.692 0.308
#> GSM28798 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM28801 2 0.5483 0.462 0.016 0.536 0.000 0.448
#> GSM11319 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM28784 2 0.4955 0.503 0.000 0.556 0.000 0.444
#> GSM11307 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.890 0.000 1.000 0.000 0.000
#> GSM11318 1 0.2469 0.718 0.892 0.000 0.000 0.108
#> GSM28792 1 0.2469 0.718 0.892 0.000 0.000 0.108
#> GSM11295 3 0.0000 0.949 0.000 0.000 1.000 0.000
#> GSM28793 1 0.1389 0.749 0.952 0.000 0.000 0.048
#> GSM11312 1 0.2760 0.743 0.872 0.000 0.000 0.128
#> GSM28778 1 0.4907 0.106 0.580 0.000 0.000 0.420
#> GSM28796 1 0.0336 0.762 0.992 0.000 0.000 0.008
#> GSM11309 1 0.3311 0.712 0.828 0.000 0.000 0.172
#> GSM11315 1 0.1557 0.761 0.944 0.000 0.000 0.056
#> GSM11306 1 0.3610 0.679 0.800 0.000 0.000 0.200
#> GSM28776 1 0.1557 0.747 0.944 0.000 0.000 0.056
#> GSM28777 3 0.0000 0.949 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.949 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.949 0.000 0.000 1.000 0.000
#> GSM28797 1 0.3311 0.731 0.828 0.000 0.000 0.172
#> GSM28786 1 0.4877 0.242 0.592 0.000 0.000 0.408
#> GSM28800 1 0.1474 0.761 0.948 0.000 0.000 0.052
#> GSM11310 1 0.0817 0.764 0.976 0.000 0.000 0.024
#> GSM28787 3 0.1867 0.906 0.000 0.000 0.928 0.072
#> GSM11304 1 0.4164 0.522 0.736 0.000 0.000 0.264
#> GSM11303 3 0.0000 0.949 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.949 0.000 0.000 1.000 0.000
#> GSM11311 1 0.2408 0.718 0.896 0.000 0.000 0.104
#> GSM28799 1 0.2469 0.718 0.892 0.000 0.000 0.108
#> GSM28791 1 0.2704 0.743 0.876 0.000 0.000 0.124
#> GSM28794 4 0.4877 0.150 0.408 0.000 0.000 0.592
#> GSM28780 1 0.2704 0.743 0.876 0.000 0.000 0.124
#> GSM28795 1 0.4643 0.421 0.656 0.000 0.000 0.344
#> GSM11301 2 0.4040 0.726 0.000 0.752 0.000 0.248
#> GSM11297 1 0.4164 0.522 0.736 0.000 0.000 0.264
#> GSM11298 1 0.0000 0.763 1.000 0.000 0.000 0.000
#> GSM11314 4 0.3172 0.315 0.160 0.000 0.000 0.840
#> GSM11299 1 0.6079 0.152 0.568 0.000 0.052 0.380
#> GSM28783 1 0.2469 0.757 0.892 0.000 0.000 0.108
#> GSM11308 1 0.4164 0.522 0.736 0.000 0.000 0.264
#> GSM28782 1 0.2704 0.743 0.876 0.000 0.000 0.124
#> GSM28779 1 0.1474 0.761 0.948 0.000 0.000 0.052
#> GSM11302 1 0.2704 0.743 0.876 0.000 0.000 0.124
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.4119 0.5923 0.752 0.000 0.000 0.212 0.036
#> GSM28789 1 0.4325 0.5712 0.736 0.000 0.000 0.220 0.044
#> GSM28790 1 0.1043 0.7092 0.960 0.000 0.000 0.040 0.000
#> GSM11300 5 0.5159 -0.1961 0.000 0.000 0.400 0.044 0.556
#> GSM28798 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM28801 4 0.4555 0.2619 0.020 0.344 0.000 0.636 0.000
#> GSM11319 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM28784 4 0.4722 0.2218 0.024 0.368 0.000 0.608 0.000
#> GSM11307 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9288 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.4956 0.4450 0.636 0.000 0.000 0.048 0.316
#> GSM28792 1 0.5027 0.4476 0.640 0.000 0.000 0.056 0.304
#> GSM11295 3 0.0963 0.9543 0.000 0.000 0.964 0.036 0.000
#> GSM28793 1 0.3863 0.5835 0.740 0.000 0.000 0.012 0.248
#> GSM11312 1 0.1965 0.7001 0.904 0.000 0.000 0.096 0.000
#> GSM28778 1 0.6036 -0.0693 0.452 0.000 0.000 0.432 0.116
#> GSM28796 1 0.3630 0.6276 0.780 0.000 0.000 0.016 0.204
#> GSM11309 1 0.4302 0.6066 0.744 0.000 0.000 0.208 0.048
#> GSM11315 1 0.2046 0.6977 0.916 0.000 0.000 0.016 0.068
#> GSM11306 1 0.4134 0.5995 0.760 0.000 0.000 0.196 0.044
#> GSM28776 1 0.3819 0.6031 0.756 0.000 0.000 0.016 0.228
#> GSM28777 3 0.0963 0.9543 0.000 0.000 0.964 0.036 0.000
#> GSM11316 3 0.0000 0.9619 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.9619 0.000 0.000 1.000 0.000 0.000
#> GSM28797 1 0.6083 0.5216 0.572 0.000 0.000 0.204 0.224
#> GSM28786 5 0.2612 0.6057 0.124 0.000 0.000 0.008 0.868
#> GSM28800 1 0.1877 0.7009 0.924 0.000 0.000 0.012 0.064
#> GSM11310 1 0.1952 0.6979 0.912 0.000 0.000 0.004 0.084
#> GSM28787 3 0.3966 0.8155 0.000 0.000 0.796 0.072 0.132
#> GSM11304 5 0.3913 0.5325 0.324 0.000 0.000 0.000 0.676
#> GSM11303 3 0.0000 0.9619 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.9619 0.000 0.000 1.000 0.000 0.000
#> GSM11311 1 0.4306 0.4660 0.660 0.000 0.000 0.012 0.328
#> GSM28799 1 0.5027 0.4476 0.640 0.000 0.000 0.056 0.304
#> GSM28791 1 0.2020 0.6988 0.900 0.000 0.000 0.100 0.000
#> GSM28794 4 0.3074 0.3785 0.196 0.000 0.000 0.804 0.000
#> GSM28780 1 0.2020 0.6988 0.900 0.000 0.000 0.100 0.000
#> GSM28795 4 0.6627 -0.0727 0.296 0.000 0.000 0.452 0.252
#> GSM11301 2 0.4294 0.0104 0.000 0.532 0.000 0.468 0.000
#> GSM11297 5 0.3913 0.5325 0.324 0.000 0.000 0.000 0.676
#> GSM11298 1 0.2966 0.6506 0.816 0.000 0.000 0.000 0.184
#> GSM11314 5 0.4383 -0.0104 0.004 0.000 0.000 0.424 0.572
#> GSM11299 5 0.3355 0.6002 0.132 0.000 0.000 0.036 0.832
#> GSM28783 1 0.4430 0.6596 0.752 0.000 0.000 0.076 0.172
#> GSM11308 5 0.3895 0.5353 0.320 0.000 0.000 0.000 0.680
#> GSM28782 1 0.2179 0.6996 0.896 0.000 0.000 0.100 0.004
#> GSM28779 1 0.1942 0.7003 0.920 0.000 0.000 0.012 0.068
#> GSM11302 1 0.0771 0.7107 0.976 0.000 0.000 0.020 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.3428 0.6148 0.304 0.000 0.000 0.696 0.000 0.000
#> GSM28789 4 0.3409 0.6187 0.300 0.000 0.000 0.700 0.000 0.000
#> GSM28790 1 0.3595 0.4987 0.704 0.000 0.000 0.288 0.008 0.000
#> GSM11300 6 0.3780 0.2088 0.000 0.000 0.248 0.004 0.020 0.728
#> GSM28798 2 0.0603 0.9852 0.000 0.980 0.000 0.016 0.000 0.004
#> GSM11296 2 0.0000 0.9912 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 5 0.2442 0.8075 0.000 0.144 0.000 0.004 0.852 0.000
#> GSM11319 2 0.0603 0.9852 0.000 0.980 0.000 0.016 0.000 0.004
#> GSM28781 2 0.0603 0.9852 0.000 0.980 0.000 0.016 0.000 0.004
#> GSM11305 2 0.0000 0.9912 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 5 0.2854 0.8064 0.000 0.208 0.000 0.000 0.792 0.000
#> GSM11307 2 0.0000 0.9912 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9912 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9912 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.3432 0.5235 0.836 0.000 0.000 0.044 0.036 0.084
#> GSM28792 1 0.3581 0.5142 0.824 0.000 0.000 0.044 0.036 0.096
#> GSM11295 3 0.2066 0.9115 0.000 0.000 0.908 0.052 0.040 0.000
#> GSM28793 1 0.0458 0.6524 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM11312 1 0.4101 0.2518 0.580 0.000 0.000 0.408 0.012 0.000
#> GSM28778 4 0.5176 0.3782 0.072 0.000 0.000 0.696 0.156 0.076
#> GSM28796 1 0.0405 0.6617 0.988 0.000 0.000 0.008 0.004 0.000
#> GSM11309 4 0.4053 0.6162 0.300 0.000 0.000 0.676 0.020 0.004
#> GSM11315 1 0.2442 0.6510 0.852 0.000 0.000 0.144 0.004 0.000
#> GSM11306 4 0.3672 0.6082 0.304 0.000 0.000 0.688 0.008 0.000
#> GSM28776 1 0.0820 0.6592 0.972 0.000 0.000 0.016 0.000 0.012
#> GSM28777 3 0.2066 0.9115 0.000 0.000 0.908 0.052 0.040 0.000
#> GSM11316 3 0.0000 0.9318 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.9318 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 4 0.4972 0.4388 0.424 0.000 0.000 0.524 0.020 0.032
#> GSM28786 6 0.3936 0.6307 0.228 0.000 0.000 0.024 0.012 0.736
#> GSM28800 1 0.2491 0.6461 0.836 0.000 0.000 0.164 0.000 0.000
#> GSM11310 1 0.2378 0.6542 0.848 0.000 0.000 0.152 0.000 0.000
#> GSM28787 3 0.4946 0.7300 0.000 0.000 0.692 0.056 0.048 0.204
#> GSM11304 6 0.4093 0.5930 0.440 0.000 0.000 0.004 0.004 0.552
#> GSM11303 3 0.0000 0.9318 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.0000 0.9318 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 1 0.1970 0.6066 0.900 0.000 0.000 0.008 0.000 0.092
#> GSM28799 1 0.3559 0.5213 0.828 0.000 0.000 0.052 0.036 0.084
#> GSM28791 1 0.4322 0.1061 0.528 0.000 0.000 0.452 0.020 0.000
#> GSM28794 5 0.3416 0.6281 0.056 0.000 0.000 0.140 0.804 0.000
#> GSM28780 1 0.4456 0.0803 0.520 0.000 0.000 0.456 0.020 0.004
#> GSM28795 4 0.6485 0.2188 0.164 0.000 0.000 0.548 0.200 0.088
#> GSM11301 5 0.3707 0.6865 0.000 0.312 0.000 0.008 0.680 0.000
#> GSM11297 6 0.4098 0.5884 0.444 0.000 0.000 0.004 0.004 0.548
#> GSM11298 1 0.1080 0.6658 0.960 0.000 0.000 0.032 0.004 0.004
#> GSM11314 6 0.6823 -0.0744 0.060 0.000 0.000 0.204 0.320 0.416
#> GSM11299 6 0.3087 0.5973 0.176 0.000 0.000 0.004 0.012 0.808
#> GSM28783 1 0.3030 0.5521 0.816 0.000 0.000 0.168 0.008 0.008
#> GSM11308 6 0.4093 0.5930 0.440 0.000 0.000 0.004 0.004 0.552
#> GSM28782 1 0.4456 0.0803 0.520 0.000 0.000 0.456 0.020 0.004
#> GSM28779 1 0.2520 0.6532 0.844 0.000 0.000 0.152 0.004 0.000
#> GSM11302 1 0.3265 0.5597 0.748 0.000 0.000 0.248 0.004 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> ATC:kmeans 42 0.384 2
#> ATC:kmeans 52 0.372 3
#> ATC:kmeans 45 0.363 4
#> ATC:kmeans 40 0.332 5
#> ATC:kmeans 42 0.423 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.933 0.974 0.4388 0.581 0.581
#> 3 3 0.912 0.923 0.967 0.4581 0.736 0.567
#> 4 4 0.807 0.778 0.904 0.1717 0.833 0.571
#> 5 5 0.764 0.690 0.806 0.0592 0.889 0.593
#> 6 6 0.782 0.557 0.773 0.0342 0.914 0.637
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
#> GSM28788 1 0.0000 0.963 1.000 0.000
#> GSM28789 2 0.1184 0.983 0.016 0.984
#> GSM28790 1 0.9358 0.469 0.648 0.352
#> GSM11300 1 0.0000 0.963 1.000 0.000
#> GSM28798 2 0.0000 0.999 0.000 1.000
#> GSM11296 2 0.0000 0.999 0.000 1.000
#> GSM28801 2 0.0000 0.999 0.000 1.000
#> GSM11319 2 0.0000 0.999 0.000 1.000
#> GSM28781 2 0.0000 0.999 0.000 1.000
#> GSM11305 2 0.0000 0.999 0.000 1.000
#> GSM28784 2 0.0000 0.999 0.000 1.000
#> GSM11307 2 0.0000 0.999 0.000 1.000
#> GSM11313 2 0.0000 0.999 0.000 1.000
#> GSM28785 2 0.0000 0.999 0.000 1.000
#> GSM11318 1 0.0000 0.963 1.000 0.000
#> GSM28792 1 0.0000 0.963 1.000 0.000
#> GSM11295 1 0.0000 0.963 1.000 0.000
#> GSM28793 1 0.0000 0.963 1.000 0.000
#> GSM11312 1 0.0376 0.960 0.996 0.004
#> GSM28778 2 0.0000 0.999 0.000 1.000
#> GSM28796 1 0.0000 0.963 1.000 0.000
#> GSM11309 1 0.0000 0.963 1.000 0.000
#> GSM11315 1 0.1633 0.943 0.976 0.024
#> GSM11306 1 0.9988 0.116 0.520 0.480
#> GSM28776 1 0.0000 0.963 1.000 0.000
#> GSM28777 1 0.0000 0.963 1.000 0.000
#> GSM11316 1 0.0000 0.963 1.000 0.000
#> GSM11320 1 0.0000 0.963 1.000 0.000
#> GSM28797 1 0.0000 0.963 1.000 0.000
#> GSM28786 1 0.0000 0.963 1.000 0.000
#> GSM28800 1 0.0000 0.963 1.000 0.000
#> GSM11310 1 0.0000 0.963 1.000 0.000
#> GSM28787 1 0.0000 0.963 1.000 0.000
#> GSM11304 1 0.0000 0.963 1.000 0.000
#> GSM11303 1 0.0000 0.963 1.000 0.000
#> GSM11317 1 0.0000 0.963 1.000 0.000
#> GSM11311 1 0.0000 0.963 1.000 0.000
#> GSM28799 1 0.0000 0.963 1.000 0.000
#> GSM28791 1 0.1633 0.943 0.976 0.024
#> GSM28794 2 0.0000 0.999 0.000 1.000
#> GSM28780 1 0.0000 0.963 1.000 0.000
#> GSM28795 1 0.9850 0.263 0.572 0.428
#> GSM11301 2 0.0000 0.999 0.000 1.000
#> GSM11297 1 0.0000 0.963 1.000 0.000
#> GSM11298 1 0.0000 0.963 1.000 0.000
#> GSM11314 2 0.0000 0.999 0.000 1.000
#> GSM11299 1 0.0000 0.963 1.000 0.000
#> GSM28783 1 0.0000 0.963 1.000 0.000
#> GSM11308 1 0.0000 0.963 1.000 0.000
#> GSM28782 1 0.0000 0.963 1.000 0.000
#> GSM28779 1 0.0000 0.963 1.000 0.000
#> GSM11302 1 0.0000 0.963 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28789 1 0.4399 0.762 0.812 0.188 0.000
#> GSM28790 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.975 0.000 0.000 1.000
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28801 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28784 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11318 1 0.4555 0.761 0.800 0.000 0.200
#> GSM28792 1 0.4555 0.761 0.800 0.000 0.200
#> GSM11295 3 0.0000 0.975 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28778 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28796 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11309 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11315 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.975 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.975 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.975 0.000 0.000 1.000
#> GSM28797 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28786 3 0.0000 0.975 0.000 0.000 1.000
#> GSM28800 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.975 0.000 0.000 1.000
#> GSM11304 1 0.6079 0.440 0.612 0.000 0.388
#> GSM11303 3 0.0000 0.975 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.975 0.000 0.000 1.000
#> GSM11311 1 0.1163 0.923 0.972 0.000 0.028
#> GSM28799 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28794 2 0.0000 1.000 0.000 1.000 0.000
#> GSM28780 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28795 3 0.0892 0.956 0.020 0.000 0.980
#> GSM11301 2 0.0000 1.000 0.000 1.000 0.000
#> GSM11297 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11298 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11314 3 0.4931 0.677 0.000 0.232 0.768
#> GSM11299 3 0.0000 0.975 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11308 1 0.6305 0.174 0.516 0.000 0.484
#> GSM28782 1 0.0000 0.942 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.942 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.942 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 4 0.0707 0.6955 0.020 0.000 0.000 0.980
#> GSM28789 4 0.1174 0.6935 0.020 0.012 0.000 0.968
#> GSM28790 4 0.4998 0.0466 0.488 0.000 0.000 0.512
#> GSM11300 3 0.0469 0.9701 0.000 0.000 0.988 0.012
#> GSM28798 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11318 1 0.0000 0.8349 1.000 0.000 0.000 0.000
#> GSM28792 1 0.0188 0.8349 0.996 0.000 0.004 0.000
#> GSM11295 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM28793 1 0.0336 0.8359 0.992 0.000 0.000 0.008
#> GSM11312 4 0.4103 0.6097 0.256 0.000 0.000 0.744
#> GSM28778 4 0.3024 0.6147 0.000 0.148 0.000 0.852
#> GSM28796 1 0.0469 0.8360 0.988 0.000 0.000 0.012
#> GSM11309 4 0.0000 0.6901 0.000 0.000 0.000 1.000
#> GSM11315 1 0.4040 0.6215 0.752 0.000 0.000 0.248
#> GSM11306 4 0.0707 0.6955 0.020 0.000 0.000 0.980
#> GSM28776 1 0.1211 0.8294 0.960 0.000 0.000 0.040
#> GSM28777 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM28797 4 0.4164 0.4710 0.264 0.000 0.000 0.736
#> GSM28786 3 0.1174 0.9573 0.012 0.000 0.968 0.020
#> GSM28800 1 0.4454 0.5363 0.692 0.000 0.000 0.308
#> GSM11310 1 0.4277 0.5838 0.720 0.000 0.000 0.280
#> GSM28787 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM11304 1 0.1174 0.8247 0.968 0.000 0.012 0.020
#> GSM11303 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9751 0.000 0.000 1.000 0.000
#> GSM11311 1 0.0817 0.8287 0.976 0.000 0.000 0.024
#> GSM28799 1 0.1118 0.8275 0.964 0.000 0.000 0.036
#> GSM28791 4 0.4008 0.6236 0.244 0.000 0.000 0.756
#> GSM28794 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM28780 4 0.3907 0.6322 0.232 0.000 0.000 0.768
#> GSM28795 4 0.6340 0.0563 0.064 0.000 0.408 0.528
#> GSM11301 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM11297 1 0.0921 0.8302 0.972 0.000 0.000 0.028
#> GSM11298 1 0.1211 0.8289 0.960 0.000 0.000 0.040
#> GSM11314 3 0.3636 0.7874 0.008 0.172 0.820 0.000
#> GSM11299 3 0.0469 0.9701 0.000 0.000 0.988 0.012
#> GSM28783 1 0.4907 0.0540 0.580 0.000 0.000 0.420
#> GSM11308 1 0.1520 0.8171 0.956 0.000 0.024 0.020
#> GSM28782 4 0.4008 0.6236 0.244 0.000 0.000 0.756
#> GSM28779 1 0.4500 0.5174 0.684 0.000 0.000 0.316
#> GSM11302 4 0.4996 0.0698 0.484 0.000 0.000 0.516
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.413 0.7035 0.380 0.000 0.000 0.620 0.000
#> GSM28789 4 0.413 0.7035 0.380 0.000 0.000 0.620 0.000
#> GSM28790 1 0.347 0.6013 0.836 0.000 0.000 0.072 0.092
#> GSM11300 3 0.223 0.8662 0.000 0.000 0.892 0.004 0.104
#> GSM28798 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11307 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11318 5 0.530 0.6249 0.292 0.000 0.000 0.080 0.628
#> GSM28792 5 0.581 0.6248 0.236 0.000 0.004 0.140 0.620
#> GSM11295 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM28793 5 0.425 0.5689 0.340 0.000 0.000 0.008 0.652
#> GSM11312 1 0.213 0.5056 0.892 0.000 0.000 0.108 0.000
#> GSM28778 4 0.424 0.5995 0.100 0.084 0.000 0.800 0.016
#> GSM28796 5 0.471 0.3586 0.436 0.000 0.000 0.016 0.548
#> GSM11309 4 0.526 0.6820 0.368 0.000 0.000 0.576 0.056
#> GSM11315 1 0.482 0.1661 0.616 0.000 0.000 0.032 0.352
#> GSM11306 4 0.417 0.6895 0.396 0.000 0.000 0.604 0.000
#> GSM28776 1 0.437 0.0140 0.580 0.000 0.000 0.004 0.416
#> GSM28777 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM28797 4 0.606 0.5205 0.168 0.000 0.000 0.564 0.268
#> GSM28786 3 0.467 0.6815 0.000 0.000 0.684 0.044 0.272
#> GSM28800 1 0.345 0.5253 0.784 0.000 0.000 0.008 0.208
#> GSM11310 1 0.337 0.5107 0.768 0.000 0.000 0.000 0.232
#> GSM28787 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM11304 5 0.284 0.6171 0.064 0.000 0.016 0.032 0.888
#> GSM11303 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.000 0.9171 0.000 0.000 1.000 0.000 0.000
#> GSM11311 5 0.376 0.6637 0.188 0.000 0.000 0.028 0.784
#> GSM28799 5 0.609 0.5646 0.304 0.000 0.000 0.152 0.544
#> GSM28791 1 0.289 0.4525 0.844 0.000 0.000 0.148 0.008
#> GSM28794 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM28780 1 0.410 0.2501 0.748 0.000 0.000 0.220 0.032
#> GSM28795 4 0.479 0.4470 0.036 0.000 0.176 0.748 0.040
#> GSM11301 2 0.000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM11297 5 0.253 0.6204 0.076 0.000 0.000 0.032 0.892
#> GSM11298 1 0.450 -0.0249 0.568 0.000 0.000 0.008 0.424
#> GSM11314 3 0.576 0.6179 0.000 0.080 0.664 0.220 0.036
#> GSM11299 3 0.229 0.8637 0.000 0.000 0.888 0.004 0.108
#> GSM28783 1 0.603 0.3498 0.572 0.000 0.000 0.172 0.256
#> GSM11308 5 0.293 0.6067 0.048 0.000 0.032 0.032 0.888
#> GSM28782 1 0.365 0.3709 0.796 0.000 0.000 0.176 0.028
#> GSM28779 1 0.311 0.5294 0.800 0.000 0.000 0.000 0.200
#> GSM11302 1 0.277 0.6093 0.876 0.000 0.000 0.032 0.092
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.551 -0.06914 0.020 0.000 0.000 0.520 0.380 0.080
#> GSM28789 4 0.552 -0.07338 0.020 0.000 0.000 0.516 0.384 0.080
#> GSM28790 4 0.441 0.25253 0.320 0.000 0.000 0.644 0.024 0.012
#> GSM11300 3 0.242 0.78356 0.000 0.000 0.844 0.000 0.000 0.156
#> GSM28798 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11307 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.238 0.55679 0.884 0.000 0.000 0.008 0.012 0.096
#> GSM28792 1 0.280 0.48751 0.856 0.000 0.000 0.012 0.016 0.116
#> GSM11295 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28793 1 0.552 0.43101 0.536 0.000 0.000 0.160 0.000 0.304
#> GSM11312 4 0.340 0.44039 0.132 0.000 0.000 0.820 0.020 0.028
#> GSM28778 5 0.169 0.82847 0.000 0.012 0.000 0.064 0.924 0.000
#> GSM28796 1 0.514 0.56209 0.632 0.000 0.000 0.136 0.004 0.228
#> GSM11309 4 0.636 -0.07820 0.036 0.000 0.000 0.472 0.324 0.168
#> GSM11315 1 0.499 0.40959 0.628 0.000 0.000 0.292 0.016 0.064
#> GSM11306 4 0.536 0.00941 0.024 0.000 0.000 0.568 0.340 0.068
#> GSM28776 1 0.661 0.17628 0.420 0.000 0.000 0.316 0.036 0.228
#> GSM28777 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 6 0.650 -0.12844 0.024 0.000 0.000 0.272 0.280 0.424
#> GSM28786 3 0.561 0.35897 0.080 0.000 0.532 0.004 0.020 0.364
#> GSM28800 4 0.609 0.00114 0.376 0.000 0.000 0.472 0.036 0.116
#> GSM11310 4 0.628 -0.01975 0.356 0.000 0.000 0.456 0.032 0.156
#> GSM28787 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11304 6 0.276 0.61873 0.084 0.000 0.020 0.024 0.000 0.872
#> GSM11303 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11317 3 0.000 0.86909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 6 0.510 0.03074 0.436 0.000 0.000 0.040 0.020 0.504
#> GSM28799 1 0.215 0.53088 0.904 0.000 0.000 0.008 0.016 0.072
#> GSM28791 4 0.255 0.46356 0.088 0.000 0.000 0.880 0.020 0.012
#> GSM28794 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28780 4 0.271 0.46502 0.036 0.000 0.000 0.884 0.040 0.040
#> GSM28795 5 0.274 0.82520 0.028 0.000 0.064 0.012 0.884 0.012
#> GSM11301 2 0.000 1.00000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11297 6 0.233 0.60703 0.080 0.000 0.000 0.032 0.000 0.888
#> GSM11298 4 0.605 -0.23398 0.328 0.000 0.000 0.404 0.000 0.268
#> GSM11314 3 0.662 0.28691 0.112 0.068 0.544 0.000 0.256 0.020
#> GSM11299 3 0.253 0.77549 0.000 0.000 0.832 0.000 0.000 0.168
#> GSM28783 4 0.649 0.14812 0.120 0.000 0.000 0.492 0.076 0.312
#> GSM11308 6 0.282 0.61052 0.068 0.000 0.044 0.016 0.000 0.872
#> GSM28782 4 0.288 0.46375 0.056 0.000 0.000 0.872 0.024 0.048
#> GSM28779 4 0.584 0.06669 0.360 0.000 0.000 0.512 0.032 0.096
#> GSM11302 4 0.438 0.29540 0.268 0.000 0.000 0.684 0.012 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 tissue(p) k
#> ATC:skmeans 49 0.393 2
#> ATC:skmeans 50 0.370 3
#> ATC:skmeans 47 0.440 4
#> ATC:skmeans 43 0.400 5
#> ATC:skmeans 29 0.379 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.979 0.992 0.3314 0.660 0.660
#> 3 3 1.000 0.959 0.987 0.5908 0.801 0.698
#> 4 4 0.665 0.692 0.815 0.2014 0.940 0.873
#> 5 5 0.708 0.766 0.889 0.0812 0.894 0.756
#> 6 6 0.727 0.722 0.876 0.0254 0.971 0.913
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
#> GSM28788 1 0.000 1.000 1.0 0.0
#> GSM28789 1 0.000 1.000 1.0 0.0
#> GSM28790 1 0.000 1.000 1.0 0.0
#> GSM11300 1 0.000 1.000 1.0 0.0
#> GSM28798 2 0.000 0.960 0.0 1.0
#> GSM11296 2 0.000 0.960 0.0 1.0
#> GSM28801 2 0.971 0.333 0.4 0.6
#> GSM11319 2 0.000 0.960 0.0 1.0
#> GSM28781 2 0.000 0.960 0.0 1.0
#> GSM11305 2 0.000 0.960 0.0 1.0
#> GSM28784 2 0.000 0.960 0.0 1.0
#> GSM11307 2 0.000 0.960 0.0 1.0
#> GSM11313 2 0.000 0.960 0.0 1.0
#> GSM28785 2 0.000 0.960 0.0 1.0
#> GSM11318 1 0.000 1.000 1.0 0.0
#> GSM28792 1 0.000 1.000 1.0 0.0
#> GSM11295 1 0.000 1.000 1.0 0.0
#> GSM28793 1 0.000 1.000 1.0 0.0
#> GSM11312 1 0.000 1.000 1.0 0.0
#> GSM28778 1 0.000 1.000 1.0 0.0
#> GSM28796 1 0.000 1.000 1.0 0.0
#> GSM11309 1 0.000 1.000 1.0 0.0
#> GSM11315 1 0.000 1.000 1.0 0.0
#> GSM11306 1 0.000 1.000 1.0 0.0
#> GSM28776 1 0.000 1.000 1.0 0.0
#> GSM28777 1 0.000 1.000 1.0 0.0
#> GSM11316 1 0.000 1.000 1.0 0.0
#> GSM11320 1 0.000 1.000 1.0 0.0
#> GSM28797 1 0.000 1.000 1.0 0.0
#> GSM28786 1 0.000 1.000 1.0 0.0
#> GSM28800 1 0.000 1.000 1.0 0.0
#> GSM11310 1 0.000 1.000 1.0 0.0
#> GSM28787 1 0.000 1.000 1.0 0.0
#> GSM11304 1 0.000 1.000 1.0 0.0
#> GSM11303 1 0.000 1.000 1.0 0.0
#> GSM11317 1 0.000 1.000 1.0 0.0
#> GSM11311 1 0.000 1.000 1.0 0.0
#> GSM28799 1 0.000 1.000 1.0 0.0
#> GSM28791 1 0.000 1.000 1.0 0.0
#> GSM28794 1 0.000 1.000 1.0 0.0
#> GSM28780 1 0.000 1.000 1.0 0.0
#> GSM28795 1 0.000 1.000 1.0 0.0
#> GSM11301 2 0.000 0.960 0.0 1.0
#> GSM11297 1 0.000 1.000 1.0 0.0
#> GSM11298 1 0.000 1.000 1.0 0.0
#> GSM11314 1 0.000 1.000 1.0 0.0
#> GSM11299 1 0.000 1.000 1.0 0.0
#> GSM28783 1 0.000 1.000 1.0 0.0
#> GSM11308 1 0.000 1.000 1.0 0.0
#> GSM28782 1 0.000 1.000 1.0 0.0
#> GSM28779 1 0.000 1.000 1.0 0.0
#> GSM11302 1 0.000 1.000 1.0 0.0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28789 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28790 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11300 3 0.5254 0.585 0.264 0.000 0.736
#> GSM28798 2 0.0000 0.935 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.935 0.000 1.000 0.000
#> GSM28801 2 0.6126 0.338 0.400 0.600 0.000
#> GSM11319 2 0.0000 0.935 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.935 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.935 0.000 1.000 0.000
#> GSM28784 2 0.0747 0.916 0.016 0.984 0.000
#> GSM11307 2 0.0000 0.935 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.935 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.935 0.000 1.000 0.000
#> GSM11318 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28792 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11295 3 0.0000 0.943 0.000 0.000 1.000
#> GSM28793 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11312 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28778 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28796 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11309 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11315 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11306 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28776 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.943 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.943 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.943 0.000 0.000 1.000
#> GSM28797 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28786 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28800 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11310 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.943 0.000 0.000 1.000
#> GSM11304 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11303 3 0.0000 0.943 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.943 0.000 0.000 1.000
#> GSM11311 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28799 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28791 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28794 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28780 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28795 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11301 2 0.0000 0.935 0.000 1.000 0.000
#> GSM11297 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11298 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11314 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11299 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28783 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11308 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28782 1 0.0000 1.000 1.000 0.000 0.000
#> GSM28779 1 0.0000 1.000 1.000 0.000 0.000
#> GSM11302 1 0.0000 1.000 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM28789 1 0.3528 0.6843 0.808 0.000 0.000 0.192
#> GSM28790 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM11300 2 0.7830 -0.3171 0.000 0.400 0.268 0.332
#> GSM28798 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM11296 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM28801 4 0.6537 0.7679 0.164 0.200 0.000 0.636
#> GSM11319 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM28781 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM11305 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM28784 4 0.6537 0.7679 0.164 0.200 0.000 0.636
#> GSM11307 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM11313 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM28785 2 0.4855 0.3919 0.000 0.600 0.000 0.400
#> GSM11318 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM28792 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM11295 3 0.0000 0.9727 0.000 0.000 1.000 0.000
#> GSM28793 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM11312 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM28778 1 0.3942 0.6258 0.764 0.000 0.000 0.236
#> GSM28796 1 0.2921 0.8269 0.860 0.000 0.000 0.140
#> GSM11309 1 0.1389 0.8490 0.952 0.000 0.000 0.048
#> GSM11315 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM11306 1 0.0188 0.8525 0.996 0.000 0.000 0.004
#> GSM28776 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM28777 3 0.0000 0.9727 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.9727 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9727 0.000 0.000 1.000 0.000
#> GSM28797 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM28786 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM28800 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM11310 1 0.3123 0.8216 0.844 0.000 0.000 0.156
#> GSM28787 3 0.3610 0.8257 0.000 0.000 0.800 0.200
#> GSM11304 1 0.7393 0.3672 0.436 0.400 0.000 0.164
#> GSM11303 3 0.0000 0.9727 0.000 0.000 1.000 0.000
#> GSM11317 3 0.0000 0.9727 0.000 0.000 1.000 0.000
#> GSM11311 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM28799 1 0.3219 0.8188 0.836 0.000 0.000 0.164
#> GSM28791 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM28794 1 0.3942 0.6258 0.764 0.000 0.000 0.236
#> GSM28780 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM28795 1 0.0592 0.8537 0.984 0.000 0.000 0.016
#> GSM11301 4 0.4730 0.3688 0.000 0.364 0.000 0.636
#> GSM11297 1 0.7393 0.3672 0.436 0.400 0.000 0.164
#> GSM11298 1 0.0188 0.8545 0.996 0.000 0.000 0.004
#> GSM11314 1 0.4830 0.6217 0.608 0.000 0.000 0.392
#> GSM11299 2 0.7756 -0.0769 0.236 0.400 0.000 0.364
#> GSM28783 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM11308 1 0.7393 0.3672 0.436 0.400 0.000 0.164
#> GSM28782 1 0.0188 0.8545 0.996 0.000 0.000 0.004
#> GSM28779 1 0.0000 0.8544 1.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.8544 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM28789 1 0.3143 0.570 0.796 0.000 0.000 0.204 0.000
#> GSM28790 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM11300 5 0.0963 0.446 0.000 0.000 0.036 0.000 0.964
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28801 4 0.3109 0.842 0.000 0.200 0.000 0.800 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28784 4 0.2690 0.874 0.000 0.156 0.000 0.844 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.3586 0.638 0.736 0.000 0.000 0.000 0.264
#> GSM28792 1 0.3741 0.637 0.732 0.000 0.000 0.004 0.264
#> GSM11295 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000
#> GSM28793 1 0.3231 0.702 0.800 0.000 0.000 0.004 0.196
#> GSM11312 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM28778 1 0.4307 0.136 0.504 0.000 0.000 0.496 0.000
#> GSM28796 1 0.2813 0.725 0.832 0.000 0.000 0.000 0.168
#> GSM11309 1 0.2439 0.755 0.876 0.000 0.000 0.004 0.120
#> GSM11315 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM11306 1 0.0162 0.811 0.996 0.000 0.000 0.004 0.000
#> GSM28776 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM28777 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000
#> GSM11316 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000
#> GSM11320 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000
#> GSM28797 1 0.3741 0.637 0.732 0.000 0.000 0.004 0.264
#> GSM28786 1 0.3741 0.637 0.732 0.000 0.000 0.004 0.264
#> GSM28800 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM11310 1 0.3561 0.643 0.740 0.000 0.000 0.000 0.260
#> GSM28787 3 0.3966 0.645 0.000 0.000 0.664 0.000 0.336
#> GSM11304 5 0.3966 0.645 0.336 0.000 0.000 0.000 0.664
#> GSM11303 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000
#> GSM11317 3 0.0000 0.948 0.000 0.000 1.000 0.000 0.000
#> GSM11311 1 0.3741 0.637 0.732 0.000 0.000 0.004 0.264
#> GSM28799 1 0.3741 0.637 0.732 0.000 0.000 0.004 0.264
#> GSM28791 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM28794 4 0.2690 0.663 0.156 0.000 0.000 0.844 0.000
#> GSM28780 1 0.0162 0.811 0.996 0.000 0.000 0.004 0.000
#> GSM28795 1 0.0609 0.806 0.980 0.000 0.000 0.000 0.020
#> GSM11301 4 0.2690 0.874 0.000 0.156 0.000 0.844 0.000
#> GSM11297 5 0.3966 0.645 0.336 0.000 0.000 0.000 0.664
#> GSM11298 1 0.0162 0.811 0.996 0.000 0.000 0.004 0.000
#> GSM11314 1 0.6746 -0.157 0.392 0.000 0.000 0.344 0.264
#> GSM11299 5 0.0000 0.479 0.000 0.000 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM11308 5 0.3966 0.645 0.336 0.000 0.000 0.000 0.664
#> GSM28782 1 0.0162 0.811 0.996 0.000 0.000 0.004 0.000
#> GSM28779 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28789 1 0.2416 0.659 0.844 0.000 0.000 0.000 0.156 0.000
#> GSM28790 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11300 6 0.2697 -0.097 0.000 0.000 0.000 0.188 0.000 0.812
#> GSM28798 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 5 0.2793 0.730 0.000 0.200 0.000 0.000 0.800 0.000
#> GSM11319 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 5 0.0146 0.910 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM11307 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.3221 0.682 0.736 0.000 0.000 0.000 0.000 0.264
#> GSM28792 1 0.3360 0.680 0.732 0.000 0.000 0.000 0.004 0.264
#> GSM11295 3 0.3862 0.707 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM28793 1 0.2902 0.739 0.800 0.000 0.000 0.000 0.004 0.196
#> GSM11312 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28778 1 0.3838 0.251 0.552 0.000 0.000 0.000 0.448 0.000
#> GSM28796 1 0.2527 0.761 0.832 0.000 0.000 0.000 0.000 0.168
#> GSM11309 1 0.2191 0.788 0.876 0.000 0.000 0.000 0.004 0.120
#> GSM11315 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11306 1 0.0146 0.842 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM28776 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28777 3 0.3862 0.707 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM11316 3 0.3862 0.707 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM11320 3 0.3862 0.707 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM28797 1 0.3360 0.680 0.732 0.000 0.000 0.000 0.004 0.264
#> GSM28786 1 0.3360 0.680 0.732 0.000 0.000 0.000 0.004 0.264
#> GSM28800 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11310 1 0.3198 0.686 0.740 0.000 0.000 0.000 0.000 0.260
#> GSM28787 4 0.3563 0.000 0.000 0.000 0.000 0.664 0.000 0.336
#> GSM11304 6 0.3563 0.555 0.336 0.000 0.000 0.000 0.000 0.664
#> GSM11303 3 0.3862 0.707 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM11317 3 0.3862 0.707 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM11311 1 0.3360 0.680 0.732 0.000 0.000 0.000 0.004 0.264
#> GSM28799 1 0.3360 0.680 0.732 0.000 0.000 0.000 0.004 0.264
#> GSM28791 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM28794 5 0.0146 0.906 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM28780 1 0.0146 0.842 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM28795 1 0.0547 0.838 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM11301 5 0.0146 0.910 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM11297 6 0.3563 0.555 0.336 0.000 0.000 0.000 0.000 0.664
#> GSM11298 1 0.0146 0.842 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM11314 3 0.5771 -0.248 0.000 0.000 0.476 0.336 0.000 0.188
#> GSM11299 6 0.2697 -0.097 0.000 0.000 0.000 0.188 0.000 0.812
#> GSM28783 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11308 6 0.3563 0.555 0.336 0.000 0.000 0.000 0.000 0.664
#> GSM28782 1 0.0146 0.842 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM28779 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM11302 1 0.0000 0.843 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> ATC:pam 51 0.395 2
#> ATC:pam 51 0.371 3
#> ATC:pam 38 0.351 4
#> ATC:pam 48 0.328 5
#> ATC:pam 47 0.326 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.629 0.840 0.926 0.4187 0.618 0.618
#> 3 3 0.743 0.819 0.916 0.4252 0.750 0.601
#> 4 4 0.575 0.653 0.824 0.1702 0.880 0.721
#> 5 5 0.543 0.533 0.718 0.0548 0.860 0.649
#> 6 6 0.604 0.509 0.721 0.0479 0.864 0.598
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM28788 1 0.1633 0.889 0.976 0.024
#> GSM28789 1 0.5519 0.804 0.872 0.128
#> GSM28790 1 0.0000 0.900 1.000 0.000
#> GSM11300 1 0.8081 0.725 0.752 0.248
#> GSM28798 2 0.0000 0.952 0.000 1.000
#> GSM11296 2 0.0000 0.952 0.000 1.000
#> GSM28801 2 0.0000 0.952 0.000 1.000
#> GSM11319 2 0.0000 0.952 0.000 1.000
#> GSM28781 2 0.0000 0.952 0.000 1.000
#> GSM11305 2 0.0000 0.952 0.000 1.000
#> GSM28784 2 0.0000 0.952 0.000 1.000
#> GSM11307 2 0.0000 0.952 0.000 1.000
#> GSM11313 2 0.0000 0.952 0.000 1.000
#> GSM28785 2 0.0000 0.952 0.000 1.000
#> GSM11318 1 0.0000 0.900 1.000 0.000
#> GSM28792 1 0.0000 0.900 1.000 0.000
#> GSM11295 1 0.8207 0.717 0.744 0.256
#> GSM28793 1 0.0000 0.900 1.000 0.000
#> GSM11312 1 0.0000 0.900 1.000 0.000
#> GSM28778 1 0.9460 0.395 0.636 0.364
#> GSM28796 1 0.0000 0.900 1.000 0.000
#> GSM11309 1 0.0376 0.899 0.996 0.004
#> GSM11315 1 0.0000 0.900 1.000 0.000
#> GSM11306 1 0.2423 0.879 0.960 0.040
#> GSM28776 1 0.0000 0.900 1.000 0.000
#> GSM28777 1 0.8207 0.717 0.744 0.256
#> GSM11316 1 0.8207 0.717 0.744 0.256
#> GSM11320 1 0.8207 0.717 0.744 0.256
#> GSM28797 1 0.0000 0.900 1.000 0.000
#> GSM28786 1 0.5294 0.833 0.880 0.120
#> GSM28800 1 0.0000 0.900 1.000 0.000
#> GSM11310 1 0.0000 0.900 1.000 0.000
#> GSM28787 1 0.8144 0.721 0.748 0.252
#> GSM11304 1 0.0000 0.900 1.000 0.000
#> GSM11303 1 0.8207 0.717 0.744 0.256
#> GSM11317 1 0.8207 0.717 0.744 0.256
#> GSM11311 1 0.0000 0.900 1.000 0.000
#> GSM28799 1 0.0000 0.900 1.000 0.000
#> GSM28791 1 0.1633 0.889 0.976 0.024
#> GSM28794 2 0.1184 0.937 0.016 0.984
#> GSM28780 1 0.1633 0.889 0.976 0.024
#> GSM28795 1 0.9248 0.535 0.660 0.340
#> GSM11301 2 0.0000 0.952 0.000 1.000
#> GSM11297 1 0.0000 0.900 1.000 0.000
#> GSM11298 1 0.0000 0.900 1.000 0.000
#> GSM11314 2 0.9983 -0.135 0.476 0.524
#> GSM11299 1 0.8016 0.729 0.756 0.244
#> GSM28783 1 0.0000 0.900 1.000 0.000
#> GSM11308 1 0.0000 0.900 1.000 0.000
#> GSM28782 1 0.0672 0.897 0.992 0.008
#> GSM28779 1 0.0000 0.900 1.000 0.000
#> GSM11302 1 0.0000 0.900 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0424 0.961 0.992 0.000 0.008
#> GSM28789 1 0.4164 0.804 0.848 0.008 0.144
#> GSM28790 1 0.0424 0.961 0.992 0.000 0.008
#> GSM11300 3 0.6653 0.597 0.288 0.032 0.680
#> GSM28798 2 0.0000 0.827 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.827 0.000 1.000 0.000
#> GSM28801 2 0.6111 0.462 0.000 0.604 0.396
#> GSM11319 2 0.0000 0.827 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.827 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.827 0.000 1.000 0.000
#> GSM28784 2 0.6045 0.493 0.000 0.620 0.380
#> GSM11307 2 0.0000 0.827 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.827 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.827 0.000 1.000 0.000
#> GSM11318 1 0.0237 0.962 0.996 0.000 0.004
#> GSM28792 1 0.3752 0.807 0.856 0.000 0.144
#> GSM11295 3 0.0237 0.764 0.004 0.000 0.996
#> GSM28793 1 0.0237 0.962 0.996 0.000 0.004
#> GSM11312 1 0.0237 0.962 0.996 0.000 0.004
#> GSM28778 3 0.9228 0.319 0.416 0.152 0.432
#> GSM28796 1 0.0237 0.962 0.996 0.000 0.004
#> GSM11309 1 0.1411 0.950 0.964 0.000 0.036
#> GSM11315 1 0.0237 0.962 0.996 0.000 0.004
#> GSM11306 1 0.1878 0.934 0.952 0.004 0.044
#> GSM28776 1 0.0000 0.962 1.000 0.000 0.000
#> GSM28777 3 0.0237 0.764 0.004 0.000 0.996
#> GSM11316 3 0.0237 0.764 0.004 0.000 0.996
#> GSM11320 3 0.0237 0.764 0.004 0.000 0.996
#> GSM28797 1 0.1753 0.943 0.952 0.000 0.048
#> GSM28786 1 0.4750 0.700 0.784 0.000 0.216
#> GSM28800 1 0.0424 0.961 0.992 0.000 0.008
#> GSM11310 1 0.0237 0.962 0.996 0.000 0.004
#> GSM28787 3 0.0237 0.764 0.004 0.000 0.996
#> GSM11304 1 0.1031 0.956 0.976 0.000 0.024
#> GSM11303 3 0.0237 0.764 0.004 0.000 0.996
#> GSM11317 3 0.0237 0.764 0.004 0.000 0.996
#> GSM11311 1 0.0237 0.962 0.996 0.000 0.004
#> GSM28799 1 0.3192 0.855 0.888 0.000 0.112
#> GSM28791 1 0.0424 0.961 0.992 0.000 0.008
#> GSM28794 2 0.7112 0.369 0.024 0.552 0.424
#> GSM28780 1 0.0237 0.960 0.996 0.000 0.004
#> GSM28795 3 0.8037 0.503 0.352 0.076 0.572
#> GSM11301 2 0.6045 0.493 0.000 0.620 0.380
#> GSM11297 1 0.0892 0.958 0.980 0.000 0.020
#> GSM11298 1 0.0000 0.962 1.000 0.000 0.000
#> GSM11314 3 0.5931 0.628 0.084 0.124 0.792
#> GSM11299 3 0.6570 0.596 0.292 0.028 0.680
#> GSM28783 1 0.0424 0.962 0.992 0.000 0.008
#> GSM11308 1 0.0747 0.959 0.984 0.000 0.016
#> GSM28782 1 0.0892 0.958 0.980 0.000 0.020
#> GSM28779 1 0.0237 0.962 0.996 0.000 0.004
#> GSM11302 1 0.0237 0.960 0.996 0.000 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.4855 0.2958 0.600 0.000 0.000 0.400
#> GSM28789 4 0.4356 0.4754 0.292 0.000 0.000 0.708
#> GSM28790 1 0.1637 0.7346 0.940 0.000 0.000 0.060
#> GSM11300 1 0.7236 0.1932 0.552 0.008 0.300 0.140
#> GSM28798 2 0.0188 0.8732 0.000 0.996 0.000 0.004
#> GSM11296 2 0.0000 0.8743 0.000 1.000 0.000 0.000
#> GSM28801 2 0.5740 0.6212 0.000 0.700 0.208 0.092
#> GSM11319 2 0.0000 0.8743 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0188 0.8732 0.000 0.996 0.000 0.004
#> GSM11305 2 0.0000 0.8743 0.000 1.000 0.000 0.000
#> GSM28784 2 0.5910 0.6113 0.000 0.688 0.208 0.104
#> GSM11307 2 0.0000 0.8743 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.8743 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.8743 0.000 1.000 0.000 0.000
#> GSM11318 1 0.3172 0.6900 0.840 0.000 0.000 0.160
#> GSM28792 1 0.5936 0.3817 0.576 0.000 0.044 0.380
#> GSM11295 3 0.1211 0.9165 0.000 0.000 0.960 0.040
#> GSM28793 1 0.2704 0.7207 0.876 0.000 0.000 0.124
#> GSM11312 1 0.2216 0.7318 0.908 0.000 0.000 0.092
#> GSM28778 4 0.5750 0.6331 0.112 0.032 0.100 0.756
#> GSM28796 1 0.1716 0.7300 0.936 0.000 0.000 0.064
#> GSM11309 1 0.5168 -0.0581 0.500 0.000 0.004 0.496
#> GSM11315 1 0.2216 0.7314 0.908 0.000 0.000 0.092
#> GSM11306 4 0.4866 0.2340 0.404 0.000 0.000 0.596
#> GSM28776 1 0.3751 0.6601 0.800 0.000 0.004 0.196
#> GSM28777 3 0.0000 0.9345 0.000 0.000 1.000 0.000
#> GSM11316 3 0.0000 0.9345 0.000 0.000 1.000 0.000
#> GSM11320 3 0.0000 0.9345 0.000 0.000 1.000 0.000
#> GSM28797 1 0.3908 0.6461 0.784 0.000 0.004 0.212
#> GSM28786 1 0.6516 0.3222 0.576 0.000 0.092 0.332
#> GSM28800 1 0.4134 0.5929 0.740 0.000 0.000 0.260
#> GSM11310 1 0.1557 0.7358 0.944 0.000 0.000 0.056
#> GSM28787 3 0.2281 0.8759 0.000 0.000 0.904 0.096
#> GSM11304 1 0.2730 0.7249 0.896 0.000 0.016 0.088
#> GSM11303 3 0.0188 0.9317 0.004 0.000 0.996 0.000
#> GSM11317 3 0.0000 0.9345 0.000 0.000 1.000 0.000
#> GSM11311 1 0.2760 0.6923 0.872 0.000 0.000 0.128
#> GSM28799 1 0.5855 0.4169 0.600 0.000 0.044 0.356
#> GSM28791 1 0.3801 0.6381 0.780 0.000 0.000 0.220
#> GSM28794 4 0.6929 0.3721 0.032 0.108 0.212 0.648
#> GSM28780 1 0.4761 0.3759 0.628 0.000 0.000 0.372
#> GSM28795 4 0.7605 0.4663 0.164 0.020 0.264 0.552
#> GSM11301 2 0.7531 0.2861 0.000 0.476 0.208 0.316
#> GSM11297 1 0.0921 0.7329 0.972 0.000 0.000 0.028
#> GSM11298 1 0.0707 0.7353 0.980 0.000 0.000 0.020
#> GSM11314 3 0.5565 0.6664 0.008 0.044 0.700 0.248
#> GSM11299 1 0.7199 0.2079 0.560 0.008 0.292 0.140
#> GSM28783 1 0.3649 0.6830 0.796 0.000 0.000 0.204
#> GSM11308 1 0.0817 0.7321 0.976 0.000 0.000 0.024
#> GSM28782 1 0.3610 0.6519 0.800 0.000 0.000 0.200
#> GSM28779 1 0.1557 0.7290 0.944 0.000 0.000 0.056
#> GSM11302 1 0.2281 0.7286 0.904 0.000 0.000 0.096
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 1 0.3630 0.5429 0.780 0.000 0.000 0.204 0.016
#> GSM28789 1 0.5467 0.2698 0.524 0.000 0.000 0.412 0.064
#> GSM28790 1 0.2685 0.6180 0.880 0.000 0.000 0.092 0.028
#> GSM11300 4 0.7665 0.1636 0.160 0.000 0.344 0.412 0.084
#> GSM28798 2 0.0703 0.8986 0.000 0.976 0.000 0.000 0.024
#> GSM11296 2 0.0000 0.9071 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.6727 -0.2438 0.000 0.436 0.188 0.008 0.368
#> GSM11319 2 0.0510 0.9026 0.000 0.984 0.000 0.000 0.016
#> GSM28781 2 0.0703 0.8986 0.000 0.976 0.000 0.000 0.024
#> GSM11305 2 0.0000 0.9071 0.000 1.000 0.000 0.000 0.000
#> GSM28784 5 0.6700 0.2403 0.000 0.348 0.188 0.008 0.456
#> GSM11307 2 0.0000 0.9071 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9071 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9071 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.4901 0.5396 0.708 0.000 0.000 0.096 0.196
#> GSM28792 1 0.6494 0.2390 0.492 0.000 0.000 0.252 0.256
#> GSM11295 3 0.0510 0.9443 0.000 0.000 0.984 0.000 0.016
#> GSM28793 1 0.2616 0.6077 0.880 0.000 0.000 0.100 0.020
#> GSM11312 1 0.4430 0.5945 0.752 0.000 0.000 0.076 0.172
#> GSM28778 5 0.7875 -0.1291 0.264 0.000 0.076 0.268 0.392
#> GSM28796 1 0.2233 0.6139 0.904 0.000 0.000 0.080 0.016
#> GSM11309 4 0.4966 -0.1095 0.404 0.000 0.000 0.564 0.032
#> GSM11315 1 0.3011 0.5990 0.844 0.000 0.000 0.140 0.016
#> GSM11306 1 0.4730 0.4589 0.688 0.000 0.000 0.260 0.052
#> GSM28776 1 0.4725 0.5561 0.720 0.000 0.000 0.080 0.200
#> GSM28777 3 0.0162 0.9518 0.000 0.000 0.996 0.000 0.004
#> GSM11316 3 0.0162 0.9512 0.000 0.000 0.996 0.004 0.000
#> GSM11320 3 0.0000 0.9519 0.000 0.000 1.000 0.000 0.000
#> GSM28797 1 0.4705 0.1547 0.504 0.000 0.004 0.484 0.008
#> GSM28786 4 0.6215 -0.0303 0.428 0.000 0.008 0.456 0.108
#> GSM28800 1 0.5886 0.4116 0.600 0.000 0.000 0.224 0.176
#> GSM11310 1 0.2769 0.6074 0.876 0.000 0.000 0.092 0.032
#> GSM28787 3 0.3730 0.7457 0.004 0.000 0.800 0.028 0.168
#> GSM11304 1 0.4734 0.3196 0.604 0.000 0.000 0.372 0.024
#> GSM11303 3 0.0703 0.9373 0.000 0.000 0.976 0.024 0.000
#> GSM11317 3 0.0000 0.9519 0.000 0.000 1.000 0.000 0.000
#> GSM11311 1 0.4252 0.3614 0.652 0.000 0.000 0.340 0.008
#> GSM28799 1 0.6420 0.2649 0.508 0.000 0.000 0.260 0.232
#> GSM28791 1 0.2629 0.5951 0.860 0.000 0.000 0.136 0.004
#> GSM28794 5 0.6956 0.4457 0.092 0.012 0.188 0.100 0.608
#> GSM28780 1 0.4309 0.5140 0.676 0.000 0.000 0.308 0.016
#> GSM28795 5 0.7990 0.1318 0.172 0.000 0.152 0.228 0.448
#> GSM11301 5 0.7050 0.3872 0.004 0.272 0.188 0.028 0.508
#> GSM11297 1 0.4770 0.3861 0.644 0.000 0.000 0.320 0.036
#> GSM11298 1 0.1018 0.6234 0.968 0.000 0.000 0.016 0.016
#> GSM11314 5 0.6251 0.3625 0.016 0.004 0.216 0.152 0.612
#> GSM11299 4 0.7852 0.3314 0.236 0.000 0.248 0.428 0.088
#> GSM28783 1 0.4521 0.5849 0.748 0.000 0.000 0.088 0.164
#> GSM11308 1 0.4498 0.4372 0.688 0.000 0.000 0.280 0.032
#> GSM28782 1 0.4238 0.4169 0.628 0.000 0.000 0.368 0.004
#> GSM28779 1 0.3772 0.5883 0.792 0.000 0.000 0.036 0.172
#> GSM11302 1 0.2011 0.6177 0.908 0.000 0.000 0.088 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 1 0.3532 0.5359 0.796 0.000 0.000 0.140 0.000 0.064
#> GSM28789 1 0.5501 0.3925 0.564 0.000 0.000 0.200 0.000 0.236
#> GSM28790 1 0.0820 0.6152 0.972 0.000 0.000 0.016 0.000 0.012
#> GSM11300 6 0.7586 -0.0634 0.020 0.000 0.160 0.240 0.148 0.432
#> GSM28798 2 0.0820 0.9757 0.000 0.972 0.000 0.000 0.012 0.016
#> GSM11296 2 0.0000 0.9867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 6 0.6137 0.3819 0.000 0.248 0.000 0.004 0.336 0.412
#> GSM11319 2 0.0717 0.9781 0.000 0.976 0.000 0.000 0.008 0.016
#> GSM28781 2 0.0820 0.9757 0.000 0.972 0.000 0.000 0.012 0.016
#> GSM11305 2 0.0000 0.9867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 6 0.6110 0.3863 0.000 0.236 0.000 0.004 0.344 0.416
#> GSM11307 2 0.0000 0.9867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.9867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.9867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 4 0.4413 0.1647 0.484 0.000 0.000 0.496 0.012 0.008
#> GSM28792 4 0.2482 0.4335 0.148 0.000 0.000 0.848 0.004 0.000
#> GSM11295 3 0.2191 0.7952 0.000 0.000 0.876 0.000 0.120 0.004
#> GSM28793 1 0.1856 0.6094 0.920 0.000 0.000 0.048 0.000 0.032
#> GSM11312 1 0.4124 0.1991 0.644 0.000 0.000 0.332 0.000 0.024
#> GSM28778 4 0.6970 0.0248 0.256 0.000 0.000 0.372 0.312 0.060
#> GSM28796 1 0.2376 0.6086 0.888 0.000 0.000 0.068 0.000 0.044
#> GSM11309 1 0.6676 0.2535 0.468 0.000 0.000 0.208 0.056 0.268
#> GSM11315 1 0.2563 0.6118 0.876 0.000 0.000 0.052 0.000 0.072
#> GSM11306 1 0.4251 0.4651 0.716 0.000 0.000 0.208 0.000 0.076
#> GSM28776 4 0.4096 0.1583 0.484 0.000 0.000 0.508 0.000 0.008
#> GSM28777 3 0.0000 0.9630 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11316 3 0.0000 0.9630 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11320 3 0.0000 0.9630 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM28797 1 0.5368 0.4069 0.532 0.000 0.000 0.092 0.008 0.368
#> GSM28786 4 0.6271 0.1441 0.148 0.000 0.000 0.524 0.048 0.280
#> GSM28800 1 0.4177 -0.0895 0.520 0.000 0.000 0.468 0.000 0.012
#> GSM11310 1 0.3301 0.4752 0.788 0.000 0.000 0.188 0.000 0.024
#> GSM28787 5 0.5101 0.0782 0.004 0.000 0.436 0.036 0.508 0.016
#> GSM11304 1 0.4988 0.4123 0.552 0.000 0.000 0.064 0.004 0.380
#> GSM11303 3 0.0146 0.9599 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM11317 3 0.0000 0.9630 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM11311 1 0.4340 0.4966 0.712 0.000 0.000 0.200 0.000 0.088
#> GSM28799 4 0.2920 0.4521 0.168 0.000 0.000 0.820 0.004 0.008
#> GSM28791 1 0.1049 0.6119 0.960 0.000 0.000 0.008 0.000 0.032
#> GSM28794 6 0.6051 0.0689 0.004 0.000 0.000 0.212 0.372 0.412
#> GSM28780 1 0.3727 0.5799 0.748 0.000 0.000 0.036 0.000 0.216
#> GSM28795 5 0.6504 0.1433 0.164 0.000 0.000 0.260 0.512 0.064
#> GSM11301 6 0.6404 0.3817 0.000 0.228 0.000 0.020 0.340 0.412
#> GSM11297 1 0.4789 0.4819 0.640 0.000 0.000 0.092 0.000 0.268
#> GSM11298 1 0.0972 0.6149 0.964 0.000 0.000 0.028 0.000 0.008
#> GSM11314 5 0.0508 0.1542 0.000 0.000 0.000 0.004 0.984 0.012
#> GSM11299 6 0.7715 -0.0370 0.096 0.000 0.052 0.272 0.152 0.428
#> GSM28783 4 0.4705 0.0482 0.472 0.000 0.000 0.484 0.000 0.044
#> GSM11308 1 0.4972 0.4594 0.628 0.000 0.000 0.116 0.000 0.256
#> GSM28782 1 0.3518 0.5667 0.732 0.000 0.000 0.012 0.000 0.256
#> GSM28779 1 0.3874 0.1507 0.636 0.000 0.000 0.356 0.000 0.008
#> GSM11302 1 0.1265 0.6164 0.948 0.000 0.000 0.008 0.000 0.044
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> ATC:mclust 50 0.394 2
#> ATC:mclust 47 0.366 3
#> ATC:mclust 39 0.405 4
#> ATC:mclust 30 0.403 5
#> ATC:mclust 24 0.392 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 21288 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.919 0.924 0.968 0.4409 0.566 0.566
#> 3 3 1.000 0.947 0.982 0.3644 0.681 0.502
#> 4 4 0.713 0.763 0.876 0.1524 0.905 0.767
#> 5 5 0.687 0.587 0.784 0.1124 0.876 0.640
#> 6 6 0.721 0.644 0.794 0.0456 0.931 0.736
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
#> GSM28788 1 0.4161 0.893 0.916 0.084
#> GSM28789 2 0.0938 0.955 0.012 0.988
#> GSM28790 2 0.6623 0.779 0.172 0.828
#> GSM11300 1 0.0000 0.965 1.000 0.000
#> GSM28798 2 0.0000 0.964 0.000 1.000
#> GSM11296 2 0.0000 0.964 0.000 1.000
#> GSM28801 2 0.0000 0.964 0.000 1.000
#> GSM11319 2 0.0000 0.964 0.000 1.000
#> GSM28781 2 0.0000 0.964 0.000 1.000
#> GSM11305 2 0.0000 0.964 0.000 1.000
#> GSM28784 2 0.0000 0.964 0.000 1.000
#> GSM11307 2 0.0000 0.964 0.000 1.000
#> GSM11313 2 0.0000 0.964 0.000 1.000
#> GSM28785 2 0.0000 0.964 0.000 1.000
#> GSM11318 1 0.0000 0.965 1.000 0.000
#> GSM28792 1 0.0000 0.965 1.000 0.000
#> GSM11295 1 0.0000 0.965 1.000 0.000
#> GSM28793 1 0.0000 0.965 1.000 0.000
#> GSM11312 1 0.8081 0.675 0.752 0.248
#> GSM28778 2 0.0000 0.964 0.000 1.000
#> GSM28796 1 0.0000 0.965 1.000 0.000
#> GSM11309 1 0.0000 0.965 1.000 0.000
#> GSM11315 1 0.8955 0.558 0.688 0.312
#> GSM11306 2 0.9044 0.511 0.320 0.680
#> GSM28776 1 0.0000 0.965 1.000 0.000
#> GSM28777 1 0.0000 0.965 1.000 0.000
#> GSM11316 1 0.0000 0.965 1.000 0.000
#> GSM11320 1 0.0000 0.965 1.000 0.000
#> GSM28797 1 0.0000 0.965 1.000 0.000
#> GSM28786 1 0.0000 0.965 1.000 0.000
#> GSM28800 1 0.3274 0.917 0.940 0.060
#> GSM11310 1 0.0000 0.965 1.000 0.000
#> GSM28787 1 0.0000 0.965 1.000 0.000
#> GSM11304 1 0.0000 0.965 1.000 0.000
#> GSM11303 1 0.0000 0.965 1.000 0.000
#> GSM11317 1 0.0000 0.965 1.000 0.000
#> GSM11311 1 0.0000 0.965 1.000 0.000
#> GSM28799 1 0.0000 0.965 1.000 0.000
#> GSM28791 1 0.9710 0.345 0.600 0.400
#> GSM28794 2 0.0000 0.964 0.000 1.000
#> GSM28780 1 0.1843 0.945 0.972 0.028
#> GSM28795 1 0.0000 0.965 1.000 0.000
#> GSM11301 2 0.0000 0.964 0.000 1.000
#> GSM11297 1 0.0000 0.965 1.000 0.000
#> GSM11298 1 0.0000 0.965 1.000 0.000
#> GSM11314 1 0.1184 0.955 0.984 0.016
#> GSM11299 1 0.0000 0.965 1.000 0.000
#> GSM28783 1 0.0000 0.965 1.000 0.000
#> GSM11308 1 0.0000 0.965 1.000 0.000
#> GSM28782 1 0.0672 0.960 0.992 0.008
#> GSM28779 1 0.1184 0.955 0.984 0.016
#> GSM11302 1 0.0376 0.962 0.996 0.004
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM28788 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28789 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28790 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11300 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM28798 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11296 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM28801 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11319 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM28781 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11305 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM28784 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11307 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11313 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM28785 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11318 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28792 1 0.1031 0.9601 0.976 0.000 0.024
#> GSM11295 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM28793 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11312 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28778 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28796 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11309 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11315 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11306 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28776 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28777 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM11316 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM11320 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM28797 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28786 1 0.6111 0.2995 0.604 0.000 0.396
#> GSM28800 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11310 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28787 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM11304 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11303 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM11317 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM11311 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28799 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28791 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28794 2 0.0747 0.9783 0.016 0.984 0.000
#> GSM28780 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28795 3 0.6291 0.0989 0.468 0.000 0.532
#> GSM11301 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM11297 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11298 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11314 3 0.1031 0.9153 0.000 0.024 0.976
#> GSM11299 3 0.0000 0.9358 0.000 0.000 1.000
#> GSM28783 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11308 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28782 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM28779 1 0.0000 0.9841 1.000 0.000 0.000
#> GSM11302 1 0.0000 0.9841 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM28788 1 0.4730 0.2228 0.636 0.000 0.000 0.364
#> GSM28789 1 0.3837 0.6576 0.776 0.000 0.000 0.224
#> GSM28790 1 0.0336 0.7958 0.992 0.000 0.000 0.008
#> GSM11300 3 0.2281 0.8395 0.000 0.000 0.904 0.096
#> GSM28798 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11296 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM28801 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11319 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM28781 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11305 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM28784 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11307 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11313 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM28785 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11318 1 0.1792 0.7758 0.932 0.000 0.000 0.068
#> GSM28792 1 0.4100 0.6601 0.816 0.000 0.036 0.148
#> GSM11295 3 0.0707 0.8654 0.000 0.000 0.980 0.020
#> GSM28793 1 0.1474 0.7869 0.948 0.000 0.000 0.052
#> GSM11312 1 0.4250 0.4119 0.724 0.000 0.000 0.276
#> GSM28778 4 0.4770 0.6460 0.288 0.012 0.000 0.700
#> GSM28796 1 0.2345 0.7603 0.900 0.000 0.000 0.100
#> GSM11309 1 0.3074 0.7601 0.848 0.000 0.000 0.152
#> GSM11315 1 0.2081 0.7719 0.916 0.000 0.000 0.084
#> GSM11306 4 0.4992 0.3834 0.476 0.000 0.000 0.524
#> GSM28776 1 0.2868 0.7217 0.864 0.000 0.000 0.136
#> GSM28777 3 0.0592 0.8639 0.000 0.000 0.984 0.016
#> GSM11316 3 0.0469 0.8647 0.000 0.000 0.988 0.012
#> GSM11320 3 0.0469 0.8649 0.000 0.000 0.988 0.012
#> GSM28797 1 0.4252 0.6063 0.744 0.000 0.004 0.252
#> GSM28786 3 0.7321 -0.0404 0.328 0.000 0.500 0.172
#> GSM28800 1 0.2921 0.7184 0.860 0.000 0.000 0.140
#> GSM11310 1 0.1474 0.7850 0.948 0.000 0.000 0.052
#> GSM28787 3 0.2589 0.8220 0.000 0.000 0.884 0.116
#> GSM11304 1 0.4655 0.6193 0.760 0.000 0.032 0.208
#> GSM11303 3 0.1716 0.8548 0.000 0.000 0.936 0.064
#> GSM11317 3 0.0336 0.8651 0.000 0.000 0.992 0.008
#> GSM11311 1 0.2216 0.7808 0.908 0.000 0.000 0.092
#> GSM28799 1 0.3569 0.6504 0.804 0.000 0.000 0.196
#> GSM28791 1 0.2011 0.7912 0.920 0.000 0.000 0.080
#> GSM28794 2 0.1174 0.9599 0.020 0.968 0.000 0.012
#> GSM28780 1 0.2868 0.7686 0.864 0.000 0.000 0.136
#> GSM28795 4 0.5763 0.4679 0.156 0.000 0.132 0.712
#> GSM11301 2 0.0000 0.9965 0.000 1.000 0.000 0.000
#> GSM11297 1 0.2921 0.7609 0.860 0.000 0.000 0.140
#> GSM11298 1 0.0817 0.7922 0.976 0.000 0.000 0.024
#> GSM11314 3 0.5143 0.4593 0.000 0.004 0.540 0.456
#> GSM11299 3 0.2593 0.8361 0.004 0.000 0.892 0.104
#> GSM28783 4 0.4994 0.4948 0.480 0.000 0.000 0.520
#> GSM11308 1 0.3074 0.7548 0.848 0.000 0.000 0.152
#> GSM28782 1 0.2921 0.7631 0.860 0.000 0.000 0.140
#> GSM28779 1 0.2469 0.7454 0.892 0.000 0.000 0.108
#> GSM11302 1 0.0817 0.7939 0.976 0.000 0.000 0.024
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM28788 4 0.4395 0.50707 0.188 0.000 0.000 0.748 0.064
#> GSM28789 4 0.3480 0.47476 0.248 0.000 0.000 0.752 0.000
#> GSM28790 1 0.2136 0.63586 0.904 0.000 0.000 0.088 0.008
#> GSM11300 3 0.3117 0.83217 0.004 0.000 0.860 0.036 0.100
#> GSM28798 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM11319 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM28781 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM28784 2 0.0451 0.98420 0.008 0.988 0.000 0.000 0.004
#> GSM11307 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM11318 1 0.2992 0.61438 0.868 0.000 0.000 0.064 0.068
#> GSM28792 1 0.5112 0.49197 0.692 0.000 0.012 0.064 0.232
#> GSM11295 3 0.1894 0.87185 0.000 0.000 0.920 0.008 0.072
#> GSM28793 1 0.2408 0.63045 0.892 0.000 0.000 0.092 0.016
#> GSM11312 1 0.6553 -0.00202 0.432 0.000 0.000 0.364 0.204
#> GSM28778 4 0.5775 -0.45964 0.088 0.000 0.000 0.472 0.440
#> GSM28796 1 0.1282 0.64302 0.952 0.000 0.000 0.004 0.044
#> GSM11309 4 0.3884 0.43631 0.288 0.000 0.000 0.708 0.004
#> GSM11315 1 0.1364 0.64214 0.952 0.000 0.000 0.012 0.036
#> GSM11306 4 0.4291 0.31082 0.092 0.000 0.000 0.772 0.136
#> GSM28776 1 0.4433 0.53177 0.740 0.000 0.000 0.200 0.060
#> GSM28777 3 0.1557 0.87112 0.000 0.000 0.940 0.008 0.052
#> GSM11316 3 0.1331 0.87390 0.000 0.000 0.952 0.008 0.040
#> GSM11320 3 0.1697 0.87440 0.000 0.000 0.932 0.008 0.060
#> GSM28797 4 0.4535 0.51308 0.184 0.000 0.020 0.756 0.040
#> GSM28786 4 0.7310 0.22561 0.088 0.000 0.184 0.536 0.192
#> GSM28800 1 0.4686 0.53151 0.736 0.000 0.000 0.160 0.104
#> GSM11310 1 0.3039 0.62296 0.836 0.000 0.000 0.152 0.012
#> GSM28787 3 0.2077 0.84571 0.000 0.000 0.908 0.008 0.084
#> GSM11304 1 0.5383 0.44040 0.688 0.000 0.028 0.220 0.064
#> GSM11303 3 0.3081 0.81515 0.000 0.000 0.832 0.012 0.156
#> GSM11317 3 0.1484 0.87785 0.000 0.000 0.944 0.008 0.048
#> GSM11311 1 0.4702 0.06723 0.552 0.000 0.000 0.432 0.016
#> GSM28799 1 0.5379 0.45688 0.668 0.000 0.000 0.164 0.168
#> GSM28791 1 0.3932 0.36589 0.672 0.000 0.000 0.328 0.000
#> GSM28794 2 0.1082 0.95523 0.028 0.964 0.000 0.000 0.008
#> GSM28780 4 0.4818 0.08993 0.460 0.000 0.000 0.520 0.020
#> GSM28795 5 0.5988 0.24048 0.036 0.000 0.044 0.400 0.520
#> GSM11301 2 0.0000 0.99473 0.000 1.000 0.000 0.000 0.000
#> GSM11297 1 0.4916 0.26836 0.628 0.000 0.016 0.340 0.016
#> GSM11298 1 0.1671 0.64243 0.924 0.000 0.000 0.076 0.000
#> GSM11314 5 0.4474 0.16980 0.004 0.000 0.332 0.012 0.652
#> GSM11299 3 0.4089 0.77343 0.024 0.000 0.808 0.044 0.124
#> GSM28783 4 0.6232 -0.37580 0.128 0.000 0.004 0.488 0.380
#> GSM11308 1 0.4964 0.03124 0.548 0.000 0.012 0.428 0.012
#> GSM28782 4 0.4656 0.04860 0.480 0.000 0.000 0.508 0.012
#> GSM28779 1 0.3521 0.59330 0.820 0.000 0.000 0.140 0.040
#> GSM11302 1 0.2970 0.61569 0.828 0.000 0.000 0.168 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM28788 4 0.4253 0.400 0.064 0.000 0.000 0.704 0.232 0.000
#> GSM28789 4 0.2554 0.618 0.076 0.000 0.000 0.876 0.048 0.000
#> GSM28790 1 0.3091 0.653 0.824 0.000 0.000 0.148 0.004 0.024
#> GSM11300 3 0.4391 0.618 0.008 0.000 0.716 0.052 0.004 0.220
#> GSM28798 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11296 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28801 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11319 2 0.0146 0.991 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM28781 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11305 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28784 2 0.1167 0.965 0.008 0.960 0.000 0.000 0.020 0.012
#> GSM11307 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11313 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM28785 2 0.0000 0.993 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM11318 1 0.3361 0.665 0.844 0.000 0.000 0.064 0.044 0.048
#> GSM28792 1 0.6222 0.381 0.528 0.000 0.004 0.080 0.072 0.316
#> GSM11295 3 0.1578 0.732 0.000 0.000 0.936 0.004 0.012 0.048
#> GSM28793 1 0.2809 0.664 0.848 0.000 0.000 0.128 0.004 0.020
#> GSM11312 1 0.6683 0.172 0.420 0.000 0.000 0.128 0.372 0.080
#> GSM28778 5 0.2922 0.840 0.056 0.000 0.000 0.068 0.864 0.012
#> GSM28796 1 0.1426 0.679 0.948 0.000 0.000 0.016 0.008 0.028
#> GSM11309 4 0.2239 0.628 0.072 0.000 0.000 0.900 0.020 0.008
#> GSM11315 1 0.1426 0.678 0.948 0.000 0.000 0.016 0.008 0.028
#> GSM11306 4 0.4484 0.241 0.028 0.000 0.000 0.640 0.320 0.012
#> GSM28776 1 0.5074 0.562 0.680 0.000 0.000 0.044 0.208 0.068
#> GSM28777 3 0.2882 0.705 0.000 0.000 0.812 0.000 0.008 0.180
#> GSM11316 3 0.2520 0.718 0.000 0.000 0.844 0.000 0.004 0.152
#> GSM11320 3 0.1464 0.725 0.000 0.000 0.944 0.004 0.016 0.036
#> GSM28797 4 0.3722 0.583 0.040 0.000 0.024 0.836 0.044 0.056
#> GSM28786 4 0.5735 0.386 0.040 0.000 0.124 0.648 0.012 0.176
#> GSM28800 1 0.4208 0.619 0.740 0.000 0.000 0.036 0.200 0.024
#> GSM11310 1 0.5695 0.407 0.584 0.000 0.000 0.288 0.048 0.080
#> GSM28787 3 0.3819 0.618 0.000 0.000 0.764 0.000 0.064 0.172
#> GSM11304 1 0.6063 0.167 0.528 0.000 0.028 0.324 0.008 0.112
#> GSM11303 3 0.3424 0.570 0.000 0.000 0.780 0.004 0.020 0.196
#> GSM11317 3 0.0603 0.738 0.000 0.000 0.980 0.004 0.000 0.016
#> GSM11311 4 0.4452 0.477 0.316 0.000 0.000 0.636 0.000 0.048
#> GSM28799 1 0.5399 0.565 0.680 0.000 0.000 0.144 0.076 0.100
#> GSM28791 1 0.5367 0.111 0.524 0.000 0.000 0.388 0.016 0.072
#> GSM28794 2 0.0837 0.971 0.020 0.972 0.000 0.000 0.004 0.004
#> GSM28780 4 0.5178 0.527 0.236 0.000 0.000 0.652 0.028 0.084
#> GSM28795 5 0.2469 0.799 0.012 0.000 0.028 0.036 0.904 0.020
#> GSM11301 2 0.0146 0.991 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM11297 4 0.5128 0.300 0.412 0.000 0.000 0.504 0.000 0.084
#> GSM11298 1 0.3346 0.630 0.816 0.000 0.000 0.140 0.008 0.036
#> GSM11314 6 0.5976 0.000 0.008 0.000 0.212 0.008 0.224 0.548
#> GSM11299 3 0.5215 0.396 0.032 0.000 0.600 0.052 0.000 0.316
#> GSM28783 5 0.3995 0.801 0.056 0.000 0.000 0.104 0.796 0.044
#> GSM11308 4 0.5386 0.422 0.336 0.000 0.012 0.568 0.004 0.080
#> GSM28782 4 0.4742 0.544 0.240 0.000 0.000 0.676 0.012 0.072
#> GSM28779 1 0.3804 0.651 0.772 0.000 0.000 0.044 0.176 0.008
#> GSM11302 1 0.3736 0.653 0.788 0.000 0.000 0.160 0.032 0.020
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 tissue(p) k
#> ATC:NMF 51 0.395 2
#> ATC:NMF 50 0.370 3
#> ATC:NMF 45 0.341 4
#> ATC:NMF 34 0.398 5
#> ATC:NMF 39 0.431 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