Date: 2019-12-25 20:17:16 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 35373 rows and 53 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] 35373 53
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:skmeans | 3 | 1.000 | 0.965 | 0.984 | ** | 2 |
ATC:pam | 2 | 1.000 | 0.992 | 0.996 | ** | |
ATC:skmeans | 3 | 0.999 | 0.958 | 0.982 | ** | 2 |
CV:skmeans | 3 | 0.971 | 0.933 | 0.974 | ** | 2 |
MAD:skmeans | 3 | 0.971 | 0.933 | 0.973 | ** | 2 |
MAD:pam | 3 | 0.962 | 0.924 | 0.952 | ** | 2 |
CV:NMF | 2 | 0.958 | 0.941 | 0.975 | ** | |
CV:pam | 3 | 0.938 | 0.902 | 0.962 | * | 2 |
SD:NMF | 2 | 0.920 | 0.908 | 0.965 | * | |
ATC:NMF | 2 | 0.919 | 0.912 | 0.963 | * | |
SD:pam | 4 | 0.910 | 0.916 | 0.951 | * | 2,3 |
MAD:NMF | 2 | 0.882 | 0.898 | 0.962 | ||
ATC:kmeans | 4 | 0.857 | 0.908 | 0.936 | ||
ATC:mclust | 5 | 0.850 | 0.723 | 0.887 | ||
MAD:kmeans | 2 | 0.850 | 0.951 | 0.975 | ||
SD:kmeans | 2 | 0.847 | 0.909 | 0.958 | ||
MAD:hclust | 2 | 0.827 | 0.893 | 0.949 | ||
CV:mclust | 6 | 0.826 | 0.843 | 0.908 | ||
MAD:mclust | 5 | 0.782 | 0.856 | 0.900 | ||
SD:hclust | 2 | 0.771 | 0.908 | 0.953 | ||
CV:kmeans | 3 | 0.757 | 0.859 | 0.926 | ||
ATC:hclust | 3 | 0.652 | 0.860 | 0.925 | ||
SD:mclust | 3 | 0.425 | 0.643 | 0.815 | ||
CV:hclust | 2 | 0.389 | 0.876 | 0.904 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 0.920 0.908 0.965 0.507 0.492 0.492
#> CV:NMF 2 0.958 0.941 0.975 0.503 0.495 0.495
#> MAD:NMF 2 0.882 0.898 0.962 0.507 0.491 0.491
#> ATC:NMF 2 0.919 0.912 0.963 0.506 0.492 0.492
#> SD:skmeans 2 0.960 0.965 0.984 0.509 0.492 0.492
#> CV:skmeans 2 0.960 0.971 0.987 0.510 0.491 0.491
#> MAD:skmeans 2 1.000 0.996 0.998 0.509 0.492 0.492
#> ATC:skmeans 2 0.922 0.956 0.980 0.509 0.491 0.491
#> SD:mclust 2 0.184 0.694 0.798 0.310 0.826 0.826
#> CV:mclust 2 0.470 0.777 0.835 0.375 0.505 0.505
#> MAD:mclust 2 0.217 0.542 0.783 0.417 0.570 0.570
#> ATC:mclust 2 0.330 0.584 0.731 0.337 0.826 0.826
#> SD:kmeans 2 0.847 0.909 0.958 0.505 0.492 0.492
#> CV:kmeans 2 0.504 0.837 0.911 0.490 0.491 0.491
#> MAD:kmeans 2 0.850 0.951 0.975 0.506 0.492 0.492
#> ATC:kmeans 2 0.742 0.796 0.924 0.491 0.499 0.499
#> SD:pam 2 0.960 0.960 0.982 0.494 0.512 0.512
#> CV:pam 2 0.920 0.913 0.965 0.508 0.491 0.491
#> MAD:pam 2 1.000 0.952 0.979 0.495 0.505 0.505
#> ATC:pam 2 1.000 0.992 0.996 0.509 0.492 0.492
#> SD:hclust 2 0.771 0.908 0.953 0.496 0.492 0.492
#> CV:hclust 2 0.389 0.876 0.904 0.463 0.495 0.495
#> MAD:hclust 2 0.827 0.893 0.949 0.495 0.495 0.495
#> ATC:hclust 2 0.376 0.701 0.752 0.397 0.495 0.495
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.802 0.852 0.937 0.318 0.730 0.503
#> CV:NMF 3 0.871 0.874 0.949 0.337 0.681 0.441
#> MAD:NMF 3 0.789 0.869 0.945 0.314 0.738 0.515
#> ATC:NMF 3 0.887 0.886 0.952 0.314 0.734 0.513
#> SD:skmeans 3 1.000 0.965 0.984 0.314 0.745 0.527
#> CV:skmeans 3 0.971 0.933 0.974 0.319 0.763 0.553
#> MAD:skmeans 3 0.971 0.933 0.973 0.311 0.745 0.527
#> ATC:skmeans 3 0.999 0.958 0.982 0.306 0.761 0.549
#> SD:mclust 3 0.425 0.643 0.815 0.746 0.589 0.502
#> CV:mclust 3 0.520 0.873 0.902 0.261 0.534 0.382
#> MAD:mclust 3 0.458 0.547 0.764 0.343 0.660 0.482
#> ATC:mclust 3 0.311 0.845 0.859 0.449 0.705 0.642
#> SD:kmeans 3 0.579 0.718 0.823 0.297 0.810 0.633
#> CV:kmeans 3 0.757 0.859 0.926 0.332 0.739 0.517
#> MAD:kmeans 3 0.596 0.692 0.817 0.291 0.792 0.602
#> ATC:kmeans 3 0.665 0.784 0.899 0.284 0.636 0.405
#> SD:pam 3 0.994 0.953 0.978 0.220 0.814 0.662
#> CV:pam 3 0.938 0.902 0.962 0.196 0.871 0.744
#> MAD:pam 3 0.962 0.924 0.952 0.228 0.835 0.689
#> ATC:pam 3 0.898 0.943 0.975 0.157 0.927 0.853
#> SD:hclust 3 0.717 0.860 0.923 0.296 0.864 0.724
#> CV:hclust 3 0.462 0.785 0.882 0.320 0.878 0.754
#> MAD:hclust 3 0.748 0.820 0.913 0.307 0.820 0.649
#> ATC:hclust 3 0.652 0.860 0.925 0.475 0.730 0.550
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.856 0.869 0.940 0.1294 0.843 0.567
#> CV:NMF 4 0.860 0.878 0.937 0.1178 0.820 0.521
#> MAD:NMF 4 0.887 0.881 0.946 0.1325 0.849 0.584
#> ATC:NMF 4 0.725 0.760 0.884 0.1221 0.858 0.608
#> SD:skmeans 4 0.810 0.760 0.887 0.1134 0.922 0.769
#> CV:skmeans 4 0.807 0.835 0.906 0.1216 0.885 0.667
#> MAD:skmeans 4 0.784 0.736 0.870 0.1185 0.878 0.649
#> ATC:skmeans 4 0.810 0.864 0.930 0.0967 0.919 0.765
#> SD:mclust 4 0.633 0.635 0.756 0.3063 0.798 0.568
#> CV:mclust 4 0.420 0.712 0.782 0.2590 0.965 0.935
#> MAD:mclust 4 0.718 0.792 0.838 0.2955 0.711 0.393
#> ATC:mclust 4 0.553 0.736 0.842 0.3879 0.737 0.512
#> SD:kmeans 4 0.605 0.751 0.838 0.1419 0.816 0.527
#> CV:kmeans 4 0.606 0.615 0.801 0.1332 0.819 0.517
#> MAD:kmeans 4 0.592 0.733 0.830 0.1449 0.819 0.527
#> ATC:kmeans 4 0.857 0.908 0.936 0.1837 0.846 0.594
#> SD:pam 4 0.910 0.916 0.951 0.1331 0.837 0.632
#> CV:pam 4 0.696 0.685 0.845 0.1765 0.867 0.667
#> MAD:pam 4 0.794 0.879 0.932 0.1306 0.846 0.645
#> ATC:pam 4 0.775 0.767 0.899 0.1845 0.834 0.626
#> SD:hclust 4 0.693 0.636 0.760 0.1311 0.888 0.700
#> CV:hclust 4 0.505 0.697 0.780 0.1353 0.929 0.809
#> MAD:hclust 4 0.645 0.654 0.789 0.1326 0.856 0.622
#> ATC:hclust 4 0.719 0.736 0.879 0.2313 0.837 0.624
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.729 0.702 0.846 0.0374 0.972 0.893
#> CV:NMF 5 0.766 0.752 0.841 0.0497 0.967 0.873
#> MAD:NMF 5 0.683 0.571 0.774 0.0439 0.936 0.763
#> ATC:NMF 5 0.693 0.630 0.835 0.0345 0.931 0.758
#> SD:skmeans 5 0.725 0.629 0.822 0.0549 0.947 0.809
#> CV:skmeans 5 0.725 0.679 0.815 0.0510 0.962 0.846
#> MAD:skmeans 5 0.744 0.640 0.806 0.0559 0.896 0.641
#> ATC:skmeans 5 0.847 0.811 0.892 0.0464 0.946 0.811
#> SD:mclust 5 0.636 0.493 0.743 0.0977 0.830 0.517
#> CV:mclust 5 0.608 0.564 0.806 0.2456 0.623 0.317
#> MAD:mclust 5 0.782 0.856 0.900 0.0906 0.913 0.680
#> ATC:mclust 5 0.850 0.723 0.887 0.1750 0.847 0.512
#> SD:kmeans 5 0.733 0.498 0.726 0.0679 0.943 0.786
#> CV:kmeans 5 0.691 0.614 0.779 0.0707 0.902 0.648
#> MAD:kmeans 5 0.776 0.714 0.815 0.0695 0.971 0.880
#> ATC:kmeans 5 0.728 0.652 0.745 0.0664 0.965 0.856
#> SD:pam 5 0.876 0.835 0.903 0.1406 0.894 0.675
#> CV:pam 5 0.764 0.788 0.891 0.0895 0.862 0.562
#> MAD:pam 5 0.859 0.824 0.892 0.1319 0.894 0.675
#> ATC:pam 5 0.744 0.797 0.845 0.1093 0.817 0.484
#> SD:hclust 5 0.751 0.712 0.854 0.0837 0.890 0.641
#> CV:hclust 5 0.551 0.749 0.766 0.1038 0.896 0.656
#> MAD:hclust 5 0.727 0.696 0.845 0.0806 0.882 0.600
#> ATC:hclust 5 0.820 0.717 0.846 0.0804 0.944 0.797
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.696 0.527 0.746 0.04029 0.858 0.508
#> CV:NMF 6 0.743 0.585 0.753 0.03461 0.910 0.651
#> MAD:NMF 6 0.664 0.546 0.771 0.03753 0.849 0.463
#> ATC:NMF 6 0.668 0.545 0.787 0.03428 0.925 0.713
#> SD:skmeans 6 0.731 0.607 0.787 0.04024 0.951 0.799
#> CV:skmeans 6 0.718 0.630 0.786 0.03627 0.961 0.820
#> MAD:skmeans 6 0.749 0.626 0.812 0.04052 0.954 0.804
#> ATC:skmeans 6 0.810 0.773 0.879 0.04041 0.958 0.833
#> SD:mclust 6 0.654 0.633 0.789 0.03296 0.843 0.420
#> CV:mclust 6 0.826 0.843 0.908 0.09575 0.906 0.626
#> MAD:mclust 6 0.740 0.484 0.733 0.00625 0.801 0.333
#> ATC:mclust 6 0.875 0.850 0.929 0.03115 0.948 0.751
#> SD:kmeans 6 0.738 0.728 0.750 0.04109 0.914 0.642
#> CV:kmeans 6 0.718 0.658 0.746 0.04255 0.908 0.619
#> MAD:kmeans 6 0.763 0.563 0.712 0.03813 0.898 0.590
#> ATC:kmeans 6 0.723 0.483 0.620 0.04101 0.864 0.483
#> SD:pam 6 0.887 0.860 0.874 0.05188 0.948 0.768
#> CV:pam 6 0.799 0.779 0.883 0.05636 0.934 0.708
#> MAD:pam 6 0.886 0.802 0.881 0.05373 0.926 0.687
#> ATC:pam 6 0.798 0.766 0.875 0.06392 0.893 0.584
#> SD:hclust 6 0.742 0.701 0.829 0.03455 0.968 0.861
#> CV:hclust 6 0.736 0.785 0.830 0.06372 0.948 0.753
#> MAD:hclust 6 0.752 0.679 0.821 0.03846 0.972 0.866
#> ATC:hclust 6 0.805 0.676 0.834 0.02990 0.960 0.830
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 disease.state(p) k
#> SD:NMF 50 5.44e-05 2
#> CV:NMF 52 1.77e-04 2
#> MAD:NMF 50 1.79e-05 2
#> ATC:NMF 50 1.79e-05 2
#> SD:skmeans 52 2.19e-06 2
#> CV:skmeans 53 1.62e-05 2
#> MAD:skmeans 53 1.45e-06 2
#> ATC:skmeans 53 5.12e-06 2
#> SD:mclust 52 5.53e-08 2
#> CV:mclust 51 1.95e-03 2
#> MAD:mclust 43 2.16e-07 2
#> ATC:mclust 37 1.37e-05 2
#> SD:kmeans 52 2.19e-06 2
#> CV:kmeans 51 3.54e-05 2
#> MAD:kmeans 53 1.45e-06 2
#> ATC:kmeans 45 1.73e-06 2
#> SD:pam 53 8.87e-08 2
#> CV:pam 50 1.30e-06 2
#> MAD:pam 52 2.51e-08 2
#> ATC:pam 53 1.45e-06 2
#> SD:hclust 53 4.66e-05 2
#> CV:hclust 52 1.77e-04 2
#> MAD:hclust 51 9.94e-05 2
#> ATC:hclust 47 1.15e-03 2
test_to_known_factors(res_list, k = 3)
#> n disease.state(p) k
#> SD:NMF 49 1.95e-04 3
#> CV:NMF 50 3.79e-03 3
#> MAD:NMF 50 1.74e-04 3
#> ATC:NMF 49 5.46e-05 3
#> SD:skmeans 52 4.81e-06 3
#> CV:skmeans 51 1.19e-04 3
#> MAD:skmeans 50 6.90e-06 3
#> ATC:skmeans 52 1.26e-05 3
#> SD:mclust 38 2.09e-08 3
#> CV:mclust 52 5.09e-09 3
#> MAD:mclust 35 6.97e-09 3
#> ATC:mclust 52 6.50e-12 3
#> SD:kmeans 47 2.77e-07 3
#> CV:kmeans 52 7.79e-05 3
#> MAD:kmeans 48 7.61e-07 3
#> ATC:kmeans 48 2.64e-04 3
#> SD:pam 53 2.00e-09 3
#> CV:pam 51 6.73e-09 3
#> MAD:pam 52 2.42e-09 3
#> ATC:pam 53 7.07e-12 3
#> SD:hclust 53 2.75e-07 3
#> CV:hclust 51 1.74e-07 3
#> MAD:hclust 51 9.83e-07 3
#> ATC:hclust 52 5.09e-08 3
test_to_known_factors(res_list, k = 4)
#> n disease.state(p) k
#> SD:NMF 50 5.28e-05 4
#> CV:NMF 51 1.95e-04 4
#> MAD:NMF 51 3.25e-05 4
#> ATC:NMF 46 1.62e-04 4
#> SD:skmeans 46 1.10e-04 4
#> CV:skmeans 49 5.39e-05 4
#> MAD:skmeans 44 2.79e-04 4
#> ATC:skmeans 52 3.98e-06 4
#> SD:mclust 42 7.75e-10 4
#> CV:mclust 49 2.55e-07 4
#> MAD:mclust 52 1.23e-06 4
#> ATC:mclust 49 2.04e-09 4
#> SD:kmeans 47 1.05e-06 4
#> CV:kmeans 38 1.41e-04 4
#> MAD:kmeans 44 7.11e-06 4
#> ATC:kmeans 53 1.08e-07 4
#> SD:pam 51 1.53e-12 4
#> CV:pam 45 9.11e-06 4
#> MAD:pam 51 1.53e-12 4
#> ATC:pam 47 3.07e-08 4
#> SD:hclust 43 3.07e-04 4
#> CV:hclust 49 6.26e-08 4
#> MAD:hclust 41 2.58e-08 4
#> ATC:hclust 46 6.81e-09 4
test_to_known_factors(res_list, k = 5)
#> n disease.state(p) k
#> SD:NMF 45 8.26e-05 5
#> CV:NMF 48 2.83e-04 5
#> MAD:NMF 35 1.02e-02 5
#> ATC:NMF 43 3.92e-04 5
#> SD:skmeans 43 1.07e-05 5
#> CV:skmeans 45 3.07e-05 5
#> MAD:skmeans 41 3.35e-05 5
#> ATC:skmeans 47 4.70e-05 5
#> SD:mclust 34 1.39e-03 5
#> CV:mclust 37 2.04e-06 5
#> MAD:mclust 52 1.21e-04 5
#> ATC:mclust 42 4.16e-08 5
#> SD:kmeans 38 5.77e-05 5
#> CV:kmeans 43 5.20e-06 5
#> MAD:kmeans 47 1.96e-08 5
#> ATC:kmeans 46 4.91e-05 5
#> SD:pam 52 3.27e-11 5
#> CV:pam 47 1.24e-08 5
#> MAD:pam 50 1.82e-10 5
#> ATC:pam 50 3.11e-08 5
#> SD:hclust 46 1.56e-07 5
#> CV:hclust 50 5.75e-07 5
#> MAD:hclust 43 1.14e-05 5
#> ATC:hclust 46 1.53e-07 5
test_to_known_factors(res_list, k = 6)
#> n disease.state(p) k
#> SD:NMF 30 8.30e-02 6
#> CV:NMF 35 1.86e-02 6
#> MAD:NMF 29 2.34e-02 6
#> ATC:NMF 32 2.85e-04 6
#> SD:skmeans 40 4.85e-05 6
#> CV:skmeans 36 5.79e-03 6
#> MAD:skmeans 41 3.05e-05 6
#> ATC:skmeans 47 3.99e-05 6
#> SD:mclust 38 3.83e-06 6
#> CV:mclust 52 1.50e-08 6
#> MAD:mclust 26 1.24e-01 6
#> ATC:mclust 50 1.88e-08 6
#> SD:kmeans 47 8.02e-08 6
#> CV:kmeans 45 2.77e-07 6
#> MAD:kmeans 37 1.38e-06 6
#> ATC:kmeans 29 7.90e-06 6
#> SD:pam 49 5.78e-09 6
#> CV:pam 46 1.59e-10 6
#> MAD:pam 48 1.25e-08 6
#> ATC:pam 47 7.83e-07 6
#> SD:hclust 46 3.85e-06 6
#> CV:hclust 50 5.34e-08 6
#> MAD:hclust 46 2.61e-05 6
#> ATC:hclust 45 3.58e-07 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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.771 0.908 0.953 0.4964 0.492 0.492
#> 3 3 0.717 0.860 0.923 0.2965 0.864 0.724
#> 4 4 0.693 0.636 0.760 0.1311 0.888 0.700
#> 5 5 0.751 0.712 0.854 0.0837 0.890 0.641
#> 6 6 0.742 0.701 0.829 0.0345 0.968 0.861
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
#> GSM40663 2 0.0000 0.964 0.000 1.000
#> GSM40667 2 0.0000 0.964 0.000 1.000
#> GSM40675 2 0.0000 0.964 0.000 1.000
#> GSM40703 2 0.0000 0.964 0.000 1.000
#> GSM40660 2 0.0672 0.967 0.008 0.992
#> GSM40668 2 0.0000 0.964 0.000 1.000
#> GSM40678 2 0.0672 0.967 0.008 0.992
#> GSM40679 2 0.0672 0.967 0.008 0.992
#> GSM40686 2 0.1843 0.959 0.028 0.972
#> GSM40687 2 0.0938 0.966 0.012 0.988
#> GSM40691 2 0.0672 0.967 0.008 0.992
#> GSM40699 2 0.0672 0.967 0.008 0.992
#> GSM40664 2 0.0672 0.967 0.008 0.992
#> GSM40682 2 0.0672 0.967 0.008 0.992
#> GSM40688 2 0.0938 0.966 0.012 0.988
#> GSM40702 2 0.0672 0.967 0.008 0.992
#> GSM40706 2 0.0938 0.966 0.012 0.988
#> GSM40711 2 0.4161 0.913 0.084 0.916
#> GSM40661 2 0.0672 0.967 0.008 0.992
#> GSM40662 1 0.9286 0.535 0.656 0.344
#> GSM40666 2 0.5178 0.883 0.116 0.884
#> GSM40669 1 0.9286 0.535 0.656 0.344
#> GSM40670 1 0.9286 0.535 0.656 0.344
#> GSM40671 1 0.0000 0.928 1.000 0.000
#> GSM40672 1 0.0000 0.928 1.000 0.000
#> GSM40673 1 0.0000 0.928 1.000 0.000
#> GSM40674 1 0.8016 0.702 0.756 0.244
#> GSM40676 2 0.5178 0.883 0.116 0.884
#> GSM40680 1 0.1633 0.920 0.976 0.024
#> GSM40681 1 0.0000 0.928 1.000 0.000
#> GSM40683 1 0.0000 0.928 1.000 0.000
#> GSM40684 2 0.5178 0.883 0.116 0.884
#> GSM40685 1 0.1414 0.922 0.980 0.020
#> GSM40689 1 0.0000 0.928 1.000 0.000
#> GSM40690 1 0.0000 0.928 1.000 0.000
#> GSM40692 1 0.1843 0.918 0.972 0.028
#> GSM40693 1 0.0000 0.928 1.000 0.000
#> GSM40694 1 0.1633 0.920 0.976 0.024
#> GSM40695 1 0.0000 0.928 1.000 0.000
#> GSM40696 1 0.0000 0.928 1.000 0.000
#> GSM40697 2 0.4298 0.907 0.088 0.912
#> GSM40704 1 0.0000 0.928 1.000 0.000
#> GSM40705 2 0.4161 0.913 0.084 0.916
#> GSM40707 1 0.0000 0.928 1.000 0.000
#> GSM40708 1 0.0000 0.928 1.000 0.000
#> GSM40709 2 0.5178 0.883 0.116 0.884
#> GSM40712 1 0.7376 0.748 0.792 0.208
#> GSM40713 1 0.1843 0.918 0.972 0.028
#> GSM40665 1 0.0376 0.927 0.996 0.004
#> GSM40677 2 0.0938 0.966 0.012 0.988
#> GSM40698 1 0.0672 0.926 0.992 0.008
#> GSM40701 2 0.0672 0.967 0.008 0.992
#> GSM40710 2 0.0938 0.966 0.012 0.988
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0424 0.906 0.000 0.008 0.992
#> GSM40667 3 0.0424 0.906 0.000 0.008 0.992
#> GSM40675 3 0.0424 0.906 0.000 0.008 0.992
#> GSM40703 3 0.0424 0.906 0.000 0.008 0.992
#> GSM40660 2 0.5859 0.573 0.000 0.656 0.344
#> GSM40668 3 0.0424 0.906 0.000 0.008 0.992
#> GSM40678 2 0.0747 0.904 0.000 0.984 0.016
#> GSM40679 2 0.0747 0.904 0.000 0.984 0.016
#> GSM40686 2 0.0747 0.896 0.016 0.984 0.000
#> GSM40687 2 0.0000 0.902 0.000 1.000 0.000
#> GSM40691 2 0.1964 0.887 0.000 0.944 0.056
#> GSM40699 2 0.0747 0.904 0.000 0.984 0.016
#> GSM40664 2 0.3879 0.809 0.000 0.848 0.152
#> GSM40682 2 0.0747 0.904 0.000 0.984 0.016
#> GSM40688 2 0.0000 0.902 0.000 1.000 0.000
#> GSM40702 2 0.1643 0.895 0.000 0.956 0.044
#> GSM40706 2 0.0237 0.902 0.000 0.996 0.004
#> GSM40711 3 0.3461 0.917 0.076 0.024 0.900
#> GSM40661 2 0.5733 0.617 0.000 0.676 0.324
#> GSM40662 1 0.7337 0.542 0.644 0.056 0.300
#> GSM40666 3 0.4121 0.906 0.108 0.024 0.868
#> GSM40669 1 0.7337 0.542 0.644 0.056 0.300
#> GSM40670 1 0.7337 0.542 0.644 0.056 0.300
#> GSM40671 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40674 1 0.6354 0.703 0.744 0.052 0.204
#> GSM40676 3 0.4121 0.906 0.108 0.024 0.868
#> GSM40680 1 0.1525 0.913 0.964 0.032 0.004
#> GSM40681 1 0.0661 0.921 0.988 0.008 0.004
#> GSM40683 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40684 3 0.4121 0.906 0.108 0.024 0.868
#> GSM40685 1 0.1399 0.915 0.968 0.028 0.004
#> GSM40689 1 0.0424 0.921 0.992 0.000 0.008
#> GSM40690 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40692 1 0.1711 0.911 0.960 0.032 0.008
#> GSM40693 1 0.0592 0.921 0.988 0.012 0.000
#> GSM40694 1 0.1525 0.913 0.964 0.032 0.004
#> GSM40695 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40696 1 0.0592 0.921 0.988 0.012 0.000
#> GSM40697 2 0.3856 0.824 0.072 0.888 0.040
#> GSM40704 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40705 3 0.3461 0.917 0.076 0.024 0.900
#> GSM40707 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.922 1.000 0.000 0.000
#> GSM40709 3 0.4371 0.901 0.108 0.032 0.860
#> GSM40712 1 0.5798 0.746 0.780 0.044 0.176
#> GSM40713 1 0.1453 0.914 0.968 0.024 0.008
#> GSM40665 1 0.0661 0.921 0.988 0.004 0.008
#> GSM40677 2 0.0000 0.902 0.000 1.000 0.000
#> GSM40698 1 0.1015 0.920 0.980 0.012 0.008
#> GSM40701 2 0.6062 0.504 0.000 0.616 0.384
#> GSM40710 2 0.0000 0.902 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.5132 -0.0440 0.000 0.004 0.448 0.548
#> GSM40667 4 0.5132 -0.0440 0.000 0.004 0.448 0.548
#> GSM40675 4 0.5132 -0.0440 0.000 0.004 0.448 0.548
#> GSM40703 4 0.5132 -0.0440 0.000 0.004 0.448 0.548
#> GSM40660 2 0.6281 0.6427 0.000 0.656 0.216 0.128
#> GSM40668 4 0.5132 -0.0440 0.000 0.004 0.448 0.548
#> GSM40678 2 0.0469 0.9076 0.000 0.988 0.012 0.000
#> GSM40679 2 0.0469 0.9076 0.000 0.988 0.012 0.000
#> GSM40686 2 0.0844 0.9028 0.004 0.980 0.004 0.012
#> GSM40687 2 0.0188 0.9060 0.000 0.996 0.000 0.004
#> GSM40691 2 0.1854 0.8900 0.000 0.940 0.048 0.012
#> GSM40699 2 0.0469 0.9076 0.000 0.988 0.012 0.000
#> GSM40664 2 0.3257 0.8196 0.000 0.844 0.152 0.004
#> GSM40682 2 0.0469 0.9076 0.000 0.988 0.012 0.000
#> GSM40688 2 0.0592 0.9045 0.000 0.984 0.000 0.016
#> GSM40702 2 0.1411 0.8996 0.000 0.960 0.020 0.020
#> GSM40706 2 0.0000 0.9063 0.000 1.000 0.000 0.000
#> GSM40711 3 0.0000 0.9469 0.000 0.000 1.000 0.000
#> GSM40661 2 0.5940 0.6593 0.000 0.672 0.240 0.088
#> GSM40662 4 0.8029 0.0693 0.220 0.012 0.328 0.440
#> GSM40666 3 0.1109 0.9705 0.004 0.000 0.968 0.028
#> GSM40669 4 0.8029 0.0693 0.220 0.012 0.328 0.440
#> GSM40670 4 0.8029 0.0693 0.220 0.012 0.328 0.440
#> GSM40671 1 0.0921 0.7544 0.972 0.000 0.000 0.028
#> GSM40672 1 0.0469 0.7497 0.988 0.000 0.000 0.012
#> GSM40673 1 0.0000 0.7452 1.000 0.000 0.000 0.000
#> GSM40674 4 0.7960 -0.1800 0.320 0.008 0.232 0.440
#> GSM40676 3 0.1109 0.9705 0.004 0.000 0.968 0.028
#> GSM40680 1 0.5668 0.5945 0.532 0.000 0.024 0.444
#> GSM40681 1 0.5193 0.6346 0.580 0.000 0.008 0.412
#> GSM40683 1 0.0000 0.7452 1.000 0.000 0.000 0.000
#> GSM40684 3 0.1109 0.9705 0.004 0.000 0.968 0.028
#> GSM40685 1 0.5483 0.5997 0.536 0.000 0.016 0.448
#> GSM40689 1 0.4297 0.7108 0.820 0.000 0.084 0.096
#> GSM40690 1 0.2281 0.7581 0.904 0.000 0.000 0.096
#> GSM40692 1 0.5755 0.5895 0.528 0.000 0.028 0.444
#> GSM40693 1 0.4193 0.6903 0.732 0.000 0.000 0.268
#> GSM40694 1 0.5668 0.5945 0.532 0.000 0.024 0.444
#> GSM40695 1 0.0469 0.7503 0.988 0.000 0.000 0.012
#> GSM40696 1 0.4193 0.6903 0.732 0.000 0.000 0.268
#> GSM40697 2 0.4108 0.8025 0.016 0.848 0.056 0.080
#> GSM40704 1 0.0000 0.7452 1.000 0.000 0.000 0.000
#> GSM40705 3 0.0000 0.9469 0.000 0.000 1.000 0.000
#> GSM40707 1 0.3024 0.7559 0.852 0.000 0.000 0.148
#> GSM40708 1 0.3024 0.7559 0.852 0.000 0.000 0.148
#> GSM40709 3 0.1443 0.9612 0.004 0.008 0.960 0.028
#> GSM40712 4 0.7584 -0.2641 0.348 0.000 0.204 0.448
#> GSM40713 1 0.4464 0.7484 0.768 0.000 0.024 0.208
#> GSM40665 1 0.5376 0.7207 0.736 0.000 0.088 0.176
#> GSM40677 2 0.0592 0.9045 0.000 0.984 0.000 0.016
#> GSM40698 1 0.6054 0.6969 0.656 0.000 0.088 0.256
#> GSM40701 2 0.6663 0.5758 0.000 0.612 0.244 0.144
#> GSM40710 2 0.0188 0.9060 0.000 0.996 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.1270 1.000 0.000 0.000 0.948 0.052 0.000
#> GSM40667 3 0.1270 1.000 0.000 0.000 0.948 0.052 0.000
#> GSM40675 3 0.1270 1.000 0.000 0.000 0.948 0.052 0.000
#> GSM40703 3 0.1270 1.000 0.000 0.000 0.948 0.052 0.000
#> GSM40660 2 0.5507 0.639 0.000 0.652 0.188 0.160 0.000
#> GSM40668 3 0.1270 1.000 0.000 0.000 0.948 0.052 0.000
#> GSM40678 2 0.0566 0.904 0.000 0.984 0.004 0.012 0.000
#> GSM40679 2 0.0566 0.904 0.000 0.984 0.004 0.012 0.000
#> GSM40686 2 0.0798 0.899 0.000 0.976 0.008 0.000 0.016
#> GSM40687 2 0.0290 0.901 0.000 0.992 0.008 0.000 0.000
#> GSM40691 2 0.1701 0.886 0.000 0.936 0.016 0.048 0.000
#> GSM40699 2 0.0566 0.904 0.000 0.984 0.004 0.012 0.000
#> GSM40664 2 0.2806 0.815 0.000 0.844 0.004 0.152 0.000
#> GSM40682 2 0.0566 0.904 0.000 0.984 0.004 0.012 0.000
#> GSM40688 2 0.0693 0.900 0.000 0.980 0.012 0.000 0.008
#> GSM40702 2 0.1300 0.896 0.000 0.956 0.028 0.016 0.000
#> GSM40706 2 0.0162 0.903 0.000 0.996 0.004 0.000 0.000
#> GSM40711 4 0.1124 0.962 0.000 0.000 0.036 0.960 0.004
#> GSM40661 2 0.5379 0.661 0.000 0.668 0.168 0.164 0.000
#> GSM40662 5 0.4387 0.561 0.000 0.012 0.000 0.348 0.640
#> GSM40666 4 0.0162 0.973 0.000 0.000 0.000 0.996 0.004
#> GSM40669 5 0.4387 0.561 0.000 0.012 0.000 0.348 0.640
#> GSM40670 5 0.4387 0.561 0.000 0.012 0.000 0.348 0.640
#> GSM40671 1 0.2179 0.679 0.896 0.000 0.004 0.000 0.100
#> GSM40672 1 0.0404 0.699 0.988 0.000 0.000 0.000 0.012
#> GSM40673 1 0.0000 0.700 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.3783 0.651 0.000 0.008 0.000 0.252 0.740
#> GSM40676 4 0.0510 0.974 0.000 0.000 0.000 0.984 0.016
#> GSM40680 5 0.0404 0.673 0.000 0.000 0.000 0.012 0.988
#> GSM40681 5 0.2970 0.569 0.168 0.000 0.000 0.004 0.828
#> GSM40683 1 0.0000 0.700 1.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.0510 0.974 0.000 0.000 0.000 0.984 0.016
#> GSM40685 5 0.0000 0.668 0.000 0.000 0.000 0.000 1.000
#> GSM40689 1 0.5641 0.540 0.688 0.000 0.036 0.092 0.184
#> GSM40690 1 0.3177 0.595 0.792 0.000 0.000 0.000 0.208
#> GSM40692 5 0.0510 0.673 0.000 0.000 0.000 0.016 0.984
#> GSM40693 1 0.4430 0.215 0.540 0.000 0.004 0.000 0.456
#> GSM40694 5 0.0404 0.673 0.000 0.000 0.000 0.012 0.988
#> GSM40695 1 0.0880 0.699 0.968 0.000 0.000 0.000 0.032
#> GSM40696 1 0.4430 0.215 0.540 0.000 0.004 0.000 0.456
#> GSM40697 2 0.3322 0.801 0.000 0.848 0.004 0.044 0.104
#> GSM40704 1 0.0000 0.700 1.000 0.000 0.000 0.000 0.000
#> GSM40705 4 0.1124 0.962 0.000 0.000 0.036 0.960 0.004
#> GSM40707 1 0.5521 0.226 0.496 0.000 0.040 0.012 0.452
#> GSM40708 1 0.5521 0.226 0.496 0.000 0.040 0.012 0.452
#> GSM40709 4 0.0451 0.968 0.000 0.008 0.000 0.988 0.004
#> GSM40712 5 0.3305 0.671 0.000 0.000 0.000 0.224 0.776
#> GSM40713 1 0.4849 0.382 0.548 0.000 0.004 0.016 0.432
#> GSM40665 5 0.6523 -0.334 0.428 0.000 0.036 0.084 0.452
#> GSM40677 2 0.0693 0.900 0.000 0.980 0.012 0.000 0.008
#> GSM40698 5 0.5765 0.134 0.264 0.000 0.020 0.084 0.632
#> GSM40701 2 0.5798 0.569 0.000 0.608 0.236 0.156 0.000
#> GSM40710 2 0.0290 0.901 0.000 0.992 0.008 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.9986 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 2 0.5511 0.5586 0.000 0.628 0.196 0.152 0.000 0.024
#> GSM40668 3 0.0146 0.9944 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40678 2 0.0508 0.8057 0.000 0.984 0.004 0.012 0.000 0.000
#> GSM40679 2 0.0508 0.8057 0.000 0.984 0.004 0.012 0.000 0.000
#> GSM40686 2 0.3509 0.7495 0.000 0.744 0.000 0.000 0.016 0.240
#> GSM40687 2 0.3023 0.7577 0.000 0.768 0.000 0.000 0.000 0.232
#> GSM40691 2 0.3424 0.7881 0.000 0.836 0.016 0.040 0.008 0.100
#> GSM40699 2 0.0508 0.8057 0.000 0.984 0.004 0.012 0.000 0.000
#> GSM40664 2 0.3806 0.7199 0.000 0.772 0.000 0.152 0.000 0.076
#> GSM40682 2 0.0508 0.8057 0.000 0.984 0.004 0.012 0.000 0.000
#> GSM40688 2 0.3309 0.7348 0.000 0.720 0.000 0.000 0.000 0.280
#> GSM40702 2 0.1426 0.7989 0.000 0.948 0.028 0.016 0.000 0.008
#> GSM40706 2 0.1082 0.8026 0.000 0.956 0.004 0.000 0.000 0.040
#> GSM40711 4 0.0865 0.9626 0.000 0.000 0.036 0.964 0.000 0.000
#> GSM40661 2 0.5545 0.5686 0.000 0.636 0.176 0.156 0.000 0.032
#> GSM40662 5 0.3912 0.6315 0.000 0.012 0.000 0.340 0.648 0.000
#> GSM40666 4 0.0000 0.9702 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40669 5 0.3927 0.6282 0.000 0.012 0.000 0.344 0.644 0.000
#> GSM40670 5 0.3927 0.6282 0.000 0.012 0.000 0.344 0.644 0.000
#> GSM40671 1 0.2724 0.5208 0.864 0.000 0.000 0.000 0.052 0.084
#> GSM40672 1 0.0363 0.6163 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40673 1 0.0000 0.6160 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.3373 0.7044 0.000 0.008 0.000 0.248 0.744 0.000
#> GSM40676 4 0.0458 0.9722 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM40680 5 0.0146 0.7184 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM40681 5 0.3122 0.6273 0.160 0.000 0.000 0.004 0.816 0.020
#> GSM40683 1 0.0000 0.6160 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.0458 0.9722 0.000 0.000 0.000 0.984 0.000 0.016
#> GSM40685 5 0.0260 0.7145 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM40689 1 0.5162 0.1605 0.672 0.000 0.000 0.088 0.036 0.204
#> GSM40690 1 0.2964 0.5596 0.792 0.000 0.000 0.000 0.204 0.004
#> GSM40692 5 0.0260 0.7193 0.000 0.000 0.000 0.008 0.992 0.000
#> GSM40693 1 0.4238 0.2763 0.540 0.000 0.000 0.000 0.444 0.016
#> GSM40694 5 0.0146 0.7184 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM40695 1 0.1151 0.5964 0.956 0.000 0.000 0.000 0.012 0.032
#> GSM40696 1 0.4238 0.2763 0.540 0.000 0.000 0.000 0.444 0.016
#> GSM40697 2 0.5044 0.6901 0.000 0.696 0.000 0.036 0.104 0.164
#> GSM40704 1 0.0000 0.6160 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40705 4 0.0865 0.9626 0.000 0.000 0.036 0.964 0.000 0.000
#> GSM40707 6 0.4617 1.0000 0.252 0.000 0.000 0.000 0.084 0.664
#> GSM40708 6 0.4617 1.0000 0.252 0.000 0.000 0.000 0.084 0.664
#> GSM40709 4 0.0520 0.9604 0.000 0.008 0.000 0.984 0.008 0.000
#> GSM40712 5 0.2912 0.7205 0.000 0.000 0.000 0.216 0.784 0.000
#> GSM40713 1 0.4650 0.3331 0.548 0.000 0.000 0.008 0.416 0.028
#> GSM40665 1 0.7007 0.0502 0.412 0.000 0.000 0.084 0.308 0.196
#> GSM40677 2 0.3309 0.7348 0.000 0.720 0.000 0.000 0.000 0.280
#> GSM40698 5 0.6567 -0.0799 0.248 0.000 0.000 0.084 0.520 0.148
#> GSM40701 2 0.5752 0.4868 0.000 0.584 0.244 0.148 0.000 0.024
#> GSM40710 2 0.3023 0.7577 0.000 0.768 0.000 0.000 0.000 0.232
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:hclust 53 4.66e-05 2
#> SD:hclust 53 2.75e-07 3
#> SD:hclust 43 3.07e-04 4
#> SD:hclust 46 1.56e-07 5
#> SD:hclust 46 3.85e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "kmeans"]
# you can also extract it by
# res = res_list["SD:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.847 0.909 0.958 0.5046 0.492 0.492
#> 3 3 0.579 0.718 0.823 0.2974 0.810 0.633
#> 4 4 0.605 0.751 0.838 0.1419 0.816 0.527
#> 5 5 0.733 0.498 0.726 0.0679 0.943 0.786
#> 6 6 0.738 0.728 0.750 0.0411 0.914 0.642
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
#> GSM40663 2 0.000 0.990 0.000 1.000
#> GSM40667 2 0.000 0.990 0.000 1.000
#> GSM40675 2 0.000 0.990 0.000 1.000
#> GSM40703 2 0.000 0.990 0.000 1.000
#> GSM40660 2 0.000 0.990 0.000 1.000
#> GSM40668 2 0.000 0.990 0.000 1.000
#> GSM40678 2 0.000 0.990 0.000 1.000
#> GSM40679 2 0.000 0.990 0.000 1.000
#> GSM40686 2 0.775 0.675 0.228 0.772
#> GSM40687 2 0.000 0.990 0.000 1.000
#> GSM40691 2 0.000 0.990 0.000 1.000
#> GSM40699 2 0.000 0.990 0.000 1.000
#> GSM40664 2 0.000 0.990 0.000 1.000
#> GSM40682 2 0.000 0.990 0.000 1.000
#> GSM40688 2 0.000 0.990 0.000 1.000
#> GSM40702 2 0.000 0.990 0.000 1.000
#> GSM40706 2 0.000 0.990 0.000 1.000
#> GSM40711 2 0.000 0.990 0.000 1.000
#> GSM40661 2 0.000 0.990 0.000 1.000
#> GSM40662 2 0.000 0.990 0.000 1.000
#> GSM40666 1 0.913 0.588 0.672 0.328
#> GSM40669 1 0.000 0.923 1.000 0.000
#> GSM40670 1 0.909 0.595 0.676 0.324
#> GSM40671 1 0.000 0.923 1.000 0.000
#> GSM40672 1 0.000 0.923 1.000 0.000
#> GSM40673 1 0.000 0.923 1.000 0.000
#> GSM40674 1 0.949 0.513 0.632 0.368
#> GSM40676 1 0.895 0.614 0.688 0.312
#> GSM40680 1 0.000 0.923 1.000 0.000
#> GSM40681 1 0.000 0.923 1.000 0.000
#> GSM40683 1 0.000 0.923 1.000 0.000
#> GSM40684 1 0.850 0.663 0.724 0.276
#> GSM40685 1 0.000 0.923 1.000 0.000
#> GSM40689 1 0.000 0.923 1.000 0.000
#> GSM40690 1 0.000 0.923 1.000 0.000
#> GSM40692 1 0.000 0.923 1.000 0.000
#> GSM40693 1 0.000 0.923 1.000 0.000
#> GSM40694 1 0.000 0.923 1.000 0.000
#> GSM40695 1 0.000 0.923 1.000 0.000
#> GSM40696 1 0.000 0.923 1.000 0.000
#> GSM40697 2 0.000 0.990 0.000 1.000
#> GSM40704 1 0.000 0.923 1.000 0.000
#> GSM40705 2 0.000 0.990 0.000 1.000
#> GSM40707 1 0.000 0.923 1.000 0.000
#> GSM40708 1 0.000 0.923 1.000 0.000
#> GSM40709 1 0.955 0.497 0.624 0.376
#> GSM40712 1 0.000 0.923 1.000 0.000
#> GSM40713 1 0.000 0.923 1.000 0.000
#> GSM40665 1 0.000 0.923 1.000 0.000
#> GSM40677 2 0.000 0.990 0.000 1.000
#> GSM40698 1 0.000 0.923 1.000 0.000
#> GSM40701 2 0.000 0.990 0.000 1.000
#> GSM40710 2 0.000 0.990 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40667 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40675 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40703 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40660 3 0.0424 0.8402 0.000 0.008 0.992
#> GSM40668 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40678 2 0.5810 0.7968 0.000 0.664 0.336
#> GSM40679 2 0.5810 0.7968 0.000 0.664 0.336
#> GSM40686 2 0.3028 0.6235 0.032 0.920 0.048
#> GSM40687 2 0.5810 0.7968 0.000 0.664 0.336
#> GSM40691 2 0.5810 0.7968 0.000 0.664 0.336
#> GSM40699 2 0.5968 0.7589 0.000 0.636 0.364
#> GSM40664 2 0.5760 0.7954 0.000 0.672 0.328
#> GSM40682 2 0.5785 0.7965 0.000 0.668 0.332
#> GSM40688 2 0.4808 0.7326 0.008 0.804 0.188
#> GSM40702 2 0.5810 0.7968 0.000 0.664 0.336
#> GSM40706 2 0.5810 0.7968 0.000 0.664 0.336
#> GSM40711 3 0.2448 0.7942 0.000 0.076 0.924
#> GSM40661 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40662 2 0.4002 0.4938 0.000 0.840 0.160
#> GSM40666 3 0.9284 0.3224 0.192 0.296 0.512
#> GSM40669 1 0.5733 0.7236 0.676 0.324 0.000
#> GSM40670 1 0.8665 0.5923 0.552 0.324 0.124
#> GSM40671 1 0.1529 0.8237 0.960 0.040 0.000
#> GSM40672 1 0.0000 0.8315 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.8315 1.000 0.000 0.000
#> GSM40674 1 0.8665 0.5923 0.552 0.324 0.124
#> GSM40676 1 0.9896 0.0977 0.376 0.264 0.360
#> GSM40680 2 0.6215 -0.3295 0.428 0.572 0.000
#> GSM40681 1 0.0747 0.8339 0.984 0.016 0.000
#> GSM40683 1 0.0000 0.8315 1.000 0.000 0.000
#> GSM40684 1 0.9896 0.0977 0.376 0.264 0.360
#> GSM40685 1 0.4796 0.7858 0.780 0.220 0.000
#> GSM40689 1 0.1765 0.8227 0.956 0.040 0.004
#> GSM40690 1 0.0237 0.8307 0.996 0.004 0.000
#> GSM40692 1 0.5810 0.7128 0.664 0.336 0.000
#> GSM40693 1 0.2959 0.8131 0.900 0.100 0.000
#> GSM40694 1 0.4750 0.7866 0.784 0.216 0.000
#> GSM40695 1 0.0000 0.8315 1.000 0.000 0.000
#> GSM40696 1 0.2959 0.8131 0.900 0.100 0.000
#> GSM40697 2 0.1950 0.6148 0.008 0.952 0.040
#> GSM40704 1 0.0000 0.8315 1.000 0.000 0.000
#> GSM40705 3 0.2878 0.7769 0.000 0.096 0.904
#> GSM40707 1 0.1765 0.8227 0.956 0.040 0.004
#> GSM40708 1 0.3500 0.8225 0.880 0.116 0.004
#> GSM40709 3 0.9284 0.3224 0.192 0.296 0.512
#> GSM40712 1 0.5650 0.7311 0.688 0.312 0.000
#> GSM40713 1 0.3551 0.8205 0.868 0.132 0.000
#> GSM40665 1 0.1765 0.8227 0.956 0.040 0.004
#> GSM40677 2 0.4808 0.7326 0.008 0.804 0.188
#> GSM40698 1 0.4110 0.8149 0.844 0.152 0.004
#> GSM40701 3 0.0237 0.8439 0.000 0.004 0.996
#> GSM40710 2 0.5810 0.7968 0.000 0.664 0.336
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.3024 0.914 0.000 0.148 0.000 0.852
#> GSM40667 4 0.3024 0.914 0.000 0.148 0.000 0.852
#> GSM40675 4 0.3024 0.914 0.000 0.148 0.000 0.852
#> GSM40703 4 0.3024 0.914 0.000 0.148 0.000 0.852
#> GSM40660 4 0.5792 0.887 0.000 0.168 0.124 0.708
#> GSM40668 4 0.3024 0.914 0.000 0.148 0.000 0.852
#> GSM40678 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> GSM40686 2 0.3647 0.811 0.000 0.832 0.152 0.016
#> GSM40687 2 0.0592 0.937 0.000 0.984 0.016 0.000
#> GSM40691 2 0.0336 0.939 0.000 0.992 0.008 0.000
#> GSM40699 2 0.0707 0.921 0.000 0.980 0.000 0.020
#> GSM40664 2 0.0188 0.941 0.000 0.996 0.000 0.004
#> GSM40682 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> GSM40688 2 0.3271 0.825 0.000 0.856 0.132 0.012
#> GSM40702 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> GSM40706 2 0.0000 0.942 0.000 1.000 0.000 0.000
#> GSM40711 4 0.4824 0.837 0.000 0.076 0.144 0.780
#> GSM40661 4 0.5664 0.889 0.000 0.156 0.124 0.720
#> GSM40662 3 0.2888 0.705 0.000 0.124 0.872 0.004
#> GSM40666 3 0.4772 0.597 0.012 0.008 0.736 0.244
#> GSM40669 3 0.3501 0.715 0.132 0.020 0.848 0.000
#> GSM40670 3 0.2748 0.726 0.072 0.020 0.904 0.004
#> GSM40671 1 0.3894 0.755 0.844 0.000 0.088 0.068
#> GSM40672 1 0.0000 0.785 1.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.785 1.000 0.000 0.000 0.000
#> GSM40674 3 0.2748 0.726 0.072 0.020 0.904 0.004
#> GSM40676 3 0.6417 0.512 0.104 0.008 0.656 0.232
#> GSM40680 3 0.5354 0.678 0.080 0.136 0.768 0.016
#> GSM40681 1 0.2125 0.754 0.920 0.000 0.076 0.004
#> GSM40683 1 0.0000 0.785 1.000 0.000 0.000 0.000
#> GSM40684 3 0.6417 0.512 0.104 0.008 0.656 0.232
#> GSM40685 3 0.5855 0.501 0.308 0.020 0.648 0.024
#> GSM40689 1 0.4224 0.748 0.824 0.000 0.100 0.076
#> GSM40690 1 0.0188 0.784 0.996 0.000 0.004 0.000
#> GSM40692 3 0.5308 0.679 0.168 0.056 0.760 0.016
#> GSM40693 1 0.4606 0.479 0.724 0.000 0.264 0.012
#> GSM40694 3 0.5186 0.461 0.344 0.000 0.640 0.016
#> GSM40695 1 0.0000 0.785 1.000 0.000 0.000 0.000
#> GSM40696 1 0.4606 0.479 0.724 0.000 0.264 0.012
#> GSM40697 3 0.4820 0.525 0.000 0.296 0.692 0.012
#> GSM40704 1 0.0000 0.785 1.000 0.000 0.000 0.000
#> GSM40705 4 0.4824 0.837 0.000 0.076 0.144 0.780
#> GSM40707 1 0.4163 0.749 0.828 0.000 0.096 0.076
#> GSM40708 1 0.6292 0.466 0.592 0.000 0.332 0.076
#> GSM40709 3 0.4739 0.600 0.012 0.008 0.740 0.240
#> GSM40712 3 0.4323 0.670 0.204 0.020 0.776 0.000
#> GSM40713 1 0.6521 0.246 0.512 0.000 0.412 0.076
#> GSM40665 1 0.4224 0.748 0.824 0.000 0.100 0.076
#> GSM40677 2 0.3479 0.820 0.000 0.840 0.148 0.012
#> GSM40698 1 0.6627 0.287 0.504 0.000 0.412 0.084
#> GSM40701 4 0.5141 0.904 0.000 0.160 0.084 0.756
#> GSM40710 2 0.0592 0.937 0.000 0.984 0.016 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.4746 0.602 0.000 0.016 0.504 0.480 0.000
#> GSM40667 3 0.4746 0.602 0.000 0.016 0.504 0.480 0.000
#> GSM40675 3 0.4746 0.602 0.000 0.016 0.504 0.480 0.000
#> GSM40703 3 0.4746 0.602 0.000 0.016 0.504 0.480 0.000
#> GSM40660 3 0.1597 0.591 0.000 0.048 0.940 0.000 0.012
#> GSM40668 3 0.4746 0.602 0.000 0.016 0.504 0.480 0.000
#> GSM40678 2 0.0963 0.936 0.000 0.964 0.000 0.036 0.000
#> GSM40679 2 0.1862 0.939 0.000 0.932 0.048 0.004 0.016
#> GSM40686 2 0.2595 0.915 0.000 0.888 0.000 0.080 0.032
#> GSM40687 2 0.1410 0.931 0.000 0.940 0.000 0.060 0.000
#> GSM40691 2 0.2321 0.932 0.000 0.912 0.056 0.024 0.008
#> GSM40699 2 0.2199 0.933 0.000 0.916 0.060 0.016 0.008
#> GSM40664 2 0.2745 0.936 0.000 0.896 0.052 0.028 0.024
#> GSM40682 2 0.2395 0.938 0.000 0.912 0.048 0.016 0.024
#> GSM40688 2 0.1872 0.927 0.000 0.928 0.000 0.052 0.020
#> GSM40702 2 0.2005 0.936 0.000 0.924 0.056 0.004 0.016
#> GSM40706 2 0.1278 0.943 0.000 0.960 0.020 0.016 0.004
#> GSM40711 3 0.1725 0.589 0.000 0.000 0.936 0.020 0.044
#> GSM40661 3 0.1364 0.596 0.000 0.036 0.952 0.000 0.012
#> GSM40662 5 0.3080 0.774 0.000 0.008 0.140 0.008 0.844
#> GSM40666 5 0.5382 0.168 0.004 0.000 0.476 0.044 0.476
#> GSM40669 5 0.2905 0.793 0.036 0.000 0.096 0.000 0.868
#> GSM40670 5 0.3197 0.782 0.024 0.000 0.140 0.000 0.836
#> GSM40671 1 0.5202 -0.228 0.596 0.000 0.000 0.348 0.056
#> GSM40672 1 0.0162 0.508 0.996 0.000 0.000 0.004 0.000
#> GSM40673 1 0.0162 0.508 0.996 0.000 0.000 0.004 0.000
#> GSM40674 5 0.3264 0.784 0.020 0.000 0.140 0.004 0.836
#> GSM40676 3 0.7263 -0.060 0.040 0.000 0.436 0.340 0.184
#> GSM40680 5 0.1954 0.775 0.028 0.008 0.000 0.032 0.932
#> GSM40681 1 0.4199 0.288 0.764 0.000 0.000 0.056 0.180
#> GSM40683 1 0.0162 0.508 0.996 0.000 0.000 0.004 0.000
#> GSM40684 3 0.7263 -0.060 0.040 0.000 0.436 0.340 0.184
#> GSM40685 5 0.3336 0.683 0.096 0.000 0.000 0.060 0.844
#> GSM40689 1 0.5107 -0.217 0.596 0.000 0.000 0.356 0.048
#> GSM40690 1 0.1399 0.488 0.952 0.000 0.000 0.028 0.020
#> GSM40692 5 0.1990 0.773 0.040 0.004 0.000 0.028 0.928
#> GSM40693 1 0.4419 0.256 0.668 0.000 0.000 0.020 0.312
#> GSM40694 5 0.3090 0.694 0.104 0.000 0.000 0.040 0.856
#> GSM40695 1 0.0162 0.508 0.996 0.000 0.000 0.004 0.000
#> GSM40696 1 0.4419 0.256 0.668 0.000 0.000 0.020 0.312
#> GSM40697 5 0.3993 0.672 0.000 0.160 0.024 0.020 0.796
#> GSM40704 1 0.0162 0.508 0.996 0.000 0.000 0.004 0.000
#> GSM40705 3 0.1943 0.582 0.000 0.000 0.924 0.020 0.056
#> GSM40707 1 0.5636 -0.356 0.544 0.000 0.000 0.372 0.084
#> GSM40708 1 0.6530 -0.767 0.424 0.000 0.000 0.380 0.196
#> GSM40709 3 0.5382 -0.302 0.004 0.000 0.476 0.044 0.476
#> GSM40712 5 0.1282 0.782 0.044 0.000 0.004 0.000 0.952
#> GSM40713 1 0.6784 -0.905 0.368 0.000 0.000 0.352 0.280
#> GSM40665 1 0.5429 -0.305 0.564 0.000 0.000 0.368 0.068
#> GSM40677 2 0.2654 0.914 0.000 0.884 0.000 0.084 0.032
#> GSM40698 4 0.6739 0.000 0.348 0.000 0.000 0.392 0.260
#> GSM40701 3 0.3533 0.612 0.000 0.040 0.840 0.108 0.012
#> GSM40710 2 0.1877 0.928 0.000 0.924 0.000 0.064 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 0.988 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.988 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.988 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.988 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.5194 0.555 0.000 0.004 0.232 0.624 0.000 0.140
#> GSM40668 3 0.1049 0.949 0.000 0.000 0.960 0.032 0.000 0.008
#> GSM40678 2 0.0717 0.853 0.000 0.976 0.000 0.008 0.000 0.016
#> GSM40679 2 0.3458 0.849 0.000 0.808 0.000 0.080 0.000 0.112
#> GSM40686 2 0.3113 0.819 0.000 0.856 0.000 0.040 0.028 0.076
#> GSM40687 2 0.1708 0.843 0.000 0.932 0.000 0.024 0.004 0.040
#> GSM40691 2 0.4527 0.813 0.000 0.712 0.000 0.088 0.008 0.192
#> GSM40699 2 0.3883 0.832 0.000 0.768 0.000 0.088 0.000 0.144
#> GSM40664 2 0.4095 0.847 0.000 0.756 0.000 0.088 0.004 0.152
#> GSM40682 2 0.3644 0.849 0.000 0.792 0.000 0.088 0.000 0.120
#> GSM40688 2 0.2525 0.832 0.000 0.876 0.000 0.012 0.012 0.100
#> GSM40702 2 0.3767 0.832 0.000 0.780 0.000 0.088 0.000 0.132
#> GSM40706 2 0.2136 0.863 0.000 0.904 0.000 0.048 0.000 0.048
#> GSM40711 4 0.4093 0.556 0.000 0.000 0.324 0.656 0.012 0.008
#> GSM40661 4 0.5368 0.539 0.000 0.004 0.260 0.592 0.000 0.144
#> GSM40662 5 0.4462 0.762 0.000 0.012 0.000 0.220 0.708 0.060
#> GSM40666 4 0.3386 0.524 0.000 0.000 0.012 0.796 0.176 0.016
#> GSM40669 5 0.3166 0.792 0.008 0.000 0.000 0.184 0.800 0.008
#> GSM40670 5 0.3323 0.760 0.000 0.000 0.000 0.240 0.752 0.008
#> GSM40671 6 0.4467 0.713 0.480 0.000 0.000 0.004 0.020 0.496
#> GSM40672 1 0.0146 0.713 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM40673 1 0.0777 0.704 0.972 0.000 0.000 0.004 0.000 0.024
#> GSM40674 5 0.3641 0.758 0.000 0.000 0.000 0.248 0.732 0.020
#> GSM40676 4 0.4667 0.493 0.000 0.000 0.012 0.652 0.048 0.288
#> GSM40680 5 0.2592 0.775 0.000 0.016 0.000 0.004 0.864 0.116
#> GSM40681 1 0.6086 0.113 0.520 0.000 0.000 0.020 0.260 0.200
#> GSM40683 1 0.0777 0.704 0.972 0.000 0.000 0.004 0.000 0.024
#> GSM40684 4 0.4667 0.493 0.000 0.000 0.012 0.652 0.048 0.288
#> GSM40685 5 0.3245 0.749 0.024 0.000 0.000 0.032 0.840 0.104
#> GSM40689 6 0.5099 0.767 0.432 0.000 0.000 0.040 0.020 0.508
#> GSM40690 1 0.2239 0.679 0.908 0.000 0.000 0.020 0.048 0.024
#> GSM40692 5 0.2689 0.777 0.004 0.016 0.000 0.004 0.864 0.112
#> GSM40693 1 0.4696 0.492 0.620 0.000 0.000 0.024 0.332 0.024
#> GSM40694 5 0.2624 0.764 0.028 0.000 0.000 0.020 0.884 0.068
#> GSM40695 1 0.0777 0.704 0.972 0.000 0.000 0.004 0.000 0.024
#> GSM40696 1 0.4696 0.492 0.620 0.000 0.000 0.024 0.332 0.024
#> GSM40697 5 0.5080 0.735 0.000 0.056 0.000 0.120 0.708 0.116
#> GSM40704 1 0.0146 0.713 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM40705 4 0.4044 0.566 0.000 0.000 0.312 0.668 0.012 0.008
#> GSM40707 6 0.4543 0.768 0.380 0.000 0.000 0.004 0.032 0.584
#> GSM40708 6 0.4754 0.751 0.236 0.000 0.000 0.004 0.092 0.668
#> GSM40709 4 0.3386 0.524 0.000 0.000 0.012 0.796 0.176 0.016
#> GSM40712 5 0.2231 0.811 0.004 0.000 0.000 0.068 0.900 0.028
#> GSM40713 6 0.6187 0.719 0.268 0.000 0.000 0.028 0.188 0.516
#> GSM40665 6 0.5115 0.781 0.400 0.000 0.000 0.044 0.020 0.536
#> GSM40677 2 0.3140 0.817 0.000 0.840 0.000 0.028 0.016 0.116
#> GSM40698 6 0.6220 0.696 0.224 0.000 0.000 0.056 0.160 0.560
#> GSM40701 4 0.6112 0.372 0.000 0.028 0.352 0.480 0.000 0.140
#> GSM40710 2 0.1793 0.842 0.000 0.928 0.000 0.032 0.004 0.036
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:kmeans 52 2.19e-06 2
#> SD:kmeans 47 2.77e-07 3
#> SD:kmeans 47 1.05e-06 4
#> SD:kmeans 38 5.77e-05 5
#> SD:kmeans 47 8.02e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 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 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.960 0.965 0.984 0.5089 0.492 0.492
#> 3 3 1.000 0.965 0.984 0.3135 0.745 0.527
#> 4 4 0.810 0.760 0.887 0.1134 0.922 0.769
#> 5 5 0.725 0.629 0.822 0.0549 0.947 0.809
#> 6 6 0.731 0.607 0.787 0.0402 0.951 0.799
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
#> GSM40663 2 0.0000 0.995 0.000 1.000
#> GSM40667 2 0.0000 0.995 0.000 1.000
#> GSM40675 2 0.0000 0.995 0.000 1.000
#> GSM40703 2 0.0000 0.995 0.000 1.000
#> GSM40660 2 0.0000 0.995 0.000 1.000
#> GSM40668 2 0.0000 0.995 0.000 1.000
#> GSM40678 2 0.0000 0.995 0.000 1.000
#> GSM40679 2 0.0000 0.995 0.000 1.000
#> GSM40686 2 0.4815 0.880 0.104 0.896
#> GSM40687 2 0.0000 0.995 0.000 1.000
#> GSM40691 2 0.0000 0.995 0.000 1.000
#> GSM40699 2 0.0000 0.995 0.000 1.000
#> GSM40664 2 0.0000 0.995 0.000 1.000
#> GSM40682 2 0.0000 0.995 0.000 1.000
#> GSM40688 2 0.0376 0.992 0.004 0.996
#> GSM40702 2 0.0000 0.995 0.000 1.000
#> GSM40706 2 0.0000 0.995 0.000 1.000
#> GSM40711 2 0.0000 0.995 0.000 1.000
#> GSM40661 2 0.0000 0.995 0.000 1.000
#> GSM40662 2 0.0000 0.995 0.000 1.000
#> GSM40666 1 0.0376 0.970 0.996 0.004
#> GSM40669 1 0.0000 0.973 1.000 0.000
#> GSM40670 1 0.0376 0.970 0.996 0.004
#> GSM40671 1 0.0000 0.973 1.000 0.000
#> GSM40672 1 0.0000 0.973 1.000 0.000
#> GSM40673 1 0.0000 0.973 1.000 0.000
#> GSM40674 1 0.7376 0.750 0.792 0.208
#> GSM40676 1 0.6048 0.828 0.852 0.148
#> GSM40680 1 0.0000 0.973 1.000 0.000
#> GSM40681 1 0.0000 0.973 1.000 0.000
#> GSM40683 1 0.0000 0.973 1.000 0.000
#> GSM40684 1 0.0376 0.970 0.996 0.004
#> GSM40685 1 0.0000 0.973 1.000 0.000
#> GSM40689 1 0.0000 0.973 1.000 0.000
#> GSM40690 1 0.0000 0.973 1.000 0.000
#> GSM40692 1 0.0000 0.973 1.000 0.000
#> GSM40693 1 0.0000 0.973 1.000 0.000
#> GSM40694 1 0.0000 0.973 1.000 0.000
#> GSM40695 1 0.0000 0.973 1.000 0.000
#> GSM40696 1 0.0000 0.973 1.000 0.000
#> GSM40697 2 0.0000 0.995 0.000 1.000
#> GSM40704 1 0.0000 0.973 1.000 0.000
#> GSM40705 2 0.0000 0.995 0.000 1.000
#> GSM40707 1 0.0000 0.973 1.000 0.000
#> GSM40708 1 0.0000 0.973 1.000 0.000
#> GSM40709 1 0.9393 0.480 0.644 0.356
#> GSM40712 1 0.0000 0.973 1.000 0.000
#> GSM40713 1 0.0000 0.973 1.000 0.000
#> GSM40665 1 0.0000 0.973 1.000 0.000
#> GSM40677 2 0.0376 0.992 0.004 0.996
#> GSM40698 1 0.0000 0.973 1.000 0.000
#> GSM40701 2 0.0000 0.995 0.000 1.000
#> GSM40710 2 0.0000 0.995 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40678 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40679 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40686 2 0.0000 0.997 0.000 1.000 0.000
#> GSM40687 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40691 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40699 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40664 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40682 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40688 2 0.0000 0.997 0.000 1.000 0.000
#> GSM40702 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40706 2 0.0237 0.999 0.000 0.996 0.004
#> GSM40711 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40662 3 0.5882 0.472 0.000 0.348 0.652
#> GSM40666 3 0.0237 0.962 0.004 0.000 0.996
#> GSM40669 1 0.0237 0.987 0.996 0.004 0.000
#> GSM40670 3 0.3030 0.884 0.092 0.004 0.904
#> GSM40671 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40674 3 0.3112 0.880 0.096 0.004 0.900
#> GSM40676 3 0.0237 0.962 0.004 0.000 0.996
#> GSM40680 1 0.4796 0.718 0.780 0.220 0.000
#> GSM40681 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40684 3 0.0237 0.962 0.004 0.000 0.996
#> GSM40685 1 0.0237 0.987 0.996 0.004 0.000
#> GSM40689 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40692 1 0.0424 0.984 0.992 0.008 0.000
#> GSM40693 1 0.0237 0.987 0.996 0.004 0.000
#> GSM40694 1 0.0237 0.987 0.996 0.004 0.000
#> GSM40695 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40696 1 0.0237 0.987 0.996 0.004 0.000
#> GSM40697 2 0.0000 0.997 0.000 1.000 0.000
#> GSM40704 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40707 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40709 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40712 1 0.0237 0.987 0.996 0.004 0.000
#> GSM40713 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.997 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.988 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.964 0.000 0.000 1.000
#> GSM40710 2 0.0237 0.999 0.000 0.996 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40668 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.9452 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.9452 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.9452 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.9452 0.000 1.000 0.000 0.000
#> GSM40691 2 0.1978 0.9016 0.000 0.928 0.068 0.004
#> GSM40699 2 0.1867 0.8994 0.000 0.928 0.072 0.000
#> GSM40664 2 0.0188 0.9430 0.000 0.996 0.000 0.004
#> GSM40682 2 0.0000 0.9452 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0188 0.9439 0.000 0.996 0.000 0.004
#> GSM40702 2 0.1557 0.9112 0.000 0.944 0.056 0.000
#> GSM40706 2 0.0000 0.9452 0.000 1.000 0.000 0.000
#> GSM40711 3 0.2011 0.8819 0.000 0.000 0.920 0.080
#> GSM40661 3 0.0188 0.9089 0.000 0.000 0.996 0.004
#> GSM40662 4 0.6398 0.3690 0.000 0.080 0.344 0.576
#> GSM40666 3 0.3726 0.7910 0.000 0.000 0.788 0.212
#> GSM40669 4 0.2589 0.7073 0.116 0.000 0.000 0.884
#> GSM40670 4 0.2773 0.7257 0.028 0.000 0.072 0.900
#> GSM40671 1 0.1557 0.8122 0.944 0.000 0.000 0.056
#> GSM40672 1 0.1022 0.8205 0.968 0.000 0.000 0.032
#> GSM40673 1 0.0921 0.8216 0.972 0.000 0.000 0.028
#> GSM40674 4 0.3047 0.6979 0.012 0.000 0.116 0.872
#> GSM40676 3 0.5807 0.7004 0.132 0.000 0.708 0.160
#> GSM40680 1 0.6498 -0.0157 0.488 0.072 0.000 0.440
#> GSM40681 1 0.1637 0.8079 0.940 0.000 0.000 0.060
#> GSM40683 1 0.0921 0.8216 0.972 0.000 0.000 0.028
#> GSM40684 3 0.5800 0.7031 0.128 0.000 0.708 0.164
#> GSM40685 4 0.4999 -0.1458 0.492 0.000 0.000 0.508
#> GSM40689 1 0.1792 0.8043 0.932 0.000 0.000 0.068
#> GSM40690 1 0.0921 0.8216 0.972 0.000 0.000 0.028
#> GSM40692 1 0.4134 0.5975 0.740 0.000 0.000 0.260
#> GSM40693 1 0.4730 0.4012 0.636 0.000 0.000 0.364
#> GSM40694 1 0.4967 0.1573 0.548 0.000 0.000 0.452
#> GSM40695 1 0.0921 0.8216 0.972 0.000 0.000 0.028
#> GSM40696 1 0.4746 0.3942 0.632 0.000 0.000 0.368
#> GSM40697 2 0.5581 0.1776 0.000 0.532 0.020 0.448
#> GSM40704 1 0.1022 0.8206 0.968 0.000 0.000 0.032
#> GSM40705 3 0.2149 0.8783 0.000 0.000 0.912 0.088
#> GSM40707 1 0.1792 0.8043 0.932 0.000 0.000 0.068
#> GSM40708 1 0.1867 0.8037 0.928 0.000 0.000 0.072
#> GSM40709 3 0.3528 0.8108 0.000 0.000 0.808 0.192
#> GSM40712 4 0.3400 0.6505 0.180 0.000 0.000 0.820
#> GSM40713 1 0.1302 0.8135 0.956 0.000 0.000 0.044
#> GSM40665 1 0.1792 0.8043 0.932 0.000 0.000 0.068
#> GSM40677 2 0.0188 0.9439 0.000 0.996 0.000 0.004
#> GSM40698 1 0.1716 0.8074 0.936 0.000 0.000 0.064
#> GSM40701 3 0.0000 0.9099 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0000 0.9452 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40668 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0290 0.8907 0.000 0.992 0.000 0.008 0.000
#> GSM40679 2 0.0000 0.8902 0.000 1.000 0.000 0.000 0.000
#> GSM40686 2 0.1774 0.8552 0.000 0.932 0.000 0.052 0.016
#> GSM40687 2 0.0290 0.8907 0.000 0.992 0.000 0.008 0.000
#> GSM40691 2 0.4532 0.6183 0.000 0.672 0.304 0.020 0.004
#> GSM40699 2 0.4182 0.5541 0.000 0.644 0.352 0.004 0.000
#> GSM40664 2 0.0898 0.8800 0.000 0.972 0.008 0.020 0.000
#> GSM40682 2 0.0000 0.8902 0.000 1.000 0.000 0.000 0.000
#> GSM40688 2 0.1082 0.8827 0.000 0.964 0.000 0.028 0.008
#> GSM40702 2 0.3508 0.6893 0.000 0.748 0.252 0.000 0.000
#> GSM40706 2 0.0290 0.8905 0.000 0.992 0.000 0.008 0.000
#> GSM40711 3 0.4138 -0.0881 0.000 0.000 0.616 0.384 0.000
#> GSM40661 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40662 3 0.7470 0.0463 0.000 0.068 0.432 0.156 0.344
#> GSM40666 4 0.5874 0.5582 0.000 0.000 0.364 0.528 0.108
#> GSM40669 5 0.2069 0.6588 0.076 0.000 0.000 0.012 0.912
#> GSM40670 5 0.2989 0.6290 0.044 0.000 0.004 0.080 0.872
#> GSM40671 1 0.2513 0.7440 0.876 0.000 0.000 0.116 0.008
#> GSM40672 1 0.0609 0.7514 0.980 0.000 0.000 0.000 0.020
#> GSM40673 1 0.0290 0.7538 0.992 0.000 0.000 0.000 0.008
#> GSM40674 5 0.3835 0.5936 0.032 0.000 0.076 0.056 0.836
#> GSM40676 4 0.4179 0.6795 0.072 0.000 0.152 0.776 0.000
#> GSM40680 1 0.7680 -0.0102 0.392 0.064 0.000 0.208 0.336
#> GSM40681 1 0.2859 0.7123 0.876 0.000 0.000 0.056 0.068
#> GSM40683 1 0.0162 0.7541 0.996 0.000 0.000 0.000 0.004
#> GSM40684 4 0.4179 0.6811 0.072 0.000 0.152 0.776 0.000
#> GSM40685 5 0.5761 -0.0915 0.420 0.000 0.000 0.088 0.492
#> GSM40689 1 0.3398 0.7019 0.780 0.000 0.000 0.216 0.004
#> GSM40690 1 0.0771 0.7517 0.976 0.000 0.000 0.004 0.020
#> GSM40692 1 0.6671 0.3583 0.532 0.016 0.000 0.216 0.236
#> GSM40693 1 0.4851 0.3574 0.624 0.000 0.000 0.036 0.340
#> GSM40694 1 0.5908 0.1751 0.512 0.000 0.000 0.108 0.380
#> GSM40695 1 0.0162 0.7546 0.996 0.000 0.000 0.004 0.000
#> GSM40696 1 0.4905 0.3573 0.624 0.000 0.000 0.040 0.336
#> GSM40697 5 0.6244 0.0987 0.000 0.396 0.024 0.080 0.500
#> GSM40704 1 0.0510 0.7523 0.984 0.000 0.000 0.000 0.016
#> GSM40705 3 0.4161 -0.1178 0.000 0.000 0.608 0.392 0.000
#> GSM40707 1 0.3863 0.6863 0.740 0.000 0.000 0.248 0.012
#> GSM40708 1 0.4206 0.6692 0.708 0.000 0.000 0.272 0.020
#> GSM40709 4 0.5794 0.5376 0.000 0.000 0.384 0.520 0.096
#> GSM40712 5 0.3464 0.6362 0.096 0.000 0.000 0.068 0.836
#> GSM40713 1 0.2563 0.7428 0.872 0.000 0.000 0.120 0.008
#> GSM40665 1 0.3521 0.6957 0.764 0.000 0.000 0.232 0.004
#> GSM40677 2 0.0794 0.8847 0.000 0.972 0.000 0.028 0.000
#> GSM40698 1 0.3343 0.7272 0.812 0.000 0.000 0.172 0.016
#> GSM40701 3 0.0000 0.7987 0.000 0.000 1.000 0.000 0.000
#> GSM40710 2 0.0290 0.8900 0.000 0.992 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
#> GSM40663 3 0.0000 0.909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.0790 0.889 0.000 0.000 0.968 0.032 0.000 0.000
#> GSM40668 3 0.0000 0.909 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.0405 0.835 0.000 0.988 0.000 0.004 0.000 0.008
#> GSM40679 2 0.0520 0.834 0.000 0.984 0.000 0.008 0.000 0.008
#> GSM40686 2 0.2631 0.779 0.000 0.840 0.000 0.008 0.000 0.152
#> GSM40687 2 0.1007 0.834 0.000 0.956 0.000 0.000 0.000 0.044
#> GSM40691 2 0.5855 0.552 0.000 0.608 0.256 0.028 0.024 0.084
#> GSM40699 2 0.4530 0.370 0.000 0.552 0.420 0.012 0.000 0.016
#> GSM40664 2 0.2961 0.805 0.000 0.872 0.016 0.044 0.008 0.060
#> GSM40682 2 0.1370 0.832 0.000 0.948 0.000 0.012 0.004 0.036
#> GSM40688 2 0.2615 0.804 0.000 0.876 0.000 0.028 0.008 0.088
#> GSM40702 2 0.4152 0.623 0.000 0.700 0.264 0.012 0.000 0.024
#> GSM40706 2 0.0837 0.837 0.000 0.972 0.004 0.004 0.000 0.020
#> GSM40711 3 0.3862 -0.364 0.000 0.000 0.524 0.476 0.000 0.000
#> GSM40661 3 0.0458 0.898 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM40662 6 0.7666 -0.117 0.000 0.056 0.284 0.040 0.300 0.320
#> GSM40666 4 0.4842 0.697 0.000 0.000 0.212 0.676 0.104 0.008
#> GSM40669 5 0.1970 0.652 0.060 0.000 0.000 0.000 0.912 0.028
#> GSM40670 5 0.1176 0.672 0.024 0.000 0.000 0.020 0.956 0.000
#> GSM40671 1 0.3798 0.673 0.796 0.000 0.000 0.116 0.012 0.076
#> GSM40672 1 0.1148 0.684 0.960 0.000 0.000 0.004 0.016 0.020
#> GSM40673 1 0.0146 0.697 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM40674 5 0.2238 0.660 0.020 0.000 0.016 0.032 0.916 0.016
#> GSM40676 4 0.2022 0.640 0.024 0.000 0.052 0.916 0.000 0.008
#> GSM40680 6 0.4087 0.350 0.092 0.036 0.000 0.008 0.064 0.800
#> GSM40681 1 0.3450 0.553 0.772 0.000 0.000 0.012 0.008 0.208
#> GSM40683 1 0.0146 0.697 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM40684 4 0.2022 0.640 0.024 0.000 0.052 0.916 0.000 0.008
#> GSM40685 6 0.6350 0.222 0.332 0.000 0.000 0.012 0.264 0.392
#> GSM40689 1 0.4473 0.630 0.708 0.000 0.000 0.212 0.008 0.072
#> GSM40690 1 0.0922 0.694 0.968 0.000 0.000 0.004 0.004 0.024
#> GSM40692 6 0.5487 0.380 0.276 0.012 0.000 0.016 0.084 0.612
#> GSM40693 1 0.4741 0.350 0.688 0.000 0.000 0.012 0.216 0.084
#> GSM40694 1 0.6153 -0.277 0.444 0.000 0.000 0.012 0.200 0.344
#> GSM40695 1 0.0725 0.699 0.976 0.000 0.000 0.012 0.000 0.012
#> GSM40696 1 0.4765 0.324 0.672 0.000 0.000 0.012 0.244 0.072
#> GSM40697 5 0.6848 0.124 0.000 0.272 0.016 0.024 0.420 0.268
#> GSM40704 1 0.0820 0.690 0.972 0.000 0.000 0.000 0.016 0.012
#> GSM40705 4 0.3999 0.227 0.000 0.000 0.496 0.500 0.004 0.000
#> GSM40707 1 0.5275 0.572 0.624 0.000 0.000 0.228 0.008 0.140
#> GSM40708 1 0.5884 0.485 0.540 0.000 0.000 0.244 0.012 0.204
#> GSM40709 4 0.5068 0.682 0.000 0.000 0.236 0.644 0.112 0.008
#> GSM40712 5 0.4640 0.427 0.064 0.000 0.000 0.012 0.684 0.240
#> GSM40713 1 0.4589 0.651 0.732 0.000 0.000 0.140 0.020 0.108
#> GSM40665 1 0.4857 0.614 0.676 0.000 0.000 0.208 0.008 0.108
#> GSM40677 2 0.2890 0.795 0.000 0.844 0.000 0.024 0.004 0.128
#> GSM40698 1 0.5038 0.591 0.664 0.000 0.000 0.152 0.008 0.176
#> GSM40701 3 0.0146 0.905 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40710 2 0.1267 0.830 0.000 0.940 0.000 0.000 0.000 0.060
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:skmeans 52 2.19e-06 2
#> SD:skmeans 52 4.81e-06 3
#> SD:skmeans 46 1.10e-04 4
#> SD:skmeans 43 1.07e-05 5
#> SD:skmeans 40 4.85e-05 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "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 35373 rows and 53 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.960 0.960 0.982 0.4940 0.512 0.512
#> 3 3 0.994 0.953 0.978 0.2202 0.814 0.662
#> 4 4 0.910 0.916 0.951 0.1331 0.837 0.632
#> 5 5 0.876 0.835 0.903 0.1406 0.894 0.675
#> 6 6 0.887 0.860 0.874 0.0519 0.948 0.768
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM40663 2 0.0000 1.000 0.000 1.000
#> GSM40667 2 0.0000 1.000 0.000 1.000
#> GSM40675 2 0.0000 1.000 0.000 1.000
#> GSM40703 2 0.0000 1.000 0.000 1.000
#> GSM40660 2 0.0000 1.000 0.000 1.000
#> GSM40668 2 0.0000 1.000 0.000 1.000
#> GSM40678 2 0.0000 1.000 0.000 1.000
#> GSM40679 2 0.0000 1.000 0.000 1.000
#> GSM40686 1 0.8955 0.583 0.688 0.312
#> GSM40687 2 0.0000 1.000 0.000 1.000
#> GSM40691 2 0.0000 1.000 0.000 1.000
#> GSM40699 2 0.0000 1.000 0.000 1.000
#> GSM40664 2 0.0000 1.000 0.000 1.000
#> GSM40682 2 0.0000 1.000 0.000 1.000
#> GSM40688 2 0.0000 1.000 0.000 1.000
#> GSM40702 2 0.0000 1.000 0.000 1.000
#> GSM40706 2 0.0000 1.000 0.000 1.000
#> GSM40711 2 0.0000 1.000 0.000 1.000
#> GSM40661 2 0.0000 1.000 0.000 1.000
#> GSM40662 1 0.7376 0.749 0.792 0.208
#> GSM40666 1 0.0672 0.964 0.992 0.008
#> GSM40669 1 0.0000 0.968 1.000 0.000
#> GSM40670 1 0.0000 0.968 1.000 0.000
#> GSM40671 1 0.0000 0.968 1.000 0.000
#> GSM40672 1 0.0000 0.968 1.000 0.000
#> GSM40673 1 0.0000 0.968 1.000 0.000
#> GSM40674 1 0.0672 0.964 0.992 0.008
#> GSM40676 1 0.0672 0.964 0.992 0.008
#> GSM40680 1 0.0376 0.966 0.996 0.004
#> GSM40681 1 0.0000 0.968 1.000 0.000
#> GSM40683 1 0.0000 0.968 1.000 0.000
#> GSM40684 1 0.0000 0.968 1.000 0.000
#> GSM40685 1 0.0000 0.968 1.000 0.000
#> GSM40689 1 0.0000 0.968 1.000 0.000
#> GSM40690 1 0.0000 0.968 1.000 0.000
#> GSM40692 1 0.0000 0.968 1.000 0.000
#> GSM40693 1 0.0000 0.968 1.000 0.000
#> GSM40694 1 0.0000 0.968 1.000 0.000
#> GSM40695 1 0.0000 0.968 1.000 0.000
#> GSM40696 1 0.0000 0.968 1.000 0.000
#> GSM40697 1 0.5059 0.866 0.888 0.112
#> GSM40704 1 0.0000 0.968 1.000 0.000
#> GSM40705 1 0.8861 0.596 0.696 0.304
#> GSM40707 1 0.0000 0.968 1.000 0.000
#> GSM40708 1 0.0000 0.968 1.000 0.000
#> GSM40709 1 0.0672 0.964 0.992 0.008
#> GSM40712 1 0.0000 0.968 1.000 0.000
#> GSM40713 1 0.0000 0.968 1.000 0.000
#> GSM40665 1 0.0000 0.968 1.000 0.000
#> GSM40677 2 0.0000 1.000 0.000 1.000
#> GSM40698 1 0.0000 0.968 1.000 0.000
#> GSM40701 2 0.0000 1.000 0.000 1.000
#> GSM40710 2 0.0000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.979 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.979 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.979 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.979 0.000 0.000 1.000
#> GSM40660 2 0.2537 0.897 0.000 0.920 0.080
#> GSM40668 3 0.0000 0.979 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40699 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40664 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40682 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40702 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40706 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40711 3 0.0747 0.970 0.000 0.016 0.984
#> GSM40661 2 0.2537 0.897 0.000 0.920 0.080
#> GSM40662 2 0.1411 0.926 0.036 0.964 0.000
#> GSM40666 1 0.2537 0.918 0.920 0.000 0.080
#> GSM40669 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40670 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40671 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40674 1 0.2625 0.896 0.916 0.084 0.000
#> GSM40676 1 0.2537 0.918 0.920 0.000 0.080
#> GSM40680 1 0.0592 0.973 0.988 0.012 0.000
#> GSM40681 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40684 1 0.2537 0.918 0.920 0.000 0.080
#> GSM40685 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40689 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40692 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40693 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40696 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40697 2 0.4796 0.671 0.220 0.780 0.000
#> GSM40704 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40705 3 0.3038 0.881 0.000 0.104 0.896
#> GSM40707 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40709 1 0.2537 0.918 0.920 0.000 0.080
#> GSM40712 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40713 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.958 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.983 1.000 0.000 0.000
#> GSM40701 2 0.4399 0.776 0.000 0.812 0.188
#> GSM40710 2 0.0000 0.958 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40660 3 0.2647 0.867 0.000 0.120 0.880 0.000
#> GSM40668 3 0.2704 0.857 0.000 0.000 0.876 0.124
#> GSM40678 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40691 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40699 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40664 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40682 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40702 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40706 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40711 3 0.1940 0.887 0.000 0.000 0.924 0.076
#> GSM40661 3 0.2469 0.876 0.000 0.108 0.892 0.000
#> GSM40662 2 0.5830 0.395 0.332 0.620 0.048 0.000
#> GSM40666 3 0.1940 0.902 0.076 0.000 0.924 0.000
#> GSM40669 1 0.1389 0.920 0.952 0.000 0.048 0.000
#> GSM40670 1 0.1389 0.920 0.952 0.000 0.048 0.000
#> GSM40671 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40672 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40673 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40674 1 0.3156 0.876 0.884 0.068 0.048 0.000
#> GSM40676 3 0.1940 0.902 0.076 0.000 0.924 0.000
#> GSM40680 1 0.0336 0.944 0.992 0.008 0.000 0.000
#> GSM40681 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40683 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40684 3 0.1940 0.902 0.076 0.000 0.924 0.000
#> GSM40685 1 0.0188 0.945 0.996 0.004 0.000 0.000
#> GSM40689 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40690 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40692 1 0.0336 0.944 0.992 0.008 0.000 0.000
#> GSM40693 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40694 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40695 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40696 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40697 1 0.4790 0.403 0.620 0.380 0.000 0.000
#> GSM40704 1 0.1940 0.926 0.924 0.000 0.076 0.000
#> GSM40705 3 0.2319 0.901 0.000 0.036 0.924 0.040
#> GSM40707 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40708 1 0.0336 0.943 0.992 0.000 0.008 0.000
#> GSM40709 3 0.1940 0.902 0.076 0.000 0.924 0.000
#> GSM40712 1 0.0817 0.936 0.976 0.000 0.024 0.000
#> GSM40713 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40665 1 0.0000 0.945 1.000 0.000 0.000 0.000
#> GSM40677 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM40698 1 0.0336 0.944 0.992 0.008 0.000 0.000
#> GSM40701 3 0.2918 0.869 0.000 0.116 0.876 0.008
#> GSM40710 2 0.0000 0.960 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40667 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40675 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40703 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40660 3 0.1732 0.9053 0.000 0.080 0.920 0.000 0.000
#> GSM40668 3 0.1792 0.9011 0.000 0.000 0.916 0.084 0.000
#> GSM40678 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40686 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40687 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40691 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40699 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40664 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40682 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40688 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40702 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40706 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40711 3 0.0000 0.9575 0.000 0.000 1.000 0.000 0.000
#> GSM40661 3 0.1197 0.9346 0.000 0.048 0.952 0.000 0.000
#> GSM40662 5 0.5355 0.5113 0.000 0.292 0.084 0.000 0.624
#> GSM40666 3 0.0000 0.9575 0.000 0.000 1.000 0.000 0.000
#> GSM40669 5 0.1792 0.7289 0.000 0.000 0.084 0.000 0.916
#> GSM40670 5 0.1792 0.7289 0.000 0.000 0.084 0.000 0.916
#> GSM40671 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40672 1 0.0000 0.5917 1.000 0.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.5917 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.2889 0.7329 0.000 0.044 0.084 0.000 0.872
#> GSM40676 3 0.0000 0.9575 0.000 0.000 1.000 0.000 0.000
#> GSM40680 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40681 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40683 1 0.0000 0.5917 1.000 0.000 0.000 0.000 0.000
#> GSM40684 3 0.0000 0.9575 0.000 0.000 1.000 0.000 0.000
#> GSM40685 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40689 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40690 1 0.3561 0.0604 0.740 0.000 0.000 0.000 0.260
#> GSM40692 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40693 5 0.4138 0.5365 0.384 0.000 0.000 0.000 0.616
#> GSM40694 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40695 1 0.0000 0.5917 1.000 0.000 0.000 0.000 0.000
#> GSM40696 5 0.4138 0.5365 0.384 0.000 0.000 0.000 0.616
#> GSM40697 5 0.2732 0.6831 0.000 0.160 0.000 0.000 0.840
#> GSM40704 1 0.0000 0.5917 1.000 0.000 0.000 0.000 0.000
#> GSM40705 3 0.0000 0.9575 0.000 0.000 1.000 0.000 0.000
#> GSM40707 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40708 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40709 3 0.0000 0.9575 0.000 0.000 1.000 0.000 0.000
#> GSM40712 5 0.0609 0.6701 0.000 0.000 0.020 0.000 0.980
#> GSM40713 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40665 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40677 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM40698 1 0.4138 0.8090 0.616 0.000 0.000 0.000 0.384
#> GSM40701 3 0.1792 0.9009 0.000 0.084 0.916 0.000 0.000
#> GSM40710 2 0.0000 1.0000 0.000 1.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
#> GSM40663 3 0.0000 1.000 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1.00 0.000 0.000 0.000
#> GSM40660 4 0.0363 0.933 0.000 0.012 0.00 0.988 0.000 0.000
#> GSM40668 4 0.0547 0.929 0.000 0.000 0.02 0.980 0.000 0.000
#> GSM40678 2 0.3843 0.717 0.000 0.548 0.00 0.000 0.000 0.452
#> GSM40679 2 0.0000 0.804 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM40686 2 0.0000 0.804 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM40687 2 0.3843 0.717 0.000 0.548 0.00 0.000 0.000 0.452
#> GSM40691 2 0.4165 0.708 0.000 0.536 0.00 0.000 0.012 0.452
#> GSM40699 2 0.3843 0.717 0.000 0.548 0.00 0.000 0.000 0.452
#> GSM40664 2 0.0000 0.804 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM40682 2 0.0000 0.804 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM40688 2 0.1910 0.800 0.000 0.892 0.00 0.000 0.000 0.108
#> GSM40702 2 0.2092 0.798 0.000 0.876 0.00 0.000 0.000 0.124
#> GSM40706 2 0.0000 0.804 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM40711 4 0.0000 0.936 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM40661 4 0.0547 0.927 0.000 0.020 0.00 0.980 0.000 0.000
#> GSM40662 5 0.0000 0.861 0.000 0.000 0.00 0.000 1.000 0.000
#> GSM40666 4 0.1610 0.878 0.000 0.000 0.00 0.916 0.084 0.000
#> GSM40669 5 0.0000 0.861 0.000 0.000 0.00 0.000 1.000 0.000
#> GSM40670 5 0.0000 0.861 0.000 0.000 0.00 0.000 1.000 0.000
#> GSM40671 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40672 1 0.0000 0.875 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.875 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM40674 5 0.0000 0.861 0.000 0.000 0.00 0.000 1.000 0.000
#> GSM40676 4 0.0000 0.936 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM40680 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40681 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40683 1 0.0000 0.875 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM40684 4 0.0000 0.936 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM40685 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40689 6 0.3851 0.986 0.460 0.000 0.00 0.000 0.000 0.540
#> GSM40690 1 0.3076 0.484 0.760 0.000 0.00 0.000 0.240 0.000
#> GSM40692 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40693 5 0.3782 0.443 0.412 0.000 0.00 0.000 0.588 0.000
#> GSM40694 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40695 1 0.1267 0.777 0.940 0.000 0.00 0.000 0.000 0.060
#> GSM40696 5 0.3804 0.423 0.424 0.000 0.00 0.000 0.576 0.000
#> GSM40697 5 0.0000 0.861 0.000 0.000 0.00 0.000 1.000 0.000
#> GSM40704 1 0.0000 0.875 1.000 0.000 0.00 0.000 0.000 0.000
#> GSM40705 4 0.0000 0.936 0.000 0.000 0.00 1.000 0.000 0.000
#> GSM40707 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40708 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40709 4 0.3695 0.473 0.000 0.000 0.00 0.624 0.376 0.000
#> GSM40712 5 0.0000 0.861 0.000 0.000 0.00 0.000 1.000 0.000
#> GSM40713 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40665 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40677 2 0.0000 0.804 0.000 1.000 0.00 0.000 0.000 0.000
#> GSM40698 6 0.3843 0.999 0.452 0.000 0.00 0.000 0.000 0.548
#> GSM40701 4 0.0547 0.928 0.000 0.020 0.00 0.980 0.000 0.000
#> GSM40710 2 0.3843 0.717 0.000 0.548 0.00 0.000 0.000 0.452
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:pam 53 8.87e-08 2
#> SD:pam 53 2.00e-09 3
#> SD:pam 51 1.53e-12 4
#> SD:pam 52 3.27e-11 5
#> SD:pam 49 5.78e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 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.184 0.694 0.798 0.3103 0.826 0.826
#> 3 3 0.425 0.643 0.815 0.7460 0.589 0.502
#> 4 4 0.633 0.635 0.756 0.3063 0.798 0.568
#> 5 5 0.636 0.493 0.743 0.0977 0.830 0.517
#> 6 6 0.654 0.633 0.789 0.0330 0.843 0.420
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
#> GSM40663 2 0.6801 0.972 0.180 0.820
#> GSM40667 2 0.6801 0.972 0.180 0.820
#> GSM40675 2 0.6801 0.972 0.180 0.820
#> GSM40703 2 0.6887 0.969 0.184 0.816
#> GSM40660 1 0.9635 0.510 0.612 0.388
#> GSM40668 2 0.7883 0.885 0.236 0.764
#> GSM40678 1 0.8608 0.588 0.716 0.284
#> GSM40679 1 0.8661 0.588 0.712 0.288
#> GSM40686 1 0.8555 0.593 0.720 0.280
#> GSM40687 1 0.8608 0.588 0.716 0.284
#> GSM40691 1 0.6801 0.696 0.820 0.180
#> GSM40699 1 0.9775 0.490 0.588 0.412
#> GSM40664 1 0.8555 0.617 0.720 0.280
#> GSM40682 1 0.8327 0.617 0.736 0.264
#> GSM40688 1 0.3431 0.726 0.936 0.064
#> GSM40702 1 0.8267 0.621 0.740 0.260
#> GSM40706 1 0.8661 0.588 0.712 0.288
#> GSM40711 1 0.9635 0.510 0.612 0.388
#> GSM40661 1 0.9686 0.512 0.604 0.396
#> GSM40662 1 0.6801 0.696 0.820 0.180
#> GSM40666 1 0.7453 0.685 0.788 0.212
#> GSM40669 1 0.6801 0.696 0.820 0.180
#> GSM40670 1 0.6801 0.696 0.820 0.180
#> GSM40671 1 0.2603 0.754 0.956 0.044
#> GSM40672 1 0.4298 0.742 0.912 0.088
#> GSM40673 1 0.5178 0.689 0.884 0.116
#> GSM40674 1 0.6801 0.696 0.820 0.180
#> GSM40676 1 0.8763 0.608 0.704 0.296
#> GSM40680 1 0.1184 0.749 0.984 0.016
#> GSM40681 1 0.1184 0.749 0.984 0.016
#> GSM40683 1 0.5059 0.678 0.888 0.112
#> GSM40684 1 0.9710 0.508 0.600 0.400
#> GSM40685 1 0.0672 0.749 0.992 0.008
#> GSM40689 1 0.3431 0.755 0.936 0.064
#> GSM40690 1 0.3431 0.749 0.936 0.064
#> GSM40692 1 0.0938 0.753 0.988 0.012
#> GSM40693 1 0.6247 0.720 0.844 0.156
#> GSM40694 1 0.3114 0.752 0.944 0.056
#> GSM40695 1 0.3114 0.730 0.944 0.056
#> GSM40696 1 0.5842 0.724 0.860 0.140
#> GSM40697 1 0.6801 0.696 0.820 0.180
#> GSM40704 1 0.5408 0.690 0.876 0.124
#> GSM40705 1 0.9686 0.512 0.604 0.396
#> GSM40707 1 0.2778 0.751 0.952 0.048
#> GSM40708 1 0.2778 0.751 0.952 0.048
#> GSM40709 1 0.7376 0.686 0.792 0.208
#> GSM40712 1 0.5737 0.723 0.864 0.136
#> GSM40713 1 0.5178 0.741 0.884 0.116
#> GSM40665 1 0.4161 0.758 0.916 0.084
#> GSM40677 1 0.3431 0.726 0.936 0.064
#> GSM40698 1 0.2236 0.751 0.964 0.036
#> GSM40701 1 0.9635 0.510 0.612 0.388
#> GSM40710 1 0.8608 0.588 0.716 0.284
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0661 0.956 0.004 0.008 0.988
#> GSM40667 3 0.0661 0.956 0.004 0.008 0.988
#> GSM40675 3 0.0661 0.956 0.004 0.008 0.988
#> GSM40703 3 0.0661 0.956 0.004 0.008 0.988
#> GSM40660 2 0.9914 0.380 0.272 0.380 0.348
#> GSM40668 3 0.4413 0.797 0.036 0.104 0.860
#> GSM40678 2 0.0661 0.676 0.004 0.988 0.008
#> GSM40679 2 0.0661 0.676 0.004 0.988 0.008
#> GSM40686 2 0.1129 0.680 0.020 0.976 0.004
#> GSM40687 2 0.0661 0.676 0.004 0.988 0.008
#> GSM40691 2 0.6322 0.576 0.276 0.700 0.024
#> GSM40699 2 0.3377 0.711 0.092 0.896 0.012
#> GSM40664 2 0.5831 0.578 0.284 0.708 0.008
#> GSM40682 2 0.1170 0.682 0.016 0.976 0.008
#> GSM40688 2 0.3267 0.703 0.116 0.884 0.000
#> GSM40702 2 0.2680 0.703 0.068 0.924 0.008
#> GSM40706 2 0.1015 0.681 0.012 0.980 0.008
#> GSM40711 2 0.9906 0.388 0.272 0.388 0.340
#> GSM40661 2 0.9897 0.388 0.268 0.388 0.344
#> GSM40662 2 0.6475 0.565 0.280 0.692 0.028
#> GSM40666 1 0.7001 0.387 0.588 0.388 0.024
#> GSM40669 1 0.6721 0.412 0.604 0.380 0.016
#> GSM40670 1 0.6721 0.412 0.604 0.380 0.016
#> GSM40671 1 0.1267 0.773 0.972 0.024 0.004
#> GSM40672 1 0.0237 0.763 0.996 0.004 0.000
#> GSM40673 1 0.0000 0.760 1.000 0.000 0.000
#> GSM40674 1 0.6737 0.403 0.600 0.384 0.016
#> GSM40676 1 0.7222 0.367 0.580 0.388 0.032
#> GSM40680 2 0.6701 0.289 0.412 0.576 0.012
#> GSM40681 1 0.2280 0.780 0.940 0.052 0.008
#> GSM40683 1 0.0000 0.760 1.000 0.000 0.000
#> GSM40684 1 0.7222 0.367 0.580 0.388 0.032
#> GSM40685 1 0.4963 0.660 0.792 0.200 0.008
#> GSM40689 1 0.1399 0.775 0.968 0.028 0.004
#> GSM40690 1 0.0747 0.771 0.984 0.016 0.000
#> GSM40692 1 0.6529 0.430 0.620 0.368 0.012
#> GSM40693 1 0.1753 0.781 0.952 0.048 0.000
#> GSM40694 1 0.1753 0.781 0.952 0.048 0.000
#> GSM40695 1 0.0000 0.760 1.000 0.000 0.000
#> GSM40696 1 0.1753 0.781 0.952 0.048 0.000
#> GSM40697 2 0.6420 0.560 0.288 0.688 0.024
#> GSM40704 1 0.0000 0.760 1.000 0.000 0.000
#> GSM40705 2 0.9906 0.388 0.272 0.388 0.340
#> GSM40707 1 0.2280 0.780 0.940 0.052 0.008
#> GSM40708 1 0.2446 0.779 0.936 0.052 0.012
#> GSM40709 1 0.7001 0.387 0.588 0.388 0.024
#> GSM40712 1 0.6704 0.420 0.608 0.376 0.016
#> GSM40713 1 0.1860 0.780 0.948 0.052 0.000
#> GSM40665 1 0.1999 0.778 0.952 0.036 0.012
#> GSM40677 2 0.3267 0.703 0.116 0.884 0.000
#> GSM40698 1 0.2446 0.779 0.936 0.052 0.012
#> GSM40701 2 0.9906 0.386 0.272 0.388 0.340
#> GSM40710 2 0.0661 0.676 0.004 0.988 0.008
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.5352 1.0000 0.000 0.016 0.388 0.596
#> GSM40667 4 0.5352 1.0000 0.000 0.016 0.388 0.596
#> GSM40675 4 0.5352 1.0000 0.000 0.016 0.388 0.596
#> GSM40703 4 0.5352 1.0000 0.000 0.016 0.388 0.596
#> GSM40660 3 0.3463 0.6823 0.096 0.040 0.864 0.000
#> GSM40668 3 0.5503 -0.7185 0.000 0.016 0.516 0.468
#> GSM40678 2 0.0000 0.8836 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.8836 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0657 0.8870 0.012 0.984 0.000 0.004
#> GSM40687 2 0.0469 0.8875 0.012 0.988 0.000 0.000
#> GSM40691 2 0.6539 0.3981 0.336 0.580 0.080 0.004
#> GSM40699 2 0.1867 0.8596 0.072 0.928 0.000 0.000
#> GSM40664 2 0.3004 0.8435 0.048 0.892 0.060 0.000
#> GSM40682 2 0.0336 0.8869 0.008 0.992 0.000 0.000
#> GSM40688 2 0.2480 0.8548 0.088 0.904 0.000 0.008
#> GSM40702 2 0.0000 0.8836 0.000 1.000 0.000 0.000
#> GSM40706 2 0.0592 0.8851 0.016 0.984 0.000 0.000
#> GSM40711 3 0.2861 0.6913 0.096 0.016 0.888 0.000
#> GSM40661 3 0.3239 0.6746 0.068 0.052 0.880 0.000
#> GSM40662 1 0.8030 -0.0694 0.388 0.296 0.312 0.004
#> GSM40666 3 0.4218 0.6833 0.116 0.012 0.832 0.040
#> GSM40669 1 0.4582 0.5039 0.748 0.008 0.236 0.008
#> GSM40670 1 0.5985 -0.0436 0.504 0.008 0.464 0.024
#> GSM40671 1 0.5599 0.5885 0.672 0.000 0.052 0.276
#> GSM40672 1 0.0336 0.7308 0.992 0.000 0.008 0.000
#> GSM40673 1 0.0592 0.7292 0.984 0.000 0.016 0.000
#> GSM40674 1 0.6297 -0.0711 0.492 0.020 0.464 0.024
#> GSM40676 3 0.5626 0.4540 0.020 0.012 0.644 0.324
#> GSM40680 2 0.6722 0.4424 0.296 0.604 0.088 0.012
#> GSM40681 1 0.5034 0.6582 0.768 0.008 0.052 0.172
#> GSM40683 1 0.0779 0.7300 0.980 0.000 0.016 0.004
#> GSM40684 3 0.5626 0.4540 0.020 0.012 0.644 0.324
#> GSM40685 1 0.3174 0.6996 0.888 0.076 0.028 0.008
#> GSM40689 1 0.6422 0.5522 0.616 0.000 0.104 0.280
#> GSM40690 1 0.0336 0.7320 0.992 0.000 0.008 0.000
#> GSM40692 1 0.3387 0.7178 0.888 0.032 0.052 0.028
#> GSM40693 1 0.0469 0.7313 0.988 0.000 0.012 0.000
#> GSM40694 1 0.0804 0.7292 0.980 0.008 0.012 0.000
#> GSM40695 1 0.0804 0.7315 0.980 0.000 0.012 0.008
#> GSM40696 1 0.0469 0.7313 0.988 0.000 0.012 0.000
#> GSM40697 1 0.7960 -0.0768 0.376 0.372 0.248 0.004
#> GSM40704 1 0.0592 0.7292 0.984 0.000 0.016 0.000
#> GSM40705 3 0.2522 0.6869 0.076 0.016 0.908 0.000
#> GSM40707 1 0.7207 0.4669 0.496 0.008 0.112 0.384
#> GSM40708 1 0.7214 0.4634 0.492 0.008 0.112 0.388
#> GSM40709 3 0.4102 0.6890 0.108 0.012 0.840 0.040
#> GSM40712 1 0.2269 0.7182 0.932 0.008 0.032 0.028
#> GSM40713 1 0.2463 0.7244 0.924 0.008 0.036 0.032
#> GSM40665 1 0.6499 0.5501 0.612 0.000 0.112 0.276
#> GSM40677 2 0.2611 0.8485 0.096 0.896 0.000 0.008
#> GSM40698 1 0.6815 0.5493 0.592 0.008 0.104 0.296
#> GSM40701 3 0.6192 0.5202 0.084 0.092 0.740 0.084
#> GSM40710 2 0.0469 0.8875 0.012 0.988 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0290 0.6967 0.000 0.008 0.992 0.000 0.000
#> GSM40667 3 0.0290 0.6967 0.000 0.008 0.992 0.000 0.000
#> GSM40675 3 0.0290 0.6967 0.000 0.008 0.992 0.000 0.000
#> GSM40703 3 0.0290 0.6967 0.000 0.008 0.992 0.000 0.000
#> GSM40660 3 0.6628 0.5257 0.008 0.132 0.540 0.016 0.304
#> GSM40668 3 0.1568 0.6963 0.000 0.020 0.944 0.000 0.036
#> GSM40678 2 0.0404 0.8903 0.000 0.988 0.000 0.000 0.012
#> GSM40679 2 0.0162 0.8944 0.004 0.996 0.000 0.000 0.000
#> GSM40686 2 0.1018 0.8912 0.016 0.968 0.000 0.016 0.000
#> GSM40687 2 0.1012 0.8861 0.000 0.968 0.000 0.012 0.020
#> GSM40691 2 0.6377 0.0126 0.380 0.452 0.000 0.000 0.168
#> GSM40699 2 0.2173 0.8702 0.012 0.920 0.016 0.000 0.052
#> GSM40664 2 0.2629 0.8326 0.008 0.896 0.000 0.032 0.064
#> GSM40682 2 0.0451 0.8938 0.004 0.988 0.000 0.008 0.000
#> GSM40688 2 0.2520 0.8483 0.096 0.888 0.000 0.004 0.012
#> GSM40702 2 0.0613 0.8941 0.004 0.984 0.004 0.008 0.000
#> GSM40706 2 0.0727 0.8942 0.004 0.980 0.004 0.000 0.012
#> GSM40711 3 0.6359 0.5642 0.008 0.088 0.588 0.028 0.288
#> GSM40661 3 0.6495 0.5552 0.004 0.124 0.572 0.024 0.276
#> GSM40662 1 0.6918 -0.2770 0.380 0.284 0.000 0.004 0.332
#> GSM40666 5 0.6596 -0.2969 0.024 0.080 0.396 0.012 0.488
#> GSM40669 1 0.5247 -0.1308 0.560 0.028 0.000 0.012 0.400
#> GSM40670 5 0.5572 0.2497 0.396 0.048 0.000 0.012 0.544
#> GSM40671 5 0.7223 -0.4309 0.312 0.016 0.000 0.332 0.340
#> GSM40672 1 0.4482 0.5394 0.636 0.000 0.000 0.016 0.348
#> GSM40673 1 0.4551 0.5377 0.616 0.000 0.000 0.016 0.368
#> GSM40674 5 0.5572 0.2497 0.396 0.048 0.000 0.012 0.544
#> GSM40676 4 0.6034 0.4338 0.000 0.092 0.020 0.588 0.300
#> GSM40680 2 0.4255 0.7519 0.020 0.800 0.000 0.112 0.068
#> GSM40681 1 0.6738 0.3721 0.452 0.004 0.000 0.236 0.308
#> GSM40683 1 0.4551 0.5377 0.616 0.000 0.000 0.016 0.368
#> GSM40684 4 0.6069 0.4333 0.000 0.088 0.024 0.588 0.300
#> GSM40685 1 0.5508 0.4305 0.692 0.052 0.000 0.052 0.204
#> GSM40689 4 0.4063 0.6554 0.204 0.016 0.004 0.768 0.008
#> GSM40690 1 0.4599 0.5387 0.624 0.000 0.000 0.020 0.356
#> GSM40692 5 0.8157 -0.0518 0.216 0.292 0.000 0.120 0.372
#> GSM40693 1 0.0794 0.4081 0.972 0.000 0.000 0.000 0.028
#> GSM40694 1 0.1267 0.4072 0.960 0.004 0.000 0.024 0.012
#> GSM40695 1 0.4613 0.5389 0.620 0.000 0.000 0.020 0.360
#> GSM40696 1 0.0794 0.4081 0.972 0.000 0.000 0.000 0.028
#> GSM40697 1 0.6758 -0.2709 0.392 0.272 0.000 0.000 0.336
#> GSM40704 1 0.4551 0.5377 0.616 0.000 0.000 0.016 0.368
#> GSM40705 3 0.6369 0.5557 0.004 0.088 0.576 0.032 0.300
#> GSM40707 4 0.0324 0.6787 0.004 0.004 0.000 0.992 0.000
#> GSM40708 4 0.0324 0.6787 0.004 0.004 0.000 0.992 0.000
#> GSM40709 5 0.6673 -0.2877 0.024 0.088 0.388 0.012 0.488
#> GSM40712 1 0.5299 -0.0380 0.612 0.016 0.000 0.036 0.336
#> GSM40713 1 0.7220 0.3547 0.384 0.028 0.000 0.208 0.380
#> GSM40665 4 0.3907 0.6559 0.204 0.016 0.000 0.772 0.008
#> GSM40677 2 0.1934 0.8781 0.052 0.928 0.000 0.004 0.016
#> GSM40698 4 0.4620 0.6684 0.168 0.024 0.000 0.760 0.048
#> GSM40701 3 0.5832 0.6047 0.012 0.136 0.676 0.012 0.164
#> GSM40710 2 0.1012 0.8861 0.000 0.968 0.000 0.012 0.020
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0260 0.9069 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40667 3 0.0260 0.9069 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40675 3 0.0260 0.9069 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40703 3 0.0260 0.9069 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40660 4 0.5238 0.6829 0.000 0.168 0.120 0.676 0.036 0.000
#> GSM40668 3 0.3710 0.4645 0.000 0.012 0.696 0.292 0.000 0.000
#> GSM40678 2 0.0862 0.8547 0.004 0.972 0.000 0.016 0.008 0.000
#> GSM40679 2 0.0146 0.8597 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM40686 2 0.1477 0.8493 0.000 0.940 0.000 0.008 0.048 0.004
#> GSM40687 2 0.0820 0.8495 0.000 0.972 0.000 0.016 0.012 0.000
#> GSM40691 2 0.3633 0.7845 0.000 0.800 0.000 0.076 0.120 0.004
#> GSM40699 2 0.3387 0.8111 0.000 0.836 0.028 0.092 0.044 0.000
#> GSM40664 2 0.3441 0.7825 0.004 0.832 0.000 0.060 0.092 0.012
#> GSM40682 2 0.0951 0.8616 0.004 0.968 0.000 0.008 0.020 0.000
#> GSM40688 2 0.2380 0.8491 0.004 0.900 0.004 0.064 0.024 0.004
#> GSM40702 2 0.1092 0.8616 0.000 0.960 0.000 0.020 0.020 0.000
#> GSM40706 2 0.0806 0.8628 0.000 0.972 0.000 0.020 0.008 0.000
#> GSM40711 4 0.2618 0.7381 0.000 0.024 0.116 0.860 0.000 0.000
#> GSM40661 4 0.5178 0.6879 0.000 0.164 0.124 0.680 0.032 0.000
#> GSM40662 2 0.6119 0.2286 0.000 0.464 0.004 0.220 0.308 0.004
#> GSM40666 4 0.2382 0.7427 0.000 0.020 0.024 0.904 0.048 0.004
#> GSM40669 5 0.3677 0.5031 0.068 0.008 0.000 0.124 0.800 0.000
#> GSM40670 5 0.3512 0.4571 0.000 0.008 0.000 0.272 0.720 0.000
#> GSM40671 6 0.3390 0.7033 0.296 0.000 0.000 0.000 0.000 0.704
#> GSM40672 1 0.3714 0.5423 0.656 0.000 0.000 0.004 0.340 0.000
#> GSM40673 1 0.0363 0.6660 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40674 5 0.3564 0.4602 0.000 0.012 0.000 0.264 0.724 0.000
#> GSM40676 4 0.3780 0.6424 0.000 0.020 0.000 0.728 0.004 0.248
#> GSM40680 5 0.5676 0.0657 0.000 0.436 0.000 0.044 0.464 0.056
#> GSM40681 5 0.6091 0.2221 0.224 0.004 0.000 0.008 0.504 0.260
#> GSM40683 1 0.0146 0.6584 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM40684 4 0.3780 0.6424 0.000 0.020 0.000 0.728 0.004 0.248
#> GSM40685 5 0.5666 0.4383 0.172 0.108 0.000 0.028 0.664 0.028
#> GSM40689 6 0.3126 0.7516 0.248 0.000 0.000 0.000 0.000 0.752
#> GSM40690 1 0.4264 0.4808 0.604 0.000 0.000 0.008 0.376 0.012
#> GSM40692 5 0.5925 0.5027 0.032 0.204 0.000 0.048 0.640 0.076
#> GSM40693 1 0.4509 0.4226 0.524 0.000 0.004 0.016 0.452 0.004
#> GSM40694 5 0.4572 0.0697 0.348 0.004 0.000 0.020 0.616 0.012
#> GSM40695 1 0.0260 0.6576 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM40696 1 0.4512 0.4133 0.520 0.000 0.004 0.016 0.456 0.004
#> GSM40697 2 0.5457 0.3500 0.000 0.544 0.000 0.124 0.328 0.004
#> GSM40704 1 0.0547 0.6650 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM40705 4 0.2715 0.7410 0.000 0.024 0.112 0.860 0.004 0.000
#> GSM40707 6 0.0405 0.7376 0.008 0.000 0.000 0.000 0.004 0.988
#> GSM40708 6 0.0551 0.7366 0.008 0.000 0.000 0.004 0.004 0.984
#> GSM40709 4 0.2382 0.7427 0.000 0.020 0.024 0.904 0.048 0.004
#> GSM40712 5 0.3361 0.5328 0.052 0.016 0.000 0.072 0.848 0.012
#> GSM40713 5 0.6593 0.0239 0.316 0.012 0.000 0.012 0.412 0.248
#> GSM40665 6 0.3329 0.7627 0.220 0.000 0.000 0.004 0.008 0.768
#> GSM40677 2 0.2237 0.8495 0.000 0.904 0.004 0.064 0.024 0.004
#> GSM40698 6 0.4839 0.4314 0.028 0.016 0.000 0.012 0.304 0.640
#> GSM40701 4 0.6389 0.4433 0.000 0.240 0.256 0.476 0.028 0.000
#> GSM40710 2 0.0914 0.8492 0.000 0.968 0.000 0.016 0.016 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:mclust 52 5.53e-08 2
#> SD:mclust 38 2.09e-08 3
#> SD:mclust 42 7.75e-10 4
#> SD:mclust 34 1.39e-03 5
#> SD:mclust 38 3.83e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.920 0.908 0.965 0.5066 0.492 0.492
#> 3 3 0.802 0.852 0.937 0.3176 0.730 0.503
#> 4 4 0.856 0.869 0.940 0.1294 0.843 0.567
#> 5 5 0.729 0.702 0.846 0.0374 0.972 0.893
#> 6 6 0.696 0.527 0.746 0.0403 0.858 0.508
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
#> GSM40663 2 0.0000 0.9552 0.000 1.000
#> GSM40667 2 0.0000 0.9552 0.000 1.000
#> GSM40675 2 0.0000 0.9552 0.000 1.000
#> GSM40703 2 0.0000 0.9552 0.000 1.000
#> GSM40660 2 0.0000 0.9552 0.000 1.000
#> GSM40668 2 0.0000 0.9552 0.000 1.000
#> GSM40678 2 0.0000 0.9552 0.000 1.000
#> GSM40679 2 0.0000 0.9552 0.000 1.000
#> GSM40686 2 0.9993 0.0628 0.484 0.516
#> GSM40687 2 0.0000 0.9552 0.000 1.000
#> GSM40691 2 0.0000 0.9552 0.000 1.000
#> GSM40699 2 0.0000 0.9552 0.000 1.000
#> GSM40664 2 0.0000 0.9552 0.000 1.000
#> GSM40682 2 0.0000 0.9552 0.000 1.000
#> GSM40688 2 0.0000 0.9552 0.000 1.000
#> GSM40702 2 0.0000 0.9552 0.000 1.000
#> GSM40706 2 0.0000 0.9552 0.000 1.000
#> GSM40711 2 0.0000 0.9552 0.000 1.000
#> GSM40661 2 0.0000 0.9552 0.000 1.000
#> GSM40662 2 0.0000 0.9552 0.000 1.000
#> GSM40666 2 0.9710 0.3363 0.400 0.600
#> GSM40669 1 0.0376 0.9642 0.996 0.004
#> GSM40670 1 0.9286 0.4572 0.656 0.344
#> GSM40671 1 0.0000 0.9675 1.000 0.000
#> GSM40672 1 0.0000 0.9675 1.000 0.000
#> GSM40673 1 0.0000 0.9675 1.000 0.000
#> GSM40674 2 0.6973 0.7509 0.188 0.812
#> GSM40676 1 0.9129 0.5000 0.672 0.328
#> GSM40680 1 0.0000 0.9675 1.000 0.000
#> GSM40681 1 0.0000 0.9675 1.000 0.000
#> GSM40683 1 0.0000 0.9675 1.000 0.000
#> GSM40684 1 0.3114 0.9147 0.944 0.056
#> GSM40685 1 0.0000 0.9675 1.000 0.000
#> GSM40689 1 0.0000 0.9675 1.000 0.000
#> GSM40690 1 0.0000 0.9675 1.000 0.000
#> GSM40692 1 0.0000 0.9675 1.000 0.000
#> GSM40693 1 0.0000 0.9675 1.000 0.000
#> GSM40694 1 0.0000 0.9675 1.000 0.000
#> GSM40695 1 0.0000 0.9675 1.000 0.000
#> GSM40696 1 0.0000 0.9675 1.000 0.000
#> GSM40697 2 0.0000 0.9552 0.000 1.000
#> GSM40704 1 0.0000 0.9675 1.000 0.000
#> GSM40705 2 0.0000 0.9552 0.000 1.000
#> GSM40707 1 0.0000 0.9675 1.000 0.000
#> GSM40708 1 0.0000 0.9675 1.000 0.000
#> GSM40709 2 0.3879 0.8857 0.076 0.924
#> GSM40712 1 0.0000 0.9675 1.000 0.000
#> GSM40713 1 0.0000 0.9675 1.000 0.000
#> GSM40665 1 0.0000 0.9675 1.000 0.000
#> GSM40677 2 0.0000 0.9552 0.000 1.000
#> GSM40698 1 0.0000 0.9675 1.000 0.000
#> GSM40701 2 0.0000 0.9552 0.000 1.000
#> GSM40710 2 0.0000 0.9552 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40691 2 0.2448 0.844 0.000 0.924 0.076
#> GSM40699 2 0.6045 0.412 0.000 0.620 0.380
#> GSM40664 2 0.5678 0.545 0.000 0.684 0.316
#> GSM40682 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40702 2 0.1031 0.875 0.000 0.976 0.024
#> GSM40706 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40711 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40662 3 0.6126 0.239 0.000 0.400 0.600
#> GSM40666 3 0.3619 0.819 0.136 0.000 0.864
#> GSM40669 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40670 1 0.6140 0.221 0.596 0.000 0.404
#> GSM40671 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40674 3 0.3412 0.830 0.124 0.000 0.876
#> GSM40676 3 0.5058 0.701 0.244 0.000 0.756
#> GSM40680 2 0.1289 0.870 0.032 0.968 0.000
#> GSM40681 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40684 3 0.5465 0.630 0.288 0.000 0.712
#> GSM40685 2 0.6154 0.357 0.408 0.592 0.000
#> GSM40689 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40692 2 0.5760 0.547 0.328 0.672 0.000
#> GSM40693 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40696 1 0.1031 0.951 0.976 0.024 0.000
#> GSM40697 2 0.3966 0.817 0.024 0.876 0.100
#> GSM40704 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40707 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40709 3 0.0424 0.903 0.008 0.000 0.992
#> GSM40712 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40713 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.884 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.975 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.907 0.000 0.000 1.000
#> GSM40710 2 0.0000 0.884 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40668 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40691 2 0.5535 0.552 0.040 0.656 0.304 0.000
#> GSM40699 2 0.3907 0.704 0.000 0.768 0.232 0.000
#> GSM40664 2 0.4990 0.498 0.008 0.640 0.000 0.352
#> GSM40682 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0592 0.914 0.016 0.984 0.000 0.000
#> GSM40702 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40706 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40711 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40661 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40662 3 0.2611 0.881 0.096 0.008 0.896 0.000
#> GSM40666 3 0.0469 0.978 0.012 0.000 0.988 0.000
#> GSM40669 1 0.0000 0.892 1.000 0.000 0.000 0.000
#> GSM40670 1 0.2408 0.828 0.896 0.000 0.104 0.000
#> GSM40671 4 0.1022 0.914 0.032 0.000 0.000 0.968
#> GSM40672 1 0.0188 0.893 0.996 0.000 0.000 0.004
#> GSM40673 1 0.1637 0.873 0.940 0.000 0.000 0.060
#> GSM40674 1 0.4761 0.422 0.628 0.000 0.372 0.000
#> GSM40676 4 0.0592 0.915 0.000 0.000 0.016 0.984
#> GSM40680 2 0.0188 0.921 0.000 0.996 0.000 0.004
#> GSM40681 4 0.5833 0.106 0.440 0.032 0.000 0.528
#> GSM40683 1 0.2216 0.852 0.908 0.000 0.000 0.092
#> GSM40684 4 0.0592 0.915 0.000 0.000 0.016 0.984
#> GSM40685 1 0.3219 0.766 0.836 0.164 0.000 0.000
#> GSM40689 4 0.1302 0.905 0.044 0.000 0.000 0.956
#> GSM40690 1 0.0817 0.889 0.976 0.000 0.000 0.024
#> GSM40692 2 0.1940 0.870 0.000 0.924 0.000 0.076
#> GSM40693 1 0.0188 0.893 0.996 0.000 0.000 0.004
#> GSM40694 1 0.0336 0.893 0.992 0.000 0.000 0.008
#> GSM40695 1 0.3356 0.771 0.824 0.000 0.000 0.176
#> GSM40696 1 0.0336 0.890 0.992 0.000 0.000 0.008
#> GSM40697 1 0.2773 0.840 0.900 0.028 0.072 0.000
#> GSM40704 1 0.0336 0.893 0.992 0.000 0.000 0.008
#> GSM40705 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40707 4 0.0336 0.922 0.008 0.000 0.000 0.992
#> GSM40708 4 0.0336 0.922 0.008 0.000 0.000 0.992
#> GSM40709 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40712 1 0.0524 0.893 0.988 0.004 0.000 0.008
#> GSM40713 1 0.4250 0.626 0.724 0.000 0.000 0.276
#> GSM40665 4 0.0336 0.922 0.008 0.000 0.000 0.992
#> GSM40677 2 0.0000 0.923 0.000 1.000 0.000 0.000
#> GSM40698 4 0.1059 0.916 0.012 0.016 0.000 0.972
#> GSM40701 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0000 0.923 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.2338 0.8550 0.000 0.004 0.884 0.112 0.000
#> GSM40668 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0162 0.7793 0.000 0.996 0.000 0.004 0.000
#> GSM40679 2 0.1732 0.7591 0.000 0.920 0.000 0.080 0.000
#> GSM40686 2 0.0880 0.7744 0.000 0.968 0.000 0.032 0.000
#> GSM40687 2 0.0880 0.7744 0.000 0.968 0.000 0.032 0.000
#> GSM40691 2 0.6672 0.2179 0.000 0.552 0.288 0.116 0.044
#> GSM40699 2 0.6067 0.2179 0.000 0.560 0.276 0.164 0.000
#> GSM40664 4 0.5608 0.0000 0.172 0.188 0.000 0.640 0.000
#> GSM40682 2 0.3563 0.6347 0.012 0.780 0.000 0.208 0.000
#> GSM40688 2 0.3264 0.6906 0.000 0.820 0.000 0.164 0.016
#> GSM40702 2 0.0404 0.7796 0.000 0.988 0.000 0.012 0.000
#> GSM40706 2 0.0404 0.7784 0.000 0.988 0.000 0.012 0.000
#> GSM40711 3 0.0162 0.9361 0.000 0.000 0.996 0.004 0.000
#> GSM40661 3 0.2770 0.8309 0.008 0.004 0.864 0.124 0.000
#> GSM40662 3 0.5584 0.3794 0.000 0.012 0.592 0.060 0.336
#> GSM40666 3 0.0162 0.9347 0.000 0.000 0.996 0.000 0.004
#> GSM40669 5 0.0932 0.7510 0.004 0.000 0.004 0.020 0.972
#> GSM40670 5 0.3160 0.6394 0.000 0.000 0.188 0.004 0.808
#> GSM40671 1 0.3760 0.7833 0.784 0.000 0.000 0.188 0.028
#> GSM40672 5 0.1628 0.7547 0.056 0.000 0.000 0.008 0.936
#> GSM40673 5 0.3934 0.6779 0.276 0.000 0.000 0.008 0.716
#> GSM40674 5 0.4305 0.0897 0.000 0.000 0.488 0.000 0.512
#> GSM40676 1 0.2966 0.7903 0.816 0.000 0.000 0.184 0.000
#> GSM40680 2 0.4780 0.3705 0.016 0.660 0.000 0.308 0.016
#> GSM40681 5 0.7008 0.4536 0.292 0.104 0.000 0.076 0.528
#> GSM40683 5 0.3809 0.6918 0.256 0.000 0.000 0.008 0.736
#> GSM40684 1 0.1300 0.7930 0.956 0.000 0.028 0.016 0.000
#> GSM40685 5 0.5753 0.2350 0.004 0.360 0.000 0.084 0.552
#> GSM40689 1 0.1357 0.7588 0.948 0.000 0.000 0.004 0.048
#> GSM40690 5 0.4972 0.6486 0.260 0.000 0.000 0.068 0.672
#> GSM40692 2 0.2757 0.7230 0.072 0.888 0.000 0.032 0.008
#> GSM40693 5 0.0880 0.7487 0.000 0.000 0.000 0.032 0.968
#> GSM40694 5 0.1251 0.7514 0.008 0.000 0.000 0.036 0.956
#> GSM40695 5 0.3530 0.7170 0.204 0.000 0.000 0.012 0.784
#> GSM40696 5 0.1270 0.7441 0.000 0.000 0.000 0.052 0.948
#> GSM40697 5 0.3947 0.6860 0.000 0.068 0.052 0.048 0.832
#> GSM40704 5 0.2583 0.7437 0.132 0.000 0.000 0.004 0.864
#> GSM40705 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40707 1 0.3720 0.7659 0.760 0.000 0.000 0.228 0.012
#> GSM40708 1 0.3783 0.7458 0.740 0.000 0.000 0.252 0.008
#> GSM40709 3 0.0000 0.9376 0.000 0.000 1.000 0.000 0.000
#> GSM40712 5 0.1809 0.7472 0.012 0.000 0.000 0.060 0.928
#> GSM40713 5 0.5543 0.5367 0.224 0.000 0.000 0.136 0.640
#> GSM40665 1 0.1043 0.7867 0.960 0.000 0.000 0.040 0.000
#> GSM40677 2 0.3163 0.6994 0.000 0.824 0.000 0.164 0.012
#> GSM40698 1 0.2381 0.7611 0.908 0.052 0.000 0.036 0.004
#> GSM40701 3 0.0404 0.9320 0.000 0.000 0.988 0.012 0.000
#> GSM40710 2 0.0880 0.7744 0.000 0.968 0.000 0.032 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.1838 0.8460 0.000 0.000 0.916 0.068 0.016 0.000
#> GSM40668 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.1720 0.6687 0.000 0.928 0.000 0.040 0.032 0.000
#> GSM40679 2 0.2703 0.6359 0.000 0.824 0.000 0.172 0.004 0.000
#> GSM40686 2 0.0146 0.6687 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM40687 2 0.1074 0.6665 0.000 0.960 0.000 0.012 0.028 0.000
#> GSM40691 3 0.7672 -0.2589 0.000 0.244 0.308 0.248 0.200 0.000
#> GSM40699 2 0.5961 0.2897 0.000 0.524 0.284 0.176 0.016 0.000
#> GSM40664 4 0.4452 0.0000 0.032 0.024 0.000 0.696 0.000 0.248
#> GSM40682 2 0.3925 0.5355 0.004 0.700 0.000 0.280 0.004 0.012
#> GSM40688 2 0.5418 0.3705 0.000 0.508 0.000 0.368 0.124 0.000
#> GSM40702 2 0.1285 0.6703 0.000 0.944 0.000 0.052 0.004 0.000
#> GSM40706 2 0.1723 0.6653 0.004 0.932 0.004 0.048 0.012 0.000
#> GSM40711 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40661 3 0.2870 0.7852 0.004 0.004 0.860 0.100 0.000 0.032
#> GSM40662 5 0.5144 0.4527 0.040 0.008 0.236 0.032 0.676 0.008
#> GSM40666 3 0.1387 0.8426 0.068 0.000 0.932 0.000 0.000 0.000
#> GSM40669 5 0.3578 0.6520 0.340 0.000 0.000 0.000 0.660 0.000
#> GSM40670 5 0.5851 0.4527 0.220 0.000 0.304 0.000 0.476 0.000
#> GSM40671 6 0.3490 0.4850 0.268 0.000 0.000 0.000 0.008 0.724
#> GSM40672 1 0.3737 -0.0569 0.608 0.000 0.000 0.000 0.392 0.000
#> GSM40673 1 0.0458 0.6121 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM40674 3 0.4270 0.5810 0.156 0.000 0.740 0.004 0.100 0.000
#> GSM40676 6 0.2910 0.4971 0.080 0.000 0.000 0.068 0.000 0.852
#> GSM40680 2 0.6916 0.0182 0.008 0.392 0.000 0.036 0.288 0.276
#> GSM40681 1 0.5461 0.4386 0.692 0.108 0.000 0.048 0.136 0.016
#> GSM40683 1 0.1584 0.6051 0.928 0.000 0.000 0.000 0.064 0.008
#> GSM40684 6 0.5069 0.4389 0.376 0.000 0.020 0.044 0.000 0.560
#> GSM40685 2 0.5945 0.3077 0.036 0.532 0.000 0.072 0.348 0.012
#> GSM40689 1 0.4151 0.0749 0.684 0.000 0.000 0.040 0.000 0.276
#> GSM40690 1 0.3019 0.5646 0.860 0.000 0.000 0.080 0.036 0.024
#> GSM40692 2 0.7241 0.1913 0.008 0.412 0.000 0.096 0.308 0.176
#> GSM40693 5 0.3482 0.6713 0.316 0.000 0.000 0.000 0.684 0.000
#> GSM40694 5 0.4271 0.6615 0.304 0.000 0.000 0.020 0.664 0.012
#> GSM40695 1 0.3794 0.4609 0.744 0.000 0.000 0.000 0.216 0.040
#> GSM40696 5 0.3756 0.6741 0.268 0.000 0.000 0.020 0.712 0.000
#> GSM40697 5 0.6602 0.3447 0.064 0.156 0.052 0.124 0.604 0.000
#> GSM40704 1 0.3050 0.4173 0.764 0.000 0.000 0.000 0.236 0.000
#> GSM40705 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40707 6 0.1812 0.5249 0.080 0.000 0.000 0.008 0.000 0.912
#> GSM40708 6 0.0725 0.4683 0.012 0.000 0.000 0.012 0.000 0.976
#> GSM40709 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40712 5 0.3766 0.6372 0.304 0.000 0.000 0.000 0.684 0.012
#> GSM40713 6 0.6143 0.1264 0.308 0.000 0.000 0.016 0.196 0.480
#> GSM40665 6 0.5240 0.4022 0.348 0.000 0.000 0.108 0.000 0.544
#> GSM40677 2 0.5997 0.2901 0.004 0.468 0.000 0.224 0.304 0.000
#> GSM40698 1 0.6539 -0.1498 0.528 0.032 0.000 0.112 0.036 0.292
#> GSM40701 3 0.0000 0.8938 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40710 2 0.1442 0.6553 0.004 0.944 0.000 0.040 0.012 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:NMF 50 5.44e-05 2
#> SD:NMF 49 1.95e-04 3
#> SD:NMF 50 5.28e-05 4
#> SD:NMF 45 8.26e-05 5
#> SD:NMF 30 8.30e-02 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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.389 0.876 0.904 0.4634 0.495 0.495
#> 3 3 0.462 0.785 0.882 0.3201 0.878 0.754
#> 4 4 0.505 0.697 0.780 0.1353 0.929 0.809
#> 5 5 0.551 0.749 0.766 0.1038 0.896 0.656
#> 6 6 0.736 0.785 0.830 0.0637 0.948 0.753
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
#> GSM40663 2 0.0000 0.889 0.000 1.000
#> GSM40667 2 0.0000 0.889 0.000 1.000
#> GSM40675 2 0.0000 0.889 0.000 1.000
#> GSM40703 2 0.0000 0.889 0.000 1.000
#> GSM40660 2 0.2778 0.919 0.048 0.952
#> GSM40668 2 0.0000 0.889 0.000 1.000
#> GSM40678 2 0.4690 0.937 0.100 0.900
#> GSM40679 2 0.4815 0.935 0.104 0.896
#> GSM40686 2 0.4690 0.937 0.100 0.900
#> GSM40687 2 0.4690 0.937 0.100 0.900
#> GSM40691 2 0.4690 0.937 0.100 0.900
#> GSM40699 2 0.4690 0.937 0.100 0.900
#> GSM40664 2 0.4939 0.932 0.108 0.892
#> GSM40682 2 0.4815 0.935 0.104 0.896
#> GSM40688 2 0.4939 0.934 0.108 0.892
#> GSM40702 2 0.4690 0.937 0.100 0.900
#> GSM40706 2 0.2778 0.918 0.048 0.952
#> GSM40711 2 0.3114 0.921 0.056 0.944
#> GSM40661 2 0.4690 0.934 0.100 0.900
#> GSM40662 2 0.8763 0.652 0.296 0.704
#> GSM40666 2 0.5178 0.925 0.116 0.884
#> GSM40669 1 0.7528 0.794 0.784 0.216
#> GSM40670 1 0.7528 0.794 0.784 0.216
#> GSM40671 1 0.0000 0.890 1.000 0.000
#> GSM40672 1 0.0000 0.890 1.000 0.000
#> GSM40673 1 0.0000 0.890 1.000 0.000
#> GSM40674 1 0.7453 0.799 0.788 0.212
#> GSM40676 2 0.8443 0.751 0.272 0.728
#> GSM40680 1 0.8207 0.735 0.744 0.256
#> GSM40681 1 0.5519 0.865 0.872 0.128
#> GSM40683 1 0.0000 0.890 1.000 0.000
#> GSM40684 2 0.8443 0.751 0.272 0.728
#> GSM40685 1 0.6247 0.850 0.844 0.156
#> GSM40689 1 0.0000 0.890 1.000 0.000
#> GSM40690 1 0.1184 0.891 0.984 0.016
#> GSM40692 1 0.9522 0.481 0.628 0.372
#> GSM40693 1 0.2948 0.889 0.948 0.052
#> GSM40694 1 0.7219 0.809 0.800 0.200
#> GSM40695 1 0.0000 0.890 1.000 0.000
#> GSM40696 1 0.2948 0.889 0.948 0.052
#> GSM40697 2 0.5059 0.932 0.112 0.888
#> GSM40704 1 0.0000 0.890 1.000 0.000
#> GSM40705 2 0.4562 0.933 0.096 0.904
#> GSM40707 1 0.0000 0.890 1.000 0.000
#> GSM40708 1 0.0376 0.890 0.996 0.004
#> GSM40709 2 0.5294 0.923 0.120 0.880
#> GSM40712 1 0.6801 0.830 0.820 0.180
#> GSM40713 1 0.0000 0.890 1.000 0.000
#> GSM40665 1 0.4298 0.881 0.912 0.088
#> GSM40677 2 0.4690 0.937 0.100 0.900
#> GSM40698 1 0.5294 0.869 0.880 0.120
#> GSM40701 2 0.2603 0.917 0.044 0.956
#> GSM40710 2 0.4690 0.937 0.100 0.900
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.8748 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.8748 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.8748 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.8748 0.000 0.000 1.000
#> GSM40660 3 0.3826 0.7930 0.008 0.124 0.868
#> GSM40668 3 0.0000 0.8748 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40679 2 0.0237 0.8829 0.004 0.996 0.000
#> GSM40686 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40699 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40664 2 0.4209 0.8240 0.020 0.860 0.120
#> GSM40682 2 0.0237 0.8829 0.004 0.996 0.000
#> GSM40688 2 0.0424 0.8817 0.008 0.992 0.000
#> GSM40702 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40706 2 0.3755 0.8162 0.008 0.872 0.120
#> GSM40711 3 0.6819 -0.0903 0.012 0.476 0.512
#> GSM40661 2 0.4195 0.8147 0.012 0.852 0.136
#> GSM40662 2 0.5891 0.6576 0.200 0.764 0.036
#> GSM40666 2 0.5467 0.7710 0.032 0.792 0.176
#> GSM40669 1 0.5873 0.7072 0.684 0.312 0.004
#> GSM40670 1 0.5873 0.7072 0.684 0.312 0.004
#> GSM40671 1 0.0237 0.8313 0.996 0.004 0.000
#> GSM40672 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40674 1 0.5845 0.7125 0.688 0.308 0.004
#> GSM40676 2 0.7816 0.6406 0.200 0.668 0.132
#> GSM40680 1 0.5882 0.6545 0.652 0.348 0.000
#> GSM40681 1 0.4002 0.8217 0.840 0.160 0.000
#> GSM40683 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40684 2 0.7816 0.6406 0.200 0.668 0.132
#> GSM40685 1 0.5178 0.7704 0.744 0.256 0.000
#> GSM40689 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40690 1 0.1163 0.8343 0.972 0.028 0.000
#> GSM40692 1 0.6295 0.3909 0.528 0.472 0.000
#> GSM40693 1 0.3879 0.8251 0.848 0.152 0.000
#> GSM40694 1 0.5560 0.7225 0.700 0.300 0.000
#> GSM40695 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40696 1 0.3879 0.8251 0.848 0.152 0.000
#> GSM40697 2 0.0592 0.8797 0.012 0.988 0.000
#> GSM40704 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40705 2 0.6473 0.5363 0.016 0.652 0.332
#> GSM40707 1 0.0000 0.8303 1.000 0.000 0.000
#> GSM40708 1 0.0237 0.8315 0.996 0.004 0.000
#> GSM40709 2 0.5412 0.7751 0.032 0.796 0.172
#> GSM40712 1 0.5588 0.7460 0.720 0.276 0.004
#> GSM40713 1 0.0237 0.8313 0.996 0.004 0.000
#> GSM40665 1 0.3267 0.8337 0.884 0.116 0.000
#> GSM40677 2 0.0000 0.8835 0.000 1.000 0.000
#> GSM40698 1 0.3941 0.8244 0.844 0.156 0.000
#> GSM40701 3 0.3851 0.7990 0.004 0.136 0.860
#> GSM40710 2 0.0000 0.8835 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 0.8552 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 0.8552 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 0.8552 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 0.8552 0.000 0.000 0.000 1.000
#> GSM40660 4 0.3966 0.7352 0.000 0.072 0.088 0.840
#> GSM40668 4 0.0000 0.8552 0.000 0.000 0.000 1.000
#> GSM40678 2 0.0188 0.7616 0.000 0.996 0.004 0.000
#> GSM40679 2 0.0188 0.7610 0.004 0.996 0.000 0.000
#> GSM40686 2 0.4304 0.6459 0.000 0.716 0.284 0.000
#> GSM40687 2 0.4277 0.6466 0.000 0.720 0.280 0.000
#> GSM40691 2 0.0188 0.7616 0.000 0.996 0.004 0.000
#> GSM40699 2 0.0188 0.7616 0.000 0.996 0.004 0.000
#> GSM40664 3 0.6278 0.7544 0.004 0.424 0.524 0.048
#> GSM40682 2 0.0188 0.7610 0.004 0.996 0.000 0.000
#> GSM40688 2 0.1022 0.7484 0.000 0.968 0.032 0.000
#> GSM40702 2 0.0000 0.7619 0.000 1.000 0.000 0.000
#> GSM40706 2 0.4857 0.1812 0.000 0.668 0.324 0.008
#> GSM40711 4 0.7566 -0.2459 0.000 0.212 0.320 0.468
#> GSM40661 3 0.6354 0.7711 0.000 0.416 0.520 0.064
#> GSM40662 2 0.7473 -0.0633 0.180 0.580 0.220 0.020
#> GSM40666 3 0.6982 0.8070 0.004 0.380 0.512 0.104
#> GSM40669 1 0.7282 0.6496 0.560 0.200 0.236 0.004
#> GSM40670 1 0.7282 0.6496 0.560 0.200 0.236 0.004
#> GSM40671 1 0.0707 0.7815 0.980 0.000 0.020 0.000
#> GSM40672 1 0.0000 0.7799 1.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.7799 1.000 0.000 0.000 0.000
#> GSM40674 1 0.7200 0.6538 0.572 0.196 0.228 0.004
#> GSM40676 3 0.8480 0.7335 0.160 0.300 0.480 0.060
#> GSM40680 1 0.7269 0.6118 0.536 0.264 0.200 0.000
#> GSM40681 1 0.5599 0.7531 0.700 0.072 0.228 0.000
#> GSM40683 1 0.0000 0.7799 1.000 0.000 0.000 0.000
#> GSM40684 3 0.8480 0.7335 0.160 0.300 0.480 0.060
#> GSM40685 1 0.6886 0.7007 0.596 0.200 0.204 0.000
#> GSM40689 1 0.0188 0.7799 0.996 0.000 0.004 0.000
#> GSM40690 1 0.2060 0.7852 0.932 0.016 0.052 0.000
#> GSM40692 1 0.6831 0.3998 0.480 0.420 0.100 0.000
#> GSM40693 1 0.5361 0.7635 0.744 0.108 0.148 0.000
#> GSM40694 1 0.7135 0.6662 0.560 0.200 0.240 0.000
#> GSM40695 1 0.0000 0.7799 1.000 0.000 0.000 0.000
#> GSM40696 1 0.5361 0.7635 0.744 0.108 0.148 0.000
#> GSM40697 2 0.1305 0.7417 0.004 0.960 0.036 0.000
#> GSM40704 1 0.0592 0.7825 0.984 0.000 0.016 0.000
#> GSM40705 3 0.7782 0.6680 0.000 0.312 0.424 0.264
#> GSM40707 1 0.0592 0.7778 0.984 0.000 0.016 0.000
#> GSM40708 1 0.0817 0.7792 0.976 0.000 0.024 0.000
#> GSM40709 3 0.6944 0.8058 0.004 0.384 0.512 0.100
#> GSM40712 1 0.7119 0.6808 0.576 0.168 0.252 0.004
#> GSM40713 1 0.0707 0.7815 0.980 0.000 0.020 0.000
#> GSM40665 1 0.5031 0.7638 0.740 0.048 0.212 0.000
#> GSM40677 2 0.4304 0.6459 0.000 0.716 0.284 0.000
#> GSM40698 1 0.5528 0.7528 0.700 0.064 0.236 0.000
#> GSM40701 4 0.3441 0.7532 0.000 0.120 0.024 0.856
#> GSM40710 2 0.4304 0.6459 0.000 0.716 0.284 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.8576 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.8576 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.8576 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.8576 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.3720 0.7397 0.000 0.020 0.836 0.096 0.048
#> GSM40668 3 0.0000 0.8576 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.1357 0.7757 0.000 0.948 0.000 0.004 0.048
#> GSM40679 2 0.1341 0.7755 0.000 0.944 0.000 0.000 0.056
#> GSM40686 2 0.4820 0.6459 0.000 0.696 0.000 0.236 0.068
#> GSM40687 2 0.4589 0.6574 0.000 0.724 0.000 0.212 0.064
#> GSM40691 2 0.1357 0.7757 0.000 0.948 0.000 0.004 0.048
#> GSM40699 2 0.1357 0.7757 0.000 0.948 0.000 0.004 0.048
#> GSM40664 4 0.5703 0.8337 0.000 0.244 0.000 0.616 0.140
#> GSM40682 2 0.1341 0.7755 0.000 0.944 0.000 0.000 0.056
#> GSM40688 2 0.2233 0.7607 0.000 0.904 0.000 0.016 0.080
#> GSM40702 2 0.1270 0.7761 0.000 0.948 0.000 0.000 0.052
#> GSM40706 2 0.5841 0.4056 0.000 0.608 0.000 0.212 0.180
#> GSM40711 3 0.7407 -0.3036 0.000 0.100 0.424 0.376 0.100
#> GSM40661 4 0.5910 0.8440 0.000 0.236 0.012 0.624 0.128
#> GSM40662 2 0.7549 -0.0928 0.024 0.440 0.020 0.200 0.316
#> GSM40666 4 0.6744 0.8565 0.000 0.204 0.052 0.584 0.160
#> GSM40669 5 0.5627 0.8027 0.160 0.072 0.000 0.064 0.704
#> GSM40670 5 0.5627 0.8027 0.160 0.072 0.000 0.064 0.704
#> GSM40671 1 0.1753 0.9171 0.936 0.000 0.000 0.032 0.032
#> GSM40672 1 0.0000 0.9207 1.000 0.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.9207 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.5722 0.7996 0.164 0.068 0.000 0.072 0.696
#> GSM40676 4 0.7032 0.8042 0.096 0.172 0.008 0.600 0.124
#> GSM40680 5 0.5492 0.7642 0.136 0.168 0.000 0.012 0.684
#> GSM40681 5 0.4839 0.7398 0.304 0.012 0.000 0.024 0.660
#> GSM40683 1 0.0000 0.9207 1.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.7032 0.8042 0.096 0.172 0.008 0.600 0.124
#> GSM40685 5 0.4979 0.8034 0.152 0.112 0.000 0.008 0.728
#> GSM40689 1 0.1117 0.9217 0.964 0.000 0.000 0.020 0.016
#> GSM40690 1 0.3074 0.6622 0.804 0.000 0.000 0.000 0.196
#> GSM40692 5 0.5819 0.5145 0.096 0.336 0.000 0.004 0.564
#> GSM40693 5 0.4944 0.7201 0.344 0.032 0.000 0.004 0.620
#> GSM40694 5 0.4883 0.8114 0.152 0.104 0.000 0.008 0.736
#> GSM40695 1 0.0404 0.9196 0.988 0.000 0.000 0.000 0.012
#> GSM40696 5 0.4944 0.7201 0.344 0.032 0.000 0.004 0.620
#> GSM40697 2 0.2452 0.7549 0.004 0.896 0.000 0.016 0.084
#> GSM40704 1 0.1851 0.8548 0.912 0.000 0.000 0.000 0.088
#> GSM40705 4 0.7728 0.6842 0.000 0.160 0.220 0.488 0.132
#> GSM40707 1 0.2588 0.8770 0.892 0.000 0.000 0.060 0.048
#> GSM40708 1 0.2729 0.8715 0.884 0.000 0.000 0.060 0.056
#> GSM40709 4 0.6714 0.8561 0.000 0.204 0.048 0.584 0.164
#> GSM40712 5 0.5154 0.8192 0.164 0.064 0.000 0.040 0.732
#> GSM40713 1 0.1753 0.9171 0.936 0.000 0.000 0.032 0.032
#> GSM40665 5 0.4677 0.6971 0.300 0.000 0.000 0.036 0.664
#> GSM40677 2 0.4847 0.6435 0.000 0.692 0.000 0.240 0.068
#> GSM40698 5 0.4527 0.7490 0.272 0.004 0.000 0.028 0.696
#> GSM40701 3 0.3424 0.7634 0.000 0.096 0.852 0.028 0.024
#> GSM40710 2 0.4847 0.6435 0.000 0.692 0.000 0.240 0.068
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 0.9406 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.9406 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.9406 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.9406 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.2669 0.7827 0.000 0.008 0.836 0.156 0.000 0.000
#> GSM40668 3 0.0000 0.9406 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.1536 0.8388 0.000 0.940 0.000 0.004 0.040 0.016
#> GSM40679 2 0.1429 0.8465 0.000 0.940 0.000 0.004 0.052 0.004
#> GSM40686 6 0.4569 0.9470 0.000 0.456 0.000 0.016 0.012 0.516
#> GSM40687 6 0.4126 0.9339 0.000 0.480 0.000 0.004 0.004 0.512
#> GSM40691 2 0.1536 0.8388 0.000 0.940 0.000 0.004 0.040 0.016
#> GSM40699 2 0.1536 0.8388 0.000 0.940 0.000 0.004 0.040 0.016
#> GSM40664 4 0.2816 0.7607 0.000 0.028 0.000 0.876 0.036 0.060
#> GSM40682 2 0.1429 0.8465 0.000 0.940 0.000 0.004 0.052 0.004
#> GSM40688 2 0.1838 0.8247 0.000 0.916 0.000 0.000 0.068 0.016
#> GSM40702 2 0.1398 0.8438 0.000 0.940 0.000 0.000 0.052 0.008
#> GSM40706 2 0.4321 0.2296 0.000 0.580 0.000 0.012 0.008 0.400
#> GSM40711 4 0.4774 0.2695 0.000 0.000 0.420 0.528 0.052 0.000
#> GSM40661 4 0.2862 0.7678 0.000 0.020 0.012 0.880 0.028 0.060
#> GSM40662 4 0.6742 0.0709 0.000 0.284 0.016 0.376 0.312 0.012
#> GSM40666 4 0.2796 0.7748 0.000 0.012 0.048 0.872 0.068 0.000
#> GSM40669 5 0.2100 0.7994 0.000 0.004 0.000 0.112 0.884 0.000
#> GSM40670 5 0.2100 0.7994 0.000 0.004 0.000 0.112 0.884 0.000
#> GSM40671 1 0.2918 0.8720 0.864 0.000 0.000 0.032 0.084 0.020
#> GSM40672 1 0.0914 0.8805 0.968 0.000 0.000 0.000 0.016 0.016
#> GSM40673 1 0.0914 0.8805 0.968 0.000 0.000 0.000 0.016 0.016
#> GSM40674 5 0.2048 0.7954 0.000 0.000 0.000 0.120 0.880 0.000
#> GSM40676 4 0.2733 0.7381 0.024 0.008 0.004 0.892 0.028 0.044
#> GSM40680 5 0.3414 0.7765 0.012 0.116 0.000 0.024 0.832 0.016
#> GSM40681 5 0.3867 0.7338 0.192 0.000 0.000 0.040 0.760 0.008
#> GSM40683 1 0.0914 0.8805 0.968 0.000 0.000 0.000 0.016 0.016
#> GSM40684 4 0.2733 0.7381 0.024 0.008 0.004 0.892 0.028 0.044
#> GSM40685 5 0.2157 0.8015 0.004 0.076 0.000 0.008 0.904 0.008
#> GSM40689 1 0.2071 0.8822 0.916 0.000 0.000 0.028 0.044 0.012
#> GSM40690 1 0.3852 0.6426 0.720 0.000 0.000 0.008 0.256 0.016
#> GSM40692 5 0.4185 0.5663 0.004 0.292 0.000 0.012 0.680 0.012
#> GSM40693 5 0.3203 0.7587 0.160 0.004 0.000 0.000 0.812 0.024
#> GSM40694 5 0.2319 0.8108 0.008 0.060 0.000 0.020 0.904 0.008
#> GSM40695 1 0.0937 0.8823 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM40696 5 0.3203 0.7587 0.160 0.004 0.000 0.000 0.812 0.024
#> GSM40697 2 0.1951 0.8142 0.000 0.908 0.000 0.000 0.076 0.016
#> GSM40704 1 0.2932 0.7962 0.820 0.000 0.000 0.000 0.164 0.016
#> GSM40705 4 0.4226 0.6549 0.000 0.008 0.216 0.724 0.052 0.000
#> GSM40707 1 0.3849 0.7983 0.804 0.000 0.000 0.104 0.032 0.060
#> GSM40708 1 0.3942 0.7955 0.800 0.000 0.000 0.100 0.040 0.060
#> GSM40709 4 0.2731 0.7753 0.000 0.012 0.044 0.876 0.068 0.000
#> GSM40712 5 0.1826 0.8135 0.000 0.020 0.000 0.052 0.924 0.004
#> GSM40713 1 0.2969 0.8703 0.860 0.000 0.000 0.032 0.088 0.020
#> GSM40665 5 0.4108 0.6795 0.184 0.000 0.000 0.060 0.748 0.008
#> GSM40677 6 0.4475 0.9615 0.000 0.448 0.000 0.016 0.008 0.528
#> GSM40698 5 0.3874 0.7239 0.156 0.000 0.000 0.060 0.776 0.008
#> GSM40701 3 0.3092 0.8240 0.000 0.088 0.852 0.044 0.016 0.000
#> GSM40710 6 0.4374 0.9618 0.000 0.448 0.000 0.016 0.004 0.532
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> CV:hclust 52 1.77e-04 2
#> CV:hclust 51 1.74e-07 3
#> CV:hclust 49 6.26e-08 4
#> CV:hclust 50 5.75e-07 5
#> CV:hclust 50 5.34e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 35373 rows and 53 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.504 0.837 0.911 0.4904 0.491 0.491
#> 3 3 0.757 0.859 0.926 0.3323 0.739 0.517
#> 4 4 0.606 0.615 0.801 0.1332 0.819 0.517
#> 5 5 0.691 0.614 0.779 0.0707 0.902 0.648
#> 6 6 0.718 0.658 0.746 0.0425 0.908 0.619
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
#> GSM40663 2 0.2423 0.891 0.040 0.960
#> GSM40667 2 0.2423 0.891 0.040 0.960
#> GSM40675 2 0.2423 0.891 0.040 0.960
#> GSM40703 2 0.2423 0.891 0.040 0.960
#> GSM40660 2 0.2423 0.891 0.040 0.960
#> GSM40668 2 0.2423 0.891 0.040 0.960
#> GSM40678 2 0.4298 0.889 0.088 0.912
#> GSM40679 2 0.4815 0.884 0.104 0.896
#> GSM40686 2 0.7219 0.813 0.200 0.800
#> GSM40687 2 0.4298 0.889 0.088 0.912
#> GSM40691 2 0.4298 0.889 0.088 0.912
#> GSM40699 2 0.0000 0.887 0.000 1.000
#> GSM40664 2 0.7139 0.817 0.196 0.804
#> GSM40682 2 0.4815 0.884 0.104 0.896
#> GSM40688 2 0.7674 0.782 0.224 0.776
#> GSM40702 2 0.0000 0.887 0.000 1.000
#> GSM40706 2 0.5737 0.866 0.136 0.864
#> GSM40711 2 0.2423 0.891 0.040 0.960
#> GSM40661 2 0.2423 0.891 0.040 0.960
#> GSM40662 2 0.7056 0.821 0.192 0.808
#> GSM40666 2 0.3584 0.887 0.068 0.932
#> GSM40669 1 0.0938 0.897 0.988 0.012
#> GSM40670 1 0.8955 0.508 0.688 0.312
#> GSM40671 1 0.0000 0.901 1.000 0.000
#> GSM40672 1 0.0376 0.901 0.996 0.004
#> GSM40673 1 0.0000 0.901 1.000 0.000
#> GSM40674 1 0.8955 0.508 0.688 0.312
#> GSM40676 1 0.9833 0.270 0.576 0.424
#> GSM40680 1 0.7883 0.699 0.764 0.236
#> GSM40681 1 0.1843 0.893 0.972 0.028
#> GSM40683 1 0.0000 0.901 1.000 0.000
#> GSM40684 1 0.9833 0.270 0.576 0.424
#> GSM40685 1 0.2423 0.887 0.960 0.040
#> GSM40689 1 0.0000 0.901 1.000 0.000
#> GSM40690 1 0.0376 0.901 0.996 0.004
#> GSM40692 1 0.2423 0.887 0.960 0.040
#> GSM40693 1 0.2423 0.887 0.960 0.040
#> GSM40694 1 0.2423 0.887 0.960 0.040
#> GSM40695 1 0.0000 0.901 1.000 0.000
#> GSM40696 1 0.2423 0.887 0.960 0.040
#> GSM40697 2 0.7883 0.764 0.236 0.764
#> GSM40704 1 0.0000 0.901 1.000 0.000
#> GSM40705 2 0.2423 0.891 0.040 0.960
#> GSM40707 1 0.0000 0.901 1.000 0.000
#> GSM40708 1 0.0000 0.901 1.000 0.000
#> GSM40709 2 0.6801 0.834 0.180 0.820
#> GSM40712 1 0.7139 0.752 0.804 0.196
#> GSM40713 1 0.0000 0.901 1.000 0.000
#> GSM40665 1 0.0000 0.901 1.000 0.000
#> GSM40677 2 0.7139 0.817 0.196 0.804
#> GSM40698 1 0.0376 0.901 0.996 0.004
#> GSM40701 2 0.0000 0.887 0.000 1.000
#> GSM40710 2 0.4298 0.889 0.088 0.912
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.1289 0.8657 0.000 0.032 0.968
#> GSM40667 3 0.1289 0.8657 0.000 0.032 0.968
#> GSM40675 3 0.1289 0.8657 0.000 0.032 0.968
#> GSM40703 3 0.1289 0.8657 0.000 0.032 0.968
#> GSM40660 3 0.4291 0.8087 0.000 0.180 0.820
#> GSM40668 3 0.1289 0.8657 0.000 0.032 0.968
#> GSM40678 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40699 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40664 2 0.0424 0.9546 0.000 0.992 0.008
#> GSM40682 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40702 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40706 2 0.0237 0.9572 0.000 0.996 0.004
#> GSM40711 3 0.1163 0.8650 0.000 0.028 0.972
#> GSM40661 3 0.4452 0.7982 0.000 0.192 0.808
#> GSM40662 2 0.0237 0.9568 0.000 0.996 0.004
#> GSM40666 3 0.6063 0.8098 0.084 0.132 0.784
#> GSM40669 1 0.4172 0.7908 0.840 0.156 0.004
#> GSM40670 1 0.5873 0.5861 0.684 0.312 0.004
#> GSM40671 1 0.0747 0.9208 0.984 0.000 0.016
#> GSM40672 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40674 1 0.5929 0.5707 0.676 0.320 0.004
#> GSM40676 3 0.7037 0.5374 0.328 0.036 0.636
#> GSM40680 2 0.1337 0.9373 0.016 0.972 0.012
#> GSM40681 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40684 3 0.7037 0.5374 0.328 0.036 0.636
#> GSM40685 2 0.6483 0.0558 0.452 0.544 0.004
#> GSM40689 1 0.1031 0.9181 0.976 0.000 0.024
#> GSM40690 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40692 2 0.1989 0.9105 0.048 0.948 0.004
#> GSM40693 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40694 1 0.0747 0.9163 0.984 0.016 0.000
#> GSM40695 1 0.0424 0.9217 0.992 0.000 0.008
#> GSM40696 1 0.0237 0.9216 0.996 0.004 0.000
#> GSM40697 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40704 1 0.0000 0.9227 1.000 0.000 0.000
#> GSM40705 3 0.1163 0.8650 0.000 0.028 0.972
#> GSM40707 1 0.1031 0.9181 0.976 0.000 0.024
#> GSM40708 1 0.1031 0.9181 0.976 0.000 0.024
#> GSM40709 3 0.7462 0.7261 0.180 0.124 0.696
#> GSM40712 1 0.5902 0.5764 0.680 0.316 0.004
#> GSM40713 1 0.0747 0.9208 0.984 0.000 0.016
#> GSM40665 1 0.1031 0.9181 0.976 0.000 0.024
#> GSM40677 2 0.0000 0.9594 0.000 1.000 0.000
#> GSM40698 1 0.2187 0.9061 0.948 0.024 0.028
#> GSM40701 3 0.4504 0.7968 0.000 0.196 0.804
#> GSM40710 2 0.0000 0.9594 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0188 0.8455 0.000 0.004 0.000 0.996
#> GSM40667 4 0.0188 0.8455 0.000 0.004 0.000 0.996
#> GSM40675 4 0.0188 0.8455 0.000 0.004 0.000 0.996
#> GSM40703 4 0.0188 0.8455 0.000 0.004 0.000 0.996
#> GSM40660 4 0.6075 0.7364 0.000 0.148 0.168 0.684
#> GSM40668 4 0.0188 0.8455 0.000 0.004 0.000 0.996
#> GSM40678 2 0.0469 0.9227 0.000 0.988 0.012 0.000
#> GSM40679 2 0.0000 0.9242 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0336 0.9242 0.000 0.992 0.008 0.000
#> GSM40687 2 0.0469 0.9227 0.000 0.988 0.012 0.000
#> GSM40691 2 0.0336 0.9218 0.000 0.992 0.008 0.000
#> GSM40699 2 0.0336 0.9236 0.000 0.992 0.008 0.000
#> GSM40664 2 0.3610 0.6920 0.000 0.800 0.200 0.000
#> GSM40682 2 0.0188 0.9239 0.000 0.996 0.004 0.000
#> GSM40688 2 0.0469 0.9199 0.000 0.988 0.012 0.000
#> GSM40702 2 0.0000 0.9242 0.000 1.000 0.000 0.000
#> GSM40706 2 0.2401 0.8600 0.000 0.904 0.092 0.004
#> GSM40711 4 0.3355 0.8119 0.000 0.004 0.160 0.836
#> GSM40661 4 0.6449 0.6878 0.000 0.140 0.220 0.640
#> GSM40662 3 0.4661 0.3802 0.000 0.348 0.652 0.000
#> GSM40666 3 0.6190 -0.1720 0.024 0.016 0.512 0.448
#> GSM40669 3 0.4636 0.4970 0.140 0.068 0.792 0.000
#> GSM40670 3 0.4591 0.5182 0.116 0.084 0.800 0.000
#> GSM40671 1 0.3400 0.6913 0.820 0.000 0.180 0.000
#> GSM40672 1 0.2530 0.7346 0.888 0.000 0.112 0.000
#> GSM40673 1 0.2469 0.7362 0.892 0.000 0.108 0.000
#> GSM40674 3 0.4591 0.5182 0.116 0.084 0.800 0.000
#> GSM40676 3 0.7407 0.2060 0.288 0.000 0.508 0.204
#> GSM40680 3 0.4992 0.1259 0.000 0.476 0.524 0.000
#> GSM40681 1 0.4898 0.4180 0.584 0.000 0.416 0.000
#> GSM40683 1 0.2469 0.7362 0.892 0.000 0.108 0.000
#> GSM40684 3 0.7407 0.2060 0.288 0.000 0.508 0.204
#> GSM40685 3 0.5903 0.4165 0.052 0.332 0.616 0.000
#> GSM40689 1 0.1867 0.7105 0.928 0.000 0.072 0.000
#> GSM40690 1 0.3123 0.7248 0.844 0.000 0.156 0.000
#> GSM40692 3 0.5143 0.1792 0.004 0.456 0.540 0.000
#> GSM40693 1 0.4996 0.2276 0.516 0.000 0.484 0.000
#> GSM40694 3 0.5364 0.1753 0.320 0.028 0.652 0.000
#> GSM40695 1 0.0592 0.7334 0.984 0.000 0.016 0.000
#> GSM40696 1 0.4996 0.2276 0.516 0.000 0.484 0.000
#> GSM40697 2 0.4941 0.0437 0.000 0.564 0.436 0.000
#> GSM40704 1 0.2469 0.7362 0.892 0.000 0.108 0.000
#> GSM40705 4 0.3355 0.8119 0.000 0.004 0.160 0.836
#> GSM40707 1 0.2921 0.6886 0.860 0.000 0.140 0.000
#> GSM40708 1 0.4382 0.5671 0.704 0.000 0.296 0.000
#> GSM40709 3 0.6488 0.2005 0.080 0.008 0.616 0.296
#> GSM40712 3 0.4764 0.5122 0.124 0.088 0.788 0.000
#> GSM40713 1 0.3400 0.6913 0.820 0.000 0.180 0.000
#> GSM40665 1 0.3649 0.6754 0.796 0.000 0.204 0.000
#> GSM40677 2 0.0336 0.9242 0.000 0.992 0.008 0.000
#> GSM40698 3 0.4996 -0.2119 0.484 0.000 0.516 0.000
#> GSM40701 4 0.6400 0.7057 0.000 0.180 0.168 0.652
#> GSM40710 2 0.0592 0.9225 0.000 0.984 0.016 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.4067 0.5843 0.000 0.000 0.692 0.300 0.008
#> GSM40667 3 0.4067 0.5843 0.000 0.000 0.692 0.300 0.008
#> GSM40675 3 0.4067 0.5843 0.000 0.000 0.692 0.300 0.008
#> GSM40703 3 0.4088 0.5837 0.000 0.000 0.688 0.304 0.008
#> GSM40660 3 0.3980 0.4352 0.000 0.092 0.816 0.012 0.080
#> GSM40668 3 0.4067 0.5843 0.000 0.000 0.692 0.300 0.008
#> GSM40678 2 0.1430 0.9070 0.000 0.944 0.000 0.052 0.004
#> GSM40679 2 0.0798 0.9142 0.000 0.976 0.000 0.008 0.016
#> GSM40686 2 0.1568 0.9133 0.000 0.944 0.000 0.036 0.020
#> GSM40687 2 0.1430 0.9070 0.000 0.944 0.000 0.052 0.004
#> GSM40691 2 0.1915 0.8950 0.000 0.928 0.000 0.040 0.032
#> GSM40699 2 0.1502 0.9075 0.000 0.940 0.000 0.056 0.004
#> GSM40664 2 0.6174 0.5810 0.000 0.660 0.100 0.168 0.072
#> GSM40682 2 0.1485 0.9121 0.000 0.948 0.000 0.032 0.020
#> GSM40688 2 0.2153 0.8863 0.000 0.916 0.000 0.044 0.040
#> GSM40702 2 0.0579 0.9144 0.000 0.984 0.000 0.008 0.008
#> GSM40706 2 0.4973 0.7705 0.000 0.744 0.024 0.148 0.084
#> GSM40711 3 0.1341 0.5049 0.000 0.000 0.944 0.000 0.056
#> GSM40661 3 0.5560 0.2648 0.000 0.060 0.716 0.132 0.092
#> GSM40662 5 0.4054 0.6549 0.000 0.120 0.028 0.040 0.812
#> GSM40666 3 0.5996 -0.2624 0.000 0.000 0.512 0.120 0.368
#> GSM40669 5 0.2367 0.7130 0.072 0.000 0.020 0.004 0.904
#> GSM40670 5 0.2396 0.7120 0.068 0.000 0.024 0.004 0.904
#> GSM40671 1 0.5235 0.5741 0.620 0.000 0.000 0.312 0.068
#> GSM40672 1 0.0671 0.7097 0.980 0.000 0.000 0.004 0.016
#> GSM40673 1 0.0404 0.7125 0.988 0.000 0.000 0.000 0.012
#> GSM40674 5 0.2396 0.7120 0.068 0.000 0.024 0.004 0.904
#> GSM40676 4 0.6994 1.0000 0.044 0.000 0.368 0.460 0.128
#> GSM40680 5 0.4303 0.6495 0.000 0.192 0.000 0.056 0.752
#> GSM40681 1 0.5143 -0.0482 0.532 0.000 0.000 0.040 0.428
#> GSM40683 1 0.0404 0.7125 0.988 0.000 0.000 0.000 0.012
#> GSM40684 4 0.6994 1.0000 0.044 0.000 0.368 0.460 0.128
#> GSM40685 5 0.3452 0.6941 0.000 0.148 0.000 0.032 0.820
#> GSM40689 1 0.3242 0.6517 0.784 0.000 0.000 0.216 0.000
#> GSM40690 1 0.2077 0.6835 0.908 0.000 0.000 0.008 0.084
#> GSM40692 5 0.3722 0.6824 0.004 0.176 0.000 0.024 0.796
#> GSM40693 5 0.4310 0.4556 0.392 0.000 0.000 0.004 0.604
#> GSM40694 5 0.2690 0.7002 0.156 0.000 0.000 0.000 0.844
#> GSM40695 1 0.0510 0.7106 0.984 0.000 0.000 0.016 0.000
#> GSM40696 5 0.4310 0.4556 0.392 0.000 0.000 0.004 0.604
#> GSM40697 5 0.4295 0.6479 0.000 0.216 0.000 0.044 0.740
#> GSM40704 1 0.0510 0.7112 0.984 0.000 0.000 0.000 0.016
#> GSM40705 3 0.1341 0.5049 0.000 0.000 0.944 0.000 0.056
#> GSM40707 1 0.4371 0.5655 0.644 0.000 0.000 0.344 0.012
#> GSM40708 1 0.5967 0.3087 0.456 0.000 0.000 0.436 0.108
#> GSM40709 3 0.6842 -0.4726 0.008 0.000 0.408 0.212 0.372
#> GSM40712 5 0.1990 0.7166 0.068 0.000 0.008 0.004 0.920
#> GSM40713 1 0.5289 0.5694 0.616 0.000 0.000 0.312 0.072
#> GSM40665 1 0.5535 0.5115 0.568 0.000 0.000 0.352 0.080
#> GSM40677 2 0.1597 0.9101 0.000 0.940 0.000 0.048 0.012
#> GSM40698 5 0.7110 -0.2569 0.240 0.000 0.016 0.372 0.372
#> GSM40701 3 0.4121 0.4317 0.000 0.104 0.808 0.016 0.072
#> GSM40710 2 0.2293 0.9003 0.000 0.900 0.000 0.084 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.000 0.981 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.000 0.981 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.000 0.981 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.000 0.981 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.528 0.532 0.008 0.068 0.344 0.572 0.008 0.000
#> GSM40668 3 0.114 0.922 0.000 0.000 0.948 0.052 0.000 0.000
#> GSM40678 2 0.160 0.834 0.028 0.940 0.000 0.024 0.008 0.000
#> GSM40679 2 0.162 0.842 0.016 0.940 0.000 0.028 0.016 0.000
#> GSM40686 2 0.296 0.828 0.056 0.864 0.000 0.064 0.016 0.000
#> GSM40687 2 0.176 0.833 0.032 0.932 0.000 0.028 0.008 0.000
#> GSM40691 2 0.412 0.773 0.096 0.788 0.000 0.076 0.040 0.000
#> GSM40699 2 0.183 0.832 0.032 0.928 0.000 0.032 0.008 0.000
#> GSM40664 2 0.673 0.432 0.076 0.492 0.000 0.328 0.028 0.076
#> GSM40682 2 0.304 0.833 0.052 0.860 0.000 0.068 0.020 0.000
#> GSM40688 2 0.461 0.746 0.108 0.752 0.000 0.076 0.064 0.000
#> GSM40702 2 0.153 0.841 0.016 0.944 0.000 0.028 0.012 0.000
#> GSM40706 2 0.670 0.524 0.256 0.488 0.000 0.184 0.072 0.000
#> GSM40711 4 0.398 0.425 0.000 0.000 0.460 0.536 0.004 0.000
#> GSM40661 4 0.470 0.584 0.008 0.040 0.244 0.692 0.012 0.004
#> GSM40662 5 0.558 0.646 0.080 0.064 0.000 0.220 0.636 0.000
#> GSM40666 4 0.502 0.571 0.000 0.000 0.132 0.696 0.144 0.028
#> GSM40669 5 0.200 0.737 0.012 0.000 0.000 0.068 0.912 0.008
#> GSM40670 5 0.212 0.732 0.008 0.000 0.000 0.084 0.900 0.008
#> GSM40671 6 0.161 0.666 0.044 0.000 0.000 0.004 0.016 0.936
#> GSM40672 1 0.444 0.879 0.620 0.000 0.000 0.004 0.032 0.344
#> GSM40673 1 0.422 0.891 0.616 0.000 0.000 0.000 0.024 0.360
#> GSM40674 5 0.223 0.731 0.008 0.000 0.000 0.092 0.892 0.008
#> GSM40676 4 0.450 0.152 0.000 0.000 0.012 0.492 0.012 0.484
#> GSM40680 5 0.638 0.624 0.108 0.120 0.000 0.136 0.616 0.020
#> GSM40681 5 0.719 -0.168 0.324 0.000 0.000 0.084 0.336 0.256
#> GSM40683 1 0.422 0.891 0.616 0.000 0.000 0.000 0.024 0.360
#> GSM40684 4 0.450 0.152 0.000 0.000 0.012 0.492 0.012 0.484
#> GSM40685 5 0.397 0.713 0.080 0.060 0.000 0.048 0.808 0.004
#> GSM40689 6 0.390 -0.447 0.404 0.000 0.000 0.000 0.004 0.592
#> GSM40690 1 0.571 0.618 0.456 0.000 0.000 0.016 0.104 0.424
#> GSM40692 5 0.527 0.687 0.104 0.084 0.000 0.084 0.716 0.012
#> GSM40693 5 0.432 0.562 0.240 0.000 0.000 0.008 0.704 0.048
#> GSM40694 5 0.225 0.737 0.060 0.000 0.000 0.012 0.904 0.024
#> GSM40695 1 0.404 0.830 0.568 0.000 0.000 0.000 0.008 0.424
#> GSM40696 5 0.432 0.562 0.240 0.000 0.000 0.008 0.704 0.048
#> GSM40697 5 0.522 0.653 0.104 0.120 0.000 0.076 0.700 0.000
#> GSM40704 1 0.443 0.881 0.584 0.000 0.000 0.004 0.024 0.388
#> GSM40705 4 0.398 0.425 0.000 0.000 0.460 0.536 0.004 0.000
#> GSM40707 6 0.282 0.582 0.108 0.000 0.000 0.032 0.004 0.856
#> GSM40708 6 0.304 0.638 0.024 0.000 0.000 0.076 0.040 0.860
#> GSM40709 4 0.475 0.552 0.000 0.000 0.024 0.720 0.140 0.116
#> GSM40712 5 0.280 0.729 0.016 0.000 0.000 0.108 0.860 0.016
#> GSM40713 6 0.163 0.664 0.044 0.000 0.000 0.000 0.024 0.932
#> GSM40665 6 0.126 0.678 0.008 0.000 0.000 0.020 0.016 0.956
#> GSM40677 2 0.286 0.828 0.056 0.868 0.000 0.064 0.012 0.000
#> GSM40698 6 0.596 0.410 0.048 0.000 0.000 0.168 0.188 0.596
#> GSM40701 4 0.544 0.527 0.008 0.084 0.336 0.564 0.008 0.000
#> GSM40710 2 0.294 0.821 0.068 0.856 0.000 0.072 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 disease.state(p) k
#> CV:kmeans 51 3.54e-05 2
#> CV:kmeans 52 7.79e-05 3
#> CV:kmeans 38 1.41e-04 4
#> CV:kmeans 43 5.20e-06 5
#> CV:kmeans 45 2.77e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 35373 rows and 53 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 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.960 0.971 0.987 0.5099 0.491 0.491
#> 3 3 0.971 0.933 0.974 0.3185 0.763 0.553
#> 4 4 0.807 0.835 0.906 0.1216 0.885 0.667
#> 5 5 0.725 0.679 0.815 0.0510 0.962 0.846
#> 6 6 0.718 0.630 0.786 0.0363 0.961 0.820
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
#> GSM40663 2 0.0000 0.986 0.000 1.000
#> GSM40667 2 0.0000 0.986 0.000 1.000
#> GSM40675 2 0.0000 0.986 0.000 1.000
#> GSM40703 2 0.0000 0.986 0.000 1.000
#> GSM40660 2 0.0000 0.986 0.000 1.000
#> GSM40668 2 0.0000 0.986 0.000 1.000
#> GSM40678 2 0.0000 0.986 0.000 1.000
#> GSM40679 2 0.0000 0.986 0.000 1.000
#> GSM40686 2 0.0000 0.986 0.000 1.000
#> GSM40687 2 0.0000 0.986 0.000 1.000
#> GSM40691 2 0.0000 0.986 0.000 1.000
#> GSM40699 2 0.0000 0.986 0.000 1.000
#> GSM40664 2 0.0000 0.986 0.000 1.000
#> GSM40682 2 0.0000 0.986 0.000 1.000
#> GSM40688 2 0.6148 0.824 0.152 0.848
#> GSM40702 2 0.0000 0.986 0.000 1.000
#> GSM40706 2 0.0000 0.986 0.000 1.000
#> GSM40711 2 0.0000 0.986 0.000 1.000
#> GSM40661 2 0.0000 0.986 0.000 1.000
#> GSM40662 2 0.0000 0.986 0.000 1.000
#> GSM40666 2 0.0376 0.983 0.004 0.996
#> GSM40669 1 0.0000 0.985 1.000 0.000
#> GSM40670 1 0.0000 0.985 1.000 0.000
#> GSM40671 1 0.0000 0.985 1.000 0.000
#> GSM40672 1 0.0000 0.985 1.000 0.000
#> GSM40673 1 0.0000 0.985 1.000 0.000
#> GSM40674 1 0.0000 0.985 1.000 0.000
#> GSM40676 1 0.6801 0.788 0.820 0.180
#> GSM40680 1 0.0000 0.985 1.000 0.000
#> GSM40681 1 0.0000 0.985 1.000 0.000
#> GSM40683 1 0.0000 0.985 1.000 0.000
#> GSM40684 1 0.6801 0.788 0.820 0.180
#> GSM40685 1 0.0000 0.985 1.000 0.000
#> GSM40689 1 0.0000 0.985 1.000 0.000
#> GSM40690 1 0.0000 0.985 1.000 0.000
#> GSM40692 1 0.0000 0.985 1.000 0.000
#> GSM40693 1 0.0000 0.985 1.000 0.000
#> GSM40694 1 0.0000 0.985 1.000 0.000
#> GSM40695 1 0.0000 0.985 1.000 0.000
#> GSM40696 1 0.0000 0.985 1.000 0.000
#> GSM40697 2 0.6801 0.786 0.180 0.820
#> GSM40704 1 0.0000 0.985 1.000 0.000
#> GSM40705 2 0.0000 0.986 0.000 1.000
#> GSM40707 1 0.0000 0.985 1.000 0.000
#> GSM40708 1 0.0000 0.985 1.000 0.000
#> GSM40709 2 0.0938 0.976 0.012 0.988
#> GSM40712 1 0.0000 0.985 1.000 0.000
#> GSM40713 1 0.0000 0.985 1.000 0.000
#> GSM40665 1 0.0000 0.985 1.000 0.000
#> GSM40677 2 0.0000 0.986 0.000 1.000
#> GSM40698 1 0.0000 0.985 1.000 0.000
#> GSM40701 2 0.0000 0.986 0.000 1.000
#> GSM40710 2 0.0000 0.986 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.000 1.000 0.000 0.000 1.000
#> GSM40667 3 0.000 1.000 0.000 0.000 1.000
#> GSM40675 3 0.000 1.000 0.000 0.000 1.000
#> GSM40703 3 0.000 1.000 0.000 0.000 1.000
#> GSM40660 3 0.000 1.000 0.000 0.000 1.000
#> GSM40668 3 0.000 1.000 0.000 0.000 1.000
#> GSM40678 2 0.000 0.986 0.000 1.000 0.000
#> GSM40679 2 0.000 0.986 0.000 1.000 0.000
#> GSM40686 2 0.000 0.986 0.000 1.000 0.000
#> GSM40687 2 0.000 0.986 0.000 1.000 0.000
#> GSM40691 2 0.000 0.986 0.000 1.000 0.000
#> GSM40699 2 0.000 0.986 0.000 1.000 0.000
#> GSM40664 2 0.000 0.986 0.000 1.000 0.000
#> GSM40682 2 0.000 0.986 0.000 1.000 0.000
#> GSM40688 2 0.000 0.986 0.000 1.000 0.000
#> GSM40702 2 0.000 0.986 0.000 1.000 0.000
#> GSM40706 2 0.116 0.963 0.000 0.972 0.028
#> GSM40711 3 0.000 1.000 0.000 0.000 1.000
#> GSM40661 3 0.000 1.000 0.000 0.000 1.000
#> GSM40662 2 0.103 0.967 0.000 0.976 0.024
#> GSM40666 3 0.000 1.000 0.000 0.000 1.000
#> GSM40669 1 0.000 0.943 1.000 0.000 0.000
#> GSM40670 1 0.630 0.143 0.528 0.000 0.472
#> GSM40671 1 0.000 0.943 1.000 0.000 0.000
#> GSM40672 1 0.000 0.943 1.000 0.000 0.000
#> GSM40673 1 0.000 0.943 1.000 0.000 0.000
#> GSM40674 1 0.630 0.117 0.520 0.000 0.480
#> GSM40676 3 0.000 1.000 0.000 0.000 1.000
#> GSM40680 2 0.000 0.986 0.000 1.000 0.000
#> GSM40681 1 0.000 0.943 1.000 0.000 0.000
#> GSM40683 1 0.000 0.943 1.000 0.000 0.000
#> GSM40684 3 0.000 1.000 0.000 0.000 1.000
#> GSM40685 1 0.450 0.721 0.804 0.196 0.000
#> GSM40689 1 0.000 0.943 1.000 0.000 0.000
#> GSM40690 1 0.000 0.943 1.000 0.000 0.000
#> GSM40692 2 0.406 0.801 0.164 0.836 0.000
#> GSM40693 1 0.000 0.943 1.000 0.000 0.000
#> GSM40694 1 0.000 0.943 1.000 0.000 0.000
#> GSM40695 1 0.000 0.943 1.000 0.000 0.000
#> GSM40696 1 0.000 0.943 1.000 0.000 0.000
#> GSM40697 2 0.000 0.986 0.000 1.000 0.000
#> GSM40704 1 0.000 0.943 1.000 0.000 0.000
#> GSM40705 3 0.000 1.000 0.000 0.000 1.000
#> GSM40707 1 0.000 0.943 1.000 0.000 0.000
#> GSM40708 1 0.000 0.943 1.000 0.000 0.000
#> GSM40709 3 0.000 1.000 0.000 0.000 1.000
#> GSM40712 1 0.000 0.943 1.000 0.000 0.000
#> GSM40713 1 0.000 0.943 1.000 0.000 0.000
#> GSM40665 1 0.000 0.943 1.000 0.000 0.000
#> GSM40677 2 0.000 0.986 0.000 1.000 0.000
#> GSM40698 1 0.000 0.943 1.000 0.000 0.000
#> GSM40701 3 0.000 1.000 0.000 0.000 1.000
#> GSM40710 2 0.000 0.986 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40668 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.945 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.945 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0188 0.945 0.000 0.996 0.000 0.004
#> GSM40687 2 0.0000 0.945 0.000 1.000 0.000 0.000
#> GSM40691 2 0.0376 0.944 0.000 0.992 0.004 0.004
#> GSM40699 2 0.0336 0.943 0.000 0.992 0.008 0.000
#> GSM40664 2 0.3052 0.852 0.104 0.880 0.004 0.012
#> GSM40682 2 0.0188 0.945 0.000 0.996 0.000 0.004
#> GSM40688 2 0.0188 0.944 0.000 0.996 0.000 0.004
#> GSM40702 2 0.0336 0.943 0.000 0.992 0.008 0.000
#> GSM40706 2 0.2673 0.872 0.008 0.904 0.080 0.008
#> GSM40711 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40661 3 0.0336 0.928 0.000 0.000 0.992 0.008
#> GSM40662 2 0.6893 0.496 0.008 0.624 0.176 0.192
#> GSM40666 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40669 4 0.0817 0.818 0.024 0.000 0.000 0.976
#> GSM40670 4 0.2089 0.806 0.020 0.000 0.048 0.932
#> GSM40671 1 0.1474 0.861 0.948 0.000 0.000 0.052
#> GSM40672 1 0.4431 0.743 0.696 0.000 0.000 0.304
#> GSM40673 1 0.3907 0.828 0.768 0.000 0.000 0.232
#> GSM40674 4 0.2179 0.797 0.012 0.000 0.064 0.924
#> GSM40676 3 0.5229 0.420 0.428 0.000 0.564 0.008
#> GSM40680 2 0.2965 0.873 0.036 0.892 0.000 0.072
#> GSM40681 1 0.4103 0.813 0.744 0.000 0.000 0.256
#> GSM40683 1 0.3873 0.831 0.772 0.000 0.000 0.228
#> GSM40684 3 0.5099 0.515 0.380 0.000 0.612 0.008
#> GSM40685 4 0.5066 0.722 0.112 0.120 0.000 0.768
#> GSM40689 1 0.1211 0.858 0.960 0.000 0.000 0.040
#> GSM40690 1 0.3873 0.831 0.772 0.000 0.000 0.228
#> GSM40692 4 0.7069 0.444 0.144 0.324 0.000 0.532
#> GSM40693 4 0.1940 0.797 0.076 0.000 0.000 0.924
#> GSM40694 4 0.1302 0.815 0.044 0.000 0.000 0.956
#> GSM40695 1 0.2973 0.857 0.856 0.000 0.000 0.144
#> GSM40696 4 0.1716 0.806 0.064 0.000 0.000 0.936
#> GSM40697 4 0.5143 0.197 0.004 0.456 0.000 0.540
#> GSM40704 1 0.4072 0.811 0.748 0.000 0.000 0.252
#> GSM40705 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40707 1 0.0188 0.841 0.996 0.000 0.000 0.004
#> GSM40708 1 0.0188 0.837 0.996 0.000 0.000 0.004
#> GSM40709 3 0.1174 0.914 0.020 0.000 0.968 0.012
#> GSM40712 4 0.1042 0.819 0.020 0.008 0.000 0.972
#> GSM40713 1 0.1792 0.863 0.932 0.000 0.000 0.068
#> GSM40665 1 0.0592 0.848 0.984 0.000 0.000 0.016
#> GSM40677 2 0.0188 0.945 0.000 0.996 0.000 0.004
#> GSM40698 1 0.1118 0.847 0.964 0.000 0.000 0.036
#> GSM40701 3 0.0000 0.932 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0188 0.945 0.000 0.996 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.958 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.958 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.958 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.958 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.0162 0.956 0.000 0.000 0.996 0.000 0.004
#> GSM40668 3 0.0000 0.958 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0290 0.829 0.000 0.992 0.000 0.008 0.000
#> GSM40679 2 0.0609 0.831 0.000 0.980 0.000 0.020 0.000
#> GSM40686 2 0.2722 0.803 0.000 0.872 0.000 0.108 0.020
#> GSM40687 2 0.0451 0.829 0.000 0.988 0.000 0.008 0.004
#> GSM40691 2 0.2696 0.791 0.000 0.892 0.012 0.072 0.024
#> GSM40699 2 0.0693 0.828 0.000 0.980 0.012 0.008 0.000
#> GSM40664 2 0.4538 0.511 0.004 0.636 0.000 0.348 0.012
#> GSM40682 2 0.1282 0.826 0.000 0.952 0.000 0.044 0.004
#> GSM40688 2 0.3681 0.724 0.000 0.808 0.000 0.148 0.044
#> GSM40702 2 0.0566 0.831 0.000 0.984 0.004 0.012 0.000
#> GSM40706 2 0.5776 0.593 0.004 0.700 0.112 0.140 0.044
#> GSM40711 3 0.0404 0.954 0.000 0.000 0.988 0.012 0.000
#> GSM40661 3 0.1704 0.913 0.000 0.000 0.928 0.068 0.004
#> GSM40662 2 0.8334 -0.167 0.000 0.312 0.132 0.296 0.260
#> GSM40666 3 0.1638 0.921 0.000 0.000 0.932 0.064 0.004
#> GSM40669 5 0.2677 0.676 0.112 0.000 0.000 0.016 0.872
#> GSM40670 5 0.3129 0.660 0.076 0.000 0.032 0.020 0.872
#> GSM40671 1 0.2124 0.779 0.900 0.000 0.000 0.096 0.004
#> GSM40672 1 0.3011 0.687 0.844 0.000 0.000 0.016 0.140
#> GSM40673 1 0.1341 0.781 0.944 0.000 0.000 0.000 0.056
#> GSM40674 5 0.3743 0.647 0.080 0.000 0.052 0.028 0.840
#> GSM40676 4 0.6342 0.298 0.208 0.000 0.272 0.520 0.000
#> GSM40680 4 0.6972 -0.194 0.044 0.376 0.000 0.456 0.124
#> GSM40681 1 0.4357 0.659 0.768 0.000 0.000 0.128 0.104
#> GSM40683 1 0.1341 0.781 0.944 0.000 0.000 0.000 0.056
#> GSM40684 4 0.6337 0.276 0.180 0.000 0.320 0.500 0.000
#> GSM40685 5 0.7543 0.386 0.148 0.112 0.000 0.236 0.504
#> GSM40689 1 0.2074 0.771 0.896 0.000 0.000 0.104 0.000
#> GSM40690 1 0.2416 0.751 0.888 0.000 0.000 0.012 0.100
#> GSM40692 4 0.8453 -0.221 0.248 0.176 0.000 0.336 0.240
#> GSM40693 5 0.5107 0.563 0.356 0.000 0.000 0.048 0.596
#> GSM40694 5 0.5861 0.602 0.260 0.000 0.000 0.148 0.592
#> GSM40695 1 0.0912 0.790 0.972 0.000 0.000 0.012 0.016
#> GSM40696 5 0.4989 0.626 0.296 0.000 0.000 0.056 0.648
#> GSM40697 5 0.6889 0.181 0.016 0.296 0.000 0.212 0.476
#> GSM40704 1 0.1792 0.765 0.916 0.000 0.000 0.000 0.084
#> GSM40705 3 0.0510 0.953 0.000 0.000 0.984 0.016 0.000
#> GSM40707 1 0.3534 0.661 0.744 0.000 0.000 0.256 0.000
#> GSM40708 1 0.4150 0.504 0.612 0.000 0.000 0.388 0.000
#> GSM40709 3 0.4281 0.710 0.012 0.000 0.756 0.204 0.028
#> GSM40712 5 0.4120 0.629 0.072 0.012 0.000 0.112 0.804
#> GSM40713 1 0.1956 0.784 0.916 0.000 0.000 0.076 0.008
#> GSM40665 1 0.3607 0.679 0.752 0.000 0.000 0.244 0.004
#> GSM40677 2 0.2361 0.808 0.000 0.892 0.000 0.096 0.012
#> GSM40698 1 0.4866 0.482 0.580 0.000 0.000 0.392 0.028
#> GSM40701 3 0.0703 0.939 0.000 0.024 0.976 0.000 0.000
#> GSM40710 2 0.2006 0.815 0.000 0.916 0.000 0.072 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 0.92111 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.92111 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.92111 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.92111 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.0665 0.91368 0.000 0.008 0.980 0.008 0.000 0.004
#> GSM40668 3 0.0000 0.92111 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.0260 0.77140 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM40679 2 0.2001 0.77248 0.000 0.912 0.000 0.040 0.000 0.048
#> GSM40686 2 0.3728 0.72000 0.000 0.788 0.000 0.068 0.004 0.140
#> GSM40687 2 0.0547 0.77219 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM40691 2 0.3743 0.67154 0.000 0.812 0.028 0.024 0.012 0.124
#> GSM40699 2 0.1719 0.75949 0.000 0.932 0.032 0.004 0.000 0.032
#> GSM40664 2 0.6043 0.30239 0.000 0.500 0.004 0.320 0.012 0.164
#> GSM40682 2 0.2801 0.75878 0.000 0.860 0.000 0.068 0.000 0.072
#> GSM40688 2 0.4760 0.46279 0.000 0.644 0.000 0.036 0.024 0.296
#> GSM40702 2 0.1636 0.76512 0.000 0.936 0.024 0.004 0.000 0.036
#> GSM40706 2 0.6589 0.25241 0.004 0.520 0.084 0.060 0.020 0.312
#> GSM40711 3 0.0632 0.91511 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM40661 3 0.2998 0.83496 0.000 0.008 0.852 0.112 0.008 0.020
#> GSM40662 6 0.8170 0.35531 0.000 0.184 0.100 0.096 0.216 0.404
#> GSM40666 3 0.3111 0.82696 0.000 0.000 0.840 0.120 0.020 0.020
#> GSM40669 5 0.1700 0.58540 0.080 0.000 0.000 0.004 0.916 0.000
#> GSM40670 5 0.2595 0.56197 0.048 0.000 0.024 0.012 0.896 0.020
#> GSM40671 1 0.2783 0.70083 0.836 0.000 0.000 0.148 0.000 0.016
#> GSM40672 1 0.2554 0.69461 0.876 0.000 0.000 0.004 0.092 0.028
#> GSM40673 1 0.0508 0.75631 0.984 0.000 0.000 0.000 0.012 0.004
#> GSM40674 5 0.4293 0.51751 0.072 0.000 0.052 0.032 0.800 0.044
#> GSM40676 4 0.3595 0.68112 0.084 0.000 0.120 0.796 0.000 0.000
#> GSM40680 6 0.6712 0.44181 0.024 0.220 0.000 0.096 0.100 0.560
#> GSM40681 1 0.4889 0.55893 0.708 0.000 0.000 0.056 0.056 0.180
#> GSM40683 1 0.0622 0.75598 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM40684 4 0.3728 0.66542 0.068 0.000 0.140 0.788 0.000 0.004
#> GSM40685 6 0.7671 0.23519 0.112 0.120 0.000 0.056 0.268 0.444
#> GSM40689 1 0.2219 0.71202 0.864 0.000 0.000 0.136 0.000 0.000
#> GSM40690 1 0.2366 0.73238 0.900 0.000 0.000 0.020 0.024 0.056
#> GSM40692 6 0.6316 0.37514 0.108 0.096 0.000 0.012 0.180 0.604
#> GSM40693 5 0.5645 0.46304 0.372 0.000 0.000 0.012 0.504 0.112
#> GSM40694 5 0.6005 0.41990 0.232 0.000 0.000 0.012 0.516 0.240
#> GSM40695 1 0.0632 0.75477 0.976 0.000 0.000 0.024 0.000 0.000
#> GSM40696 5 0.5714 0.49629 0.308 0.000 0.000 0.012 0.540 0.140
#> GSM40697 6 0.6818 0.40848 0.020 0.256 0.000 0.032 0.216 0.476
#> GSM40704 1 0.0993 0.75127 0.964 0.000 0.000 0.000 0.024 0.012
#> GSM40705 3 0.1007 0.90669 0.000 0.000 0.956 0.044 0.000 0.000
#> GSM40707 1 0.3578 0.40470 0.660 0.000 0.000 0.340 0.000 0.000
#> GSM40708 4 0.4212 0.07696 0.424 0.000 0.000 0.560 0.000 0.016
#> GSM40709 3 0.6056 0.35655 0.004 0.000 0.540 0.320 0.068 0.068
#> GSM40712 5 0.4736 0.41466 0.044 0.000 0.000 0.044 0.704 0.208
#> GSM40713 1 0.2593 0.70036 0.844 0.000 0.000 0.148 0.008 0.000
#> GSM40665 1 0.4185 0.40947 0.644 0.000 0.000 0.332 0.004 0.020
#> GSM40677 2 0.3576 0.73039 0.000 0.800 0.000 0.060 0.004 0.136
#> GSM40698 1 0.6264 -0.00256 0.456 0.000 0.000 0.360 0.032 0.152
#> GSM40701 3 0.0951 0.90698 0.000 0.020 0.968 0.000 0.004 0.008
#> GSM40710 2 0.3039 0.74871 0.000 0.848 0.000 0.060 0.004 0.088
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> CV:skmeans 53 1.62e-05 2
#> CV:skmeans 51 1.19e-04 3
#> CV:skmeans 49 5.39e-05 4
#> CV:skmeans 45 3.07e-05 5
#> CV:skmeans 36 5.79e-03 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 35373 rows and 53 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 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.920 0.913 0.965 0.5078 0.491 0.491
#> 3 3 0.938 0.902 0.962 0.1965 0.871 0.744
#> 4 4 0.696 0.685 0.845 0.1765 0.867 0.667
#> 5 5 0.764 0.788 0.891 0.0895 0.862 0.562
#> 6 6 0.799 0.779 0.883 0.0564 0.934 0.708
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
#> GSM40663 2 0.0000 0.958 0.000 1.000
#> GSM40667 2 0.0000 0.958 0.000 1.000
#> GSM40675 2 0.0000 0.958 0.000 1.000
#> GSM40703 2 0.0000 0.958 0.000 1.000
#> GSM40660 2 0.0000 0.958 0.000 1.000
#> GSM40668 2 0.0000 0.958 0.000 1.000
#> GSM40678 2 0.0672 0.957 0.008 0.992
#> GSM40679 2 0.0672 0.957 0.008 0.992
#> GSM40686 2 0.0672 0.957 0.008 0.992
#> GSM40687 2 0.0672 0.957 0.008 0.992
#> GSM40691 2 0.0672 0.957 0.008 0.992
#> GSM40699 2 0.0000 0.958 0.000 1.000
#> GSM40664 2 0.1843 0.943 0.028 0.972
#> GSM40682 2 0.0672 0.957 0.008 0.992
#> GSM40688 2 0.0672 0.957 0.008 0.992
#> GSM40702 2 0.0000 0.958 0.000 1.000
#> GSM40706 2 0.1414 0.950 0.020 0.980
#> GSM40711 2 0.0000 0.958 0.000 1.000
#> GSM40661 2 0.0000 0.958 0.000 1.000
#> GSM40662 2 0.4298 0.883 0.088 0.912
#> GSM40666 1 0.8555 0.611 0.720 0.280
#> GSM40669 1 0.0000 0.965 1.000 0.000
#> GSM40670 1 0.0000 0.965 1.000 0.000
#> GSM40671 1 0.0000 0.965 1.000 0.000
#> GSM40672 1 0.0000 0.965 1.000 0.000
#> GSM40673 1 0.0000 0.965 1.000 0.000
#> GSM40674 1 0.0000 0.965 1.000 0.000
#> GSM40676 1 0.0672 0.959 0.992 0.008
#> GSM40680 2 0.9580 0.374 0.380 0.620
#> GSM40681 1 0.0000 0.965 1.000 0.000
#> GSM40683 1 0.0000 0.965 1.000 0.000
#> GSM40684 1 0.0672 0.959 0.992 0.008
#> GSM40685 1 0.3431 0.909 0.936 0.064
#> GSM40689 1 0.0000 0.965 1.000 0.000
#> GSM40690 1 0.0000 0.965 1.000 0.000
#> GSM40692 1 0.0000 0.965 1.000 0.000
#> GSM40693 1 0.0000 0.965 1.000 0.000
#> GSM40694 1 0.0000 0.965 1.000 0.000
#> GSM40695 1 0.0000 0.965 1.000 0.000
#> GSM40696 1 0.0000 0.965 1.000 0.000
#> GSM40697 2 0.9833 0.257 0.424 0.576
#> GSM40704 1 0.0000 0.965 1.000 0.000
#> GSM40705 2 0.0000 0.958 0.000 1.000
#> GSM40707 1 0.0000 0.965 1.000 0.000
#> GSM40708 1 0.0000 0.965 1.000 0.000
#> GSM40709 1 0.4939 0.868 0.892 0.108
#> GSM40712 1 0.9686 0.319 0.604 0.396
#> GSM40713 1 0.0000 0.965 1.000 0.000
#> GSM40665 1 0.0000 0.965 1.000 0.000
#> GSM40677 2 0.0672 0.957 0.008 0.992
#> GSM40698 1 0.0000 0.965 1.000 0.000
#> GSM40701 2 0.0000 0.958 0.000 1.000
#> GSM40710 2 0.0672 0.957 0.008 0.992
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.965 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.965 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.965 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.965 0.000 0.000 1.000
#> GSM40660 2 0.0892 0.913 0.000 0.980 0.020
#> GSM40668 3 0.0000 0.965 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40699 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40664 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40682 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40702 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40706 2 0.0424 0.921 0.008 0.992 0.000
#> GSM40711 3 0.4062 0.806 0.000 0.164 0.836
#> GSM40661 2 0.0592 0.919 0.000 0.988 0.012
#> GSM40662 2 0.0747 0.915 0.016 0.984 0.000
#> GSM40666 1 0.6416 0.523 0.676 0.304 0.020
#> GSM40669 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40670 1 0.0237 0.965 0.996 0.000 0.004
#> GSM40671 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40674 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40676 1 0.0892 0.955 0.980 0.000 0.020
#> GSM40680 2 0.2165 0.862 0.064 0.936 0.000
#> GSM40681 1 0.1289 0.946 0.968 0.032 0.000
#> GSM40683 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40684 1 0.0892 0.955 0.980 0.000 0.020
#> GSM40685 1 0.2878 0.881 0.904 0.096 0.000
#> GSM40689 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40692 1 0.1289 0.947 0.968 0.032 0.000
#> GSM40693 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40696 1 0.0237 0.965 0.996 0.004 0.000
#> GSM40697 2 0.6260 0.167 0.448 0.552 0.000
#> GSM40704 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40705 3 0.1411 0.944 0.000 0.036 0.964
#> GSM40707 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40709 1 0.4349 0.826 0.852 0.128 0.020
#> GSM40712 2 0.6286 0.145 0.464 0.536 0.000
#> GSM40713 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.967 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.925 0.000 1.000 0.000
#> GSM40698 1 0.2066 0.920 0.940 0.060 0.000
#> GSM40701 2 0.0892 0.913 0.000 0.980 0.020
#> GSM40710 2 0.0000 0.925 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 0.830 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 0.830 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 0.830 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 0.830 0.000 0.000 0.000 1.000
#> GSM40660 2 0.4941 0.419 0.000 0.564 0.436 0.000
#> GSM40668 4 0.3764 0.777 0.000 0.000 0.216 0.784
#> GSM40678 2 0.0000 0.906 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0188 0.906 0.000 0.996 0.004 0.000
#> GSM40686 2 0.1389 0.892 0.000 0.952 0.048 0.000
#> GSM40687 2 0.0000 0.906 0.000 1.000 0.000 0.000
#> GSM40691 2 0.0000 0.906 0.000 1.000 0.000 0.000
#> GSM40699 2 0.0000 0.906 0.000 1.000 0.000 0.000
#> GSM40664 2 0.2376 0.879 0.016 0.916 0.068 0.000
#> GSM40682 2 0.0000 0.906 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0817 0.903 0.000 0.976 0.024 0.000
#> GSM40702 2 0.0592 0.904 0.000 0.984 0.016 0.000
#> GSM40706 2 0.2149 0.876 0.000 0.912 0.088 0.000
#> GSM40711 4 0.6278 0.634 0.000 0.060 0.408 0.532
#> GSM40661 2 0.3486 0.775 0.000 0.812 0.188 0.000
#> GSM40662 2 0.4244 0.774 0.036 0.804 0.160 0.000
#> GSM40666 3 0.0188 0.299 0.004 0.000 0.996 0.000
#> GSM40669 3 0.4981 0.581 0.464 0.000 0.536 0.000
#> GSM40670 3 0.4967 0.592 0.452 0.000 0.548 0.000
#> GSM40671 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40672 1 0.0469 0.782 0.988 0.000 0.012 0.000
#> GSM40673 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40674 3 0.4981 0.581 0.464 0.000 0.536 0.000
#> GSM40676 1 0.4888 0.294 0.588 0.000 0.412 0.000
#> GSM40680 2 0.3474 0.840 0.064 0.868 0.068 0.000
#> GSM40681 1 0.4055 0.642 0.832 0.060 0.108 0.000
#> GSM40683 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40684 1 0.4866 0.301 0.596 0.000 0.404 0.000
#> GSM40685 1 0.3308 0.685 0.872 0.092 0.036 0.000
#> GSM40689 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40690 1 0.4830 -0.256 0.608 0.000 0.392 0.000
#> GSM40692 1 0.4804 0.557 0.780 0.148 0.072 0.000
#> GSM40693 3 0.4948 0.594 0.440 0.000 0.560 0.000
#> GSM40694 1 0.4843 -0.121 0.604 0.000 0.396 0.000
#> GSM40695 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40696 3 0.5097 0.598 0.428 0.004 0.568 0.000
#> GSM40697 3 0.7358 0.266 0.160 0.392 0.448 0.000
#> GSM40704 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40705 4 0.5398 0.669 0.000 0.016 0.404 0.580
#> GSM40707 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40708 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40709 3 0.1743 0.306 0.056 0.004 0.940 0.000
#> GSM40712 3 0.6613 0.578 0.288 0.116 0.596 0.000
#> GSM40713 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40665 1 0.0000 0.792 1.000 0.000 0.000 0.000
#> GSM40677 2 0.0336 0.906 0.000 0.992 0.008 0.000
#> GSM40698 1 0.3984 0.628 0.828 0.132 0.040 0.000
#> GSM40701 2 0.4543 0.579 0.000 0.676 0.324 0.000
#> GSM40710 2 0.0000 0.906 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40667 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40675 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40703 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0510 0.861 0.000 0.016 0.984 0.000 0.000
#> GSM40668 3 0.4256 0.272 0.000 0.000 0.564 0.436 0.000
#> GSM40678 2 0.1082 0.905 0.000 0.964 0.028 0.000 0.008
#> GSM40679 2 0.0404 0.909 0.000 0.988 0.000 0.000 0.012
#> GSM40686 2 0.1270 0.894 0.000 0.948 0.000 0.000 0.052
#> GSM40687 2 0.1082 0.905 0.000 0.964 0.028 0.000 0.008
#> GSM40691 2 0.1082 0.905 0.000 0.964 0.028 0.000 0.008
#> GSM40699 2 0.1082 0.905 0.000 0.964 0.028 0.000 0.008
#> GSM40664 2 0.4300 0.781 0.048 0.776 0.012 0.000 0.164
#> GSM40682 2 0.0290 0.909 0.000 0.992 0.000 0.000 0.008
#> GSM40688 2 0.1628 0.901 0.000 0.936 0.008 0.000 0.056
#> GSM40702 2 0.2124 0.898 0.000 0.916 0.028 0.000 0.056
#> GSM40706 2 0.2605 0.842 0.000 0.852 0.000 0.000 0.148
#> GSM40711 3 0.0609 0.869 0.000 0.000 0.980 0.020 0.000
#> GSM40661 2 0.5005 0.595 0.000 0.660 0.276 0.000 0.064
#> GSM40662 5 0.4196 0.266 0.004 0.356 0.000 0.000 0.640
#> GSM40666 3 0.1043 0.862 0.000 0.000 0.960 0.000 0.040
#> GSM40669 5 0.2690 0.738 0.156 0.000 0.000 0.000 0.844
#> GSM40670 5 0.2648 0.741 0.152 0.000 0.000 0.000 0.848
#> GSM40671 1 0.0510 0.883 0.984 0.000 0.016 0.000 0.000
#> GSM40672 1 0.0609 0.874 0.980 0.000 0.000 0.000 0.020
#> GSM40673 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.2648 0.742 0.152 0.000 0.000 0.000 0.848
#> GSM40676 3 0.0794 0.865 0.028 0.000 0.972 0.000 0.000
#> GSM40680 2 0.4258 0.767 0.072 0.768 0.000 0.000 0.160
#> GSM40681 1 0.5307 0.558 0.676 0.168 0.000 0.000 0.156
#> GSM40683 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM40684 3 0.0794 0.865 0.028 0.000 0.972 0.000 0.000
#> GSM40685 1 0.3593 0.756 0.828 0.088 0.000 0.000 0.084
#> GSM40689 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM40690 5 0.4278 0.335 0.452 0.000 0.000 0.000 0.548
#> GSM40692 1 0.5125 0.575 0.696 0.148 0.000 0.000 0.156
#> GSM40693 5 0.1965 0.743 0.096 0.000 0.000 0.000 0.904
#> GSM40694 5 0.3949 0.433 0.332 0.000 0.000 0.000 0.668
#> GSM40695 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM40696 5 0.1792 0.740 0.084 0.000 0.000 0.000 0.916
#> GSM40697 5 0.4291 0.487 0.016 0.276 0.004 0.000 0.704
#> GSM40704 1 0.0162 0.883 0.996 0.000 0.000 0.000 0.004
#> GSM40705 3 0.0794 0.866 0.000 0.000 0.972 0.028 0.000
#> GSM40707 1 0.0510 0.883 0.984 0.000 0.016 0.000 0.000
#> GSM40708 1 0.0510 0.883 0.984 0.000 0.016 0.000 0.000
#> GSM40709 3 0.2563 0.814 0.008 0.000 0.872 0.000 0.120
#> GSM40712 5 0.0510 0.702 0.016 0.000 0.000 0.000 0.984
#> GSM40713 1 0.0000 0.885 1.000 0.000 0.000 0.000 0.000
#> GSM40665 1 0.0510 0.883 0.984 0.000 0.016 0.000 0.000
#> GSM40677 2 0.0404 0.910 0.000 0.988 0.000 0.000 0.012
#> GSM40698 1 0.5877 0.382 0.576 0.332 0.016 0.000 0.076
#> GSM40701 3 0.3519 0.648 0.000 0.216 0.776 0.000 0.008
#> GSM40710 2 0.0162 0.909 0.000 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.0000 0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40668 4 0.3782 0.316 0.000 0.000 0.412 0.588 0.000 0.000
#> GSM40678 6 0.0865 0.766 0.000 0.036 0.000 0.000 0.000 0.964
#> GSM40679 2 0.2048 0.838 0.000 0.880 0.000 0.000 0.000 0.120
#> GSM40686 2 0.2118 0.838 0.000 0.888 0.000 0.000 0.008 0.104
#> GSM40687 6 0.0865 0.766 0.000 0.036 0.000 0.000 0.000 0.964
#> GSM40691 6 0.1075 0.762 0.000 0.048 0.000 0.000 0.000 0.952
#> GSM40699 6 0.0865 0.766 0.000 0.036 0.000 0.000 0.000 0.964
#> GSM40664 2 0.0622 0.809 0.000 0.980 0.000 0.000 0.012 0.008
#> GSM40682 2 0.2092 0.836 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM40688 2 0.3221 0.653 0.000 0.736 0.000 0.000 0.000 0.264
#> GSM40702 6 0.3810 0.365 0.000 0.428 0.000 0.000 0.000 0.572
#> GSM40706 2 0.2257 0.776 0.000 0.876 0.000 0.000 0.008 0.116
#> GSM40711 4 0.0000 0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40661 6 0.4823 0.452 0.000 0.388 0.000 0.060 0.000 0.552
#> GSM40662 5 0.3409 0.632 0.000 0.300 0.000 0.000 0.700 0.000
#> GSM40666 4 0.0000 0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40669 5 0.1074 0.789 0.012 0.028 0.000 0.000 0.960 0.000
#> GSM40670 5 0.1921 0.789 0.052 0.032 0.000 0.000 0.916 0.000
#> GSM40671 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40672 1 0.2060 0.884 0.900 0.000 0.000 0.000 0.084 0.016
#> GSM40673 1 0.1168 0.917 0.956 0.000 0.000 0.000 0.028 0.016
#> GSM40674 5 0.1890 0.786 0.060 0.024 0.000 0.000 0.916 0.000
#> GSM40676 4 0.0000 0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40680 2 0.0363 0.803 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM40681 1 0.4566 0.540 0.652 0.280 0.000 0.000 0.068 0.000
#> GSM40683 1 0.1168 0.917 0.956 0.000 0.000 0.000 0.028 0.016
#> GSM40684 4 0.0000 0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40685 1 0.2606 0.854 0.888 0.044 0.000 0.000 0.020 0.048
#> GSM40689 1 0.1168 0.917 0.956 0.000 0.000 0.000 0.028 0.016
#> GSM40690 5 0.4076 0.373 0.364 0.000 0.000 0.000 0.620 0.016
#> GSM40692 1 0.3457 0.705 0.752 0.232 0.000 0.000 0.016 0.000
#> GSM40693 5 0.0000 0.786 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM40694 5 0.5012 0.424 0.336 0.088 0.000 0.000 0.576 0.000
#> GSM40695 1 0.0622 0.920 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM40696 5 0.0000 0.786 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM40697 5 0.5932 0.517 0.052 0.240 0.000 0.000 0.588 0.120
#> GSM40704 1 0.1245 0.916 0.952 0.000 0.000 0.000 0.032 0.016
#> GSM40705 4 0.0000 0.921 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40707 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40708 1 0.0146 0.919 0.996 0.004 0.000 0.000 0.000 0.000
#> GSM40709 4 0.2349 0.828 0.008 0.080 0.000 0.892 0.020 0.000
#> GSM40712 5 0.1075 0.784 0.000 0.048 0.000 0.000 0.952 0.000
#> GSM40713 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40665 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40677 2 0.1957 0.840 0.000 0.888 0.000 0.000 0.000 0.112
#> GSM40698 2 0.3741 0.447 0.320 0.672 0.000 0.000 0.008 0.000
#> GSM40701 6 0.4355 0.283 0.000 0.024 0.000 0.420 0.000 0.556
#> GSM40710 2 0.2664 0.792 0.000 0.816 0.000 0.000 0.000 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 disease.state(p) k
#> CV:pam 50 1.30e-06 2
#> CV:pam 51 6.73e-09 3
#> CV:pam 45 9.11e-06 4
#> CV:pam 47 1.24e-08 5
#> CV:pam 46 1.59e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.470 0.777 0.835 0.3747 0.505 0.505
#> 3 3 0.520 0.873 0.902 0.2606 0.534 0.382
#> 4 4 0.420 0.712 0.782 0.2590 0.965 0.935
#> 5 5 0.608 0.564 0.806 0.2456 0.623 0.317
#> 6 6 0.826 0.843 0.908 0.0957 0.906 0.626
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
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
#> GSM40663 2 0.1414 0.588 0.020 0.980
#> GSM40667 2 0.1414 0.588 0.020 0.980
#> GSM40675 2 0.1414 0.588 0.020 0.980
#> GSM40703 2 0.1414 0.588 0.020 0.980
#> GSM40660 2 0.9775 0.756 0.412 0.588
#> GSM40668 2 0.9000 0.771 0.316 0.684
#> GSM40678 2 0.9815 0.742 0.420 0.580
#> GSM40679 1 0.9732 -0.329 0.596 0.404
#> GSM40686 2 0.9732 0.763 0.404 0.596
#> GSM40687 2 0.9686 0.763 0.396 0.604
#> GSM40691 1 0.0000 0.929 1.000 0.000
#> GSM40699 2 0.9795 0.762 0.416 0.584
#> GSM40664 1 1.0000 -0.680 0.500 0.500
#> GSM40682 2 0.9896 0.736 0.440 0.560
#> GSM40688 1 0.0000 0.929 1.000 0.000
#> GSM40702 2 0.9850 0.756 0.428 0.572
#> GSM40706 1 0.0000 0.929 1.000 0.000
#> GSM40711 2 0.9044 0.772 0.320 0.680
#> GSM40661 2 0.9815 0.756 0.420 0.580
#> GSM40662 1 0.2948 0.866 0.948 0.052
#> GSM40666 2 1.0000 0.586 0.496 0.504
#> GSM40669 1 0.0000 0.929 1.000 0.000
#> GSM40670 1 0.0000 0.929 1.000 0.000
#> GSM40671 1 0.1184 0.922 0.984 0.016
#> GSM40672 1 0.0000 0.929 1.000 0.000
#> GSM40673 1 0.1184 0.922 0.984 0.016
#> GSM40674 1 0.0000 0.929 1.000 0.000
#> GSM40676 2 0.9815 0.728 0.420 0.580
#> GSM40680 1 0.3274 0.852 0.940 0.060
#> GSM40681 1 0.0672 0.924 0.992 0.008
#> GSM40683 1 0.1184 0.922 0.984 0.016
#> GSM40684 2 0.9754 0.742 0.408 0.592
#> GSM40685 1 0.0000 0.929 1.000 0.000
#> GSM40689 1 0.1184 0.922 0.984 0.016
#> GSM40690 1 0.0000 0.929 1.000 0.000
#> GSM40692 1 0.0000 0.929 1.000 0.000
#> GSM40693 1 0.0000 0.929 1.000 0.000
#> GSM40694 1 0.0000 0.929 1.000 0.000
#> GSM40695 1 0.1184 0.922 0.984 0.016
#> GSM40696 1 0.0000 0.929 1.000 0.000
#> GSM40697 1 0.0000 0.929 1.000 0.000
#> GSM40704 1 0.1184 0.922 0.984 0.016
#> GSM40705 2 0.9286 0.775 0.344 0.656
#> GSM40707 1 0.2778 0.884 0.952 0.048
#> GSM40708 1 0.4431 0.813 0.908 0.092
#> GSM40709 2 0.9998 0.597 0.492 0.508
#> GSM40712 1 0.0000 0.929 1.000 0.000
#> GSM40713 1 0.1184 0.922 0.984 0.016
#> GSM40665 1 0.1414 0.919 0.980 0.020
#> GSM40677 2 0.9686 0.765 0.396 0.604
#> GSM40698 1 0.1184 0.918 0.984 0.016
#> GSM40701 2 0.9358 0.779 0.352 0.648
#> GSM40710 2 0.9963 0.704 0.464 0.536
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 1.0000 0.000 0.000 1.000
#> GSM40667 3 0.0000 1.0000 0.000 0.000 1.000
#> GSM40675 3 0.0000 1.0000 0.000 0.000 1.000
#> GSM40703 3 0.0000 1.0000 0.000 0.000 1.000
#> GSM40660 2 0.2711 0.8974 0.088 0.912 0.000
#> GSM40668 2 0.5435 0.8489 0.048 0.808 0.144
#> GSM40678 2 0.0747 0.8566 0.016 0.984 0.000
#> GSM40679 2 0.0747 0.8566 0.016 0.984 0.000
#> GSM40686 2 0.0747 0.8566 0.016 0.984 0.000
#> GSM40687 2 0.0747 0.8566 0.016 0.984 0.000
#> GSM40691 2 0.2261 0.8826 0.068 0.932 0.000
#> GSM40699 2 0.0592 0.8590 0.012 0.988 0.000
#> GSM40664 2 0.3192 0.8988 0.112 0.888 0.000
#> GSM40682 2 0.0747 0.8566 0.016 0.984 0.000
#> GSM40688 2 0.2261 0.8827 0.068 0.932 0.000
#> GSM40702 2 0.0000 0.8656 0.000 1.000 0.000
#> GSM40706 2 0.3116 0.8961 0.108 0.892 0.000
#> GSM40711 2 0.5588 0.8827 0.124 0.808 0.068
#> GSM40661 2 0.2711 0.8975 0.088 0.912 0.000
#> GSM40662 2 0.2959 0.8987 0.100 0.900 0.000
#> GSM40666 2 0.4002 0.8903 0.160 0.840 0.000
#> GSM40669 2 0.4842 0.8627 0.224 0.776 0.000
#> GSM40670 2 0.4702 0.8725 0.212 0.788 0.000
#> GSM40671 1 0.1529 0.9204 0.960 0.040 0.000
#> GSM40672 1 0.0892 0.9170 0.980 0.020 0.000
#> GSM40673 1 0.0892 0.9170 0.980 0.020 0.000
#> GSM40674 2 0.4605 0.8775 0.204 0.796 0.000
#> GSM40676 2 0.4452 0.8742 0.192 0.808 0.000
#> GSM40680 2 0.3340 0.8981 0.120 0.880 0.000
#> GSM40681 2 0.5291 0.7952 0.268 0.732 0.000
#> GSM40683 1 0.1163 0.9225 0.972 0.028 0.000
#> GSM40684 2 0.4452 0.8742 0.192 0.808 0.000
#> GSM40685 2 0.3752 0.8962 0.144 0.856 0.000
#> GSM40689 1 0.1289 0.9235 0.968 0.032 0.000
#> GSM40690 1 0.1411 0.9230 0.964 0.036 0.000
#> GSM40692 2 0.3686 0.8966 0.140 0.860 0.000
#> GSM40693 1 0.6204 -0.0123 0.576 0.424 0.000
#> GSM40694 2 0.5431 0.7884 0.284 0.716 0.000
#> GSM40695 1 0.1289 0.9235 0.968 0.032 0.000
#> GSM40696 2 0.5363 0.8027 0.276 0.724 0.000
#> GSM40697 2 0.3879 0.8950 0.152 0.848 0.000
#> GSM40704 1 0.0892 0.9170 0.980 0.020 0.000
#> GSM40705 2 0.5588 0.8827 0.124 0.808 0.068
#> GSM40707 1 0.1529 0.9206 0.960 0.040 0.000
#> GSM40708 2 0.4796 0.8520 0.220 0.780 0.000
#> GSM40709 2 0.4178 0.8852 0.172 0.828 0.000
#> GSM40712 2 0.4002 0.8931 0.160 0.840 0.000
#> GSM40713 1 0.1289 0.9235 0.968 0.032 0.000
#> GSM40665 1 0.2066 0.8970 0.940 0.060 0.000
#> GSM40677 2 0.0747 0.8566 0.016 0.984 0.000
#> GSM40698 2 0.4452 0.8742 0.192 0.808 0.000
#> GSM40701 2 0.1411 0.8820 0.036 0.964 0.000
#> GSM40710 2 0.0747 0.8566 0.016 0.984 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40660 2 0.4625 0.726 0.140 0.804 0.044 0.012
#> GSM40668 2 0.4887 0.716 0.184 0.772 0.028 0.016
#> GSM40678 2 0.3764 0.632 0.000 0.784 0.216 0.000
#> GSM40679 2 0.3610 0.639 0.000 0.800 0.200 0.000
#> GSM40686 2 0.3764 0.632 0.000 0.784 0.216 0.000
#> GSM40687 2 0.3764 0.632 0.000 0.784 0.216 0.000
#> GSM40691 2 0.4277 0.638 0.000 0.720 0.280 0.000
#> GSM40699 2 0.2704 0.678 0.000 0.876 0.124 0.000
#> GSM40664 2 0.2999 0.728 0.132 0.864 0.004 0.000
#> GSM40682 2 0.2760 0.669 0.000 0.872 0.128 0.000
#> GSM40688 2 0.4564 0.643 0.000 0.672 0.328 0.000
#> GSM40702 2 0.2149 0.685 0.000 0.912 0.088 0.000
#> GSM40706 2 0.4883 0.643 0.016 0.696 0.288 0.000
#> GSM40711 2 0.5022 0.714 0.188 0.764 0.032 0.016
#> GSM40661 2 0.4365 0.718 0.188 0.784 0.028 0.000
#> GSM40662 2 0.3778 0.715 0.052 0.848 0.100 0.000
#> GSM40666 2 0.4716 0.715 0.196 0.764 0.040 0.000
#> GSM40669 2 0.6638 0.280 0.084 0.496 0.420 0.000
#> GSM40670 2 0.6862 0.498 0.128 0.560 0.312 0.000
#> GSM40671 1 0.1824 0.864 0.936 0.060 0.004 0.000
#> GSM40672 1 0.3497 0.735 0.860 0.036 0.104 0.000
#> GSM40673 1 0.2053 0.848 0.924 0.004 0.072 0.000
#> GSM40674 2 0.6907 0.436 0.120 0.532 0.348 0.000
#> GSM40676 2 0.4692 0.708 0.212 0.756 0.032 0.000
#> GSM40680 2 0.4568 0.726 0.124 0.800 0.076 0.000
#> GSM40681 2 0.4677 0.569 0.316 0.680 0.004 0.000
#> GSM40683 1 0.1807 0.875 0.940 0.008 0.052 0.000
#> GSM40684 2 0.4692 0.708 0.212 0.756 0.032 0.000
#> GSM40685 2 0.5093 0.546 0.012 0.640 0.348 0.000
#> GSM40689 1 0.0921 0.887 0.972 0.028 0.000 0.000
#> GSM40690 1 0.3182 0.828 0.876 0.096 0.028 0.000
#> GSM40692 2 0.5062 0.606 0.020 0.680 0.300 0.000
#> GSM40693 3 0.6426 0.858 0.272 0.108 0.620 0.000
#> GSM40694 2 0.7181 0.138 0.152 0.512 0.336 0.000
#> GSM40695 1 0.1256 0.890 0.964 0.028 0.008 0.000
#> GSM40696 3 0.6664 0.868 0.216 0.164 0.620 0.000
#> GSM40697 2 0.4819 0.558 0.004 0.652 0.344 0.000
#> GSM40704 1 0.2053 0.848 0.924 0.004 0.072 0.000
#> GSM40705 2 0.5022 0.714 0.188 0.764 0.032 0.016
#> GSM40707 1 0.1305 0.885 0.960 0.036 0.004 0.000
#> GSM40708 2 0.4741 0.623 0.328 0.668 0.004 0.000
#> GSM40709 2 0.4716 0.715 0.196 0.764 0.040 0.000
#> GSM40712 2 0.5036 0.573 0.024 0.696 0.280 0.000
#> GSM40713 1 0.2500 0.870 0.916 0.040 0.044 0.000
#> GSM40665 1 0.1661 0.875 0.944 0.052 0.004 0.000
#> GSM40677 2 0.3764 0.632 0.000 0.784 0.216 0.000
#> GSM40698 2 0.4283 0.689 0.256 0.740 0.004 0.000
#> GSM40701 2 0.3552 0.728 0.128 0.848 0.024 0.000
#> GSM40710 2 0.3764 0.632 0.000 0.784 0.216 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40667 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40675 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40703 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> GSM40660 3 0.4562 0.5023 0.000 0.032 0.676 0.000 0.292
#> GSM40668 3 0.1914 0.6410 0.000 0.032 0.932 0.004 0.032
#> GSM40678 2 0.0566 0.8311 0.000 0.984 0.004 0.000 0.012
#> GSM40679 2 0.0566 0.8311 0.000 0.984 0.004 0.000 0.012
#> GSM40686 2 0.0566 0.8300 0.004 0.984 0.000 0.000 0.012
#> GSM40687 2 0.0566 0.8311 0.000 0.984 0.004 0.000 0.012
#> GSM40691 5 0.2927 0.7466 0.000 0.092 0.040 0.000 0.868
#> GSM40699 2 0.3445 0.7427 0.000 0.824 0.036 0.000 0.140
#> GSM40664 3 0.6056 0.3229 0.012 0.088 0.520 0.000 0.380
#> GSM40682 2 0.4507 0.4422 0.004 0.644 0.012 0.000 0.340
#> GSM40688 5 0.4367 0.1518 0.004 0.416 0.000 0.000 0.580
#> GSM40702 2 0.5274 0.3071 0.000 0.572 0.056 0.000 0.372
#> GSM40706 5 0.1661 0.7862 0.000 0.036 0.024 0.000 0.940
#> GSM40711 3 0.1493 0.6391 0.000 0.028 0.948 0.000 0.024
#> GSM40661 3 0.3567 0.6200 0.004 0.032 0.820 0.000 0.144
#> GSM40662 5 0.4284 0.5773 0.000 0.040 0.224 0.000 0.736
#> GSM40666 3 0.1828 0.6435 0.004 0.028 0.936 0.000 0.032
#> GSM40669 5 0.1732 0.7594 0.000 0.000 0.080 0.000 0.920
#> GSM40670 5 0.2286 0.7370 0.000 0.004 0.108 0.000 0.888
#> GSM40671 1 0.4972 0.3481 0.536 0.008 0.440 0.000 0.016
#> GSM40672 1 0.4450 -0.1340 0.508 0.004 0.000 0.000 0.488
#> GSM40673 1 0.1502 0.5478 0.940 0.004 0.000 0.000 0.056
#> GSM40674 5 0.2886 0.7212 0.000 0.008 0.148 0.000 0.844
#> GSM40676 3 0.2006 0.6316 0.024 0.020 0.932 0.000 0.024
#> GSM40680 5 0.6406 -0.1776 0.008 0.132 0.412 0.000 0.448
#> GSM40681 3 0.6795 0.2961 0.152 0.020 0.436 0.000 0.392
#> GSM40683 1 0.0566 0.5417 0.984 0.004 0.000 0.000 0.012
#> GSM40684 3 0.2006 0.6316 0.024 0.020 0.932 0.000 0.024
#> GSM40685 5 0.0854 0.7931 0.008 0.012 0.004 0.000 0.976
#> GSM40689 1 0.4911 0.2694 0.504 0.008 0.476 0.000 0.012
#> GSM40690 5 0.6773 -0.2381 0.300 0.000 0.304 0.000 0.396
#> GSM40692 5 0.1372 0.7925 0.004 0.024 0.016 0.000 0.956
#> GSM40693 5 0.1124 0.7782 0.036 0.004 0.000 0.000 0.960
#> GSM40694 5 0.0968 0.7917 0.012 0.012 0.004 0.000 0.972
#> GSM40695 1 0.3942 0.5106 0.728 0.000 0.260 0.000 0.012
#> GSM40696 5 0.0771 0.7826 0.020 0.004 0.000 0.000 0.976
#> GSM40697 5 0.0865 0.7874 0.000 0.024 0.004 0.000 0.972
#> GSM40704 1 0.1357 0.5485 0.948 0.004 0.000 0.000 0.048
#> GSM40705 3 0.1399 0.6385 0.000 0.028 0.952 0.000 0.020
#> GSM40707 3 0.4735 -0.0456 0.372 0.008 0.608 0.000 0.012
#> GSM40708 3 0.4853 0.2304 0.312 0.008 0.652 0.000 0.028
#> GSM40709 3 0.2036 0.6431 0.008 0.028 0.928 0.000 0.036
#> GSM40712 5 0.2452 0.7593 0.004 0.016 0.084 0.000 0.896
#> GSM40713 1 0.5352 0.3305 0.524 0.004 0.428 0.000 0.044
#> GSM40665 3 0.5072 -0.2758 0.456 0.008 0.516 0.000 0.020
#> GSM40677 2 0.0404 0.8306 0.000 0.988 0.000 0.000 0.012
#> GSM40698 3 0.6679 0.3149 0.136 0.020 0.456 0.000 0.388
#> GSM40701 3 0.4642 0.4857 0.000 0.032 0.660 0.000 0.308
#> GSM40710 2 0.0566 0.8300 0.004 0.984 0.000 0.000 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.1845 0.877 0.000 0.008 0.000 0.916 0.072 0.004
#> GSM40668 4 0.2009 0.837 0.000 0.008 0.084 0.904 0.004 0.000
#> GSM40678 2 0.0363 0.959 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM40679 2 0.0458 0.958 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM40686 2 0.0260 0.958 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM40687 2 0.0363 0.959 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM40691 5 0.2402 0.840 0.000 0.140 0.000 0.004 0.856 0.000
#> GSM40699 2 0.1398 0.933 0.000 0.940 0.000 0.008 0.052 0.000
#> GSM40664 6 0.6770 0.244 0.004 0.328 0.000 0.076 0.136 0.456
#> GSM40682 2 0.1663 0.903 0.000 0.912 0.000 0.000 0.088 0.000
#> GSM40688 5 0.2513 0.833 0.008 0.140 0.000 0.000 0.852 0.000
#> GSM40702 2 0.1967 0.898 0.000 0.904 0.000 0.012 0.084 0.000
#> GSM40706 5 0.0146 0.924 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM40711 4 0.0000 0.885 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40661 4 0.2555 0.872 0.000 0.016 0.000 0.888 0.064 0.032
#> GSM40662 5 0.3327 0.824 0.000 0.092 0.000 0.088 0.820 0.000
#> GSM40666 4 0.0858 0.884 0.000 0.004 0.000 0.968 0.000 0.028
#> GSM40669 5 0.0146 0.922 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM40670 5 0.0146 0.922 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM40671 6 0.2300 0.714 0.144 0.000 0.000 0.000 0.000 0.856
#> GSM40672 1 0.1812 0.831 0.912 0.000 0.000 0.000 0.080 0.008
#> GSM40673 1 0.0405 0.902 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM40674 5 0.1296 0.902 0.000 0.004 0.000 0.044 0.948 0.004
#> GSM40676 6 0.3230 0.695 0.008 0.008 0.000 0.192 0.000 0.792
#> GSM40680 5 0.5495 0.646 0.000 0.188 0.000 0.060 0.656 0.096
#> GSM40681 6 0.3674 0.712 0.004 0.016 0.000 0.060 0.104 0.816
#> GSM40683 1 0.0458 0.899 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM40684 6 0.3043 0.691 0.008 0.000 0.000 0.200 0.000 0.792
#> GSM40685 5 0.0260 0.925 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM40689 6 0.2996 0.658 0.228 0.000 0.000 0.000 0.000 0.772
#> GSM40690 6 0.4520 0.630 0.220 0.000 0.000 0.000 0.092 0.688
#> GSM40692 5 0.0260 0.925 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM40693 5 0.0767 0.922 0.012 0.008 0.000 0.000 0.976 0.004
#> GSM40694 5 0.0260 0.925 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM40695 1 0.2854 0.711 0.792 0.000 0.000 0.000 0.000 0.208
#> GSM40696 5 0.0767 0.922 0.012 0.008 0.000 0.000 0.976 0.004
#> GSM40697 5 0.0260 0.925 0.000 0.008 0.000 0.000 0.992 0.000
#> GSM40704 1 0.0405 0.902 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM40705 4 0.0000 0.885 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40707 6 0.2234 0.727 0.124 0.000 0.000 0.004 0.000 0.872
#> GSM40708 6 0.1462 0.748 0.000 0.008 0.000 0.056 0.000 0.936
#> GSM40709 4 0.3376 0.664 0.000 0.000 0.000 0.764 0.016 0.220
#> GSM40712 5 0.2803 0.861 0.000 0.012 0.000 0.052 0.872 0.064
#> GSM40713 6 0.3349 0.648 0.244 0.000 0.000 0.000 0.008 0.748
#> GSM40665 6 0.1010 0.749 0.036 0.000 0.000 0.004 0.000 0.960
#> GSM40677 2 0.0260 0.958 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM40698 6 0.3346 0.727 0.004 0.012 0.000 0.064 0.080 0.840
#> GSM40701 4 0.2149 0.866 0.000 0.016 0.000 0.900 0.080 0.004
#> GSM40710 2 0.0260 0.958 0.000 0.992 0.000 0.000 0.008 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> CV:mclust 51 1.95e-03 2
#> CV:mclust 52 5.09e-09 3
#> CV:mclust 49 2.55e-07 4
#> CV:mclust 37 2.04e-06 5
#> CV:mclust 52 1.50e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.958 0.941 0.975 0.5034 0.495 0.495
#> 3 3 0.871 0.874 0.949 0.3367 0.681 0.441
#> 4 4 0.860 0.878 0.937 0.1178 0.820 0.521
#> 5 5 0.766 0.752 0.841 0.0497 0.967 0.873
#> 6 6 0.743 0.585 0.753 0.0346 0.910 0.651
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
#> GSM40663 2 0.000 0.976 0.000 1.000
#> GSM40667 2 0.000 0.976 0.000 1.000
#> GSM40675 2 0.000 0.976 0.000 1.000
#> GSM40703 2 0.000 0.976 0.000 1.000
#> GSM40660 2 0.000 0.976 0.000 1.000
#> GSM40668 2 0.000 0.976 0.000 1.000
#> GSM40678 2 0.000 0.976 0.000 1.000
#> GSM40679 2 0.000 0.976 0.000 1.000
#> GSM40686 2 0.753 0.737 0.216 0.784
#> GSM40687 2 0.000 0.976 0.000 1.000
#> GSM40691 2 0.000 0.976 0.000 1.000
#> GSM40699 2 0.000 0.976 0.000 1.000
#> GSM40664 2 0.402 0.911 0.080 0.920
#> GSM40682 2 0.000 0.976 0.000 1.000
#> GSM40688 2 0.000 0.976 0.000 1.000
#> GSM40702 2 0.000 0.976 0.000 1.000
#> GSM40706 2 0.000 0.976 0.000 1.000
#> GSM40711 2 0.000 0.976 0.000 1.000
#> GSM40661 2 0.000 0.976 0.000 1.000
#> GSM40662 2 0.000 0.976 0.000 1.000
#> GSM40666 2 0.118 0.967 0.016 0.984
#> GSM40669 1 0.242 0.936 0.960 0.040
#> GSM40670 2 0.163 0.961 0.024 0.976
#> GSM40671 1 0.000 0.969 1.000 0.000
#> GSM40672 1 0.000 0.969 1.000 0.000
#> GSM40673 1 0.000 0.969 1.000 0.000
#> GSM40674 2 0.767 0.722 0.224 0.776
#> GSM40676 1 0.615 0.806 0.848 0.152
#> GSM40680 1 0.141 0.954 0.980 0.020
#> GSM40681 1 0.000 0.969 1.000 0.000
#> GSM40683 1 0.000 0.969 1.000 0.000
#> GSM40684 1 0.995 0.120 0.540 0.460
#> GSM40685 1 0.000 0.969 1.000 0.000
#> GSM40689 1 0.000 0.969 1.000 0.000
#> GSM40690 1 0.000 0.969 1.000 0.000
#> GSM40692 1 0.000 0.969 1.000 0.000
#> GSM40693 1 0.000 0.969 1.000 0.000
#> GSM40694 1 0.000 0.969 1.000 0.000
#> GSM40695 1 0.000 0.969 1.000 0.000
#> GSM40696 1 0.000 0.969 1.000 0.000
#> GSM40697 2 0.000 0.976 0.000 1.000
#> GSM40704 1 0.000 0.969 1.000 0.000
#> GSM40705 2 0.000 0.976 0.000 1.000
#> GSM40707 1 0.000 0.969 1.000 0.000
#> GSM40708 1 0.000 0.969 1.000 0.000
#> GSM40709 2 0.343 0.927 0.064 0.936
#> GSM40712 1 0.000 0.969 1.000 0.000
#> GSM40713 1 0.000 0.969 1.000 0.000
#> GSM40665 1 0.000 0.969 1.000 0.000
#> GSM40677 2 0.184 0.958 0.028 0.972
#> GSM40698 1 0.000 0.969 1.000 0.000
#> GSM40701 2 0.000 0.976 0.000 1.000
#> GSM40710 2 0.000 0.976 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40699 2 0.0237 0.9249 0.000 0.996 0.004
#> GSM40664 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40682 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40702 2 0.0747 0.9178 0.000 0.984 0.016
#> GSM40706 2 0.4796 0.7141 0.000 0.780 0.220
#> GSM40711 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40662 2 0.5397 0.6017 0.000 0.720 0.280
#> GSM40666 3 0.0424 0.9637 0.008 0.000 0.992
#> GSM40669 1 0.1315 0.9214 0.972 0.008 0.020
#> GSM40670 3 0.1411 0.9453 0.036 0.000 0.964
#> GSM40671 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40674 3 0.4452 0.7686 0.192 0.000 0.808
#> GSM40676 1 0.6260 0.1351 0.552 0.000 0.448
#> GSM40680 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40681 1 0.1860 0.8964 0.948 0.052 0.000
#> GSM40683 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40684 3 0.4121 0.8055 0.168 0.000 0.832
#> GSM40685 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40689 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40692 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40693 2 0.6299 0.0951 0.476 0.524 0.000
#> GSM40694 1 0.5926 0.3923 0.644 0.356 0.000
#> GSM40695 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40696 2 0.2356 0.8707 0.072 0.928 0.000
#> GSM40697 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40704 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40707 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40709 3 0.1163 0.9513 0.028 0.000 0.972
#> GSM40712 2 0.5706 0.5240 0.320 0.680 0.000
#> GSM40713 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.9272 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.9399 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.9672 0.000 0.000 1.000
#> GSM40710 2 0.0000 0.9272 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40668 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.964 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.964 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.964 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.964 0.000 1.000 0.000 0.000
#> GSM40691 2 0.0817 0.954 0.024 0.976 0.000 0.000
#> GSM40699 2 0.0000 0.964 0.000 1.000 0.000 0.000
#> GSM40664 2 0.2546 0.899 0.008 0.900 0.000 0.092
#> GSM40682 2 0.0524 0.961 0.008 0.988 0.000 0.004
#> GSM40688 2 0.0469 0.960 0.012 0.988 0.000 0.000
#> GSM40702 2 0.0672 0.959 0.008 0.984 0.000 0.008
#> GSM40706 2 0.3564 0.851 0.012 0.860 0.112 0.016
#> GSM40711 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40661 3 0.1624 0.918 0.000 0.028 0.952 0.020
#> GSM40662 3 0.5716 0.217 0.028 0.420 0.552 0.000
#> GSM40666 3 0.0336 0.945 0.008 0.000 0.992 0.000
#> GSM40669 1 0.0992 0.872 0.976 0.004 0.012 0.008
#> GSM40670 1 0.4697 0.462 0.644 0.000 0.356 0.000
#> GSM40671 4 0.2281 0.885 0.096 0.000 0.000 0.904
#> GSM40672 1 0.0707 0.870 0.980 0.000 0.000 0.020
#> GSM40673 1 0.2647 0.822 0.880 0.000 0.000 0.120
#> GSM40674 1 0.3024 0.778 0.852 0.000 0.148 0.000
#> GSM40676 4 0.0188 0.907 0.004 0.000 0.000 0.996
#> GSM40680 2 0.0927 0.956 0.008 0.976 0.000 0.016
#> GSM40681 1 0.5812 0.658 0.708 0.136 0.000 0.156
#> GSM40683 1 0.2814 0.812 0.868 0.000 0.000 0.132
#> GSM40684 4 0.1356 0.891 0.008 0.000 0.032 0.960
#> GSM40685 2 0.1211 0.943 0.040 0.960 0.000 0.000
#> GSM40689 4 0.2081 0.892 0.084 0.000 0.000 0.916
#> GSM40690 1 0.2814 0.814 0.868 0.000 0.000 0.132
#> GSM40692 2 0.0188 0.963 0.004 0.996 0.000 0.000
#> GSM40693 1 0.1109 0.871 0.968 0.028 0.000 0.004
#> GSM40694 1 0.0817 0.872 0.976 0.024 0.000 0.000
#> GSM40695 4 0.4331 0.662 0.288 0.000 0.000 0.712
#> GSM40696 1 0.1211 0.864 0.960 0.040 0.000 0.000
#> GSM40697 2 0.4540 0.735 0.196 0.772 0.032 0.000
#> GSM40704 1 0.1211 0.866 0.960 0.000 0.000 0.040
#> GSM40705 3 0.0188 0.949 0.000 0.000 0.996 0.004
#> GSM40707 4 0.0592 0.910 0.016 0.000 0.000 0.984
#> GSM40708 4 0.0000 0.905 0.000 0.000 0.000 1.000
#> GSM40709 3 0.0524 0.945 0.004 0.000 0.988 0.008
#> GSM40712 1 0.0921 0.871 0.972 0.028 0.000 0.000
#> GSM40713 4 0.4072 0.719 0.252 0.000 0.000 0.748
#> GSM40665 4 0.0921 0.910 0.028 0.000 0.000 0.972
#> GSM40677 2 0.0000 0.964 0.000 1.000 0.000 0.000
#> GSM40698 4 0.0895 0.910 0.020 0.004 0.000 0.976
#> GSM40701 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0524 0.961 0.008 0.988 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40667 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40675 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40703 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40660 3 0.0404 0.8794 0.000 0.000 0.988 NA 0.000
#> GSM40668 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40678 2 0.0609 0.8436 0.000 0.980 0.000 NA 0.000
#> GSM40679 2 0.0290 0.8441 0.000 0.992 0.000 NA 0.000
#> GSM40686 2 0.1270 0.8390 0.000 0.948 0.000 NA 0.000
#> GSM40687 2 0.0703 0.8430 0.000 0.976 0.000 NA 0.000
#> GSM40691 2 0.3911 0.7612 0.000 0.796 0.000 NA 0.060
#> GSM40699 2 0.0671 0.8446 0.000 0.980 0.004 NA 0.000
#> GSM40664 2 0.6289 0.3582 0.152 0.452 0.000 NA 0.000
#> GSM40682 2 0.3143 0.7829 0.000 0.796 0.000 NA 0.000
#> GSM40688 2 0.2628 0.8106 0.000 0.884 0.000 NA 0.028
#> GSM40702 2 0.0880 0.8440 0.000 0.968 0.000 NA 0.000
#> GSM40706 2 0.4989 0.5777 0.000 0.552 0.032 NA 0.000
#> GSM40711 3 0.0162 0.8824 0.000 0.000 0.996 NA 0.000
#> GSM40661 3 0.6587 0.4471 0.048 0.100 0.560 NA 0.000
#> GSM40662 3 0.7061 0.2316 0.000 0.312 0.504 NA 0.124
#> GSM40666 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40669 5 0.1965 0.7768 0.000 0.000 0.000 NA 0.904
#> GSM40670 3 0.5175 0.0344 0.000 0.000 0.496 NA 0.464
#> GSM40671 1 0.1750 0.8771 0.936 0.000 0.000 NA 0.036
#> GSM40672 5 0.2806 0.7800 0.004 0.000 0.000 NA 0.844
#> GSM40673 5 0.3760 0.7599 0.028 0.000 0.000 NA 0.784
#> GSM40674 5 0.4206 0.5578 0.000 0.000 0.272 NA 0.708
#> GSM40676 1 0.0771 0.8857 0.976 0.000 0.004 NA 0.000
#> GSM40680 2 0.3260 0.8171 0.056 0.856 0.000 NA 0.004
#> GSM40681 5 0.4467 0.7360 0.016 0.016 0.000 NA 0.716
#> GSM40683 5 0.4170 0.7486 0.048 0.000 0.000 NA 0.760
#> GSM40684 1 0.0671 0.8859 0.980 0.000 0.004 NA 0.000
#> GSM40685 2 0.4751 0.7062 0.000 0.732 0.000 NA 0.116
#> GSM40689 1 0.4094 0.7739 0.788 0.000 0.000 NA 0.084
#> GSM40690 5 0.5010 0.6129 0.036 0.000 0.000 NA 0.572
#> GSM40692 2 0.0865 0.8434 0.000 0.972 0.000 NA 0.004
#> GSM40693 5 0.2179 0.7719 0.000 0.000 0.000 NA 0.888
#> GSM40694 5 0.3323 0.7379 0.000 0.056 0.000 NA 0.844
#> GSM40695 5 0.6392 0.2296 0.356 0.000 0.000 NA 0.468
#> GSM40696 5 0.2763 0.7566 0.000 0.004 0.000 NA 0.848
#> GSM40697 2 0.5359 0.6655 0.000 0.692 0.008 NA 0.148
#> GSM40704 5 0.2189 0.7877 0.012 0.000 0.000 NA 0.904
#> GSM40705 3 0.0000 0.8835 0.000 0.000 1.000 NA 0.000
#> GSM40707 1 0.0510 0.8857 0.984 0.000 0.000 NA 0.000
#> GSM40708 1 0.0290 0.8854 0.992 0.000 0.000 NA 0.000
#> GSM40709 3 0.0955 0.8675 0.000 0.000 0.968 NA 0.004
#> GSM40712 5 0.1197 0.7890 0.000 0.000 0.000 NA 0.952
#> GSM40713 1 0.3386 0.7954 0.832 0.000 0.000 NA 0.128
#> GSM40665 1 0.2377 0.8542 0.872 0.000 0.000 NA 0.000
#> GSM40677 2 0.3521 0.7689 0.000 0.764 0.000 NA 0.004
#> GSM40698 1 0.5665 0.6356 0.620 0.108 0.000 NA 0.004
#> GSM40701 3 0.0162 0.8824 0.000 0.000 0.996 NA 0.000
#> GSM40710 2 0.3003 0.7972 0.000 0.812 0.000 NA 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0260 0.9207 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM40667 3 0.0260 0.9207 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM40675 3 0.0260 0.9207 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM40703 3 0.0260 0.9207 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM40660 3 0.0914 0.9081 0.000 0.000 0.968 0.016 0.016 0.000
#> GSM40668 3 0.0000 0.9206 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.0717 0.7643 0.000 0.976 0.000 0.016 0.008 0.000
#> GSM40679 2 0.1082 0.7637 0.000 0.956 0.000 0.040 0.004 0.000
#> GSM40686 2 0.1895 0.7458 0.000 0.912 0.000 0.072 0.016 0.000
#> GSM40687 2 0.1257 0.7641 0.000 0.952 0.000 0.028 0.020 0.000
#> GSM40691 2 0.3670 0.6846 0.000 0.788 0.004 0.056 0.152 0.000
#> GSM40699 2 0.1007 0.7632 0.000 0.956 0.000 0.044 0.000 0.000
#> GSM40664 4 0.4909 0.4541 0.000 0.216 0.000 0.668 0.008 0.108
#> GSM40682 2 0.4456 0.1648 0.000 0.524 0.000 0.448 0.028 0.000
#> GSM40688 2 0.2706 0.7314 0.000 0.860 0.000 0.036 0.104 0.000
#> GSM40702 2 0.1320 0.7617 0.000 0.948 0.000 0.036 0.016 0.000
#> GSM40706 4 0.6373 -0.0542 0.004 0.332 0.004 0.336 0.324 0.000
#> GSM40711 3 0.0508 0.9167 0.000 0.000 0.984 0.012 0.004 0.000
#> GSM40661 4 0.5293 0.4294 0.000 0.064 0.280 0.620 0.000 0.036
#> GSM40662 5 0.6440 0.1764 0.008 0.232 0.340 0.004 0.412 0.004
#> GSM40666 3 0.0260 0.9188 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM40669 5 0.3991 0.3482 0.472 0.000 0.004 0.000 0.524 0.000
#> GSM40670 3 0.5850 -0.3677 0.164 0.000 0.424 0.004 0.408 0.000
#> GSM40671 6 0.1906 0.8128 0.036 0.000 0.000 0.032 0.008 0.924
#> GSM40672 1 0.2558 0.5149 0.840 0.000 0.000 0.004 0.156 0.000
#> GSM40673 1 0.0260 0.6437 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM40674 5 0.6232 0.2637 0.348 0.000 0.292 0.004 0.356 0.000
#> GSM40676 6 0.1391 0.8215 0.016 0.000 0.000 0.040 0.000 0.944
#> GSM40680 2 0.4505 0.6712 0.000 0.760 0.000 0.072 0.108 0.060
#> GSM40681 1 0.2989 0.5881 0.868 0.020 0.000 0.080 0.016 0.016
#> GSM40683 1 0.0508 0.6439 0.984 0.000 0.000 0.004 0.000 0.012
#> GSM40684 6 0.1760 0.8237 0.048 0.000 0.004 0.020 0.000 0.928
#> GSM40685 2 0.4502 0.5936 0.000 0.696 0.000 0.048 0.240 0.016
#> GSM40689 6 0.5037 0.4398 0.380 0.000 0.000 0.080 0.000 0.540
#> GSM40690 4 0.6122 0.2002 0.280 0.000 0.000 0.528 0.160 0.032
#> GSM40692 2 0.1765 0.7635 0.000 0.924 0.000 0.024 0.052 0.000
#> GSM40693 5 0.4067 0.3930 0.444 0.000 0.000 0.008 0.548 0.000
#> GSM40694 5 0.5398 0.3730 0.364 0.096 0.000 0.008 0.532 0.000
#> GSM40695 1 0.2527 0.5198 0.832 0.000 0.000 0.000 0.000 0.168
#> GSM40696 5 0.4731 0.4284 0.400 0.020 0.000 0.020 0.560 0.000
#> GSM40697 2 0.4743 0.4037 0.000 0.564 0.004 0.044 0.388 0.000
#> GSM40704 1 0.3921 0.1648 0.676 0.000 0.000 0.004 0.308 0.012
#> GSM40705 3 0.0000 0.9206 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40707 6 0.0993 0.8220 0.024 0.000 0.000 0.012 0.000 0.964
#> GSM40708 6 0.0748 0.8150 0.004 0.000 0.000 0.016 0.004 0.976
#> GSM40709 3 0.2245 0.8606 0.016 0.000 0.908 0.036 0.040 0.000
#> GSM40712 1 0.4452 -0.3003 0.548 0.008 0.000 0.016 0.428 0.000
#> GSM40713 6 0.3018 0.7599 0.168 0.000 0.000 0.004 0.012 0.816
#> GSM40665 6 0.4443 0.6219 0.068 0.000 0.000 0.232 0.004 0.696
#> GSM40677 2 0.4838 0.2671 0.000 0.544 0.000 0.396 0.060 0.000
#> GSM40698 4 0.6123 0.1993 0.080 0.072 0.000 0.520 0.000 0.328
#> GSM40701 3 0.0508 0.9167 0.000 0.000 0.984 0.012 0.004 0.000
#> GSM40710 2 0.4349 0.5659 0.000 0.708 0.000 0.208 0.084 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> CV:NMF 52 0.000177 2
#> CV:NMF 50 0.003788 3
#> CV:NMF 51 0.000195 4
#> CV:NMF 48 0.000283 5
#> CV:NMF 35 0.018579 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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.827 0.893 0.949 0.4953 0.495 0.495
#> 3 3 0.748 0.820 0.913 0.3072 0.820 0.649
#> 4 4 0.645 0.654 0.789 0.1326 0.856 0.622
#> 5 5 0.727 0.696 0.845 0.0806 0.882 0.600
#> 6 6 0.752 0.679 0.821 0.0385 0.972 0.866
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
#> GSM40663 2 0.0000 0.954 0.000 1.000
#> GSM40667 2 0.0000 0.954 0.000 1.000
#> GSM40675 2 0.0000 0.954 0.000 1.000
#> GSM40703 2 0.0000 0.954 0.000 1.000
#> GSM40660 2 0.0376 0.956 0.004 0.996
#> GSM40668 2 0.0000 0.954 0.000 1.000
#> GSM40678 2 0.0672 0.957 0.008 0.992
#> GSM40679 2 0.0672 0.957 0.008 0.992
#> GSM40686 2 0.6247 0.814 0.156 0.844
#> GSM40687 2 0.0672 0.957 0.008 0.992
#> GSM40691 2 0.0672 0.957 0.008 0.992
#> GSM40699 2 0.0672 0.957 0.008 0.992
#> GSM40664 2 0.1414 0.953 0.020 0.980
#> GSM40682 2 0.0672 0.957 0.008 0.992
#> GSM40688 2 0.0672 0.957 0.008 0.992
#> GSM40702 2 0.0672 0.957 0.008 0.992
#> GSM40706 2 0.0672 0.957 0.008 0.992
#> GSM40711 2 0.3274 0.927 0.060 0.940
#> GSM40661 2 0.0938 0.956 0.012 0.988
#> GSM40662 2 0.9850 0.197 0.428 0.572
#> GSM40666 2 0.3879 0.915 0.076 0.924
#> GSM40669 1 0.9170 0.537 0.668 0.332
#> GSM40670 1 0.9170 0.537 0.668 0.332
#> GSM40671 1 0.0000 0.930 1.000 0.000
#> GSM40672 1 0.0000 0.930 1.000 0.000
#> GSM40673 1 0.0000 0.930 1.000 0.000
#> GSM40674 1 0.9460 0.467 0.636 0.364
#> GSM40676 2 0.4022 0.912 0.080 0.920
#> GSM40680 1 0.3733 0.890 0.928 0.072
#> GSM40681 1 0.0672 0.928 0.992 0.008
#> GSM40683 1 0.0000 0.930 1.000 0.000
#> GSM40684 2 0.4022 0.912 0.080 0.920
#> GSM40685 1 0.1633 0.922 0.976 0.024
#> GSM40689 1 0.0000 0.930 1.000 0.000
#> GSM40690 1 0.0000 0.930 1.000 0.000
#> GSM40692 1 0.3733 0.890 0.928 0.072
#> GSM40693 1 0.0000 0.930 1.000 0.000
#> GSM40694 1 0.1633 0.922 0.976 0.024
#> GSM40695 1 0.0000 0.930 1.000 0.000
#> GSM40696 1 0.0000 0.930 1.000 0.000
#> GSM40697 2 0.2778 0.934 0.048 0.952
#> GSM40704 1 0.0000 0.930 1.000 0.000
#> GSM40705 2 0.3274 0.927 0.060 0.940
#> GSM40707 1 0.0000 0.930 1.000 0.000
#> GSM40708 1 0.0000 0.930 1.000 0.000
#> GSM40709 2 0.4022 0.912 0.080 0.920
#> GSM40712 1 0.7674 0.716 0.776 0.224
#> GSM40713 1 0.0376 0.929 0.996 0.004
#> GSM40665 1 0.1184 0.926 0.984 0.016
#> GSM40677 2 0.0672 0.957 0.008 0.992
#> GSM40698 1 0.1184 0.926 0.984 0.016
#> GSM40701 2 0.0376 0.956 0.004 0.996
#> GSM40710 2 0.0672 0.957 0.008 0.992
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0237 0.8525 0.000 0.004 0.996
#> GSM40667 3 0.0237 0.8525 0.000 0.004 0.996
#> GSM40675 3 0.0237 0.8525 0.000 0.004 0.996
#> GSM40703 3 0.0237 0.8525 0.000 0.004 0.996
#> GSM40660 3 0.5591 0.5766 0.000 0.304 0.696
#> GSM40668 3 0.0237 0.8525 0.000 0.004 0.996
#> GSM40678 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40686 2 0.4047 0.7787 0.148 0.848 0.004
#> GSM40687 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40691 2 0.2959 0.8617 0.000 0.900 0.100
#> GSM40699 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40664 2 0.4755 0.7310 0.008 0.808 0.184
#> GSM40682 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40702 2 0.3941 0.7921 0.000 0.844 0.156
#> GSM40706 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40711 3 0.3694 0.8577 0.052 0.052 0.896
#> GSM40661 3 0.6302 0.1108 0.000 0.480 0.520
#> GSM40662 1 0.9370 -0.0456 0.420 0.168 0.412
#> GSM40666 3 0.4087 0.8526 0.068 0.052 0.880
#> GSM40669 1 0.7384 0.5606 0.660 0.068 0.272
#> GSM40670 1 0.7384 0.5606 0.660 0.068 0.272
#> GSM40671 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40674 1 0.7671 0.5032 0.628 0.072 0.300
#> GSM40676 3 0.4179 0.8509 0.072 0.052 0.876
#> GSM40680 1 0.2682 0.8663 0.920 0.076 0.004
#> GSM40681 1 0.0592 0.9040 0.988 0.012 0.000
#> GSM40683 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40684 3 0.4179 0.8509 0.072 0.052 0.876
#> GSM40685 1 0.1289 0.8965 0.968 0.032 0.000
#> GSM40689 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40692 1 0.2682 0.8663 0.920 0.076 0.004
#> GSM40693 1 0.0237 0.9061 0.996 0.004 0.000
#> GSM40694 1 0.1289 0.8962 0.968 0.032 0.000
#> GSM40695 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40696 1 0.0237 0.9061 0.996 0.004 0.000
#> GSM40697 2 0.3764 0.8677 0.040 0.892 0.068
#> GSM40704 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40705 3 0.3694 0.8577 0.052 0.052 0.896
#> GSM40707 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.9063 1.000 0.000 0.000
#> GSM40709 3 0.4179 0.8504 0.072 0.052 0.876
#> GSM40712 1 0.6174 0.7141 0.768 0.064 0.168
#> GSM40713 1 0.0237 0.9061 0.996 0.004 0.000
#> GSM40665 1 0.1129 0.8997 0.976 0.020 0.004
#> GSM40677 2 0.0000 0.9333 0.000 1.000 0.000
#> GSM40698 1 0.1129 0.8997 0.976 0.020 0.004
#> GSM40701 3 0.5098 0.6555 0.000 0.248 0.752
#> GSM40710 2 0.0000 0.9333 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 0.84253 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 0.84253 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 0.84253 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 0.84253 0.000 0.000 0.000 1.000
#> GSM40660 4 0.5883 0.53494 0.000 0.288 0.064 0.648
#> GSM40668 4 0.0000 0.84253 0.000 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40686 2 0.4083 0.76854 0.068 0.832 0.100 0.000
#> GSM40687 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40691 2 0.2987 0.83184 0.000 0.880 0.104 0.016
#> GSM40699 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40664 2 0.4049 0.71360 0.000 0.780 0.212 0.008
#> GSM40682 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0336 0.89234 0.000 0.992 0.008 0.000
#> GSM40702 2 0.4037 0.78382 0.000 0.832 0.056 0.112
#> GSM40706 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40711 3 0.4961 0.30250 0.000 0.000 0.552 0.448
#> GSM40661 2 0.7486 -0.00815 0.000 0.464 0.188 0.348
#> GSM40662 3 0.6993 0.41938 0.100 0.120 0.684 0.096
#> GSM40666 3 0.5097 0.33554 0.004 0.000 0.568 0.428
#> GSM40669 3 0.4504 0.21532 0.204 0.020 0.772 0.004
#> GSM40670 3 0.4504 0.21532 0.204 0.020 0.772 0.004
#> GSM40671 1 0.0188 0.76965 0.996 0.000 0.004 0.000
#> GSM40672 1 0.0592 0.77135 0.984 0.000 0.016 0.000
#> GSM40673 1 0.0000 0.76791 1.000 0.000 0.000 0.000
#> GSM40674 3 0.5438 0.25835 0.200 0.024 0.740 0.036
#> GSM40676 3 0.4916 0.33785 0.000 0.000 0.576 0.424
#> GSM40680 1 0.6204 0.58151 0.500 0.052 0.448 0.000
#> GSM40681 1 0.4331 0.73556 0.712 0.000 0.288 0.000
#> GSM40683 1 0.0000 0.76791 1.000 0.000 0.000 0.000
#> GSM40684 3 0.4916 0.33785 0.000 0.000 0.576 0.424
#> GSM40685 1 0.5290 0.59654 0.516 0.008 0.476 0.000
#> GSM40689 1 0.3219 0.76691 0.836 0.000 0.164 0.000
#> GSM40690 1 0.1637 0.77660 0.940 0.000 0.060 0.000
#> GSM40692 1 0.6204 0.58151 0.500 0.052 0.448 0.000
#> GSM40693 1 0.2469 0.77285 0.892 0.000 0.108 0.000
#> GSM40694 1 0.5273 0.61694 0.536 0.008 0.456 0.000
#> GSM40695 1 0.0188 0.76965 0.996 0.000 0.004 0.000
#> GSM40696 1 0.2469 0.77285 0.892 0.000 0.108 0.000
#> GSM40697 2 0.3224 0.82395 0.016 0.864 0.120 0.000
#> GSM40704 1 0.0000 0.76791 1.000 0.000 0.000 0.000
#> GSM40705 3 0.4961 0.30250 0.000 0.000 0.552 0.448
#> GSM40707 1 0.4406 0.71492 0.700 0.000 0.300 0.000
#> GSM40708 1 0.4406 0.71492 0.700 0.000 0.300 0.000
#> GSM40709 3 0.5088 0.33934 0.004 0.000 0.572 0.424
#> GSM40712 3 0.5047 -0.15723 0.316 0.016 0.668 0.000
#> GSM40713 1 0.3024 0.78310 0.852 0.000 0.148 0.000
#> GSM40665 1 0.4522 0.72975 0.680 0.000 0.320 0.000
#> GSM40677 2 0.0000 0.89559 0.000 1.000 0.000 0.000
#> GSM40698 1 0.4888 0.67322 0.588 0.000 0.412 0.000
#> GSM40701 4 0.4840 0.62211 0.000 0.240 0.028 0.732
#> GSM40710 2 0.0000 0.89559 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.1121 0.8676 0.000 0.000 0.956 0.044 0.000
#> GSM40667 3 0.1121 0.8676 0.000 0.000 0.956 0.044 0.000
#> GSM40675 3 0.1121 0.8676 0.000 0.000 0.956 0.044 0.000
#> GSM40703 3 0.1121 0.8676 0.000 0.000 0.956 0.044 0.000
#> GSM40660 3 0.6104 0.5521 0.000 0.268 0.604 0.104 0.024
#> GSM40668 3 0.1121 0.8676 0.000 0.000 0.956 0.044 0.000
#> GSM40678 2 0.0000 0.8905 0.000 1.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 0.8905 0.000 1.000 0.000 0.000 0.000
#> GSM40686 2 0.3333 0.7667 0.008 0.820 0.000 0.008 0.164
#> GSM40687 2 0.0000 0.8905 0.000 1.000 0.000 0.000 0.000
#> GSM40691 2 0.2856 0.8259 0.000 0.872 0.008 0.104 0.016
#> GSM40699 2 0.0000 0.8905 0.000 1.000 0.000 0.000 0.000
#> GSM40664 2 0.3961 0.6974 0.000 0.760 0.000 0.212 0.028
#> GSM40682 2 0.0000 0.8905 0.000 1.000 0.000 0.000 0.000
#> GSM40688 2 0.0510 0.8852 0.000 0.984 0.000 0.000 0.016
#> GSM40702 2 0.4131 0.7675 0.000 0.812 0.100 0.064 0.024
#> GSM40706 2 0.0000 0.8905 0.000 1.000 0.000 0.000 0.000
#> GSM40711 4 0.0963 0.8702 0.000 0.000 0.036 0.964 0.000
#> GSM40661 2 0.7140 0.0388 0.000 0.444 0.304 0.228 0.024
#> GSM40662 4 0.6072 -0.0901 0.000 0.104 0.004 0.460 0.432
#> GSM40666 4 0.0324 0.8802 0.004 0.000 0.004 0.992 0.000
#> GSM40669 5 0.4557 0.4482 0.008 0.012 0.000 0.324 0.656
#> GSM40670 5 0.4557 0.4482 0.008 0.012 0.000 0.324 0.656
#> GSM40671 1 0.0771 0.8060 0.976 0.000 0.004 0.000 0.020
#> GSM40672 1 0.0880 0.8034 0.968 0.000 0.000 0.000 0.032
#> GSM40673 1 0.0000 0.8094 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.4633 0.4018 0.004 0.016 0.000 0.348 0.632
#> GSM40676 4 0.0451 0.8810 0.000 0.000 0.004 0.988 0.008
#> GSM40680 5 0.3216 0.6675 0.068 0.048 0.000 0.016 0.868
#> GSM40681 5 0.4283 0.3226 0.348 0.000 0.000 0.008 0.644
#> GSM40683 1 0.0000 0.8094 1.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.0451 0.8810 0.000 0.000 0.004 0.988 0.008
#> GSM40685 5 0.1430 0.6676 0.052 0.000 0.000 0.004 0.944
#> GSM40689 1 0.4879 0.5088 0.728 0.000 0.032 0.036 0.204
#> GSM40690 1 0.3003 0.7177 0.812 0.000 0.000 0.000 0.188
#> GSM40692 5 0.3216 0.6675 0.068 0.048 0.000 0.016 0.868
#> GSM40693 1 0.3730 0.6130 0.712 0.000 0.000 0.000 0.288
#> GSM40694 5 0.2520 0.6612 0.096 0.004 0.000 0.012 0.888
#> GSM40695 1 0.0671 0.8074 0.980 0.000 0.004 0.000 0.016
#> GSM40696 1 0.3730 0.6130 0.712 0.000 0.000 0.000 0.288
#> GSM40697 2 0.3301 0.8161 0.000 0.848 0.000 0.072 0.080
#> GSM40704 1 0.0000 0.8094 1.000 0.000 0.000 0.000 0.000
#> GSM40705 4 0.0963 0.8702 0.000 0.000 0.036 0.964 0.000
#> GSM40707 5 0.5331 0.3945 0.364 0.000 0.044 0.008 0.584
#> GSM40708 5 0.5331 0.3945 0.364 0.000 0.044 0.008 0.584
#> GSM40709 4 0.0324 0.8785 0.004 0.000 0.000 0.992 0.004
#> GSM40712 5 0.3840 0.5774 0.012 0.008 0.000 0.208 0.772
#> GSM40713 1 0.4196 0.4337 0.640 0.000 0.004 0.000 0.356
#> GSM40665 5 0.6316 0.2742 0.344 0.000 0.040 0.072 0.544
#> GSM40677 2 0.0162 0.8892 0.000 0.996 0.000 0.000 0.004
#> GSM40698 5 0.5275 0.5728 0.188 0.000 0.032 0.068 0.712
#> GSM40701 3 0.5303 0.6559 0.000 0.224 0.688 0.068 0.020
#> GSM40710 2 0.0000 0.8905 0.000 1.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
#> GSM40663 3 0.0146 0.8742 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40667 3 0.0146 0.8742 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40675 3 0.0146 0.8742 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40703 3 0.0146 0.8742 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40660 3 0.5855 0.6132 0.000 0.208 0.624 0.064 0.004 0.100
#> GSM40668 3 0.0146 0.8742 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40678 2 0.0000 0.8292 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 0.8292 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40686 2 0.4464 0.7067 0.000 0.712 0.000 0.000 0.148 0.140
#> GSM40687 2 0.1204 0.8254 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM40691 2 0.4273 0.7604 0.000 0.768 0.008 0.068 0.016 0.140
#> GSM40699 2 0.0000 0.8292 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40664 2 0.5055 0.5930 0.000 0.652 0.000 0.184 0.004 0.160
#> GSM40682 2 0.0000 0.8292 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40688 2 0.2884 0.7878 0.000 0.824 0.004 0.000 0.008 0.164
#> GSM40702 2 0.4657 0.6846 0.000 0.752 0.100 0.044 0.004 0.100
#> GSM40706 2 0.1141 0.8224 0.000 0.948 0.000 0.000 0.000 0.052
#> GSM40711 4 0.0790 0.9641 0.000 0.000 0.032 0.968 0.000 0.000
#> GSM40661 2 0.7465 -0.1298 0.000 0.352 0.324 0.184 0.004 0.136
#> GSM40662 5 0.6361 0.2029 0.000 0.064 0.004 0.412 0.432 0.088
#> GSM40666 4 0.0405 0.9685 0.000 0.000 0.000 0.988 0.008 0.004
#> GSM40669 5 0.4146 0.5426 0.000 0.000 0.000 0.288 0.676 0.036
#> GSM40670 5 0.4146 0.5426 0.000 0.000 0.000 0.288 0.676 0.036
#> GSM40671 1 0.0820 0.7446 0.972 0.000 0.000 0.000 0.012 0.016
#> GSM40672 1 0.0790 0.7480 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM40673 1 0.0000 0.7541 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.4361 0.5133 0.000 0.000 0.000 0.308 0.648 0.044
#> GSM40676 4 0.0363 0.9730 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM40680 5 0.1498 0.6045 0.000 0.028 0.000 0.000 0.940 0.032
#> GSM40681 5 0.3650 0.3462 0.280 0.000 0.000 0.000 0.708 0.012
#> GSM40683 1 0.0000 0.7541 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.0363 0.9730 0.000 0.000 0.000 0.988 0.000 0.012
#> GSM40685 5 0.0993 0.6059 0.012 0.000 0.000 0.000 0.964 0.024
#> GSM40689 1 0.3930 0.3132 0.728 0.000 0.000 0.032 0.004 0.236
#> GSM40690 1 0.2902 0.6714 0.800 0.000 0.000 0.000 0.196 0.004
#> GSM40692 5 0.1498 0.6045 0.000 0.028 0.000 0.000 0.940 0.032
#> GSM40693 1 0.3528 0.5992 0.700 0.000 0.000 0.000 0.296 0.004
#> GSM40694 5 0.1257 0.5998 0.028 0.000 0.000 0.000 0.952 0.020
#> GSM40695 1 0.0717 0.7466 0.976 0.000 0.000 0.000 0.008 0.016
#> GSM40696 1 0.3528 0.5992 0.700 0.000 0.000 0.000 0.296 0.004
#> GSM40697 2 0.5157 0.7143 0.000 0.676 0.004 0.044 0.060 0.216
#> GSM40704 1 0.0000 0.7541 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40705 4 0.0790 0.9641 0.000 0.000 0.032 0.968 0.000 0.000
#> GSM40707 6 0.4931 1.0000 0.248 0.000 0.000 0.000 0.116 0.636
#> GSM40708 6 0.4931 1.0000 0.248 0.000 0.000 0.000 0.116 0.636
#> GSM40709 4 0.0622 0.9641 0.000 0.000 0.000 0.980 0.012 0.008
#> GSM40712 5 0.3236 0.6164 0.000 0.000 0.000 0.180 0.796 0.024
#> GSM40713 1 0.4379 0.3142 0.576 0.000 0.000 0.000 0.396 0.028
#> GSM40665 5 0.7031 -0.3666 0.284 0.000 0.000 0.064 0.364 0.288
#> GSM40677 2 0.2520 0.7939 0.000 0.844 0.004 0.000 0.000 0.152
#> GSM40698 5 0.6195 0.0132 0.124 0.000 0.000 0.064 0.556 0.256
#> GSM40701 3 0.4847 0.6845 0.000 0.176 0.708 0.032 0.000 0.084
#> GSM40710 2 0.1204 0.8254 0.000 0.944 0.000 0.000 0.000 0.056
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:hclust 51 9.94e-05 2
#> MAD:hclust 51 9.83e-07 3
#> MAD:hclust 41 2.58e-08 4
#> MAD:hclust 43 1.14e-05 5
#> MAD:hclust 46 2.61e-05 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.850 0.951 0.975 0.5058 0.492 0.492
#> 3 3 0.596 0.692 0.817 0.2906 0.792 0.602
#> 4 4 0.592 0.733 0.830 0.1449 0.819 0.527
#> 5 5 0.776 0.714 0.815 0.0695 0.971 0.880
#> 6 6 0.763 0.563 0.712 0.0381 0.898 0.590
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
#> GSM40663 2 0.000 0.990 0.000 1.000
#> GSM40667 2 0.000 0.990 0.000 1.000
#> GSM40675 2 0.000 0.990 0.000 1.000
#> GSM40703 2 0.000 0.990 0.000 1.000
#> GSM40660 2 0.000 0.990 0.000 1.000
#> GSM40668 2 0.000 0.990 0.000 1.000
#> GSM40678 2 0.000 0.990 0.000 1.000
#> GSM40679 2 0.000 0.990 0.000 1.000
#> GSM40686 2 0.781 0.682 0.232 0.768
#> GSM40687 2 0.000 0.990 0.000 1.000
#> GSM40691 2 0.000 0.990 0.000 1.000
#> GSM40699 2 0.000 0.990 0.000 1.000
#> GSM40664 2 0.000 0.990 0.000 1.000
#> GSM40682 2 0.000 0.990 0.000 1.000
#> GSM40688 2 0.000 0.990 0.000 1.000
#> GSM40702 2 0.000 0.990 0.000 1.000
#> GSM40706 2 0.000 0.990 0.000 1.000
#> GSM40711 2 0.000 0.990 0.000 1.000
#> GSM40661 2 0.000 0.990 0.000 1.000
#> GSM40662 2 0.000 0.990 0.000 1.000
#> GSM40666 1 0.680 0.818 0.820 0.180
#> GSM40669 1 0.000 0.958 1.000 0.000
#> GSM40670 1 0.680 0.818 0.820 0.180
#> GSM40671 1 0.000 0.958 1.000 0.000
#> GSM40672 1 0.000 0.958 1.000 0.000
#> GSM40673 1 0.000 0.958 1.000 0.000
#> GSM40674 1 0.706 0.804 0.808 0.192
#> GSM40676 1 0.671 0.822 0.824 0.176
#> GSM40680 1 0.000 0.958 1.000 0.000
#> GSM40681 1 0.000 0.958 1.000 0.000
#> GSM40683 1 0.000 0.958 1.000 0.000
#> GSM40684 1 0.671 0.822 0.824 0.176
#> GSM40685 1 0.000 0.958 1.000 0.000
#> GSM40689 1 0.000 0.958 1.000 0.000
#> GSM40690 1 0.000 0.958 1.000 0.000
#> GSM40692 1 0.000 0.958 1.000 0.000
#> GSM40693 1 0.000 0.958 1.000 0.000
#> GSM40694 1 0.000 0.958 1.000 0.000
#> GSM40695 1 0.000 0.958 1.000 0.000
#> GSM40696 1 0.000 0.958 1.000 0.000
#> GSM40697 2 0.000 0.990 0.000 1.000
#> GSM40704 1 0.000 0.958 1.000 0.000
#> GSM40705 2 0.000 0.990 0.000 1.000
#> GSM40707 1 0.000 0.958 1.000 0.000
#> GSM40708 1 0.000 0.958 1.000 0.000
#> GSM40709 1 0.706 0.804 0.808 0.192
#> GSM40712 1 0.000 0.958 1.000 0.000
#> GSM40713 1 0.000 0.958 1.000 0.000
#> GSM40665 1 0.000 0.958 1.000 0.000
#> GSM40677 2 0.000 0.990 0.000 1.000
#> GSM40698 1 0.000 0.958 1.000 0.000
#> GSM40701 2 0.000 0.990 0.000 1.000
#> GSM40710 2 0.000 0.990 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.5968 0.674 0.000 0.364 0.636
#> GSM40667 3 0.5968 0.674 0.000 0.364 0.636
#> GSM40675 3 0.5968 0.674 0.000 0.364 0.636
#> GSM40703 3 0.5968 0.674 0.000 0.364 0.636
#> GSM40660 3 0.6095 0.644 0.000 0.392 0.608
#> GSM40668 3 0.5968 0.674 0.000 0.364 0.636
#> GSM40678 2 0.0000 0.846 0.000 1.000 0.000
#> GSM40679 2 0.0237 0.847 0.000 0.996 0.004
#> GSM40686 2 0.5881 0.659 0.016 0.728 0.256
#> GSM40687 2 0.0000 0.846 0.000 1.000 0.000
#> GSM40691 2 0.0237 0.847 0.000 0.996 0.004
#> GSM40699 2 0.1964 0.766 0.000 0.944 0.056
#> GSM40664 2 0.0237 0.847 0.000 0.996 0.004
#> GSM40682 2 0.0237 0.847 0.000 0.996 0.004
#> GSM40688 2 0.4465 0.742 0.004 0.820 0.176
#> GSM40702 2 0.0000 0.846 0.000 1.000 0.000
#> GSM40706 2 0.0000 0.846 0.000 1.000 0.000
#> GSM40711 3 0.5216 0.645 0.000 0.260 0.740
#> GSM40661 3 0.5988 0.672 0.000 0.368 0.632
#> GSM40662 2 0.6079 0.528 0.000 0.612 0.388
#> GSM40666 3 0.7642 0.228 0.248 0.092 0.660
#> GSM40669 1 0.7536 0.644 0.632 0.064 0.304
#> GSM40670 1 0.8056 0.512 0.532 0.068 0.400
#> GSM40671 1 0.1753 0.820 0.952 0.000 0.048
#> GSM40672 1 0.0000 0.830 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.830 1.000 0.000 0.000
#> GSM40674 1 0.8056 0.512 0.532 0.068 0.400
#> GSM40676 3 0.8426 0.052 0.384 0.092 0.524
#> GSM40680 1 0.9936 0.163 0.380 0.336 0.284
#> GSM40681 1 0.0592 0.830 0.988 0.000 0.012
#> GSM40683 1 0.0000 0.830 1.000 0.000 0.000
#> GSM40684 3 0.8426 0.052 0.384 0.092 0.524
#> GSM40685 1 0.4605 0.770 0.796 0.000 0.204
#> GSM40689 1 0.1860 0.818 0.948 0.000 0.052
#> GSM40690 1 0.0000 0.830 1.000 0.000 0.000
#> GSM40692 1 0.8132 0.623 0.612 0.104 0.284
#> GSM40693 1 0.3686 0.792 0.860 0.000 0.140
#> GSM40694 1 0.4555 0.772 0.800 0.000 0.200
#> GSM40695 1 0.0000 0.830 1.000 0.000 0.000
#> GSM40696 1 0.3686 0.792 0.860 0.000 0.140
#> GSM40697 2 0.5690 0.636 0.004 0.708 0.288
#> GSM40704 1 0.0000 0.830 1.000 0.000 0.000
#> GSM40705 3 0.5216 0.645 0.000 0.260 0.740
#> GSM40707 1 0.1860 0.818 0.948 0.000 0.052
#> GSM40708 1 0.2448 0.820 0.924 0.000 0.076
#> GSM40709 3 0.7642 0.228 0.248 0.092 0.660
#> GSM40712 1 0.7159 0.670 0.660 0.052 0.288
#> GSM40713 1 0.2537 0.821 0.920 0.000 0.080
#> GSM40665 1 0.1860 0.818 0.948 0.000 0.052
#> GSM40677 2 0.4465 0.742 0.004 0.820 0.176
#> GSM40698 1 0.2537 0.820 0.920 0.000 0.080
#> GSM40701 3 0.6008 0.670 0.000 0.372 0.628
#> GSM40710 2 0.0000 0.846 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.3024 0.895 0.000 0.148 0.000 0.852
#> GSM40667 4 0.3024 0.895 0.000 0.148 0.000 0.852
#> GSM40675 4 0.3024 0.895 0.000 0.148 0.000 0.852
#> GSM40703 4 0.3024 0.895 0.000 0.148 0.000 0.852
#> GSM40660 4 0.6121 0.856 0.000 0.156 0.164 0.680
#> GSM40668 4 0.3024 0.895 0.000 0.148 0.000 0.852
#> GSM40678 2 0.0000 0.943 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0188 0.944 0.000 0.996 0.004 0.000
#> GSM40686 2 0.3172 0.812 0.000 0.840 0.160 0.000
#> GSM40687 2 0.0000 0.943 0.000 1.000 0.000 0.000
#> GSM40691 2 0.0921 0.929 0.000 0.972 0.028 0.000
#> GSM40699 2 0.0336 0.939 0.000 0.992 0.000 0.008
#> GSM40664 2 0.0188 0.944 0.000 0.996 0.004 0.000
#> GSM40682 2 0.0188 0.944 0.000 0.996 0.004 0.000
#> GSM40688 2 0.2973 0.828 0.000 0.856 0.144 0.000
#> GSM40702 2 0.0188 0.944 0.000 0.996 0.004 0.000
#> GSM40706 2 0.0000 0.943 0.000 1.000 0.000 0.000
#> GSM40711 4 0.5118 0.793 0.000 0.072 0.176 0.752
#> GSM40661 4 0.5905 0.868 0.000 0.156 0.144 0.700
#> GSM40662 3 0.3161 0.637 0.000 0.124 0.864 0.012
#> GSM40666 3 0.4825 0.459 0.004 0.008 0.700 0.288
#> GSM40669 3 0.3837 0.615 0.224 0.000 0.776 0.000
#> GSM40670 3 0.2926 0.665 0.096 0.004 0.888 0.012
#> GSM40671 1 0.4458 0.772 0.808 0.000 0.116 0.076
#> GSM40672 1 0.0000 0.800 1.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.800 1.000 0.000 0.000 0.000
#> GSM40674 3 0.2926 0.665 0.096 0.004 0.888 0.012
#> GSM40676 3 0.6704 0.433 0.120 0.008 0.628 0.244
#> GSM40680 3 0.5272 0.629 0.112 0.136 0.752 0.000
#> GSM40681 1 0.2408 0.722 0.896 0.000 0.104 0.000
#> GSM40683 1 0.0000 0.800 1.000 0.000 0.000 0.000
#> GSM40684 3 0.6704 0.433 0.120 0.008 0.628 0.244
#> GSM40685 3 0.5158 0.155 0.472 0.000 0.524 0.004
#> GSM40689 1 0.4513 0.771 0.804 0.000 0.120 0.076
#> GSM40690 1 0.0000 0.800 1.000 0.000 0.000 0.000
#> GSM40692 3 0.5143 0.627 0.172 0.076 0.752 0.000
#> GSM40693 1 0.4500 0.347 0.684 0.000 0.316 0.000
#> GSM40694 3 0.4998 0.128 0.488 0.000 0.512 0.000
#> GSM40695 1 0.0000 0.800 1.000 0.000 0.000 0.000
#> GSM40696 1 0.4500 0.347 0.684 0.000 0.316 0.000
#> GSM40697 3 0.4564 0.402 0.000 0.328 0.672 0.000
#> GSM40704 1 0.0000 0.800 1.000 0.000 0.000 0.000
#> GSM40705 4 0.5118 0.793 0.000 0.072 0.176 0.752
#> GSM40707 1 0.4513 0.771 0.804 0.000 0.120 0.076
#> GSM40708 1 0.4872 0.756 0.776 0.000 0.148 0.076
#> GSM40709 3 0.4799 0.462 0.004 0.008 0.704 0.284
#> GSM40712 3 0.4008 0.596 0.244 0.000 0.756 0.000
#> GSM40713 1 0.5845 0.625 0.672 0.000 0.252 0.076
#> GSM40665 1 0.4513 0.771 0.804 0.000 0.120 0.076
#> GSM40677 2 0.3024 0.827 0.000 0.852 0.148 0.000
#> GSM40698 1 0.5631 0.684 0.700 0.000 0.224 0.076
#> GSM40701 4 0.5234 0.885 0.000 0.152 0.096 0.752
#> GSM40710 2 0.0188 0.944 0.000 0.996 0.004 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0510 0.715 0.000 0.016 0.984 0.000 0.000
#> GSM40667 3 0.0510 0.715 0.000 0.016 0.984 0.000 0.000
#> GSM40675 3 0.0510 0.715 0.000 0.016 0.984 0.000 0.000
#> GSM40703 3 0.0510 0.715 0.000 0.016 0.984 0.000 0.000
#> GSM40660 3 0.5696 0.455 0.000 0.040 0.472 0.468 0.020
#> GSM40668 3 0.1018 0.714 0.000 0.016 0.968 0.016 0.000
#> GSM40678 2 0.0510 0.956 0.000 0.984 0.000 0.016 0.000
#> GSM40679 2 0.1012 0.958 0.000 0.968 0.000 0.020 0.012
#> GSM40686 2 0.2473 0.932 0.000 0.896 0.000 0.072 0.032
#> GSM40687 2 0.0609 0.955 0.000 0.980 0.000 0.020 0.000
#> GSM40691 2 0.2046 0.947 0.000 0.916 0.000 0.068 0.016
#> GSM40699 2 0.1082 0.953 0.000 0.964 0.000 0.028 0.008
#> GSM40664 2 0.1626 0.956 0.000 0.940 0.000 0.044 0.016
#> GSM40682 2 0.1522 0.956 0.000 0.944 0.000 0.044 0.012
#> GSM40688 2 0.2450 0.926 0.000 0.896 0.000 0.076 0.028
#> GSM40702 2 0.1300 0.953 0.000 0.956 0.000 0.028 0.016
#> GSM40706 2 0.0324 0.957 0.000 0.992 0.000 0.004 0.004
#> GSM40711 3 0.4968 0.457 0.000 0.000 0.516 0.456 0.028
#> GSM40661 3 0.5421 0.490 0.000 0.024 0.500 0.456 0.020
#> GSM40662 5 0.2338 0.819 0.000 0.004 0.000 0.112 0.884
#> GSM40666 4 0.5261 0.657 0.004 0.000 0.044 0.572 0.380
#> GSM40669 5 0.2260 0.853 0.028 0.000 0.000 0.064 0.908
#> GSM40670 5 0.2193 0.829 0.008 0.000 0.000 0.092 0.900
#> GSM40671 1 0.5194 0.619 0.632 0.000 0.012 0.316 0.040
#> GSM40672 1 0.0162 0.685 0.996 0.000 0.000 0.000 0.004
#> GSM40673 1 0.0451 0.686 0.988 0.000 0.000 0.008 0.004
#> GSM40674 5 0.2249 0.829 0.008 0.000 0.000 0.096 0.896
#> GSM40676 4 0.3760 0.682 0.016 0.000 0.044 0.828 0.112
#> GSM40680 5 0.1948 0.856 0.024 0.008 0.000 0.036 0.932
#> GSM40681 1 0.3241 0.627 0.832 0.000 0.000 0.024 0.144
#> GSM40683 1 0.0451 0.686 0.988 0.000 0.000 0.008 0.004
#> GSM40684 4 0.3760 0.682 0.016 0.000 0.044 0.828 0.112
#> GSM40685 5 0.2873 0.785 0.120 0.000 0.000 0.020 0.860
#> GSM40689 1 0.4919 0.624 0.656 0.000 0.012 0.304 0.028
#> GSM40690 1 0.0451 0.682 0.988 0.000 0.000 0.004 0.008
#> GSM40692 5 0.1996 0.857 0.032 0.004 0.000 0.036 0.928
#> GSM40693 1 0.4446 -0.128 0.520 0.000 0.000 0.004 0.476
#> GSM40694 5 0.2997 0.764 0.148 0.000 0.000 0.012 0.840
#> GSM40695 1 0.0451 0.686 0.988 0.000 0.000 0.008 0.004
#> GSM40696 1 0.4446 -0.128 0.520 0.000 0.000 0.004 0.476
#> GSM40697 5 0.3410 0.755 0.000 0.092 0.000 0.068 0.840
#> GSM40704 1 0.0162 0.685 0.996 0.000 0.000 0.000 0.004
#> GSM40705 3 0.4968 0.457 0.000 0.000 0.516 0.456 0.028
#> GSM40707 1 0.5557 0.587 0.564 0.000 0.016 0.376 0.044
#> GSM40708 1 0.5925 0.558 0.528 0.000 0.016 0.388 0.068
#> GSM40709 4 0.5261 0.657 0.004 0.000 0.044 0.572 0.380
#> GSM40712 5 0.1485 0.860 0.032 0.000 0.000 0.020 0.948
#> GSM40713 1 0.6064 0.549 0.516 0.000 0.012 0.384 0.088
#> GSM40665 1 0.5400 0.590 0.572 0.000 0.012 0.376 0.040
#> GSM40677 2 0.2740 0.920 0.000 0.876 0.000 0.096 0.028
#> GSM40698 1 0.6126 0.545 0.500 0.000 0.012 0.396 0.092
#> GSM40701 3 0.4684 0.642 0.000 0.024 0.712 0.244 0.020
#> GSM40710 2 0.0703 0.955 0.000 0.976 0.000 0.024 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0363 0.8516 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM40667 3 0.0363 0.8516 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM40675 3 0.0363 0.8516 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM40703 3 0.0363 0.8516 0.000 0.012 0.988 0.000 0.000 0.000
#> GSM40660 6 0.6649 0.8937 0.000 0.032 0.244 0.168 0.028 0.528
#> GSM40668 3 0.1624 0.8090 0.000 0.012 0.936 0.008 0.000 0.044
#> GSM40678 2 0.1462 0.8396 0.000 0.936 0.000 0.008 0.000 0.056
#> GSM40679 2 0.2006 0.8442 0.000 0.892 0.000 0.004 0.000 0.104
#> GSM40686 2 0.3359 0.7719 0.000 0.784 0.000 0.008 0.012 0.196
#> GSM40687 2 0.1462 0.8396 0.000 0.936 0.000 0.008 0.000 0.056
#> GSM40691 2 0.3789 0.7617 0.000 0.668 0.000 0.004 0.004 0.324
#> GSM40699 2 0.2912 0.8017 0.000 0.784 0.000 0.000 0.000 0.216
#> GSM40664 2 0.2980 0.8260 0.000 0.808 0.000 0.012 0.000 0.180
#> GSM40682 2 0.2482 0.8363 0.000 0.848 0.000 0.004 0.000 0.148
#> GSM40688 2 0.3764 0.7342 0.000 0.724 0.000 0.008 0.012 0.256
#> GSM40702 2 0.2793 0.8047 0.000 0.800 0.000 0.000 0.000 0.200
#> GSM40706 2 0.1471 0.8478 0.000 0.932 0.000 0.004 0.000 0.064
#> GSM40711 4 0.7058 -0.6804 0.000 0.000 0.320 0.328 0.064 0.288
#> GSM40661 6 0.6683 0.8887 0.000 0.024 0.296 0.176 0.024 0.480
#> GSM40662 5 0.3023 0.8020 0.000 0.000 0.000 0.032 0.828 0.140
#> GSM40666 4 0.6409 -0.3178 0.000 0.000 0.012 0.356 0.304 0.328
#> GSM40669 5 0.1584 0.8276 0.008 0.000 0.000 0.000 0.928 0.064
#> GSM40670 5 0.2145 0.8083 0.000 0.000 0.000 0.028 0.900 0.072
#> GSM40671 4 0.3823 0.2660 0.436 0.000 0.000 0.564 0.000 0.000
#> GSM40672 1 0.0000 0.7766 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40673 1 0.0363 0.7739 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM40674 5 0.2201 0.8077 0.000 0.000 0.000 0.028 0.896 0.076
#> GSM40676 4 0.4596 -0.0484 0.000 0.000 0.004 0.696 0.096 0.204
#> GSM40680 5 0.4084 0.8130 0.016 0.008 0.000 0.060 0.784 0.132
#> GSM40681 1 0.5180 0.5891 0.692 0.000 0.000 0.060 0.164 0.084
#> GSM40683 1 0.0363 0.7739 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM40684 4 0.4596 -0.0484 0.000 0.000 0.004 0.696 0.096 0.204
#> GSM40685 5 0.4484 0.7572 0.040 0.000 0.000 0.056 0.744 0.160
#> GSM40689 4 0.3986 0.2310 0.464 0.000 0.004 0.532 0.000 0.000
#> GSM40690 1 0.1116 0.7653 0.960 0.000 0.000 0.008 0.004 0.028
#> GSM40692 5 0.4084 0.8130 0.016 0.008 0.000 0.060 0.784 0.132
#> GSM40693 1 0.4868 0.3024 0.548 0.000 0.000 0.004 0.396 0.052
#> GSM40694 5 0.4359 0.7477 0.084 0.000 0.000 0.052 0.772 0.092
#> GSM40695 1 0.0363 0.7739 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM40696 1 0.4868 0.3024 0.548 0.000 0.000 0.004 0.396 0.052
#> GSM40697 5 0.4180 0.7525 0.000 0.024 0.000 0.008 0.680 0.288
#> GSM40704 1 0.0000 0.7766 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40705 4 0.7055 -0.6772 0.000 0.000 0.320 0.332 0.064 0.284
#> GSM40707 4 0.4212 0.2997 0.392 0.000 0.008 0.592 0.000 0.008
#> GSM40708 4 0.4469 0.3099 0.364 0.000 0.008 0.608 0.012 0.008
#> GSM40709 4 0.6409 -0.3178 0.000 0.000 0.012 0.356 0.304 0.328
#> GSM40712 5 0.1577 0.8333 0.016 0.000 0.000 0.036 0.940 0.008
#> GSM40713 4 0.4301 0.3002 0.392 0.000 0.000 0.584 0.024 0.000
#> GSM40665 4 0.4056 0.2862 0.416 0.000 0.004 0.576 0.000 0.004
#> GSM40677 2 0.3852 0.7367 0.000 0.732 0.000 0.016 0.012 0.240
#> GSM40698 4 0.5188 0.2772 0.364 0.000 0.004 0.568 0.024 0.040
#> GSM40701 3 0.5891 -0.3412 0.000 0.048 0.508 0.064 0.004 0.376
#> GSM40710 2 0.1124 0.8386 0.000 0.956 0.000 0.008 0.000 0.036
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:kmeans 53 1.45e-06 2
#> MAD:kmeans 48 7.61e-07 3
#> MAD:kmeans 44 7.11e-06 4
#> MAD:kmeans 47 1.96e-08 5
#> MAD:kmeans 37 1.38e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "skmeans"]
# you can also extract it by
# res = res_list["MAD:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 35373 rows and 53 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 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.996 0.998 0.5085 0.492 0.492
#> 3 3 0.971 0.933 0.973 0.3108 0.745 0.527
#> 4 4 0.784 0.736 0.870 0.1185 0.878 0.649
#> 5 5 0.744 0.640 0.806 0.0559 0.896 0.641
#> 6 6 0.749 0.626 0.812 0.0405 0.954 0.804
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
#> GSM40663 2 0.0000 0.999 0.000 1.000
#> GSM40667 2 0.0000 0.999 0.000 1.000
#> GSM40675 2 0.0000 0.999 0.000 1.000
#> GSM40703 2 0.0000 0.999 0.000 1.000
#> GSM40660 2 0.0000 0.999 0.000 1.000
#> GSM40668 2 0.0000 0.999 0.000 1.000
#> GSM40678 2 0.0000 0.999 0.000 1.000
#> GSM40679 2 0.0000 0.999 0.000 1.000
#> GSM40686 2 0.1633 0.976 0.024 0.976
#> GSM40687 2 0.0000 0.999 0.000 1.000
#> GSM40691 2 0.0000 0.999 0.000 1.000
#> GSM40699 2 0.0000 0.999 0.000 1.000
#> GSM40664 2 0.0000 0.999 0.000 1.000
#> GSM40682 2 0.0000 0.999 0.000 1.000
#> GSM40688 2 0.0000 0.999 0.000 1.000
#> GSM40702 2 0.0000 0.999 0.000 1.000
#> GSM40706 2 0.0000 0.999 0.000 1.000
#> GSM40711 2 0.0000 0.999 0.000 1.000
#> GSM40661 2 0.0000 0.999 0.000 1.000
#> GSM40662 2 0.0000 0.999 0.000 1.000
#> GSM40666 1 0.0000 0.997 1.000 0.000
#> GSM40669 1 0.0000 0.997 1.000 0.000
#> GSM40670 1 0.0000 0.997 1.000 0.000
#> GSM40671 1 0.0000 0.997 1.000 0.000
#> GSM40672 1 0.0000 0.997 1.000 0.000
#> GSM40673 1 0.0000 0.997 1.000 0.000
#> GSM40674 1 0.1843 0.972 0.972 0.028
#> GSM40676 1 0.0672 0.990 0.992 0.008
#> GSM40680 1 0.0000 0.997 1.000 0.000
#> GSM40681 1 0.0000 0.997 1.000 0.000
#> GSM40683 1 0.0000 0.997 1.000 0.000
#> GSM40684 1 0.0000 0.997 1.000 0.000
#> GSM40685 1 0.0000 0.997 1.000 0.000
#> GSM40689 1 0.0000 0.997 1.000 0.000
#> GSM40690 1 0.0000 0.997 1.000 0.000
#> GSM40692 1 0.0000 0.997 1.000 0.000
#> GSM40693 1 0.0000 0.997 1.000 0.000
#> GSM40694 1 0.0000 0.997 1.000 0.000
#> GSM40695 1 0.0000 0.997 1.000 0.000
#> GSM40696 1 0.0000 0.997 1.000 0.000
#> GSM40697 2 0.0000 0.999 0.000 1.000
#> GSM40704 1 0.0000 0.997 1.000 0.000
#> GSM40705 2 0.0000 0.999 0.000 1.000
#> GSM40707 1 0.0000 0.997 1.000 0.000
#> GSM40708 1 0.0000 0.997 1.000 0.000
#> GSM40709 1 0.2778 0.952 0.952 0.048
#> GSM40712 1 0.0000 0.997 1.000 0.000
#> GSM40713 1 0.0000 0.997 1.000 0.000
#> GSM40665 1 0.0000 0.997 1.000 0.000
#> GSM40677 2 0.0000 0.999 0.000 1.000
#> GSM40698 1 0.0000 0.997 1.000 0.000
#> GSM40701 2 0.0000 0.999 0.000 1.000
#> GSM40710 2 0.0000 0.999 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40678 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40679 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40686 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40687 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40691 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40699 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40664 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40682 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40688 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40702 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40706 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40711 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40662 3 0.5988 0.418 0.000 0.368 0.632
#> GSM40666 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40669 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40670 3 0.5948 0.480 0.360 0.000 0.640
#> GSM40671 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40674 3 0.5785 0.535 0.332 0.000 0.668
#> GSM40676 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40680 1 0.5905 0.440 0.648 0.352 0.000
#> GSM40681 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40684 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40685 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40689 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40692 1 0.0424 0.974 0.992 0.008 0.000
#> GSM40693 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40696 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40697 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40704 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40707 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40709 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40712 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40713 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40677 2 0.0000 1.000 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.981 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.928 0.000 0.000 1.000
#> GSM40710 2 0.0000 1.000 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40668 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40691 2 0.1576 0.9242 0.000 0.948 0.048 0.004
#> GSM40699 2 0.1389 0.9251 0.000 0.952 0.048 0.000
#> GSM40664 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40682 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0188 0.9518 0.000 0.996 0.000 0.004
#> GSM40702 2 0.1302 0.9280 0.000 0.956 0.044 0.000
#> GSM40706 2 0.0000 0.9531 0.000 1.000 0.000 0.000
#> GSM40711 3 0.1716 0.8578 0.000 0.000 0.936 0.064
#> GSM40661 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40662 4 0.7052 -0.0574 0.000 0.128 0.372 0.500
#> GSM40666 3 0.4356 0.6918 0.000 0.000 0.708 0.292
#> GSM40669 4 0.1716 0.5828 0.064 0.000 0.000 0.936
#> GSM40670 4 0.1151 0.5606 0.008 0.000 0.024 0.968
#> GSM40671 1 0.0000 0.8518 1.000 0.000 0.000 0.000
#> GSM40672 1 0.2704 0.8458 0.876 0.000 0.000 0.124
#> GSM40673 1 0.2589 0.8534 0.884 0.000 0.000 0.116
#> GSM40674 4 0.2988 0.4772 0.012 0.000 0.112 0.876
#> GSM40676 3 0.6584 0.5013 0.336 0.000 0.568 0.096
#> GSM40680 4 0.6607 0.3555 0.400 0.084 0.000 0.516
#> GSM40681 1 0.3123 0.8121 0.844 0.000 0.000 0.156
#> GSM40683 1 0.2589 0.8534 0.884 0.000 0.000 0.116
#> GSM40684 3 0.6552 0.5135 0.328 0.000 0.576 0.096
#> GSM40685 4 0.4941 0.3481 0.436 0.000 0.000 0.564
#> GSM40689 1 0.0000 0.8518 1.000 0.000 0.000 0.000
#> GSM40690 1 0.2530 0.8551 0.888 0.000 0.000 0.112
#> GSM40692 1 0.5695 -0.2871 0.500 0.024 0.000 0.476
#> GSM40693 4 0.4999 0.2395 0.492 0.000 0.000 0.508
#> GSM40694 4 0.4967 0.3207 0.452 0.000 0.000 0.548
#> GSM40695 1 0.2530 0.8551 0.888 0.000 0.000 0.112
#> GSM40696 4 0.5000 0.2281 0.496 0.000 0.000 0.504
#> GSM40697 2 0.5250 0.2889 0.000 0.552 0.008 0.440
#> GSM40704 1 0.2589 0.8534 0.884 0.000 0.000 0.116
#> GSM40705 3 0.1716 0.8578 0.000 0.000 0.936 0.064
#> GSM40707 1 0.0188 0.8510 0.996 0.000 0.000 0.004
#> GSM40708 1 0.0188 0.8510 0.996 0.000 0.000 0.004
#> GSM40709 3 0.4382 0.6874 0.000 0.000 0.704 0.296
#> GSM40712 4 0.2530 0.5795 0.112 0.000 0.000 0.888
#> GSM40713 1 0.0921 0.8572 0.972 0.000 0.000 0.028
#> GSM40665 1 0.0000 0.8518 1.000 0.000 0.000 0.000
#> GSM40677 2 0.0188 0.9518 0.000 0.996 0.000 0.004
#> GSM40698 1 0.0469 0.8468 0.988 0.000 0.000 0.012
#> GSM40701 3 0.0000 0.8809 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0000 0.9531 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.8799 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.8799 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.8799 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.8799 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.0162 0.8773 0.000 0.000 0.996 0.004 0.000
#> GSM40668 3 0.0000 0.8799 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0000 0.9265 0.000 1.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 0.9265 0.000 1.000 0.000 0.000 0.000
#> GSM40686 2 0.0671 0.9194 0.000 0.980 0.000 0.016 0.004
#> GSM40687 2 0.0000 0.9265 0.000 1.000 0.000 0.000 0.000
#> GSM40691 2 0.3353 0.7695 0.000 0.796 0.196 0.008 0.000
#> GSM40699 2 0.3534 0.7044 0.000 0.744 0.256 0.000 0.000
#> GSM40664 2 0.1012 0.9113 0.000 0.968 0.020 0.012 0.000
#> GSM40682 2 0.0000 0.9265 0.000 1.000 0.000 0.000 0.000
#> GSM40688 2 0.0510 0.9218 0.000 0.984 0.000 0.016 0.000
#> GSM40702 2 0.3300 0.7639 0.000 0.792 0.204 0.004 0.000
#> GSM40706 2 0.0000 0.9265 0.000 1.000 0.000 0.000 0.000
#> GSM40711 3 0.4045 0.2165 0.000 0.000 0.644 0.356 0.000
#> GSM40661 3 0.0290 0.8745 0.000 0.000 0.992 0.008 0.000
#> GSM40662 5 0.7620 0.0934 0.000 0.064 0.344 0.192 0.400
#> GSM40666 4 0.6075 0.4749 0.000 0.000 0.356 0.512 0.132
#> GSM40669 5 0.2300 0.6030 0.072 0.000 0.000 0.024 0.904
#> GSM40670 5 0.2740 0.5782 0.028 0.000 0.000 0.096 0.876
#> GSM40671 1 0.3318 0.6828 0.808 0.000 0.000 0.180 0.012
#> GSM40672 1 0.0865 0.7047 0.972 0.000 0.000 0.004 0.024
#> GSM40673 1 0.0290 0.7119 0.992 0.000 0.000 0.000 0.008
#> GSM40674 5 0.3696 0.5559 0.028 0.000 0.040 0.092 0.840
#> GSM40676 4 0.4262 0.6194 0.124 0.000 0.100 0.776 0.000
#> GSM40680 1 0.7577 -0.0278 0.388 0.048 0.000 0.236 0.328
#> GSM40681 1 0.3043 0.6507 0.864 0.000 0.000 0.080 0.056
#> GSM40683 1 0.0290 0.7119 0.992 0.000 0.000 0.000 0.008
#> GSM40684 4 0.4266 0.6235 0.120 0.000 0.104 0.776 0.000
#> GSM40685 5 0.5648 -0.1142 0.448 0.000 0.000 0.076 0.476
#> GSM40689 1 0.3550 0.6531 0.760 0.000 0.000 0.236 0.004
#> GSM40690 1 0.0404 0.7110 0.988 0.000 0.000 0.000 0.012
#> GSM40692 1 0.6919 0.1750 0.488 0.020 0.000 0.212 0.280
#> GSM40693 1 0.5195 0.1847 0.564 0.000 0.000 0.048 0.388
#> GSM40694 1 0.5922 0.1614 0.532 0.000 0.000 0.116 0.352
#> GSM40695 1 0.0162 0.7121 0.996 0.000 0.000 0.000 0.004
#> GSM40696 1 0.5133 0.1906 0.568 0.000 0.000 0.044 0.388
#> GSM40697 5 0.5756 0.3363 0.000 0.324 0.012 0.076 0.588
#> GSM40704 1 0.0510 0.7100 0.984 0.000 0.000 0.000 0.016
#> GSM40705 3 0.4074 0.1888 0.000 0.000 0.636 0.364 0.000
#> GSM40707 1 0.4040 0.6261 0.712 0.000 0.000 0.276 0.012
#> GSM40708 1 0.4138 0.6246 0.708 0.000 0.000 0.276 0.016
#> GSM40709 4 0.6041 0.4714 0.000 0.000 0.356 0.516 0.128
#> GSM40712 5 0.3953 0.5662 0.148 0.000 0.000 0.060 0.792
#> GSM40713 1 0.3462 0.6803 0.792 0.000 0.000 0.196 0.012
#> GSM40665 1 0.3890 0.6411 0.736 0.000 0.000 0.252 0.012
#> GSM40677 2 0.0510 0.9218 0.000 0.984 0.000 0.016 0.000
#> GSM40698 1 0.3530 0.6773 0.784 0.000 0.000 0.204 0.012
#> GSM40701 3 0.0000 0.8799 0.000 0.000 1.000 0.000 0.000
#> GSM40710 2 0.0000 0.9265 0.000 1.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
#> GSM40663 3 0.0000 0.8669 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.8669 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.8669 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.8669 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.0582 0.8591 0.000 0.004 0.984 0.004 0.004 0.004
#> GSM40668 3 0.0146 0.8660 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM40678 2 0.0436 0.8789 0.000 0.988 0.000 0.004 0.004 0.004
#> GSM40679 2 0.0405 0.8788 0.000 0.988 0.000 0.004 0.008 0.000
#> GSM40686 2 0.2573 0.8273 0.000 0.872 0.000 0.012 0.104 0.012
#> GSM40687 2 0.0405 0.8788 0.000 0.988 0.000 0.004 0.000 0.008
#> GSM40691 2 0.4901 0.6812 0.000 0.700 0.192 0.000 0.040 0.068
#> GSM40699 2 0.3690 0.6163 0.000 0.684 0.308 0.000 0.008 0.000
#> GSM40664 2 0.2379 0.8504 0.000 0.904 0.024 0.052 0.012 0.008
#> GSM40682 2 0.0291 0.8789 0.000 0.992 0.000 0.004 0.004 0.000
#> GSM40688 2 0.2176 0.8487 0.000 0.896 0.000 0.000 0.080 0.024
#> GSM40702 2 0.3593 0.7145 0.000 0.756 0.224 0.004 0.012 0.004
#> GSM40706 2 0.0520 0.8784 0.000 0.984 0.000 0.000 0.008 0.008
#> GSM40711 3 0.3966 0.0435 0.000 0.000 0.552 0.444 0.004 0.000
#> GSM40661 3 0.0260 0.8628 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40662 5 0.7536 -0.0755 0.000 0.052 0.228 0.048 0.416 0.256
#> GSM40666 4 0.4745 0.7191 0.000 0.000 0.192 0.704 0.020 0.084
#> GSM40669 6 0.2933 0.6147 0.056 0.000 0.000 0.008 0.076 0.860
#> GSM40670 6 0.2018 0.6394 0.016 0.000 0.004 0.028 0.028 0.924
#> GSM40671 1 0.3767 0.6909 0.780 0.000 0.000 0.132 0.088 0.000
#> GSM40672 1 0.1151 0.6867 0.956 0.000 0.000 0.000 0.012 0.032
#> GSM40673 1 0.0405 0.7064 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM40674 6 0.3095 0.6236 0.016 0.000 0.028 0.064 0.024 0.868
#> GSM40676 4 0.1148 0.7458 0.016 0.000 0.020 0.960 0.004 0.000
#> GSM40680 5 0.2736 0.4050 0.072 0.004 0.000 0.016 0.880 0.028
#> GSM40681 1 0.3627 0.4677 0.752 0.000 0.000 0.004 0.224 0.020
#> GSM40683 1 0.0291 0.7072 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM40684 4 0.1003 0.7474 0.016 0.000 0.020 0.964 0.000 0.000
#> GSM40685 5 0.6441 0.2460 0.300 0.000 0.000 0.020 0.420 0.260
#> GSM40689 1 0.3763 0.6875 0.768 0.000 0.000 0.172 0.060 0.000
#> GSM40690 1 0.0909 0.6963 0.968 0.000 0.000 0.000 0.012 0.020
#> GSM40692 5 0.3036 0.4369 0.124 0.000 0.000 0.008 0.840 0.028
#> GSM40693 1 0.5843 -0.1622 0.516 0.000 0.000 0.004 0.220 0.260
#> GSM40694 5 0.5779 0.3057 0.400 0.000 0.000 0.004 0.444 0.152
#> GSM40695 1 0.0551 0.7066 0.984 0.000 0.000 0.004 0.004 0.008
#> GSM40696 1 0.5776 -0.1361 0.520 0.000 0.000 0.004 0.188 0.288
#> GSM40697 6 0.6239 0.1700 0.000 0.212 0.008 0.008 0.292 0.480
#> GSM40704 1 0.0717 0.6990 0.976 0.000 0.000 0.000 0.008 0.016
#> GSM40705 3 0.3857 -0.0332 0.000 0.000 0.532 0.468 0.000 0.000
#> GSM40707 1 0.4989 0.6140 0.640 0.000 0.000 0.248 0.108 0.004
#> GSM40708 1 0.5231 0.5913 0.612 0.000 0.000 0.252 0.132 0.004
#> GSM40709 4 0.5000 0.7246 0.000 0.000 0.180 0.688 0.024 0.108
#> GSM40712 6 0.4871 0.3156 0.088 0.000 0.000 0.000 0.296 0.616
#> GSM40713 1 0.4057 0.6846 0.764 0.000 0.000 0.124 0.108 0.004
#> GSM40665 1 0.4719 0.6459 0.680 0.000 0.000 0.216 0.100 0.004
#> GSM40677 2 0.2456 0.8490 0.000 0.888 0.000 0.008 0.076 0.028
#> GSM40698 1 0.4358 0.6630 0.712 0.000 0.000 0.196 0.092 0.000
#> GSM40701 3 0.0291 0.8636 0.000 0.004 0.992 0.000 0.004 0.000
#> GSM40710 2 0.0779 0.8761 0.000 0.976 0.000 0.008 0.008 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:skmeans 53 1.45e-06 2
#> MAD:skmeans 50 6.90e-06 3
#> MAD:skmeans 44 2.79e-04 4
#> MAD:skmeans 41 3.35e-05 5
#> MAD:skmeans 41 3.05e-05 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 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.952 0.979 0.4947 0.505 0.505
#> 3 3 0.962 0.924 0.952 0.2284 0.835 0.689
#> 4 4 0.794 0.879 0.932 0.1306 0.846 0.645
#> 5 5 0.859 0.824 0.892 0.1319 0.894 0.675
#> 6 6 0.886 0.802 0.881 0.0537 0.926 0.687
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
#> GSM40663 2 0.0000 0.976 0.000 1.000
#> GSM40667 2 0.0000 0.976 0.000 1.000
#> GSM40675 2 0.0000 0.976 0.000 1.000
#> GSM40703 2 0.0000 0.976 0.000 1.000
#> GSM40660 2 0.0000 0.976 0.000 1.000
#> GSM40668 2 0.0000 0.976 0.000 1.000
#> GSM40678 2 0.0672 0.977 0.008 0.992
#> GSM40679 2 0.0672 0.977 0.008 0.992
#> GSM40686 2 0.9552 0.379 0.376 0.624
#> GSM40687 2 0.0672 0.977 0.008 0.992
#> GSM40691 2 0.0672 0.977 0.008 0.992
#> GSM40699 2 0.0000 0.976 0.000 1.000
#> GSM40664 2 0.0672 0.977 0.008 0.992
#> GSM40682 2 0.0672 0.977 0.008 0.992
#> GSM40688 2 0.0672 0.977 0.008 0.992
#> GSM40702 2 0.0672 0.977 0.008 0.992
#> GSM40706 2 0.0672 0.977 0.008 0.992
#> GSM40711 2 0.1843 0.954 0.028 0.972
#> GSM40661 2 0.0000 0.976 0.000 1.000
#> GSM40662 1 0.8144 0.662 0.748 0.252
#> GSM40666 1 0.0938 0.973 0.988 0.012
#> GSM40669 1 0.0376 0.977 0.996 0.004
#> GSM40670 1 0.0376 0.977 0.996 0.004
#> GSM40671 1 0.0000 0.978 1.000 0.000
#> GSM40672 1 0.0000 0.978 1.000 0.000
#> GSM40673 1 0.0000 0.978 1.000 0.000
#> GSM40674 1 0.0376 0.977 0.996 0.004
#> GSM40676 1 0.0938 0.973 0.988 0.012
#> GSM40680 1 0.0376 0.977 0.996 0.004
#> GSM40681 1 0.0000 0.978 1.000 0.000
#> GSM40683 1 0.0000 0.978 1.000 0.000
#> GSM40684 1 0.0938 0.973 0.988 0.012
#> GSM40685 1 0.0000 0.978 1.000 0.000
#> GSM40689 1 0.0000 0.978 1.000 0.000
#> GSM40690 1 0.0000 0.978 1.000 0.000
#> GSM40692 1 0.0376 0.977 0.996 0.004
#> GSM40693 1 0.0000 0.978 1.000 0.000
#> GSM40694 1 0.0000 0.978 1.000 0.000
#> GSM40695 1 0.0000 0.978 1.000 0.000
#> GSM40696 1 0.0000 0.978 1.000 0.000
#> GSM40697 1 0.1843 0.957 0.972 0.028
#> GSM40704 1 0.0000 0.978 1.000 0.000
#> GSM40705 1 0.8661 0.606 0.712 0.288
#> GSM40707 1 0.0000 0.978 1.000 0.000
#> GSM40708 1 0.0000 0.978 1.000 0.000
#> GSM40709 1 0.0938 0.973 0.988 0.012
#> GSM40712 1 0.0000 0.978 1.000 0.000
#> GSM40713 1 0.0000 0.978 1.000 0.000
#> GSM40665 1 0.0000 0.978 1.000 0.000
#> GSM40677 2 0.0672 0.977 0.008 0.992
#> GSM40698 1 0.0000 0.978 1.000 0.000
#> GSM40701 2 0.0000 0.976 0.000 1.000
#> GSM40710 2 0.0672 0.977 0.008 0.992
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.1964 0.935 0.000 0.056 0.944
#> GSM40667 3 0.1964 0.935 0.000 0.056 0.944
#> GSM40675 3 0.1964 0.935 0.000 0.056 0.944
#> GSM40703 3 0.1964 0.935 0.000 0.056 0.944
#> GSM40660 2 0.1031 0.919 0.000 0.976 0.024
#> GSM40668 3 0.1964 0.935 0.000 0.056 0.944
#> GSM40678 2 0.0000 0.938 0.000 1.000 0.000
#> GSM40679 2 0.1529 0.934 0.040 0.960 0.000
#> GSM40686 2 0.1964 0.928 0.056 0.944 0.000
#> GSM40687 2 0.0000 0.938 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.938 0.000 1.000 0.000
#> GSM40699 2 0.0000 0.938 0.000 1.000 0.000
#> GSM40664 2 0.1860 0.930 0.052 0.948 0.000
#> GSM40682 2 0.1411 0.936 0.036 0.964 0.000
#> GSM40688 2 0.1860 0.930 0.052 0.948 0.000
#> GSM40702 2 0.0000 0.938 0.000 1.000 0.000
#> GSM40706 2 0.0000 0.938 0.000 1.000 0.000
#> GSM40711 3 0.1860 0.932 0.000 0.052 0.948
#> GSM40661 2 0.3619 0.798 0.000 0.864 0.136
#> GSM40662 2 0.2590 0.911 0.072 0.924 0.004
#> GSM40666 1 0.1751 0.954 0.960 0.012 0.028
#> GSM40669 1 0.1267 0.954 0.972 0.024 0.004
#> GSM40670 1 0.1163 0.956 0.972 0.000 0.028
#> GSM40671 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40672 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40673 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40674 1 0.3644 0.854 0.872 0.124 0.004
#> GSM40676 1 0.1751 0.954 0.960 0.012 0.028
#> GSM40680 1 0.1267 0.954 0.972 0.024 0.004
#> GSM40681 1 0.0000 0.964 1.000 0.000 0.000
#> GSM40683 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40684 1 0.1751 0.954 0.960 0.012 0.028
#> GSM40685 1 0.0000 0.964 1.000 0.000 0.000
#> GSM40689 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40690 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40692 1 0.1267 0.954 0.972 0.024 0.004
#> GSM40693 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40694 1 0.0000 0.964 1.000 0.000 0.000
#> GSM40695 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40696 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40697 2 0.4978 0.705 0.216 0.780 0.004
#> GSM40704 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40705 3 0.1860 0.932 0.000 0.052 0.948
#> GSM40707 1 0.1860 0.959 0.948 0.000 0.052
#> GSM40708 1 0.0000 0.964 1.000 0.000 0.000
#> GSM40709 1 0.1751 0.954 0.960 0.012 0.028
#> GSM40712 1 0.0237 0.963 0.996 0.000 0.004
#> GSM40713 1 0.0000 0.964 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.964 1.000 0.000 0.000
#> GSM40677 2 0.1860 0.930 0.052 0.948 0.000
#> GSM40698 1 0.0747 0.959 0.984 0.016 0.000
#> GSM40701 3 0.6280 0.230 0.000 0.460 0.540
#> GSM40710 2 0.0000 0.938 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.1302 1.0000 0.000 0.000 0.044 0.956
#> GSM40667 4 0.1302 1.0000 0.000 0.000 0.044 0.956
#> GSM40675 4 0.1302 1.0000 0.000 0.000 0.044 0.956
#> GSM40703 4 0.1302 1.0000 0.000 0.000 0.044 0.956
#> GSM40660 3 0.3311 0.7665 0.000 0.172 0.828 0.000
#> GSM40668 3 0.2973 0.7719 0.000 0.000 0.856 0.144
#> GSM40678 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0336 0.9535 0.008 0.992 0.000 0.000
#> GSM40687 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40691 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40699 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40664 2 0.0188 0.9574 0.004 0.996 0.000 0.000
#> GSM40682 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40702 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40706 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40711 3 0.0188 0.8621 0.000 0.000 0.996 0.004
#> GSM40661 3 0.3764 0.7201 0.000 0.216 0.784 0.000
#> GSM40662 2 0.6708 0.4048 0.272 0.596 0.132 0.000
#> GSM40666 3 0.1211 0.8666 0.040 0.000 0.960 0.000
#> GSM40669 1 0.2814 0.8478 0.868 0.000 0.132 0.000
#> GSM40670 1 0.2814 0.8478 0.868 0.000 0.132 0.000
#> GSM40671 1 0.0336 0.9172 0.992 0.000 0.000 0.008
#> GSM40672 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40673 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40674 1 0.4224 0.8224 0.812 0.044 0.144 0.000
#> GSM40676 3 0.1211 0.8666 0.040 0.000 0.960 0.000
#> GSM40680 1 0.2814 0.8347 0.868 0.132 0.000 0.000
#> GSM40681 1 0.0469 0.9176 0.988 0.000 0.000 0.012
#> GSM40683 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40684 3 0.1211 0.8666 0.040 0.000 0.960 0.000
#> GSM40685 1 0.0336 0.9162 0.992 0.008 0.000 0.000
#> GSM40689 1 0.0336 0.9172 0.992 0.000 0.000 0.008
#> GSM40690 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40692 1 0.2814 0.8347 0.868 0.132 0.000 0.000
#> GSM40693 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40694 1 0.0000 0.9166 1.000 0.000 0.000 0.000
#> GSM40695 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40696 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40697 1 0.5000 0.0657 0.500 0.500 0.000 0.000
#> GSM40704 1 0.1489 0.9130 0.952 0.000 0.004 0.044
#> GSM40705 3 0.0188 0.8621 0.000 0.000 0.996 0.004
#> GSM40707 1 0.0336 0.9172 0.992 0.000 0.000 0.008
#> GSM40708 1 0.0336 0.9159 0.992 0.000 0.008 0.000
#> GSM40709 3 0.2530 0.7909 0.112 0.000 0.888 0.000
#> GSM40712 1 0.2814 0.8478 0.868 0.000 0.132 0.000
#> GSM40713 1 0.0469 0.9148 0.988 0.000 0.012 0.000
#> GSM40665 1 0.0000 0.9166 1.000 0.000 0.000 0.000
#> GSM40677 2 0.0000 0.9607 0.000 1.000 0.000 0.000
#> GSM40698 1 0.2530 0.8610 0.896 0.100 0.004 0.000
#> GSM40701 3 0.3667 0.7998 0.000 0.056 0.856 0.088
#> GSM40710 2 0.0000 0.9607 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40667 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40675 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40703 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0963 0.945 0.000 0.036 0.964 0.000 0.000
#> GSM40668 3 0.1671 0.920 0.000 0.000 0.924 0.076 0.000
#> GSM40678 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40686 2 0.0703 0.970 0.024 0.976 0.000 0.000 0.000
#> GSM40687 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40691 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40699 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40664 2 0.0510 0.980 0.016 0.984 0.000 0.000 0.000
#> GSM40682 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40688 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40702 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40706 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40711 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000
#> GSM40661 3 0.1197 0.935 0.000 0.048 0.952 0.000 0.000
#> GSM40662 5 0.5372 0.343 0.024 0.376 0.024 0.000 0.576
#> GSM40666 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000
#> GSM40669 5 0.4808 0.663 0.400 0.000 0.024 0.000 0.576
#> GSM40670 5 0.4808 0.663 0.400 0.000 0.024 0.000 0.576
#> GSM40671 1 0.0703 0.776 0.976 0.000 0.000 0.000 0.024
#> GSM40672 1 0.4235 0.583 0.576 0.000 0.000 0.000 0.424
#> GSM40673 1 0.4235 0.583 0.576 0.000 0.000 0.000 0.424
#> GSM40674 5 0.6561 0.674 0.272 0.052 0.100 0.000 0.576
#> GSM40676 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000
#> GSM40680 1 0.0162 0.774 0.996 0.000 0.000 0.000 0.004
#> GSM40681 1 0.2179 0.736 0.888 0.000 0.000 0.000 0.112
#> GSM40683 1 0.4235 0.583 0.576 0.000 0.000 0.000 0.424
#> GSM40684 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000
#> GSM40685 1 0.0162 0.774 0.996 0.000 0.000 0.000 0.004
#> GSM40689 1 0.0865 0.776 0.972 0.000 0.004 0.000 0.024
#> GSM40690 1 0.4283 0.547 0.544 0.000 0.000 0.000 0.456
#> GSM40692 1 0.0162 0.775 0.996 0.004 0.000 0.000 0.000
#> GSM40693 5 0.0162 0.468 0.004 0.000 0.000 0.000 0.996
#> GSM40694 1 0.0000 0.776 1.000 0.000 0.000 0.000 0.000
#> GSM40695 1 0.4171 0.600 0.604 0.000 0.000 0.000 0.396
#> GSM40696 5 0.0162 0.468 0.004 0.000 0.000 0.000 0.996
#> GSM40697 5 0.5906 0.667 0.284 0.140 0.000 0.000 0.576
#> GSM40704 1 0.4235 0.583 0.576 0.000 0.000 0.000 0.424
#> GSM40705 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000
#> GSM40707 1 0.0865 0.776 0.972 0.000 0.004 0.000 0.024
#> GSM40708 1 0.0162 0.775 0.996 0.000 0.004 0.000 0.000
#> GSM40709 3 0.1768 0.886 0.072 0.000 0.924 0.000 0.004
#> GSM40712 5 0.4375 0.643 0.420 0.000 0.004 0.000 0.576
#> GSM40713 1 0.0162 0.774 0.996 0.000 0.000 0.000 0.004
#> GSM40665 1 0.0162 0.775 0.996 0.000 0.004 0.000 0.000
#> GSM40677 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000
#> GSM40698 1 0.0162 0.775 0.996 0.004 0.000 0.000 0.000
#> GSM40701 3 0.1965 0.928 0.000 0.024 0.924 0.052 0.000
#> GSM40710 2 0.0000 0.996 0.000 1.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
#> GSM40663 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.3727 0.9832 0.000 0.000 0.000 0.612 0.388 0.000
#> GSM40668 4 0.3965 0.9810 0.000 0.000 0.008 0.604 0.388 0.000
#> GSM40678 2 0.0146 0.6983 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM40679 2 0.3737 0.8226 0.000 0.608 0.000 0.392 0.000 0.000
#> GSM40686 2 0.3737 0.8226 0.000 0.608 0.000 0.392 0.000 0.000
#> GSM40687 2 0.0146 0.6983 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM40691 2 0.3198 0.3583 0.000 0.740 0.000 0.000 0.260 0.000
#> GSM40699 2 0.0146 0.6983 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM40664 2 0.3737 0.8226 0.000 0.608 0.000 0.392 0.000 0.000
#> GSM40682 2 0.3737 0.8226 0.000 0.608 0.000 0.392 0.000 0.000
#> GSM40688 2 0.3717 0.8219 0.000 0.616 0.000 0.384 0.000 0.000
#> GSM40702 2 0.3647 0.8174 0.000 0.640 0.000 0.360 0.000 0.000
#> GSM40706 2 0.3737 0.8226 0.000 0.608 0.000 0.392 0.000 0.000
#> GSM40711 4 0.3737 0.9849 0.000 0.000 0.000 0.608 0.392 0.000
#> GSM40661 4 0.3428 0.8974 0.000 0.000 0.000 0.696 0.304 0.000
#> GSM40662 5 0.3737 0.8874 0.392 0.000 0.000 0.000 0.608 0.000
#> GSM40666 4 0.3737 0.9849 0.000 0.000 0.000 0.608 0.392 0.000
#> GSM40669 5 0.3737 0.8874 0.392 0.000 0.000 0.000 0.608 0.000
#> GSM40670 5 0.3737 0.8874 0.392 0.000 0.000 0.000 0.608 0.000
#> GSM40671 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40672 1 0.3737 0.7108 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM40673 1 0.3737 0.7108 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM40674 5 0.3737 0.8874 0.392 0.000 0.000 0.000 0.608 0.000
#> GSM40676 4 0.3737 0.9849 0.000 0.000 0.000 0.608 0.392 0.000
#> GSM40680 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40681 6 0.2135 0.7447 0.128 0.000 0.000 0.000 0.000 0.872
#> GSM40683 1 0.3737 0.7108 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM40684 4 0.3737 0.9849 0.000 0.000 0.000 0.608 0.392 0.000
#> GSM40685 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40689 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40690 1 0.3727 0.7103 0.612 0.000 0.000 0.000 0.000 0.388
#> GSM40692 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40693 1 0.0865 0.2170 0.964 0.000 0.000 0.000 0.036 0.000
#> GSM40694 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40695 6 0.3782 -0.2329 0.412 0.000 0.000 0.000 0.000 0.588
#> GSM40696 1 0.0865 0.2170 0.964 0.000 0.000 0.000 0.036 0.000
#> GSM40697 5 0.3872 0.8844 0.392 0.000 0.000 0.004 0.604 0.000
#> GSM40704 1 0.3737 0.7108 0.608 0.000 0.000 0.000 0.000 0.392
#> GSM40705 4 0.3737 0.9849 0.000 0.000 0.000 0.608 0.392 0.000
#> GSM40707 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40708 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40709 5 0.3825 -0.0963 0.000 0.000 0.000 0.160 0.768 0.072
#> GSM40712 5 0.3872 0.8842 0.392 0.000 0.000 0.000 0.604 0.004
#> GSM40713 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40665 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40677 2 0.3737 0.8226 0.000 0.608 0.000 0.392 0.000 0.000
#> GSM40698 6 0.0000 0.9331 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40701 4 0.3862 0.9810 0.000 0.004 0.000 0.608 0.388 0.000
#> GSM40710 2 0.0000 0.7000 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:pam 52 2.51e-08 2
#> MAD:pam 52 2.42e-09 3
#> MAD:pam 51 1.53e-12 4
#> MAD:pam 50 1.82e-10 5
#> MAD:pam 48 1.25e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 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 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.217 0.542 0.783 0.41721 0.570 0.570
#> 3 3 0.458 0.547 0.764 0.34294 0.660 0.482
#> 4 4 0.718 0.792 0.838 0.29549 0.711 0.393
#> 5 5 0.782 0.856 0.900 0.09057 0.913 0.680
#> 6 6 0.740 0.484 0.733 0.00625 0.801 0.333
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM40663 2 0.9988 0.506 0.480 0.520
#> GSM40667 2 0.9988 0.506 0.480 0.520
#> GSM40675 2 0.9988 0.506 0.480 0.520
#> GSM40703 2 0.9988 0.506 0.480 0.520
#> GSM40660 1 0.9998 -0.512 0.508 0.492
#> GSM40668 2 0.9996 0.497 0.488 0.512
#> GSM40678 2 0.5294 0.747 0.120 0.880
#> GSM40679 2 0.5294 0.747 0.120 0.880
#> GSM40686 2 0.6623 0.701 0.172 0.828
#> GSM40687 2 0.5294 0.747 0.120 0.880
#> GSM40691 1 0.1633 0.712 0.976 0.024
#> GSM40699 2 0.8499 0.687 0.276 0.724
#> GSM40664 2 0.6343 0.749 0.160 0.840
#> GSM40682 2 0.6343 0.749 0.160 0.840
#> GSM40688 1 0.9775 0.331 0.588 0.412
#> GSM40702 2 0.6343 0.749 0.160 0.840
#> GSM40706 2 0.5294 0.747 0.120 0.880
#> GSM40711 1 0.9998 -0.512 0.508 0.492
#> GSM40661 1 0.9998 -0.512 0.508 0.492
#> GSM40662 1 0.1633 0.712 0.976 0.024
#> GSM40666 1 0.1843 0.709 0.972 0.028
#> GSM40669 1 0.1633 0.712 0.976 0.024
#> GSM40670 1 0.1633 0.712 0.976 0.024
#> GSM40671 1 0.5408 0.731 0.876 0.124
#> GSM40672 1 0.7299 0.686 0.796 0.204
#> GSM40673 1 0.7376 0.684 0.792 0.208
#> GSM40674 1 0.1633 0.712 0.976 0.024
#> GSM40676 2 0.9754 0.485 0.408 0.592
#> GSM40680 1 0.5737 0.730 0.864 0.136
#> GSM40681 1 0.5519 0.731 0.872 0.128
#> GSM40683 1 0.7376 0.684 0.792 0.208
#> GSM40684 1 0.9998 -0.512 0.508 0.492
#> GSM40685 1 0.5408 0.731 0.876 0.124
#> GSM40689 1 0.5842 0.729 0.860 0.140
#> GSM40690 1 0.5737 0.728 0.864 0.136
#> GSM40692 1 0.5842 0.729 0.860 0.140
#> GSM40693 1 0.0672 0.721 0.992 0.008
#> GSM40694 1 0.2603 0.729 0.956 0.044
#> GSM40695 1 0.6623 0.710 0.828 0.172
#> GSM40696 1 0.0938 0.723 0.988 0.012
#> GSM40697 1 0.1633 0.712 0.976 0.024
#> GSM40704 1 0.7299 0.686 0.796 0.204
#> GSM40705 1 0.9998 -0.512 0.508 0.492
#> GSM40707 1 0.5519 0.731 0.872 0.128
#> GSM40708 1 0.5737 0.728 0.864 0.136
#> GSM40709 1 0.1843 0.709 0.972 0.028
#> GSM40712 1 0.1633 0.712 0.976 0.024
#> GSM40713 1 0.4161 0.732 0.916 0.084
#> GSM40665 1 0.5408 0.731 0.876 0.124
#> GSM40677 1 0.9775 0.331 0.588 0.412
#> GSM40698 1 0.5519 0.731 0.872 0.128
#> GSM40701 1 0.9998 -0.512 0.508 0.492
#> GSM40710 2 0.5294 0.747 0.120 0.880
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0892 0.692 0.000 0.020 0.980
#> GSM40667 3 0.0892 0.692 0.000 0.020 0.980
#> GSM40675 3 0.0892 0.692 0.000 0.020 0.980
#> GSM40703 3 0.0892 0.692 0.000 0.020 0.980
#> GSM40660 2 0.9842 0.159 0.260 0.412 0.328
#> GSM40668 3 0.4505 0.611 0.048 0.092 0.860
#> GSM40678 2 0.1878 0.700 0.044 0.952 0.004
#> GSM40679 2 0.1878 0.700 0.044 0.952 0.004
#> GSM40686 2 0.2165 0.698 0.064 0.936 0.000
#> GSM40687 2 0.1878 0.700 0.044 0.952 0.004
#> GSM40691 2 0.8111 0.458 0.264 0.624 0.112
#> GSM40699 2 0.1751 0.676 0.012 0.960 0.028
#> GSM40664 2 0.5325 0.615 0.248 0.748 0.004
#> GSM40682 2 0.3129 0.702 0.088 0.904 0.008
#> GSM40688 2 0.2796 0.697 0.092 0.908 0.000
#> GSM40702 2 0.4665 0.668 0.100 0.852 0.048
#> GSM40706 2 0.1878 0.700 0.044 0.952 0.004
#> GSM40711 3 0.9858 -0.219 0.252 0.372 0.376
#> GSM40661 2 0.9853 0.130 0.256 0.400 0.344
#> GSM40662 2 0.8285 0.414 0.288 0.600 0.112
#> GSM40666 1 0.9014 0.222 0.484 0.380 0.136
#> GSM40669 1 0.8710 0.266 0.508 0.380 0.112
#> GSM40670 1 0.8710 0.266 0.508 0.380 0.112
#> GSM40671 1 0.0237 0.755 0.996 0.000 0.004
#> GSM40672 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40674 1 0.8721 0.255 0.504 0.384 0.112
#> GSM40676 1 0.8310 0.294 0.544 0.368 0.088
#> GSM40680 1 0.6467 0.309 0.604 0.388 0.008
#> GSM40681 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40684 1 0.8784 0.237 0.512 0.368 0.120
#> GSM40685 1 0.5216 0.530 0.740 0.260 0.000
#> GSM40689 1 0.0475 0.755 0.992 0.004 0.004
#> GSM40690 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40692 1 0.6180 0.421 0.660 0.332 0.008
#> GSM40693 1 0.0983 0.748 0.980 0.016 0.004
#> GSM40694 1 0.0475 0.753 0.992 0.004 0.004
#> GSM40695 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40696 1 0.0983 0.750 0.980 0.016 0.004
#> GSM40697 2 0.8409 0.368 0.308 0.580 0.112
#> GSM40704 1 0.0000 0.754 1.000 0.000 0.000
#> GSM40705 3 0.9858 -0.219 0.252 0.372 0.376
#> GSM40707 1 0.0424 0.754 0.992 0.000 0.008
#> GSM40708 1 0.0424 0.754 0.992 0.000 0.008
#> GSM40709 1 0.9014 0.222 0.484 0.380 0.136
#> GSM40712 1 0.8699 0.269 0.512 0.376 0.112
#> GSM40713 1 0.0661 0.754 0.988 0.004 0.008
#> GSM40665 1 0.0424 0.754 0.992 0.000 0.008
#> GSM40677 2 0.2796 0.697 0.092 0.908 0.000
#> GSM40698 1 0.0661 0.753 0.988 0.004 0.008
#> GSM40701 2 0.9815 0.151 0.256 0.420 0.324
#> GSM40710 2 0.1878 0.700 0.044 0.952 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.4008 0.746 0.000 0.000 0.756 0.244
#> GSM40667 3 0.4008 0.746 0.000 0.000 0.756 0.244
#> GSM40675 3 0.4008 0.746 0.000 0.000 0.756 0.244
#> GSM40703 3 0.4008 0.746 0.000 0.000 0.756 0.244
#> GSM40660 3 0.3081 0.825 0.064 0.000 0.888 0.048
#> GSM40668 3 0.1940 0.802 0.000 0.000 0.924 0.076
#> GSM40678 2 0.0000 0.924 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.924 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0376 0.923 0.004 0.992 0.004 0.000
#> GSM40687 2 0.0000 0.924 0.000 1.000 0.000 0.000
#> GSM40691 1 0.5569 0.653 0.736 0.176 0.080 0.008
#> GSM40699 2 0.3168 0.853 0.040 0.888 0.068 0.004
#> GSM40664 2 0.3521 0.840 0.016 0.876 0.032 0.076
#> GSM40682 2 0.0188 0.924 0.000 0.996 0.004 0.000
#> GSM40688 2 0.1398 0.905 0.040 0.956 0.004 0.000
#> GSM40702 2 0.0927 0.917 0.000 0.976 0.008 0.016
#> GSM40706 2 0.0000 0.924 0.000 1.000 0.000 0.000
#> GSM40711 3 0.3533 0.829 0.056 0.000 0.864 0.080
#> GSM40661 3 0.3354 0.826 0.044 0.000 0.872 0.084
#> GSM40662 1 0.4923 0.682 0.732 0.004 0.240 0.024
#> GSM40666 3 0.3400 0.819 0.064 0.000 0.872 0.064
#> GSM40669 1 0.4436 0.705 0.764 0.000 0.216 0.020
#> GSM40670 1 0.4675 0.682 0.736 0.000 0.244 0.020
#> GSM40671 4 0.4164 0.877 0.264 0.000 0.000 0.736
#> GSM40672 1 0.0188 0.816 0.996 0.000 0.000 0.004
#> GSM40673 1 0.0707 0.813 0.980 0.000 0.000 0.020
#> GSM40674 1 0.4675 0.682 0.736 0.000 0.244 0.020
#> GSM40676 4 0.4671 0.613 0.028 0.000 0.220 0.752
#> GSM40680 2 0.6514 0.285 0.384 0.556 0.024 0.036
#> GSM40681 1 0.3764 0.573 0.784 0.000 0.000 0.216
#> GSM40683 1 0.2530 0.737 0.888 0.000 0.000 0.112
#> GSM40684 4 0.4507 0.593 0.020 0.000 0.224 0.756
#> GSM40685 1 0.0000 0.818 1.000 0.000 0.000 0.000
#> GSM40689 4 0.4304 0.860 0.284 0.000 0.000 0.716
#> GSM40690 1 0.1302 0.801 0.956 0.000 0.000 0.044
#> GSM40692 1 0.2317 0.790 0.928 0.036 0.004 0.032
#> GSM40693 1 0.0000 0.818 1.000 0.000 0.000 0.000
#> GSM40694 1 0.0000 0.818 1.000 0.000 0.000 0.000
#> GSM40695 1 0.4008 0.515 0.756 0.000 0.000 0.244
#> GSM40696 1 0.0000 0.818 1.000 0.000 0.000 0.000
#> GSM40697 1 0.5168 0.687 0.736 0.024 0.224 0.016
#> GSM40704 1 0.0336 0.816 0.992 0.000 0.000 0.008
#> GSM40705 3 0.3587 0.827 0.052 0.000 0.860 0.088
#> GSM40707 4 0.4164 0.877 0.264 0.000 0.000 0.736
#> GSM40708 4 0.4164 0.877 0.264 0.000 0.000 0.736
#> GSM40709 3 0.3400 0.819 0.064 0.000 0.872 0.064
#> GSM40712 1 0.2376 0.793 0.916 0.000 0.068 0.016
#> GSM40713 1 0.1474 0.797 0.948 0.000 0.000 0.052
#> GSM40665 4 0.4164 0.877 0.264 0.000 0.000 0.736
#> GSM40677 2 0.1398 0.905 0.040 0.956 0.004 0.000
#> GSM40698 4 0.4277 0.869 0.280 0.000 0.000 0.720
#> GSM40701 3 0.2996 0.827 0.064 0.000 0.892 0.044
#> GSM40710 2 0.0000 0.924 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0324 0.841 0.004 0.000 0.992 0.004 0.000
#> GSM40667 3 0.0324 0.841 0.004 0.000 0.992 0.004 0.000
#> GSM40675 3 0.0324 0.841 0.004 0.000 0.992 0.004 0.000
#> GSM40703 3 0.0324 0.841 0.004 0.000 0.992 0.004 0.000
#> GSM40660 3 0.3681 0.889 0.000 0.008 0.820 0.036 0.136
#> GSM40668 3 0.2329 0.887 0.000 0.000 0.876 0.000 0.124
#> GSM40678 2 0.0162 0.892 0.000 0.996 0.004 0.000 0.000
#> GSM40679 2 0.0566 0.899 0.000 0.984 0.004 0.000 0.012
#> GSM40686 2 0.0963 0.902 0.000 0.964 0.000 0.000 0.036
#> GSM40687 2 0.0000 0.892 0.000 1.000 0.000 0.000 0.000
#> GSM40691 5 0.1195 0.869 0.000 0.028 0.000 0.012 0.960
#> GSM40699 2 0.2284 0.873 0.000 0.896 0.004 0.004 0.096
#> GSM40664 2 0.3051 0.850 0.000 0.864 0.000 0.060 0.076
#> GSM40682 2 0.1124 0.902 0.000 0.960 0.004 0.000 0.036
#> GSM40688 2 0.2561 0.833 0.000 0.856 0.000 0.000 0.144
#> GSM40702 2 0.1430 0.898 0.000 0.944 0.004 0.000 0.052
#> GSM40706 2 0.0671 0.900 0.000 0.980 0.004 0.000 0.016
#> GSM40711 3 0.3578 0.888 0.000 0.000 0.820 0.048 0.132
#> GSM40661 3 0.3834 0.887 0.000 0.008 0.816 0.052 0.124
#> GSM40662 5 0.1095 0.876 0.000 0.012 0.008 0.012 0.968
#> GSM40666 3 0.4536 0.817 0.000 0.000 0.712 0.048 0.240
#> GSM40669 5 0.0703 0.882 0.000 0.000 0.000 0.024 0.976
#> GSM40670 5 0.0609 0.881 0.000 0.000 0.000 0.020 0.980
#> GSM40671 4 0.3816 0.564 0.304 0.000 0.000 0.696 0.000
#> GSM40672 1 0.0898 0.951 0.972 0.000 0.000 0.008 0.020
#> GSM40673 1 0.0162 0.953 0.996 0.000 0.000 0.000 0.004
#> GSM40674 5 0.0609 0.881 0.000 0.000 0.000 0.020 0.980
#> GSM40676 4 0.2857 0.840 0.012 0.000 0.008 0.868 0.112
#> GSM40680 2 0.5771 0.686 0.068 0.700 0.000 0.136 0.096
#> GSM40681 1 0.1597 0.934 0.940 0.000 0.000 0.048 0.012
#> GSM40683 1 0.0162 0.953 0.996 0.000 0.000 0.000 0.004
#> GSM40684 4 0.2612 0.829 0.000 0.000 0.008 0.868 0.124
#> GSM40685 5 0.3919 0.783 0.188 0.000 0.000 0.036 0.776
#> GSM40689 4 0.1942 0.875 0.068 0.000 0.000 0.920 0.012
#> GSM40690 1 0.1579 0.941 0.944 0.000 0.000 0.032 0.024
#> GSM40692 2 0.7445 0.362 0.276 0.496 0.000 0.112 0.116
#> GSM40693 5 0.3795 0.777 0.192 0.000 0.000 0.028 0.780
#> GSM40694 5 0.4010 0.763 0.208 0.000 0.000 0.032 0.760
#> GSM40695 1 0.0566 0.955 0.984 0.000 0.000 0.012 0.004
#> GSM40696 5 0.3795 0.777 0.192 0.000 0.000 0.028 0.780
#> GSM40697 5 0.0807 0.880 0.000 0.012 0.000 0.012 0.976
#> GSM40704 1 0.0162 0.953 0.996 0.000 0.000 0.000 0.004
#> GSM40705 3 0.3578 0.888 0.000 0.000 0.820 0.048 0.132
#> GSM40707 4 0.1043 0.884 0.040 0.000 0.000 0.960 0.000
#> GSM40708 4 0.1043 0.884 0.040 0.000 0.000 0.960 0.000
#> GSM40709 3 0.4495 0.815 0.000 0.000 0.712 0.044 0.244
#> GSM40712 5 0.0865 0.881 0.004 0.000 0.000 0.024 0.972
#> GSM40713 1 0.3216 0.832 0.848 0.000 0.000 0.108 0.044
#> GSM40665 4 0.1043 0.884 0.040 0.000 0.000 0.960 0.000
#> GSM40677 2 0.1197 0.900 0.000 0.952 0.000 0.000 0.048
#> GSM40698 4 0.2853 0.865 0.052 0.000 0.000 0.876 0.072
#> GSM40701 3 0.3584 0.889 0.000 0.012 0.828 0.028 0.132
#> GSM40710 2 0.0000 0.892 0.000 1.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
#> GSM40663 4 0.4093 0.319 0.000 0.008 0.476 0.516 0.000 0.000
#> GSM40667 4 0.4093 0.319 0.000 0.008 0.476 0.516 0.000 0.000
#> GSM40675 4 0.4093 0.319 0.000 0.008 0.476 0.516 0.000 0.000
#> GSM40703 4 0.4093 0.319 0.000 0.008 0.476 0.516 0.000 0.000
#> GSM40660 2 0.2006 0.152 0.000 0.904 0.000 0.080 0.016 0.000
#> GSM40668 3 0.5353 -0.566 0.000 0.440 0.464 0.092 0.004 0.000
#> GSM40678 2 0.3997 0.380 0.004 0.508 0.488 0.000 0.000 0.000
#> GSM40679 2 0.3995 0.383 0.000 0.516 0.480 0.000 0.004 0.000
#> GSM40686 2 0.4325 0.373 0.000 0.524 0.456 0.000 0.020 0.000
#> GSM40687 2 0.3997 0.380 0.004 0.508 0.488 0.000 0.000 0.000
#> GSM40691 2 0.5588 0.342 0.000 0.528 0.300 0.000 0.172 0.000
#> GSM40699 2 0.4002 0.383 0.000 0.588 0.404 0.000 0.008 0.000
#> GSM40664 2 0.4921 0.370 0.000 0.516 0.436 0.000 0.028 0.020
#> GSM40682 2 0.4258 0.386 0.000 0.516 0.468 0.000 0.016 0.000
#> GSM40688 3 0.4566 -0.561 0.008 0.484 0.488 0.000 0.020 0.000
#> GSM40702 2 0.4169 0.389 0.000 0.532 0.456 0.000 0.012 0.000
#> GSM40706 2 0.3995 0.383 0.000 0.516 0.480 0.000 0.004 0.000
#> GSM40711 4 0.3995 0.521 0.000 0.480 0.000 0.516 0.004 0.000
#> GSM40661 2 0.2218 0.131 0.000 0.884 0.000 0.104 0.012 0.000
#> GSM40662 2 0.3766 0.229 0.000 0.720 0.024 0.000 0.256 0.000
#> GSM40666 4 0.4263 0.518 0.000 0.480 0.000 0.504 0.016 0.000
#> GSM40669 5 0.1500 0.731 0.012 0.052 0.000 0.000 0.936 0.000
#> GSM40670 5 0.2170 0.701 0.012 0.100 0.000 0.000 0.888 0.000
#> GSM40671 6 0.0146 0.888 0.000 0.000 0.000 0.000 0.004 0.996
#> GSM40672 5 0.3819 0.629 0.340 0.000 0.000 0.000 0.652 0.008
#> GSM40673 1 0.0858 0.992 0.968 0.000 0.000 0.000 0.028 0.004
#> GSM40674 5 0.2266 0.694 0.012 0.108 0.000 0.000 0.880 0.000
#> GSM40676 4 0.6335 0.359 0.008 0.372 0.000 0.384 0.004 0.232
#> GSM40680 5 0.6721 0.157 0.028 0.328 0.116 0.000 0.484 0.044
#> GSM40681 5 0.4067 0.696 0.260 0.000 0.000 0.000 0.700 0.040
#> GSM40683 1 0.0858 0.992 0.968 0.000 0.000 0.000 0.028 0.004
#> GSM40684 4 0.6313 0.369 0.008 0.380 0.000 0.384 0.004 0.224
#> GSM40685 5 0.2851 0.771 0.132 0.004 0.000 0.000 0.844 0.020
#> GSM40689 6 0.1059 0.866 0.016 0.004 0.000 0.000 0.016 0.964
#> GSM40690 5 0.3859 0.686 0.288 0.000 0.000 0.000 0.692 0.020
#> GSM40692 5 0.5195 0.674 0.040 0.068 0.112 0.000 0.732 0.048
#> GSM40693 5 0.2914 0.763 0.152 0.004 0.000 0.008 0.832 0.004
#> GSM40694 5 0.2907 0.766 0.152 0.000 0.000 0.000 0.828 0.020
#> GSM40695 1 0.1297 0.977 0.948 0.000 0.000 0.000 0.040 0.012
#> GSM40696 5 0.2876 0.764 0.148 0.004 0.000 0.008 0.836 0.004
#> GSM40697 2 0.5174 0.234 0.000 0.536 0.096 0.000 0.368 0.000
#> GSM40704 1 0.0858 0.992 0.968 0.000 0.000 0.000 0.028 0.004
#> GSM40705 4 0.3995 0.521 0.000 0.480 0.000 0.516 0.004 0.000
#> GSM40707 6 0.0000 0.889 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40708 6 0.0000 0.889 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40709 4 0.4263 0.518 0.000 0.480 0.000 0.504 0.016 0.000
#> GSM40712 5 0.1333 0.742 0.008 0.048 0.000 0.000 0.944 0.000
#> GSM40713 5 0.4782 0.698 0.168 0.012 0.000 0.000 0.700 0.120
#> GSM40665 6 0.0000 0.889 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM40677 3 0.4566 -0.561 0.008 0.484 0.488 0.000 0.020 0.000
#> GSM40698 6 0.4622 0.336 0.024 0.020 0.000 0.000 0.332 0.624
#> GSM40701 2 0.1952 0.191 0.000 0.920 0.012 0.052 0.016 0.000
#> GSM40710 2 0.3997 0.380 0.004 0.508 0.488 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 disease.state(p) k
#> MAD:mclust 43 2.16e-07 2
#> MAD:mclust 35 6.97e-09 3
#> MAD:mclust 52 1.23e-06 4
#> MAD:mclust 52 1.21e-04 5
#> MAD:mclust 26 1.24e-01 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.882 0.898 0.962 0.5073 0.491 0.491
#> 3 3 0.789 0.869 0.945 0.3143 0.738 0.515
#> 4 4 0.887 0.881 0.946 0.1325 0.849 0.584
#> 5 5 0.683 0.571 0.774 0.0439 0.936 0.763
#> 6 6 0.664 0.546 0.771 0.0375 0.849 0.463
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
#> GSM40663 2 0.0000 0.9591 0.000 1.000
#> GSM40667 2 0.0000 0.9591 0.000 1.000
#> GSM40675 2 0.0000 0.9591 0.000 1.000
#> GSM40703 2 0.0000 0.9591 0.000 1.000
#> GSM40660 2 0.0000 0.9591 0.000 1.000
#> GSM40668 2 0.0000 0.9591 0.000 1.000
#> GSM40678 2 0.0000 0.9591 0.000 1.000
#> GSM40679 2 0.0000 0.9591 0.000 1.000
#> GSM40686 2 1.0000 -0.0132 0.496 0.504
#> GSM40687 2 0.0000 0.9591 0.000 1.000
#> GSM40691 2 0.0000 0.9591 0.000 1.000
#> GSM40699 2 0.0000 0.9591 0.000 1.000
#> GSM40664 2 0.0000 0.9591 0.000 1.000
#> GSM40682 2 0.0000 0.9591 0.000 1.000
#> GSM40688 2 0.0000 0.9591 0.000 1.000
#> GSM40702 2 0.0000 0.9591 0.000 1.000
#> GSM40706 2 0.0000 0.9591 0.000 1.000
#> GSM40711 2 0.0000 0.9591 0.000 1.000
#> GSM40661 2 0.0000 0.9591 0.000 1.000
#> GSM40662 2 0.0000 0.9591 0.000 1.000
#> GSM40666 1 0.9988 0.0600 0.520 0.480
#> GSM40669 1 0.0000 0.9570 1.000 0.000
#> GSM40670 1 0.6801 0.7688 0.820 0.180
#> GSM40671 1 0.0000 0.9570 1.000 0.000
#> GSM40672 1 0.0000 0.9570 1.000 0.000
#> GSM40673 1 0.0000 0.9570 1.000 0.000
#> GSM40674 2 0.9427 0.4118 0.360 0.640
#> GSM40676 1 0.8386 0.6311 0.732 0.268
#> GSM40680 1 0.0000 0.9570 1.000 0.000
#> GSM40681 1 0.0000 0.9570 1.000 0.000
#> GSM40683 1 0.0000 0.9570 1.000 0.000
#> GSM40684 1 0.4298 0.8780 0.912 0.088
#> GSM40685 1 0.0000 0.9570 1.000 0.000
#> GSM40689 1 0.0000 0.9570 1.000 0.000
#> GSM40690 1 0.0000 0.9570 1.000 0.000
#> GSM40692 1 0.0000 0.9570 1.000 0.000
#> GSM40693 1 0.0000 0.9570 1.000 0.000
#> GSM40694 1 0.0000 0.9570 1.000 0.000
#> GSM40695 1 0.0000 0.9570 1.000 0.000
#> GSM40696 1 0.0000 0.9570 1.000 0.000
#> GSM40697 2 0.0376 0.9557 0.004 0.996
#> GSM40704 1 0.0000 0.9570 1.000 0.000
#> GSM40705 2 0.0000 0.9591 0.000 1.000
#> GSM40707 1 0.0000 0.9570 1.000 0.000
#> GSM40708 1 0.0000 0.9570 1.000 0.000
#> GSM40709 2 0.5842 0.8091 0.140 0.860
#> GSM40712 1 0.0000 0.9570 1.000 0.000
#> GSM40713 1 0.0000 0.9570 1.000 0.000
#> GSM40665 1 0.0000 0.9570 1.000 0.000
#> GSM40677 2 0.0000 0.9591 0.000 1.000
#> GSM40698 1 0.0000 0.9570 1.000 0.000
#> GSM40701 2 0.0000 0.9591 0.000 1.000
#> GSM40710 2 0.0000 0.9591 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40699 2 0.6154 0.252 0.000 0.592 0.408
#> GSM40664 3 0.5948 0.413 0.000 0.360 0.640
#> GSM40682 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40702 2 0.2448 0.870 0.000 0.924 0.076
#> GSM40706 2 0.0237 0.931 0.000 0.996 0.004
#> GSM40711 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40662 3 0.6280 0.129 0.000 0.460 0.540
#> GSM40666 3 0.3192 0.829 0.112 0.000 0.888
#> GSM40669 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40670 1 0.4504 0.721 0.804 0.000 0.196
#> GSM40671 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40674 3 0.4702 0.747 0.212 0.000 0.788
#> GSM40676 3 0.4504 0.766 0.196 0.000 0.804
#> GSM40680 2 0.4291 0.771 0.180 0.820 0.000
#> GSM40681 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40684 3 0.4504 0.766 0.196 0.000 0.804
#> GSM40685 1 0.5678 0.501 0.684 0.316 0.000
#> GSM40689 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40692 2 0.3941 0.796 0.156 0.844 0.000
#> GSM40693 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40696 1 0.0424 0.964 0.992 0.008 0.000
#> GSM40697 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40704 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40707 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40709 3 0.0592 0.887 0.012 0.000 0.988
#> GSM40712 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40713 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.933 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.971 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.891 0.000 0.000 1.000
#> GSM40710 2 0.0000 0.933 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0188 0.9881 0.000 0.000 0.996 0.004
#> GSM40668 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40691 2 0.2943 0.8835 0.032 0.892 0.076 0.000
#> GSM40699 2 0.2973 0.8290 0.000 0.856 0.144 0.000
#> GSM40664 4 0.4996 -0.0322 0.000 0.484 0.000 0.516
#> GSM40682 2 0.0336 0.9631 0.000 0.992 0.000 0.008
#> GSM40688 2 0.0188 0.9654 0.004 0.996 0.000 0.000
#> GSM40702 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40706 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40711 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40661 3 0.0336 0.9855 0.000 0.000 0.992 0.008
#> GSM40662 3 0.2742 0.8942 0.076 0.024 0.900 0.000
#> GSM40666 3 0.0188 0.9871 0.004 0.000 0.996 0.000
#> GSM40669 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40670 1 0.1557 0.8537 0.944 0.000 0.056 0.000
#> GSM40671 4 0.0921 0.8976 0.028 0.000 0.000 0.972
#> GSM40672 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40673 1 0.2011 0.8543 0.920 0.000 0.000 0.080
#> GSM40674 1 0.4477 0.5286 0.688 0.000 0.312 0.000
#> GSM40676 4 0.0000 0.9095 0.000 0.000 0.000 1.000
#> GSM40680 2 0.2589 0.8613 0.000 0.884 0.000 0.116
#> GSM40681 1 0.4800 0.5625 0.656 0.004 0.000 0.340
#> GSM40683 1 0.2408 0.8390 0.896 0.000 0.000 0.104
#> GSM40684 4 0.0000 0.9095 0.000 0.000 0.000 1.000
#> GSM40685 1 0.0188 0.8822 0.996 0.004 0.000 0.000
#> GSM40689 4 0.2149 0.8343 0.088 0.000 0.000 0.912
#> GSM40690 1 0.1792 0.8621 0.932 0.000 0.000 0.068
#> GSM40692 2 0.0188 0.9656 0.000 0.996 0.000 0.004
#> GSM40693 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40694 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40695 1 0.4406 0.6308 0.700 0.000 0.000 0.300
#> GSM40696 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40697 1 0.2300 0.8424 0.924 0.048 0.028 0.000
#> GSM40704 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40705 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40707 4 0.0469 0.9080 0.012 0.000 0.000 0.988
#> GSM40708 4 0.0336 0.9093 0.008 0.000 0.000 0.992
#> GSM40709 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40712 1 0.0000 0.8839 1.000 0.000 0.000 0.000
#> GSM40713 1 0.4776 0.4974 0.624 0.000 0.000 0.376
#> GSM40665 4 0.0000 0.9095 0.000 0.000 0.000 1.000
#> GSM40677 2 0.0000 0.9676 0.000 1.000 0.000 0.000
#> GSM40698 4 0.0188 0.9099 0.004 0.000 0.000 0.996
#> GSM40701 3 0.0000 0.9903 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0000 0.9676 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.2522 0.8383 0.000 0.012 0.880 0.000 0.108
#> GSM40668 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0162 0.7918 0.000 0.996 0.000 0.000 0.004
#> GSM40679 2 0.1121 0.7858 0.000 0.956 0.000 0.000 0.044
#> GSM40686 2 0.0703 0.7913 0.000 0.976 0.000 0.000 0.024
#> GSM40687 2 0.0703 0.7913 0.000 0.976 0.000 0.000 0.024
#> GSM40691 2 0.6369 0.3508 0.004 0.544 0.216 0.000 0.236
#> GSM40699 2 0.5050 0.5755 0.000 0.700 0.180 0.000 0.120
#> GSM40664 5 0.6783 -0.2712 0.000 0.296 0.000 0.316 0.388
#> GSM40682 2 0.3513 0.6996 0.000 0.800 0.000 0.020 0.180
#> GSM40688 2 0.3336 0.7056 0.000 0.772 0.000 0.000 0.228
#> GSM40702 2 0.0510 0.7925 0.000 0.984 0.000 0.000 0.016
#> GSM40706 2 0.0794 0.7889 0.000 0.972 0.000 0.000 0.028
#> GSM40711 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40661 3 0.2720 0.8367 0.000 0.004 0.880 0.020 0.096
#> GSM40662 5 0.6390 0.1125 0.076 0.036 0.384 0.000 0.504
#> GSM40666 3 0.0794 0.9041 0.028 0.000 0.972 0.000 0.000
#> GSM40669 1 0.4126 0.4044 0.620 0.000 0.000 0.000 0.380
#> GSM40670 1 0.6477 0.1308 0.492 0.000 0.228 0.000 0.280
#> GSM40671 4 0.3961 0.7577 0.212 0.000 0.000 0.760 0.028
#> GSM40672 1 0.1965 0.5539 0.904 0.000 0.000 0.000 0.096
#> GSM40673 1 0.1043 0.5530 0.960 0.000 0.000 0.040 0.000
#> GSM40674 3 0.5297 0.1425 0.360 0.000 0.580 0.000 0.060
#> GSM40676 4 0.1357 0.7473 0.048 0.000 0.000 0.948 0.004
#> GSM40680 2 0.6315 0.2420 0.000 0.448 0.000 0.396 0.156
#> GSM40681 1 0.4691 0.4683 0.784 0.064 0.000 0.092 0.060
#> GSM40683 1 0.1197 0.5526 0.952 0.000 0.000 0.048 0.000
#> GSM40684 4 0.5289 0.7036 0.208 0.000 0.108 0.680 0.004
#> GSM40685 1 0.6673 0.0575 0.388 0.232 0.000 0.000 0.380
#> GSM40689 1 0.5112 -0.5104 0.496 0.000 0.000 0.468 0.036
#> GSM40690 1 0.3410 0.4811 0.840 0.000 0.000 0.092 0.068
#> GSM40692 2 0.5589 0.5539 0.012 0.648 0.000 0.092 0.248
#> GSM40693 1 0.4201 0.3765 0.592 0.000 0.000 0.000 0.408
#> GSM40694 1 0.4210 0.3779 0.588 0.000 0.000 0.000 0.412
#> GSM40695 1 0.2818 0.4827 0.856 0.000 0.000 0.132 0.012
#> GSM40696 1 0.4249 0.3500 0.568 0.000 0.000 0.000 0.432
#> GSM40697 5 0.6408 -0.3951 0.432 0.068 0.040 0.000 0.460
#> GSM40704 1 0.1410 0.5600 0.940 0.000 0.000 0.000 0.060
#> GSM40705 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40707 4 0.1750 0.7291 0.036 0.000 0.000 0.936 0.028
#> GSM40708 4 0.1597 0.7009 0.012 0.000 0.000 0.940 0.048
#> GSM40709 3 0.0000 0.9265 0.000 0.000 1.000 0.000 0.000
#> GSM40712 1 0.4171 0.3947 0.604 0.000 0.000 0.000 0.396
#> GSM40713 1 0.5474 0.3270 0.576 0.000 0.000 0.348 0.076
#> GSM40665 4 0.4891 0.6853 0.316 0.000 0.000 0.640 0.044
#> GSM40677 2 0.3661 0.6705 0.000 0.724 0.000 0.000 0.276
#> GSM40698 4 0.6162 0.5650 0.392 0.048 0.000 0.516 0.044
#> GSM40701 3 0.0404 0.9207 0.000 0.000 0.988 0.000 0.012
#> GSM40710 2 0.0703 0.7913 0.000 0.976 0.000 0.000 0.024
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.2313 0.8564 0.004 0.000 0.884 0.100 0.012 0.000
#> GSM40668 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.1498 0.7628 0.000 0.940 0.000 0.028 0.032 0.000
#> GSM40679 2 0.2776 0.7310 0.000 0.860 0.000 0.088 0.052 0.000
#> GSM40686 2 0.0458 0.7635 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM40687 2 0.0725 0.7647 0.000 0.976 0.000 0.012 0.012 0.000
#> GSM40691 5 0.7421 0.1371 0.004 0.244 0.156 0.180 0.416 0.000
#> GSM40699 2 0.5884 0.4248 0.000 0.612 0.200 0.128 0.060 0.000
#> GSM40664 4 0.4190 0.0000 0.004 0.056 0.000 0.748 0.008 0.184
#> GSM40682 2 0.4407 0.3380 0.000 0.592 0.000 0.380 0.024 0.004
#> GSM40688 5 0.6126 -0.0521 0.004 0.336 0.000 0.244 0.416 0.000
#> GSM40702 2 0.1257 0.7653 0.000 0.952 0.000 0.020 0.028 0.000
#> GSM40706 2 0.1801 0.7472 0.000 0.924 0.004 0.056 0.016 0.000
#> GSM40711 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40661 3 0.3088 0.7641 0.000 0.000 0.808 0.172 0.000 0.020
#> GSM40662 5 0.3360 0.4159 0.020 0.004 0.148 0.012 0.816 0.000
#> GSM40666 3 0.2300 0.7997 0.144 0.000 0.856 0.000 0.000 0.000
#> GSM40669 5 0.4051 0.4019 0.432 0.000 0.008 0.000 0.560 0.000
#> GSM40670 5 0.6083 0.2854 0.272 0.000 0.364 0.000 0.364 0.000
#> GSM40671 6 0.3728 0.4431 0.344 0.000 0.000 0.004 0.000 0.652
#> GSM40672 1 0.1910 0.6461 0.892 0.000 0.000 0.000 0.108 0.000
#> GSM40673 1 0.1088 0.7386 0.960 0.000 0.000 0.024 0.000 0.016
#> GSM40674 3 0.3976 0.6343 0.196 0.000 0.748 0.004 0.052 0.000
#> GSM40676 6 0.1867 0.4912 0.020 0.000 0.000 0.064 0.000 0.916
#> GSM40680 6 0.6467 -0.0255 0.008 0.200 0.000 0.024 0.284 0.484
#> GSM40681 1 0.4432 0.6449 0.780 0.044 0.000 0.076 0.088 0.012
#> GSM40683 1 0.0692 0.7392 0.976 0.000 0.000 0.004 0.000 0.020
#> GSM40684 6 0.5352 0.4449 0.172 0.000 0.080 0.072 0.000 0.676
#> GSM40685 2 0.7228 -0.1153 0.140 0.408 0.000 0.116 0.328 0.008
#> GSM40689 1 0.4792 0.4479 0.672 0.000 0.000 0.148 0.000 0.180
#> GSM40690 1 0.4140 0.5796 0.704 0.000 0.000 0.260 0.016 0.020
#> GSM40692 5 0.6235 0.1504 0.004 0.176 0.000 0.044 0.564 0.212
#> GSM40693 5 0.3647 0.4763 0.360 0.000 0.000 0.000 0.640 0.000
#> GSM40694 5 0.4504 0.4813 0.332 0.000 0.000 0.032 0.628 0.008
#> GSM40695 1 0.1844 0.7319 0.924 0.000 0.000 0.004 0.024 0.048
#> GSM40696 5 0.3620 0.4813 0.352 0.000 0.000 0.000 0.648 0.000
#> GSM40697 5 0.5856 0.4464 0.108 0.080 0.036 0.096 0.680 0.000
#> GSM40704 1 0.1663 0.6724 0.912 0.000 0.000 0.000 0.088 0.000
#> GSM40705 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40707 6 0.1524 0.5297 0.060 0.000 0.000 0.008 0.000 0.932
#> GSM40708 6 0.0717 0.5006 0.016 0.000 0.000 0.008 0.000 0.976
#> GSM40709 3 0.0000 0.9325 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40712 5 0.4246 0.3748 0.400 0.000 0.000 0.020 0.580 0.000
#> GSM40713 6 0.5014 0.2745 0.392 0.000 0.000 0.008 0.056 0.544
#> GSM40665 6 0.5976 0.1871 0.248 0.000 0.000 0.264 0.004 0.484
#> GSM40677 5 0.5698 -0.1701 0.000 0.400 0.000 0.160 0.440 0.000
#> GSM40698 1 0.7015 0.1006 0.448 0.024 0.000 0.268 0.036 0.224
#> GSM40701 3 0.0260 0.9292 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40710 2 0.1500 0.7435 0.000 0.936 0.000 0.052 0.012 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:NMF 50 1.79e-05 2
#> MAD:NMF 50 1.74e-04 3
#> MAD:NMF 51 3.25e-05 4
#> MAD:NMF 35 1.02e-02 5
#> MAD:NMF 29 2.34e-02 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 35373 rows and 53 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 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.376 0.701 0.752 0.3965 0.495 0.495
#> 3 3 0.652 0.860 0.925 0.4746 0.730 0.550
#> 4 4 0.719 0.736 0.879 0.2313 0.837 0.624
#> 5 5 0.820 0.717 0.846 0.0804 0.944 0.797
#> 6 6 0.805 0.676 0.834 0.0299 0.960 0.830
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
#> GSM40663 2 0.000 0.6181 0.000 1.000
#> GSM40667 2 0.000 0.6181 0.000 1.000
#> GSM40675 2 0.000 0.6181 0.000 1.000
#> GSM40703 2 0.000 0.6181 0.000 1.000
#> GSM40660 2 0.833 0.8627 0.264 0.736
#> GSM40668 2 0.000 0.6181 0.000 1.000
#> GSM40678 2 0.861 0.8672 0.284 0.716
#> GSM40679 2 0.861 0.8672 0.284 0.716
#> GSM40686 2 0.861 0.8672 0.284 0.716
#> GSM40687 2 0.861 0.8672 0.284 0.716
#> GSM40691 2 0.855 0.8670 0.280 0.720
#> GSM40699 2 0.827 0.8605 0.260 0.740
#> GSM40664 2 0.861 0.8672 0.284 0.716
#> GSM40682 2 0.861 0.8672 0.284 0.716
#> GSM40688 2 0.861 0.8672 0.284 0.716
#> GSM40702 2 0.855 0.8670 0.280 0.720
#> GSM40706 2 0.861 0.8672 0.284 0.716
#> GSM40711 2 0.833 0.8627 0.264 0.736
#> GSM40661 2 0.827 0.8605 0.260 0.740
#> GSM40662 2 0.971 0.6861 0.400 0.600
#> GSM40666 2 0.936 0.7896 0.352 0.648
#> GSM40669 1 0.978 -0.0803 0.588 0.412
#> GSM40670 1 0.978 -0.0803 0.588 0.412
#> GSM40671 1 0.000 0.8298 1.000 0.000
#> GSM40672 1 0.000 0.8298 1.000 0.000
#> GSM40673 1 0.000 0.8298 1.000 0.000
#> GSM40674 1 0.978 -0.0803 0.588 0.412
#> GSM40676 2 0.946 0.7738 0.364 0.636
#> GSM40680 1 0.992 -0.2529 0.552 0.448
#> GSM40681 1 0.000 0.8298 1.000 0.000
#> GSM40683 1 0.000 0.8298 1.000 0.000
#> GSM40684 2 0.946 0.7738 0.364 0.636
#> GSM40685 1 0.416 0.7430 0.916 0.084
#> GSM40689 1 0.000 0.8298 1.000 0.000
#> GSM40690 1 0.000 0.8298 1.000 0.000
#> GSM40692 1 0.992 -0.2529 0.552 0.448
#> GSM40693 1 0.000 0.8298 1.000 0.000
#> GSM40694 1 0.000 0.8298 1.000 0.000
#> GSM40695 1 0.000 0.8298 1.000 0.000
#> GSM40696 1 0.000 0.8298 1.000 0.000
#> GSM40697 2 0.981 0.6414 0.420 0.580
#> GSM40704 1 0.000 0.8298 1.000 0.000
#> GSM40705 2 0.833 0.8627 0.264 0.736
#> GSM40707 1 0.000 0.8298 1.000 0.000
#> GSM40708 1 0.000 0.8298 1.000 0.000
#> GSM40709 2 0.939 0.7838 0.356 0.644
#> GSM40712 1 0.978 -0.0803 0.588 0.412
#> GSM40713 1 0.000 0.8298 1.000 0.000
#> GSM40665 1 0.000 0.8298 1.000 0.000
#> GSM40677 2 0.861 0.8672 0.284 0.716
#> GSM40698 1 0.000 0.8298 1.000 0.000
#> GSM40701 2 0.827 0.8605 0.260 0.740
#> GSM40710 2 0.861 0.8672 0.284 0.716
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 1.000 0.000 0.000 1.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1.000
#> GSM40660 2 0.4702 0.753 0.000 0.788 0.212
#> GSM40668 3 0.0000 1.000 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40691 2 0.0237 0.860 0.000 0.996 0.004
#> GSM40699 2 0.4235 0.774 0.000 0.824 0.176
#> GSM40664 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40682 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40702 2 0.0237 0.860 0.000 0.996 0.004
#> GSM40706 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40711 2 0.4702 0.753 0.000 0.788 0.212
#> GSM40661 2 0.4750 0.748 0.000 0.784 0.216
#> GSM40662 2 0.3267 0.822 0.116 0.884 0.000
#> GSM40666 2 0.2261 0.853 0.068 0.932 0.000
#> GSM40669 2 0.5591 0.652 0.304 0.696 0.000
#> GSM40670 2 0.5591 0.652 0.304 0.696 0.000
#> GSM40671 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40674 2 0.5591 0.652 0.304 0.696 0.000
#> GSM40676 2 0.2711 0.848 0.088 0.912 0.000
#> GSM40680 2 0.5291 0.713 0.268 0.732 0.000
#> GSM40681 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40684 2 0.2711 0.848 0.088 0.912 0.000
#> GSM40685 1 0.5988 0.254 0.632 0.368 0.000
#> GSM40689 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40692 2 0.5291 0.713 0.268 0.732 0.000
#> GSM40693 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40696 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40697 2 0.3619 0.814 0.136 0.864 0.000
#> GSM40704 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40705 2 0.4702 0.753 0.000 0.788 0.212
#> GSM40707 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40709 2 0.2356 0.852 0.072 0.928 0.000
#> GSM40712 2 0.5591 0.652 0.304 0.696 0.000
#> GSM40713 1 0.0000 0.966 1.000 0.000 0.000
#> GSM40665 1 0.0237 0.961 0.996 0.004 0.000
#> GSM40677 2 0.0000 0.861 0.000 1.000 0.000
#> GSM40698 1 0.1529 0.918 0.960 0.040 0.000
#> GSM40701 2 0.4702 0.753 0.000 0.788 0.212
#> GSM40710 2 0.0000 0.861 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 1.00000 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 1.00000 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 1.00000 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 1.00000 0.000 0.000 0.000 1.000
#> GSM40660 3 0.5464 0.59913 0.000 0.072 0.716 0.212
#> GSM40668 4 0.0000 1.00000 0.000 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.79022 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0592 0.79230 0.000 0.984 0.016 0.000
#> GSM40686 2 0.0592 0.79230 0.000 0.984 0.016 0.000
#> GSM40687 2 0.0000 0.79022 0.000 1.000 0.000 0.000
#> GSM40691 2 0.3945 0.61919 0.000 0.780 0.216 0.004
#> GSM40699 2 0.6745 0.39833 0.000 0.612 0.212 0.176
#> GSM40664 2 0.4999 0.02906 0.000 0.508 0.492 0.000
#> GSM40682 2 0.0592 0.79230 0.000 0.984 0.016 0.000
#> GSM40688 2 0.0592 0.79230 0.000 0.984 0.016 0.000
#> GSM40702 2 0.3982 0.61444 0.000 0.776 0.220 0.004
#> GSM40706 2 0.0000 0.79022 0.000 1.000 0.000 0.000
#> GSM40711 3 0.3908 0.62002 0.000 0.004 0.784 0.212
#> GSM40661 3 0.5867 0.58405 0.000 0.096 0.688 0.216
#> GSM40662 2 0.6813 0.07739 0.104 0.516 0.380 0.000
#> GSM40666 3 0.0000 0.69765 0.000 0.000 1.000 0.000
#> GSM40669 3 0.3942 0.64986 0.236 0.000 0.764 0.000
#> GSM40670 3 0.3942 0.64986 0.236 0.000 0.764 0.000
#> GSM40671 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40672 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40674 3 0.3942 0.64986 0.236 0.000 0.764 0.000
#> GSM40676 3 0.0707 0.70154 0.020 0.000 0.980 0.000
#> GSM40680 3 0.7743 0.14779 0.232 0.368 0.400 0.000
#> GSM40681 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40683 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40684 3 0.0707 0.70154 0.020 0.000 0.980 0.000
#> GSM40685 1 0.5060 0.10173 0.584 0.004 0.412 0.000
#> GSM40689 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40690 1 0.0188 0.96164 0.996 0.000 0.004 0.000
#> GSM40692 3 0.7743 0.14779 0.232 0.368 0.400 0.000
#> GSM40693 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40694 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40695 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40696 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40697 2 0.6895 0.00902 0.108 0.492 0.400 0.000
#> GSM40704 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40705 3 0.3908 0.62002 0.000 0.004 0.784 0.212
#> GSM40707 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40708 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40709 3 0.0188 0.69906 0.004 0.000 0.996 0.000
#> GSM40712 3 0.3942 0.64986 0.236 0.000 0.764 0.000
#> GSM40713 1 0.0000 0.96452 1.000 0.000 0.000 0.000
#> GSM40665 1 0.0707 0.94813 0.980 0.000 0.020 0.000
#> GSM40677 2 0.0592 0.79230 0.000 0.984 0.016 0.000
#> GSM40698 1 0.1661 0.91033 0.944 0.004 0.052 0.000
#> GSM40701 3 0.5889 0.58531 0.000 0.100 0.688 0.212
#> GSM40710 2 0.0000 0.79022 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.3143 1.0000 0.000 0.000 0.796 0.204 0.000
#> GSM40667 3 0.3143 1.0000 0.000 0.000 0.796 0.204 0.000
#> GSM40675 3 0.3143 1.0000 0.000 0.000 0.796 0.204 0.000
#> GSM40703 3 0.3143 1.0000 0.000 0.000 0.796 0.204 0.000
#> GSM40660 4 0.1704 0.6275 0.000 0.068 0.004 0.928 0.000
#> GSM40668 3 0.3143 1.0000 0.000 0.000 0.796 0.204 0.000
#> GSM40678 2 0.0960 0.7638 0.000 0.972 0.016 0.008 0.004
#> GSM40679 2 0.0404 0.7639 0.000 0.988 0.000 0.000 0.012
#> GSM40686 2 0.1195 0.7588 0.000 0.960 0.028 0.000 0.012
#> GSM40687 2 0.0960 0.7638 0.000 0.972 0.016 0.008 0.004
#> GSM40691 2 0.3551 0.6448 0.000 0.772 0.000 0.220 0.008
#> GSM40699 2 0.4310 0.3979 0.000 0.604 0.004 0.392 0.000
#> GSM40664 2 0.5330 -0.0530 0.000 0.484 0.028 0.476 0.012
#> GSM40682 2 0.0404 0.7639 0.000 0.988 0.000 0.000 0.012
#> GSM40688 2 0.1195 0.7588 0.000 0.960 0.028 0.000 0.012
#> GSM40702 2 0.3582 0.6411 0.000 0.768 0.000 0.224 0.008
#> GSM40706 2 0.3053 0.7187 0.000 0.872 0.044 0.008 0.076
#> GSM40711 4 0.0162 0.6372 0.000 0.000 0.004 0.996 0.000
#> GSM40661 4 0.2193 0.6116 0.000 0.092 0.008 0.900 0.000
#> GSM40662 2 0.5548 -0.0941 0.000 0.492 0.036 0.016 0.456
#> GSM40666 4 0.4227 0.5746 0.000 0.000 0.000 0.580 0.420
#> GSM40669 5 0.1768 0.6665 0.072 0.000 0.000 0.004 0.924
#> GSM40670 5 0.1768 0.6665 0.072 0.000 0.000 0.004 0.924
#> GSM40671 1 0.0609 0.9521 0.980 0.000 0.020 0.000 0.000
#> GSM40672 1 0.0162 0.9548 0.996 0.000 0.004 0.000 0.000
#> GSM40673 1 0.0404 0.9542 0.988 0.000 0.012 0.000 0.000
#> GSM40674 5 0.1768 0.6665 0.072 0.000 0.000 0.004 0.924
#> GSM40676 4 0.4713 0.5530 0.016 0.000 0.000 0.544 0.440
#> GSM40680 5 0.7163 0.3093 0.048 0.344 0.148 0.000 0.460
#> GSM40681 1 0.1018 0.9489 0.968 0.000 0.016 0.000 0.016
#> GSM40683 1 0.0404 0.9542 0.988 0.000 0.012 0.000 0.000
#> GSM40684 4 0.4713 0.5530 0.016 0.000 0.000 0.544 0.440
#> GSM40685 5 0.6207 0.3781 0.348 0.008 0.120 0.000 0.524
#> GSM40689 1 0.0404 0.9542 0.988 0.000 0.012 0.000 0.000
#> GSM40690 1 0.0579 0.9535 0.984 0.000 0.008 0.000 0.008
#> GSM40692 5 0.7163 0.3093 0.048 0.344 0.148 0.000 0.460
#> GSM40693 1 0.0912 0.9499 0.972 0.000 0.012 0.000 0.016
#> GSM40694 1 0.1018 0.9489 0.968 0.000 0.016 0.000 0.016
#> GSM40695 1 0.0404 0.9542 0.988 0.000 0.012 0.000 0.000
#> GSM40696 1 0.0912 0.9499 0.972 0.000 0.012 0.000 0.016
#> GSM40697 2 0.5557 -0.1718 0.000 0.468 0.068 0.000 0.464
#> GSM40704 1 0.0404 0.9542 0.988 0.000 0.012 0.000 0.000
#> GSM40705 4 0.0162 0.6372 0.000 0.000 0.004 0.996 0.000
#> GSM40707 1 0.0404 0.9542 0.988 0.000 0.012 0.000 0.000
#> GSM40708 1 0.0000 0.9548 1.000 0.000 0.000 0.000 0.000
#> GSM40709 4 0.4262 0.5619 0.000 0.000 0.000 0.560 0.440
#> GSM40712 5 0.1768 0.6665 0.072 0.000 0.000 0.004 0.924
#> GSM40713 1 0.1018 0.9489 0.968 0.000 0.016 0.000 0.016
#> GSM40665 1 0.3657 0.7822 0.820 0.000 0.064 0.000 0.116
#> GSM40677 2 0.1195 0.7588 0.000 0.960 0.028 0.000 0.012
#> GSM40698 1 0.4593 0.7019 0.756 0.008 0.076 0.000 0.160
#> GSM40701 4 0.2068 0.6115 0.000 0.092 0.004 0.904 0.000
#> GSM40710 2 0.0960 0.7638 0.000 0.972 0.016 0.008 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.6681 0.588 0.000 0.000 0.208 0.508 0.204 0.080
#> GSM40668 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.3586 0.594 0.000 0.720 0.000 0.000 0.012 0.268
#> GSM40679 2 0.0146 0.710 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM40686 2 0.0713 0.703 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM40687 2 0.3541 0.597 0.000 0.728 0.000 0.000 0.012 0.260
#> GSM40691 2 0.3896 0.614 0.000 0.744 0.000 0.000 0.204 0.052
#> GSM40699 2 0.6338 0.339 0.000 0.552 0.172 0.000 0.212 0.064
#> GSM40664 4 0.5448 0.177 0.000 0.440 0.000 0.476 0.028 0.056
#> GSM40682 2 0.0146 0.710 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM40688 2 0.0713 0.703 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM40702 2 0.3954 0.610 0.000 0.740 0.000 0.000 0.204 0.056
#> GSM40706 6 0.1007 0.000 0.000 0.044 0.000 0.000 0.000 0.956
#> GSM40711 4 0.5702 0.603 0.000 0.000 0.208 0.576 0.204 0.012
#> GSM40661 4 0.6928 0.570 0.000 0.000 0.212 0.476 0.212 0.100
#> GSM40662 2 0.4128 -0.309 0.000 0.504 0.000 0.004 0.488 0.004
#> GSM40666 4 0.0000 0.542 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40669 5 0.4039 0.599 0.000 0.008 0.000 0.424 0.568 0.000
#> GSM40670 5 0.4039 0.599 0.000 0.008 0.000 0.424 0.568 0.000
#> GSM40671 1 0.0547 0.933 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM40672 1 0.0260 0.936 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM40673 1 0.0363 0.935 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40674 5 0.4039 0.599 0.000 0.008 0.000 0.424 0.568 0.000
#> GSM40676 4 0.1003 0.526 0.016 0.000 0.000 0.964 0.020 0.000
#> GSM40680 5 0.3967 0.430 0.012 0.356 0.000 0.000 0.632 0.000
#> GSM40681 1 0.0937 0.930 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM40683 1 0.0363 0.935 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40684 4 0.1003 0.526 0.016 0.000 0.000 0.964 0.020 0.000
#> GSM40685 5 0.3944 0.340 0.216 0.016 0.000 0.000 0.744 0.024
#> GSM40689 1 0.0363 0.935 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40690 1 0.0909 0.931 0.968 0.000 0.000 0.000 0.020 0.012
#> GSM40692 5 0.3967 0.430 0.012 0.356 0.000 0.000 0.632 0.000
#> GSM40693 1 0.0790 0.932 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM40694 1 0.1007 0.928 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM40695 1 0.0363 0.935 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40696 1 0.0790 0.932 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM40697 5 0.4183 0.234 0.000 0.480 0.000 0.012 0.508 0.000
#> GSM40704 1 0.0363 0.935 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40705 4 0.5702 0.603 0.000 0.000 0.208 0.576 0.204 0.012
#> GSM40707 1 0.0363 0.935 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40708 1 0.0146 0.936 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM40709 4 0.0547 0.534 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM40712 5 0.4039 0.599 0.000 0.008 0.000 0.424 0.568 0.000
#> GSM40713 1 0.1007 0.928 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM40665 1 0.3855 0.637 0.704 0.000 0.000 0.000 0.272 0.024
#> GSM40677 2 0.0713 0.703 0.000 0.972 0.000 0.000 0.028 0.000
#> GSM40698 1 0.4406 0.534 0.624 0.008 0.000 0.000 0.344 0.024
#> GSM40701 4 0.6944 0.569 0.000 0.000 0.208 0.476 0.212 0.104
#> GSM40710 2 0.3541 0.597 0.000 0.728 0.000 0.000 0.012 0.260
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:hclust 47 1.15e-03 2
#> ATC:hclust 52 5.09e-08 3
#> ATC:hclust 46 6.81e-09 4
#> ATC:hclust 46 1.53e-07 5
#> ATC:hclust 45 3.58e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 35373 rows and 53 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.742 0.796 0.924 0.4908 0.499 0.499
#> 3 3 0.665 0.784 0.899 0.2839 0.636 0.405
#> 4 4 0.857 0.908 0.936 0.1837 0.846 0.594
#> 5 5 0.728 0.652 0.745 0.0664 0.965 0.856
#> 6 6 0.723 0.483 0.620 0.0410 0.864 0.483
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM40663 2 0.000 0.9048 0.000 1.000
#> GSM40667 2 0.000 0.9048 0.000 1.000
#> GSM40675 2 0.000 0.9048 0.000 1.000
#> GSM40703 2 0.000 0.9048 0.000 1.000
#> GSM40660 2 0.000 0.9048 0.000 1.000
#> GSM40668 2 0.000 0.9048 0.000 1.000
#> GSM40678 2 0.000 0.9048 0.000 1.000
#> GSM40679 2 0.402 0.8436 0.080 0.920
#> GSM40686 1 1.000 -0.0658 0.500 0.500
#> GSM40687 2 0.000 0.9048 0.000 1.000
#> GSM40691 2 0.000 0.9048 0.000 1.000
#> GSM40699 2 0.000 0.9048 0.000 1.000
#> GSM40664 2 0.975 0.3105 0.408 0.592
#> GSM40682 2 0.402 0.8436 0.080 0.920
#> GSM40688 2 0.990 0.2136 0.440 0.560
#> GSM40702 2 0.000 0.9048 0.000 1.000
#> GSM40706 2 0.000 0.9048 0.000 1.000
#> GSM40711 2 0.000 0.9048 0.000 1.000
#> GSM40661 2 0.000 0.9048 0.000 1.000
#> GSM40662 2 0.963 0.3561 0.388 0.612
#> GSM40666 1 0.966 0.3410 0.608 0.392
#> GSM40669 1 0.000 0.9126 1.000 0.000
#> GSM40670 1 0.760 0.6759 0.780 0.220
#> GSM40671 1 0.000 0.9126 1.000 0.000
#> GSM40672 1 0.000 0.9126 1.000 0.000
#> GSM40673 1 0.000 0.9126 1.000 0.000
#> GSM40674 1 0.760 0.6759 0.780 0.220
#> GSM40676 1 0.000 0.9126 1.000 0.000
#> GSM40680 1 0.000 0.9126 1.000 0.000
#> GSM40681 1 0.000 0.9126 1.000 0.000
#> GSM40683 1 0.000 0.9126 1.000 0.000
#> GSM40684 1 0.000 0.9126 1.000 0.000
#> GSM40685 1 0.000 0.9126 1.000 0.000
#> GSM40689 1 0.000 0.9126 1.000 0.000
#> GSM40690 1 0.000 0.9126 1.000 0.000
#> GSM40692 1 0.000 0.9126 1.000 0.000
#> GSM40693 1 0.000 0.9126 1.000 0.000
#> GSM40694 1 0.000 0.9126 1.000 0.000
#> GSM40695 1 0.000 0.9126 1.000 0.000
#> GSM40696 1 0.000 0.9126 1.000 0.000
#> GSM40697 1 0.988 0.1946 0.564 0.436
#> GSM40704 1 0.000 0.9126 1.000 0.000
#> GSM40705 2 0.000 0.9048 0.000 1.000
#> GSM40707 1 0.000 0.9126 1.000 0.000
#> GSM40708 1 0.000 0.9126 1.000 0.000
#> GSM40709 1 0.988 0.2104 0.564 0.436
#> GSM40712 1 0.000 0.9126 1.000 0.000
#> GSM40713 1 0.000 0.9126 1.000 0.000
#> GSM40665 1 0.000 0.9126 1.000 0.000
#> GSM40677 2 0.975 0.3105 0.408 0.592
#> GSM40698 1 0.000 0.9126 1.000 0.000
#> GSM40701 2 0.000 0.9048 0.000 1.000
#> GSM40710 2 0.000 0.9048 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.909 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.909 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.909 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.909 0.000 0.000 1.000
#> GSM40660 3 0.5706 0.615 0.000 0.320 0.680
#> GSM40668 3 0.0000 0.909 0.000 0.000 1.000
#> GSM40678 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40679 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40686 2 0.0424 0.772 0.008 0.992 0.000
#> GSM40687 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40691 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40699 2 0.6305 -0.300 0.000 0.516 0.484
#> GSM40664 2 0.0000 0.771 0.000 1.000 0.000
#> GSM40682 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40688 2 0.0424 0.772 0.008 0.992 0.000
#> GSM40702 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40706 2 0.0424 0.771 0.000 0.992 0.008
#> GSM40711 3 0.1964 0.902 0.000 0.056 0.944
#> GSM40661 3 0.4178 0.833 0.000 0.172 0.828
#> GSM40662 2 0.0000 0.771 0.000 1.000 0.000
#> GSM40666 2 0.5327 0.669 0.272 0.728 0.000
#> GSM40669 2 0.6204 0.470 0.424 0.576 0.000
#> GSM40670 2 0.5327 0.669 0.272 0.728 0.000
#> GSM40671 1 0.0424 0.971 0.992 0.008 0.000
#> GSM40672 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40674 2 0.5327 0.669 0.272 0.728 0.000
#> GSM40676 2 0.6225 0.440 0.432 0.568 0.000
#> GSM40680 2 0.6111 0.520 0.396 0.604 0.000
#> GSM40681 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40684 2 0.6225 0.440 0.432 0.568 0.000
#> GSM40685 1 0.5254 0.515 0.736 0.264 0.000
#> GSM40689 1 0.0424 0.971 0.992 0.008 0.000
#> GSM40690 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40692 2 0.6111 0.520 0.396 0.604 0.000
#> GSM40693 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40696 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40697 2 0.0424 0.772 0.008 0.992 0.000
#> GSM40704 1 0.0000 0.973 1.000 0.000 0.000
#> GSM40705 3 0.1964 0.902 0.000 0.056 0.944
#> GSM40707 1 0.0424 0.971 0.992 0.008 0.000
#> GSM40708 1 0.0424 0.971 0.992 0.008 0.000
#> GSM40709 2 0.5291 0.672 0.268 0.732 0.000
#> GSM40712 2 0.6291 0.365 0.468 0.532 0.000
#> GSM40713 1 0.0424 0.971 0.992 0.008 0.000
#> GSM40665 1 0.0424 0.971 0.992 0.008 0.000
#> GSM40677 2 0.0424 0.772 0.008 0.992 0.000
#> GSM40698 1 0.1964 0.919 0.944 0.056 0.000
#> GSM40701 3 0.4178 0.833 0.000 0.172 0.828
#> GSM40710 2 0.0424 0.771 0.000 0.992 0.008
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 0.848 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 0.848 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 0.848 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 0.848 0.000 0.000 0.000 1.000
#> GSM40660 4 0.6429 0.765 0.000 0.144 0.212 0.644
#> GSM40668 4 0.0000 0.848 0.000 0.000 0.000 1.000
#> GSM40678 2 0.0336 0.963 0.000 0.992 0.008 0.000
#> GSM40679 2 0.0469 0.963 0.000 0.988 0.012 0.000
#> GSM40686 2 0.1211 0.955 0.000 0.960 0.040 0.000
#> GSM40687 2 0.0336 0.963 0.000 0.992 0.008 0.000
#> GSM40691 2 0.0336 0.963 0.000 0.992 0.008 0.000
#> GSM40699 2 0.2611 0.864 0.000 0.896 0.008 0.096
#> GSM40664 2 0.1211 0.955 0.000 0.960 0.040 0.000
#> GSM40682 2 0.1022 0.958 0.000 0.968 0.032 0.000
#> GSM40688 2 0.1211 0.955 0.000 0.960 0.040 0.000
#> GSM40702 2 0.0336 0.963 0.000 0.992 0.008 0.000
#> GSM40706 2 0.0707 0.959 0.000 0.980 0.020 0.000
#> GSM40711 4 0.4868 0.799 0.000 0.040 0.212 0.748
#> GSM40661 4 0.6440 0.766 0.000 0.148 0.208 0.644
#> GSM40662 3 0.1302 0.858 0.000 0.044 0.956 0.000
#> GSM40666 3 0.0469 0.875 0.012 0.000 0.988 0.000
#> GSM40669 3 0.2048 0.871 0.064 0.008 0.928 0.000
#> GSM40670 3 0.0469 0.875 0.012 0.000 0.988 0.000
#> GSM40671 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40672 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40674 3 0.0469 0.875 0.012 0.000 0.988 0.000
#> GSM40676 3 0.0469 0.875 0.012 0.000 0.988 0.000
#> GSM40680 3 0.4849 0.807 0.164 0.064 0.772 0.000
#> GSM40681 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40683 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40684 3 0.0469 0.875 0.012 0.000 0.988 0.000
#> GSM40685 3 0.4158 0.778 0.224 0.008 0.768 0.000
#> GSM40689 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40690 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40692 3 0.4849 0.807 0.164 0.064 0.772 0.000
#> GSM40693 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40694 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40695 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40696 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40697 3 0.3873 0.719 0.000 0.228 0.772 0.000
#> GSM40704 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40705 4 0.4868 0.799 0.000 0.040 0.212 0.748
#> GSM40707 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40708 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40709 3 0.0469 0.875 0.012 0.000 0.988 0.000
#> GSM40712 3 0.2546 0.862 0.092 0.008 0.900 0.000
#> GSM40713 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40665 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM40677 2 0.1211 0.955 0.000 0.960 0.040 0.000
#> GSM40698 3 0.4158 0.778 0.224 0.008 0.768 0.000
#> GSM40701 4 0.6133 0.667 0.000 0.268 0.088 0.644
#> GSM40710 2 0.0336 0.963 0.000 0.992 0.008 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.732 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.732 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.732 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.732 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.6724 0.588 0.000 0.208 0.408 0.380 0.004
#> GSM40668 3 0.0000 0.732 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0510 0.872 0.000 0.984 0.000 0.016 0.000
#> GSM40679 2 0.2763 0.864 0.000 0.848 0.000 0.004 0.148
#> GSM40686 2 0.3282 0.847 0.000 0.804 0.000 0.008 0.188
#> GSM40687 2 0.0510 0.872 0.000 0.984 0.000 0.016 0.000
#> GSM40691 2 0.0510 0.872 0.000 0.984 0.000 0.016 0.000
#> GSM40699 2 0.3629 0.711 0.000 0.832 0.092 0.072 0.004
#> GSM40664 2 0.3209 0.852 0.000 0.812 0.000 0.008 0.180
#> GSM40682 2 0.2890 0.862 0.000 0.836 0.000 0.004 0.160
#> GSM40688 2 0.3355 0.848 0.000 0.804 0.000 0.012 0.184
#> GSM40702 2 0.0404 0.872 0.000 0.988 0.000 0.012 0.000
#> GSM40706 2 0.1331 0.859 0.000 0.952 0.000 0.040 0.008
#> GSM40711 3 0.4973 0.631 0.000 0.024 0.564 0.408 0.004
#> GSM40661 3 0.6736 0.592 0.000 0.212 0.412 0.372 0.004
#> GSM40662 5 0.4448 -0.367 0.000 0.004 0.000 0.480 0.516
#> GSM40666 4 0.3366 0.735 0.000 0.000 0.000 0.768 0.232
#> GSM40669 5 0.4297 -0.288 0.000 0.000 0.000 0.472 0.528
#> GSM40670 4 0.4294 0.333 0.000 0.000 0.000 0.532 0.468
#> GSM40671 1 0.1281 0.804 0.956 0.000 0.000 0.032 0.012
#> GSM40672 1 0.0000 0.810 1.000 0.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.810 1.000 0.000 0.000 0.000 0.000
#> GSM40674 4 0.4287 0.356 0.000 0.000 0.000 0.540 0.460
#> GSM40676 4 0.2891 0.714 0.000 0.000 0.000 0.824 0.176
#> GSM40680 5 0.0898 0.519 0.008 0.000 0.000 0.020 0.972
#> GSM40681 1 0.4251 0.678 0.624 0.000 0.000 0.004 0.372
#> GSM40683 1 0.0000 0.810 1.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.2891 0.714 0.000 0.000 0.000 0.824 0.176
#> GSM40685 5 0.0579 0.513 0.008 0.000 0.000 0.008 0.984
#> GSM40689 1 0.1168 0.803 0.960 0.000 0.000 0.032 0.008
#> GSM40690 1 0.3491 0.774 0.768 0.000 0.000 0.004 0.228
#> GSM40692 5 0.0798 0.519 0.008 0.000 0.000 0.016 0.976
#> GSM40693 1 0.4310 0.653 0.604 0.000 0.000 0.004 0.392
#> GSM40694 1 0.4446 0.524 0.520 0.000 0.000 0.004 0.476
#> GSM40695 1 0.0000 0.810 1.000 0.000 0.000 0.000 0.000
#> GSM40696 1 0.4310 0.653 0.604 0.000 0.000 0.004 0.392
#> GSM40697 5 0.4725 0.300 0.000 0.200 0.000 0.080 0.720
#> GSM40704 1 0.0000 0.810 1.000 0.000 0.000 0.000 0.000
#> GSM40705 3 0.4973 0.631 0.000 0.024 0.564 0.408 0.004
#> GSM40707 1 0.1331 0.800 0.952 0.000 0.000 0.040 0.008
#> GSM40708 1 0.4793 0.760 0.700 0.000 0.000 0.068 0.232
#> GSM40709 4 0.3395 0.734 0.000 0.000 0.000 0.764 0.236
#> GSM40712 5 0.4273 -0.201 0.000 0.000 0.000 0.448 0.552
#> GSM40713 1 0.4297 0.771 0.728 0.000 0.000 0.036 0.236
#> GSM40665 1 0.4793 0.760 0.700 0.000 0.000 0.068 0.232
#> GSM40677 2 0.3246 0.849 0.000 0.808 0.000 0.008 0.184
#> GSM40698 5 0.5656 0.218 0.104 0.000 0.000 0.308 0.588
#> GSM40701 3 0.6840 0.586 0.000 0.252 0.412 0.332 0.004
#> GSM40710 2 0.0404 0.873 0.000 0.988 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
#> GSM40663 3 0.0000 0.9993 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 0.9993 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 0.9993 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 0.9993 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 4 0.8442 0.1266 0.148 0.196 0.212 0.356 0.088 0.000
#> GSM40668 3 0.0146 0.9970 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM40678 2 0.0000 0.6867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40679 2 0.4674 0.6183 0.060 0.608 0.000 0.000 0.332 0.000
#> GSM40686 2 0.4808 0.5837 0.056 0.536 0.000 0.000 0.408 0.000
#> GSM40687 2 0.0000 0.6867 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40691 2 0.0603 0.6843 0.016 0.980 0.000 0.000 0.004 0.000
#> GSM40699 2 0.3034 0.6075 0.048 0.864 0.032 0.000 0.056 0.000
#> GSM40664 2 0.4863 0.5877 0.060 0.528 0.000 0.000 0.412 0.000
#> GSM40682 2 0.4831 0.5937 0.060 0.548 0.000 0.000 0.392 0.000
#> GSM40688 2 0.4808 0.5837 0.056 0.536 0.000 0.000 0.408 0.000
#> GSM40702 2 0.0909 0.6772 0.020 0.968 0.000 0.000 0.012 0.000
#> GSM40706 2 0.3845 0.6471 0.088 0.772 0.000 0.000 0.140 0.000
#> GSM40711 4 0.6768 0.1185 0.136 0.008 0.320 0.468 0.068 0.000
#> GSM40661 4 0.8549 0.0831 0.148 0.236 0.216 0.312 0.088 0.000
#> GSM40662 4 0.5022 -0.0128 0.000 0.000 0.000 0.496 0.432 0.072
#> GSM40666 4 0.0000 0.4924 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40669 4 0.5319 0.1427 0.000 0.000 0.000 0.568 0.296 0.136
#> GSM40670 4 0.4664 0.2678 0.000 0.000 0.000 0.644 0.280 0.076
#> GSM40671 1 0.4076 0.6206 0.620 0.000 0.000 0.000 0.016 0.364
#> GSM40672 6 0.4689 -0.7048 0.440 0.000 0.000 0.000 0.044 0.516
#> GSM40673 1 0.4639 0.7913 0.512 0.000 0.000 0.000 0.040 0.448
#> GSM40674 4 0.4616 0.2719 0.000 0.000 0.000 0.648 0.280 0.072
#> GSM40676 4 0.2747 0.4696 0.096 0.000 0.000 0.860 0.044 0.000
#> GSM40680 5 0.4845 0.8228 0.008 0.000 0.000 0.044 0.560 0.388
#> GSM40681 6 0.0547 0.4603 0.020 0.000 0.000 0.000 0.000 0.980
#> GSM40683 1 0.4639 0.7913 0.512 0.000 0.000 0.000 0.040 0.448
#> GSM40684 4 0.2747 0.4696 0.096 0.000 0.000 0.860 0.044 0.000
#> GSM40685 5 0.5169 0.7414 0.020 0.000 0.000 0.044 0.476 0.460
#> GSM40689 1 0.3563 0.7143 0.664 0.000 0.000 0.000 0.000 0.336
#> GSM40690 6 0.3290 0.2082 0.208 0.000 0.000 0.000 0.016 0.776
#> GSM40692 5 0.4837 0.8227 0.008 0.000 0.000 0.044 0.564 0.384
#> GSM40693 6 0.0405 0.4639 0.004 0.000 0.000 0.000 0.008 0.988
#> GSM40694 6 0.1500 0.4546 0.012 0.000 0.000 0.000 0.052 0.936
#> GSM40695 1 0.4639 0.7913 0.512 0.000 0.000 0.000 0.040 0.448
#> GSM40696 6 0.0405 0.4639 0.004 0.000 0.000 0.000 0.008 0.988
#> GSM40697 5 0.5572 0.5421 0.000 0.100 0.000 0.104 0.668 0.128
#> GSM40704 1 0.4639 0.7913 0.512 0.000 0.000 0.000 0.040 0.448
#> GSM40705 4 0.6768 0.1185 0.136 0.008 0.320 0.468 0.068 0.000
#> GSM40707 1 0.3528 0.6603 0.700 0.000 0.000 0.000 0.004 0.296
#> GSM40708 6 0.5031 0.0830 0.448 0.000 0.000 0.000 0.072 0.480
#> GSM40709 4 0.0000 0.4924 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM40712 4 0.5916 -0.0561 0.004 0.000 0.000 0.488 0.300 0.208
#> GSM40713 6 0.4634 0.0445 0.400 0.000 0.000 0.000 0.044 0.556
#> GSM40665 6 0.5033 0.0866 0.452 0.000 0.000 0.000 0.072 0.476
#> GSM40677 2 0.4808 0.5837 0.056 0.536 0.000 0.000 0.408 0.000
#> GSM40698 6 0.7673 -0.0921 0.280 0.000 0.000 0.228 0.200 0.292
#> GSM40701 2 0.8453 -0.1739 0.148 0.352 0.216 0.196 0.088 0.000
#> GSM40710 2 0.0405 0.6878 0.004 0.988 0.000 0.000 0.008 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:kmeans 45 1.73e-06 2
#> ATC:kmeans 48 2.64e-04 3
#> ATC:kmeans 53 1.08e-07 4
#> ATC:kmeans 46 4.91e-05 5
#> ATC:kmeans 29 7.90e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 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 0.922 0.956 0.980 0.5094 0.491 0.491
#> 3 3 0.999 0.958 0.982 0.3061 0.761 0.549
#> 4 4 0.810 0.864 0.930 0.0967 0.919 0.765
#> 5 5 0.847 0.811 0.892 0.0464 0.946 0.811
#> 6 6 0.810 0.773 0.879 0.0404 0.958 0.833
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
#> GSM40663 2 0.0000 0.979 0.000 1.000
#> GSM40667 2 0.0000 0.979 0.000 1.000
#> GSM40675 2 0.0000 0.979 0.000 1.000
#> GSM40703 2 0.0000 0.979 0.000 1.000
#> GSM40660 2 0.0000 0.979 0.000 1.000
#> GSM40668 2 0.0000 0.979 0.000 1.000
#> GSM40678 2 0.0000 0.979 0.000 1.000
#> GSM40679 2 0.0000 0.979 0.000 1.000
#> GSM40686 2 0.6148 0.818 0.152 0.848
#> GSM40687 2 0.0000 0.979 0.000 1.000
#> GSM40691 2 0.0000 0.979 0.000 1.000
#> GSM40699 2 0.0000 0.979 0.000 1.000
#> GSM40664 2 0.0000 0.979 0.000 1.000
#> GSM40682 2 0.0000 0.979 0.000 1.000
#> GSM40688 2 0.0376 0.976 0.004 0.996
#> GSM40702 2 0.0000 0.979 0.000 1.000
#> GSM40706 2 0.0000 0.979 0.000 1.000
#> GSM40711 2 0.0000 0.979 0.000 1.000
#> GSM40661 2 0.0000 0.979 0.000 1.000
#> GSM40662 2 0.0000 0.979 0.000 1.000
#> GSM40666 1 0.8144 0.679 0.748 0.252
#> GSM40669 1 0.0000 0.978 1.000 0.000
#> GSM40670 1 0.6247 0.821 0.844 0.156
#> GSM40671 1 0.0000 0.978 1.000 0.000
#> GSM40672 1 0.0000 0.978 1.000 0.000
#> GSM40673 1 0.0000 0.978 1.000 0.000
#> GSM40674 1 0.5737 0.845 0.864 0.136
#> GSM40676 1 0.0000 0.978 1.000 0.000
#> GSM40680 1 0.0000 0.978 1.000 0.000
#> GSM40681 1 0.0000 0.978 1.000 0.000
#> GSM40683 1 0.0000 0.978 1.000 0.000
#> GSM40684 1 0.0000 0.978 1.000 0.000
#> GSM40685 1 0.0000 0.978 1.000 0.000
#> GSM40689 1 0.0000 0.978 1.000 0.000
#> GSM40690 1 0.0000 0.978 1.000 0.000
#> GSM40692 1 0.0000 0.978 1.000 0.000
#> GSM40693 1 0.0000 0.978 1.000 0.000
#> GSM40694 1 0.0000 0.978 1.000 0.000
#> GSM40695 1 0.0000 0.978 1.000 0.000
#> GSM40696 1 0.0000 0.978 1.000 0.000
#> GSM40697 2 0.2948 0.933 0.052 0.948
#> GSM40704 1 0.0000 0.978 1.000 0.000
#> GSM40705 2 0.0000 0.979 0.000 1.000
#> GSM40707 1 0.0000 0.978 1.000 0.000
#> GSM40708 1 0.0000 0.978 1.000 0.000
#> GSM40709 2 0.8661 0.580 0.288 0.712
#> GSM40712 1 0.0000 0.978 1.000 0.000
#> GSM40713 1 0.0000 0.978 1.000 0.000
#> GSM40665 1 0.0000 0.978 1.000 0.000
#> GSM40677 2 0.0000 0.979 0.000 1.000
#> GSM40698 1 0.0000 0.978 1.000 0.000
#> GSM40701 2 0.0000 0.979 0.000 1.000
#> GSM40710 2 0.0000 0.979 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40691 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40699 2 0.0424 0.978 0.000 0.992 0.008
#> GSM40664 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40682 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40702 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40706 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40711 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40662 2 0.4555 0.745 0.000 0.800 0.200
#> GSM40666 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40669 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40670 3 0.5882 0.495 0.348 0.000 0.652
#> GSM40671 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40672 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40673 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40674 3 0.2878 0.864 0.096 0.000 0.904
#> GSM40676 3 0.5397 0.623 0.280 0.000 0.720
#> GSM40680 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40681 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40683 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40684 3 0.0424 0.938 0.008 0.000 0.992
#> GSM40685 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40689 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40690 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40692 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40693 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40694 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40695 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40696 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40697 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40704 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40707 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40708 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40709 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40712 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40713 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40665 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.985 0.000 1.000 0.000
#> GSM40698 1 0.0000 1.000 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.944 0.000 0.000 1.000
#> GSM40710 2 0.0000 0.985 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40660 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40668 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40691 2 0.3610 0.7598 0.000 0.800 0.000 0.200
#> GSM40699 4 0.4989 -0.0275 0.000 0.472 0.000 0.528
#> GSM40664 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40682 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40688 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40702 2 0.3610 0.7598 0.000 0.800 0.000 0.200
#> GSM40706 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40711 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40661 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40662 2 0.5564 0.6826 0.000 0.708 0.076 0.216
#> GSM40666 3 0.3649 0.7353 0.000 0.000 0.796 0.204
#> GSM40669 3 0.3444 0.6693 0.184 0.000 0.816 0.000
#> GSM40670 3 0.0592 0.7973 0.016 0.000 0.984 0.000
#> GSM40671 1 0.0469 0.9246 0.988 0.000 0.012 0.000
#> GSM40672 1 0.0000 0.9275 1.000 0.000 0.000 0.000
#> GSM40673 1 0.0000 0.9275 1.000 0.000 0.000 0.000
#> GSM40674 3 0.0804 0.7989 0.008 0.000 0.980 0.012
#> GSM40676 3 0.4079 0.7779 0.180 0.000 0.800 0.020
#> GSM40680 1 0.3219 0.8581 0.836 0.000 0.164 0.000
#> GSM40681 1 0.1118 0.9169 0.964 0.000 0.036 0.000
#> GSM40683 1 0.0000 0.9275 1.000 0.000 0.000 0.000
#> GSM40684 3 0.4244 0.7838 0.160 0.000 0.804 0.036
#> GSM40685 1 0.3219 0.8581 0.836 0.000 0.164 0.000
#> GSM40689 1 0.0469 0.9246 0.988 0.000 0.012 0.000
#> GSM40690 1 0.0000 0.9275 1.000 0.000 0.000 0.000
#> GSM40692 1 0.3172 0.8611 0.840 0.000 0.160 0.000
#> GSM40693 1 0.3172 0.8611 0.840 0.000 0.160 0.000
#> GSM40694 1 0.3172 0.8611 0.840 0.000 0.160 0.000
#> GSM40695 1 0.0000 0.9275 1.000 0.000 0.000 0.000
#> GSM40696 1 0.3172 0.8611 0.840 0.000 0.160 0.000
#> GSM40697 2 0.3172 0.7707 0.000 0.840 0.160 0.000
#> GSM40704 1 0.0000 0.9275 1.000 0.000 0.000 0.000
#> GSM40705 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40707 1 0.0469 0.9246 0.988 0.000 0.012 0.000
#> GSM40708 1 0.0469 0.9246 0.988 0.000 0.012 0.000
#> GSM40709 3 0.3726 0.7287 0.000 0.000 0.788 0.212
#> GSM40712 1 0.3649 0.8211 0.796 0.000 0.204 0.000
#> GSM40713 1 0.0188 0.9267 0.996 0.000 0.004 0.000
#> GSM40665 1 0.0469 0.9246 0.988 0.000 0.012 0.000
#> GSM40677 2 0.0000 0.9272 0.000 1.000 0.000 0.000
#> GSM40698 1 0.0469 0.9246 0.988 0.000 0.012 0.000
#> GSM40701 4 0.0000 0.9365 0.000 0.000 0.000 1.000
#> GSM40710 2 0.0000 0.9272 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40668 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0963 0.8541 0.000 0.964 0.000 0.000 0.036
#> GSM40679 2 0.0404 0.8548 0.000 0.988 0.000 0.000 0.012
#> GSM40686 2 0.1341 0.8452 0.000 0.944 0.000 0.000 0.056
#> GSM40687 2 0.0963 0.8541 0.000 0.964 0.000 0.000 0.036
#> GSM40691 2 0.3875 0.7255 0.000 0.792 0.160 0.000 0.048
#> GSM40699 2 0.5096 0.2547 0.000 0.520 0.444 0.000 0.036
#> GSM40664 2 0.1043 0.8504 0.000 0.960 0.000 0.000 0.040
#> GSM40682 2 0.0000 0.8556 0.000 1.000 0.000 0.000 0.000
#> GSM40688 2 0.1410 0.8433 0.000 0.940 0.000 0.000 0.060
#> GSM40702 2 0.3734 0.7236 0.000 0.796 0.168 0.000 0.036
#> GSM40706 2 0.0963 0.8541 0.000 0.964 0.000 0.000 0.036
#> GSM40711 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40661 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40662 5 0.7071 -0.0228 0.000 0.328 0.188 0.028 0.456
#> GSM40666 4 0.3119 0.8160 0.000 0.000 0.072 0.860 0.068
#> GSM40669 5 0.4264 0.5223 0.044 0.000 0.000 0.212 0.744
#> GSM40670 5 0.3980 0.4907 0.008 0.000 0.000 0.284 0.708
#> GSM40671 1 0.0703 0.8992 0.976 0.000 0.000 0.024 0.000
#> GSM40672 1 0.0324 0.9031 0.992 0.000 0.000 0.004 0.004
#> GSM40673 1 0.0000 0.9042 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.4183 0.4375 0.008 0.000 0.000 0.324 0.668
#> GSM40676 4 0.1270 0.8413 0.052 0.000 0.000 0.948 0.000
#> GSM40680 1 0.4452 0.7078 0.696 0.000 0.000 0.032 0.272
#> GSM40681 1 0.2193 0.8765 0.912 0.000 0.000 0.028 0.060
#> GSM40683 1 0.0000 0.9042 1.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.1270 0.8413 0.052 0.000 0.000 0.948 0.000
#> GSM40685 1 0.3724 0.8030 0.788 0.000 0.000 0.028 0.184
#> GSM40689 1 0.1341 0.8885 0.944 0.000 0.000 0.056 0.000
#> GSM40690 1 0.0000 0.9042 1.000 0.000 0.000 0.000 0.000
#> GSM40692 1 0.4326 0.7222 0.708 0.000 0.000 0.028 0.264
#> GSM40693 1 0.3146 0.8403 0.844 0.000 0.000 0.028 0.128
#> GSM40694 1 0.3193 0.8377 0.840 0.000 0.000 0.028 0.132
#> GSM40695 1 0.0000 0.9042 1.000 0.000 0.000 0.000 0.000
#> GSM40696 1 0.3193 0.8384 0.840 0.000 0.000 0.028 0.132
#> GSM40697 2 0.4835 0.3972 0.000 0.592 0.000 0.028 0.380
#> GSM40704 1 0.0000 0.9042 1.000 0.000 0.000 0.000 0.000
#> GSM40705 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40707 1 0.1671 0.8795 0.924 0.000 0.000 0.076 0.000
#> GSM40708 1 0.1732 0.8771 0.920 0.000 0.000 0.080 0.000
#> GSM40709 4 0.3130 0.8139 0.000 0.000 0.096 0.856 0.048
#> GSM40712 5 0.4167 0.3867 0.252 0.000 0.000 0.024 0.724
#> GSM40713 1 0.0162 0.9037 0.996 0.000 0.000 0.004 0.000
#> GSM40665 1 0.1671 0.8795 0.924 0.000 0.000 0.076 0.000
#> GSM40677 2 0.1341 0.8452 0.000 0.944 0.000 0.000 0.056
#> GSM40698 1 0.1671 0.8795 0.924 0.000 0.000 0.076 0.000
#> GSM40701 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000
#> GSM40710 2 0.0963 0.8541 0.000 0.964 0.000 0.000 0.036
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40660 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40668 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.0692 0.8093 0.000 0.976 0.000 0.000 0.020 0.004
#> GSM40679 2 0.2213 0.8087 0.000 0.888 0.000 0.004 0.100 0.008
#> GSM40686 2 0.3533 0.7629 0.000 0.776 0.000 0.008 0.196 0.020
#> GSM40687 2 0.0692 0.8093 0.000 0.976 0.000 0.000 0.020 0.004
#> GSM40691 2 0.4374 0.6593 0.000 0.756 0.112 0.008 0.116 0.008
#> GSM40699 2 0.4176 0.3344 0.000 0.580 0.404 0.000 0.016 0.000
#> GSM40664 2 0.3183 0.7845 0.000 0.812 0.000 0.008 0.164 0.016
#> GSM40682 2 0.1787 0.8128 0.000 0.920 0.000 0.004 0.068 0.008
#> GSM40688 2 0.4029 0.7098 0.000 0.712 0.000 0.012 0.256 0.020
#> GSM40702 2 0.2680 0.7294 0.000 0.856 0.124 0.000 0.016 0.004
#> GSM40706 2 0.1268 0.8092 0.000 0.952 0.008 0.000 0.036 0.004
#> GSM40711 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40661 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40662 5 0.7319 0.0913 0.000 0.208 0.124 0.020 0.484 0.164
#> GSM40666 4 0.3447 0.8369 0.000 0.000 0.064 0.820 0.008 0.108
#> GSM40669 6 0.2123 0.8773 0.012 0.000 0.000 0.052 0.024 0.912
#> GSM40670 6 0.1411 0.8780 0.000 0.000 0.000 0.060 0.004 0.936
#> GSM40671 1 0.0508 0.8527 0.984 0.000 0.000 0.012 0.000 0.004
#> GSM40672 1 0.1003 0.8432 0.964 0.000 0.000 0.004 0.028 0.004
#> GSM40673 1 0.0000 0.8553 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40674 6 0.1444 0.8708 0.000 0.000 0.000 0.072 0.000 0.928
#> GSM40676 4 0.0858 0.8711 0.028 0.000 0.000 0.968 0.000 0.004
#> GSM40680 5 0.4283 0.2947 0.344 0.004 0.000 0.004 0.632 0.016
#> GSM40681 1 0.2994 0.7325 0.820 0.000 0.000 0.008 0.164 0.008
#> GSM40683 1 0.0000 0.8553 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.0858 0.8711 0.028 0.000 0.000 0.968 0.000 0.004
#> GSM40685 1 0.4630 0.2988 0.580 0.000 0.000 0.000 0.372 0.048
#> GSM40689 1 0.0858 0.8471 0.968 0.000 0.000 0.028 0.000 0.004
#> GSM40690 1 0.0458 0.8523 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM40692 5 0.4303 0.1802 0.392 0.000 0.000 0.008 0.588 0.012
#> GSM40693 1 0.3780 0.6219 0.728 0.000 0.000 0.004 0.248 0.020
#> GSM40694 1 0.3858 0.6160 0.724 0.000 0.000 0.004 0.248 0.024
#> GSM40695 1 0.0000 0.8553 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40696 1 0.3803 0.6158 0.724 0.000 0.000 0.004 0.252 0.020
#> GSM40697 5 0.4542 0.2247 0.000 0.176 0.000 0.008 0.716 0.100
#> GSM40704 1 0.0146 0.8549 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM40705 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40707 1 0.1806 0.8154 0.908 0.000 0.000 0.088 0.000 0.004
#> GSM40708 1 0.1908 0.8103 0.900 0.000 0.000 0.096 0.000 0.004
#> GSM40709 4 0.3290 0.8533 0.000 0.000 0.060 0.840 0.016 0.084
#> GSM40712 6 0.3554 0.7142 0.108 0.000 0.000 0.004 0.080 0.808
#> GSM40713 1 0.0291 0.8545 0.992 0.000 0.000 0.004 0.000 0.004
#> GSM40665 1 0.1753 0.8191 0.912 0.000 0.000 0.084 0.000 0.004
#> GSM40677 2 0.3661 0.7590 0.000 0.768 0.000 0.012 0.200 0.020
#> GSM40698 1 0.1949 0.8159 0.904 0.000 0.000 0.088 0.004 0.004
#> GSM40701 3 0.0000 1.0000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40710 2 0.0405 0.8116 0.000 0.988 0.000 0.000 0.008 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:skmeans 53 5.12e-06 2
#> ATC:skmeans 52 1.26e-05 3
#> ATC:skmeans 52 3.98e-06 4
#> ATC:skmeans 47 4.70e-05 5
#> ATC:skmeans 47 3.99e-05 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 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 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.992 0.996 0.5087 0.492 0.492
#> 3 3 0.898 0.943 0.975 0.1569 0.927 0.853
#> 4 4 0.775 0.767 0.899 0.1845 0.834 0.626
#> 5 5 0.744 0.797 0.845 0.1093 0.817 0.484
#> 6 6 0.798 0.766 0.875 0.0639 0.893 0.584
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
#> GSM40663 2 0.0000 0.999 0.000 1.000
#> GSM40667 2 0.0000 0.999 0.000 1.000
#> GSM40675 2 0.0000 0.999 0.000 1.000
#> GSM40703 2 0.0000 0.999 0.000 1.000
#> GSM40660 2 0.0000 0.999 0.000 1.000
#> GSM40668 2 0.0000 0.999 0.000 1.000
#> GSM40678 2 0.0000 0.999 0.000 1.000
#> GSM40679 2 0.0000 0.999 0.000 1.000
#> GSM40686 2 0.0672 0.992 0.008 0.992
#> GSM40687 2 0.0000 0.999 0.000 1.000
#> GSM40691 2 0.0000 0.999 0.000 1.000
#> GSM40699 2 0.0000 0.999 0.000 1.000
#> GSM40664 2 0.0000 0.999 0.000 1.000
#> GSM40682 2 0.0000 0.999 0.000 1.000
#> GSM40688 2 0.0376 0.996 0.004 0.996
#> GSM40702 2 0.0000 0.999 0.000 1.000
#> GSM40706 2 0.0000 0.999 0.000 1.000
#> GSM40711 2 0.0000 0.999 0.000 1.000
#> GSM40661 2 0.0000 0.999 0.000 1.000
#> GSM40662 2 0.0000 0.999 0.000 1.000
#> GSM40666 1 0.2423 0.958 0.960 0.040
#> GSM40669 1 0.0000 0.993 1.000 0.000
#> GSM40670 1 0.0672 0.987 0.992 0.008
#> GSM40671 1 0.0000 0.993 1.000 0.000
#> GSM40672 1 0.0000 0.993 1.000 0.000
#> GSM40673 1 0.0000 0.993 1.000 0.000
#> GSM40674 1 0.0672 0.987 0.992 0.008
#> GSM40676 1 0.0000 0.993 1.000 0.000
#> GSM40680 1 0.0000 0.993 1.000 0.000
#> GSM40681 1 0.0000 0.993 1.000 0.000
#> GSM40683 1 0.0000 0.993 1.000 0.000
#> GSM40684 1 0.0000 0.993 1.000 0.000
#> GSM40685 1 0.0000 0.993 1.000 0.000
#> GSM40689 1 0.0000 0.993 1.000 0.000
#> GSM40690 1 0.0000 0.993 1.000 0.000
#> GSM40692 1 0.0000 0.993 1.000 0.000
#> GSM40693 1 0.0000 0.993 1.000 0.000
#> GSM40694 1 0.0000 0.993 1.000 0.000
#> GSM40695 1 0.0000 0.993 1.000 0.000
#> GSM40696 1 0.0000 0.993 1.000 0.000
#> GSM40697 2 0.0672 0.992 0.008 0.992
#> GSM40704 1 0.0000 0.993 1.000 0.000
#> GSM40705 2 0.0000 0.999 0.000 1.000
#> GSM40707 1 0.0000 0.993 1.000 0.000
#> GSM40708 1 0.0000 0.993 1.000 0.000
#> GSM40709 1 0.5408 0.863 0.876 0.124
#> GSM40712 1 0.0000 0.993 1.000 0.000
#> GSM40713 1 0.0000 0.993 1.000 0.000
#> GSM40665 1 0.0000 0.993 1.000 0.000
#> GSM40677 2 0.0000 0.999 0.000 1.000
#> GSM40698 1 0.0000 0.993 1.000 0.000
#> GSM40701 2 0.0000 0.999 0.000 1.000
#> GSM40710 2 0.0000 0.999 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.000 1.000 0.000 0.000 1.000
#> GSM40667 3 0.000 1.000 0.000 0.000 1.000
#> GSM40675 3 0.000 1.000 0.000 0.000 1.000
#> GSM40703 3 0.000 1.000 0.000 0.000 1.000
#> GSM40660 2 0.000 0.981 0.000 1.000 0.000
#> GSM40668 3 0.000 1.000 0.000 0.000 1.000
#> GSM40678 2 0.000 0.981 0.000 1.000 0.000
#> GSM40679 2 0.000 0.981 0.000 1.000 0.000
#> GSM40686 2 0.000 0.981 0.000 1.000 0.000
#> GSM40687 2 0.000 0.981 0.000 1.000 0.000
#> GSM40691 2 0.000 0.981 0.000 1.000 0.000
#> GSM40699 2 0.000 0.981 0.000 1.000 0.000
#> GSM40664 2 0.000 0.981 0.000 1.000 0.000
#> GSM40682 2 0.000 0.981 0.000 1.000 0.000
#> GSM40688 2 0.000 0.981 0.000 1.000 0.000
#> GSM40702 2 0.000 0.981 0.000 1.000 0.000
#> GSM40706 2 0.000 0.981 0.000 1.000 0.000
#> GSM40711 2 0.263 0.899 0.000 0.916 0.084
#> GSM40661 2 0.000 0.981 0.000 1.000 0.000
#> GSM40662 2 0.000 0.981 0.000 1.000 0.000
#> GSM40666 1 0.304 0.869 0.896 0.104 0.000
#> GSM40669 1 0.000 0.956 1.000 0.000 0.000
#> GSM40670 1 0.263 0.887 0.916 0.084 0.000
#> GSM40671 1 0.000 0.956 1.000 0.000 0.000
#> GSM40672 1 0.000 0.956 1.000 0.000 0.000
#> GSM40673 1 0.000 0.956 1.000 0.000 0.000
#> GSM40674 1 0.341 0.850 0.876 0.124 0.000
#> GSM40676 1 0.000 0.956 1.000 0.000 0.000
#> GSM40680 1 0.480 0.721 0.780 0.220 0.000
#> GSM40681 1 0.000 0.956 1.000 0.000 0.000
#> GSM40683 1 0.000 0.956 1.000 0.000 0.000
#> GSM40684 1 0.000 0.956 1.000 0.000 0.000
#> GSM40685 1 0.000 0.956 1.000 0.000 0.000
#> GSM40689 1 0.000 0.956 1.000 0.000 0.000
#> GSM40690 1 0.000 0.956 1.000 0.000 0.000
#> GSM40692 1 0.514 0.678 0.748 0.252 0.000
#> GSM40693 1 0.000 0.956 1.000 0.000 0.000
#> GSM40694 1 0.000 0.956 1.000 0.000 0.000
#> GSM40695 1 0.000 0.956 1.000 0.000 0.000
#> GSM40696 1 0.000 0.956 1.000 0.000 0.000
#> GSM40697 2 0.000 0.981 0.000 1.000 0.000
#> GSM40704 1 0.000 0.956 1.000 0.000 0.000
#> GSM40705 2 0.518 0.657 0.000 0.744 0.256
#> GSM40707 1 0.000 0.956 1.000 0.000 0.000
#> GSM40708 1 0.000 0.956 1.000 0.000 0.000
#> GSM40709 1 0.475 0.737 0.784 0.216 0.000
#> GSM40712 1 0.000 0.956 1.000 0.000 0.000
#> GSM40713 1 0.000 0.956 1.000 0.000 0.000
#> GSM40665 1 0.000 0.956 1.000 0.000 0.000
#> GSM40677 2 0.000 0.981 0.000 1.000 0.000
#> GSM40698 1 0.000 0.956 1.000 0.000 0.000
#> GSM40701 2 0.000 0.981 0.000 1.000 0.000
#> GSM40710 2 0.000 0.981 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 1.0000 0.000 0.000 0.000 1
#> GSM40667 4 0.0000 1.0000 0.000 0.000 0.000 1
#> GSM40675 4 0.0000 1.0000 0.000 0.000 0.000 1
#> GSM40703 4 0.0000 1.0000 0.000 0.000 0.000 1
#> GSM40660 3 0.4072 0.6721 0.000 0.252 0.748 0
#> GSM40668 4 0.0000 1.0000 0.000 0.000 0.000 1
#> GSM40678 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40679 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40686 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40687 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40691 2 0.2469 0.7689 0.000 0.892 0.108 0
#> GSM40699 2 0.4790 0.2228 0.000 0.620 0.380 0
#> GSM40664 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40682 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40688 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40702 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40706 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40711 3 0.3873 0.6846 0.000 0.228 0.772 0
#> GSM40661 3 0.4103 0.6686 0.000 0.256 0.744 0
#> GSM40662 2 0.3975 0.6344 0.000 0.760 0.240 0
#> GSM40666 3 0.0000 0.5808 0.000 0.000 1.000 0
#> GSM40669 1 0.4103 0.6778 0.744 0.000 0.256 0
#> GSM40670 1 0.6851 0.1880 0.496 0.104 0.400 0
#> GSM40671 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40672 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40673 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40674 3 0.7788 -0.0168 0.376 0.244 0.380 0
#> GSM40676 1 0.3172 0.7932 0.840 0.000 0.160 0
#> GSM40680 1 0.6247 0.1266 0.516 0.428 0.056 0
#> GSM40681 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40683 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40684 3 0.4843 0.0712 0.396 0.000 0.604 0
#> GSM40685 1 0.2053 0.8610 0.924 0.004 0.072 0
#> GSM40689 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40690 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40692 2 0.5697 0.4232 0.292 0.656 0.052 0
#> GSM40693 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40694 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40695 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40696 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40697 2 0.4040 0.6239 0.000 0.752 0.248 0
#> GSM40704 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40705 3 0.3873 0.6846 0.000 0.228 0.772 0
#> GSM40707 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40708 1 0.0188 0.9067 0.996 0.000 0.004 0
#> GSM40709 3 0.0000 0.5808 0.000 0.000 1.000 0
#> GSM40712 1 0.4103 0.6778 0.744 0.000 0.256 0
#> GSM40713 1 0.0188 0.9067 0.996 0.000 0.004 0
#> GSM40665 1 0.0000 0.9085 1.000 0.000 0.000 0
#> GSM40677 2 0.0000 0.8794 0.000 1.000 0.000 0
#> GSM40698 1 0.2256 0.8629 0.924 0.020 0.056 0
#> GSM40701 3 0.4103 0.6686 0.000 0.256 0.744 0
#> GSM40710 2 0.0000 0.8794 0.000 1.000 0.000 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM40660 4 0.2377 0.888 0.000 0.128 0 0.872 0.000
#> GSM40668 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM40678 2 0.1997 0.840 0.000 0.924 0 0.040 0.036
#> GSM40679 2 0.1043 0.851 0.000 0.960 0 0.040 0.000
#> GSM40686 2 0.0000 0.849 0.000 1.000 0 0.000 0.000
#> GSM40687 2 0.1997 0.840 0.000 0.924 0 0.040 0.036
#> GSM40691 2 0.3847 0.662 0.000 0.784 0 0.180 0.036
#> GSM40699 4 0.4946 0.477 0.000 0.368 0 0.596 0.036
#> GSM40664 2 0.0000 0.849 0.000 1.000 0 0.000 0.000
#> GSM40682 2 0.1043 0.851 0.000 0.960 0 0.040 0.000
#> GSM40688 2 0.0000 0.849 0.000 1.000 0 0.000 0.000
#> GSM40702 2 0.1043 0.851 0.000 0.960 0 0.040 0.000
#> GSM40706 2 0.1043 0.851 0.000 0.960 0 0.040 0.000
#> GSM40711 4 0.2597 0.855 0.000 0.092 0 0.884 0.024
#> GSM40661 4 0.2377 0.888 0.000 0.128 0 0.872 0.000
#> GSM40662 5 0.3326 0.687 0.000 0.152 0 0.024 0.824
#> GSM40666 5 0.3949 0.540 0.000 0.000 0 0.332 0.668
#> GSM40669 5 0.2230 0.746 0.116 0.000 0 0.000 0.884
#> GSM40670 5 0.2838 0.747 0.036 0.072 0 0.008 0.884
#> GSM40671 1 0.0963 0.895 0.964 0.000 0 0.000 0.036
#> GSM40672 1 0.3590 0.851 0.828 0.000 0 0.092 0.080
#> GSM40673 1 0.3590 0.851 0.828 0.000 0 0.092 0.080
#> GSM40674 5 0.2775 0.747 0.036 0.076 0 0.004 0.884
#> GSM40676 5 0.6338 0.368 0.392 0.000 0 0.160 0.448
#> GSM40680 2 0.4394 0.596 0.220 0.732 0 0.000 0.048
#> GSM40681 1 0.1997 0.873 0.924 0.040 0 0.000 0.036
#> GSM40683 1 0.3590 0.851 0.828 0.000 0 0.092 0.080
#> GSM40684 5 0.6260 0.501 0.172 0.000 0 0.312 0.516
#> GSM40685 5 0.5027 0.589 0.304 0.056 0 0.000 0.640
#> GSM40689 1 0.0510 0.903 0.984 0.000 0 0.016 0.000
#> GSM40690 1 0.0510 0.903 0.984 0.000 0 0.016 0.000
#> GSM40692 2 0.3772 0.664 0.172 0.792 0 0.000 0.036
#> GSM40693 1 0.0510 0.903 0.984 0.000 0 0.016 0.000
#> GSM40694 1 0.0963 0.895 0.964 0.000 0 0.000 0.036
#> GSM40695 1 0.3590 0.851 0.828 0.000 0 0.092 0.080
#> GSM40696 1 0.1386 0.894 0.952 0.032 0 0.016 0.000
#> GSM40697 5 0.3424 0.649 0.000 0.240 0 0.000 0.760
#> GSM40704 1 0.3590 0.851 0.828 0.000 0 0.092 0.080
#> GSM40705 4 0.2685 0.851 0.000 0.092 0 0.880 0.028
#> GSM40707 1 0.2782 0.888 0.880 0.000 0 0.048 0.072
#> GSM40708 1 0.2472 0.862 0.908 0.012 0 0.036 0.044
#> GSM40709 5 0.3003 0.671 0.000 0.000 0 0.188 0.812
#> GSM40712 5 0.2915 0.745 0.116 0.024 0 0.000 0.860
#> GSM40713 1 0.1469 0.889 0.948 0.016 0 0.000 0.036
#> GSM40665 1 0.0963 0.895 0.964 0.000 0 0.000 0.036
#> GSM40677 2 0.0000 0.849 0.000 1.000 0 0.000 0.000
#> GSM40698 2 0.5907 0.111 0.440 0.488 0 0.036 0.036
#> GSM40701 4 0.2377 0.888 0.000 0.128 0 0.872 0.000
#> GSM40710 2 0.1997 0.840 0.000 0.924 0 0.040 0.036
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM40667 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM40675 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM40703 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM40660 4 0.0790 0.931 0.000 0.032 0 0.968 0.000 0.000
#> GSM40668 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM40678 2 0.3158 0.819 0.164 0.812 0 0.020 0.004 0.000
#> GSM40679 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40686 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40687 2 0.3158 0.819 0.164 0.812 0 0.020 0.004 0.000
#> GSM40691 2 0.5113 0.610 0.164 0.644 0 0.188 0.004 0.000
#> GSM40699 4 0.3891 0.757 0.164 0.064 0 0.768 0.004 0.000
#> GSM40664 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40682 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40688 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40702 2 0.0363 0.898 0.000 0.988 0 0.012 0.000 0.000
#> GSM40706 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40711 4 0.0603 0.909 0.016 0.000 0 0.980 0.004 0.000
#> GSM40661 4 0.0790 0.931 0.000 0.032 0 0.968 0.000 0.000
#> GSM40662 5 0.1387 0.834 0.000 0.068 0 0.000 0.932 0.000
#> GSM40666 5 0.3320 0.705 0.016 0.000 0 0.212 0.772 0.000
#> GSM40669 5 0.0363 0.860 0.000 0.000 0 0.000 0.988 0.012
#> GSM40670 5 0.0260 0.860 0.000 0.000 0 0.000 0.992 0.008
#> GSM40671 6 0.0260 0.701 0.008 0.000 0 0.000 0.000 0.992
#> GSM40672 1 0.2697 1.000 0.812 0.000 0 0.000 0.000 0.188
#> GSM40673 1 0.2697 1.000 0.812 0.000 0 0.000 0.000 0.188
#> GSM40674 5 0.0146 0.860 0.000 0.000 0 0.000 0.996 0.004
#> GSM40676 6 0.4667 0.530 0.024 0.000 0 0.108 0.140 0.728
#> GSM40680 6 0.3789 0.249 0.000 0.416 0 0.000 0.000 0.584
#> GSM40681 6 0.0000 0.704 0.000 0.000 0 0.000 0.000 1.000
#> GSM40683 1 0.2697 1.000 0.812 0.000 0 0.000 0.000 0.188
#> GSM40684 5 0.5691 0.528 0.024 0.000 0 0.232 0.596 0.148
#> GSM40685 6 0.3175 0.521 0.000 0.000 0 0.000 0.256 0.744
#> GSM40689 6 0.3765 0.171 0.404 0.000 0 0.000 0.000 0.596
#> GSM40690 6 0.3774 0.159 0.408 0.000 0 0.000 0.000 0.592
#> GSM40692 2 0.3217 0.633 0.000 0.768 0 0.000 0.008 0.224
#> GSM40693 6 0.3756 0.178 0.400 0.000 0 0.000 0.000 0.600
#> GSM40694 6 0.0000 0.704 0.000 0.000 0 0.000 0.000 1.000
#> GSM40695 1 0.2697 1.000 0.812 0.000 0 0.000 0.000 0.188
#> GSM40696 6 0.3706 0.228 0.380 0.000 0 0.000 0.000 0.620
#> GSM40697 5 0.2854 0.696 0.000 0.208 0 0.000 0.792 0.000
#> GSM40704 1 0.2697 1.000 0.812 0.000 0 0.000 0.000 0.188
#> GSM40705 4 0.0603 0.909 0.016 0.000 0 0.980 0.004 0.000
#> GSM40707 6 0.3288 0.357 0.276 0.000 0 0.000 0.000 0.724
#> GSM40708 6 0.0632 0.698 0.024 0.000 0 0.000 0.000 0.976
#> GSM40709 5 0.1408 0.846 0.020 0.000 0 0.036 0.944 0.000
#> GSM40712 5 0.1387 0.831 0.000 0.000 0 0.000 0.932 0.068
#> GSM40713 6 0.0000 0.704 0.000 0.000 0 0.000 0.000 1.000
#> GSM40665 6 0.0000 0.704 0.000 0.000 0 0.000 0.000 1.000
#> GSM40677 2 0.0000 0.903 0.000 1.000 0 0.000 0.000 0.000
#> GSM40698 6 0.1492 0.684 0.024 0.036 0 0.000 0.000 0.940
#> GSM40701 4 0.0790 0.931 0.000 0.032 0 0.968 0.000 0.000
#> GSM40710 2 0.2632 0.830 0.164 0.832 0 0.000 0.004 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:pam 53 1.45e-06 2
#> ATC:pam 53 7.07e-12 3
#> ATC:pam 47 3.07e-08 4
#> ATC:pam 50 3.11e-08 5
#> ATC:pam 47 7.83e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.330 0.584 0.731 0.3374 0.826 0.826
#> 3 3 0.311 0.845 0.859 0.4492 0.705 0.642
#> 4 4 0.553 0.736 0.842 0.3879 0.737 0.512
#> 5 5 0.850 0.723 0.887 0.1750 0.847 0.512
#> 6 6 0.875 0.850 0.929 0.0311 0.948 0.751
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM40663 2 0.6438 1.000 0.164 0.836
#> GSM40667 2 0.6438 1.000 0.164 0.836
#> GSM40675 2 0.6438 1.000 0.164 0.836
#> GSM40703 2 0.6438 1.000 0.164 0.836
#> GSM40660 1 0.9954 0.206 0.540 0.460
#> GSM40668 2 0.6438 1.000 0.164 0.836
#> GSM40678 1 0.5519 0.676 0.872 0.128
#> GSM40679 1 0.5519 0.676 0.872 0.128
#> GSM40686 1 0.5519 0.676 0.872 0.128
#> GSM40687 1 0.5519 0.676 0.872 0.128
#> GSM40691 1 0.9922 0.226 0.552 0.448
#> GSM40699 1 0.9963 0.212 0.536 0.464
#> GSM40664 1 0.2948 0.717 0.948 0.052
#> GSM40682 1 0.2778 0.718 0.952 0.048
#> GSM40688 1 0.2948 0.717 0.948 0.052
#> GSM40702 1 0.4298 0.710 0.912 0.088
#> GSM40706 1 0.5519 0.676 0.872 0.128
#> GSM40711 1 0.9944 0.212 0.544 0.456
#> GSM40661 1 0.9954 0.206 0.540 0.460
#> GSM40662 1 0.9909 0.230 0.556 0.444
#> GSM40666 1 0.9922 0.222 0.552 0.448
#> GSM40669 1 0.9922 0.222 0.552 0.448
#> GSM40670 1 0.9922 0.222 0.552 0.448
#> GSM40671 1 0.3274 0.708 0.940 0.060
#> GSM40672 1 0.2236 0.718 0.964 0.036
#> GSM40673 1 0.3274 0.708 0.940 0.060
#> GSM40674 1 0.9922 0.222 0.552 0.448
#> GSM40676 1 0.1633 0.721 0.976 0.024
#> GSM40680 1 0.0938 0.724 0.988 0.012
#> GSM40681 1 0.3274 0.708 0.940 0.060
#> GSM40683 1 0.3274 0.708 0.940 0.060
#> GSM40684 1 0.9922 0.222 0.552 0.448
#> GSM40685 1 0.0672 0.725 0.992 0.008
#> GSM40689 1 0.3274 0.708 0.940 0.060
#> GSM40690 1 0.3274 0.708 0.940 0.060
#> GSM40692 1 0.0938 0.724 0.988 0.012
#> GSM40693 1 0.0672 0.725 0.992 0.008
#> GSM40694 1 0.7674 0.548 0.776 0.224
#> GSM40695 1 0.3274 0.708 0.940 0.060
#> GSM40696 1 0.0000 0.725 1.000 0.000
#> GSM40697 1 0.9909 0.230 0.556 0.444
#> GSM40704 1 0.3274 0.708 0.940 0.060
#> GSM40705 1 0.9944 0.212 0.544 0.456
#> GSM40707 1 0.0000 0.725 1.000 0.000
#> GSM40708 1 0.0000 0.725 1.000 0.000
#> GSM40709 1 0.9922 0.222 0.552 0.448
#> GSM40712 1 0.9922 0.222 0.552 0.448
#> GSM40713 1 0.4022 0.707 0.920 0.080
#> GSM40665 1 0.0000 0.725 1.000 0.000
#> GSM40677 1 0.5519 0.676 0.872 0.128
#> GSM40698 1 0.0000 0.725 1.000 0.000
#> GSM40701 1 0.9954 0.206 0.540 0.460
#> GSM40710 1 0.5519 0.676 0.872 0.128
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.3116 0.9884 0.108 0.000 0.892
#> GSM40667 3 0.3116 0.9884 0.108 0.000 0.892
#> GSM40675 3 0.3116 0.9884 0.108 0.000 0.892
#> GSM40703 3 0.3116 0.9884 0.108 0.000 0.892
#> GSM40660 1 0.1751 0.8384 0.960 0.028 0.012
#> GSM40668 3 0.3619 0.9522 0.136 0.000 0.864
#> GSM40678 2 0.3752 0.9318 0.144 0.856 0.000
#> GSM40679 2 0.3752 0.9318 0.144 0.856 0.000
#> GSM40686 2 0.3752 0.9318 0.144 0.856 0.000
#> GSM40687 2 0.3752 0.9318 0.144 0.856 0.000
#> GSM40691 1 0.1289 0.8388 0.968 0.032 0.000
#> GSM40699 2 0.7437 0.8302 0.200 0.692 0.108
#> GSM40664 1 0.6302 -0.0584 0.520 0.480 0.000
#> GSM40682 2 0.4235 0.9147 0.176 0.824 0.000
#> GSM40688 2 0.4504 0.8977 0.196 0.804 0.000
#> GSM40702 2 0.7044 0.8293 0.168 0.724 0.108
#> GSM40706 2 0.5363 0.7808 0.276 0.724 0.000
#> GSM40711 1 0.1411 0.8363 0.964 0.000 0.036
#> GSM40661 1 0.4446 0.8193 0.856 0.032 0.112
#> GSM40662 1 0.1163 0.8412 0.972 0.028 0.000
#> GSM40666 1 0.1163 0.8401 0.972 0.000 0.028
#> GSM40669 1 0.0424 0.8480 0.992 0.000 0.008
#> GSM40670 1 0.0424 0.8480 0.992 0.000 0.008
#> GSM40671 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40672 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40673 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40674 1 0.0424 0.8480 0.992 0.000 0.008
#> GSM40676 1 0.3715 0.8300 0.868 0.004 0.128
#> GSM40680 1 0.3116 0.8493 0.892 0.108 0.000
#> GSM40681 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40683 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40684 1 0.3715 0.8300 0.868 0.004 0.128
#> GSM40685 1 0.3116 0.8493 0.892 0.108 0.000
#> GSM40689 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40690 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40692 1 0.3116 0.8493 0.892 0.108 0.000
#> GSM40693 1 0.3752 0.8531 0.856 0.144 0.000
#> GSM40694 1 0.2537 0.8631 0.920 0.080 0.000
#> GSM40695 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40696 1 0.3686 0.8530 0.860 0.140 0.000
#> GSM40697 1 0.0892 0.8452 0.980 0.020 0.000
#> GSM40704 1 0.5138 0.8177 0.748 0.252 0.000
#> GSM40705 1 0.1411 0.8363 0.964 0.000 0.036
#> GSM40707 1 0.4862 0.8542 0.820 0.160 0.020
#> GSM40708 1 0.3879 0.8526 0.848 0.152 0.000
#> GSM40709 1 0.1399 0.8393 0.968 0.004 0.028
#> GSM40712 1 0.0237 0.8493 0.996 0.000 0.004
#> GSM40713 1 0.4702 0.8181 0.788 0.212 0.000
#> GSM40665 1 0.3941 0.8523 0.844 0.156 0.000
#> GSM40677 2 0.3752 0.9318 0.144 0.856 0.000
#> GSM40698 1 0.3192 0.8480 0.888 0.112 0.000
#> GSM40701 1 0.4489 0.8181 0.856 0.036 0.108
#> GSM40710 2 0.3752 0.9318 0.144 0.856 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40667 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40675 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40703 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40660 3 0.6894 0.677 0.320 0.000 0.552 0.128
#> GSM40668 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.837 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.837 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.837 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.837 0.000 1.000 0.000 0.000
#> GSM40691 1 0.1211 0.801 0.960 0.040 0.000 0.000
#> GSM40699 2 0.5905 0.429 0.304 0.636 0.060 0.000
#> GSM40664 2 0.4814 0.492 0.008 0.676 0.316 0.000
#> GSM40682 2 0.0779 0.832 0.004 0.980 0.016 0.000
#> GSM40688 2 0.4964 0.568 0.256 0.716 0.028 0.000
#> GSM40702 2 0.0592 0.831 0.016 0.984 0.000 0.000
#> GSM40706 2 0.3726 0.670 0.000 0.788 0.212 0.000
#> GSM40711 3 0.6878 0.682 0.316 0.000 0.556 0.128
#> GSM40661 3 0.6878 0.682 0.316 0.000 0.556 0.128
#> GSM40662 1 0.2530 0.763 0.888 0.000 0.112 0.000
#> GSM40666 3 0.6835 0.685 0.316 0.000 0.560 0.124
#> GSM40669 1 0.0921 0.826 0.972 0.000 0.028 0.000
#> GSM40670 1 0.1022 0.825 0.968 0.000 0.032 0.000
#> GSM40671 3 0.3764 0.755 0.216 0.000 0.784 0.000
#> GSM40672 1 0.4999 -0.182 0.508 0.000 0.492 0.000
#> GSM40673 3 0.4040 0.741 0.248 0.000 0.752 0.000
#> GSM40674 1 0.1867 0.797 0.928 0.000 0.072 0.000
#> GSM40676 3 0.2149 0.675 0.088 0.000 0.912 0.000
#> GSM40680 1 0.4164 0.544 0.736 0.000 0.264 0.000
#> GSM40681 1 0.4761 0.352 0.628 0.000 0.372 0.000
#> GSM40683 3 0.4040 0.741 0.248 0.000 0.752 0.000
#> GSM40684 3 0.3172 0.697 0.160 0.000 0.840 0.000
#> GSM40685 1 0.1118 0.827 0.964 0.000 0.036 0.000
#> GSM40689 3 0.3569 0.755 0.196 0.000 0.804 0.000
#> GSM40690 3 0.4008 0.743 0.244 0.000 0.756 0.000
#> GSM40692 1 0.3311 0.721 0.828 0.000 0.172 0.000
#> GSM40693 1 0.1211 0.826 0.960 0.000 0.040 0.000
#> GSM40694 1 0.1302 0.824 0.956 0.000 0.044 0.000
#> GSM40695 3 0.3764 0.755 0.216 0.000 0.784 0.000
#> GSM40696 1 0.1211 0.826 0.960 0.000 0.040 0.000
#> GSM40697 1 0.0000 0.821 1.000 0.000 0.000 0.000
#> GSM40704 3 0.4356 0.698 0.292 0.000 0.708 0.000
#> GSM40705 3 0.6878 0.682 0.316 0.000 0.556 0.128
#> GSM40707 3 0.0188 0.672 0.004 0.000 0.996 0.000
#> GSM40708 3 0.0188 0.672 0.004 0.000 0.996 0.000
#> GSM40709 3 0.6501 0.698 0.316 0.000 0.588 0.096
#> GSM40712 1 0.0921 0.826 0.972 0.000 0.028 0.000
#> GSM40713 3 0.4072 0.741 0.252 0.000 0.748 0.000
#> GSM40665 3 0.0188 0.672 0.004 0.000 0.996 0.000
#> GSM40677 2 0.0000 0.837 0.000 1.000 0.000 0.000
#> GSM40698 3 0.1022 0.678 0.032 0.000 0.968 0.000
#> GSM40701 3 0.7288 0.673 0.320 0.016 0.548 0.116
#> GSM40710 2 0.0000 0.837 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.6520 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.6520 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.6520 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.6520 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.5295 0.4136 0.000 0.000 0.540 0.408 0.052
#> GSM40668 3 0.0000 0.6520 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0000 0.8785 0.000 1.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 0.8785 0.000 1.000 0.000 0.000 0.000
#> GSM40686 2 0.0000 0.8785 0.000 1.000 0.000 0.000 0.000
#> GSM40687 2 0.0000 0.8785 0.000 1.000 0.000 0.000 0.000
#> GSM40691 5 0.0404 0.9116 0.000 0.012 0.000 0.000 0.988
#> GSM40699 2 0.2074 0.8305 0.000 0.920 0.000 0.044 0.036
#> GSM40664 2 0.4084 0.4458 0.000 0.668 0.000 0.328 0.004
#> GSM40682 2 0.0162 0.8766 0.004 0.996 0.000 0.000 0.000
#> GSM40688 2 0.4452 0.0495 0.004 0.500 0.000 0.000 0.496
#> GSM40702 2 0.0290 0.8749 0.000 0.992 0.000 0.000 0.008
#> GSM40706 2 0.3305 0.6490 0.000 0.776 0.000 0.224 0.000
#> GSM40711 3 0.4942 0.3931 0.000 0.000 0.540 0.432 0.028
#> GSM40661 4 0.6869 -0.1020 0.000 0.152 0.340 0.480 0.028
#> GSM40662 5 0.0162 0.9180 0.004 0.000 0.000 0.000 0.996
#> GSM40666 3 0.5809 0.4052 0.004 0.000 0.528 0.384 0.084
#> GSM40669 5 0.0000 0.9191 0.000 0.000 0.000 0.000 1.000
#> GSM40670 5 0.0000 0.9191 0.000 0.000 0.000 0.000 1.000
#> GSM40671 1 0.0162 0.9361 0.996 0.000 0.000 0.004 0.000
#> GSM40672 1 0.0963 0.9266 0.964 0.000 0.000 0.000 0.036
#> GSM40673 1 0.0000 0.9364 1.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.0000 0.9191 0.000 0.000 0.000 0.000 1.000
#> GSM40676 4 0.0000 0.7928 0.000 0.000 0.000 1.000 0.000
#> GSM40680 5 0.6056 0.3162 0.356 0.032 0.000 0.060 0.552
#> GSM40681 1 0.3983 0.4403 0.660 0.000 0.000 0.000 0.340
#> GSM40683 1 0.0000 0.9364 1.000 0.000 0.000 0.000 0.000
#> GSM40684 4 0.0162 0.7913 0.000 0.000 0.000 0.996 0.004
#> GSM40685 5 0.2891 0.7625 0.176 0.000 0.000 0.000 0.824
#> GSM40689 1 0.0566 0.9330 0.984 0.000 0.000 0.012 0.004
#> GSM40690 1 0.0880 0.9291 0.968 0.000 0.000 0.000 0.032
#> GSM40692 5 0.4815 0.6607 0.208 0.056 0.000 0.012 0.724
#> GSM40693 5 0.0162 0.9184 0.004 0.000 0.000 0.000 0.996
#> GSM40694 5 0.0162 0.9184 0.004 0.000 0.000 0.000 0.996
#> GSM40695 1 0.0000 0.9364 1.000 0.000 0.000 0.000 0.000
#> GSM40696 5 0.0162 0.9184 0.004 0.000 0.000 0.000 0.996
#> GSM40697 5 0.0000 0.9191 0.000 0.000 0.000 0.000 1.000
#> GSM40704 1 0.1478 0.8977 0.936 0.000 0.000 0.000 0.064
#> GSM40705 3 0.4942 0.3931 0.000 0.000 0.540 0.432 0.028
#> GSM40707 4 0.0510 0.7947 0.016 0.000 0.000 0.984 0.000
#> GSM40708 4 0.0404 0.7974 0.012 0.000 0.000 0.988 0.000
#> GSM40709 4 0.4965 -0.3059 0.000 0.000 0.452 0.520 0.028
#> GSM40712 5 0.0000 0.9191 0.000 0.000 0.000 0.000 1.000
#> GSM40713 1 0.0324 0.9362 0.992 0.000 0.000 0.004 0.004
#> GSM40665 4 0.0404 0.7974 0.012 0.000 0.000 0.988 0.000
#> GSM40677 2 0.0000 0.8785 0.000 1.000 0.000 0.000 0.000
#> GSM40698 4 0.0404 0.7974 0.012 0.000 0.000 0.988 0.000
#> GSM40701 3 0.5763 0.3517 0.000 0.032 0.508 0.428 0.032
#> GSM40710 2 0.0000 0.8785 0.000 1.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
#> GSM40663 3 0.0146 0.981 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40667 3 0.0146 0.981 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40675 3 0.0146 0.981 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40703 3 0.0146 0.981 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM40660 4 0.1708 0.776 0.000 0.040 0.004 0.932 0.024 0.000
#> GSM40668 3 0.1444 0.921 0.000 0.000 0.928 0.072 0.000 0.000
#> GSM40678 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40679 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40686 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40687 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40691 5 0.1152 0.858 0.000 0.044 0.000 0.004 0.952 0.000
#> GSM40699 2 0.2869 0.779 0.000 0.832 0.000 0.148 0.020 0.000
#> GSM40664 2 0.3575 0.771 0.000 0.796 0.000 0.076 0.000 0.128
#> GSM40682 2 0.0260 0.930 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM40688 5 0.4991 0.284 0.000 0.404 0.000 0.072 0.524 0.000
#> GSM40702 2 0.0260 0.930 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM40706 2 0.3534 0.776 0.000 0.800 0.000 0.076 0.000 0.124
#> GSM40711 4 0.0405 0.777 0.000 0.000 0.004 0.988 0.000 0.008
#> GSM40661 4 0.5587 0.335 0.000 0.356 0.004 0.508 0.000 0.132
#> GSM40662 5 0.1700 0.831 0.000 0.004 0.000 0.080 0.916 0.000
#> GSM40666 4 0.2309 0.738 0.000 0.000 0.000 0.888 0.084 0.028
#> GSM40669 5 0.0291 0.882 0.000 0.000 0.004 0.004 0.992 0.000
#> GSM40670 5 0.0405 0.881 0.000 0.000 0.004 0.008 0.988 0.000
#> GSM40671 1 0.0146 0.947 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM40672 1 0.2219 0.834 0.864 0.000 0.000 0.000 0.136 0.000
#> GSM40673 1 0.0000 0.946 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40674 5 0.0405 0.881 0.000 0.000 0.004 0.008 0.988 0.000
#> GSM40676 6 0.0146 0.953 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM40680 5 0.4984 0.524 0.000 0.244 0.000 0.124 0.632 0.000
#> GSM40681 1 0.1663 0.890 0.912 0.000 0.000 0.000 0.088 0.000
#> GSM40683 1 0.0000 0.946 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40684 6 0.1556 0.881 0.000 0.000 0.000 0.080 0.000 0.920
#> GSM40685 5 0.0146 0.882 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM40689 1 0.0146 0.947 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM40690 1 0.0146 0.947 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM40692 5 0.4721 0.580 0.000 0.212 0.000 0.116 0.672 0.000
#> GSM40693 5 0.0000 0.883 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM40694 5 0.0000 0.883 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM40695 1 0.0000 0.946 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM40696 5 0.0000 0.883 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM40697 5 0.0000 0.883 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM40704 1 0.2454 0.810 0.840 0.000 0.000 0.000 0.160 0.000
#> GSM40705 4 0.0405 0.777 0.000 0.000 0.004 0.988 0.000 0.008
#> GSM40707 6 0.0632 0.969 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM40708 6 0.0632 0.969 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM40709 4 0.1267 0.770 0.000 0.000 0.000 0.940 0.000 0.060
#> GSM40712 5 0.0291 0.882 0.000 0.000 0.004 0.004 0.992 0.000
#> GSM40713 1 0.0146 0.947 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM40665 6 0.0632 0.969 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM40677 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM40698 6 0.0547 0.968 0.020 0.000 0.000 0.000 0.000 0.980
#> GSM40701 4 0.4313 0.387 0.000 0.372 0.004 0.604 0.020 0.000
#> GSM40710 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:mclust 37 1.37e-05 2
#> ATC:mclust 52 6.50e-12 3
#> ATC:mclust 49 2.04e-09 4
#> ATC:mclust 42 4.16e-08 5
#> ATC:mclust 50 1.88e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 35373 rows and 53 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
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.912 0.963 0.5062 0.492 0.492
#> 3 3 0.887 0.886 0.952 0.3143 0.734 0.513
#> 4 4 0.725 0.760 0.884 0.1221 0.858 0.608
#> 5 5 0.693 0.630 0.835 0.0345 0.931 0.758
#> 6 6 0.668 0.545 0.787 0.0343 0.925 0.713
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM40663 2 0.0000 0.9858 0.000 1.000
#> GSM40667 2 0.0000 0.9858 0.000 1.000
#> GSM40675 2 0.0000 0.9858 0.000 1.000
#> GSM40703 2 0.0000 0.9858 0.000 1.000
#> GSM40660 2 0.0000 0.9858 0.000 1.000
#> GSM40668 2 0.0000 0.9858 0.000 1.000
#> GSM40678 2 0.0000 0.9858 0.000 1.000
#> GSM40679 2 0.0000 0.9858 0.000 1.000
#> GSM40686 1 0.9460 0.4710 0.636 0.364
#> GSM40687 2 0.0000 0.9858 0.000 1.000
#> GSM40691 2 0.0000 0.9858 0.000 1.000
#> GSM40699 2 0.0000 0.9858 0.000 1.000
#> GSM40664 2 0.0000 0.9858 0.000 1.000
#> GSM40682 2 0.0000 0.9858 0.000 1.000
#> GSM40688 2 0.4562 0.8934 0.096 0.904
#> GSM40702 2 0.0000 0.9858 0.000 1.000
#> GSM40706 2 0.0000 0.9858 0.000 1.000
#> GSM40711 2 0.0000 0.9858 0.000 1.000
#> GSM40661 2 0.0000 0.9858 0.000 1.000
#> GSM40662 2 0.2236 0.9566 0.036 0.964
#> GSM40666 2 0.5178 0.8674 0.116 0.884
#> GSM40669 1 0.0000 0.9364 1.000 0.000
#> GSM40670 1 0.9000 0.5671 0.684 0.316
#> GSM40671 1 0.0000 0.9364 1.000 0.000
#> GSM40672 1 0.0000 0.9364 1.000 0.000
#> GSM40673 1 0.0000 0.9364 1.000 0.000
#> GSM40674 1 0.9427 0.4808 0.640 0.360
#> GSM40676 1 0.1414 0.9221 0.980 0.020
#> GSM40680 1 0.0000 0.9364 1.000 0.000
#> GSM40681 1 0.0000 0.9364 1.000 0.000
#> GSM40683 1 0.0000 0.9364 1.000 0.000
#> GSM40684 1 0.4562 0.8565 0.904 0.096
#> GSM40685 1 0.0000 0.9364 1.000 0.000
#> GSM40689 1 0.0000 0.9364 1.000 0.000
#> GSM40690 1 0.0000 0.9364 1.000 0.000
#> GSM40692 1 0.0000 0.9364 1.000 0.000
#> GSM40693 1 0.0000 0.9364 1.000 0.000
#> GSM40694 1 0.0000 0.9364 1.000 0.000
#> GSM40695 1 0.0000 0.9364 1.000 0.000
#> GSM40696 1 0.0000 0.9364 1.000 0.000
#> GSM40697 1 1.0000 0.0883 0.504 0.496
#> GSM40704 1 0.0000 0.9364 1.000 0.000
#> GSM40705 2 0.0000 0.9858 0.000 1.000
#> GSM40707 1 0.0000 0.9364 1.000 0.000
#> GSM40708 1 0.0000 0.9364 1.000 0.000
#> GSM40709 2 0.3114 0.9375 0.056 0.944
#> GSM40712 1 0.0000 0.9364 1.000 0.000
#> GSM40713 1 0.0000 0.9364 1.000 0.000
#> GSM40665 1 0.0000 0.9364 1.000 0.000
#> GSM40677 2 0.0672 0.9800 0.008 0.992
#> GSM40698 1 0.0000 0.9364 1.000 0.000
#> GSM40701 2 0.0000 0.9858 0.000 1.000
#> GSM40710 2 0.0000 0.9858 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM40663 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40667 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40675 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40703 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40660 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40668 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40678 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40679 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40686 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40687 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40691 2 0.1031 0.906 0.000 0.976 0.024
#> GSM40699 2 0.2625 0.863 0.000 0.916 0.084
#> GSM40664 2 0.0424 0.912 0.000 0.992 0.008
#> GSM40682 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40688 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40702 2 0.0892 0.908 0.000 0.980 0.020
#> GSM40706 3 0.0592 0.958 0.000 0.012 0.988
#> GSM40711 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40661 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40662 2 0.8387 0.157 0.084 0.488 0.428
#> GSM40666 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40669 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40670 1 0.5465 0.596 0.712 0.000 0.288
#> GSM40671 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40672 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40673 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40674 1 0.6180 0.302 0.584 0.000 0.416
#> GSM40676 1 0.4291 0.769 0.820 0.000 0.180
#> GSM40680 2 0.4555 0.752 0.200 0.800 0.000
#> GSM40681 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40683 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40684 3 0.5733 0.480 0.324 0.000 0.676
#> GSM40685 2 0.1860 0.890 0.052 0.948 0.000
#> GSM40689 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40690 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40692 2 0.5926 0.494 0.356 0.644 0.000
#> GSM40693 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40694 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40695 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40696 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40697 2 0.2301 0.884 0.060 0.936 0.004
#> GSM40704 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40705 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40707 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40708 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40709 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40712 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40713 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40665 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40677 2 0.0000 0.914 0.000 1.000 0.000
#> GSM40698 1 0.0000 0.955 1.000 0.000 0.000
#> GSM40701 3 0.0000 0.970 0.000 0.000 1.000
#> GSM40710 2 0.0000 0.914 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM40663 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40667 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40675 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40703 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40660 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40668 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40678 2 0.0000 0.8888 0.000 1.000 0.000 0.000
#> GSM40679 2 0.0000 0.8888 0.000 1.000 0.000 0.000
#> GSM40686 2 0.0000 0.8888 0.000 1.000 0.000 0.000
#> GSM40687 2 0.0000 0.8888 0.000 1.000 0.000 0.000
#> GSM40691 2 0.5354 0.7414 0.116 0.756 0.124 0.004
#> GSM40699 2 0.2760 0.8016 0.000 0.872 0.128 0.000
#> GSM40664 4 0.4967 0.0592 0.000 0.452 0.000 0.548
#> GSM40682 2 0.0336 0.8868 0.000 0.992 0.000 0.008
#> GSM40688 2 0.2334 0.8510 0.088 0.908 0.000 0.004
#> GSM40702 2 0.0524 0.8867 0.000 0.988 0.004 0.008
#> GSM40706 3 0.4993 0.6031 0.000 0.260 0.712 0.028
#> GSM40711 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40661 3 0.1109 0.9129 0.000 0.004 0.968 0.028
#> GSM40662 3 0.7565 0.2385 0.200 0.292 0.504 0.004
#> GSM40666 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40669 1 0.0188 0.7562 0.996 0.000 0.004 0.000
#> GSM40670 1 0.3873 0.5727 0.772 0.000 0.228 0.000
#> GSM40671 4 0.4250 0.4753 0.276 0.000 0.000 0.724
#> GSM40672 1 0.2345 0.7631 0.900 0.000 0.000 0.100
#> GSM40673 1 0.3764 0.7302 0.784 0.000 0.000 0.216
#> GSM40674 1 0.4500 0.4678 0.684 0.000 0.316 0.000
#> GSM40676 4 0.1118 0.8470 0.036 0.000 0.000 0.964
#> GSM40680 2 0.1975 0.8568 0.048 0.936 0.000 0.016
#> GSM40681 1 0.3610 0.7384 0.800 0.000 0.000 0.200
#> GSM40683 1 0.4008 0.7116 0.756 0.000 0.000 0.244
#> GSM40684 4 0.2002 0.8393 0.044 0.000 0.020 0.936
#> GSM40685 2 0.4837 0.5300 0.348 0.648 0.000 0.004
#> GSM40689 1 0.4877 0.4639 0.592 0.000 0.000 0.408
#> GSM40690 1 0.4585 0.6089 0.668 0.000 0.000 0.332
#> GSM40692 2 0.5125 0.4641 0.388 0.604 0.000 0.008
#> GSM40693 1 0.0000 0.7583 1.000 0.000 0.000 0.000
#> GSM40694 1 0.0000 0.7583 1.000 0.000 0.000 0.000
#> GSM40695 1 0.4304 0.6729 0.716 0.000 0.000 0.284
#> GSM40696 1 0.0000 0.7583 1.000 0.000 0.000 0.000
#> GSM40697 1 0.5166 0.3528 0.688 0.288 0.020 0.004
#> GSM40704 1 0.2868 0.7581 0.864 0.000 0.000 0.136
#> GSM40705 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40707 4 0.1792 0.8323 0.068 0.000 0.000 0.932
#> GSM40708 4 0.1302 0.8481 0.044 0.000 0.000 0.956
#> GSM40709 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40712 1 0.0000 0.7583 1.000 0.000 0.000 0.000
#> GSM40713 1 0.4103 0.7022 0.744 0.000 0.000 0.256
#> GSM40665 4 0.1302 0.8481 0.044 0.000 0.000 0.956
#> GSM40677 2 0.0376 0.8874 0.004 0.992 0.000 0.004
#> GSM40698 4 0.0895 0.8377 0.020 0.004 0.000 0.976
#> GSM40701 3 0.0000 0.9348 0.000 0.000 1.000 0.000
#> GSM40710 2 0.0188 0.8880 0.000 0.996 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM40663 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40667 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40675 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40703 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40660 3 0.0510 0.8354 0.000 0.000 0.984 0.016 0.000
#> GSM40668 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40678 2 0.0451 0.7457 0.004 0.988 0.000 0.008 0.000
#> GSM40679 2 0.1732 0.7396 0.000 0.920 0.000 0.080 0.000
#> GSM40686 2 0.0162 0.7470 0.000 0.996 0.000 0.004 0.000
#> GSM40687 2 0.0865 0.7413 0.004 0.972 0.000 0.024 0.000
#> GSM40691 2 0.6459 0.3458 0.000 0.584 0.148 0.240 0.028
#> GSM40699 2 0.3395 0.3789 0.000 0.764 0.236 0.000 0.000
#> GSM40664 1 0.4593 0.5735 0.736 0.184 0.000 0.080 0.000
#> GSM40682 2 0.3536 0.6686 0.084 0.832 0.000 0.084 0.000
#> GSM40688 2 0.4602 0.5505 0.000 0.656 0.000 0.316 0.028
#> GSM40702 2 0.1153 0.7454 0.004 0.964 0.008 0.024 0.000
#> GSM40706 4 0.6547 0.0000 0.000 0.296 0.232 0.472 0.000
#> GSM40711 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40661 3 0.2367 0.7450 0.072 0.004 0.904 0.020 0.000
#> GSM40662 3 0.8071 -0.2286 0.000 0.160 0.424 0.256 0.160
#> GSM40666 3 0.0290 0.8384 0.000 0.000 0.992 0.000 0.008
#> GSM40669 5 0.3318 0.6603 0.000 0.000 0.008 0.192 0.800
#> GSM40670 5 0.5845 0.2107 0.000 0.000 0.352 0.108 0.540
#> GSM40671 5 0.4297 0.0591 0.472 0.000 0.000 0.000 0.528
#> GSM40672 5 0.1041 0.7386 0.032 0.000 0.000 0.004 0.964
#> GSM40673 5 0.1732 0.7316 0.080 0.000 0.000 0.000 0.920
#> GSM40674 3 0.4976 0.0364 0.000 0.000 0.504 0.028 0.468
#> GSM40676 1 0.0566 0.8781 0.984 0.000 0.000 0.004 0.012
#> GSM40680 2 0.3961 0.6584 0.008 0.812 0.000 0.072 0.108
#> GSM40681 5 0.1478 0.7352 0.064 0.000 0.000 0.000 0.936
#> GSM40683 5 0.2233 0.7217 0.104 0.000 0.000 0.004 0.892
#> GSM40684 1 0.1806 0.8727 0.940 0.000 0.016 0.016 0.028
#> GSM40685 2 0.5027 0.4484 0.000 0.700 0.000 0.112 0.188
#> GSM40689 5 0.4302 0.5583 0.248 0.000 0.000 0.032 0.720
#> GSM40690 5 0.3106 0.6892 0.140 0.000 0.000 0.020 0.840
#> GSM40692 5 0.7029 -0.1177 0.008 0.352 0.000 0.284 0.356
#> GSM40693 5 0.3480 0.6283 0.000 0.000 0.000 0.248 0.752
#> GSM40694 5 0.2516 0.6907 0.000 0.000 0.000 0.140 0.860
#> GSM40695 5 0.2230 0.7168 0.116 0.000 0.000 0.000 0.884
#> GSM40696 5 0.3707 0.6007 0.000 0.000 0.000 0.284 0.716
#> GSM40697 5 0.6914 0.0896 0.000 0.232 0.008 0.372 0.388
#> GSM40704 5 0.1205 0.7384 0.040 0.000 0.000 0.004 0.956
#> GSM40705 3 0.0000 0.8435 0.000 0.000 1.000 0.000 0.000
#> GSM40707 1 0.3318 0.7200 0.800 0.000 0.000 0.008 0.192
#> GSM40708 1 0.0671 0.8796 0.980 0.000 0.000 0.004 0.016
#> GSM40709 3 0.2873 0.7004 0.000 0.000 0.860 0.120 0.020
#> GSM40712 5 0.0880 0.7255 0.000 0.000 0.000 0.032 0.968
#> GSM40713 5 0.2230 0.7183 0.116 0.000 0.000 0.000 0.884
#> GSM40665 1 0.1753 0.8773 0.936 0.000 0.000 0.032 0.032
#> GSM40677 2 0.3706 0.6470 0.004 0.756 0.000 0.236 0.004
#> GSM40698 1 0.1901 0.8710 0.932 0.004 0.000 0.024 0.040
#> GSM40701 3 0.0162 0.8417 0.000 0.000 0.996 0.004 0.000
#> GSM40710 2 0.0671 0.7436 0.004 0.980 0.000 0.016 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM40663 3 0.0909 0.8142 0.000 0.000 0.968 0.012 0.020 0.000
#> GSM40667 3 0.0622 0.8178 0.000 0.000 0.980 0.008 0.012 0.000
#> GSM40675 3 0.0622 0.8178 0.000 0.000 0.980 0.008 0.012 0.000
#> GSM40703 3 0.0909 0.8142 0.000 0.000 0.968 0.012 0.020 0.000
#> GSM40660 3 0.0363 0.8166 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM40668 3 0.0000 0.8192 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40678 2 0.0551 0.6771 0.000 0.984 0.000 0.004 0.004 0.008
#> GSM40679 2 0.3168 0.6390 0.000 0.820 0.000 0.028 0.148 0.004
#> GSM40686 2 0.0547 0.6800 0.000 0.980 0.000 0.000 0.020 0.000
#> GSM40687 2 0.1555 0.6638 0.000 0.940 0.000 0.012 0.040 0.008
#> GSM40691 2 0.5870 0.1430 0.000 0.480 0.160 0.008 0.352 0.000
#> GSM40699 2 0.3023 0.5016 0.000 0.768 0.232 0.000 0.000 0.000
#> GSM40664 6 0.5936 0.4078 0.000 0.096 0.000 0.088 0.204 0.612
#> GSM40682 2 0.7198 0.1172 0.000 0.440 0.000 0.140 0.232 0.188
#> GSM40688 5 0.4532 -0.2494 0.000 0.468 0.000 0.032 0.500 0.000
#> GSM40702 2 0.2212 0.6749 0.000 0.912 0.020 0.004 0.048 0.016
#> GSM40706 4 0.3510 0.0000 0.000 0.084 0.072 0.828 0.012 0.004
#> GSM40711 3 0.0291 0.8184 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM40661 3 0.5443 0.4704 0.000 0.000 0.668 0.056 0.120 0.156
#> GSM40662 5 0.6685 0.2105 0.088 0.104 0.352 0.004 0.452 0.000
#> GSM40666 3 0.0146 0.8188 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM40669 1 0.3766 0.3834 0.684 0.000 0.012 0.000 0.304 0.000
#> GSM40670 3 0.5914 -0.1417 0.380 0.000 0.412 0.000 0.208 0.000
#> GSM40671 1 0.3955 0.3935 0.648 0.000 0.000 0.008 0.004 0.340
#> GSM40672 1 0.0291 0.7534 0.992 0.000 0.000 0.004 0.004 0.000
#> GSM40673 1 0.1080 0.7570 0.960 0.000 0.000 0.004 0.004 0.032
#> GSM40674 3 0.4838 0.2374 0.372 0.000 0.564 0.000 0.064 0.000
#> GSM40676 6 0.1307 0.7851 0.032 0.000 0.000 0.008 0.008 0.952
#> GSM40680 2 0.6795 0.2996 0.112 0.560 0.000 0.060 0.220 0.048
#> GSM40681 1 0.1628 0.7460 0.940 0.008 0.000 0.004 0.036 0.012
#> GSM40683 1 0.1155 0.7565 0.956 0.000 0.000 0.004 0.004 0.036
#> GSM40684 6 0.3208 0.7722 0.088 0.000 0.036 0.016 0.008 0.852
#> GSM40685 2 0.5189 0.4268 0.104 0.688 0.000 0.012 0.176 0.020
#> GSM40689 1 0.4422 0.4625 0.672 0.000 0.000 0.020 0.024 0.284
#> GSM40690 1 0.3666 0.7106 0.812 0.000 0.000 0.016 0.092 0.080
#> GSM40692 5 0.6296 0.4053 0.340 0.200 0.000 0.020 0.440 0.000
#> GSM40693 1 0.3747 0.1496 0.604 0.000 0.000 0.000 0.396 0.000
#> GSM40694 1 0.3288 0.4859 0.724 0.000 0.000 0.000 0.276 0.000
#> GSM40695 1 0.1471 0.7499 0.932 0.000 0.000 0.004 0.000 0.064
#> GSM40696 5 0.3868 -0.0541 0.496 0.000 0.000 0.000 0.504 0.000
#> GSM40697 5 0.5206 0.4316 0.156 0.176 0.008 0.004 0.656 0.000
#> GSM40704 1 0.0363 0.7505 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM40705 3 0.0260 0.8194 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM40707 6 0.3788 0.6658 0.232 0.000 0.000 0.020 0.008 0.740
#> GSM40708 6 0.2586 0.7857 0.080 0.000 0.000 0.032 0.008 0.880
#> GSM40709 3 0.4498 0.3343 0.040 0.000 0.632 0.324 0.000 0.004
#> GSM40712 1 0.2003 0.6767 0.884 0.000 0.000 0.000 0.116 0.000
#> GSM40713 1 0.3093 0.6889 0.816 0.000 0.000 0.008 0.012 0.164
#> GSM40665 6 0.2989 0.7903 0.072 0.000 0.000 0.028 0.036 0.864
#> GSM40677 2 0.5260 0.1927 0.000 0.464 0.000 0.064 0.460 0.012
#> GSM40698 6 0.4756 0.7360 0.080 0.016 0.000 0.056 0.088 0.760
#> GSM40701 3 0.0000 0.8192 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM40710 2 0.1511 0.6625 0.000 0.940 0.000 0.012 0.044 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:NMF 50 1.79e-05 2
#> ATC:NMF 49 5.46e-05 3
#> ATC:NMF 46 1.62e-04 4
#> ATC:NMF 43 3.92e-04 5
#> ATC:NMF 32 2.85e-04 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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