Date: 2019-12-25 20:17:11 CET, cola version: 1.3.2
Document is loading...
All available functions which can be applied to this res_list
object:
res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#> On a matrix with 21168 rows and 52 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4, anno = anno)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 21168 52
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_list),
col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:mclust | 3 | 1.000 | 0.977 | 0.978 | ** | |
ATC:hclust | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:skmeans | 2 | 1.000 | 0.977 | 0.991 | ** | |
ATC:pam | 2 | 1.000 | 0.992 | 0.996 | ** | |
ATC:mclust | 2 | 1.000 | 0.985 | 0.993 | ** | |
ATC:NMF | 2 | 1.000 | 0.983 | 0.992 | ** | |
MAD:mclust | 4 | 0.919 | 0.892 | 0.953 | * | 2 |
MAD:pam | 4 | 0.908 | 0.878 | 0.951 | * | |
CV:mclust | 3 | 0.901 | 0.929 | 0.969 | * | |
SD:pam | 5 | 0.866 | 0.864 | 0.929 | ||
SD:NMF | 2 | 0.843 | 0.887 | 0.954 | ||
MAD:NMF | 2 | 0.804 | 0.899 | 0.957 | ||
SD:skmeans | 2 | 0.732 | 0.840 | 0.939 | ||
MAD:skmeans | 2 | 0.730 | 0.856 | 0.939 | ||
CV:NMF | 2 | 0.728 | 0.844 | 0.936 | ||
MAD:kmeans | 2 | 0.688 | 0.882 | 0.934 | ||
CV:skmeans | 2 | 0.659 | 0.851 | 0.932 | ||
CV:kmeans | 3 | 0.548 | 0.885 | 0.905 | ||
MAD:hclust | 3 | 0.519 | 0.741 | 0.770 | ||
SD:kmeans | 3 | 0.518 | 0.822 | 0.886 | ||
CV:pam | 2 | 0.514 | 0.830 | 0.913 | ||
SD:hclust | 3 | 0.457 | 0.720 | 0.790 | ||
CV:hclust | 3 | 0.370 | 0.742 | 0.802 |
**: 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.843 0.887 0.954 0.478 0.517 0.517
#> CV:NMF 2 0.728 0.844 0.936 0.491 0.502 0.502
#> MAD:NMF 2 0.804 0.899 0.957 0.491 0.509 0.509
#> ATC:NMF 2 1.000 0.983 0.992 0.342 0.660 0.660
#> SD:skmeans 2 0.732 0.840 0.939 0.492 0.509 0.509
#> CV:skmeans 2 0.659 0.851 0.932 0.505 0.493 0.493
#> MAD:skmeans 2 0.730 0.856 0.939 0.502 0.502 0.502
#> ATC:skmeans 2 1.000 0.977 0.991 0.455 0.551 0.551
#> SD:mclust 2 0.619 0.899 0.926 0.369 0.683 0.683
#> CV:mclust 2 0.195 0.608 0.762 0.436 0.618 0.618
#> MAD:mclust 2 0.974 0.978 0.970 0.318 0.683 0.683
#> ATC:mclust 2 1.000 0.985 0.993 0.504 0.497 0.497
#> SD:kmeans 2 0.656 0.872 0.911 0.370 0.683 0.683
#> CV:kmeans 2 0.415 0.733 0.871 0.391 0.638 0.638
#> MAD:kmeans 2 0.688 0.882 0.934 0.428 0.551 0.551
#> ATC:kmeans 2 1.000 1.000 1.000 0.317 0.683 0.683
#> SD:pam 2 0.640 0.840 0.929 0.480 0.517 0.517
#> CV:pam 2 0.514 0.830 0.913 0.453 0.527 0.527
#> MAD:pam 2 0.842 0.884 0.955 0.492 0.502 0.502
#> ATC:pam 2 1.000 0.992 0.996 0.344 0.660 0.660
#> SD:hclust 2 0.699 0.897 0.927 0.359 0.638 0.638
#> CV:hclust 2 0.724 0.896 0.929 0.349 0.638 0.638
#> MAD:hclust 2 0.595 0.926 0.929 0.371 0.638 0.638
#> ATC:hclust 2 1.000 1.000 1.000 0.317 0.683 0.683
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.472 0.669 0.825 0.3875 0.692 0.465
#> CV:NMF 3 0.398 0.619 0.799 0.3502 0.655 0.419
#> MAD:NMF 3 0.594 0.779 0.873 0.3596 0.757 0.555
#> ATC:NMF 3 0.461 0.738 0.838 0.5342 0.904 0.855
#> SD:skmeans 3 0.602 0.830 0.891 0.3684 0.729 0.510
#> CV:skmeans 3 0.343 0.502 0.766 0.3325 0.735 0.510
#> MAD:skmeans 3 0.558 0.760 0.863 0.3427 0.746 0.533
#> ATC:skmeans 3 0.849 0.928 0.954 0.4628 0.756 0.565
#> SD:mclust 3 1.000 0.977 0.978 0.3826 0.815 0.730
#> CV:mclust 3 0.901 0.929 0.969 0.1901 0.736 0.617
#> MAD:mclust 3 0.594 0.844 0.886 0.7484 0.815 0.730
#> ATC:mclust 3 0.645 0.707 0.797 0.2369 0.842 0.681
#> SD:kmeans 3 0.518 0.822 0.886 0.5259 0.795 0.700
#> CV:kmeans 3 0.548 0.885 0.905 0.4259 0.744 0.626
#> MAD:kmeans 3 0.457 0.655 0.822 0.4197 0.615 0.414
#> ATC:kmeans 3 0.598 0.843 0.892 0.9109 0.679 0.531
#> SD:pam 3 0.553 0.806 0.843 0.3397 0.803 0.631
#> CV:pam 3 0.469 0.790 0.886 0.2881 0.868 0.755
#> MAD:pam 3 0.861 0.870 0.924 0.3261 0.837 0.676
#> ATC:pam 3 0.652 0.825 0.885 0.6148 0.787 0.681
#> SD:hclust 3 0.457 0.720 0.790 0.3926 0.807 0.697
#> CV:hclust 3 0.370 0.742 0.802 0.5780 0.744 0.626
#> MAD:hclust 3 0.519 0.741 0.770 0.4505 0.747 0.603
#> ATC:hclust 3 1.000 0.972 0.985 0.0579 0.984 0.977
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.704 0.789 0.888 0.1418 0.805 0.486
#> CV:NMF 4 0.738 0.744 0.874 0.1406 0.792 0.468
#> MAD:NMF 4 0.708 0.750 0.867 0.1381 0.812 0.508
#> ATC:NMF 4 0.551 0.656 0.815 0.3130 0.716 0.507
#> SD:skmeans 4 0.615 0.694 0.833 0.1289 0.833 0.546
#> CV:skmeans 4 0.449 0.536 0.731 0.1264 0.805 0.487
#> MAD:skmeans 4 0.546 0.588 0.786 0.1256 0.858 0.603
#> ATC:skmeans 4 0.692 0.732 0.849 0.0891 0.937 0.813
#> SD:mclust 4 0.819 0.856 0.906 0.3808 0.801 0.601
#> CV:mclust 4 0.732 0.845 0.919 0.3492 0.799 0.602
#> MAD:mclust 4 0.919 0.892 0.953 0.3208 0.749 0.504
#> ATC:mclust 4 0.895 0.916 0.959 0.1700 0.834 0.568
#> SD:kmeans 4 0.594 0.637 0.803 0.2426 0.801 0.584
#> CV:kmeans 4 0.642 0.642 0.815 0.2707 0.794 0.569
#> MAD:kmeans 4 0.588 0.658 0.810 0.1839 0.759 0.453
#> ATC:kmeans 4 0.681 0.832 0.886 0.1503 0.792 0.517
#> SD:pam 4 0.731 0.823 0.915 0.1384 0.875 0.665
#> CV:pam 4 0.662 0.794 0.893 0.2338 0.857 0.659
#> MAD:pam 4 0.908 0.878 0.951 0.1356 0.891 0.688
#> ATC:pam 4 0.762 0.897 0.932 0.2257 0.863 0.701
#> SD:hclust 4 0.457 0.638 0.772 0.2912 0.916 0.817
#> CV:hclust 4 0.463 0.632 0.779 0.2008 0.873 0.735
#> MAD:hclust 4 0.524 0.652 0.802 0.2344 0.820 0.589
#> ATC:hclust 4 0.582 0.828 0.897 0.8317 0.686 0.530
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.644 0.543 0.742 0.0615 0.908 0.662
#> CV:NMF 5 0.634 0.623 0.767 0.0681 0.941 0.760
#> MAD:NMF 5 0.603 0.546 0.730 0.0625 0.887 0.582
#> ATC:NMF 5 0.599 0.711 0.805 0.0969 0.798 0.449
#> SD:skmeans 5 0.715 0.702 0.816 0.0632 0.919 0.690
#> CV:skmeans 5 0.545 0.481 0.692 0.0617 0.885 0.586
#> MAD:skmeans 5 0.602 0.579 0.758 0.0625 0.897 0.613
#> ATC:skmeans 5 0.685 0.515 0.713 0.0615 0.945 0.821
#> SD:mclust 5 0.759 0.814 0.873 0.1209 0.850 0.540
#> CV:mclust 5 0.718 0.666 0.844 0.1323 0.867 0.582
#> MAD:mclust 5 0.798 0.803 0.851 0.0731 0.943 0.788
#> ATC:mclust 5 0.730 0.664 0.779 0.0681 0.937 0.768
#> SD:kmeans 5 0.682 0.653 0.766 0.1114 0.879 0.590
#> CV:kmeans 5 0.692 0.664 0.768 0.0993 0.881 0.590
#> MAD:kmeans 5 0.726 0.743 0.803 0.0975 0.882 0.589
#> ATC:kmeans 5 0.667 0.664 0.794 0.0983 0.854 0.548
#> SD:pam 5 0.866 0.864 0.929 0.0958 0.869 0.562
#> CV:pam 5 0.709 0.679 0.860 0.0969 0.888 0.618
#> MAD:pam 5 0.839 0.766 0.898 0.0782 0.902 0.638
#> ATC:pam 5 0.837 0.760 0.864 0.0760 0.963 0.886
#> SD:hclust 5 0.640 0.535 0.778 0.1511 0.817 0.556
#> CV:hclust 5 0.527 0.613 0.763 0.0872 0.971 0.917
#> MAD:hclust 5 0.656 0.693 0.798 0.1127 0.857 0.581
#> ATC:hclust 5 0.561 0.732 0.821 0.0690 1.000 1.000
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.716 0.609 0.776 0.0433 0.871 0.491
#> CV:NMF 6 0.701 0.609 0.759 0.0409 0.931 0.671
#> MAD:NMF 6 0.685 0.634 0.780 0.0434 0.909 0.581
#> ATC:NMF 6 0.569 0.630 0.807 0.0275 0.974 0.894
#> SD:skmeans 6 0.760 0.666 0.798 0.0362 0.931 0.680
#> CV:skmeans 6 0.604 0.505 0.682 0.0392 0.938 0.705
#> MAD:skmeans 6 0.648 0.533 0.727 0.0395 0.956 0.784
#> ATC:skmeans 6 0.690 0.537 0.740 0.0410 0.844 0.494
#> SD:mclust 6 0.770 0.686 0.838 0.0445 0.936 0.704
#> CV:mclust 6 0.781 0.704 0.847 0.0432 0.949 0.749
#> MAD:mclust 6 0.762 0.718 0.831 0.0537 0.907 0.602
#> ATC:mclust 6 0.758 0.728 0.846 0.0651 0.896 0.566
#> SD:kmeans 6 0.747 0.795 0.809 0.0506 0.937 0.691
#> CV:kmeans 6 0.742 0.804 0.824 0.0578 0.925 0.645
#> MAD:kmeans 6 0.795 0.801 0.841 0.0538 0.966 0.826
#> ATC:kmeans 6 0.709 0.598 0.729 0.0556 0.943 0.760
#> SD:pam 6 0.841 0.749 0.867 0.0383 0.941 0.723
#> CV:pam 6 0.738 0.654 0.837 0.0285 0.965 0.832
#> MAD:pam 6 0.843 0.755 0.884 0.0422 0.956 0.781
#> ATC:pam 6 0.888 0.897 0.946 0.0926 0.865 0.563
#> SD:hclust 6 0.638 0.486 0.757 0.0487 0.981 0.928
#> CV:hclust 6 0.562 0.478 0.740 0.0713 0.876 0.642
#> MAD:hclust 6 0.694 0.748 0.784 0.0774 0.951 0.782
#> ATC:hclust 6 0.567 0.700 0.820 0.0463 0.955 0.872
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 2.68e-04 2
#> CV:NMF 49 6.70e-04 2
#> MAD:NMF 50 5.92e-04 2
#> ATC:NMF 52 2.41e-07 2
#> SD:skmeans 47 4.29e-04 2
#> CV:skmeans 51 1.12e-03 2
#> MAD:skmeans 50 7.95e-04 2
#> ATC:skmeans 51 1.34e-04 2
#> SD:mclust 52 3.80e-08 2
#> CV:mclust 47 2.19e-07 2
#> MAD:mclust 52 3.80e-08 2
#> ATC:mclust 52 1.57e-03 2
#> SD:kmeans 50 7.66e-08 2
#> CV:kmeans 44 6.25e-07 2
#> MAD:kmeans 50 8.70e-05 2
#> ATC:kmeans 52 3.80e-08 2
#> SD:pam 48 8.31e-03 2
#> CV:pam 49 5.32e-03 2
#> MAD:pam 48 9.53e-03 2
#> ATC:pam 52 2.41e-07 2
#> SD:hclust 50 7.66e-08 2
#> CV:hclust 50 7.66e-08 2
#> MAD:hclust 52 1.10e-06 2
#> ATC:hclust 52 3.80e-08 2
test_to_known_factors(res_list, k = 3)
#> n disease.state(p) k
#> SD:NMF 44 6.12e-06 3
#> CV:NMF 38 6.92e-05 3
#> MAD:NMF 48 2.17e-05 3
#> ATC:NMF 49 6.40e-06 3
#> SD:skmeans 51 1.50e-05 3
#> CV:skmeans 36 2.78e-04 3
#> MAD:skmeans 48 2.17e-05 3
#> ATC:skmeans 52 2.35e-05 3
#> SD:mclust 52 4.38e-10 3
#> CV:mclust 51 7.48e-10 3
#> MAD:mclust 51 8.29e-11 3
#> ATC:mclust 47 1.13e-02 3
#> SD:kmeans 48 4.64e-10 3
#> CV:kmeans 51 4.01e-10 3
#> MAD:kmeans 39 1.42e-09 3
#> ATC:kmeans 49 4.56e-09 3
#> SD:pam 47 4.67e-07 3
#> CV:pam 50 8.21e-04 3
#> MAD:pam 49 8.13e-06 3
#> ATC:pam 50 4.76e-07 3
#> SD:hclust 48 2.07e-09 3
#> CV:hclust 48 3.75e-09 3
#> MAD:hclust 49 3.92e-09 3
#> ATC:hclust 51 5.05e-08 3
test_to_known_factors(res_list, k = 4)
#> n disease.state(p) k
#> SD:NMF 49 1.57e-05 4
#> CV:NMF 44 2.04e-05 4
#> MAD:NMF 45 1.48e-05 4
#> ATC:NMF 44 5.95e-07 4
#> SD:skmeans 44 2.11e-04 4
#> CV:skmeans 32 5.03e-05 4
#> MAD:skmeans 33 1.86e-04 4
#> ATC:skmeans 46 6.62e-04 4
#> SD:mclust 48 1.14e-08 4
#> CV:mclust 49 1.79e-08 4
#> MAD:mclust 50 8.92e-09 4
#> ATC:mclust 51 5.74e-06 4
#> SD:kmeans 36 6.33e-06 4
#> CV:kmeans 37 9.45e-06 4
#> MAD:kmeans 41 2.37e-07 4
#> ATC:kmeans 51 1.40e-08 4
#> SD:pam 50 8.28e-09 4
#> CV:pam 48 1.11e-07 4
#> MAD:pam 48 1.41e-07 4
#> ATC:pam 51 7.81e-09 4
#> SD:hclust 41 3.29e-09 4
#> CV:hclust 44 1.37e-08 4
#> MAD:hclust 44 1.26e-06 4
#> ATC:hclust 49 7.42e-10 4
test_to_known_factors(res_list, k = 5)
#> n disease.state(p) k
#> SD:NMF 35 8.09e-05 5
#> CV:NMF 38 5.05e-04 5
#> MAD:NMF 37 3.29e-06 5
#> ATC:NMF 44 1.69e-05 5
#> SD:skmeans 44 1.16e-05 5
#> CV:skmeans 27 4.03e-05 5
#> MAD:skmeans 38 3.45e-06 5
#> ATC:skmeans 34 8.27e-03 5
#> SD:mclust 49 1.55e-08 5
#> CV:mclust 39 3.62e-06 5
#> MAD:mclust 50 8.03e-08 5
#> ATC:mclust 45 3.85e-08 5
#> SD:kmeans 34 8.14e-06 5
#> CV:kmeans 35 1.34e-05 5
#> MAD:kmeans 41 1.59e-07 5
#> ATC:kmeans 43 4.56e-07 5
#> SD:pam 49 1.46e-07 5
#> CV:pam 42 4.11e-06 5
#> MAD:pam 41 1.54e-06 5
#> ATC:pam 46 4.56e-08 5
#> SD:hclust 35 8.24e-05 5
#> CV:hclust 42 1.27e-07 5
#> MAD:hclust 44 1.65e-07 5
#> ATC:hclust 47 2.44e-09 5
test_to_known_factors(res_list, k = 6)
#> n disease.state(p) k
#> SD:NMF 41 2.74e-05 6
#> CV:NMF 40 9.76e-06 6
#> MAD:NMF 45 5.27e-06 6
#> ATC:NMF 42 4.60e-05 6
#> SD:skmeans 41 1.83e-05 6
#> CV:skmeans 29 1.55e-04 6
#> MAD:skmeans 35 8.35e-05 6
#> ATC:skmeans 34 1.37e-04 6
#> SD:mclust 41 5.96e-06 6
#> CV:mclust 44 1.44e-06 6
#> MAD:mclust 44 2.05e-06 6
#> ATC:mclust 47 4.74e-05 6
#> SD:kmeans 50 2.11e-07 6
#> CV:kmeans 46 1.55e-06 6
#> MAD:kmeans 49 3.48e-07 6
#> ATC:kmeans 38 3.28e-06 6
#> SD:pam 43 2.11e-06 6
#> CV:pam 38 3.86e-05 6
#> MAD:pam 45 3.25e-06 6
#> ATC:pam 51 2.87e-07 6
#> SD:hclust 35 1.47e-05 6
#> CV:hclust 34 6.71e-07 6
#> MAD:hclust 45 6.03e-07 6
#> ATC:hclust 43 1.07e-06 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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.699 0.897 0.927 0.3595 0.638 0.638
#> 3 3 0.457 0.720 0.790 0.3926 0.807 0.697
#> 4 4 0.457 0.638 0.772 0.2912 0.916 0.817
#> 5 5 0.640 0.535 0.778 0.1511 0.817 0.556
#> 6 6 0.638 0.486 0.757 0.0487 0.981 0.928
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
#> GSM38155 2 0.2603 0.905 0.044 0.956
#> GSM38156 2 0.2603 0.905 0.044 0.956
#> GSM38157 2 0.2603 0.905 0.044 0.956
#> GSM38158 2 0.2603 0.905 0.044 0.956
#> GSM38159 2 0.4431 0.883 0.092 0.908
#> GSM38160 2 0.2603 0.905 0.044 0.956
#> GSM38161 2 0.4298 0.888 0.088 0.912
#> GSM38162 1 0.2603 0.924 0.956 0.044
#> GSM38163 1 0.4431 0.918 0.908 0.092
#> GSM38164 1 0.3274 0.933 0.940 0.060
#> GSM38165 1 0.2603 0.924 0.956 0.044
#> GSM38166 1 0.2603 0.924 0.956 0.044
#> GSM38167 1 0.0376 0.938 0.996 0.004
#> GSM38168 1 0.0938 0.939 0.988 0.012
#> GSM38169 1 0.3274 0.933 0.940 0.060
#> GSM38170 1 0.2603 0.924 0.956 0.044
#> GSM38171 1 0.4562 0.915 0.904 0.096
#> GSM38172 1 0.0938 0.939 0.988 0.012
#> GSM38173 1 0.2778 0.937 0.952 0.048
#> GSM38174 1 0.0376 0.938 0.996 0.004
#> GSM38175 1 0.4815 0.909 0.896 0.104
#> GSM38176 1 0.4431 0.918 0.908 0.092
#> GSM38177 1 0.0376 0.938 0.996 0.004
#> GSM38178 1 0.3274 0.933 0.940 0.060
#> GSM38179 1 0.4298 0.920 0.912 0.088
#> GSM38180 1 0.4431 0.918 0.908 0.092
#> GSM38181 1 0.2603 0.924 0.956 0.044
#> GSM38182 1 0.2423 0.938 0.960 0.040
#> GSM38183 1 0.4431 0.918 0.908 0.092
#> GSM38184 2 0.2603 0.905 0.044 0.956
#> GSM38185 1 0.6712 0.822 0.824 0.176
#> GSM38186 1 0.4562 0.915 0.904 0.096
#> GSM38187 1 0.2236 0.938 0.964 0.036
#> GSM38188 1 0.4939 0.903 0.892 0.108
#> GSM38189 1 0.2778 0.937 0.952 0.048
#> GSM38190 1 0.3431 0.932 0.936 0.064
#> GSM38191 2 0.9909 0.330 0.444 0.556
#> GSM38192 1 0.4431 0.918 0.908 0.092
#> GSM38193 2 0.4298 0.888 0.088 0.912
#> GSM38194 2 0.9909 0.330 0.444 0.556
#> GSM38195 1 0.2423 0.938 0.960 0.040
#> GSM38196 1 0.0376 0.938 0.996 0.004
#> GSM38197 1 0.2423 0.938 0.960 0.040
#> GSM38198 1 0.2603 0.924 0.956 0.044
#> GSM38199 1 0.2603 0.924 0.956 0.044
#> GSM38200 2 0.2603 0.905 0.044 0.956
#> GSM38201 1 0.2603 0.924 0.956 0.044
#> GSM38202 1 0.2603 0.924 0.956 0.044
#> GSM38203 1 0.2603 0.924 0.956 0.044
#> GSM38204 1 0.2603 0.924 0.956 0.044
#> GSM38205 1 0.2603 0.924 0.956 0.044
#> GSM38206 1 0.2603 0.924 0.956 0.044
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.4842 0.805740 0.000 0.776 0.224
#> GSM38156 2 0.4887 0.805519 0.000 0.772 0.228
#> GSM38157 2 0.4842 0.805740 0.000 0.776 0.224
#> GSM38158 2 0.6204 0.747396 0.000 0.576 0.424
#> GSM38159 2 0.6940 0.784538 0.068 0.708 0.224
#> GSM38160 2 0.0424 0.770795 0.000 0.992 0.008
#> GSM38161 2 0.1964 0.758603 0.056 0.944 0.000
#> GSM38162 1 0.4654 0.504475 0.792 0.000 0.208
#> GSM38163 1 0.2599 0.777417 0.932 0.052 0.016
#> GSM38164 1 0.1482 0.774751 0.968 0.012 0.020
#> GSM38165 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38166 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38167 1 0.4062 0.636411 0.836 0.000 0.164
#> GSM38168 1 0.4723 0.633381 0.824 0.016 0.160
#> GSM38169 1 0.1620 0.775837 0.964 0.012 0.024
#> GSM38170 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38171 1 0.2550 0.776229 0.932 0.056 0.012
#> GSM38172 1 0.2625 0.759867 0.916 0.000 0.084
#> GSM38173 1 0.3234 0.768113 0.908 0.020 0.072
#> GSM38174 1 0.4121 0.629360 0.832 0.000 0.168
#> GSM38175 1 0.2680 0.768432 0.924 0.068 0.008
#> GSM38176 1 0.2599 0.777417 0.932 0.052 0.016
#> GSM38177 1 0.4002 0.640773 0.840 0.000 0.160
#> GSM38178 1 0.1620 0.775837 0.964 0.012 0.024
#> GSM38179 1 0.2280 0.779072 0.940 0.052 0.008
#> GSM38180 1 0.2384 0.777660 0.936 0.056 0.008
#> GSM38181 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38182 1 0.2866 0.762845 0.916 0.008 0.076
#> GSM38183 1 0.2384 0.777846 0.936 0.056 0.008
#> GSM38184 2 0.6215 0.746316 0.000 0.572 0.428
#> GSM38185 1 0.3918 0.673590 0.856 0.140 0.004
#> GSM38186 1 0.2486 0.775423 0.932 0.060 0.008
#> GSM38187 1 0.2200 0.769969 0.940 0.004 0.056
#> GSM38188 1 0.4443 0.740416 0.864 0.084 0.052
#> GSM38189 1 0.3502 0.761571 0.896 0.020 0.084
#> GSM38190 1 0.1620 0.773489 0.964 0.012 0.024
#> GSM38191 2 0.6948 0.219404 0.472 0.512 0.016
#> GSM38192 1 0.2384 0.777846 0.936 0.056 0.008
#> GSM38193 2 0.1964 0.758603 0.056 0.944 0.000
#> GSM38194 2 0.6948 0.219404 0.472 0.512 0.016
#> GSM38195 1 0.2866 0.762845 0.916 0.008 0.076
#> GSM38196 1 0.4121 0.629360 0.832 0.000 0.168
#> GSM38197 1 0.2280 0.772209 0.940 0.008 0.052
#> GSM38198 1 0.4654 0.504475 0.792 0.000 0.208
#> GSM38199 1 0.5968 -0.351954 0.636 0.000 0.364
#> GSM38200 2 0.4887 0.805519 0.000 0.772 0.228
#> GSM38201 1 0.4654 0.504475 0.792 0.000 0.208
#> GSM38202 1 0.5591 0.000204 0.696 0.000 0.304
#> GSM38203 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38204 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38205 3 0.6280 1.000000 0.460 0.000 0.540
#> GSM38206 3 0.6280 1.000000 0.460 0.000 0.540
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.4761 0.72170 0.004 0.664 0.000 0.332
#> GSM38156 2 0.4454 0.72846 0.000 0.692 0.000 0.308
#> GSM38157 2 0.4624 0.71694 0.000 0.660 0.000 0.340
#> GSM38158 2 0.0000 0.56748 0.000 1.000 0.000 0.000
#> GSM38159 2 0.6532 0.55815 0.092 0.572 0.000 0.336
#> GSM38160 4 0.4877 -0.23159 0.000 0.408 0.000 0.592
#> GSM38161 4 0.5855 0.00645 0.044 0.356 0.000 0.600
#> GSM38162 1 0.7745 0.33059 0.412 0.000 0.236 0.352
#> GSM38163 1 0.2499 0.76321 0.920 0.032 0.044 0.004
#> GSM38164 1 0.1767 0.75060 0.944 0.000 0.012 0.044
#> GSM38165 3 0.1767 0.86281 0.044 0.000 0.944 0.012
#> GSM38166 3 0.0895 0.86969 0.020 0.000 0.976 0.004
#> GSM38167 1 0.6401 0.64155 0.652 0.000 0.176 0.172
#> GSM38168 1 0.7889 0.41222 0.460 0.008 0.224 0.308
#> GSM38169 1 0.2142 0.75195 0.928 0.000 0.016 0.056
#> GSM38170 3 0.1854 0.85981 0.048 0.000 0.940 0.012
#> GSM38171 1 0.1209 0.75831 0.964 0.032 0.000 0.004
#> GSM38172 1 0.4410 0.74212 0.808 0.000 0.064 0.128
#> GSM38173 1 0.3734 0.75557 0.852 0.012 0.020 0.116
#> GSM38174 1 0.6439 0.63857 0.648 0.000 0.176 0.176
#> GSM38175 1 0.1452 0.75498 0.956 0.036 0.000 0.008
#> GSM38176 1 0.2499 0.76321 0.920 0.032 0.044 0.004
#> GSM38177 1 0.6811 0.59821 0.604 0.000 0.180 0.216
#> GSM38178 1 0.2142 0.75195 0.928 0.000 0.016 0.056
#> GSM38179 1 0.2224 0.76413 0.928 0.032 0.040 0.000
#> GSM38180 1 0.1022 0.75883 0.968 0.032 0.000 0.000
#> GSM38181 3 0.1388 0.86916 0.028 0.000 0.960 0.012
#> GSM38182 1 0.4370 0.73204 0.800 0.000 0.156 0.044
#> GSM38183 1 0.2319 0.76338 0.924 0.036 0.040 0.000
#> GSM38184 2 0.1059 0.54766 0.016 0.972 0.000 0.012
#> GSM38185 1 0.3156 0.69901 0.884 0.048 0.000 0.068
#> GSM38186 1 0.1118 0.75821 0.964 0.036 0.000 0.000
#> GSM38187 1 0.2593 0.76016 0.892 0.000 0.104 0.004
#> GSM38188 1 0.5972 0.70213 0.748 0.064 0.124 0.064
#> GSM38189 1 0.5721 0.72708 0.740 0.012 0.132 0.116
#> GSM38190 1 0.1854 0.74980 0.940 0.000 0.012 0.048
#> GSM38191 4 0.5650 0.36628 0.432 0.024 0.000 0.544
#> GSM38192 1 0.2319 0.76338 0.924 0.036 0.040 0.000
#> GSM38193 4 0.5855 0.00645 0.044 0.356 0.000 0.600
#> GSM38194 4 0.5650 0.36628 0.432 0.024 0.000 0.544
#> GSM38195 1 0.4370 0.73204 0.800 0.000 0.156 0.044
#> GSM38196 1 0.6439 0.63834 0.648 0.000 0.176 0.176
#> GSM38197 1 0.2715 0.76018 0.892 0.004 0.100 0.004
#> GSM38198 1 0.7745 0.33059 0.412 0.000 0.236 0.352
#> GSM38199 3 0.6805 0.47915 0.220 0.000 0.604 0.176
#> GSM38200 2 0.4605 0.70920 0.000 0.664 0.000 0.336
#> GSM38201 1 0.7745 0.33059 0.412 0.000 0.236 0.352
#> GSM38202 3 0.7538 0.31487 0.260 0.000 0.492 0.248
#> GSM38203 3 0.0592 0.87089 0.016 0.000 0.984 0.000
#> GSM38204 3 0.0592 0.87089 0.016 0.000 0.984 0.000
#> GSM38205 3 0.0592 0.87089 0.016 0.000 0.984 0.000
#> GSM38206 3 0.0592 0.87089 0.016 0.000 0.984 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.4200 0.1777 0.004 0.672 0.000 0.004 0.320
#> GSM38156 2 0.4298 0.1080 0.000 0.640 0.000 0.008 0.352
#> GSM38157 2 0.4088 0.2098 0.000 0.688 0.000 0.008 0.304
#> GSM38158 5 0.3913 0.7867 0.000 0.324 0.000 0.000 0.676
#> GSM38159 2 0.5880 0.0910 0.116 0.584 0.000 0.004 0.296
#> GSM38160 2 0.1943 0.3745 0.000 0.924 0.000 0.020 0.056
#> GSM38161 2 0.0798 0.3929 0.008 0.976 0.000 0.016 0.000
#> GSM38162 4 0.2140 0.6552 0.040 0.000 0.012 0.924 0.024
#> GSM38163 1 0.1461 0.7575 0.952 0.000 0.028 0.016 0.004
#> GSM38164 1 0.3897 0.6664 0.768 0.000 0.000 0.028 0.204
#> GSM38165 3 0.4087 0.7785 0.028 0.000 0.800 0.144 0.028
#> GSM38166 3 0.1498 0.8465 0.008 0.000 0.952 0.016 0.024
#> GSM38167 4 0.4768 0.5623 0.384 0.000 0.024 0.592 0.000
#> GSM38168 4 0.3218 0.6724 0.088 0.008 0.012 0.868 0.024
#> GSM38169 1 0.4649 0.6321 0.720 0.000 0.000 0.068 0.212
#> GSM38170 3 0.4169 0.7736 0.032 0.000 0.796 0.144 0.028
#> GSM38171 1 0.0162 0.7582 0.996 0.000 0.000 0.000 0.004
#> GSM38172 1 0.6211 0.4889 0.616 0.000 0.024 0.212 0.148
#> GSM38173 1 0.4779 0.6255 0.748 0.000 0.008 0.124 0.120
#> GSM38174 4 0.4734 0.5791 0.372 0.000 0.024 0.604 0.000
#> GSM38175 1 0.0404 0.7578 0.988 0.012 0.000 0.000 0.000
#> GSM38176 1 0.1461 0.7575 0.952 0.000 0.028 0.016 0.004
#> GSM38177 4 0.4400 0.6283 0.308 0.000 0.020 0.672 0.000
#> GSM38178 1 0.4649 0.6321 0.720 0.000 0.000 0.068 0.212
#> GSM38179 1 0.1211 0.7582 0.960 0.000 0.024 0.016 0.000
#> GSM38180 1 0.0000 0.7577 1.000 0.000 0.000 0.000 0.000
#> GSM38181 3 0.2745 0.8360 0.024 0.000 0.896 0.052 0.028
#> GSM38182 1 0.5042 -0.2548 0.512 0.000 0.024 0.460 0.004
#> GSM38183 1 0.1372 0.7581 0.956 0.004 0.024 0.016 0.000
#> GSM38184 5 0.4453 0.8035 0.048 0.228 0.000 0.000 0.724
#> GSM38185 1 0.1892 0.7220 0.916 0.080 0.000 0.004 0.000
#> GSM38186 1 0.0162 0.7579 0.996 0.004 0.000 0.000 0.000
#> GSM38187 1 0.2843 0.7236 0.876 0.000 0.076 0.048 0.000
#> GSM38188 1 0.6038 -0.2942 0.472 0.052 0.008 0.452 0.016
#> GSM38189 4 0.6574 0.1894 0.416 0.000 0.020 0.444 0.120
#> GSM38190 1 0.3845 0.6674 0.768 0.000 0.000 0.024 0.208
#> GSM38191 2 0.7222 0.2007 0.200 0.532 0.000 0.068 0.200
#> GSM38192 1 0.1372 0.7581 0.956 0.004 0.024 0.016 0.000
#> GSM38193 2 0.0798 0.3929 0.008 0.976 0.000 0.016 0.000
#> GSM38194 2 0.7222 0.2007 0.200 0.532 0.000 0.068 0.200
#> GSM38195 1 0.5042 -0.2548 0.512 0.000 0.024 0.460 0.004
#> GSM38196 4 0.4746 0.5748 0.376 0.000 0.024 0.600 0.000
#> GSM38197 1 0.2929 0.7256 0.876 0.004 0.076 0.044 0.000
#> GSM38198 4 0.2140 0.6552 0.040 0.000 0.012 0.924 0.024
#> GSM38199 3 0.5937 -0.0111 0.080 0.000 0.480 0.432 0.008
#> GSM38200 2 0.4173 0.2019 0.000 0.688 0.000 0.012 0.300
#> GSM38201 4 0.2140 0.6552 0.040 0.000 0.012 0.924 0.024
#> GSM38202 4 0.5940 0.1700 0.104 0.000 0.348 0.544 0.004
#> GSM38203 3 0.0162 0.8472 0.000 0.000 0.996 0.000 0.004
#> GSM38204 3 0.0162 0.8472 0.000 0.000 0.996 0.000 0.004
#> GSM38205 3 0.0162 0.8472 0.000 0.000 0.996 0.000 0.004
#> GSM38206 3 0.0451 0.8488 0.000 0.000 0.988 0.008 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.1148 0.5368 0.004 0.960 0.000 0.000 0.020 0.016
#> GSM38156 2 0.0937 0.5105 0.000 0.960 0.000 0.000 0.000 0.040
#> GSM38157 2 0.0363 0.5492 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM38158 2 0.3782 -0.5277 0.000 0.588 0.000 0.000 0.000 0.412
#> GSM38159 2 0.2696 0.4034 0.116 0.856 0.000 0.000 0.028 0.000
#> GSM38160 2 0.4990 0.4113 0.000 0.644 0.000 0.000 0.204 0.152
#> GSM38161 2 0.4559 0.2889 0.008 0.512 0.000 0.000 0.460 0.020
#> GSM38162 4 0.0748 0.6149 0.004 0.000 0.000 0.976 0.016 0.004
#> GSM38163 1 0.1794 0.6878 0.936 0.000 0.020 0.024 0.008 0.012
#> GSM38164 1 0.5146 0.3159 0.540 0.000 0.000 0.012 0.388 0.060
#> GSM38165 3 0.5535 0.7161 0.012 0.000 0.652 0.104 0.028 0.204
#> GSM38166 3 0.2920 0.7695 0.000 0.000 0.820 0.008 0.004 0.168
#> GSM38167 4 0.5346 0.5372 0.356 0.000 0.000 0.560 0.036 0.048
#> GSM38168 4 0.2042 0.6254 0.048 0.008 0.000 0.920 0.016 0.008
#> GSM38169 1 0.5326 0.2312 0.496 0.000 0.000 0.024 0.428 0.052
#> GSM38170 3 0.5621 0.7132 0.016 0.000 0.648 0.104 0.028 0.204
#> GSM38171 1 0.0622 0.6881 0.980 0.000 0.000 0.000 0.008 0.012
#> GSM38172 1 0.7016 0.1219 0.408 0.000 0.020 0.168 0.356 0.048
#> GSM38173 1 0.5105 0.5169 0.688 0.000 0.008 0.116 0.172 0.016
#> GSM38174 4 0.5226 0.5670 0.336 0.000 0.000 0.584 0.032 0.048
#> GSM38175 1 0.0405 0.6881 0.988 0.004 0.000 0.000 0.008 0.000
#> GSM38176 1 0.1794 0.6878 0.936 0.000 0.020 0.024 0.008 0.012
#> GSM38177 4 0.4712 0.6082 0.284 0.000 0.000 0.656 0.028 0.032
#> GSM38178 1 0.5326 0.2312 0.496 0.000 0.000 0.024 0.428 0.052
#> GSM38179 1 0.1088 0.6867 0.960 0.000 0.016 0.024 0.000 0.000
#> GSM38180 1 0.0000 0.6876 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38181 3 0.4077 0.7573 0.008 0.000 0.752 0.024 0.016 0.200
#> GSM38182 1 0.5935 -0.2623 0.476 0.004 0.000 0.404 0.036 0.080
#> GSM38183 1 0.1232 0.6873 0.956 0.004 0.016 0.024 0.000 0.000
#> GSM38184 6 0.4982 0.0000 0.048 0.384 0.000 0.000 0.012 0.556
#> GSM38185 1 0.1867 0.6572 0.916 0.064 0.000 0.000 0.020 0.000
#> GSM38186 1 0.0436 0.6887 0.988 0.004 0.000 0.000 0.004 0.004
#> GSM38187 1 0.2817 0.6597 0.876 0.000 0.068 0.040 0.008 0.008
#> GSM38188 1 0.6392 -0.2888 0.440 0.048 0.000 0.424 0.048 0.040
#> GSM38189 4 0.6602 0.2734 0.336 0.000 0.016 0.444 0.184 0.020
#> GSM38190 1 0.5064 0.3166 0.540 0.000 0.000 0.008 0.392 0.060
#> GSM38191 5 0.3249 1.0000 0.060 0.088 0.000 0.012 0.840 0.000
#> GSM38192 1 0.1232 0.6873 0.956 0.004 0.016 0.024 0.000 0.000
#> GSM38193 2 0.4559 0.2889 0.008 0.512 0.000 0.000 0.460 0.020
#> GSM38194 5 0.3249 1.0000 0.060 0.088 0.000 0.012 0.840 0.000
#> GSM38195 1 0.5935 -0.2623 0.476 0.004 0.000 0.404 0.036 0.080
#> GSM38196 4 0.5250 0.5586 0.344 0.000 0.000 0.576 0.032 0.048
#> GSM38197 1 0.2848 0.6625 0.876 0.004 0.068 0.040 0.008 0.004
#> GSM38198 4 0.0748 0.6149 0.004 0.000 0.000 0.976 0.016 0.004
#> GSM38199 3 0.6130 -0.0266 0.064 0.000 0.452 0.428 0.028 0.028
#> GSM38200 2 0.2003 0.5474 0.000 0.912 0.000 0.000 0.044 0.044
#> GSM38201 4 0.0748 0.6149 0.004 0.000 0.000 0.976 0.016 0.004
#> GSM38202 4 0.5998 0.1284 0.084 0.000 0.332 0.540 0.020 0.024
#> GSM38203 3 0.0146 0.7800 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM38204 3 0.0146 0.7800 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM38205 3 0.0146 0.7800 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM38206 3 0.0260 0.7822 0.000 0.000 0.992 0.008 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
#> SD:hclust 50 7.66e-08 2
#> SD:hclust 48 2.07e-09 3
#> SD:hclust 41 3.29e-09 4
#> SD:hclust 35 8.24e-05 5
#> SD:hclust 35 1.47e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.656 0.872 0.911 0.3704 0.683 0.683
#> 3 3 0.518 0.822 0.886 0.5259 0.795 0.700
#> 4 4 0.594 0.637 0.803 0.2426 0.801 0.584
#> 5 5 0.682 0.653 0.766 0.1114 0.879 0.590
#> 6 6 0.747 0.795 0.809 0.0506 0.937 0.691
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
#> GSM38155 2 0.000 1.000 0.000 1.000
#> GSM38156 2 0.000 1.000 0.000 1.000
#> GSM38157 2 0.000 1.000 0.000 1.000
#> GSM38158 2 0.000 1.000 0.000 1.000
#> GSM38159 2 0.000 1.000 0.000 1.000
#> GSM38160 2 0.000 1.000 0.000 1.000
#> GSM38161 2 0.000 1.000 0.000 1.000
#> GSM38162 1 0.000 0.887 1.000 0.000
#> GSM38163 1 0.456 0.889 0.904 0.096
#> GSM38164 1 0.456 0.889 0.904 0.096
#> GSM38165 1 0.000 0.887 1.000 0.000
#> GSM38166 1 0.000 0.887 1.000 0.000
#> GSM38167 1 0.163 0.891 0.976 0.024
#> GSM38168 1 0.552 0.875 0.872 0.128
#> GSM38169 1 0.456 0.889 0.904 0.096
#> GSM38170 1 0.000 0.887 1.000 0.000
#> GSM38171 1 0.714 0.836 0.804 0.196
#> GSM38172 1 0.000 0.887 1.000 0.000
#> GSM38173 1 0.541 0.878 0.876 0.124
#> GSM38174 1 0.278 0.893 0.952 0.048
#> GSM38175 1 0.844 0.768 0.728 0.272
#> GSM38176 1 0.722 0.833 0.800 0.200
#> GSM38177 1 0.163 0.891 0.976 0.024
#> GSM38178 1 0.456 0.889 0.904 0.096
#> GSM38179 1 0.443 0.890 0.908 0.092
#> GSM38180 1 0.456 0.889 0.904 0.096
#> GSM38181 1 0.000 0.887 1.000 0.000
#> GSM38182 1 0.358 0.893 0.932 0.068
#> GSM38183 1 0.689 0.844 0.816 0.184
#> GSM38184 2 0.000 1.000 0.000 1.000
#> GSM38185 1 0.861 0.755 0.716 0.284
#> GSM38186 1 0.738 0.827 0.792 0.208
#> GSM38187 1 0.260 0.893 0.956 0.044
#> GSM38188 1 0.871 0.745 0.708 0.292
#> GSM38189 1 0.456 0.889 0.904 0.096
#> GSM38190 1 0.850 0.765 0.724 0.276
#> GSM38191 1 0.995 0.429 0.540 0.460
#> GSM38192 1 0.855 0.760 0.720 0.280
#> GSM38193 2 0.000 1.000 0.000 1.000
#> GSM38194 1 0.997 0.408 0.532 0.468
#> GSM38195 1 0.358 0.893 0.932 0.068
#> GSM38196 1 0.118 0.890 0.984 0.016
#> GSM38197 1 0.861 0.755 0.716 0.284
#> GSM38198 1 0.000 0.887 1.000 0.000
#> GSM38199 1 0.000 0.887 1.000 0.000
#> GSM38200 2 0.000 1.000 0.000 1.000
#> GSM38201 1 0.000 0.887 1.000 0.000
#> GSM38202 1 0.000 0.887 1.000 0.000
#> GSM38203 1 0.000 0.887 1.000 0.000
#> GSM38204 1 0.000 0.887 1.000 0.000
#> GSM38205 1 0.000 0.887 1.000 0.000
#> GSM38206 1 0.000 0.887 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0424 0.994 0.008 0.992 0.000
#> GSM38156 2 0.0424 0.994 0.008 0.992 0.000
#> GSM38157 2 0.0424 0.994 0.008 0.992 0.000
#> GSM38158 2 0.0848 0.992 0.008 0.984 0.008
#> GSM38159 2 0.0424 0.994 0.008 0.992 0.000
#> GSM38160 2 0.1170 0.990 0.008 0.976 0.016
#> GSM38161 2 0.1170 0.990 0.008 0.976 0.016
#> GSM38162 1 0.5335 0.691 0.760 0.008 0.232
#> GSM38163 1 0.3116 0.827 0.892 0.000 0.108
#> GSM38164 1 0.1643 0.831 0.956 0.000 0.044
#> GSM38165 3 0.2066 0.915 0.060 0.000 0.940
#> GSM38166 3 0.1964 0.915 0.056 0.000 0.944
#> GSM38167 1 0.3826 0.816 0.868 0.008 0.124
#> GSM38168 1 0.4059 0.793 0.860 0.012 0.128
#> GSM38169 1 0.1643 0.831 0.956 0.000 0.044
#> GSM38170 1 0.5363 0.724 0.724 0.000 0.276
#> GSM38171 1 0.3375 0.827 0.892 0.008 0.100
#> GSM38172 1 0.5541 0.691 0.740 0.008 0.252
#> GSM38173 1 0.1163 0.833 0.972 0.000 0.028
#> GSM38174 1 0.3129 0.822 0.904 0.008 0.088
#> GSM38175 1 0.3539 0.827 0.888 0.012 0.100
#> GSM38176 1 0.3375 0.827 0.892 0.008 0.100
#> GSM38177 1 0.3043 0.820 0.908 0.008 0.084
#> GSM38178 1 0.1643 0.831 0.956 0.000 0.044
#> GSM38179 1 0.3116 0.827 0.892 0.000 0.108
#> GSM38180 1 0.3116 0.827 0.892 0.000 0.108
#> GSM38181 3 0.2537 0.900 0.080 0.000 0.920
#> GSM38182 1 0.3551 0.829 0.868 0.000 0.132
#> GSM38183 1 0.3375 0.827 0.892 0.008 0.100
#> GSM38184 2 0.0848 0.992 0.008 0.984 0.008
#> GSM38185 1 0.5331 0.794 0.824 0.076 0.100
#> GSM38186 1 0.1832 0.840 0.956 0.008 0.036
#> GSM38187 1 0.3192 0.826 0.888 0.000 0.112
#> GSM38188 1 0.3550 0.822 0.896 0.080 0.024
#> GSM38189 1 0.1031 0.836 0.976 0.000 0.024
#> GSM38190 1 0.1832 0.830 0.956 0.008 0.036
#> GSM38191 1 0.7353 0.497 0.632 0.316 0.052
#> GSM38192 1 0.5243 0.797 0.828 0.072 0.100
#> GSM38193 2 0.1170 0.990 0.008 0.976 0.016
#> GSM38194 1 0.7353 0.497 0.632 0.316 0.052
#> GSM38195 1 0.3551 0.829 0.868 0.000 0.132
#> GSM38196 1 0.3965 0.812 0.860 0.008 0.132
#> GSM38197 1 0.5416 0.791 0.820 0.080 0.100
#> GSM38198 1 0.4645 0.756 0.816 0.008 0.176
#> GSM38199 3 0.6079 0.201 0.388 0.000 0.612
#> GSM38200 2 0.0424 0.994 0.008 0.992 0.000
#> GSM38201 1 0.6513 0.315 0.592 0.008 0.400
#> GSM38202 1 0.5335 0.691 0.760 0.008 0.232
#> GSM38203 3 0.1643 0.907 0.044 0.000 0.956
#> GSM38204 3 0.2066 0.915 0.060 0.000 0.940
#> GSM38205 3 0.1643 0.907 0.044 0.000 0.956
#> GSM38206 3 0.1860 0.915 0.052 0.000 0.948
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0336 0.9550 0.008 0.992 0.000 0.000
#> GSM38156 2 0.0336 0.9550 0.008 0.992 0.000 0.000
#> GSM38157 2 0.0336 0.9550 0.008 0.992 0.000 0.000
#> GSM38158 2 0.1617 0.9451 0.008 0.956 0.012 0.024
#> GSM38159 2 0.0937 0.9533 0.012 0.976 0.000 0.012
#> GSM38160 2 0.2843 0.9270 0.000 0.892 0.020 0.088
#> GSM38161 2 0.3444 0.9227 0.012 0.868 0.016 0.104
#> GSM38162 4 0.5568 0.7199 0.152 0.000 0.120 0.728
#> GSM38163 1 0.0859 0.7004 0.980 0.004 0.008 0.008
#> GSM38164 1 0.5292 0.0814 0.512 0.000 0.008 0.480
#> GSM38165 3 0.2363 0.9040 0.056 0.000 0.920 0.024
#> GSM38166 3 0.2385 0.9038 0.052 0.000 0.920 0.028
#> GSM38167 4 0.6203 0.4712 0.388 0.004 0.048 0.560
#> GSM38168 4 0.5675 0.7220 0.188 0.004 0.088 0.720
#> GSM38169 1 0.5292 0.0814 0.512 0.000 0.008 0.480
#> GSM38170 1 0.6795 0.3501 0.624 0.004 0.184 0.188
#> GSM38171 1 0.0524 0.7007 0.988 0.008 0.000 0.004
#> GSM38172 4 0.4462 0.6771 0.132 0.000 0.064 0.804
#> GSM38173 1 0.5273 0.1401 0.536 0.000 0.008 0.456
#> GSM38174 4 0.6334 0.4680 0.388 0.008 0.048 0.556
#> GSM38175 1 0.1182 0.6922 0.968 0.016 0.000 0.016
#> GSM38176 1 0.0672 0.7009 0.984 0.008 0.000 0.008
#> GSM38177 4 0.5374 0.6861 0.244 0.000 0.052 0.704
#> GSM38178 1 0.5296 0.0460 0.500 0.000 0.008 0.492
#> GSM38179 1 0.0712 0.7002 0.984 0.004 0.008 0.004
#> GSM38180 1 0.0712 0.7002 0.984 0.004 0.008 0.004
#> GSM38181 3 0.2773 0.8904 0.072 0.000 0.900 0.028
#> GSM38182 1 0.5597 0.3870 0.680 0.008 0.036 0.276
#> GSM38183 1 0.0524 0.7005 0.988 0.008 0.000 0.004
#> GSM38184 2 0.1617 0.9451 0.008 0.956 0.012 0.024
#> GSM38185 1 0.1520 0.6881 0.956 0.020 0.000 0.024
#> GSM38186 1 0.1174 0.6945 0.968 0.012 0.000 0.020
#> GSM38187 1 0.0524 0.7002 0.988 0.004 0.008 0.000
#> GSM38188 1 0.6774 0.3083 0.600 0.104 0.008 0.288
#> GSM38189 1 0.5294 -0.0395 0.508 0.000 0.008 0.484
#> GSM38190 1 0.5461 0.0747 0.508 0.008 0.004 0.480
#> GSM38191 4 0.7718 0.2492 0.260 0.180 0.020 0.540
#> GSM38192 1 0.0927 0.6943 0.976 0.016 0.000 0.008
#> GSM38193 2 0.3171 0.9206 0.004 0.876 0.016 0.104
#> GSM38194 4 0.6785 0.4074 0.156 0.176 0.016 0.652
#> GSM38195 1 0.5597 0.3870 0.680 0.008 0.036 0.276
#> GSM38196 4 0.6251 0.4872 0.380 0.004 0.052 0.564
#> GSM38197 1 0.1174 0.6896 0.968 0.020 0.000 0.012
#> GSM38198 4 0.5594 0.7237 0.180 0.000 0.100 0.720
#> GSM38199 3 0.6682 0.2127 0.112 0.000 0.576 0.312
#> GSM38200 2 0.1545 0.9475 0.000 0.952 0.008 0.040
#> GSM38201 4 0.5495 0.6793 0.096 0.000 0.176 0.728
#> GSM38202 4 0.5369 0.7196 0.144 0.000 0.112 0.744
#> GSM38203 3 0.1624 0.8950 0.028 0.000 0.952 0.020
#> GSM38204 3 0.1807 0.9070 0.052 0.000 0.940 0.008
#> GSM38205 3 0.1624 0.8950 0.028 0.000 0.952 0.020
#> GSM38206 3 0.1807 0.9070 0.052 0.000 0.940 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0162 0.9173 0.004 0.996 0.000 0.000 0.000
#> GSM38156 2 0.0162 0.9173 0.004 0.996 0.000 0.000 0.000
#> GSM38157 2 0.0162 0.9173 0.004 0.996 0.000 0.000 0.000
#> GSM38158 2 0.1168 0.9081 0.000 0.960 0.008 0.000 0.032
#> GSM38159 2 0.0703 0.9129 0.024 0.976 0.000 0.000 0.000
#> GSM38160 2 0.3914 0.8599 0.000 0.780 0.016 0.012 0.192
#> GSM38161 2 0.3961 0.8586 0.004 0.780 0.016 0.008 0.192
#> GSM38162 4 0.1403 0.6054 0.024 0.000 0.024 0.952 0.000
#> GSM38163 1 0.0798 0.9712 0.976 0.000 0.000 0.008 0.016
#> GSM38164 5 0.6698 0.3991 0.248 0.000 0.000 0.340 0.412
#> GSM38165 3 0.1869 0.9188 0.016 0.000 0.936 0.012 0.036
#> GSM38166 3 0.2374 0.9129 0.016 0.000 0.912 0.020 0.052
#> GSM38167 4 0.7412 0.2037 0.164 0.000 0.060 0.440 0.336
#> GSM38168 4 0.1403 0.6054 0.024 0.000 0.024 0.952 0.000
#> GSM38169 5 0.6698 0.3991 0.248 0.000 0.000 0.340 0.412
#> GSM38170 5 0.8422 -0.0336 0.272 0.000 0.168 0.224 0.336
#> GSM38171 1 0.0693 0.9701 0.980 0.000 0.000 0.012 0.008
#> GSM38172 4 0.4565 -0.0328 0.012 0.000 0.000 0.580 0.408
#> GSM38173 5 0.6785 0.3945 0.312 0.000 0.000 0.300 0.388
#> GSM38174 4 0.7463 0.1751 0.160 0.000 0.064 0.420 0.356
#> GSM38175 1 0.0451 0.9676 0.988 0.000 0.000 0.004 0.008
#> GSM38176 1 0.0798 0.9712 0.976 0.000 0.000 0.008 0.016
#> GSM38177 4 0.1442 0.6003 0.032 0.000 0.012 0.952 0.004
#> GSM38178 5 0.6602 0.3697 0.216 0.000 0.000 0.360 0.424
#> GSM38179 1 0.0290 0.9725 0.992 0.000 0.000 0.008 0.000
#> GSM38180 1 0.0693 0.9701 0.980 0.000 0.000 0.012 0.008
#> GSM38181 3 0.2374 0.9129 0.016 0.000 0.912 0.020 0.052
#> GSM38182 5 0.7763 -0.0239 0.280 0.000 0.060 0.280 0.380
#> GSM38183 1 0.0693 0.9720 0.980 0.000 0.000 0.008 0.012
#> GSM38184 2 0.1329 0.9065 0.004 0.956 0.008 0.000 0.032
#> GSM38185 1 0.1314 0.9510 0.960 0.004 0.004 0.008 0.024
#> GSM38186 1 0.0798 0.9667 0.976 0.000 0.000 0.016 0.008
#> GSM38187 1 0.0955 0.9678 0.968 0.000 0.000 0.004 0.028
#> GSM38188 5 0.8481 0.0208 0.252 0.112 0.012 0.264 0.360
#> GSM38189 5 0.6889 0.1844 0.232 0.000 0.008 0.340 0.420
#> GSM38190 5 0.6706 0.4019 0.256 0.000 0.000 0.328 0.416
#> GSM38191 5 0.6973 0.2506 0.084 0.100 0.008 0.220 0.588
#> GSM38192 1 0.0794 0.9649 0.972 0.000 0.000 0.000 0.028
#> GSM38193 2 0.3961 0.8586 0.004 0.780 0.016 0.008 0.192
#> GSM38194 5 0.6590 0.1894 0.036 0.104 0.008 0.268 0.584
#> GSM38195 5 0.7763 -0.0239 0.280 0.000 0.060 0.280 0.380
#> GSM38196 4 0.7436 0.2075 0.160 0.000 0.064 0.440 0.336
#> GSM38197 1 0.1168 0.9568 0.960 0.008 0.000 0.000 0.032
#> GSM38198 4 0.1403 0.6054 0.024 0.000 0.024 0.952 0.000
#> GSM38199 3 0.6074 0.4273 0.028 0.000 0.616 0.256 0.100
#> GSM38200 2 0.2811 0.8958 0.000 0.876 0.012 0.012 0.100
#> GSM38201 4 0.1646 0.5983 0.020 0.000 0.032 0.944 0.004
#> GSM38202 4 0.4473 0.4739 0.024 0.000 0.044 0.772 0.160
#> GSM38203 3 0.1059 0.9197 0.008 0.000 0.968 0.020 0.004
#> GSM38204 3 0.0912 0.9219 0.016 0.000 0.972 0.012 0.000
#> GSM38205 3 0.1059 0.9197 0.008 0.000 0.968 0.020 0.004
#> GSM38206 3 0.0912 0.9219 0.016 0.000 0.972 0.012 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0146 0.8476 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38156 2 0.0146 0.8478 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38157 2 0.0146 0.8478 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38158 2 0.1391 0.8358 0.000 0.944 0.000 0.000 0.016 0.040
#> GSM38159 2 0.1080 0.8397 0.032 0.960 0.000 0.000 0.004 0.004
#> GSM38160 2 0.5123 0.7062 0.000 0.588 0.004 0.004 0.328 0.076
#> GSM38161 2 0.4686 0.6991 0.004 0.588 0.000 0.000 0.364 0.044
#> GSM38162 4 0.0405 0.8868 0.000 0.000 0.008 0.988 0.004 0.000
#> GSM38163 1 0.0837 0.9742 0.972 0.000 0.000 0.004 0.004 0.020
#> GSM38164 5 0.6954 0.7932 0.156 0.000 0.000 0.168 0.496 0.180
#> GSM38165 3 0.2971 0.8731 0.000 0.000 0.844 0.000 0.052 0.104
#> GSM38166 3 0.3045 0.8718 0.000 0.000 0.840 0.000 0.060 0.100
#> GSM38167 6 0.5571 0.6653 0.080 0.000 0.016 0.308 0.012 0.584
#> GSM38168 4 0.0291 0.8847 0.000 0.000 0.004 0.992 0.004 0.000
#> GSM38169 5 0.6907 0.7934 0.156 0.000 0.000 0.168 0.504 0.172
#> GSM38170 6 0.6498 0.6074 0.136 0.000 0.072 0.108 0.060 0.624
#> GSM38171 1 0.0748 0.9787 0.976 0.000 0.000 0.004 0.004 0.016
#> GSM38172 5 0.5692 0.5964 0.000 0.000 0.000 0.320 0.500 0.180
#> GSM38173 5 0.7036 0.7539 0.188 0.000 0.000 0.148 0.480 0.184
#> GSM38174 6 0.5386 0.6919 0.080 0.000 0.016 0.264 0.012 0.628
#> GSM38175 1 0.0363 0.9808 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM38176 1 0.0551 0.9785 0.984 0.000 0.000 0.004 0.004 0.008
#> GSM38177 4 0.0653 0.8721 0.004 0.000 0.004 0.980 0.000 0.012
#> GSM38178 5 0.6855 0.7832 0.132 0.000 0.000 0.172 0.508 0.188
#> GSM38179 1 0.0508 0.9809 0.984 0.000 0.000 0.004 0.000 0.012
#> GSM38180 1 0.0405 0.9809 0.988 0.000 0.000 0.004 0.000 0.008
#> GSM38181 3 0.3186 0.8701 0.004 0.000 0.836 0.000 0.060 0.100
#> GSM38182 6 0.5711 0.7253 0.196 0.000 0.012 0.136 0.024 0.632
#> GSM38183 1 0.0146 0.9808 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM38184 2 0.1461 0.8359 0.000 0.940 0.000 0.000 0.016 0.044
#> GSM38185 1 0.0909 0.9726 0.968 0.000 0.000 0.000 0.012 0.020
#> GSM38186 1 0.0603 0.9774 0.980 0.000 0.000 0.004 0.000 0.016
#> GSM38187 1 0.0870 0.9769 0.972 0.000 0.000 0.004 0.012 0.012
#> GSM38188 6 0.7262 0.6573 0.176 0.084 0.000 0.148 0.060 0.532
#> GSM38189 6 0.6704 0.0308 0.112 0.000 0.000 0.148 0.220 0.520
#> GSM38190 5 0.6955 0.7932 0.160 0.000 0.000 0.164 0.496 0.180
#> GSM38191 5 0.2791 0.5458 0.024 0.028 0.000 0.064 0.880 0.004
#> GSM38192 1 0.0622 0.9761 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM38193 2 0.4686 0.6991 0.004 0.588 0.000 0.000 0.364 0.044
#> GSM38194 5 0.2823 0.5454 0.020 0.028 0.000 0.072 0.876 0.004
#> GSM38195 6 0.5796 0.7259 0.196 0.000 0.016 0.136 0.024 0.628
#> GSM38196 6 0.5571 0.6653 0.080 0.000 0.016 0.308 0.012 0.584
#> GSM38197 1 0.0820 0.9721 0.972 0.000 0.000 0.000 0.016 0.012
#> GSM38198 4 0.0405 0.8868 0.000 0.000 0.008 0.988 0.004 0.000
#> GSM38199 3 0.6282 0.5388 0.004 0.000 0.588 0.116 0.092 0.200
#> GSM38200 2 0.3815 0.8034 0.000 0.792 0.004 0.004 0.124 0.076
#> GSM38201 4 0.0405 0.8868 0.000 0.000 0.008 0.988 0.004 0.000
#> GSM38202 4 0.5240 0.1442 0.000 0.000 0.012 0.576 0.080 0.332
#> GSM38203 3 0.0291 0.8873 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38204 3 0.0291 0.8881 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM38205 3 0.0291 0.8873 0.000 0.000 0.992 0.004 0.004 0.000
#> GSM38206 3 0.0146 0.8887 0.000 0.000 0.996 0.000 0.000 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> SD:kmeans 50 7.66e-08 2
#> SD:kmeans 48 4.64e-10 3
#> SD:kmeans 36 6.33e-06 4
#> SD:kmeans 34 8.14e-06 5
#> SD:kmeans 50 2.11e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.732 0.840 0.939 0.4917 0.509 0.509
#> 3 3 0.602 0.830 0.891 0.3684 0.729 0.510
#> 4 4 0.615 0.694 0.833 0.1289 0.833 0.546
#> 5 5 0.715 0.702 0.816 0.0632 0.919 0.690
#> 6 6 0.760 0.666 0.798 0.0362 0.931 0.680
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
#> GSM38155 2 0.0000 0.9242 0.000 1.000
#> GSM38156 2 0.0000 0.9242 0.000 1.000
#> GSM38157 2 0.0000 0.9242 0.000 1.000
#> GSM38158 2 0.0000 0.9242 0.000 1.000
#> GSM38159 2 0.0000 0.9242 0.000 1.000
#> GSM38160 2 0.0000 0.9242 0.000 1.000
#> GSM38161 2 0.0000 0.9242 0.000 1.000
#> GSM38162 1 0.0000 0.9317 1.000 0.000
#> GSM38163 1 0.1843 0.9121 0.972 0.028
#> GSM38164 1 0.0000 0.9317 1.000 0.000
#> GSM38165 1 0.0000 0.9317 1.000 0.000
#> GSM38166 1 0.0000 0.9317 1.000 0.000
#> GSM38167 1 0.0000 0.9317 1.000 0.000
#> GSM38168 1 0.5629 0.8160 0.868 0.132
#> GSM38169 1 0.0000 0.9317 1.000 0.000
#> GSM38170 1 0.0000 0.9317 1.000 0.000
#> GSM38171 2 0.9988 0.0717 0.480 0.520
#> GSM38172 1 0.0000 0.9317 1.000 0.000
#> GSM38173 1 0.7674 0.6924 0.776 0.224
#> GSM38174 1 0.0672 0.9266 0.992 0.008
#> GSM38175 2 0.0000 0.9242 0.000 1.000
#> GSM38176 2 0.9970 0.1155 0.468 0.532
#> GSM38177 1 0.0000 0.9317 1.000 0.000
#> GSM38178 1 0.7602 0.7019 0.780 0.220
#> GSM38179 1 0.0000 0.9317 1.000 0.000
#> GSM38180 1 0.6712 0.7623 0.824 0.176
#> GSM38181 1 0.0000 0.9317 1.000 0.000
#> GSM38182 1 0.8081 0.6552 0.752 0.248
#> GSM38183 2 0.9815 0.2594 0.420 0.580
#> GSM38184 2 0.0000 0.9242 0.000 1.000
#> GSM38185 2 0.0000 0.9242 0.000 1.000
#> GSM38186 1 0.9909 0.1504 0.556 0.444
#> GSM38187 1 0.0000 0.9317 1.000 0.000
#> GSM38188 2 0.0000 0.9242 0.000 1.000
#> GSM38189 1 0.0000 0.9317 1.000 0.000
#> GSM38190 2 0.0000 0.9242 0.000 1.000
#> GSM38191 2 0.0000 0.9242 0.000 1.000
#> GSM38192 2 0.0000 0.9242 0.000 1.000
#> GSM38193 2 0.0000 0.9242 0.000 1.000
#> GSM38194 2 0.0000 0.9242 0.000 1.000
#> GSM38195 1 0.9170 0.4923 0.668 0.332
#> GSM38196 1 0.0000 0.9317 1.000 0.000
#> GSM38197 2 0.0000 0.9242 0.000 1.000
#> GSM38198 1 0.0000 0.9317 1.000 0.000
#> GSM38199 1 0.0000 0.9317 1.000 0.000
#> GSM38200 2 0.0000 0.9242 0.000 1.000
#> GSM38201 1 0.0000 0.9317 1.000 0.000
#> GSM38202 1 0.0000 0.9317 1.000 0.000
#> GSM38203 1 0.0000 0.9317 1.000 0.000
#> GSM38204 1 0.0000 0.9317 1.000 0.000
#> GSM38205 1 0.0000 0.9317 1.000 0.000
#> GSM38206 1 0.0000 0.9317 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38159 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38160 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38162 3 0.3482 0.847 0.128 0.000 0.872
#> GSM38163 1 0.2959 0.821 0.900 0.000 0.100
#> GSM38164 1 0.4235 0.747 0.824 0.000 0.176
#> GSM38165 3 0.1411 0.871 0.036 0.000 0.964
#> GSM38166 3 0.1411 0.871 0.036 0.000 0.964
#> GSM38167 3 0.4842 0.787 0.224 0.000 0.776
#> GSM38168 3 0.7102 0.722 0.132 0.144 0.724
#> GSM38169 1 0.2356 0.812 0.928 0.000 0.072
#> GSM38170 3 0.3412 0.843 0.124 0.000 0.876
#> GSM38171 1 0.2918 0.837 0.924 0.032 0.044
#> GSM38172 3 0.4002 0.831 0.160 0.000 0.840
#> GSM38173 1 0.1950 0.824 0.952 0.008 0.040
#> GSM38174 3 0.4931 0.783 0.232 0.000 0.768
#> GSM38175 1 0.4452 0.742 0.808 0.192 0.000
#> GSM38176 1 0.2434 0.839 0.940 0.036 0.024
#> GSM38177 3 0.5216 0.752 0.260 0.000 0.740
#> GSM38178 1 0.5734 0.741 0.788 0.048 0.164
#> GSM38179 1 0.2400 0.835 0.932 0.004 0.064
#> GSM38180 1 0.2584 0.832 0.928 0.008 0.064
#> GSM38181 3 0.2356 0.858 0.072 0.000 0.928
#> GSM38182 3 0.6588 0.697 0.208 0.060 0.732
#> GSM38183 1 0.2703 0.837 0.928 0.056 0.016
#> GSM38184 2 0.0237 0.956 0.004 0.996 0.000
#> GSM38185 2 0.4974 0.658 0.236 0.764 0.000
#> GSM38186 1 0.3155 0.838 0.916 0.040 0.044
#> GSM38187 1 0.5621 0.618 0.692 0.000 0.308
#> GSM38188 2 0.4179 0.852 0.052 0.876 0.072
#> GSM38189 1 0.6008 0.477 0.664 0.004 0.332
#> GSM38190 1 0.6684 0.568 0.676 0.292 0.032
#> GSM38191 2 0.1031 0.943 0.024 0.976 0.000
#> GSM38192 1 0.5621 0.579 0.692 0.308 0.000
#> GSM38193 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38194 2 0.2749 0.900 0.064 0.924 0.012
#> GSM38195 3 0.6910 0.704 0.144 0.120 0.736
#> GSM38196 3 0.2448 0.870 0.076 0.000 0.924
#> GSM38197 2 0.2550 0.917 0.040 0.936 0.024
#> GSM38198 3 0.3482 0.847 0.128 0.000 0.872
#> GSM38199 3 0.1529 0.873 0.040 0.000 0.960
#> GSM38200 2 0.0000 0.958 0.000 1.000 0.000
#> GSM38201 3 0.2711 0.858 0.088 0.000 0.912
#> GSM38202 3 0.2356 0.865 0.072 0.000 0.928
#> GSM38203 3 0.1411 0.871 0.036 0.000 0.964
#> GSM38204 3 0.1411 0.871 0.036 0.000 0.964
#> GSM38205 3 0.1411 0.871 0.036 0.000 0.964
#> GSM38206 3 0.1411 0.871 0.036 0.000 0.964
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38160 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38162 4 0.4098 0.635 0.012 0.000 0.204 0.784
#> GSM38163 1 0.1661 0.886 0.944 0.000 0.052 0.004
#> GSM38164 4 0.5050 0.657 0.176 0.000 0.068 0.756
#> GSM38165 3 0.0336 0.821 0.008 0.000 0.992 0.000
#> GSM38166 3 0.0188 0.822 0.004 0.000 0.996 0.000
#> GSM38167 4 0.6626 0.160 0.092 0.000 0.364 0.544
#> GSM38168 4 0.3736 0.661 0.012 0.016 0.124 0.848
#> GSM38169 4 0.4838 0.593 0.252 0.000 0.024 0.724
#> GSM38170 3 0.4261 0.740 0.112 0.000 0.820 0.068
#> GSM38171 1 0.1484 0.900 0.960 0.004 0.020 0.016
#> GSM38172 4 0.4462 0.659 0.044 0.000 0.164 0.792
#> GSM38173 4 0.5833 0.276 0.440 0.004 0.024 0.532
#> GSM38174 4 0.6058 0.315 0.072 0.000 0.296 0.632
#> GSM38175 1 0.1902 0.880 0.932 0.064 0.000 0.004
#> GSM38176 1 0.0336 0.898 0.992 0.008 0.000 0.000
#> GSM38177 4 0.5119 0.643 0.112 0.000 0.124 0.764
#> GSM38178 4 0.4587 0.671 0.128 0.016 0.044 0.812
#> GSM38179 1 0.1406 0.899 0.960 0.000 0.016 0.024
#> GSM38180 1 0.1256 0.899 0.964 0.000 0.028 0.008
#> GSM38181 3 0.2032 0.802 0.036 0.000 0.936 0.028
#> GSM38182 3 0.7541 0.510 0.132 0.032 0.576 0.260
#> GSM38183 1 0.1256 0.898 0.964 0.008 0.000 0.028
#> GSM38184 2 0.0336 0.880 0.008 0.992 0.000 0.000
#> GSM38185 2 0.5902 0.185 0.428 0.540 0.004 0.028
#> GSM38186 1 0.3285 0.847 0.884 0.020 0.016 0.080
#> GSM38187 1 0.4936 0.447 0.624 0.000 0.372 0.004
#> GSM38188 2 0.6566 0.609 0.048 0.684 0.068 0.200
#> GSM38189 4 0.5282 0.643 0.136 0.004 0.100 0.760
#> GSM38190 4 0.7166 0.470 0.244 0.164 0.008 0.584
#> GSM38191 2 0.4008 0.767 0.020 0.832 0.012 0.136
#> GSM38192 1 0.2473 0.868 0.908 0.080 0.012 0.000
#> GSM38193 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38194 2 0.5247 0.557 0.032 0.684 0.000 0.284
#> GSM38195 3 0.7542 0.558 0.104 0.068 0.616 0.212
#> GSM38196 3 0.6257 0.154 0.056 0.000 0.508 0.436
#> GSM38197 2 0.6477 0.592 0.164 0.668 0.160 0.008
#> GSM38198 4 0.3895 0.645 0.012 0.000 0.184 0.804
#> GSM38199 3 0.3695 0.672 0.016 0.000 0.828 0.156
#> GSM38200 2 0.0000 0.884 0.000 1.000 0.000 0.000
#> GSM38201 4 0.4522 0.534 0.000 0.000 0.320 0.680
#> GSM38202 4 0.5163 0.214 0.004 0.000 0.480 0.516
#> GSM38203 3 0.0592 0.817 0.000 0.000 0.984 0.016
#> GSM38204 3 0.0376 0.822 0.004 0.000 0.992 0.004
#> GSM38205 3 0.0469 0.818 0.000 0.000 0.988 0.012
#> GSM38206 3 0.0188 0.822 0.004 0.000 0.996 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.8283 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.8283 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.8283 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.8283 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.0510 0.8222 0.016 0.984 0.000 0.000 0.000
#> GSM38160 2 0.0000 0.8283 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0162 0.8274 0.000 0.996 0.000 0.004 0.000
#> GSM38162 4 0.4893 0.6015 0.000 0.000 0.088 0.704 0.208
#> GSM38163 1 0.2339 0.8635 0.912 0.000 0.028 0.008 0.052
#> GSM38164 5 0.4131 0.7803 0.064 0.000 0.024 0.100 0.812
#> GSM38165 3 0.0162 0.9097 0.000 0.000 0.996 0.000 0.004
#> GSM38166 3 0.0898 0.9015 0.000 0.000 0.972 0.020 0.008
#> GSM38167 4 0.4261 0.6138 0.048 0.000 0.060 0.812 0.080
#> GSM38168 4 0.4393 0.6167 0.000 0.004 0.052 0.752 0.192
#> GSM38169 5 0.3700 0.7901 0.084 0.000 0.008 0.076 0.832
#> GSM38170 3 0.5953 0.5923 0.116 0.000 0.676 0.156 0.052
#> GSM38171 1 0.2171 0.8735 0.924 0.004 0.008 0.020 0.044
#> GSM38172 5 0.4705 0.6419 0.008 0.000 0.076 0.172 0.744
#> GSM38173 5 0.4630 0.7022 0.216 0.000 0.016 0.036 0.732
#> GSM38174 4 0.4220 0.5770 0.028 0.000 0.044 0.800 0.128
#> GSM38175 1 0.1989 0.8711 0.932 0.032 0.000 0.020 0.016
#> GSM38176 1 0.1116 0.8767 0.964 0.004 0.000 0.004 0.028
#> GSM38177 4 0.4823 0.6027 0.044 0.000 0.032 0.744 0.180
#> GSM38178 5 0.3477 0.7683 0.040 0.004 0.008 0.100 0.848
#> GSM38179 1 0.1948 0.8751 0.932 0.000 0.008 0.024 0.036
#> GSM38180 1 0.1670 0.8729 0.936 0.000 0.000 0.012 0.052
#> GSM38181 3 0.1997 0.8810 0.016 0.000 0.932 0.024 0.028
#> GSM38182 4 0.7630 0.4196 0.064 0.024 0.232 0.528 0.152
#> GSM38183 1 0.1626 0.8754 0.940 0.000 0.000 0.016 0.044
#> GSM38184 2 0.0566 0.8224 0.012 0.984 0.000 0.004 0.000
#> GSM38185 2 0.6508 0.0616 0.416 0.476 0.004 0.048 0.056
#> GSM38186 1 0.4787 0.7472 0.772 0.004 0.024 0.112 0.088
#> GSM38187 1 0.5209 0.3945 0.588 0.000 0.368 0.008 0.036
#> GSM38188 2 0.7753 0.2394 0.032 0.484 0.036 0.252 0.196
#> GSM38189 5 0.4754 0.6088 0.040 0.004 0.028 0.172 0.756
#> GSM38190 5 0.4394 0.7436 0.112 0.084 0.000 0.016 0.788
#> GSM38191 2 0.5508 0.4819 0.008 0.648 0.024 0.036 0.284
#> GSM38192 1 0.1988 0.8602 0.928 0.048 0.000 0.016 0.008
#> GSM38193 2 0.0162 0.8274 0.000 0.996 0.000 0.004 0.000
#> GSM38194 2 0.5747 0.1336 0.000 0.504 0.000 0.088 0.408
#> GSM38195 4 0.7421 0.4020 0.048 0.024 0.248 0.536 0.144
#> GSM38196 4 0.4439 0.6274 0.008 0.000 0.176 0.760 0.056
#> GSM38197 2 0.6863 0.5020 0.192 0.600 0.152 0.016 0.040
#> GSM38198 4 0.4868 0.6171 0.004 0.000 0.084 0.720 0.192
#> GSM38199 3 0.3947 0.7762 0.020 0.000 0.824 0.072 0.084
#> GSM38200 2 0.0000 0.8283 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.5707 0.5781 0.000 0.000 0.216 0.624 0.160
#> GSM38202 4 0.6970 0.3276 0.008 0.000 0.368 0.372 0.252
#> GSM38203 3 0.0404 0.9075 0.000 0.000 0.988 0.012 0.000
#> GSM38204 3 0.0000 0.9101 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.1197 0.8865 0.000 0.000 0.952 0.048 0.000
#> GSM38206 3 0.0000 0.9101 0.000 0.000 1.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
#> GSM38155 2 0.0260 0.8550 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38156 2 0.0405 0.8557 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM38157 2 0.0547 0.8543 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM38158 2 0.0000 0.8554 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38159 2 0.1844 0.8244 0.048 0.924 0.000 0.000 0.004 0.024
#> GSM38160 2 0.1382 0.8496 0.000 0.948 0.000 0.008 0.008 0.036
#> GSM38161 2 0.1750 0.8435 0.000 0.932 0.000 0.012 0.016 0.040
#> GSM38162 4 0.1675 0.8043 0.000 0.000 0.032 0.936 0.024 0.008
#> GSM38163 1 0.3873 0.7453 0.828 0.000 0.044 0.032 0.056 0.040
#> GSM38164 5 0.3278 0.7363 0.032 0.004 0.008 0.088 0.852 0.016
#> GSM38165 3 0.0520 0.8903 0.000 0.000 0.984 0.000 0.008 0.008
#> GSM38166 3 0.1138 0.8858 0.000 0.000 0.960 0.004 0.012 0.024
#> GSM38167 6 0.6242 0.4428 0.064 0.000 0.032 0.336 0.040 0.528
#> GSM38168 4 0.1871 0.7967 0.000 0.000 0.016 0.928 0.032 0.024
#> GSM38169 5 0.2753 0.7362 0.028 0.000 0.004 0.080 0.876 0.012
#> GSM38170 3 0.6180 0.4600 0.056 0.000 0.604 0.056 0.044 0.240
#> GSM38171 1 0.3303 0.7628 0.848 0.000 0.020 0.004 0.060 0.068
#> GSM38172 5 0.4555 0.5875 0.000 0.000 0.040 0.272 0.672 0.016
#> GSM38173 5 0.4988 0.6548 0.128 0.004 0.008 0.068 0.736 0.056
#> GSM38174 6 0.5171 0.5259 0.016 0.000 0.024 0.280 0.040 0.640
#> GSM38175 1 0.2926 0.7652 0.876 0.048 0.000 0.008 0.020 0.048
#> GSM38176 1 0.1716 0.7740 0.932 0.000 0.000 0.004 0.028 0.036
#> GSM38177 4 0.3976 0.6953 0.028 0.000 0.024 0.812 0.040 0.096
#> GSM38178 5 0.3742 0.7216 0.012 0.008 0.012 0.084 0.828 0.056
#> GSM38179 1 0.2430 0.7713 0.900 0.000 0.004 0.012 0.036 0.048
#> GSM38180 1 0.3021 0.7676 0.860 0.000 0.020 0.000 0.044 0.076
#> GSM38181 3 0.0922 0.8845 0.000 0.000 0.968 0.004 0.004 0.024
#> GSM38182 6 0.4995 0.5820 0.020 0.044 0.080 0.040 0.048 0.768
#> GSM38183 1 0.2137 0.7719 0.912 0.000 0.000 0.012 0.048 0.028
#> GSM38184 2 0.1003 0.8427 0.028 0.964 0.000 0.000 0.004 0.004
#> GSM38185 1 0.6935 0.1456 0.384 0.368 0.004 0.012 0.032 0.200
#> GSM38186 1 0.6789 0.5487 0.600 0.036 0.016 0.076 0.092 0.180
#> GSM38187 1 0.6493 0.3083 0.500 0.000 0.344 0.032 0.044 0.080
#> GSM38188 6 0.7147 0.0833 0.016 0.388 0.020 0.076 0.084 0.416
#> GSM38189 5 0.6289 0.4935 0.028 0.000 0.044 0.116 0.596 0.216
#> GSM38190 5 0.3615 0.7055 0.016 0.080 0.000 0.032 0.836 0.036
#> GSM38191 2 0.6615 -0.0058 0.004 0.444 0.008 0.044 0.376 0.124
#> GSM38192 1 0.2953 0.7654 0.884 0.032 0.008 0.012 0.024 0.040
#> GSM38193 2 0.2186 0.8346 0.000 0.908 0.000 0.012 0.024 0.056
#> GSM38194 5 0.6330 0.1020 0.000 0.372 0.000 0.080 0.464 0.084
#> GSM38195 6 0.5312 0.5720 0.012 0.032 0.132 0.056 0.040 0.728
#> GSM38196 6 0.5440 0.4292 0.016 0.000 0.052 0.348 0.016 0.568
#> GSM38197 2 0.8409 0.1123 0.204 0.404 0.212 0.024 0.076 0.080
#> GSM38198 4 0.1518 0.7995 0.000 0.000 0.024 0.944 0.008 0.024
#> GSM38199 3 0.4886 0.7296 0.028 0.000 0.756 0.084 0.080 0.052
#> GSM38200 2 0.0922 0.8530 0.000 0.968 0.000 0.004 0.004 0.024
#> GSM38201 4 0.2326 0.7728 0.000 0.000 0.092 0.888 0.012 0.008
#> GSM38202 4 0.7013 0.3214 0.004 0.000 0.224 0.492 0.144 0.136
#> GSM38203 3 0.0713 0.8880 0.000 0.000 0.972 0.028 0.000 0.000
#> GSM38204 3 0.0665 0.8912 0.000 0.000 0.980 0.008 0.008 0.004
#> GSM38205 3 0.1910 0.8419 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM38206 3 0.0458 0.8917 0.000 0.000 0.984 0.016 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
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 47 4.29e-04 2
#> SD:skmeans 51 1.50e-05 3
#> SD:skmeans 44 2.11e-04 4
#> SD:skmeans 44 1.16e-05 5
#> SD:skmeans 41 1.83e-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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.640 0.840 0.929 0.4797 0.517 0.517
#> 3 3 0.553 0.806 0.843 0.3397 0.803 0.631
#> 4 4 0.731 0.823 0.915 0.1384 0.875 0.665
#> 5 5 0.866 0.864 0.929 0.0958 0.869 0.562
#> 6 6 0.841 0.749 0.867 0.0383 0.941 0.723
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
#> GSM38155 2 0.0000 0.9152 0.000 1.000
#> GSM38156 2 0.1184 0.9142 0.016 0.984
#> GSM38157 2 0.0000 0.9152 0.000 1.000
#> GSM38158 2 0.0000 0.9152 0.000 1.000
#> GSM38159 2 0.0000 0.9152 0.000 1.000
#> GSM38160 2 0.0376 0.9153 0.004 0.996
#> GSM38161 2 0.0000 0.9152 0.000 1.000
#> GSM38162 1 0.0000 0.9217 1.000 0.000
#> GSM38163 2 0.2043 0.9126 0.032 0.968
#> GSM38164 1 0.0376 0.9205 0.996 0.004
#> GSM38165 1 0.9732 0.2685 0.596 0.404
#> GSM38166 2 0.7219 0.7877 0.200 0.800
#> GSM38167 1 0.0000 0.9217 1.000 0.000
#> GSM38168 1 0.0000 0.9217 1.000 0.000
#> GSM38169 1 0.9954 0.0369 0.540 0.460
#> GSM38170 1 0.6973 0.7280 0.812 0.188
#> GSM38171 2 0.2043 0.9126 0.032 0.968
#> GSM38172 1 0.0000 0.9217 1.000 0.000
#> GSM38173 2 0.7528 0.7682 0.216 0.784
#> GSM38174 1 0.0000 0.9217 1.000 0.000
#> GSM38175 2 0.0376 0.9157 0.004 0.996
#> GSM38176 2 0.0376 0.9157 0.004 0.996
#> GSM38177 1 0.0376 0.9202 0.996 0.004
#> GSM38178 2 0.9998 0.0993 0.492 0.508
#> GSM38179 2 0.2043 0.9126 0.032 0.968
#> GSM38180 2 0.2043 0.9126 0.032 0.968
#> GSM38181 2 0.6343 0.8265 0.160 0.840
#> GSM38182 2 0.6531 0.8190 0.168 0.832
#> GSM38183 2 0.0376 0.9157 0.004 0.996
#> GSM38184 2 0.0000 0.9152 0.000 1.000
#> GSM38185 2 0.0000 0.9152 0.000 1.000
#> GSM38186 2 0.9286 0.4329 0.344 0.656
#> GSM38187 2 0.2043 0.9126 0.032 0.968
#> GSM38188 2 0.7376 0.7774 0.208 0.792
#> GSM38189 1 0.0672 0.9186 0.992 0.008
#> GSM38190 2 0.6623 0.8154 0.172 0.828
#> GSM38191 2 0.1414 0.9153 0.020 0.980
#> GSM38192 2 0.0000 0.9152 0.000 1.000
#> GSM38193 2 0.3879 0.8721 0.076 0.924
#> GSM38194 1 0.5737 0.8171 0.864 0.136
#> GSM38195 2 0.4690 0.8739 0.100 0.900
#> GSM38196 1 0.0000 0.9217 1.000 0.000
#> GSM38197 2 0.0000 0.9152 0.000 1.000
#> GSM38198 1 0.0000 0.9217 1.000 0.000
#> GSM38199 1 0.0000 0.9217 1.000 0.000
#> GSM38200 2 0.0000 0.9152 0.000 1.000
#> GSM38201 1 0.0000 0.9217 1.000 0.000
#> GSM38202 1 0.0000 0.9217 1.000 0.000
#> GSM38203 1 0.1414 0.9103 0.980 0.020
#> GSM38204 2 0.3114 0.9016 0.056 0.944
#> GSM38205 1 0.0376 0.9203 0.996 0.004
#> GSM38206 1 0.4161 0.8582 0.916 0.084
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38156 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38157 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38158 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38159 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38160 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38161 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38162 3 0.3267 0.833 0.000 0.116 0.884
#> GSM38163 1 0.0237 0.831 0.996 0.000 0.004
#> GSM38164 3 0.2711 0.859 0.088 0.000 0.912
#> GSM38165 3 0.9067 0.141 0.384 0.140 0.476
#> GSM38166 1 0.5331 0.742 0.792 0.024 0.184
#> GSM38167 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38168 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38169 1 0.6305 0.118 0.516 0.000 0.484
#> GSM38170 3 0.5692 0.614 0.268 0.008 0.724
#> GSM38171 1 0.0237 0.831 0.996 0.000 0.004
#> GSM38172 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38173 1 0.4178 0.764 0.828 0.000 0.172
#> GSM38174 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38175 1 0.1529 0.815 0.960 0.040 0.000
#> GSM38176 1 0.1529 0.815 0.960 0.040 0.000
#> GSM38177 3 0.1643 0.889 0.044 0.000 0.956
#> GSM38178 1 0.6280 0.233 0.540 0.000 0.460
#> GSM38179 1 0.0237 0.831 0.996 0.000 0.004
#> GSM38180 1 0.0237 0.831 0.996 0.000 0.004
#> GSM38181 1 0.4665 0.795 0.852 0.048 0.100
#> GSM38182 1 0.3551 0.786 0.868 0.000 0.132
#> GSM38183 1 0.1529 0.815 0.960 0.040 0.000
#> GSM38184 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38185 1 0.1529 0.815 0.960 0.040 0.000
#> GSM38186 1 0.7140 0.440 0.632 0.040 0.328
#> GSM38187 1 0.0000 0.830 1.000 0.000 0.000
#> GSM38188 1 0.7027 0.719 0.724 0.104 0.172
#> GSM38189 3 0.1753 0.887 0.048 0.000 0.952
#> GSM38190 1 0.8520 0.486 0.588 0.280 0.132
#> GSM38191 1 0.2176 0.822 0.948 0.020 0.032
#> GSM38192 1 0.1643 0.811 0.956 0.044 0.000
#> GSM38193 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38194 3 0.4636 0.794 0.116 0.036 0.848
#> GSM38195 1 0.2261 0.818 0.932 0.000 0.068
#> GSM38196 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38197 1 0.1643 0.811 0.956 0.044 0.000
#> GSM38198 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38199 3 0.1950 0.889 0.040 0.008 0.952
#> GSM38200 2 0.3686 1.000 0.140 0.860 0.000
#> GSM38201 3 0.3267 0.833 0.000 0.116 0.884
#> GSM38202 3 0.1529 0.890 0.040 0.000 0.960
#> GSM38203 3 0.4099 0.820 0.008 0.140 0.852
#> GSM38204 1 0.5159 0.753 0.820 0.140 0.040
#> GSM38205 3 0.3851 0.823 0.004 0.136 0.860
#> GSM38206 3 0.6191 0.775 0.084 0.140 0.776
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0188 0.9962 0.004 0.996 0.000 0.000
#> GSM38160 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38162 4 0.3311 0.7306 0.000 0.000 0.172 0.828
#> GSM38163 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38164 4 0.3852 0.7106 0.180 0.000 0.012 0.808
#> GSM38165 3 0.0336 0.9161 0.008 0.000 0.992 0.000
#> GSM38166 3 0.3311 0.7806 0.000 0.000 0.828 0.172
#> GSM38167 4 0.1545 0.8521 0.040 0.000 0.008 0.952
#> GSM38168 4 0.0336 0.8644 0.000 0.000 0.008 0.992
#> GSM38169 1 0.5378 0.2486 0.540 0.000 0.012 0.448
#> GSM38170 4 0.5939 0.5319 0.248 0.000 0.084 0.668
#> GSM38171 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0469 0.8640 0.000 0.000 0.012 0.988
#> GSM38173 1 0.4137 0.7337 0.780 0.000 0.012 0.208
#> GSM38174 4 0.0469 0.8640 0.000 0.000 0.012 0.988
#> GSM38175 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38177 4 0.1635 0.8507 0.044 0.000 0.008 0.948
#> GSM38178 4 0.5320 0.0986 0.416 0.000 0.012 0.572
#> GSM38179 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38180 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38181 3 0.3796 0.8413 0.056 0.000 0.848 0.096
#> GSM38182 1 0.4839 0.7344 0.764 0.000 0.052 0.184
#> GSM38183 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38184 2 0.0188 0.9962 0.004 0.996 0.000 0.000
#> GSM38185 1 0.1022 0.8508 0.968 0.000 0.000 0.032
#> GSM38186 1 0.4103 0.5932 0.744 0.000 0.000 0.256
#> GSM38187 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38188 1 0.6652 0.6043 0.632 0.100 0.012 0.256
#> GSM38189 4 0.1059 0.8615 0.016 0.000 0.012 0.972
#> GSM38190 1 0.7389 0.5340 0.568 0.244 0.012 0.176
#> GSM38191 1 0.3863 0.7458 0.812 0.004 0.008 0.176
#> GSM38192 1 0.0000 0.8608 1.000 0.000 0.000 0.000
#> GSM38193 2 0.0188 0.9962 0.004 0.996 0.000 0.000
#> GSM38194 4 0.3196 0.8052 0.104 0.012 0.008 0.876
#> GSM38195 1 0.2859 0.8143 0.880 0.000 0.008 0.112
#> GSM38196 4 0.0336 0.8644 0.000 0.000 0.008 0.992
#> GSM38197 1 0.0188 0.8600 0.996 0.000 0.000 0.004
#> GSM38198 4 0.0336 0.8644 0.000 0.000 0.008 0.992
#> GSM38199 4 0.1118 0.8573 0.000 0.000 0.036 0.964
#> GSM38200 2 0.0000 0.9984 0.000 1.000 0.000 0.000
#> GSM38201 4 0.3311 0.7306 0.000 0.000 0.172 0.828
#> GSM38202 4 0.0469 0.8640 0.000 0.000 0.012 0.988
#> GSM38203 3 0.0469 0.9117 0.000 0.000 0.988 0.012
#> GSM38204 3 0.0707 0.9103 0.020 0.000 0.980 0.000
#> GSM38205 3 0.1940 0.8776 0.000 0.000 0.924 0.076
#> GSM38206 3 0.0336 0.9153 0.000 0.000 0.992 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.0162 0.996 0.004 0.996 0.000 0.000 0.000
#> GSM38160 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38162 4 0.0290 0.939 0.000 0.000 0.008 0.992 0.000
#> GSM38163 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38164 5 0.1106 0.784 0.024 0.000 0.000 0.012 0.964
#> GSM38165 3 0.0000 0.989 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0290 0.985 0.000 0.000 0.992 0.000 0.008
#> GSM38167 4 0.0000 0.941 0.000 0.000 0.000 1.000 0.000
#> GSM38168 4 0.0000 0.941 0.000 0.000 0.000 1.000 0.000
#> GSM38169 5 0.1082 0.783 0.028 0.000 0.000 0.008 0.964
#> GSM38170 5 0.5085 0.599 0.012 0.000 0.032 0.324 0.632
#> GSM38171 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38172 5 0.4171 0.389 0.000 0.000 0.000 0.396 0.604
#> GSM38173 5 0.3171 0.705 0.176 0.000 0.000 0.008 0.816
#> GSM38174 5 0.3966 0.592 0.000 0.000 0.000 0.336 0.664
#> GSM38175 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38177 4 0.0162 0.940 0.004 0.000 0.000 0.996 0.000
#> GSM38178 5 0.1043 0.781 0.000 0.000 0.000 0.040 0.960
#> GSM38179 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38180 1 0.2471 0.824 0.864 0.000 0.000 0.000 0.136
#> GSM38181 3 0.0898 0.971 0.008 0.000 0.972 0.000 0.020
#> GSM38182 5 0.3167 0.712 0.148 0.000 0.008 0.008 0.836
#> GSM38183 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38184 2 0.0162 0.996 0.004 0.996 0.000 0.000 0.000
#> GSM38185 1 0.0955 0.918 0.968 0.004 0.000 0.000 0.028
#> GSM38186 1 0.5697 0.397 0.596 0.000 0.000 0.288 0.116
#> GSM38187 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38188 5 0.0162 0.779 0.004 0.000 0.000 0.000 0.996
#> GSM38189 5 0.0609 0.782 0.000 0.000 0.000 0.020 0.980
#> GSM38190 5 0.1697 0.772 0.060 0.008 0.000 0.000 0.932
#> GSM38191 1 0.1564 0.907 0.948 0.004 0.000 0.024 0.024
#> GSM38192 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38193 2 0.0162 0.996 0.004 0.996 0.000 0.000 0.000
#> GSM38194 4 0.4021 0.772 0.076 0.008 0.000 0.808 0.108
#> GSM38195 1 0.3282 0.740 0.804 0.000 0.000 0.008 0.188
#> GSM38196 4 0.2424 0.794 0.000 0.000 0.000 0.868 0.132
#> GSM38197 1 0.0000 0.935 1.000 0.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.941 0.000 0.000 0.000 1.000 0.000
#> GSM38199 5 0.4533 0.380 0.000 0.000 0.008 0.448 0.544
#> GSM38200 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.0290 0.939 0.000 0.000 0.008 0.992 0.000
#> GSM38202 5 0.4030 0.586 0.000 0.000 0.000 0.352 0.648
#> GSM38203 3 0.0000 0.989 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 0.989 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0794 0.969 0.000 0.000 0.972 0.028 0.000
#> GSM38206 3 0.0000 0.989 0.000 0.000 1.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
#> GSM38155 2 0.0146 0.9664 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.9669 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.9669 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.9669 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38159 2 0.0146 0.9664 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM38160 2 0.2416 0.8837 0.000 0.844 0.000 0.000 0.000 0.156
#> GSM38161 2 0.0547 0.9623 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM38162 4 0.0000 0.7360 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38163 1 0.2775 0.8301 0.856 0.000 0.000 0.000 0.104 0.040
#> GSM38164 5 0.0603 0.7504 0.000 0.000 0.000 0.016 0.980 0.004
#> GSM38165 3 0.0632 0.9800 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM38166 3 0.0632 0.9800 0.000 0.000 0.976 0.000 0.000 0.024
#> GSM38167 4 0.3810 0.3143 0.000 0.000 0.000 0.572 0.000 0.428
#> GSM38168 4 0.0000 0.7360 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38169 5 0.0405 0.7465 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM38170 6 0.6344 0.5317 0.012 0.000 0.032 0.152 0.268 0.536
#> GSM38171 1 0.2775 0.8301 0.856 0.000 0.000 0.000 0.104 0.040
#> GSM38172 5 0.3817 0.0418 0.000 0.000 0.000 0.432 0.568 0.000
#> GSM38173 5 0.1480 0.7274 0.040 0.000 0.000 0.000 0.940 0.020
#> GSM38174 6 0.3201 0.7475 0.000 0.000 0.000 0.012 0.208 0.780
#> GSM38175 1 0.0146 0.8505 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38176 1 0.2775 0.8301 0.856 0.000 0.000 0.000 0.104 0.040
#> GSM38177 4 0.0000 0.7360 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38178 5 0.3003 0.6462 0.000 0.000 0.000 0.016 0.812 0.172
#> GSM38179 1 0.2775 0.8301 0.856 0.000 0.000 0.000 0.104 0.040
#> GSM38180 1 0.4624 0.3733 0.528 0.000 0.000 0.000 0.432 0.040
#> GSM38181 3 0.1036 0.9734 0.008 0.000 0.964 0.000 0.004 0.024
#> GSM38182 6 0.2941 0.7412 0.000 0.000 0.000 0.000 0.220 0.780
#> GSM38183 1 0.0363 0.8511 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38184 2 0.0146 0.9664 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM38185 1 0.0508 0.8423 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM38186 1 0.6573 0.2475 0.436 0.000 0.000 0.200 0.324 0.040
#> GSM38187 1 0.0000 0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38188 5 0.3684 0.3507 0.000 0.000 0.000 0.000 0.628 0.372
#> GSM38189 5 0.2511 0.7131 0.000 0.000 0.000 0.056 0.880 0.064
#> GSM38190 5 0.1492 0.7132 0.024 0.000 0.000 0.000 0.940 0.036
#> GSM38191 1 0.1588 0.8078 0.924 0.000 0.000 0.000 0.072 0.004
#> GSM38192 1 0.0000 0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38193 2 0.0790 0.9582 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM38194 4 0.4344 0.4677 0.012 0.004 0.000 0.660 0.308 0.016
#> GSM38195 6 0.3652 0.6235 0.188 0.000 0.000 0.000 0.044 0.768
#> GSM38196 4 0.4499 0.2723 0.000 0.000 0.000 0.540 0.032 0.428
#> GSM38197 1 0.0000 0.8498 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.7360 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38199 4 0.4685 0.4747 0.000 0.000 0.036 0.648 0.296 0.020
#> GSM38200 2 0.2260 0.8941 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM38201 4 0.0000 0.7360 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38202 4 0.4032 0.2273 0.000 0.000 0.000 0.572 0.420 0.008
#> GSM38203 3 0.0547 0.9714 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM38204 3 0.0000 0.9817 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0458 0.9746 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM38206 3 0.0000 0.9817 0.000 0.000 1.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
#> SD:pam 48 8.31e-03 2
#> SD:pam 47 4.67e-07 3
#> SD:pam 50 8.28e-09 4
#> SD:pam 49 1.46e-07 5
#> SD:pam 43 2.11e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "mclust"]
# you can also extract it by
# res = res_list["SD:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.619 0.899 0.926 0.3690 0.683 0.683
#> 3 3 1.000 0.977 0.978 0.3826 0.815 0.730
#> 4 4 0.819 0.856 0.906 0.3808 0.801 0.601
#> 5 5 0.759 0.814 0.873 0.1209 0.850 0.540
#> 6 6 0.770 0.686 0.838 0.0445 0.936 0.704
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
#> GSM38155 2 0.0000 0.995 0.000 1.000
#> GSM38156 2 0.0000 0.995 0.000 1.000
#> GSM38157 2 0.0000 0.995 0.000 1.000
#> GSM38158 2 0.0000 0.995 0.000 1.000
#> GSM38159 2 0.0672 0.990 0.008 0.992
#> GSM38160 2 0.0376 0.993 0.004 0.996
#> GSM38161 2 0.0000 0.995 0.000 1.000
#> GSM38162 1 0.0000 0.907 1.000 0.000
#> GSM38163 1 0.3879 0.905 0.924 0.076
#> GSM38164 1 0.1633 0.911 0.976 0.024
#> GSM38165 1 0.3114 0.905 0.944 0.056
#> GSM38166 1 0.3114 0.905 0.944 0.056
#> GSM38167 1 0.0000 0.907 1.000 0.000
#> GSM38168 1 0.6623 0.846 0.828 0.172
#> GSM38169 1 0.3114 0.908 0.944 0.056
#> GSM38170 1 0.2778 0.907 0.952 0.048
#> GSM38171 1 0.2778 0.911 0.952 0.048
#> GSM38172 1 0.0000 0.907 1.000 0.000
#> GSM38173 1 0.2603 0.911 0.956 0.044
#> GSM38174 1 0.5059 0.889 0.888 0.112
#> GSM38175 1 0.8327 0.770 0.736 0.264
#> GSM38176 1 0.4161 0.897 0.916 0.084
#> GSM38177 1 0.0000 0.907 1.000 0.000
#> GSM38178 1 0.2236 0.911 0.964 0.036
#> GSM38179 1 0.4022 0.903 0.920 0.080
#> GSM38180 1 0.0376 0.908 0.996 0.004
#> GSM38181 1 0.3114 0.905 0.944 0.056
#> GSM38182 1 0.4939 0.894 0.892 0.108
#> GSM38183 1 0.6148 0.858 0.848 0.152
#> GSM38184 2 0.1633 0.972 0.024 0.976
#> GSM38185 1 0.8813 0.744 0.700 0.300
#> GSM38186 1 0.6712 0.842 0.824 0.176
#> GSM38187 1 0.2423 0.908 0.960 0.040
#> GSM38188 1 0.8608 0.757 0.716 0.284
#> GSM38189 1 0.2236 0.911 0.964 0.036
#> GSM38190 1 0.2423 0.911 0.960 0.040
#> GSM38191 1 0.8713 0.751 0.708 0.292
#> GSM38192 1 0.8763 0.747 0.704 0.296
#> GSM38193 2 0.0000 0.995 0.000 1.000
#> GSM38194 1 0.8016 0.779 0.756 0.244
#> GSM38195 1 0.5519 0.887 0.872 0.128
#> GSM38196 1 0.0000 0.907 1.000 0.000
#> GSM38197 1 0.8813 0.744 0.700 0.300
#> GSM38198 1 0.0000 0.907 1.000 0.000
#> GSM38199 1 0.0000 0.907 1.000 0.000
#> GSM38200 2 0.0000 0.995 0.000 1.000
#> GSM38201 1 0.0000 0.907 1.000 0.000
#> GSM38202 1 0.0000 0.907 1.000 0.000
#> GSM38203 1 0.3114 0.905 0.944 0.056
#> GSM38204 1 0.3114 0.905 0.944 0.056
#> GSM38205 1 0.3114 0.905 0.944 0.056
#> GSM38206 1 0.3114 0.905 0.944 0.056
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38159 2 0.0237 0.993 0.004 0.996 0.000
#> GSM38160 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38162 1 0.0592 0.969 0.988 0.000 0.012
#> GSM38163 1 0.1832 0.975 0.956 0.008 0.036
#> GSM38164 1 0.0237 0.973 0.996 0.000 0.004
#> GSM38165 3 0.0000 0.988 0.000 0.000 1.000
#> GSM38166 3 0.0000 0.988 0.000 0.000 1.000
#> GSM38167 1 0.1289 0.976 0.968 0.000 0.032
#> GSM38168 1 0.0000 0.972 1.000 0.000 0.000
#> GSM38169 1 0.0000 0.972 1.000 0.000 0.000
#> GSM38170 1 0.2400 0.963 0.932 0.004 0.064
#> GSM38171 1 0.1877 0.975 0.956 0.012 0.032
#> GSM38172 1 0.0747 0.967 0.984 0.000 0.016
#> GSM38173 1 0.0237 0.973 0.996 0.000 0.004
#> GSM38174 1 0.0747 0.975 0.984 0.000 0.016
#> GSM38175 1 0.1877 0.975 0.956 0.012 0.032
#> GSM38176 1 0.1877 0.975 0.956 0.012 0.032
#> GSM38177 1 0.0237 0.973 0.996 0.000 0.004
#> GSM38178 1 0.0237 0.973 0.996 0.000 0.004
#> GSM38179 1 0.1832 0.975 0.956 0.008 0.036
#> GSM38180 1 0.1877 0.975 0.956 0.012 0.032
#> GSM38181 3 0.1643 0.930 0.044 0.000 0.956
#> GSM38182 1 0.1832 0.975 0.956 0.008 0.036
#> GSM38183 1 0.1877 0.975 0.956 0.012 0.032
#> GSM38184 2 0.0592 0.981 0.012 0.988 0.000
#> GSM38185 1 0.2806 0.959 0.928 0.040 0.032
#> GSM38186 1 0.1711 0.976 0.960 0.008 0.032
#> GSM38187 1 0.1878 0.974 0.952 0.004 0.044
#> GSM38188 1 0.2031 0.974 0.952 0.016 0.032
#> GSM38189 1 0.0237 0.973 0.996 0.000 0.004
#> GSM38190 1 0.0237 0.972 0.996 0.000 0.004
#> GSM38191 1 0.2050 0.974 0.952 0.020 0.028
#> GSM38192 1 0.2313 0.970 0.944 0.024 0.032
#> GSM38193 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38194 1 0.0237 0.971 0.996 0.004 0.000
#> GSM38195 1 0.1877 0.975 0.956 0.012 0.032
#> GSM38196 1 0.1031 0.976 0.976 0.000 0.024
#> GSM38197 1 0.2689 0.962 0.932 0.036 0.032
#> GSM38198 1 0.0424 0.971 0.992 0.000 0.008
#> GSM38199 1 0.2165 0.959 0.936 0.000 0.064
#> GSM38200 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38201 1 0.1411 0.955 0.964 0.000 0.036
#> GSM38202 1 0.0892 0.968 0.980 0.000 0.020
#> GSM38203 3 0.0000 0.988 0.000 0.000 1.000
#> GSM38204 3 0.0000 0.988 0.000 0.000 1.000
#> GSM38205 3 0.0000 0.988 0.000 0.000 1.000
#> GSM38206 3 0.0000 0.988 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0336 0.9895 0.008 0.992 0.000 0.000
#> GSM38160 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38162 4 0.0000 0.8588 0.000 0.000 0.000 1.000
#> GSM38163 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38164 1 0.4888 0.3519 0.588 0.000 0.000 0.412
#> GSM38165 3 0.0000 1.0000 0.000 0.000 1.000 0.000
#> GSM38166 3 0.0000 1.0000 0.000 0.000 1.000 0.000
#> GSM38167 1 0.4382 0.5825 0.704 0.000 0.000 0.296
#> GSM38168 4 0.0000 0.8588 0.000 0.000 0.000 1.000
#> GSM38169 1 0.4999 0.0766 0.508 0.000 0.000 0.492
#> GSM38170 1 0.1637 0.8535 0.940 0.000 0.060 0.000
#> GSM38171 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0000 0.8588 0.000 0.000 0.000 1.000
#> GSM38173 1 0.3172 0.7947 0.840 0.000 0.000 0.160
#> GSM38174 1 0.3123 0.7993 0.844 0.000 0.000 0.156
#> GSM38175 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38177 4 0.1940 0.8270 0.076 0.000 0.000 0.924
#> GSM38178 1 0.4164 0.6712 0.736 0.000 0.000 0.264
#> GSM38179 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38180 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38181 3 0.0000 1.0000 0.000 0.000 1.000 0.000
#> GSM38182 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38183 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38184 2 0.0336 0.9899 0.008 0.992 0.000 0.000
#> GSM38185 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38186 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38187 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38188 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38189 1 0.2760 0.8194 0.872 0.000 0.000 0.128
#> GSM38190 1 0.3266 0.7875 0.832 0.000 0.000 0.168
#> GSM38191 4 0.4776 0.4798 0.376 0.000 0.000 0.624
#> GSM38192 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38193 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38194 4 0.1452 0.8430 0.008 0.036 0.000 0.956
#> GSM38195 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38196 4 0.3837 0.7170 0.224 0.000 0.000 0.776
#> GSM38197 1 0.0000 0.8948 1.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.8588 0.000 0.000 0.000 1.000
#> GSM38199 4 0.6347 0.3643 0.384 0.000 0.068 0.548
#> GSM38200 2 0.0000 0.9976 0.000 1.000 0.000 0.000
#> GSM38201 4 0.0000 0.8588 0.000 0.000 0.000 1.000
#> GSM38202 4 0.0188 0.8579 0.004 0.000 0.000 0.996
#> GSM38203 3 0.0000 1.0000 0.000 0.000 1.000 0.000
#> GSM38204 3 0.0000 1.0000 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0000 1.0000 0.000 0.000 1.000 0.000
#> GSM38206 3 0.0000 1.0000 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.0727 0.974 0.004 0.980 0.000 0.004 0.012
#> GSM38160 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38162 4 0.0955 0.846 0.000 0.000 0.028 0.968 0.004
#> GSM38163 1 0.2127 0.820 0.892 0.000 0.000 0.000 0.108
#> GSM38164 5 0.4031 0.716 0.044 0.000 0.000 0.184 0.772
#> GSM38165 3 0.0000 0.987 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0000 0.987 0.000 0.000 1.000 0.000 0.000
#> GSM38167 5 0.4537 0.727 0.076 0.000 0.000 0.184 0.740
#> GSM38168 4 0.2719 0.789 0.004 0.000 0.000 0.852 0.144
#> GSM38169 5 0.4254 0.686 0.040 0.000 0.000 0.220 0.740
#> GSM38170 1 0.3497 0.829 0.856 0.000 0.052 0.028 0.064
#> GSM38171 1 0.0703 0.856 0.976 0.000 0.000 0.000 0.024
#> GSM38172 4 0.1800 0.849 0.000 0.000 0.020 0.932 0.048
#> GSM38173 5 0.3954 0.693 0.192 0.000 0.000 0.036 0.772
#> GSM38174 5 0.4254 0.740 0.080 0.000 0.000 0.148 0.772
#> GSM38175 1 0.0609 0.857 0.980 0.000 0.000 0.000 0.020
#> GSM38176 1 0.2074 0.822 0.896 0.000 0.000 0.000 0.104
#> GSM38177 5 0.3635 0.671 0.004 0.000 0.000 0.248 0.748
#> GSM38178 5 0.3863 0.733 0.052 0.000 0.000 0.152 0.796
#> GSM38179 1 0.2179 0.816 0.888 0.000 0.000 0.000 0.112
#> GSM38180 1 0.0703 0.856 0.976 0.000 0.000 0.000 0.024
#> GSM38181 3 0.1082 0.957 0.008 0.000 0.964 0.028 0.000
#> GSM38182 1 0.3929 0.784 0.764 0.000 0.000 0.028 0.208
#> GSM38183 1 0.2471 0.790 0.864 0.000 0.000 0.000 0.136
#> GSM38184 2 0.2270 0.900 0.072 0.908 0.000 0.004 0.016
#> GSM38185 1 0.2970 0.803 0.828 0.000 0.000 0.004 0.168
#> GSM38186 5 0.4446 0.174 0.476 0.004 0.000 0.000 0.520
#> GSM38187 1 0.0880 0.857 0.968 0.000 0.000 0.000 0.032
#> GSM38188 1 0.5091 0.670 0.648 0.016 0.000 0.032 0.304
#> GSM38189 5 0.4655 0.654 0.248 0.000 0.000 0.052 0.700
#> GSM38190 5 0.4457 0.712 0.116 0.000 0.000 0.124 0.760
#> GSM38191 5 0.6489 0.448 0.136 0.020 0.000 0.304 0.540
#> GSM38192 1 0.1205 0.856 0.956 0.000 0.000 0.004 0.040
#> GSM38193 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38194 4 0.2516 0.796 0.000 0.000 0.000 0.860 0.140
#> GSM38195 1 0.3863 0.788 0.772 0.000 0.000 0.028 0.200
#> GSM38196 5 0.4935 0.558 0.040 0.000 0.000 0.344 0.616
#> GSM38197 1 0.4073 0.780 0.752 0.000 0.000 0.032 0.216
#> GSM38198 4 0.0290 0.847 0.000 0.000 0.000 0.992 0.008
#> GSM38199 5 0.6754 0.579 0.084 0.000 0.088 0.252 0.576
#> GSM38200 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.0955 0.846 0.000 0.000 0.028 0.968 0.004
#> GSM38202 4 0.3990 0.460 0.004 0.000 0.000 0.688 0.308
#> GSM38203 3 0.0290 0.983 0.008 0.000 0.992 0.000 0.000
#> GSM38204 3 0.0000 0.987 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0609 0.973 0.020 0.000 0.980 0.000 0.000
#> GSM38206 3 0.0000 0.987 0.000 0.000 1.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
#> GSM38155 2 0.0363 0.9388 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM38156 2 0.0363 0.9392 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM38157 2 0.0260 0.9395 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38158 2 0.0260 0.9395 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38159 2 0.4799 0.6181 0.004 0.656 0.000 0.252 0.000 0.088
#> GSM38160 2 0.0260 0.9412 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38161 2 0.0260 0.9412 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38162 4 0.3515 0.8085 0.000 0.000 0.000 0.676 0.324 0.000
#> GSM38163 1 0.0713 0.6573 0.972 0.000 0.000 0.000 0.028 0.000
#> GSM38164 5 0.1391 0.6994 0.000 0.000 0.000 0.040 0.944 0.016
#> GSM38165 3 0.0000 0.9904 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0000 0.9904 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38167 5 0.2880 0.7017 0.048 0.000 0.000 0.024 0.872 0.056
#> GSM38168 4 0.4283 0.7123 0.000 0.000 0.000 0.592 0.384 0.024
#> GSM38169 5 0.1970 0.6826 0.000 0.000 0.000 0.060 0.912 0.028
#> GSM38170 1 0.5187 0.2673 0.604 0.000 0.056 0.000 0.028 0.312
#> GSM38171 1 0.0458 0.6552 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM38172 4 0.3993 0.7126 0.000 0.000 0.000 0.592 0.400 0.008
#> GSM38173 5 0.1148 0.7223 0.020 0.000 0.000 0.004 0.960 0.016
#> GSM38174 5 0.2411 0.7165 0.044 0.000 0.000 0.024 0.900 0.032
#> GSM38175 1 0.3769 0.3371 0.640 0.000 0.000 0.000 0.004 0.356
#> GSM38176 1 0.3725 0.4227 0.676 0.000 0.000 0.000 0.316 0.008
#> GSM38177 5 0.2179 0.6950 0.000 0.000 0.000 0.064 0.900 0.036
#> GSM38178 5 0.1036 0.7131 0.004 0.000 0.000 0.024 0.964 0.008
#> GSM38179 1 0.0713 0.6573 0.972 0.000 0.000 0.000 0.028 0.000
#> GSM38180 1 0.0458 0.6552 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM38181 3 0.1010 0.9517 0.004 0.000 0.960 0.000 0.000 0.036
#> GSM38182 6 0.2632 0.7192 0.164 0.000 0.004 0.000 0.000 0.832
#> GSM38183 1 0.3804 0.3908 0.656 0.000 0.000 0.000 0.336 0.008
#> GSM38184 2 0.3183 0.8031 0.060 0.828 0.000 0.000 0.000 0.112
#> GSM38185 6 0.2135 0.7230 0.128 0.000 0.000 0.000 0.000 0.872
#> GSM38186 5 0.3013 0.6538 0.152 0.004 0.000 0.004 0.828 0.012
#> GSM38187 1 0.3371 0.3861 0.708 0.000 0.000 0.000 0.000 0.292
#> GSM38188 6 0.1448 0.7491 0.016 0.012 0.000 0.000 0.024 0.948
#> GSM38189 5 0.1333 0.7246 0.048 0.000 0.000 0.008 0.944 0.000
#> GSM38190 5 0.4386 0.3496 0.004 0.000 0.000 0.348 0.620 0.028
#> GSM38191 6 0.6328 0.3453 0.016 0.008 0.000 0.292 0.196 0.488
#> GSM38192 1 0.3867 0.0591 0.512 0.000 0.000 0.000 0.000 0.488
#> GSM38193 2 0.0260 0.9412 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38194 4 0.2776 0.4605 0.000 0.004 0.000 0.860 0.104 0.032
#> GSM38195 6 0.2703 0.7082 0.172 0.000 0.000 0.000 0.004 0.824
#> GSM38196 5 0.3830 0.6518 0.052 0.000 0.000 0.080 0.812 0.056
#> GSM38197 6 0.1327 0.7620 0.064 0.000 0.000 0.000 0.000 0.936
#> GSM38198 4 0.3515 0.8085 0.000 0.000 0.000 0.676 0.324 0.000
#> GSM38199 5 0.6520 0.0943 0.420 0.000 0.036 0.064 0.432 0.048
#> GSM38200 2 0.0260 0.9412 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38201 4 0.3531 0.8060 0.000 0.000 0.000 0.672 0.328 0.000
#> GSM38202 5 0.5144 -0.3654 0.028 0.000 0.000 0.404 0.532 0.036
#> GSM38203 3 0.0146 0.9877 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.9904 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0146 0.9880 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM38206 3 0.0000 0.9904 0.000 0.000 1.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
#> SD:mclust 52 3.80e-08 2
#> SD:mclust 52 4.38e-10 3
#> SD:mclust 48 1.14e-08 4
#> SD:mclust 49 1.55e-08 5
#> SD:mclust 41 5.96e-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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.843 0.887 0.954 0.4775 0.517 0.517
#> 3 3 0.472 0.669 0.825 0.3875 0.692 0.465
#> 4 4 0.704 0.789 0.888 0.1418 0.805 0.486
#> 5 5 0.644 0.543 0.742 0.0615 0.908 0.662
#> 6 6 0.716 0.609 0.776 0.0433 0.871 0.491
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
#> GSM38155 2 0.0000 0.93607 0.000 1.000
#> GSM38156 2 0.0000 0.93607 0.000 1.000
#> GSM38157 2 0.0000 0.93607 0.000 1.000
#> GSM38158 2 0.0000 0.93607 0.000 1.000
#> GSM38159 2 0.0000 0.93607 0.000 1.000
#> GSM38160 2 0.0000 0.93607 0.000 1.000
#> GSM38161 2 0.0000 0.93607 0.000 1.000
#> GSM38162 1 0.0000 0.95547 1.000 0.000
#> GSM38163 1 0.2043 0.93823 0.968 0.032
#> GSM38164 1 0.0000 0.95547 1.000 0.000
#> GSM38165 1 0.0000 0.95547 1.000 0.000
#> GSM38166 1 0.0000 0.95547 1.000 0.000
#> GSM38167 1 0.0000 0.95547 1.000 0.000
#> GSM38168 1 0.7139 0.77331 0.804 0.196
#> GSM38169 1 0.1843 0.94086 0.972 0.028
#> GSM38170 1 0.0000 0.95547 1.000 0.000
#> GSM38171 2 0.9993 0.00231 0.484 0.516
#> GSM38172 1 0.0000 0.95547 1.000 0.000
#> GSM38173 1 0.7745 0.72655 0.772 0.228
#> GSM38174 1 0.3879 0.90327 0.924 0.076
#> GSM38175 2 0.0000 0.93607 0.000 1.000
#> GSM38176 2 0.9993 0.00231 0.484 0.516
#> GSM38177 1 0.0000 0.95547 1.000 0.000
#> GSM38178 1 0.0000 0.95547 1.000 0.000
#> GSM38179 1 0.0000 0.95547 1.000 0.000
#> GSM38180 1 0.5946 0.83490 0.856 0.144
#> GSM38181 1 0.0000 0.95547 1.000 0.000
#> GSM38182 1 0.0376 0.95341 0.996 0.004
#> GSM38183 1 0.7376 0.75611 0.792 0.208
#> GSM38184 2 0.0000 0.93607 0.000 1.000
#> GSM38185 2 0.0000 0.93607 0.000 1.000
#> GSM38186 1 0.8763 0.60473 0.704 0.296
#> GSM38187 1 0.0000 0.95547 1.000 0.000
#> GSM38188 2 0.0000 0.93607 0.000 1.000
#> GSM38189 1 0.2236 0.93531 0.964 0.036
#> GSM38190 2 0.0000 0.93607 0.000 1.000
#> GSM38191 2 0.1414 0.92463 0.020 0.980
#> GSM38192 2 0.1184 0.92690 0.016 0.984
#> GSM38193 2 0.0000 0.93607 0.000 1.000
#> GSM38194 2 0.1633 0.92114 0.024 0.976
#> GSM38195 1 0.1633 0.94199 0.976 0.024
#> GSM38196 1 0.0000 0.95547 1.000 0.000
#> GSM38197 2 0.4161 0.86299 0.084 0.916
#> GSM38198 1 0.0000 0.95547 1.000 0.000
#> GSM38199 1 0.0000 0.95547 1.000 0.000
#> GSM38200 2 0.0000 0.93607 0.000 1.000
#> GSM38201 1 0.0000 0.95547 1.000 0.000
#> GSM38202 1 0.0000 0.95547 1.000 0.000
#> GSM38203 1 0.0000 0.95547 1.000 0.000
#> GSM38204 1 0.0000 0.95547 1.000 0.000
#> GSM38205 1 0.0000 0.95547 1.000 0.000
#> GSM38206 1 0.0000 0.95547 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.1964 0.8876 0.056 0.944 0.000
#> GSM38156 2 0.0237 0.9040 0.004 0.996 0.000
#> GSM38157 2 0.0747 0.9026 0.016 0.984 0.000
#> GSM38158 2 0.1031 0.9005 0.024 0.976 0.000
#> GSM38159 2 0.4235 0.7666 0.176 0.824 0.000
#> GSM38160 2 0.2066 0.8916 0.000 0.940 0.060
#> GSM38161 2 0.1163 0.9018 0.000 0.972 0.028
#> GSM38162 3 0.2486 0.7238 0.060 0.008 0.932
#> GSM38163 1 0.2066 0.7158 0.940 0.000 0.060
#> GSM38164 1 0.4575 0.6810 0.828 0.012 0.160
#> GSM38165 3 0.4887 0.7326 0.228 0.000 0.772
#> GSM38166 3 0.4974 0.7281 0.236 0.000 0.764
#> GSM38167 3 0.6309 0.0311 0.496 0.000 0.504
#> GSM38168 3 0.6119 0.5927 0.064 0.164 0.772
#> GSM38169 1 0.4399 0.6684 0.812 0.000 0.188
#> GSM38170 3 0.6235 0.4938 0.436 0.000 0.564
#> GSM38171 1 0.3234 0.7423 0.908 0.072 0.020
#> GSM38172 3 0.2959 0.7354 0.100 0.000 0.900
#> GSM38173 1 0.3461 0.7537 0.900 0.076 0.024
#> GSM38174 1 0.6763 0.1009 0.552 0.012 0.436
#> GSM38175 1 0.4750 0.6722 0.784 0.216 0.000
#> GSM38176 1 0.2959 0.7428 0.900 0.100 0.000
#> GSM38177 3 0.6180 0.2400 0.416 0.000 0.584
#> GSM38178 1 0.5216 0.5973 0.740 0.000 0.260
#> GSM38179 1 0.1964 0.7172 0.944 0.000 0.056
#> GSM38180 1 0.0892 0.7317 0.980 0.000 0.020
#> GSM38181 3 0.5968 0.5959 0.364 0.000 0.636
#> GSM38182 1 0.6955 -0.3836 0.492 0.016 0.492
#> GSM38183 1 0.1964 0.7531 0.944 0.056 0.000
#> GSM38184 2 0.2878 0.8609 0.096 0.904 0.000
#> GSM38185 1 0.6307 0.0766 0.512 0.488 0.000
#> GSM38186 1 0.3499 0.7536 0.900 0.072 0.028
#> GSM38187 1 0.4931 0.4991 0.768 0.000 0.232
#> GSM38188 2 0.0424 0.9040 0.008 0.992 0.000
#> GSM38189 1 0.4249 0.6994 0.864 0.028 0.108
#> GSM38190 1 0.5656 0.5783 0.712 0.284 0.004
#> GSM38191 2 0.4861 0.7841 0.008 0.800 0.192
#> GSM38192 1 0.4504 0.6934 0.804 0.196 0.000
#> GSM38193 2 0.2165 0.8900 0.000 0.936 0.064
#> GSM38194 2 0.7062 0.6666 0.068 0.696 0.236
#> GSM38195 3 0.6451 0.4823 0.436 0.004 0.560
#> GSM38196 3 0.3686 0.7414 0.140 0.000 0.860
#> GSM38197 2 0.4790 0.8191 0.056 0.848 0.096
#> GSM38198 3 0.2680 0.7222 0.068 0.008 0.924
#> GSM38199 3 0.4842 0.7460 0.224 0.000 0.776
#> GSM38200 2 0.1031 0.9024 0.000 0.976 0.024
#> GSM38201 3 0.1585 0.7264 0.028 0.008 0.964
#> GSM38202 3 0.2066 0.7445 0.060 0.000 0.940
#> GSM38203 3 0.4002 0.7524 0.160 0.000 0.840
#> GSM38204 3 0.4887 0.7326 0.228 0.000 0.772
#> GSM38205 3 0.2066 0.7523 0.060 0.000 0.940
#> GSM38206 3 0.4702 0.7396 0.212 0.000 0.788
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.2081 0.8760 0.084 0.916 0.000 0.000
#> GSM38156 2 0.0817 0.8946 0.024 0.976 0.000 0.000
#> GSM38157 2 0.1302 0.8921 0.044 0.956 0.000 0.000
#> GSM38158 2 0.1474 0.8900 0.052 0.948 0.000 0.000
#> GSM38159 2 0.3801 0.7530 0.220 0.780 0.000 0.000
#> GSM38160 2 0.1452 0.8830 0.000 0.956 0.008 0.036
#> GSM38161 2 0.0524 0.8922 0.000 0.988 0.004 0.008
#> GSM38162 4 0.0188 0.8559 0.004 0.000 0.000 0.996
#> GSM38163 1 0.0921 0.8660 0.972 0.000 0.000 0.028
#> GSM38164 4 0.4697 0.4894 0.356 0.000 0.000 0.644
#> GSM38165 3 0.0376 0.8843 0.004 0.000 0.992 0.004
#> GSM38166 3 0.0336 0.8846 0.000 0.000 0.992 0.008
#> GSM38167 4 0.2831 0.8306 0.120 0.000 0.004 0.876
#> GSM38168 4 0.0376 0.8546 0.004 0.004 0.000 0.992
#> GSM38169 4 0.4382 0.6160 0.296 0.000 0.000 0.704
#> GSM38170 3 0.2944 0.8321 0.128 0.000 0.868 0.004
#> GSM38171 1 0.1059 0.8526 0.972 0.012 0.016 0.000
#> GSM38172 4 0.0921 0.8564 0.028 0.000 0.000 0.972
#> GSM38173 1 0.3498 0.7755 0.832 0.008 0.000 0.160
#> GSM38174 4 0.3528 0.7730 0.192 0.000 0.000 0.808
#> GSM38175 1 0.0921 0.8491 0.972 0.028 0.000 0.000
#> GSM38176 1 0.1004 0.8659 0.972 0.004 0.000 0.024
#> GSM38177 4 0.1637 0.8523 0.060 0.000 0.000 0.940
#> GSM38178 4 0.2814 0.8213 0.132 0.000 0.000 0.868
#> GSM38179 1 0.2053 0.8521 0.924 0.000 0.004 0.072
#> GSM38180 1 0.1362 0.8640 0.964 0.004 0.012 0.020
#> GSM38181 3 0.0707 0.8817 0.020 0.000 0.980 0.000
#> GSM38182 3 0.4991 0.6007 0.316 0.004 0.672 0.008
#> GSM38183 1 0.1743 0.8621 0.940 0.004 0.000 0.056
#> GSM38184 2 0.3266 0.8106 0.168 0.832 0.000 0.000
#> GSM38185 1 0.3688 0.6394 0.792 0.208 0.000 0.000
#> GSM38186 1 0.1978 0.8573 0.928 0.004 0.000 0.068
#> GSM38187 3 0.4679 0.5425 0.352 0.000 0.648 0.000
#> GSM38188 2 0.1284 0.8952 0.024 0.964 0.012 0.000
#> GSM38189 1 0.4313 0.6322 0.736 0.000 0.004 0.260
#> GSM38190 1 0.5320 0.2240 0.572 0.012 0.000 0.416
#> GSM38191 2 0.2760 0.8164 0.000 0.872 0.000 0.128
#> GSM38192 1 0.1398 0.8399 0.956 0.040 0.004 0.000
#> GSM38193 2 0.1545 0.8814 0.000 0.952 0.008 0.040
#> GSM38194 4 0.4304 0.5564 0.000 0.284 0.000 0.716
#> GSM38195 3 0.3444 0.7907 0.184 0.000 0.816 0.000
#> GSM38196 4 0.3612 0.8137 0.044 0.000 0.100 0.856
#> GSM38197 2 0.4996 0.0907 0.000 0.516 0.484 0.000
#> GSM38198 4 0.0188 0.8559 0.004 0.000 0.000 0.996
#> GSM38199 3 0.3172 0.7665 0.000 0.000 0.840 0.160
#> GSM38200 2 0.0672 0.8918 0.000 0.984 0.008 0.008
#> GSM38201 4 0.1629 0.8385 0.000 0.024 0.024 0.952
#> GSM38202 4 0.2408 0.8386 0.016 0.004 0.060 0.920
#> GSM38203 3 0.0592 0.8824 0.000 0.000 0.984 0.016
#> GSM38204 3 0.0336 0.8846 0.000 0.000 0.992 0.008
#> GSM38205 3 0.1022 0.8763 0.000 0.000 0.968 0.032
#> GSM38206 3 0.0336 0.8846 0.000 0.000 0.992 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.2423 0.7134 0.080 0.896 0.000 0.000 0.024
#> GSM38156 2 0.1478 0.7300 0.000 0.936 0.000 0.000 0.064
#> GSM38157 2 0.2230 0.7406 0.000 0.884 0.000 0.000 0.116
#> GSM38158 2 0.0794 0.7291 0.000 0.972 0.000 0.000 0.028
#> GSM38159 2 0.5118 0.2834 0.412 0.548 0.000 0.000 0.040
#> GSM38160 2 0.4467 0.7007 0.000 0.640 0.000 0.016 0.344
#> GSM38161 2 0.5462 0.6942 0.024 0.656 0.000 0.056 0.264
#> GSM38162 4 0.1197 0.5164 0.000 0.000 0.000 0.952 0.048
#> GSM38163 1 0.2728 0.6818 0.892 0.012 0.004 0.016 0.076
#> GSM38164 4 0.5672 -0.1729 0.088 0.000 0.000 0.544 0.368
#> GSM38165 3 0.0000 0.8942 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0566 0.8888 0.004 0.000 0.984 0.000 0.012
#> GSM38167 4 0.6343 0.0769 0.284 0.000 0.000 0.516 0.200
#> GSM38168 4 0.1410 0.5073 0.000 0.000 0.000 0.940 0.060
#> GSM38169 4 0.5056 0.0202 0.044 0.000 0.000 0.596 0.360
#> GSM38170 1 0.6148 0.4565 0.536 0.000 0.304 0.000 0.160
#> GSM38171 1 0.1798 0.7394 0.928 0.004 0.004 0.000 0.064
#> GSM38172 4 0.4029 0.1984 0.004 0.000 0.000 0.680 0.316
#> GSM38173 5 0.6994 0.6031 0.228 0.016 0.000 0.308 0.448
#> GSM38174 4 0.6744 -0.0527 0.188 0.008 0.000 0.408 0.396
#> GSM38175 1 0.0798 0.7389 0.976 0.016 0.000 0.000 0.008
#> GSM38176 1 0.0510 0.7381 0.984 0.000 0.000 0.000 0.016
#> GSM38177 4 0.0865 0.5169 0.004 0.000 0.000 0.972 0.024
#> GSM38178 4 0.4588 0.0453 0.016 0.000 0.000 0.604 0.380
#> GSM38179 1 0.1205 0.7403 0.956 0.000 0.004 0.000 0.040
#> GSM38180 1 0.2069 0.7348 0.912 0.000 0.012 0.000 0.076
#> GSM38181 3 0.0451 0.8902 0.008 0.000 0.988 0.000 0.004
#> GSM38182 1 0.8363 0.2960 0.412 0.152 0.064 0.052 0.320
#> GSM38183 1 0.1356 0.7341 0.956 0.012 0.000 0.004 0.028
#> GSM38184 2 0.3281 0.6802 0.060 0.848 0.000 0.000 0.092
#> GSM38185 1 0.4788 0.6427 0.740 0.120 0.004 0.000 0.136
#> GSM38186 1 0.2632 0.7027 0.888 0.000 0.000 0.040 0.072
#> GSM38187 1 0.4561 0.1359 0.504 0.000 0.488 0.000 0.008
#> GSM38188 2 0.5317 0.5485 0.008 0.548 0.004 0.028 0.412
#> GSM38189 5 0.6947 0.5497 0.152 0.032 0.004 0.292 0.520
#> GSM38190 5 0.7900 0.5189 0.116 0.196 0.000 0.240 0.448
#> GSM38191 2 0.6671 0.4474 0.000 0.532 0.024 0.156 0.288
#> GSM38192 1 0.2491 0.7026 0.896 0.068 0.000 0.000 0.036
#> GSM38193 2 0.5879 0.6527 0.008 0.556 0.000 0.088 0.348
#> GSM38194 4 0.5836 0.0727 0.000 0.100 0.000 0.516 0.384
#> GSM38195 1 0.8280 0.3793 0.436 0.084 0.212 0.024 0.244
#> GSM38196 4 0.5088 0.3226 0.080 0.000 0.000 0.668 0.252
#> GSM38197 3 0.3851 0.6418 0.004 0.212 0.768 0.000 0.016
#> GSM38198 4 0.1121 0.5159 0.000 0.000 0.000 0.956 0.044
#> GSM38199 3 0.6224 0.1543 0.004 0.000 0.568 0.232 0.196
#> GSM38200 2 0.3550 0.7247 0.000 0.760 0.000 0.004 0.236
#> GSM38201 4 0.2358 0.4875 0.000 0.000 0.008 0.888 0.104
#> GSM38202 4 0.3578 0.4015 0.004 0.000 0.008 0.784 0.204
#> GSM38203 3 0.0451 0.8913 0.000 0.000 0.988 0.004 0.008
#> GSM38204 3 0.0000 0.8942 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.1117 0.8798 0.000 0.000 0.964 0.020 0.016
#> GSM38206 3 0.0000 0.8942 0.000 0.000 1.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
#> GSM38155 2 0.2571 0.6712 0.040 0.896 0.000 0.008 0.016 0.040
#> GSM38156 2 0.2932 0.6865 0.000 0.820 0.000 0.000 0.016 0.164
#> GSM38157 2 0.3791 0.6714 0.000 0.732 0.000 0.032 0.000 0.236
#> GSM38158 2 0.2729 0.6700 0.004 0.876 0.000 0.008 0.032 0.080
#> GSM38159 1 0.4648 0.1134 0.524 0.444 0.000 0.024 0.004 0.004
#> GSM38160 2 0.5350 0.6377 0.000 0.592 0.000 0.212 0.000 0.196
#> GSM38161 2 0.4965 0.6431 0.036 0.632 0.000 0.296 0.000 0.036
#> GSM38162 4 0.2933 0.7862 0.000 0.000 0.000 0.796 0.200 0.004
#> GSM38163 1 0.4236 0.6958 0.804 0.068 0.008 0.012 0.072 0.036
#> GSM38164 5 0.1088 0.6490 0.000 0.016 0.000 0.024 0.960 0.000
#> GSM38165 3 0.0000 0.9346 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.1910 0.8483 0.000 0.000 0.892 0.000 0.000 0.108
#> GSM38167 6 0.6839 0.2430 0.236 0.000 0.000 0.316 0.052 0.396
#> GSM38168 4 0.4065 0.6743 0.000 0.000 0.000 0.672 0.300 0.028
#> GSM38169 5 0.1588 0.6428 0.000 0.000 0.000 0.072 0.924 0.004
#> GSM38170 6 0.5559 0.2988 0.392 0.000 0.064 0.024 0.004 0.516
#> GSM38171 1 0.2207 0.7699 0.908 0.004 0.000 0.008 0.020 0.060
#> GSM38172 5 0.2445 0.6075 0.000 0.000 0.004 0.120 0.868 0.008
#> GSM38173 5 0.2094 0.6419 0.024 0.000 0.000 0.004 0.908 0.064
#> GSM38174 6 0.4829 0.5757 0.040 0.000 0.000 0.132 0.104 0.724
#> GSM38175 1 0.0806 0.7799 0.972 0.008 0.000 0.000 0.000 0.020
#> GSM38176 1 0.0748 0.7792 0.976 0.004 0.000 0.004 0.016 0.000
#> GSM38177 4 0.3881 0.7586 0.036 0.000 0.000 0.792 0.136 0.036
#> GSM38178 5 0.2052 0.6488 0.000 0.004 0.000 0.056 0.912 0.028
#> GSM38179 1 0.1624 0.7731 0.936 0.000 0.000 0.004 0.020 0.040
#> GSM38180 1 0.2263 0.7458 0.884 0.000 0.000 0.000 0.016 0.100
#> GSM38181 3 0.0547 0.9271 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM38182 6 0.3063 0.6803 0.064 0.020 0.004 0.028 0.012 0.872
#> GSM38183 1 0.1223 0.7782 0.960 0.004 0.000 0.016 0.012 0.008
#> GSM38184 2 0.5542 0.5356 0.084 0.700 0.000 0.024 0.076 0.116
#> GSM38185 1 0.4601 0.1202 0.556 0.032 0.000 0.004 0.000 0.408
#> GSM38186 1 0.2518 0.7416 0.880 0.000 0.000 0.016 0.012 0.092
#> GSM38187 1 0.4158 0.2759 0.572 0.000 0.416 0.004 0.000 0.008
#> GSM38188 6 0.2975 0.5352 0.000 0.132 0.000 0.016 0.012 0.840
#> GSM38189 5 0.4885 0.2334 0.016 0.004 0.000 0.024 0.540 0.416
#> GSM38190 5 0.3748 0.5672 0.012 0.140 0.000 0.024 0.804 0.020
#> GSM38191 2 0.6400 0.2188 0.000 0.456 0.004 0.204 0.316 0.020
#> GSM38192 1 0.1590 0.7644 0.936 0.048 0.000 0.008 0.008 0.000
#> GSM38193 2 0.5227 0.5940 0.008 0.552 0.000 0.360 0.000 0.080
#> GSM38194 5 0.5361 0.2474 0.000 0.116 0.000 0.372 0.512 0.000
#> GSM38195 6 0.3815 0.6831 0.080 0.016 0.036 0.024 0.012 0.832
#> GSM38196 4 0.5758 0.1304 0.016 0.000 0.000 0.496 0.116 0.372
#> GSM38197 3 0.3917 0.6756 0.028 0.208 0.752 0.004 0.000 0.008
#> GSM38198 4 0.2882 0.7933 0.000 0.000 0.000 0.812 0.180 0.008
#> GSM38199 5 0.4258 0.1265 0.000 0.000 0.468 0.016 0.516 0.000
#> GSM38200 2 0.4493 0.6227 0.000 0.636 0.000 0.052 0.000 0.312
#> GSM38201 4 0.3135 0.7827 0.000 0.004 0.008 0.816 0.164 0.008
#> GSM38202 5 0.6068 -0.0439 0.000 0.000 0.004 0.272 0.456 0.268
#> GSM38203 3 0.0000 0.9346 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.9346 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.1152 0.9108 0.000 0.000 0.952 0.044 0.000 0.004
#> GSM38206 3 0.0000 0.9346 0.000 0.000 1.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
#> SD:NMF 50 2.68e-04 2
#> SD:NMF 44 6.12e-06 3
#> SD:NMF 49 1.57e-05 4
#> SD:NMF 35 8.09e-05 5
#> SD:NMF 41 2.74e-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["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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.724 0.896 0.929 0.3491 0.638 0.638
#> 3 3 0.370 0.742 0.802 0.5780 0.744 0.626
#> 4 4 0.463 0.632 0.779 0.2008 0.873 0.735
#> 5 5 0.527 0.613 0.763 0.0872 0.971 0.917
#> 6 6 0.562 0.478 0.740 0.0713 0.876 0.642
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
#> GSM38155 2 0.4815 0.866 0.104 0.896
#> GSM38156 2 0.2778 0.875 0.048 0.952
#> GSM38157 2 0.2778 0.875 0.048 0.952
#> GSM38158 2 0.2778 0.875 0.048 0.952
#> GSM38159 2 0.5059 0.863 0.112 0.888
#> GSM38160 2 0.2778 0.875 0.048 0.952
#> GSM38161 2 0.6247 0.835 0.156 0.844
#> GSM38162 1 0.1633 0.949 0.976 0.024
#> GSM38163 1 0.2423 0.948 0.960 0.040
#> GSM38164 1 0.3879 0.928 0.924 0.076
#> GSM38165 1 0.2778 0.929 0.952 0.048
#> GSM38166 1 0.2778 0.929 0.952 0.048
#> GSM38167 1 0.1184 0.951 0.984 0.016
#> GSM38168 1 0.1843 0.949 0.972 0.028
#> GSM38169 1 0.3733 0.931 0.928 0.072
#> GSM38170 1 0.3114 0.936 0.944 0.056
#> GSM38171 1 0.3431 0.937 0.936 0.064
#> GSM38172 1 0.1184 0.950 0.984 0.016
#> GSM38173 1 0.4022 0.928 0.920 0.080
#> GSM38174 1 0.1633 0.951 0.976 0.024
#> GSM38175 1 0.5946 0.847 0.856 0.144
#> GSM38176 1 0.2423 0.948 0.960 0.040
#> GSM38177 1 0.0938 0.951 0.988 0.012
#> GSM38178 1 0.2043 0.946 0.968 0.032
#> GSM38179 1 0.2423 0.948 0.960 0.040
#> GSM38180 1 0.3431 0.937 0.936 0.064
#> GSM38181 1 0.2778 0.929 0.952 0.048
#> GSM38182 1 0.1843 0.951 0.972 0.028
#> GSM38183 1 0.2423 0.948 0.960 0.040
#> GSM38184 2 0.2778 0.875 0.048 0.952
#> GSM38185 1 0.3879 0.929 0.924 0.076
#> GSM38186 1 0.2948 0.944 0.948 0.052
#> GSM38187 1 0.2603 0.950 0.956 0.044
#> GSM38188 1 0.5519 0.874 0.872 0.128
#> GSM38189 1 0.3733 0.935 0.928 0.072
#> GSM38190 1 0.4161 0.922 0.916 0.084
#> GSM38191 2 0.9983 0.232 0.476 0.524
#> GSM38192 1 0.2423 0.948 0.960 0.040
#> GSM38193 2 0.6343 0.831 0.160 0.840
#> GSM38194 2 0.9983 0.232 0.476 0.524
#> GSM38195 1 0.1843 0.951 0.972 0.028
#> GSM38196 1 0.1414 0.951 0.980 0.020
#> GSM38197 1 0.2603 0.950 0.956 0.044
#> GSM38198 1 0.1633 0.949 0.976 0.024
#> GSM38199 1 0.2236 0.936 0.964 0.036
#> GSM38200 2 0.2778 0.875 0.048 0.952
#> GSM38201 1 0.1633 0.949 0.976 0.024
#> GSM38202 1 0.1184 0.945 0.984 0.016
#> GSM38203 1 0.2778 0.929 0.952 0.048
#> GSM38204 1 0.2778 0.929 0.952 0.048
#> GSM38205 1 0.2778 0.929 0.952 0.048
#> GSM38206 1 0.2778 0.929 0.952 0.048
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.497 0.8879 0.100 0.840 0.060
#> GSM38156 2 0.103 0.9194 0.024 0.976 0.000
#> GSM38157 2 0.103 0.9194 0.024 0.976 0.000
#> GSM38158 2 0.103 0.9194 0.024 0.976 0.000
#> GSM38159 2 0.512 0.8839 0.108 0.832 0.060
#> GSM38160 2 0.219 0.9157 0.024 0.948 0.028
#> GSM38161 2 0.637 0.8238 0.176 0.756 0.068
#> GSM38162 1 0.609 0.6834 0.716 0.020 0.264
#> GSM38163 1 0.254 0.7921 0.920 0.000 0.080
#> GSM38164 1 0.452 0.7755 0.852 0.032 0.116
#> GSM38165 3 0.576 0.6430 0.328 0.000 0.672
#> GSM38166 3 0.418 0.8638 0.172 0.000 0.828
#> GSM38167 1 0.423 0.7672 0.844 0.008 0.148
#> GSM38168 1 0.564 0.7174 0.760 0.020 0.220
#> GSM38169 1 0.425 0.7774 0.864 0.028 0.108
#> GSM38170 1 0.611 0.2013 0.604 0.000 0.396
#> GSM38171 1 0.220 0.7893 0.940 0.004 0.056
#> GSM38172 1 0.486 0.7679 0.820 0.020 0.160
#> GSM38173 1 0.344 0.7840 0.896 0.016 0.088
#> GSM38174 1 0.327 0.7845 0.884 0.000 0.116
#> GSM38175 1 0.408 0.7354 0.880 0.048 0.072
#> GSM38176 1 0.254 0.7921 0.920 0.000 0.080
#> GSM38177 1 0.410 0.7711 0.852 0.008 0.140
#> GSM38178 1 0.535 0.7635 0.804 0.036 0.160
#> GSM38179 1 0.263 0.7905 0.916 0.000 0.084
#> GSM38180 1 0.220 0.7893 0.940 0.004 0.056
#> GSM38181 3 0.435 0.8564 0.184 0.000 0.816
#> GSM38182 1 0.207 0.7994 0.940 0.000 0.060
#> GSM38183 1 0.263 0.7905 0.916 0.000 0.084
#> GSM38184 2 0.103 0.9194 0.024 0.976 0.000
#> GSM38185 1 0.199 0.7857 0.948 0.004 0.048
#> GSM38186 1 0.286 0.7947 0.912 0.004 0.084
#> GSM38187 1 0.394 0.7466 0.844 0.000 0.156
#> GSM38188 1 0.516 0.7434 0.832 0.096 0.072
#> GSM38189 1 0.437 0.7843 0.864 0.040 0.096
#> GSM38190 1 0.397 0.7714 0.880 0.032 0.088
#> GSM38191 1 0.894 -0.0142 0.484 0.388 0.128
#> GSM38192 1 0.263 0.7905 0.916 0.000 0.084
#> GSM38193 2 0.642 0.8184 0.180 0.752 0.068
#> GSM38194 1 0.894 -0.0142 0.484 0.388 0.128
#> GSM38195 1 0.207 0.7994 0.940 0.000 0.060
#> GSM38196 1 0.388 0.7715 0.848 0.000 0.152
#> GSM38197 1 0.394 0.7466 0.844 0.000 0.156
#> GSM38198 1 0.609 0.6834 0.716 0.020 0.264
#> GSM38199 3 0.682 0.1613 0.476 0.012 0.512
#> GSM38200 2 0.103 0.9194 0.024 0.976 0.000
#> GSM38201 1 0.629 0.6486 0.692 0.020 0.288
#> GSM38202 1 0.606 0.5752 0.708 0.016 0.276
#> GSM38203 3 0.385 0.8519 0.136 0.004 0.860
#> GSM38204 3 0.385 0.8519 0.136 0.004 0.860
#> GSM38205 3 0.417 0.8599 0.156 0.004 0.840
#> GSM38206 3 0.406 0.8647 0.164 0.000 0.836
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.4568 0.8018 0.024 0.772 0.004 0.200
#> GSM38156 2 0.0000 0.8466 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.8466 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.8466 0.000 1.000 0.000 0.000
#> GSM38159 2 0.4759 0.7971 0.032 0.764 0.004 0.200
#> GSM38160 2 0.3893 0.8039 0.000 0.796 0.008 0.196
#> GSM38161 2 0.6531 0.6678 0.064 0.564 0.008 0.364
#> GSM38162 4 0.7178 0.5420 0.324 0.000 0.156 0.520
#> GSM38163 1 0.2197 0.7204 0.928 0.000 0.048 0.024
#> GSM38164 1 0.4754 0.5729 0.748 0.016 0.008 0.228
#> GSM38165 3 0.6155 0.6382 0.148 0.000 0.676 0.176
#> GSM38166 3 0.2797 0.8383 0.068 0.000 0.900 0.032
#> GSM38167 1 0.4552 0.6549 0.800 0.000 0.072 0.128
#> GSM38168 4 0.6972 0.4997 0.356 0.000 0.124 0.520
#> GSM38169 1 0.4399 0.5801 0.760 0.016 0.000 0.224
#> GSM38170 1 0.7519 -0.0499 0.480 0.000 0.312 0.208
#> GSM38171 1 0.2748 0.7087 0.904 0.004 0.020 0.072
#> GSM38172 1 0.5496 0.4232 0.652 0.000 0.036 0.312
#> GSM38173 1 0.3631 0.6717 0.824 0.004 0.004 0.168
#> GSM38174 1 0.4485 0.6581 0.796 0.000 0.052 0.152
#> GSM38175 1 0.3743 0.6153 0.824 0.000 0.016 0.160
#> GSM38176 1 0.2197 0.7204 0.928 0.000 0.048 0.024
#> GSM38177 1 0.4944 0.6017 0.768 0.000 0.072 0.160
#> GSM38178 1 0.5954 0.4123 0.640 0.016 0.032 0.312
#> GSM38179 1 0.2282 0.7195 0.924 0.000 0.052 0.024
#> GSM38180 1 0.2748 0.7087 0.904 0.004 0.020 0.072
#> GSM38181 3 0.3081 0.8352 0.064 0.000 0.888 0.048
#> GSM38182 1 0.3088 0.6989 0.864 0.000 0.008 0.128
#> GSM38183 1 0.2174 0.7202 0.928 0.000 0.052 0.020
#> GSM38184 2 0.0000 0.8466 0.000 1.000 0.000 0.000
#> GSM38185 1 0.2300 0.7097 0.920 0.000 0.016 0.064
#> GSM38186 1 0.2855 0.7194 0.904 0.004 0.040 0.052
#> GSM38187 1 0.3895 0.6588 0.832 0.000 0.132 0.036
#> GSM38188 1 0.5898 0.5467 0.716 0.088 0.012 0.184
#> GSM38189 1 0.5139 0.6178 0.740 0.020 0.020 0.220
#> GSM38190 1 0.4327 0.6042 0.768 0.016 0.000 0.216
#> GSM38191 4 0.7513 0.2043 0.336 0.156 0.008 0.500
#> GSM38192 1 0.2174 0.7202 0.928 0.000 0.052 0.020
#> GSM38193 2 0.6544 0.6634 0.064 0.560 0.008 0.368
#> GSM38194 4 0.7513 0.2043 0.336 0.156 0.008 0.500
#> GSM38195 1 0.3088 0.6989 0.864 0.000 0.008 0.128
#> GSM38196 1 0.4389 0.6634 0.812 0.000 0.072 0.116
#> GSM38197 1 0.3803 0.6612 0.836 0.000 0.132 0.032
#> GSM38198 4 0.7178 0.5420 0.324 0.000 0.156 0.520
#> GSM38199 3 0.7474 0.0660 0.292 0.000 0.496 0.212
#> GSM38200 2 0.0188 0.8463 0.000 0.996 0.000 0.004
#> GSM38201 4 0.7222 0.5406 0.300 0.000 0.172 0.528
#> GSM38202 1 0.7397 -0.0761 0.508 0.000 0.200 0.292
#> GSM38203 3 0.2111 0.8248 0.044 0.000 0.932 0.024
#> GSM38204 3 0.1767 0.8278 0.044 0.000 0.944 0.012
#> GSM38205 3 0.2908 0.8250 0.064 0.000 0.896 0.040
#> GSM38206 3 0.2483 0.8385 0.052 0.000 0.916 0.032
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.3821 0.6947 0.020 0.764 0.000 0.000 0.216
#> GSM38156 2 0.0000 0.7736 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.7736 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0162 0.7741 0.000 0.996 0.000 0.000 0.004
#> GSM38159 2 0.3993 0.6876 0.028 0.756 0.000 0.000 0.216
#> GSM38160 2 0.5868 0.5467 0.000 0.576 0.000 0.132 0.292
#> GSM38161 2 0.5614 0.3585 0.040 0.476 0.000 0.016 0.468
#> GSM38162 4 0.3413 0.8161 0.124 0.000 0.044 0.832 0.000
#> GSM38163 1 0.2507 0.7104 0.908 0.000 0.028 0.044 0.020
#> GSM38164 1 0.6211 0.3309 0.564 0.000 0.004 0.176 0.256
#> GSM38165 3 0.6695 0.5165 0.108 0.000 0.620 0.152 0.120
#> GSM38166 3 0.2087 0.7761 0.020 0.000 0.928 0.020 0.032
#> GSM38167 1 0.4377 0.6239 0.760 0.000 0.024 0.192 0.024
#> GSM38168 4 0.3648 0.7733 0.188 0.000 0.016 0.792 0.004
#> GSM38169 1 0.6059 0.3461 0.572 0.000 0.000 0.184 0.244
#> GSM38170 1 0.7917 -0.0759 0.452 0.000 0.228 0.196 0.124
#> GSM38171 1 0.1960 0.6892 0.928 0.004 0.000 0.020 0.048
#> GSM38172 1 0.6893 0.0879 0.456 0.000 0.020 0.348 0.176
#> GSM38173 1 0.4252 0.6100 0.764 0.000 0.000 0.064 0.172
#> GSM38174 1 0.4185 0.6095 0.752 0.000 0.008 0.216 0.024
#> GSM38175 1 0.2971 0.5866 0.836 0.000 0.000 0.008 0.156
#> GSM38176 1 0.2507 0.7104 0.908 0.000 0.028 0.044 0.020
#> GSM38177 1 0.4977 0.5243 0.684 0.000 0.024 0.264 0.028
#> GSM38178 1 0.6947 0.1037 0.448 0.000 0.016 0.328 0.208
#> GSM38179 1 0.2430 0.7094 0.912 0.000 0.028 0.040 0.020
#> GSM38180 1 0.1960 0.6892 0.928 0.004 0.000 0.020 0.048
#> GSM38181 3 0.3165 0.7583 0.044 0.000 0.876 0.032 0.048
#> GSM38182 1 0.3060 0.6786 0.848 0.000 0.000 0.128 0.024
#> GSM38183 1 0.2333 0.7099 0.916 0.000 0.028 0.040 0.016
#> GSM38184 2 0.0162 0.7741 0.000 0.996 0.000 0.000 0.004
#> GSM38185 1 0.1557 0.6876 0.940 0.000 0.000 0.008 0.052
#> GSM38186 1 0.2344 0.7032 0.920 0.004 0.020 0.028 0.028
#> GSM38187 1 0.4162 0.6612 0.812 0.000 0.104 0.048 0.036
#> GSM38188 1 0.6119 0.5313 0.672 0.080 0.000 0.108 0.140
#> GSM38189 1 0.5728 0.5835 0.672 0.012 0.004 0.152 0.160
#> GSM38190 1 0.5579 0.4157 0.620 0.000 0.000 0.116 0.264
#> GSM38191 5 0.5584 1.0000 0.224 0.056 0.000 0.044 0.676
#> GSM38192 1 0.2333 0.7099 0.916 0.000 0.028 0.040 0.016
#> GSM38193 2 0.5675 0.3493 0.044 0.472 0.000 0.016 0.468
#> GSM38194 5 0.5584 1.0000 0.224 0.056 0.000 0.044 0.676
#> GSM38195 1 0.3060 0.6786 0.848 0.000 0.000 0.128 0.024
#> GSM38196 1 0.4089 0.6225 0.764 0.000 0.024 0.204 0.008
#> GSM38197 1 0.4084 0.6633 0.816 0.000 0.104 0.048 0.032
#> GSM38198 4 0.3413 0.8161 0.124 0.000 0.044 0.832 0.000
#> GSM38199 3 0.7443 -0.1043 0.172 0.000 0.460 0.304 0.064
#> GSM38200 2 0.0290 0.7730 0.000 0.992 0.000 0.000 0.008
#> GSM38201 4 0.3584 0.7956 0.108 0.000 0.056 0.832 0.004
#> GSM38202 4 0.7543 0.2381 0.372 0.000 0.164 0.396 0.068
#> GSM38203 3 0.2305 0.7663 0.000 0.000 0.896 0.012 0.092
#> GSM38204 3 0.2011 0.7688 0.000 0.000 0.908 0.004 0.088
#> GSM38205 3 0.3690 0.7470 0.008 0.000 0.832 0.068 0.092
#> GSM38206 3 0.0609 0.7796 0.000 0.000 0.980 0.020 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.3163 0.6857 0.004 0.764 0.000 0.000 0.232 0.000
#> GSM38156 2 0.0000 0.8410 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.8410 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.0146 0.8412 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38159 2 0.3368 0.6798 0.012 0.756 0.000 0.000 0.232 0.000
#> GSM38160 2 0.5624 0.3724 0.000 0.456 0.000 0.000 0.148 0.396
#> GSM38161 5 0.4051 -0.2470 0.008 0.432 0.000 0.000 0.560 0.000
#> GSM38162 4 0.0777 0.5388 0.024 0.000 0.004 0.972 0.000 0.000
#> GSM38163 1 0.3394 0.7123 0.840 0.000 0.012 0.100 0.020 0.028
#> GSM38164 5 0.7139 -0.1036 0.340 0.000 0.000 0.188 0.372 0.100
#> GSM38165 6 0.5966 -0.3018 0.036 0.000 0.424 0.096 0.000 0.444
#> GSM38166 3 0.3596 0.6030 0.008 0.000 0.760 0.016 0.000 0.216
#> GSM38167 1 0.5019 0.5996 0.664 0.000 0.004 0.244 0.020 0.068
#> GSM38168 4 0.2006 0.5082 0.104 0.000 0.000 0.892 0.000 0.004
#> GSM38169 5 0.7128 -0.1130 0.356 0.000 0.000 0.192 0.356 0.096
#> GSM38170 6 0.6168 0.1370 0.324 0.000 0.012 0.184 0.004 0.476
#> GSM38171 1 0.1666 0.6997 0.936 0.000 0.000 0.008 0.020 0.036
#> GSM38172 4 0.7585 0.1937 0.236 0.000 0.000 0.340 0.248 0.176
#> GSM38173 1 0.5124 0.4592 0.668 0.000 0.000 0.044 0.224 0.064
#> GSM38174 1 0.4865 0.5682 0.684 0.000 0.004 0.232 0.024 0.056
#> GSM38175 1 0.2593 0.6472 0.844 0.000 0.000 0.000 0.148 0.008
#> GSM38176 1 0.3394 0.7123 0.840 0.000 0.012 0.100 0.020 0.028
#> GSM38177 1 0.5312 0.4567 0.572 0.000 0.000 0.340 0.024 0.064
#> GSM38178 4 0.7581 0.1508 0.236 0.000 0.000 0.320 0.280 0.164
#> GSM38179 1 0.3069 0.7106 0.856 0.000 0.012 0.096 0.008 0.028
#> GSM38180 1 0.1483 0.6995 0.944 0.000 0.000 0.008 0.012 0.036
#> GSM38181 3 0.4117 0.5380 0.020 0.000 0.708 0.016 0.000 0.256
#> GSM38182 1 0.3956 0.6561 0.792 0.000 0.000 0.112 0.024 0.072
#> GSM38183 1 0.2991 0.7118 0.860 0.000 0.012 0.096 0.008 0.024
#> GSM38184 2 0.0146 0.8412 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38185 1 0.0777 0.7075 0.972 0.000 0.000 0.000 0.024 0.004
#> GSM38186 1 0.2650 0.7119 0.888 0.000 0.004 0.056 0.016 0.036
#> GSM38187 1 0.4735 0.6444 0.752 0.000 0.092 0.100 0.008 0.048
#> GSM38188 1 0.6869 0.3781 0.584 0.072 0.000 0.092 0.168 0.084
#> GSM38189 1 0.6446 0.4062 0.584 0.004 0.004 0.136 0.184 0.088
#> GSM38190 1 0.6729 -0.1105 0.424 0.000 0.000 0.120 0.364 0.092
#> GSM38191 5 0.2043 0.3961 0.064 0.012 0.000 0.012 0.912 0.000
#> GSM38192 1 0.2991 0.7118 0.860 0.000 0.012 0.096 0.008 0.024
#> GSM38193 5 0.4045 -0.2395 0.008 0.428 0.000 0.000 0.564 0.000
#> GSM38194 5 0.2043 0.3961 0.064 0.012 0.000 0.012 0.912 0.000
#> GSM38195 1 0.3956 0.6561 0.792 0.000 0.000 0.112 0.024 0.072
#> GSM38196 1 0.4828 0.5963 0.672 0.000 0.004 0.256 0.024 0.044
#> GSM38197 1 0.4673 0.6470 0.756 0.000 0.092 0.100 0.008 0.044
#> GSM38198 4 0.0777 0.5388 0.024 0.000 0.004 0.972 0.000 0.000
#> GSM38199 3 0.7620 -0.2506 0.096 0.000 0.336 0.304 0.016 0.248
#> GSM38200 2 0.0458 0.8356 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM38201 4 0.0862 0.5164 0.008 0.000 0.016 0.972 0.004 0.000
#> GSM38202 4 0.7592 0.0328 0.272 0.000 0.044 0.380 0.052 0.252
#> GSM38203 3 0.0405 0.6731 0.000 0.000 0.988 0.008 0.004 0.000
#> GSM38204 3 0.0000 0.6747 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.1644 0.6341 0.000 0.000 0.920 0.076 0.004 0.000
#> GSM38206 3 0.2538 0.6600 0.000 0.000 0.860 0.016 0.000 0.124
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 50 7.66e-08 2
#> CV:hclust 48 3.75e-09 3
#> CV:hclust 44 1.37e-08 4
#> CV:hclust 42 1.27e-07 5
#> CV:hclust 34 6.71e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.415 0.733 0.871 0.3909 0.638 0.638
#> 3 3 0.548 0.885 0.905 0.4259 0.744 0.626
#> 4 4 0.642 0.642 0.815 0.2707 0.794 0.569
#> 5 5 0.692 0.664 0.768 0.0993 0.881 0.590
#> 6 6 0.742 0.804 0.824 0.0578 0.925 0.645
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
#> GSM38155 2 0.0000 0.880 0.000 1.000
#> GSM38156 2 0.0000 0.880 0.000 1.000
#> GSM38157 2 0.0000 0.880 0.000 1.000
#> GSM38158 2 0.0000 0.880 0.000 1.000
#> GSM38159 2 0.0000 0.880 0.000 1.000
#> GSM38160 2 0.0000 0.880 0.000 1.000
#> GSM38161 2 0.0000 0.880 0.000 1.000
#> GSM38162 1 0.0376 0.832 0.996 0.004
#> GSM38163 1 0.5842 0.824 0.860 0.140
#> GSM38164 1 0.4690 0.839 0.900 0.100
#> GSM38165 1 0.0000 0.831 1.000 0.000
#> GSM38166 1 0.0000 0.831 1.000 0.000
#> GSM38167 1 0.4562 0.839 0.904 0.096
#> GSM38168 1 0.6531 0.805 0.832 0.168
#> GSM38169 1 0.4815 0.839 0.896 0.104
#> GSM38170 1 0.0000 0.831 1.000 0.000
#> GSM38171 1 0.8267 0.729 0.740 0.260
#> GSM38172 1 0.0000 0.831 1.000 0.000
#> GSM38173 1 0.8327 0.725 0.736 0.264
#> GSM38174 1 0.4939 0.838 0.892 0.108
#> GSM38175 1 0.9896 0.418 0.560 0.440
#> GSM38176 1 0.8443 0.715 0.728 0.272
#> GSM38177 1 0.4562 0.839 0.904 0.096
#> GSM38178 1 0.5059 0.837 0.888 0.112
#> GSM38179 1 0.4815 0.839 0.896 0.104
#> GSM38180 1 0.6887 0.796 0.816 0.184
#> GSM38181 1 0.0000 0.831 1.000 0.000
#> GSM38182 1 0.5059 0.837 0.888 0.112
#> GSM38183 1 0.8327 0.725 0.736 0.264
#> GSM38184 2 0.0000 0.880 0.000 1.000
#> GSM38185 1 0.9909 0.408 0.556 0.444
#> GSM38186 1 0.8499 0.711 0.724 0.276
#> GSM38187 1 0.1414 0.835 0.980 0.020
#> GSM38188 1 1.0000 0.239 0.500 0.500
#> GSM38189 1 0.5059 0.837 0.888 0.112
#> GSM38190 1 0.9988 0.302 0.520 0.480
#> GSM38191 2 0.9998 -0.290 0.492 0.508
#> GSM38192 1 0.9922 0.398 0.552 0.448
#> GSM38193 2 0.0000 0.880 0.000 1.000
#> GSM38194 2 0.9998 -0.290 0.492 0.508
#> GSM38195 1 0.5059 0.837 0.888 0.112
#> GSM38196 1 0.2236 0.837 0.964 0.036
#> GSM38197 1 0.9922 0.398 0.552 0.448
#> GSM38198 1 0.0376 0.832 0.996 0.004
#> GSM38199 1 0.0000 0.831 1.000 0.000
#> GSM38200 2 0.0000 0.880 0.000 1.000
#> GSM38201 1 0.0000 0.831 1.000 0.000
#> GSM38202 1 0.0376 0.832 0.996 0.004
#> GSM38203 1 0.0000 0.831 1.000 0.000
#> GSM38204 1 0.0000 0.831 1.000 0.000
#> GSM38205 1 0.0000 0.831 1.000 0.000
#> GSM38206 1 0.0000 0.831 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.992 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.992 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.992 0.000 1.000 0.000
#> GSM38158 2 0.0237 0.991 0.000 0.996 0.004
#> GSM38159 2 0.0000 0.992 0.000 1.000 0.000
#> GSM38160 2 0.1289 0.983 0.000 0.968 0.032
#> GSM38161 2 0.1031 0.986 0.000 0.976 0.024
#> GSM38162 1 0.3038 0.861 0.896 0.000 0.104
#> GSM38163 1 0.3112 0.875 0.916 0.028 0.056
#> GSM38164 1 0.1163 0.875 0.972 0.000 0.028
#> GSM38165 3 0.2537 0.986 0.080 0.000 0.920
#> GSM38166 3 0.2537 0.986 0.080 0.000 0.920
#> GSM38167 1 0.2625 0.871 0.916 0.000 0.084
#> GSM38168 1 0.3043 0.868 0.908 0.008 0.084
#> GSM38169 1 0.1163 0.875 0.972 0.000 0.028
#> GSM38170 1 0.4555 0.812 0.800 0.000 0.200
#> GSM38171 1 0.3356 0.873 0.908 0.036 0.056
#> GSM38172 1 0.4002 0.823 0.840 0.000 0.160
#> GSM38173 1 0.2434 0.874 0.940 0.036 0.024
#> GSM38174 1 0.2448 0.871 0.924 0.000 0.076
#> GSM38175 1 0.3896 0.867 0.888 0.060 0.052
#> GSM38176 1 0.3356 0.873 0.908 0.036 0.056
#> GSM38177 1 0.2711 0.867 0.912 0.000 0.088
#> GSM38178 1 0.1163 0.875 0.972 0.000 0.028
#> GSM38179 1 0.2066 0.875 0.940 0.000 0.060
#> GSM38180 1 0.3356 0.873 0.908 0.036 0.056
#> GSM38181 3 0.2625 0.982 0.084 0.000 0.916
#> GSM38182 1 0.2796 0.874 0.908 0.000 0.092
#> GSM38183 1 0.3356 0.873 0.908 0.036 0.056
#> GSM38184 2 0.0237 0.991 0.000 0.996 0.004
#> GSM38185 1 0.3993 0.866 0.884 0.064 0.052
#> GSM38186 1 0.3148 0.876 0.916 0.036 0.048
#> GSM38187 1 0.2959 0.864 0.900 0.000 0.100
#> GSM38188 1 0.6735 0.699 0.696 0.260 0.044
#> GSM38189 1 0.1964 0.877 0.944 0.000 0.056
#> GSM38190 1 0.4679 0.804 0.832 0.148 0.020
#> GSM38191 1 0.6632 0.652 0.692 0.272 0.036
#> GSM38192 1 0.3993 0.866 0.884 0.064 0.052
#> GSM38193 2 0.1031 0.986 0.000 0.976 0.024
#> GSM38194 1 0.6562 0.663 0.700 0.264 0.036
#> GSM38195 1 0.2796 0.874 0.908 0.000 0.092
#> GSM38196 1 0.2711 0.869 0.912 0.000 0.088
#> GSM38197 1 0.4689 0.847 0.852 0.096 0.052
#> GSM38198 1 0.2959 0.863 0.900 0.000 0.100
#> GSM38199 3 0.2878 0.966 0.096 0.000 0.904
#> GSM38200 2 0.0592 0.990 0.000 0.988 0.012
#> GSM38201 1 0.6095 0.368 0.608 0.000 0.392
#> GSM38202 1 0.3619 0.832 0.864 0.000 0.136
#> GSM38203 3 0.2448 0.974 0.076 0.000 0.924
#> GSM38204 3 0.2537 0.986 0.080 0.000 0.920
#> GSM38205 3 0.2261 0.966 0.068 0.000 0.932
#> GSM38206 3 0.2537 0.986 0.080 0.000 0.920
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.9767 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.9767 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.9767 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0188 0.9761 0.000 0.996 0.004 0.000
#> GSM38159 2 0.0188 0.9761 0.004 0.996 0.000 0.000
#> GSM38160 2 0.2635 0.9452 0.000 0.904 0.020 0.076
#> GSM38161 2 0.2161 0.9579 0.004 0.932 0.016 0.048
#> GSM38162 4 0.4916 0.6881 0.184 0.000 0.056 0.760
#> GSM38163 1 0.0657 0.6986 0.984 0.000 0.004 0.012
#> GSM38164 1 0.5277 -0.0407 0.532 0.000 0.008 0.460
#> GSM38165 3 0.2111 0.9807 0.044 0.000 0.932 0.024
#> GSM38166 3 0.2021 0.9808 0.040 0.000 0.936 0.024
#> GSM38167 4 0.6340 0.4245 0.408 0.000 0.064 0.528
#> GSM38168 4 0.4578 0.6812 0.160 0.000 0.052 0.788
#> GSM38169 1 0.5268 -0.0236 0.540 0.000 0.008 0.452
#> GSM38170 1 0.6563 0.3004 0.632 0.000 0.160 0.208
#> GSM38171 1 0.1452 0.6922 0.956 0.000 0.008 0.036
#> GSM38172 4 0.5070 0.6374 0.192 0.000 0.060 0.748
#> GSM38173 1 0.5075 0.3334 0.644 0.000 0.012 0.344
#> GSM38174 4 0.6306 0.3697 0.392 0.000 0.064 0.544
#> GSM38175 1 0.0376 0.6987 0.992 0.004 0.000 0.004
#> GSM38176 1 0.0657 0.6989 0.984 0.004 0.000 0.012
#> GSM38177 4 0.4881 0.6861 0.196 0.000 0.048 0.756
#> GSM38178 4 0.5268 0.1938 0.452 0.000 0.008 0.540
#> GSM38179 1 0.0524 0.6990 0.988 0.000 0.004 0.008
#> GSM38180 1 0.1356 0.6920 0.960 0.000 0.008 0.032
#> GSM38181 3 0.2021 0.9808 0.040 0.000 0.936 0.024
#> GSM38182 1 0.6123 0.1583 0.572 0.000 0.056 0.372
#> GSM38183 1 0.0524 0.6987 0.988 0.004 0.000 0.008
#> GSM38184 2 0.0188 0.9761 0.000 0.996 0.004 0.000
#> GSM38185 1 0.1762 0.6837 0.944 0.004 0.004 0.048
#> GSM38186 1 0.1492 0.6924 0.956 0.004 0.004 0.036
#> GSM38187 1 0.0657 0.6976 0.984 0.000 0.012 0.004
#> GSM38188 1 0.8175 -0.0743 0.404 0.220 0.016 0.360
#> GSM38189 1 0.5620 0.1335 0.560 0.000 0.024 0.416
#> GSM38190 1 0.6796 -0.0670 0.476 0.064 0.012 0.448
#> GSM38191 4 0.7932 0.1862 0.356 0.164 0.020 0.460
#> GSM38192 1 0.0657 0.6976 0.984 0.004 0.000 0.012
#> GSM38193 2 0.2328 0.9543 0.004 0.924 0.016 0.056
#> GSM38194 4 0.7597 0.3653 0.256 0.168 0.020 0.556
#> GSM38195 1 0.5970 0.1593 0.600 0.000 0.052 0.348
#> GSM38196 4 0.6392 0.4300 0.404 0.000 0.068 0.528
#> GSM38197 1 0.1247 0.6907 0.968 0.012 0.004 0.016
#> GSM38198 4 0.4916 0.6881 0.184 0.000 0.056 0.760
#> GSM38199 3 0.2500 0.9642 0.044 0.000 0.916 0.040
#> GSM38200 2 0.1109 0.9705 0.000 0.968 0.004 0.028
#> GSM38201 4 0.5209 0.6380 0.104 0.000 0.140 0.756
#> GSM38202 4 0.4964 0.6647 0.168 0.000 0.068 0.764
#> GSM38203 3 0.1256 0.9755 0.028 0.000 0.964 0.008
#> GSM38204 3 0.1489 0.9820 0.044 0.000 0.952 0.004
#> GSM38205 3 0.1256 0.9755 0.028 0.000 0.964 0.008
#> GSM38206 3 0.1489 0.9820 0.044 0.000 0.952 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.9312 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.9312 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.9312 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0162 0.9306 0.000 0.996 0.000 0.000 0.004
#> GSM38159 2 0.0613 0.9288 0.004 0.984 0.000 0.004 0.008
#> GSM38160 2 0.4188 0.8381 0.004 0.756 0.004 0.024 0.212
#> GSM38161 2 0.3899 0.8536 0.012 0.788 0.004 0.012 0.184
#> GSM38162 4 0.1697 0.6195 0.060 0.000 0.008 0.932 0.000
#> GSM38163 1 0.0693 0.8860 0.980 0.000 0.000 0.012 0.008
#> GSM38164 5 0.6670 0.4624 0.308 0.000 0.000 0.256 0.436
#> GSM38165 3 0.1862 0.9631 0.016 0.000 0.932 0.004 0.048
#> GSM38166 3 0.1869 0.9635 0.016 0.000 0.936 0.012 0.036
#> GSM38167 4 0.6981 0.3444 0.220 0.000 0.032 0.516 0.232
#> GSM38168 4 0.2027 0.6034 0.040 0.000 0.008 0.928 0.024
#> GSM38169 5 0.6683 0.4608 0.308 0.000 0.000 0.260 0.432
#> GSM38170 1 0.7976 -0.1189 0.440 0.000 0.128 0.192 0.240
#> GSM38171 1 0.1915 0.8648 0.928 0.000 0.000 0.032 0.040
#> GSM38172 4 0.5943 -0.1613 0.080 0.000 0.008 0.468 0.444
#> GSM38173 5 0.6207 0.4338 0.400 0.000 0.000 0.140 0.460
#> GSM38174 4 0.7271 0.1986 0.176 0.000 0.044 0.444 0.336
#> GSM38175 1 0.0798 0.8822 0.976 0.000 0.000 0.008 0.016
#> GSM38176 1 0.0671 0.8874 0.980 0.000 0.000 0.016 0.004
#> GSM38177 4 0.1704 0.6171 0.068 0.000 0.004 0.928 0.000
#> GSM38178 5 0.6503 0.3852 0.220 0.000 0.000 0.300 0.480
#> GSM38179 1 0.0510 0.8874 0.984 0.000 0.000 0.016 0.000
#> GSM38180 1 0.1836 0.8673 0.932 0.000 0.000 0.032 0.036
#> GSM38181 3 0.1869 0.9635 0.016 0.000 0.936 0.012 0.036
#> GSM38182 5 0.7554 0.0213 0.280 0.000 0.044 0.276 0.400
#> GSM38183 1 0.0693 0.8869 0.980 0.000 0.000 0.008 0.012
#> GSM38184 2 0.0162 0.9306 0.000 0.996 0.000 0.000 0.004
#> GSM38185 1 0.2511 0.8239 0.892 0.000 0.000 0.028 0.080
#> GSM38186 1 0.1915 0.8648 0.928 0.000 0.000 0.032 0.040
#> GSM38187 1 0.0798 0.8864 0.976 0.000 0.000 0.008 0.016
#> GSM38188 5 0.8784 0.1201 0.176 0.196 0.020 0.240 0.368
#> GSM38189 5 0.7155 0.2035 0.288 0.000 0.016 0.296 0.400
#> GSM38190 5 0.7210 0.4888 0.284 0.044 0.000 0.188 0.484
#> GSM38191 5 0.6569 0.3874 0.172 0.068 0.000 0.140 0.620
#> GSM38192 1 0.0609 0.8820 0.980 0.000 0.000 0.000 0.020
#> GSM38193 2 0.3861 0.8501 0.012 0.784 0.004 0.008 0.192
#> GSM38194 5 0.6721 0.3420 0.136 0.080 0.000 0.176 0.608
#> GSM38195 5 0.7579 0.0307 0.304 0.000 0.044 0.268 0.384
#> GSM38196 4 0.6958 0.3466 0.212 0.000 0.032 0.520 0.236
#> GSM38197 1 0.0794 0.8781 0.972 0.000 0.000 0.000 0.028
#> GSM38198 4 0.1697 0.6195 0.060 0.000 0.008 0.932 0.000
#> GSM38199 3 0.1799 0.9564 0.012 0.000 0.940 0.028 0.020
#> GSM38200 2 0.1889 0.9173 0.004 0.936 0.004 0.020 0.036
#> GSM38201 4 0.1872 0.5859 0.020 0.000 0.052 0.928 0.000
#> GSM38202 4 0.5663 0.2842 0.068 0.000 0.016 0.612 0.304
#> GSM38203 3 0.0955 0.9578 0.000 0.000 0.968 0.028 0.004
#> GSM38204 3 0.0671 0.9678 0.016 0.000 0.980 0.000 0.004
#> GSM38205 3 0.0955 0.9578 0.000 0.000 0.968 0.028 0.004
#> GSM38206 3 0.0510 0.9683 0.016 0.000 0.984 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0146 0.885 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38156 2 0.0146 0.885 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38157 2 0.0146 0.885 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38158 2 0.0146 0.886 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38159 2 0.0798 0.882 0.012 0.976 0.000 0.004 0.004 0.004
#> GSM38160 2 0.5546 0.724 0.000 0.608 0.004 0.008 0.200 0.180
#> GSM38161 2 0.5061 0.778 0.008 0.692 0.004 0.008 0.172 0.116
#> GSM38162 4 0.0665 0.972 0.008 0.000 0.008 0.980 0.004 0.000
#> GSM38163 1 0.0748 0.942 0.976 0.000 0.000 0.004 0.016 0.004
#> GSM38164 5 0.5287 0.776 0.132 0.000 0.000 0.160 0.672 0.036
#> GSM38165 3 0.3368 0.897 0.004 0.000 0.820 0.000 0.060 0.116
#> GSM38166 3 0.3174 0.902 0.004 0.000 0.836 0.000 0.056 0.104
#> GSM38167 6 0.6555 0.499 0.088 0.000 0.016 0.348 0.064 0.484
#> GSM38168 4 0.1294 0.945 0.008 0.000 0.008 0.956 0.004 0.024
#> GSM38169 5 0.5350 0.775 0.132 0.000 0.000 0.168 0.664 0.036
#> GSM38170 6 0.7223 0.450 0.216 0.000 0.132 0.052 0.080 0.520
#> GSM38171 1 0.2420 0.904 0.888 0.000 0.000 0.004 0.032 0.076
#> GSM38172 5 0.4814 0.673 0.020 0.000 0.000 0.284 0.648 0.048
#> GSM38173 5 0.5711 0.625 0.172 0.000 0.000 0.056 0.636 0.136
#> GSM38174 6 0.5598 0.654 0.080 0.000 0.016 0.184 0.052 0.668
#> GSM38175 1 0.0798 0.941 0.976 0.004 0.000 0.004 0.012 0.004
#> GSM38176 1 0.0767 0.943 0.976 0.000 0.000 0.008 0.012 0.004
#> GSM38177 4 0.1312 0.950 0.012 0.000 0.004 0.956 0.020 0.008
#> GSM38178 5 0.5541 0.748 0.088 0.000 0.000 0.160 0.664 0.088
#> GSM38179 1 0.0653 0.942 0.980 0.000 0.000 0.012 0.004 0.004
#> GSM38180 1 0.2364 0.907 0.892 0.000 0.000 0.004 0.032 0.072
#> GSM38181 3 0.3330 0.901 0.008 0.000 0.828 0.000 0.056 0.108
#> GSM38182 6 0.5738 0.665 0.124 0.000 0.016 0.100 0.084 0.676
#> GSM38183 1 0.0665 0.942 0.980 0.000 0.000 0.008 0.008 0.004
#> GSM38184 2 0.0146 0.886 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38185 1 0.2594 0.899 0.880 0.004 0.000 0.004 0.028 0.084
#> GSM38186 1 0.2420 0.902 0.888 0.000 0.000 0.004 0.032 0.076
#> GSM38187 1 0.0622 0.942 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM38188 6 0.7004 0.464 0.040 0.152 0.004 0.060 0.196 0.548
#> GSM38189 6 0.6264 0.383 0.072 0.000 0.004 0.080 0.332 0.512
#> GSM38190 5 0.5817 0.730 0.128 0.016 0.000 0.084 0.668 0.104
#> GSM38191 5 0.5120 0.644 0.080 0.016 0.000 0.096 0.732 0.076
#> GSM38192 1 0.0508 0.941 0.984 0.004 0.000 0.000 0.012 0.000
#> GSM38193 2 0.5294 0.761 0.008 0.664 0.004 0.008 0.188 0.128
#> GSM38194 5 0.5137 0.643 0.056 0.016 0.000 0.128 0.724 0.076
#> GSM38195 6 0.6006 0.666 0.144 0.000 0.016 0.100 0.092 0.648
#> GSM38196 6 0.6590 0.496 0.088 0.000 0.020 0.352 0.060 0.480
#> GSM38197 1 0.0653 0.940 0.980 0.004 0.000 0.000 0.012 0.004
#> GSM38198 4 0.0665 0.972 0.008 0.000 0.008 0.980 0.004 0.000
#> GSM38199 3 0.3124 0.893 0.004 0.000 0.860 0.020 0.064 0.052
#> GSM38200 2 0.3039 0.848 0.000 0.848 0.004 0.000 0.060 0.088
#> GSM38201 4 0.0748 0.964 0.004 0.000 0.016 0.976 0.000 0.004
#> GSM38202 6 0.6616 0.270 0.012 0.000 0.012 0.264 0.304 0.408
#> GSM38203 3 0.0405 0.918 0.000 0.000 0.988 0.008 0.000 0.004
#> GSM38204 3 0.0260 0.920 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM38205 3 0.0405 0.918 0.000 0.000 0.988 0.008 0.000 0.004
#> GSM38206 3 0.0146 0.921 0.004 0.000 0.996 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
#> CV:kmeans 44 6.25e-07 2
#> CV:kmeans 51 4.01e-10 3
#> CV:kmeans 37 9.45e-06 4
#> CV:kmeans 35 1.34e-05 5
#> CV:kmeans 46 1.55e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.659 0.851 0.932 0.5054 0.493 0.493
#> 3 3 0.343 0.502 0.766 0.3325 0.735 0.510
#> 4 4 0.449 0.536 0.731 0.1264 0.805 0.487
#> 5 5 0.545 0.481 0.692 0.0617 0.885 0.586
#> 6 6 0.604 0.505 0.682 0.0392 0.938 0.705
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
#> GSM38155 2 0.0000 0.918 0.000 1.000
#> GSM38156 2 0.0000 0.918 0.000 1.000
#> GSM38157 2 0.0000 0.918 0.000 1.000
#> GSM38158 2 0.0000 0.918 0.000 1.000
#> GSM38159 2 0.0000 0.918 0.000 1.000
#> GSM38160 2 0.0000 0.918 0.000 1.000
#> GSM38161 2 0.0000 0.918 0.000 1.000
#> GSM38162 1 0.0000 0.928 1.000 0.000
#> GSM38163 1 0.8267 0.626 0.740 0.260
#> GSM38164 1 0.1414 0.919 0.980 0.020
#> GSM38165 1 0.0000 0.928 1.000 0.000
#> GSM38166 1 0.0000 0.928 1.000 0.000
#> GSM38167 1 0.0000 0.928 1.000 0.000
#> GSM38168 1 0.8327 0.616 0.736 0.264
#> GSM38169 1 0.3584 0.890 0.932 0.068
#> GSM38170 1 0.0000 0.928 1.000 0.000
#> GSM38171 2 0.5294 0.840 0.120 0.880
#> GSM38172 1 0.0000 0.928 1.000 0.000
#> GSM38173 2 0.8713 0.617 0.292 0.708
#> GSM38174 1 0.4690 0.866 0.900 0.100
#> GSM38175 2 0.0000 0.918 0.000 1.000
#> GSM38176 2 0.6531 0.794 0.168 0.832
#> GSM38177 1 0.0376 0.927 0.996 0.004
#> GSM38178 1 0.9000 0.566 0.684 0.316
#> GSM38179 1 0.0000 0.928 1.000 0.000
#> GSM38180 2 0.9988 0.115 0.480 0.520
#> GSM38181 1 0.0000 0.928 1.000 0.000
#> GSM38182 1 0.9209 0.535 0.664 0.336
#> GSM38183 2 0.7139 0.764 0.196 0.804
#> GSM38184 2 0.0000 0.918 0.000 1.000
#> GSM38185 2 0.0000 0.918 0.000 1.000
#> GSM38186 2 0.9323 0.515 0.348 0.652
#> GSM38187 1 0.2778 0.902 0.952 0.048
#> GSM38188 2 0.3114 0.886 0.056 0.944
#> GSM38189 1 0.4161 0.878 0.916 0.084
#> GSM38190 2 0.0000 0.918 0.000 1.000
#> GSM38191 2 0.0938 0.913 0.012 0.988
#> GSM38192 2 0.0000 0.918 0.000 1.000
#> GSM38193 2 0.0000 0.918 0.000 1.000
#> GSM38194 2 0.3431 0.885 0.064 0.936
#> GSM38195 1 0.8267 0.670 0.740 0.260
#> GSM38196 1 0.0000 0.928 1.000 0.000
#> GSM38197 2 0.1633 0.908 0.024 0.976
#> GSM38198 1 0.0000 0.928 1.000 0.000
#> GSM38199 1 0.0000 0.928 1.000 0.000
#> GSM38200 2 0.0000 0.918 0.000 1.000
#> GSM38201 1 0.0000 0.928 1.000 0.000
#> GSM38202 1 0.0000 0.928 1.000 0.000
#> GSM38203 1 0.0000 0.928 1.000 0.000
#> GSM38204 1 0.0000 0.928 1.000 0.000
#> GSM38205 1 0.0000 0.928 1.000 0.000
#> GSM38206 1 0.0000 0.928 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38159 2 0.1163 0.8406 0.028 0.972 0.000
#> GSM38160 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38162 3 0.5465 0.5673 0.288 0.000 0.712
#> GSM38163 1 0.5406 0.4961 0.764 0.012 0.224
#> GSM38164 1 0.7329 -0.0274 0.544 0.032 0.424
#> GSM38165 3 0.1031 0.6856 0.024 0.000 0.976
#> GSM38166 3 0.1031 0.6874 0.024 0.000 0.976
#> GSM38167 1 0.6678 -0.2475 0.512 0.008 0.480
#> GSM38168 3 0.9507 0.1270 0.380 0.188 0.432
#> GSM38169 1 0.4808 0.4333 0.804 0.008 0.188
#> GSM38170 3 0.4605 0.6092 0.204 0.000 0.796
#> GSM38171 1 0.6827 0.5489 0.728 0.192 0.080
#> GSM38172 3 0.5254 0.5842 0.264 0.000 0.736
#> GSM38173 1 0.7199 0.5154 0.704 0.204 0.092
#> GSM38174 3 0.9014 0.1851 0.408 0.132 0.460
#> GSM38175 1 0.6267 0.1235 0.548 0.452 0.000
#> GSM38176 1 0.3966 0.5815 0.876 0.100 0.024
#> GSM38177 1 0.7394 -0.2227 0.496 0.032 0.472
#> GSM38178 1 0.9588 0.0928 0.460 0.216 0.324
#> GSM38179 1 0.4521 0.5079 0.816 0.004 0.180
#> GSM38180 1 0.6025 0.5523 0.784 0.076 0.140
#> GSM38181 3 0.3941 0.5942 0.156 0.000 0.844
#> GSM38182 3 0.9746 -0.0187 0.328 0.240 0.432
#> GSM38183 1 0.6044 0.5774 0.772 0.172 0.056
#> GSM38184 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38185 2 0.7091 0.1487 0.416 0.560 0.024
#> GSM38186 1 0.6062 0.5808 0.780 0.148 0.072
#> GSM38187 3 0.6678 -0.1111 0.480 0.008 0.512
#> GSM38188 2 0.5413 0.6989 0.164 0.800 0.036
#> GSM38189 1 0.9131 -0.0132 0.460 0.144 0.396
#> GSM38190 2 0.6359 0.3317 0.404 0.592 0.004
#> GSM38191 2 0.5576 0.7307 0.104 0.812 0.084
#> GSM38192 1 0.6633 0.1160 0.548 0.444 0.008
#> GSM38193 2 0.0237 0.8541 0.004 0.996 0.000
#> GSM38194 2 0.7263 0.5393 0.224 0.692 0.084
#> GSM38195 3 0.9471 0.1369 0.308 0.208 0.484
#> GSM38196 3 0.5621 0.5493 0.308 0.000 0.692
#> GSM38197 2 0.6662 0.6567 0.120 0.752 0.128
#> GSM38198 3 0.5678 0.5379 0.316 0.000 0.684
#> GSM38199 3 0.2537 0.6844 0.080 0.000 0.920
#> GSM38200 2 0.0000 0.8561 0.000 1.000 0.000
#> GSM38201 3 0.4399 0.6372 0.188 0.000 0.812
#> GSM38202 3 0.4452 0.6526 0.192 0.000 0.808
#> GSM38203 3 0.0237 0.6872 0.004 0.000 0.996
#> GSM38204 3 0.1289 0.6825 0.032 0.000 0.968
#> GSM38205 3 0.0424 0.6874 0.008 0.000 0.992
#> GSM38206 3 0.0747 0.6863 0.016 0.000 0.984
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.7903 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0188 0.7894 0.004 0.996 0.000 0.000
#> GSM38157 2 0.0000 0.7903 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.7903 0.000 1.000 0.000 0.000
#> GSM38159 2 0.1902 0.7474 0.064 0.932 0.000 0.004
#> GSM38160 2 0.0188 0.7894 0.004 0.996 0.000 0.000
#> GSM38161 2 0.0779 0.7816 0.016 0.980 0.000 0.004
#> GSM38162 4 0.5321 0.5602 0.056 0.000 0.228 0.716
#> GSM38163 1 0.4571 0.6166 0.808 0.004 0.116 0.072
#> GSM38164 4 0.7582 0.4320 0.240 0.012 0.204 0.544
#> GSM38165 3 0.1510 0.7965 0.028 0.000 0.956 0.016
#> GSM38166 3 0.1151 0.7855 0.008 0.000 0.968 0.024
#> GSM38167 4 0.7418 0.4681 0.240 0.004 0.216 0.540
#> GSM38168 4 0.5743 0.5838 0.064 0.044 0.136 0.756
#> GSM38169 4 0.6773 0.3651 0.320 0.016 0.076 0.588
#> GSM38170 3 0.6208 0.4926 0.168 0.004 0.684 0.144
#> GSM38171 1 0.5632 0.6454 0.768 0.088 0.040 0.104
#> GSM38172 4 0.6280 0.4493 0.072 0.000 0.344 0.584
#> GSM38173 1 0.7887 0.2670 0.532 0.116 0.048 0.304
#> GSM38174 4 0.8262 0.4131 0.172 0.052 0.256 0.520
#> GSM38175 1 0.5420 0.5835 0.688 0.276 0.008 0.028
#> GSM38176 1 0.3189 0.6515 0.884 0.016 0.012 0.088
#> GSM38177 4 0.5700 0.5399 0.160 0.016 0.084 0.740
#> GSM38178 4 0.7873 0.4452 0.184 0.112 0.100 0.604
#> GSM38179 1 0.4626 0.6207 0.804 0.004 0.072 0.120
#> GSM38180 1 0.4378 0.6518 0.836 0.024 0.052 0.088
#> GSM38181 3 0.2722 0.7577 0.064 0.000 0.904 0.032
#> GSM38182 4 0.9613 0.1624 0.208 0.140 0.324 0.328
#> GSM38183 1 0.4716 0.6383 0.804 0.040 0.020 0.136
#> GSM38184 2 0.0000 0.7903 0.000 1.000 0.000 0.000
#> GSM38185 1 0.7422 0.2807 0.492 0.400 0.044 0.064
#> GSM38186 1 0.6820 0.5501 0.668 0.068 0.060 0.204
#> GSM38187 1 0.6507 0.0357 0.472 0.008 0.468 0.052
#> GSM38188 2 0.7177 0.5040 0.088 0.656 0.076 0.180
#> GSM38189 4 0.9206 0.3321 0.240 0.092 0.256 0.412
#> GSM38190 2 0.8206 -0.0325 0.256 0.368 0.012 0.364
#> GSM38191 2 0.8801 0.3403 0.144 0.516 0.148 0.192
#> GSM38192 1 0.5461 0.5774 0.688 0.276 0.020 0.016
#> GSM38193 2 0.1109 0.7785 0.004 0.968 0.000 0.028
#> GSM38194 2 0.7982 0.0441 0.116 0.432 0.040 0.412
#> GSM38195 3 0.9448 -0.1158 0.204 0.128 0.392 0.276
#> GSM38196 4 0.6971 0.3037 0.120 0.000 0.372 0.508
#> GSM38197 2 0.8274 0.1497 0.240 0.496 0.228 0.036
#> GSM38198 4 0.5147 0.5684 0.060 0.000 0.200 0.740
#> GSM38199 3 0.3803 0.6884 0.032 0.000 0.836 0.132
#> GSM38200 2 0.0000 0.7903 0.000 1.000 0.000 0.000
#> GSM38201 4 0.5150 0.4055 0.008 0.000 0.396 0.596
#> GSM38202 4 0.6064 0.3120 0.044 0.000 0.444 0.512
#> GSM38203 3 0.1743 0.7883 0.004 0.000 0.940 0.056
#> GSM38204 3 0.1510 0.7960 0.028 0.000 0.956 0.016
#> GSM38205 3 0.2124 0.7772 0.008 0.000 0.924 0.068
#> GSM38206 3 0.0895 0.7975 0.004 0.000 0.976 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0324 0.83300 0.004 0.992 0.000 0.004 0.000
#> GSM38156 2 0.0579 0.83234 0.000 0.984 0.000 0.008 0.008
#> GSM38157 2 0.0566 0.83164 0.000 0.984 0.000 0.012 0.004
#> GSM38158 2 0.0162 0.83269 0.000 0.996 0.000 0.004 0.000
#> GSM38159 2 0.2162 0.79652 0.064 0.916 0.000 0.008 0.012
#> GSM38160 2 0.0898 0.83071 0.008 0.972 0.000 0.000 0.020
#> GSM38161 2 0.1018 0.82943 0.016 0.968 0.000 0.000 0.016
#> GSM38162 4 0.6740 0.24097 0.036 0.000 0.136 0.536 0.292
#> GSM38163 1 0.5670 0.58541 0.704 0.000 0.088 0.148 0.060
#> GSM38164 4 0.7277 0.18698 0.152 0.016 0.164 0.584 0.084
#> GSM38165 3 0.1082 0.80253 0.000 0.000 0.964 0.028 0.008
#> GSM38166 3 0.1682 0.79084 0.012 0.000 0.940 0.004 0.044
#> GSM38167 5 0.7012 0.28675 0.156 0.008 0.048 0.220 0.568
#> GSM38168 4 0.7229 0.14261 0.072 0.028 0.052 0.480 0.368
#> GSM38169 4 0.5998 0.16573 0.140 0.012 0.024 0.676 0.148
#> GSM38170 3 0.7215 0.25895 0.104 0.000 0.548 0.128 0.220
#> GSM38171 1 0.5630 0.62213 0.728 0.032 0.024 0.084 0.132
#> GSM38172 4 0.5773 0.26431 0.020 0.000 0.248 0.640 0.092
#> GSM38173 4 0.8444 -0.05224 0.324 0.092 0.040 0.400 0.144
#> GSM38174 5 0.5861 0.48877 0.076 0.012 0.096 0.100 0.716
#> GSM38175 1 0.5663 0.60766 0.680 0.208 0.000 0.052 0.060
#> GSM38176 1 0.2888 0.67153 0.880 0.004 0.000 0.056 0.060
#> GSM38177 4 0.7415 0.11488 0.092 0.012 0.076 0.460 0.360
#> GSM38178 4 0.7961 0.06489 0.092 0.068 0.084 0.532 0.224
#> GSM38179 1 0.5656 0.59658 0.700 0.000 0.048 0.156 0.096
#> GSM38180 1 0.4747 0.65162 0.788 0.004 0.060 0.072 0.076
#> GSM38181 3 0.2331 0.77221 0.024 0.000 0.908 0.004 0.064
#> GSM38182 5 0.6904 0.47151 0.092 0.092 0.080 0.076 0.660
#> GSM38183 1 0.5341 0.64689 0.740 0.056 0.008 0.140 0.056
#> GSM38184 2 0.0898 0.82947 0.020 0.972 0.000 0.008 0.000
#> GSM38185 1 0.7991 0.36024 0.464 0.268 0.036 0.048 0.184
#> GSM38186 1 0.5814 0.56748 0.692 0.024 0.012 0.112 0.160
#> GSM38187 3 0.6480 0.13083 0.392 0.004 0.500 0.048 0.056
#> GSM38188 2 0.7329 0.23088 0.036 0.528 0.028 0.132 0.276
#> GSM38189 5 0.8378 0.19160 0.116 0.036 0.120 0.300 0.428
#> GSM38190 4 0.7803 0.09518 0.160 0.316 0.004 0.432 0.088
#> GSM38191 2 0.8482 0.15540 0.060 0.460 0.108 0.256 0.116
#> GSM38192 1 0.5582 0.61295 0.708 0.192 0.032 0.024 0.044
#> GSM38193 2 0.2124 0.80562 0.012 0.924 0.000 0.020 0.044
#> GSM38194 4 0.7446 0.01287 0.060 0.400 0.012 0.416 0.112
#> GSM38195 5 0.6899 0.46009 0.068 0.044 0.164 0.084 0.640
#> GSM38196 5 0.6521 0.33821 0.064 0.000 0.148 0.164 0.624
#> GSM38197 2 0.9121 -0.06911 0.200 0.344 0.284 0.092 0.080
#> GSM38198 4 0.6509 0.20615 0.028 0.000 0.108 0.520 0.344
#> GSM38199 3 0.4203 0.71124 0.032 0.000 0.808 0.108 0.052
#> GSM38200 2 0.0162 0.83293 0.000 0.996 0.000 0.000 0.004
#> GSM38201 4 0.6804 0.21572 0.008 0.000 0.292 0.464 0.236
#> GSM38202 4 0.7376 0.00722 0.028 0.000 0.276 0.380 0.316
#> GSM38203 3 0.2228 0.78336 0.000 0.000 0.912 0.048 0.040
#> GSM38204 3 0.1018 0.79994 0.000 0.000 0.968 0.016 0.016
#> GSM38205 3 0.2795 0.75836 0.000 0.000 0.880 0.064 0.056
#> GSM38206 3 0.0833 0.80142 0.004 0.000 0.976 0.016 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0653 0.88034 0.012 0.980 0.000 0.004 0.000 0.004
#> GSM38156 2 0.1053 0.87820 0.004 0.964 0.000 0.000 0.020 0.012
#> GSM38157 2 0.1026 0.88110 0.004 0.968 0.000 0.012 0.008 0.008
#> GSM38158 2 0.0551 0.88022 0.008 0.984 0.000 0.000 0.004 0.004
#> GSM38159 2 0.3136 0.79641 0.100 0.852 0.000 0.008 0.020 0.020
#> GSM38160 2 0.2816 0.84948 0.004 0.876 0.000 0.012 0.044 0.064
#> GSM38161 2 0.2263 0.86201 0.012 0.912 0.000 0.008 0.036 0.032
#> GSM38162 4 0.3982 0.65102 0.028 0.000 0.084 0.816 0.036 0.036
#> GSM38163 1 0.6280 0.48987 0.628 0.000 0.048 0.068 0.180 0.076
#> GSM38164 5 0.7176 0.33529 0.104 0.012 0.080 0.192 0.560 0.052
#> GSM38165 3 0.1761 0.68870 0.016 0.000 0.936 0.032 0.008 0.008
#> GSM38166 3 0.2688 0.66893 0.004 0.000 0.884 0.024 0.020 0.068
#> GSM38167 6 0.7640 0.33303 0.132 0.000 0.064 0.280 0.084 0.440
#> GSM38168 4 0.5713 0.52067 0.044 0.020 0.032 0.708 0.084 0.112
#> GSM38169 5 0.6993 0.34005 0.100 0.012 0.024 0.212 0.556 0.096
#> GSM38170 3 0.8491 -0.02995 0.172 0.012 0.392 0.108 0.096 0.220
#> GSM38171 1 0.6021 0.57222 0.676 0.024 0.028 0.044 0.144 0.084
#> GSM38172 5 0.7010 0.00612 0.008 0.000 0.152 0.380 0.384 0.076
#> GSM38173 5 0.7725 0.13960 0.260 0.040 0.008 0.108 0.452 0.132
#> GSM38174 6 0.5696 0.47882 0.032 0.008 0.036 0.184 0.064 0.676
#> GSM38175 1 0.5971 0.55892 0.672 0.144 0.008 0.028 0.080 0.068
#> GSM38176 1 0.2765 0.62944 0.884 0.004 0.000 0.024 0.044 0.044
#> GSM38177 4 0.6041 0.50042 0.056 0.008 0.032 0.668 0.132 0.104
#> GSM38178 5 0.7738 0.26154 0.052 0.032 0.036 0.208 0.472 0.200
#> GSM38179 1 0.6225 0.54780 0.660 0.008 0.036 0.080 0.108 0.108
#> GSM38180 1 0.5907 0.57149 0.672 0.004 0.040 0.040 0.136 0.108
#> GSM38181 3 0.2741 0.66648 0.028 0.000 0.884 0.012 0.012 0.064
#> GSM38182 6 0.5430 0.49101 0.024 0.056 0.100 0.040 0.044 0.736
#> GSM38183 1 0.5774 0.57093 0.696 0.024 0.012 0.064 0.116 0.088
#> GSM38184 2 0.1321 0.87860 0.020 0.952 0.000 0.000 0.004 0.024
#> GSM38185 1 0.8387 0.31235 0.392 0.228 0.032 0.040 0.104 0.204
#> GSM38186 1 0.7405 0.48269 0.548 0.032 0.032 0.084 0.176 0.128
#> GSM38187 3 0.7704 -0.06815 0.340 0.004 0.384 0.036 0.116 0.120
#> GSM38188 2 0.7086 0.20333 0.024 0.508 0.004 0.080 0.128 0.256
#> GSM38189 6 0.8473 -0.03307 0.080 0.040 0.068 0.136 0.336 0.340
#> GSM38190 5 0.7485 0.30588 0.096 0.244 0.000 0.084 0.488 0.088
#> GSM38191 5 0.8755 0.25088 0.052 0.284 0.112 0.096 0.364 0.092
#> GSM38192 1 0.5992 0.57749 0.692 0.100 0.028 0.028 0.092 0.060
#> GSM38193 2 0.3361 0.80492 0.004 0.844 0.000 0.020 0.064 0.068
#> GSM38194 5 0.7850 0.29145 0.020 0.224 0.012 0.232 0.408 0.104
#> GSM38195 6 0.6871 0.47168 0.052 0.056 0.152 0.076 0.044 0.620
#> GSM38196 6 0.7353 0.35501 0.088 0.000 0.120 0.280 0.044 0.468
#> GSM38197 3 0.9664 -0.12858 0.164 0.212 0.264 0.088 0.120 0.152
#> GSM38198 4 0.3771 0.63777 0.020 0.000 0.064 0.824 0.016 0.076
#> GSM38199 3 0.6203 0.46530 0.036 0.000 0.636 0.140 0.132 0.056
#> GSM38200 2 0.1237 0.87608 0.000 0.956 0.000 0.004 0.020 0.020
#> GSM38201 4 0.4166 0.61111 0.012 0.000 0.188 0.756 0.024 0.020
#> GSM38202 4 0.7850 0.25091 0.024 0.000 0.196 0.400 0.192 0.188
#> GSM38203 3 0.2282 0.67517 0.000 0.000 0.900 0.068 0.020 0.012
#> GSM38204 3 0.1364 0.68853 0.000 0.000 0.952 0.020 0.016 0.012
#> GSM38205 3 0.2833 0.62676 0.000 0.000 0.836 0.148 0.012 0.004
#> GSM38206 3 0.1138 0.68840 0.000 0.000 0.960 0.024 0.004 0.012
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> CV:skmeans 51 1.12e-03 2
#> CV:skmeans 36 2.78e-04 3
#> CV:skmeans 32 5.03e-05 4
#> CV:skmeans 27 4.03e-05 5
#> CV:skmeans 29 1.55e-04 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.514 0.830 0.913 0.4532 0.527 0.527
#> 3 3 0.469 0.790 0.886 0.2881 0.868 0.755
#> 4 4 0.662 0.794 0.893 0.2338 0.857 0.659
#> 5 5 0.709 0.679 0.860 0.0969 0.888 0.618
#> 6 6 0.738 0.654 0.837 0.0285 0.965 0.832
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
#> GSM38155 2 0.0000 0.937 0.000 1.000
#> GSM38156 2 0.1184 0.928 0.016 0.984
#> GSM38157 2 0.0000 0.937 0.000 1.000
#> GSM38158 2 0.0000 0.937 0.000 1.000
#> GSM38159 2 0.0000 0.937 0.000 1.000
#> GSM38160 2 0.0000 0.937 0.000 1.000
#> GSM38161 2 0.0000 0.937 0.000 1.000
#> GSM38162 1 0.0672 0.832 0.992 0.008
#> GSM38163 2 0.0000 0.937 0.000 1.000
#> GSM38164 1 0.7815 0.694 0.768 0.232
#> GSM38165 1 0.9933 0.235 0.548 0.452
#> GSM38166 2 0.8144 0.696 0.252 0.748
#> GSM38167 1 0.0672 0.832 0.992 0.008
#> GSM38168 1 0.7602 0.743 0.780 0.220
#> GSM38169 2 0.7815 0.718 0.232 0.768
#> GSM38170 1 0.9881 0.396 0.564 0.436
#> GSM38171 2 0.0000 0.937 0.000 1.000
#> GSM38172 1 0.0376 0.830 0.996 0.004
#> GSM38173 2 0.6438 0.800 0.164 0.836
#> GSM38174 1 0.1184 0.833 0.984 0.016
#> GSM38175 2 0.0000 0.937 0.000 1.000
#> GSM38176 2 0.0000 0.937 0.000 1.000
#> GSM38177 1 0.0672 0.832 0.992 0.008
#> GSM38178 2 0.8207 0.680 0.256 0.744
#> GSM38179 2 0.0672 0.933 0.008 0.992
#> GSM38180 2 0.0000 0.937 0.000 1.000
#> GSM38181 2 0.0672 0.932 0.008 0.992
#> GSM38182 2 0.7528 0.738 0.216 0.784
#> GSM38183 2 0.0000 0.937 0.000 1.000
#> GSM38184 2 0.0000 0.937 0.000 1.000
#> GSM38185 2 0.0000 0.937 0.000 1.000
#> GSM38186 2 0.4815 0.830 0.104 0.896
#> GSM38187 2 0.0000 0.937 0.000 1.000
#> GSM38188 2 0.7376 0.748 0.208 0.792
#> GSM38189 1 0.9608 0.424 0.616 0.384
#> GSM38190 2 0.5408 0.842 0.124 0.876
#> GSM38191 2 0.3114 0.901 0.056 0.944
#> GSM38192 2 0.0000 0.937 0.000 1.000
#> GSM38193 2 0.0376 0.935 0.004 0.996
#> GSM38194 1 0.8207 0.731 0.744 0.256
#> GSM38195 2 0.0672 0.933 0.008 0.992
#> GSM38196 1 0.6048 0.796 0.852 0.148
#> GSM38197 2 0.0000 0.937 0.000 1.000
#> GSM38198 1 0.1184 0.833 0.984 0.016
#> GSM38199 1 0.2043 0.828 0.968 0.032
#> GSM38200 2 0.0000 0.937 0.000 1.000
#> GSM38201 1 0.0672 0.832 0.992 0.008
#> GSM38202 1 0.0938 0.833 0.988 0.012
#> GSM38203 1 0.7453 0.744 0.788 0.212
#> GSM38204 2 0.0672 0.932 0.008 0.992
#> GSM38205 1 0.5519 0.802 0.872 0.128
#> GSM38206 1 0.8661 0.686 0.712 0.288
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38156 2 0.4677 0.846 0.028 0.840 0.132
#> GSM38157 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38158 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38159 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38160 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38161 2 0.2959 0.866 0.000 0.900 0.100
#> GSM38162 1 0.0000 0.789 1.000 0.000 0.000
#> GSM38163 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38164 1 0.4399 0.675 0.812 0.188 0.000
#> GSM38165 3 0.4217 0.864 0.100 0.032 0.868
#> GSM38166 3 0.3918 0.837 0.012 0.120 0.868
#> GSM38167 1 0.0000 0.789 1.000 0.000 0.000
#> GSM38168 1 0.5178 0.604 0.744 0.256 0.000
#> GSM38169 2 0.5363 0.623 0.276 0.724 0.000
#> GSM38170 1 0.6442 0.320 0.564 0.432 0.004
#> GSM38171 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38172 1 0.0000 0.789 1.000 0.000 0.000
#> GSM38173 2 0.4291 0.749 0.180 0.820 0.000
#> GSM38174 1 0.0424 0.789 0.992 0.008 0.000
#> GSM38175 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38176 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38177 1 0.0000 0.789 1.000 0.000 0.000
#> GSM38178 2 0.5560 0.582 0.300 0.700 0.000
#> GSM38179 2 0.0424 0.883 0.008 0.992 0.000
#> GSM38180 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38181 3 0.3941 0.807 0.000 0.156 0.844
#> GSM38182 2 0.5216 0.645 0.260 0.740 0.000
#> GSM38183 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38184 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38185 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38186 2 0.3038 0.823 0.104 0.896 0.000
#> GSM38187 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38188 2 0.5365 0.657 0.252 0.744 0.004
#> GSM38189 1 0.5835 0.455 0.660 0.340 0.000
#> GSM38190 2 0.4164 0.791 0.144 0.848 0.008
#> GSM38191 2 0.1964 0.860 0.056 0.944 0.000
#> GSM38192 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38193 2 0.3482 0.857 0.000 0.872 0.128
#> GSM38194 1 0.5058 0.661 0.756 0.244 0.000
#> GSM38195 2 0.0747 0.880 0.016 0.984 0.000
#> GSM38196 1 0.4346 0.684 0.816 0.184 0.000
#> GSM38197 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38198 1 0.1163 0.784 0.972 0.028 0.000
#> GSM38199 3 0.5926 0.569 0.356 0.000 0.644
#> GSM38200 2 0.3551 0.855 0.000 0.868 0.132
#> GSM38201 1 0.0000 0.789 1.000 0.000 0.000
#> GSM38202 1 0.0237 0.789 0.996 0.004 0.000
#> GSM38203 3 0.3551 0.855 0.132 0.000 0.868
#> GSM38204 3 0.3551 0.828 0.000 0.132 0.868
#> GSM38205 3 0.3619 0.853 0.136 0.000 0.864
#> GSM38206 3 0.3826 0.860 0.124 0.008 0.868
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.2408 0.905 0.104 0.896 0.000 0.000
#> GSM38156 2 0.1211 0.901 0.040 0.960 0.000 0.000
#> GSM38157 2 0.1389 0.906 0.048 0.952 0.000 0.000
#> GSM38158 2 0.1389 0.906 0.048 0.952 0.000 0.000
#> GSM38159 2 0.3356 0.881 0.176 0.824 0.000 0.000
#> GSM38160 2 0.3726 0.810 0.212 0.788 0.000 0.000
#> GSM38161 1 0.5000 -0.220 0.500 0.500 0.000 0.000
#> GSM38162 4 0.0592 0.836 0.000 0.016 0.000 0.984
#> GSM38163 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38164 4 0.4225 0.716 0.184 0.024 0.000 0.792
#> GSM38165 3 0.0000 0.955 0.000 0.000 1.000 0.000
#> GSM38166 3 0.0000 0.955 0.000 0.000 1.000 0.000
#> GSM38167 4 0.0895 0.837 0.004 0.020 0.000 0.976
#> GSM38168 4 0.4692 0.699 0.212 0.032 0.000 0.756
#> GSM38169 1 0.4927 0.633 0.712 0.024 0.000 0.264
#> GSM38170 4 0.5516 0.341 0.428 0.012 0.004 0.556
#> GSM38171 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0817 0.833 0.000 0.024 0.000 0.976
#> GSM38173 1 0.3448 0.758 0.828 0.004 0.000 0.168
#> GSM38174 4 0.1059 0.839 0.012 0.016 0.000 0.972
#> GSM38175 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38177 4 0.0592 0.836 0.000 0.016 0.000 0.984
#> GSM38178 1 0.5088 0.595 0.688 0.024 0.000 0.288
#> GSM38179 1 0.0336 0.862 0.992 0.000 0.000 0.008
#> GSM38180 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38181 3 0.1022 0.926 0.032 0.000 0.968 0.000
#> GSM38182 1 0.4932 0.655 0.728 0.032 0.000 0.240
#> GSM38183 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38184 2 0.3219 0.889 0.164 0.836 0.000 0.000
#> GSM38185 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38186 1 0.2408 0.784 0.896 0.000 0.000 0.104
#> GSM38187 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38188 1 0.6637 0.465 0.572 0.324 0.000 0.104
#> GSM38189 4 0.5311 0.454 0.328 0.024 0.000 0.648
#> GSM38190 1 0.5033 0.727 0.760 0.168 0.000 0.072
#> GSM38191 1 0.1637 0.842 0.940 0.000 0.000 0.060
#> GSM38192 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38193 2 0.3486 0.862 0.188 0.812 0.000 0.000
#> GSM38194 4 0.5204 0.733 0.160 0.088 0.000 0.752
#> GSM38195 1 0.0804 0.860 0.980 0.012 0.000 0.008
#> GSM38196 4 0.3862 0.765 0.152 0.024 0.000 0.824
#> GSM38197 1 0.0000 0.865 1.000 0.000 0.000 0.000
#> GSM38198 4 0.1406 0.834 0.016 0.024 0.000 0.960
#> GSM38199 3 0.3942 0.683 0.000 0.000 0.764 0.236
#> GSM38200 2 0.1302 0.904 0.044 0.956 0.000 0.000
#> GSM38201 4 0.0592 0.836 0.000 0.016 0.000 0.984
#> GSM38202 4 0.1004 0.833 0.004 0.024 0.000 0.972
#> GSM38203 3 0.0000 0.955 0.000 0.000 1.000 0.000
#> GSM38204 3 0.0000 0.955 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0336 0.950 0.000 0.000 0.992 0.008
#> GSM38206 3 0.0000 0.955 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.1410 0.8122 0.060 0.940 0.000 0.000 0.000
#> GSM38156 2 0.0162 0.8026 0.004 0.996 0.000 0.000 0.000
#> GSM38157 2 0.0162 0.8026 0.004 0.996 0.000 0.000 0.000
#> GSM38158 2 0.0162 0.8026 0.004 0.996 0.000 0.000 0.000
#> GSM38159 2 0.2516 0.8030 0.140 0.860 0.000 0.000 0.000
#> GSM38160 2 0.3496 0.7229 0.200 0.788 0.000 0.000 0.012
#> GSM38161 2 0.4307 0.1439 0.496 0.504 0.000 0.000 0.000
#> GSM38162 4 0.2516 0.7092 0.000 0.000 0.000 0.860 0.140
#> GSM38163 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38164 5 0.4576 0.0615 0.016 0.000 0.000 0.376 0.608
#> GSM38165 3 0.0000 0.9552 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0000 0.9552 0.000 0.000 1.000 0.000 0.000
#> GSM38167 4 0.3300 0.5760 0.000 0.004 0.000 0.792 0.204
#> GSM38168 4 0.1205 0.6848 0.040 0.004 0.000 0.956 0.000
#> GSM38169 5 0.4313 0.3133 0.356 0.000 0.000 0.008 0.636
#> GSM38170 4 0.5646 0.2534 0.356 0.004 0.000 0.564 0.076
#> GSM38171 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38172 5 0.4074 0.1128 0.000 0.000 0.000 0.364 0.636
#> GSM38173 1 0.3395 0.6338 0.764 0.000 0.000 0.000 0.236
#> GSM38174 5 0.4449 0.0619 0.000 0.004 0.000 0.484 0.512
#> GSM38175 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38177 4 0.3039 0.6932 0.000 0.000 0.000 0.808 0.192
#> GSM38178 5 0.1121 0.5853 0.044 0.000 0.000 0.000 0.956
#> GSM38179 1 0.0290 0.8870 0.992 0.000 0.000 0.008 0.000
#> GSM38180 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38181 3 0.0880 0.9261 0.032 0.000 0.968 0.000 0.000
#> GSM38182 5 0.2674 0.5384 0.000 0.004 0.000 0.140 0.856
#> GSM38183 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38184 2 0.2329 0.8094 0.124 0.876 0.000 0.000 0.000
#> GSM38185 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38186 1 0.2074 0.7975 0.896 0.000 0.000 0.104 0.000
#> GSM38187 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38188 5 0.2648 0.5401 0.000 0.152 0.000 0.000 0.848
#> GSM38189 5 0.0000 0.5852 0.000 0.000 0.000 0.000 1.000
#> GSM38190 1 0.6244 0.0930 0.496 0.156 0.000 0.000 0.348
#> GSM38191 1 0.1341 0.8523 0.944 0.000 0.000 0.000 0.056
#> GSM38192 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38193 2 0.2648 0.7901 0.152 0.848 0.000 0.000 0.000
#> GSM38194 4 0.6774 0.4955 0.124 0.084 0.000 0.600 0.192
#> GSM38195 1 0.6338 0.0826 0.468 0.004 0.000 0.140 0.388
#> GSM38196 4 0.1471 0.6790 0.020 0.004 0.000 0.952 0.024
#> GSM38197 1 0.0000 0.8917 1.000 0.000 0.000 0.000 0.000
#> GSM38198 4 0.1952 0.7147 0.004 0.000 0.000 0.912 0.084
#> GSM38199 3 0.4444 0.6856 0.000 0.000 0.760 0.136 0.104
#> GSM38200 2 0.3689 0.5807 0.004 0.740 0.000 0.000 0.256
#> GSM38201 4 0.2516 0.7092 0.000 0.000 0.000 0.860 0.140
#> GSM38202 4 0.4287 0.3063 0.000 0.000 0.000 0.540 0.460
#> GSM38203 3 0.0000 0.9552 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 0.9552 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0290 0.9503 0.000 0.000 0.992 0.008 0.000
#> GSM38206 3 0.0000 0.9552 0.000 0.000 1.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
#> GSM38155 2 0.1204 0.7593 0.056 0.944 0.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.7521 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.7521 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.7521 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38159 2 0.2260 0.7442 0.140 0.860 0.000 0.000 0.000 0.000
#> GSM38160 2 0.7248 0.2807 0.192 0.392 0.000 0.000 0.296 0.120
#> GSM38161 2 0.3868 0.1199 0.496 0.504 0.000 0.000 0.000 0.000
#> GSM38162 4 0.0000 0.7371 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38163 1 0.1007 0.8993 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM38164 5 0.3515 0.3366 0.000 0.000 0.000 0.324 0.676 0.000
#> GSM38165 3 0.0000 0.9549 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0000 0.9549 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38167 4 0.5058 0.4936 0.000 0.000 0.000 0.600 0.108 0.292
#> GSM38168 4 0.0000 0.7371 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38169 5 0.3601 0.3537 0.312 0.000 0.000 0.004 0.684 0.000
#> GSM38170 6 0.6380 -0.1742 0.092 0.000 0.004 0.384 0.064 0.456
#> GSM38171 1 0.1007 0.8993 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM38172 5 0.3607 0.3174 0.000 0.000 0.000 0.348 0.652 0.000
#> GSM38173 1 0.3390 0.5947 0.704 0.000 0.000 0.000 0.296 0.000
#> GSM38174 6 0.1957 0.5678 0.000 0.000 0.000 0.112 0.000 0.888
#> GSM38175 1 0.0146 0.9031 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38176 1 0.1007 0.8993 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM38177 4 0.2491 0.6548 0.000 0.000 0.000 0.836 0.164 0.000
#> GSM38178 5 0.4203 0.3883 0.032 0.000 0.000 0.000 0.652 0.316
#> GSM38179 1 0.1265 0.8963 0.948 0.000 0.000 0.008 0.044 0.000
#> GSM38180 1 0.0865 0.9009 0.964 0.000 0.000 0.000 0.036 0.000
#> GSM38181 3 0.0790 0.9240 0.032 0.000 0.968 0.000 0.000 0.000
#> GSM38182 6 0.2178 0.5417 0.000 0.000 0.000 0.000 0.132 0.868
#> GSM38183 1 0.0146 0.9031 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38184 2 0.2048 0.7537 0.120 0.880 0.000 0.000 0.000 0.000
#> GSM38185 1 0.0146 0.9031 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38186 1 0.2795 0.8044 0.856 0.000 0.000 0.100 0.044 0.000
#> GSM38187 1 0.0146 0.9031 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38188 6 0.5547 0.0693 0.000 0.152 0.000 0.000 0.332 0.516
#> GSM38189 5 0.3620 0.3446 0.000 0.000 0.000 0.000 0.648 0.352
#> GSM38190 1 0.5700 -0.0416 0.436 0.160 0.000 0.000 0.404 0.000
#> GSM38191 1 0.1349 0.8693 0.940 0.000 0.000 0.000 0.056 0.004
#> GSM38192 1 0.0146 0.9031 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38193 2 0.2378 0.7302 0.152 0.848 0.000 0.000 0.000 0.000
#> GSM38194 4 0.6153 0.4280 0.124 0.088 0.000 0.592 0.196 0.000
#> GSM38195 6 0.2494 0.5412 0.120 0.000 0.000 0.000 0.016 0.864
#> GSM38196 4 0.3717 0.4370 0.000 0.000 0.000 0.616 0.000 0.384
#> GSM38197 1 0.0146 0.9031 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM38198 4 0.0000 0.7371 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38199 3 0.3997 0.6968 0.000 0.000 0.760 0.132 0.108 0.000
#> GSM38200 2 0.3175 0.5088 0.000 0.744 0.000 0.000 0.000 0.256
#> GSM38201 4 0.0000 0.7371 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38202 4 0.4242 0.1395 0.000 0.000 0.000 0.536 0.448 0.016
#> GSM38203 3 0.0000 0.9549 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.9549 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0260 0.9496 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38206 3 0.0000 0.9549 0.000 0.000 1.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
#> CV:pam 49 5.32e-03 2
#> CV:pam 50 8.21e-04 3
#> CV:pam 48 1.11e-07 4
#> CV:pam 42 4.11e-06 5
#> CV:pam 38 3.86e-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["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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.195 0.608 0.762 0.4360 0.618 0.618
#> 3 3 0.901 0.929 0.969 0.1901 0.736 0.617
#> 4 4 0.732 0.845 0.919 0.3492 0.799 0.602
#> 5 5 0.718 0.666 0.844 0.1323 0.867 0.582
#> 6 6 0.781 0.704 0.847 0.0432 0.949 0.749
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM38155 2 0.000 0.8367 0.000 1.000
#> GSM38156 2 0.000 0.8367 0.000 1.000
#> GSM38157 2 0.000 0.8367 0.000 1.000
#> GSM38158 2 0.000 0.8367 0.000 1.000
#> GSM38159 2 0.443 0.7392 0.092 0.908
#> GSM38160 2 0.000 0.8367 0.000 1.000
#> GSM38161 2 0.000 0.8367 0.000 1.000
#> GSM38162 1 0.402 0.6744 0.920 0.080
#> GSM38163 1 0.925 0.5398 0.660 0.340
#> GSM38164 1 0.552 0.6858 0.872 0.128
#> GSM38165 1 0.814 0.5405 0.748 0.252
#> GSM38166 1 0.814 0.5405 0.748 0.252
#> GSM38167 1 0.260 0.6850 0.956 0.044
#> GSM38168 1 0.625 0.6759 0.844 0.156
#> GSM38169 1 0.224 0.6788 0.964 0.036
#> GSM38170 1 0.563 0.6455 0.868 0.132
#> GSM38171 1 0.904 0.5660 0.680 0.320
#> GSM38172 1 0.416 0.6741 0.916 0.084
#> GSM38173 1 0.886 0.6013 0.696 0.304
#> GSM38174 1 0.876 0.6191 0.704 0.296
#> GSM38175 1 0.936 0.5239 0.648 0.352
#> GSM38176 1 0.921 0.5439 0.664 0.336
#> GSM38177 1 0.388 0.6748 0.924 0.076
#> GSM38178 1 0.891 0.6086 0.692 0.308
#> GSM38179 1 0.939 0.5174 0.644 0.356
#> GSM38180 1 0.821 0.6234 0.744 0.256
#> GSM38181 1 0.814 0.5405 0.748 0.252
#> GSM38182 1 0.925 0.5722 0.660 0.340
#> GSM38183 1 0.932 0.5304 0.652 0.348
#> GSM38184 2 0.000 0.8367 0.000 1.000
#> GSM38185 1 0.998 0.3437 0.524 0.476
#> GSM38186 1 0.932 0.5350 0.652 0.348
#> GSM38187 1 0.506 0.6557 0.888 0.112
#> GSM38188 2 0.909 0.1541 0.324 0.676
#> GSM38189 1 0.808 0.6473 0.752 0.248
#> GSM38190 1 0.969 0.5157 0.604 0.396
#> GSM38191 2 0.913 0.1379 0.328 0.672
#> GSM38192 1 0.988 0.4138 0.564 0.436
#> GSM38193 2 0.141 0.8214 0.020 0.980
#> GSM38194 1 0.949 0.5575 0.632 0.368
#> GSM38195 1 0.921 0.5846 0.664 0.336
#> GSM38196 1 0.204 0.6817 0.968 0.032
#> GSM38197 2 0.952 0.0257 0.372 0.628
#> GSM38198 1 0.402 0.6744 0.920 0.080
#> GSM38199 1 0.506 0.6575 0.888 0.112
#> GSM38200 2 0.000 0.8367 0.000 1.000
#> GSM38201 1 0.443 0.6756 0.908 0.092
#> GSM38202 1 0.327 0.6802 0.940 0.060
#> GSM38203 1 0.814 0.5405 0.748 0.252
#> GSM38204 1 0.814 0.5405 0.748 0.252
#> GSM38205 1 0.814 0.5405 0.748 0.252
#> GSM38206 1 0.814 0.5405 0.748 0.252
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38159 2 0.4654 0.672 0.208 0.792 0.000
#> GSM38160 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38162 1 0.0237 0.958 0.996 0.000 0.004
#> GSM38163 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38164 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38165 3 0.0000 1.000 0.000 0.000 1.000
#> GSM38166 3 0.0000 1.000 0.000 0.000 1.000
#> GSM38167 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38168 1 0.0237 0.958 0.996 0.004 0.000
#> GSM38169 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38170 1 0.0424 0.956 0.992 0.008 0.000
#> GSM38171 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38172 1 0.0237 0.958 0.996 0.000 0.004
#> GSM38173 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38174 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38175 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38176 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38177 1 0.0237 0.958 0.996 0.000 0.004
#> GSM38178 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38179 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38180 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38181 3 0.0000 1.000 0.000 0.000 1.000
#> GSM38182 1 0.0424 0.956 0.992 0.008 0.000
#> GSM38183 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38184 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38185 1 0.0592 0.954 0.988 0.012 0.000
#> GSM38186 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38187 1 0.1170 0.948 0.976 0.008 0.016
#> GSM38188 1 0.5098 0.692 0.752 0.248 0.000
#> GSM38189 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38190 1 0.0892 0.949 0.980 0.020 0.000
#> GSM38191 1 0.4654 0.752 0.792 0.208 0.000
#> GSM38192 1 0.0237 0.958 0.996 0.004 0.000
#> GSM38193 2 0.2356 0.870 0.072 0.928 0.000
#> GSM38194 1 0.4654 0.751 0.792 0.208 0.000
#> GSM38195 1 0.0424 0.956 0.992 0.008 0.000
#> GSM38196 1 0.0000 0.959 1.000 0.000 0.000
#> GSM38197 1 0.4399 0.777 0.812 0.188 0.000
#> GSM38198 1 0.0237 0.958 0.996 0.000 0.004
#> GSM38199 1 0.5968 0.452 0.636 0.000 0.364
#> GSM38200 2 0.0000 0.950 0.000 1.000 0.000
#> GSM38201 1 0.0747 0.951 0.984 0.000 0.016
#> GSM38202 1 0.0237 0.958 0.996 0.000 0.004
#> GSM38203 3 0.0000 1.000 0.000 0.000 1.000
#> GSM38204 3 0.0000 1.000 0.000 0.000 1.000
#> GSM38205 3 0.0000 1.000 0.000 0.000 1.000
#> GSM38206 3 0.0000 1.000 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38159 2 0.3356 0.773 0.176 0.824 0.000 0.000
#> GSM38160 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38162 4 0.0000 0.886 0.000 0.000 0.000 1.000
#> GSM38163 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38164 1 0.3764 0.773 0.784 0.000 0.000 0.216
#> GSM38165 3 0.0000 0.961 0.000 0.000 1.000 0.000
#> GSM38166 3 0.0000 0.961 0.000 0.000 1.000 0.000
#> GSM38167 1 0.4304 0.697 0.716 0.000 0.000 0.284
#> GSM38168 4 0.1022 0.882 0.032 0.000 0.000 0.968
#> GSM38169 1 0.4605 0.604 0.664 0.000 0.000 0.336
#> GSM38170 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38171 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0469 0.889 0.012 0.000 0.000 0.988
#> GSM38173 1 0.2530 0.842 0.888 0.000 0.000 0.112
#> GSM38174 1 0.3172 0.819 0.840 0.000 0.000 0.160
#> GSM38175 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38177 4 0.1792 0.861 0.068 0.000 0.000 0.932
#> GSM38178 1 0.4193 0.715 0.732 0.000 0.000 0.268
#> GSM38179 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38180 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38181 3 0.0000 0.961 0.000 0.000 1.000 0.000
#> GSM38182 1 0.2704 0.838 0.876 0.000 0.000 0.124
#> GSM38183 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38184 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38185 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38186 1 0.0469 0.863 0.988 0.000 0.000 0.012
#> GSM38187 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38188 1 0.6712 0.454 0.552 0.344 0.000 0.104
#> GSM38189 1 0.2921 0.829 0.860 0.000 0.000 0.140
#> GSM38190 1 0.4337 0.809 0.808 0.052 0.000 0.140
#> GSM38191 1 0.7567 0.326 0.484 0.240 0.000 0.276
#> GSM38192 1 0.0000 0.864 1.000 0.000 0.000 0.000
#> GSM38193 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38194 4 0.4379 0.734 0.036 0.172 0.000 0.792
#> GSM38195 1 0.2647 0.839 0.880 0.000 0.000 0.120
#> GSM38196 4 0.4679 0.323 0.352 0.000 0.000 0.648
#> GSM38197 1 0.3745 0.815 0.852 0.088 0.000 0.060
#> GSM38198 4 0.0000 0.886 0.000 0.000 0.000 1.000
#> GSM38199 3 0.5477 0.656 0.092 0.000 0.728 0.180
#> GSM38200 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38201 4 0.0000 0.886 0.000 0.000 0.000 1.000
#> GSM38202 4 0.0592 0.889 0.016 0.000 0.000 0.984
#> GSM38203 3 0.0000 0.961 0.000 0.000 1.000 0.000
#> GSM38204 3 0.0000 0.961 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0000 0.961 0.000 0.000 1.000 0.000
#> GSM38206 3 0.0000 0.961 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.1952 0.8971 0.084 0.912 0.000 0.000 0.004
#> GSM38160 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38162 4 0.0162 0.7502 0.000 0.000 0.000 0.996 0.004
#> GSM38163 1 0.0510 0.7990 0.984 0.000 0.000 0.000 0.016
#> GSM38164 5 0.6358 0.2718 0.208 0.000 0.000 0.276 0.516
#> GSM38165 3 0.0162 0.9428 0.000 0.000 0.996 0.000 0.004
#> GSM38166 3 0.0162 0.9428 0.000 0.000 0.996 0.000 0.004
#> GSM38167 5 0.5580 0.0559 0.088 0.000 0.000 0.336 0.576
#> GSM38168 4 0.2804 0.7292 0.056 0.008 0.000 0.888 0.048
#> GSM38169 5 0.6364 0.1255 0.188 0.000 0.000 0.312 0.500
#> GSM38170 1 0.4307 0.1126 0.500 0.000 0.000 0.000 0.500
#> GSM38171 1 0.1043 0.7991 0.960 0.000 0.000 0.000 0.040
#> GSM38172 4 0.2930 0.7140 0.004 0.000 0.000 0.832 0.164
#> GSM38173 1 0.4890 -0.0938 0.524 0.000 0.000 0.024 0.452
#> GSM38174 5 0.2377 0.5935 0.128 0.000 0.000 0.000 0.872
#> GSM38175 1 0.0794 0.8024 0.972 0.000 0.000 0.000 0.028
#> GSM38176 1 0.0510 0.7990 0.984 0.000 0.000 0.000 0.016
#> GSM38177 4 0.5406 0.2021 0.056 0.000 0.000 0.480 0.464
#> GSM38178 5 0.4210 0.4821 0.096 0.000 0.000 0.124 0.780
#> GSM38179 1 0.0510 0.7990 0.984 0.000 0.000 0.000 0.016
#> GSM38180 1 0.0880 0.8021 0.968 0.000 0.000 0.000 0.032
#> GSM38181 3 0.0162 0.9428 0.000 0.000 0.996 0.000 0.004
#> GSM38182 5 0.3177 0.5191 0.208 0.000 0.000 0.000 0.792
#> GSM38183 1 0.0510 0.7990 0.984 0.000 0.000 0.000 0.016
#> GSM38184 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38185 1 0.4201 0.3870 0.592 0.000 0.000 0.000 0.408
#> GSM38186 1 0.2020 0.7409 0.900 0.000 0.000 0.000 0.100
#> GSM38187 1 0.3333 0.6780 0.788 0.000 0.004 0.000 0.208
#> GSM38188 5 0.4397 0.4798 0.028 0.276 0.000 0.000 0.696
#> GSM38189 5 0.3177 0.5387 0.208 0.000 0.000 0.000 0.792
#> GSM38190 5 0.6036 0.3066 0.376 0.096 0.000 0.008 0.520
#> GSM38191 5 0.4805 0.5220 0.020 0.208 0.000 0.044 0.728
#> GSM38192 1 0.1341 0.7904 0.944 0.000 0.000 0.000 0.056
#> GSM38193 2 0.0510 0.9740 0.000 0.984 0.000 0.000 0.016
#> GSM38194 4 0.5424 0.5985 0.056 0.164 0.000 0.716 0.064
#> GSM38195 5 0.3274 0.5044 0.220 0.000 0.000 0.000 0.780
#> GSM38196 5 0.4723 -0.2038 0.016 0.000 0.000 0.448 0.536
#> GSM38197 5 0.4559 0.5278 0.152 0.100 0.000 0.000 0.748
#> GSM38198 4 0.0162 0.7502 0.000 0.000 0.000 0.996 0.004
#> GSM38199 3 0.5592 0.4764 0.008 0.000 0.628 0.088 0.276
#> GSM38200 2 0.0000 0.9871 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.0162 0.7502 0.000 0.000 0.000 0.996 0.004
#> GSM38202 4 0.4517 0.3448 0.008 0.000 0.000 0.556 0.436
#> GSM38203 3 0.0000 0.9432 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 0.9432 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0000 0.9432 0.000 0.000 1.000 0.000 0.000
#> GSM38206 3 0.0000 0.9432 0.000 0.000 1.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
#> GSM38155 2 0.0520 0.9530 0.000 0.984 0.000 0.008 0.000 0.008
#> GSM38156 2 0.0405 0.9547 0.000 0.988 0.000 0.008 0.000 0.004
#> GSM38157 2 0.0000 0.9549 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.9549 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38159 2 0.1841 0.8990 0.064 0.920 0.000 0.008 0.000 0.008
#> GSM38160 2 0.2302 0.8841 0.000 0.872 0.000 0.008 0.000 0.120
#> GSM38161 2 0.0891 0.9509 0.000 0.968 0.000 0.008 0.000 0.024
#> GSM38162 4 0.1556 0.8200 0.000 0.000 0.000 0.920 0.080 0.000
#> GSM38163 1 0.0260 0.8176 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM38164 5 0.2113 0.6920 0.092 0.000 0.000 0.004 0.896 0.008
#> GSM38165 3 0.1556 0.9059 0.000 0.000 0.920 0.000 0.000 0.080
#> GSM38166 3 0.1714 0.9035 0.000 0.000 0.908 0.000 0.000 0.092
#> GSM38167 5 0.0937 0.7038 0.040 0.000 0.000 0.000 0.960 0.000
#> GSM38168 4 0.3606 0.7053 0.000 0.008 0.000 0.724 0.264 0.004
#> GSM38169 5 0.1219 0.7040 0.048 0.000 0.000 0.004 0.948 0.000
#> GSM38170 1 0.4690 0.2258 0.552 0.000 0.000 0.000 0.048 0.400
#> GSM38171 1 0.0508 0.8175 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM38172 4 0.2823 0.6936 0.000 0.000 0.000 0.796 0.204 0.000
#> GSM38173 1 0.5408 -0.1089 0.476 0.000 0.000 0.000 0.408 0.116
#> GSM38174 5 0.5132 -0.0540 0.084 0.000 0.000 0.000 0.500 0.416
#> GSM38175 1 0.0405 0.8184 0.988 0.000 0.000 0.000 0.004 0.008
#> GSM38176 1 0.0622 0.8167 0.980 0.000 0.000 0.000 0.012 0.008
#> GSM38177 5 0.0713 0.6743 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM38178 5 0.3654 0.6239 0.060 0.000 0.000 0.004 0.792 0.144
#> GSM38179 1 0.0458 0.8170 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM38180 1 0.0508 0.8168 0.984 0.000 0.000 0.000 0.004 0.012
#> GSM38181 3 0.1765 0.9023 0.000 0.000 0.904 0.000 0.000 0.096
#> GSM38182 6 0.4723 0.6354 0.180 0.000 0.000 0.000 0.140 0.680
#> GSM38183 1 0.0603 0.8171 0.980 0.000 0.000 0.000 0.016 0.004
#> GSM38184 2 0.0291 0.9538 0.000 0.992 0.004 0.000 0.000 0.004
#> GSM38185 1 0.4039 0.2039 0.568 0.000 0.000 0.000 0.008 0.424
#> GSM38186 1 0.1265 0.8009 0.948 0.000 0.000 0.000 0.044 0.008
#> GSM38187 1 0.3858 0.5958 0.732 0.000 0.004 0.000 0.028 0.236
#> GSM38188 6 0.2765 0.6615 0.004 0.132 0.000 0.000 0.016 0.848
#> GSM38189 6 0.5683 0.2955 0.172 0.000 0.000 0.000 0.336 0.492
#> GSM38190 5 0.6627 0.2300 0.296 0.044 0.000 0.008 0.484 0.168
#> GSM38191 6 0.4287 0.6080 0.008 0.116 0.000 0.008 0.104 0.764
#> GSM38192 1 0.1082 0.8063 0.956 0.000 0.000 0.000 0.004 0.040
#> GSM38193 2 0.2389 0.8817 0.000 0.864 0.000 0.008 0.000 0.128
#> GSM38194 4 0.6164 0.5915 0.004 0.084 0.000 0.588 0.228 0.096
#> GSM38195 6 0.4626 0.6389 0.172 0.000 0.000 0.000 0.136 0.692
#> GSM38196 5 0.2664 0.5812 0.000 0.000 0.000 0.184 0.816 0.000
#> GSM38197 6 0.3005 0.6860 0.036 0.092 0.000 0.000 0.016 0.856
#> GSM38198 4 0.1610 0.8202 0.000 0.000 0.000 0.916 0.084 0.000
#> GSM38199 3 0.5992 0.4975 0.004 0.000 0.592 0.092 0.248 0.064
#> GSM38200 2 0.0717 0.9521 0.000 0.976 0.000 0.008 0.000 0.016
#> GSM38201 4 0.0632 0.7952 0.000 0.000 0.000 0.976 0.024 0.000
#> GSM38202 5 0.4211 0.0562 0.004 0.000 0.000 0.456 0.532 0.008
#> GSM38203 3 0.0000 0.9140 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.9140 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0146 0.9125 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM38206 3 0.0000 0.9140 0.000 0.000 1.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
#> CV:mclust 47 2.19e-07 2
#> CV:mclust 51 7.48e-10 3
#> CV:mclust 49 1.79e-08 4
#> CV:mclust 39 3.62e-06 5
#> CV:mclust 44 1.44e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.728 0.844 0.936 0.4912 0.502 0.502
#> 3 3 0.398 0.619 0.799 0.3502 0.655 0.419
#> 4 4 0.738 0.744 0.874 0.1406 0.792 0.468
#> 5 5 0.634 0.623 0.767 0.0681 0.941 0.760
#> 6 6 0.701 0.609 0.759 0.0409 0.931 0.671
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 2
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM38155 2 0.000 0.9180 0.000 1.000
#> GSM38156 2 0.000 0.9180 0.000 1.000
#> GSM38157 2 0.000 0.9180 0.000 1.000
#> GSM38158 2 0.000 0.9180 0.000 1.000
#> GSM38159 2 0.000 0.9180 0.000 1.000
#> GSM38160 2 0.000 0.9180 0.000 1.000
#> GSM38161 2 0.000 0.9180 0.000 1.000
#> GSM38162 1 0.000 0.9311 1.000 0.000
#> GSM38163 1 0.311 0.8923 0.944 0.056
#> GSM38164 1 0.000 0.9311 1.000 0.000
#> GSM38165 1 0.000 0.9311 1.000 0.000
#> GSM38166 1 0.000 0.9311 1.000 0.000
#> GSM38167 1 0.000 0.9311 1.000 0.000
#> GSM38168 1 0.814 0.6530 0.748 0.252
#> GSM38169 1 0.000 0.9311 1.000 0.000
#> GSM38170 1 0.000 0.9311 1.000 0.000
#> GSM38171 2 0.184 0.9027 0.028 0.972
#> GSM38172 1 0.000 0.9311 1.000 0.000
#> GSM38173 2 0.994 0.1655 0.456 0.544
#> GSM38174 1 0.850 0.6233 0.724 0.276
#> GSM38175 2 0.000 0.9180 0.000 1.000
#> GSM38176 2 0.767 0.7052 0.224 0.776
#> GSM38177 1 0.000 0.9311 1.000 0.000
#> GSM38178 1 0.343 0.8887 0.936 0.064
#> GSM38179 1 0.000 0.9311 1.000 0.000
#> GSM38180 1 0.833 0.6387 0.736 0.264
#> GSM38181 1 0.000 0.9311 1.000 0.000
#> GSM38182 1 0.900 0.5369 0.684 0.316
#> GSM38183 2 0.969 0.3536 0.396 0.604
#> GSM38184 2 0.000 0.9180 0.000 1.000
#> GSM38185 2 0.000 0.9180 0.000 1.000
#> GSM38186 1 0.998 0.0523 0.528 0.472
#> GSM38187 1 0.000 0.9311 1.000 0.000
#> GSM38188 2 0.000 0.9180 0.000 1.000
#> GSM38189 1 0.204 0.9119 0.968 0.032
#> GSM38190 2 0.000 0.9180 0.000 1.000
#> GSM38191 2 0.295 0.8864 0.052 0.948
#> GSM38192 2 0.000 0.9180 0.000 1.000
#> GSM38193 2 0.000 0.9180 0.000 1.000
#> GSM38194 2 0.821 0.6552 0.256 0.744
#> GSM38195 1 0.343 0.8893 0.936 0.064
#> GSM38196 1 0.000 0.9311 1.000 0.000
#> GSM38197 2 0.563 0.8152 0.132 0.868
#> GSM38198 1 0.000 0.9311 1.000 0.000
#> GSM38199 1 0.000 0.9311 1.000 0.000
#> GSM38200 2 0.000 0.9180 0.000 1.000
#> GSM38201 1 0.000 0.9311 1.000 0.000
#> GSM38202 1 0.000 0.9311 1.000 0.000
#> GSM38203 1 0.000 0.9311 1.000 0.000
#> GSM38204 1 0.000 0.9311 1.000 0.000
#> GSM38205 1 0.000 0.9311 1.000 0.000
#> GSM38206 1 0.000 0.9311 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0892 0.9158 0.020 0.980 0.000
#> GSM38156 2 0.0000 0.9202 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.9202 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.9202 0.000 1.000 0.000
#> GSM38159 2 0.4178 0.7647 0.172 0.828 0.000
#> GSM38160 2 0.0000 0.9202 0.000 1.000 0.000
#> GSM38161 2 0.0892 0.9156 0.020 0.980 0.000
#> GSM38162 1 0.6095 0.2645 0.608 0.000 0.392
#> GSM38163 1 0.4897 0.5889 0.812 0.016 0.172
#> GSM38164 1 0.4390 0.6274 0.840 0.012 0.148
#> GSM38165 3 0.0000 0.7874 0.000 0.000 1.000
#> GSM38166 3 0.0237 0.7867 0.004 0.000 0.996
#> GSM38167 1 0.3267 0.6195 0.884 0.000 0.116
#> GSM38168 1 0.7831 0.3830 0.632 0.088 0.280
#> GSM38169 1 0.0892 0.6374 0.980 0.000 0.020
#> GSM38170 3 0.2711 0.7555 0.088 0.000 0.912
#> GSM38171 1 0.8264 0.2967 0.556 0.356 0.088
#> GSM38172 1 0.6235 0.1380 0.564 0.000 0.436
#> GSM38173 1 0.5298 0.6471 0.804 0.164 0.032
#> GSM38174 1 0.8221 0.4334 0.624 0.128 0.248
#> GSM38175 1 0.6260 0.1447 0.552 0.448 0.000
#> GSM38176 1 0.5036 0.6363 0.808 0.172 0.020
#> GSM38177 1 0.3192 0.6170 0.888 0.000 0.112
#> GSM38178 1 0.4654 0.5501 0.792 0.000 0.208
#> GSM38179 1 0.4291 0.5838 0.820 0.000 0.180
#> GSM38180 1 0.6858 0.5504 0.728 0.084 0.188
#> GSM38181 3 0.2261 0.7586 0.068 0.000 0.932
#> GSM38182 3 0.9180 0.2365 0.152 0.376 0.472
#> GSM38183 1 0.5119 0.6403 0.816 0.152 0.032
#> GSM38184 2 0.0424 0.9178 0.008 0.992 0.000
#> GSM38185 2 0.4235 0.7526 0.176 0.824 0.000
#> GSM38186 1 0.4840 0.6411 0.816 0.168 0.016
#> GSM38187 3 0.5178 0.5623 0.256 0.000 0.744
#> GSM38188 2 0.0237 0.9198 0.004 0.996 0.000
#> GSM38189 3 0.7366 0.1066 0.444 0.032 0.524
#> GSM38190 1 0.5905 0.4675 0.648 0.352 0.000
#> GSM38191 2 0.5757 0.7418 0.152 0.792 0.056
#> GSM38192 1 0.7067 0.0536 0.512 0.468 0.020
#> GSM38193 2 0.0747 0.9174 0.016 0.984 0.000
#> GSM38194 1 0.5147 0.5936 0.800 0.180 0.020
#> GSM38195 3 0.6511 0.6488 0.136 0.104 0.760
#> GSM38196 1 0.5650 0.4286 0.688 0.000 0.312
#> GSM38197 2 0.5480 0.6222 0.004 0.732 0.264
#> GSM38198 1 0.5968 0.3269 0.636 0.000 0.364
#> GSM38199 3 0.0747 0.7837 0.016 0.000 0.984
#> GSM38200 2 0.0000 0.9202 0.000 1.000 0.000
#> GSM38201 3 0.6111 0.3056 0.396 0.000 0.604
#> GSM38202 3 0.5926 0.3941 0.356 0.000 0.644
#> GSM38203 3 0.0000 0.7874 0.000 0.000 1.000
#> GSM38204 3 0.0000 0.7874 0.000 0.000 1.000
#> GSM38205 3 0.1031 0.7774 0.024 0.000 0.976
#> GSM38206 3 0.0000 0.7874 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.2973 0.8374 0.096 0.884 0.000 0.020
#> GSM38156 2 0.0188 0.8751 0.000 0.996 0.000 0.004
#> GSM38157 2 0.0376 0.8754 0.004 0.992 0.000 0.004
#> GSM38158 2 0.0592 0.8755 0.016 0.984 0.000 0.000
#> GSM38159 2 0.5311 0.5443 0.328 0.648 0.000 0.024
#> GSM38160 2 0.0524 0.8751 0.004 0.988 0.000 0.008
#> GSM38161 2 0.1833 0.8708 0.032 0.944 0.000 0.024
#> GSM38162 4 0.1004 0.8635 0.004 0.000 0.024 0.972
#> GSM38163 1 0.1109 0.8626 0.968 0.000 0.004 0.028
#> GSM38164 4 0.4535 0.5965 0.292 0.000 0.004 0.704
#> GSM38165 3 0.0000 0.8528 0.000 0.000 1.000 0.000
#> GSM38166 3 0.0000 0.8528 0.000 0.000 1.000 0.000
#> GSM38167 4 0.2888 0.8123 0.124 0.000 0.004 0.872
#> GSM38168 4 0.1174 0.8640 0.012 0.000 0.020 0.968
#> GSM38169 4 0.4713 0.4634 0.360 0.000 0.000 0.640
#> GSM38170 3 0.3306 0.7463 0.156 0.000 0.840 0.004
#> GSM38171 1 0.0927 0.8601 0.976 0.016 0.000 0.008
#> GSM38172 4 0.1151 0.8637 0.008 0.000 0.024 0.968
#> GSM38173 1 0.3355 0.7492 0.836 0.004 0.000 0.160
#> GSM38174 4 0.6188 0.4757 0.312 0.064 0.004 0.620
#> GSM38175 1 0.1182 0.8570 0.968 0.016 0.000 0.016
#> GSM38176 1 0.0707 0.8622 0.980 0.000 0.000 0.020
#> GSM38177 4 0.1022 0.8565 0.032 0.000 0.000 0.968
#> GSM38178 4 0.1985 0.8624 0.040 0.004 0.016 0.940
#> GSM38179 1 0.1302 0.8583 0.956 0.000 0.000 0.044
#> GSM38180 1 0.0779 0.8616 0.980 0.000 0.004 0.016
#> GSM38181 3 0.1022 0.8388 0.032 0.000 0.968 0.000
#> GSM38182 2 0.8800 -0.0918 0.360 0.404 0.164 0.072
#> GSM38183 1 0.1716 0.8498 0.936 0.000 0.000 0.064
#> GSM38184 2 0.1474 0.8697 0.052 0.948 0.000 0.000
#> GSM38185 1 0.4268 0.6548 0.760 0.232 0.004 0.004
#> GSM38186 1 0.1474 0.8541 0.948 0.000 0.000 0.052
#> GSM38187 3 0.4746 0.4413 0.368 0.000 0.632 0.000
#> GSM38188 2 0.0927 0.8690 0.016 0.976 0.000 0.008
#> GSM38189 1 0.7798 0.3362 0.540 0.080 0.068 0.312
#> GSM38190 1 0.7468 0.2605 0.492 0.204 0.000 0.304
#> GSM38191 2 0.4828 0.7391 0.036 0.780 0.012 0.172
#> GSM38192 1 0.1388 0.8526 0.960 0.028 0.000 0.012
#> GSM38193 2 0.1929 0.8698 0.036 0.940 0.000 0.024
#> GSM38194 4 0.3280 0.7677 0.016 0.124 0.000 0.860
#> GSM38195 3 0.6805 0.3362 0.360 0.056 0.560 0.024
#> GSM38196 4 0.2596 0.8515 0.068 0.000 0.024 0.908
#> GSM38197 3 0.5000 -0.0287 0.000 0.496 0.504 0.000
#> GSM38198 4 0.0895 0.8637 0.004 0.000 0.020 0.976
#> GSM38199 3 0.0921 0.8386 0.000 0.000 0.972 0.028
#> GSM38200 2 0.0188 0.8751 0.000 0.996 0.000 0.004
#> GSM38201 4 0.1978 0.8471 0.004 0.000 0.068 0.928
#> GSM38202 4 0.2861 0.8319 0.012 0.004 0.092 0.892
#> GSM38203 3 0.0000 0.8528 0.000 0.000 1.000 0.000
#> GSM38204 3 0.0000 0.8528 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0000 0.8528 0.000 0.000 1.000 0.000
#> GSM38206 3 0.0000 0.8528 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.3203 0.672 0.168 0.820 0.000 0.000 0.012
#> GSM38156 2 0.3093 0.707 0.008 0.824 0.000 0.000 0.168
#> GSM38157 2 0.2806 0.713 0.004 0.844 0.000 0.000 0.152
#> GSM38158 2 0.1831 0.732 0.004 0.920 0.000 0.000 0.076
#> GSM38159 2 0.5101 0.315 0.416 0.552 0.000 0.008 0.024
#> GSM38160 2 0.3609 0.711 0.004 0.816 0.000 0.032 0.148
#> GSM38161 2 0.4324 0.676 0.080 0.808 0.000 0.048 0.064
#> GSM38162 4 0.0798 0.687 0.000 0.016 0.000 0.976 0.008
#> GSM38163 1 0.2401 0.758 0.904 0.008 0.008 0.004 0.076
#> GSM38164 4 0.6282 0.447 0.132 0.008 0.000 0.524 0.336
#> GSM38165 3 0.0000 0.847 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0510 0.845 0.000 0.000 0.984 0.000 0.016
#> GSM38167 4 0.5240 0.485 0.092 0.000 0.000 0.656 0.252
#> GSM38168 4 0.2471 0.680 0.000 0.000 0.000 0.864 0.136
#> GSM38169 4 0.5781 0.495 0.104 0.000 0.000 0.552 0.344
#> GSM38170 3 0.6607 0.241 0.236 0.000 0.516 0.008 0.240
#> GSM38171 1 0.2798 0.758 0.852 0.008 0.000 0.000 0.140
#> GSM38172 4 0.4037 0.624 0.004 0.000 0.004 0.704 0.288
#> GSM38173 5 0.6336 0.329 0.332 0.032 0.000 0.088 0.548
#> GSM38174 5 0.4915 0.486 0.048 0.028 0.000 0.192 0.732
#> GSM38175 1 0.2053 0.776 0.924 0.048 0.000 0.004 0.024
#> GSM38176 1 0.0854 0.793 0.976 0.004 0.000 0.008 0.012
#> GSM38177 4 0.2054 0.694 0.028 0.000 0.000 0.920 0.052
#> GSM38178 4 0.4438 0.548 0.004 0.000 0.004 0.608 0.384
#> GSM38179 1 0.2700 0.779 0.884 0.000 0.004 0.024 0.088
#> GSM38180 1 0.3128 0.730 0.824 0.004 0.000 0.004 0.168
#> GSM38181 3 0.0671 0.843 0.004 0.000 0.980 0.000 0.016
#> GSM38182 5 0.6399 0.491 0.132 0.168 0.012 0.040 0.648
#> GSM38183 1 0.2434 0.775 0.912 0.040 0.000 0.024 0.024
#> GSM38184 2 0.3085 0.722 0.032 0.852 0.000 0.000 0.116
#> GSM38185 1 0.6000 0.143 0.532 0.128 0.000 0.000 0.340
#> GSM38186 1 0.3888 0.672 0.788 0.004 0.000 0.032 0.176
#> GSM38187 3 0.3906 0.561 0.292 0.000 0.704 0.000 0.004
#> GSM38188 2 0.4557 0.203 0.000 0.516 0.000 0.008 0.476
#> GSM38189 5 0.4786 0.582 0.156 0.028 0.000 0.060 0.756
#> GSM38190 5 0.6776 0.377 0.168 0.068 0.000 0.168 0.596
#> GSM38191 2 0.6558 0.518 0.048 0.636 0.012 0.176 0.128
#> GSM38192 1 0.2844 0.735 0.876 0.092 0.004 0.000 0.028
#> GSM38193 2 0.5303 0.625 0.036 0.728 0.000 0.132 0.104
#> GSM38194 4 0.6481 0.403 0.016 0.228 0.000 0.564 0.192
#> GSM38195 5 0.7295 0.464 0.164 0.084 0.144 0.020 0.588
#> GSM38196 4 0.4149 0.571 0.040 0.000 0.004 0.768 0.188
#> GSM38197 3 0.4147 0.474 0.008 0.316 0.676 0.000 0.000
#> GSM38198 4 0.0404 0.690 0.000 0.012 0.000 0.988 0.000
#> GSM38199 3 0.3255 0.732 0.000 0.000 0.848 0.052 0.100
#> GSM38200 2 0.3086 0.705 0.004 0.816 0.000 0.000 0.180
#> GSM38201 4 0.2060 0.682 0.000 0.024 0.012 0.928 0.036
#> GSM38202 4 0.4389 0.508 0.004 0.000 0.004 0.624 0.368
#> GSM38203 3 0.0290 0.846 0.000 0.000 0.992 0.008 0.000
#> GSM38204 3 0.0000 0.847 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0955 0.837 0.000 0.004 0.968 0.028 0.000
#> GSM38206 3 0.0000 0.847 0.000 0.000 1.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
#> GSM38155 2 0.2711 0.666 0.084 0.872 0.000 0.000 0.036 0.008
#> GSM38156 2 0.2868 0.653 0.000 0.840 0.000 0.000 0.028 0.132
#> GSM38157 2 0.3122 0.629 0.000 0.804 0.000 0.000 0.020 0.176
#> GSM38158 2 0.2022 0.679 0.008 0.916 0.000 0.000 0.024 0.052
#> GSM38159 2 0.5346 0.384 0.344 0.576 0.000 0.012 0.052 0.016
#> GSM38160 2 0.6122 0.542 0.004 0.584 0.000 0.104 0.068 0.240
#> GSM38161 2 0.5171 0.631 0.044 0.736 0.000 0.100 0.076 0.044
#> GSM38162 4 0.1429 0.748 0.000 0.000 0.004 0.940 0.052 0.004
#> GSM38163 1 0.3378 0.743 0.820 0.016 0.004 0.004 0.144 0.012
#> GSM38164 5 0.3387 0.715 0.016 0.012 0.000 0.160 0.808 0.004
#> GSM38165 3 0.0000 0.842 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0653 0.836 0.004 0.000 0.980 0.000 0.004 0.012
#> GSM38167 4 0.6776 0.352 0.116 0.016 0.000 0.484 0.068 0.316
#> GSM38168 4 0.3276 0.664 0.000 0.000 0.000 0.816 0.132 0.052
#> GSM38169 5 0.3790 0.712 0.020 0.000 0.000 0.184 0.772 0.024
#> GSM38170 6 0.7439 0.153 0.280 0.016 0.212 0.024 0.040 0.428
#> GSM38171 1 0.3395 0.775 0.816 0.004 0.000 0.000 0.056 0.124
#> GSM38172 5 0.3695 0.687 0.000 0.000 0.000 0.244 0.732 0.024
#> GSM38173 5 0.5464 0.524 0.100 0.020 0.000 0.028 0.676 0.176
#> GSM38174 6 0.3709 0.588 0.032 0.016 0.000 0.072 0.048 0.832
#> GSM38175 1 0.2388 0.791 0.904 0.040 0.000 0.004 0.036 0.016
#> GSM38176 1 0.1151 0.805 0.956 0.000 0.000 0.000 0.032 0.012
#> GSM38177 4 0.2808 0.715 0.032 0.020 0.000 0.888 0.036 0.024
#> GSM38178 5 0.4299 0.719 0.004 0.008 0.000 0.164 0.748 0.076
#> GSM38179 1 0.2881 0.793 0.864 0.000 0.000 0.012 0.040 0.084
#> GSM38180 1 0.3202 0.771 0.816 0.000 0.000 0.000 0.040 0.144
#> GSM38181 3 0.0622 0.837 0.008 0.000 0.980 0.000 0.000 0.012
#> GSM38182 6 0.2936 0.625 0.020 0.084 0.000 0.008 0.020 0.868
#> GSM38183 1 0.2717 0.782 0.884 0.032 0.000 0.012 0.064 0.008
#> GSM38184 2 0.2803 0.675 0.032 0.876 0.000 0.000 0.028 0.064
#> GSM38185 1 0.4937 0.152 0.492 0.028 0.000 0.000 0.020 0.460
#> GSM38186 1 0.3725 0.764 0.804 0.004 0.000 0.012 0.052 0.128
#> GSM38187 3 0.4093 0.162 0.440 0.000 0.552 0.000 0.004 0.004
#> GSM38188 6 0.4728 0.235 0.004 0.340 0.000 0.000 0.052 0.604
#> GSM38189 6 0.5297 0.168 0.016 0.036 0.000 0.016 0.384 0.548
#> GSM38190 5 0.4532 0.597 0.028 0.112 0.000 0.008 0.760 0.092
#> GSM38191 2 0.7184 0.179 0.032 0.432 0.024 0.076 0.380 0.056
#> GSM38192 1 0.2964 0.738 0.848 0.108 0.000 0.000 0.040 0.004
#> GSM38193 2 0.7077 0.489 0.040 0.536 0.000 0.208 0.092 0.124
#> GSM38194 5 0.6095 0.446 0.020 0.096 0.000 0.284 0.568 0.032
#> GSM38195 6 0.4027 0.626 0.040 0.048 0.036 0.004 0.048 0.824
#> GSM38196 4 0.4750 0.507 0.040 0.000 0.000 0.628 0.016 0.316
#> GSM38197 3 0.5087 0.383 0.004 0.308 0.624 0.004 0.028 0.032
#> GSM38198 4 0.1155 0.749 0.004 0.000 0.004 0.956 0.036 0.000
#> GSM38199 3 0.3932 0.558 0.000 0.000 0.720 0.028 0.248 0.004
#> GSM38200 2 0.3827 0.516 0.004 0.680 0.000 0.000 0.008 0.308
#> GSM38201 4 0.1845 0.741 0.000 0.000 0.004 0.916 0.072 0.008
#> GSM38202 5 0.6062 0.277 0.000 0.000 0.000 0.288 0.408 0.304
#> GSM38203 3 0.0000 0.842 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.842 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.1267 0.811 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM38206 3 0.0000 0.842 0.000 0.000 1.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
#> CV:NMF 49 6.70e-04 2
#> CV:NMF 38 6.92e-05 3
#> CV:NMF 44 2.04e-05 4
#> CV:NMF 38 5.05e-04 5
#> CV:NMF 40 9.76e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.595 0.926 0.929 0.3713 0.638 0.638
#> 3 3 0.519 0.741 0.770 0.4505 0.747 0.603
#> 4 4 0.524 0.652 0.802 0.2344 0.820 0.589
#> 5 5 0.656 0.693 0.798 0.1127 0.857 0.581
#> 6 6 0.694 0.748 0.784 0.0774 0.951 0.782
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
#> GSM38155 2 0.1414 0.955 0.020 0.980
#> GSM38156 2 0.0000 0.963 0.000 1.000
#> GSM38157 2 0.0000 0.963 0.000 1.000
#> GSM38158 2 0.0000 0.963 0.000 1.000
#> GSM38159 2 0.4161 0.908 0.084 0.916
#> GSM38160 2 0.0000 0.963 0.000 1.000
#> GSM38161 2 0.0672 0.962 0.008 0.992
#> GSM38162 1 0.0000 0.914 1.000 0.000
#> GSM38163 1 0.5737 0.926 0.864 0.136
#> GSM38164 1 0.5946 0.923 0.856 0.144
#> GSM38165 1 0.0000 0.914 1.000 0.000
#> GSM38166 1 0.0000 0.914 1.000 0.000
#> GSM38167 1 0.4161 0.931 0.916 0.084
#> GSM38168 1 0.1633 0.920 0.976 0.024
#> GSM38169 1 0.5946 0.923 0.856 0.144
#> GSM38170 1 0.1414 0.921 0.980 0.020
#> GSM38171 1 0.5946 0.923 0.856 0.144
#> GSM38172 1 0.1184 0.919 0.984 0.016
#> GSM38173 1 0.5842 0.925 0.860 0.140
#> GSM38174 1 0.4022 0.931 0.920 0.080
#> GSM38175 1 0.6623 0.903 0.828 0.172
#> GSM38176 1 0.5737 0.926 0.864 0.136
#> GSM38177 1 0.4161 0.931 0.916 0.084
#> GSM38178 1 0.5178 0.931 0.884 0.116
#> GSM38179 1 0.5737 0.926 0.864 0.136
#> GSM38180 1 0.5946 0.923 0.856 0.144
#> GSM38181 1 0.1184 0.920 0.984 0.016
#> GSM38182 1 0.4562 0.930 0.904 0.096
#> GSM38183 1 0.5737 0.926 0.864 0.136
#> GSM38184 2 0.0000 0.963 0.000 1.000
#> GSM38185 1 0.6887 0.892 0.816 0.184
#> GSM38186 1 0.5946 0.923 0.856 0.144
#> GSM38187 1 0.5737 0.926 0.864 0.136
#> GSM38188 1 0.5737 0.923 0.864 0.136
#> GSM38189 1 0.5629 0.927 0.868 0.132
#> GSM38190 1 0.5946 0.923 0.856 0.144
#> GSM38191 2 0.5178 0.874 0.116 0.884
#> GSM38192 1 0.5737 0.926 0.864 0.136
#> GSM38193 2 0.0672 0.962 0.008 0.992
#> GSM38194 2 0.5178 0.874 0.116 0.884
#> GSM38195 1 0.4562 0.930 0.904 0.096
#> GSM38196 1 0.4022 0.931 0.920 0.080
#> GSM38197 1 0.5737 0.926 0.864 0.136
#> GSM38198 1 0.0000 0.914 1.000 0.000
#> GSM38199 1 0.0376 0.916 0.996 0.004
#> GSM38200 2 0.0000 0.963 0.000 1.000
#> GSM38201 1 0.0000 0.914 1.000 0.000
#> GSM38202 1 0.0376 0.916 0.996 0.004
#> GSM38203 1 0.0000 0.914 1.000 0.000
#> GSM38204 1 0.0000 0.914 1.000 0.000
#> GSM38205 1 0.0000 0.914 1.000 0.000
#> GSM38206 1 0.0000 0.914 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.6228 0.852 0.012 0.672 0.316
#> GSM38156 2 0.5497 0.857 0.000 0.708 0.292
#> GSM38157 2 0.5497 0.857 0.000 0.708 0.292
#> GSM38158 2 0.5968 0.844 0.000 0.636 0.364
#> GSM38159 2 0.8625 0.797 0.124 0.560 0.316
#> GSM38160 2 0.0000 0.822 0.000 1.000 0.000
#> GSM38161 2 0.1411 0.817 0.036 0.964 0.000
#> GSM38162 3 0.6204 0.957 0.424 0.000 0.576
#> GSM38163 1 0.0237 0.791 0.996 0.000 0.004
#> GSM38164 1 0.1989 0.777 0.948 0.004 0.048
#> GSM38165 3 0.6168 0.958 0.412 0.000 0.588
#> GSM38166 3 0.6192 0.956 0.420 0.000 0.580
#> GSM38167 1 0.5201 0.534 0.760 0.004 0.236
#> GSM38168 3 0.6905 0.921 0.440 0.016 0.544
#> GSM38169 1 0.2096 0.777 0.944 0.004 0.052
#> GSM38170 1 0.5988 -0.216 0.632 0.000 0.368
#> GSM38171 1 0.0892 0.788 0.980 0.000 0.020
#> GSM38172 1 0.5098 0.479 0.752 0.000 0.248
#> GSM38173 1 0.1411 0.783 0.964 0.000 0.036
#> GSM38174 1 0.5201 0.515 0.760 0.004 0.236
#> GSM38175 1 0.1919 0.767 0.956 0.024 0.020
#> GSM38176 1 0.0237 0.791 0.996 0.000 0.004
#> GSM38177 1 0.5244 0.526 0.756 0.004 0.240
#> GSM38178 1 0.2945 0.761 0.908 0.004 0.088
#> GSM38179 1 0.0000 0.792 1.000 0.000 0.000
#> GSM38180 1 0.0892 0.788 0.980 0.000 0.020
#> GSM38181 1 0.6280 -0.655 0.540 0.000 0.460
#> GSM38182 1 0.4883 0.595 0.788 0.004 0.208
#> GSM38183 1 0.0000 0.792 1.000 0.000 0.000
#> GSM38184 2 0.7013 0.838 0.028 0.608 0.364
#> GSM38185 1 0.2313 0.756 0.944 0.032 0.024
#> GSM38186 1 0.0747 0.789 0.984 0.000 0.016
#> GSM38187 1 0.0237 0.791 0.996 0.000 0.004
#> GSM38188 1 0.5581 0.623 0.788 0.036 0.176
#> GSM38189 1 0.4645 0.660 0.816 0.008 0.176
#> GSM38190 1 0.1989 0.777 0.948 0.004 0.048
#> GSM38191 2 0.5008 0.717 0.180 0.804 0.016
#> GSM38192 1 0.0000 0.792 1.000 0.000 0.000
#> GSM38193 2 0.1411 0.817 0.036 0.964 0.000
#> GSM38194 2 0.5008 0.717 0.180 0.804 0.016
#> GSM38195 1 0.4883 0.595 0.788 0.004 0.208
#> GSM38196 1 0.5201 0.515 0.760 0.004 0.236
#> GSM38197 1 0.0237 0.791 0.996 0.000 0.004
#> GSM38198 3 0.6204 0.957 0.424 0.000 0.576
#> GSM38199 3 0.6252 0.926 0.444 0.000 0.556
#> GSM38200 2 0.5497 0.857 0.000 0.708 0.292
#> GSM38201 3 0.6192 0.959 0.420 0.000 0.580
#> GSM38202 3 0.6307 0.823 0.488 0.000 0.512
#> GSM38203 3 0.6154 0.958 0.408 0.000 0.592
#> GSM38204 3 0.6154 0.958 0.408 0.000 0.592
#> GSM38205 3 0.6154 0.958 0.408 0.000 0.592
#> GSM38206 3 0.6154 0.958 0.408 0.000 0.592
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.3029 0.83943 0.028 0.896 0.068 0.008
#> GSM38156 2 0.2589 0.84585 0.000 0.884 0.116 0.000
#> GSM38157 2 0.2589 0.84585 0.000 0.884 0.116 0.000
#> GSM38158 2 0.0000 0.82334 0.000 1.000 0.000 0.000
#> GSM38159 2 0.5029 0.64227 0.140 0.780 0.072 0.008
#> GSM38160 3 0.4679 0.69624 0.000 0.352 0.648 0.000
#> GSM38161 3 0.5322 0.77693 0.028 0.312 0.660 0.000
#> GSM38162 4 0.5334 0.70721 0.088 0.000 0.172 0.740
#> GSM38163 1 0.1576 0.81970 0.948 0.000 0.004 0.048
#> GSM38164 1 0.3037 0.78334 0.888 0.000 0.076 0.036
#> GSM38165 4 0.2670 0.71604 0.052 0.000 0.040 0.908
#> GSM38166 4 0.2578 0.71816 0.052 0.000 0.036 0.912
#> GSM38167 4 0.5774 0.13717 0.464 0.000 0.028 0.508
#> GSM38168 4 0.6044 0.69116 0.104 0.008 0.188 0.700
#> GSM38169 1 0.3128 0.78232 0.884 0.000 0.076 0.040
#> GSM38170 4 0.5062 0.57477 0.284 0.000 0.024 0.692
#> GSM38171 1 0.0895 0.81759 0.976 0.000 0.004 0.020
#> GSM38172 1 0.5875 0.56977 0.692 0.000 0.104 0.204
#> GSM38173 1 0.1913 0.81225 0.940 0.000 0.040 0.020
#> GSM38174 4 0.5602 0.13321 0.472 0.000 0.020 0.508
#> GSM38175 1 0.1114 0.80541 0.972 0.004 0.016 0.008
#> GSM38176 1 0.1576 0.81970 0.948 0.000 0.004 0.048
#> GSM38177 4 0.5778 0.14016 0.472 0.000 0.028 0.500
#> GSM38178 1 0.3754 0.76497 0.852 0.000 0.084 0.064
#> GSM38179 1 0.1302 0.82009 0.956 0.000 0.000 0.044
#> GSM38180 1 0.0707 0.81734 0.980 0.000 0.000 0.020
#> GSM38181 4 0.4332 0.69068 0.176 0.000 0.032 0.792
#> GSM38182 1 0.5277 -0.05425 0.532 0.000 0.008 0.460
#> GSM38183 1 0.1302 0.82009 0.956 0.000 0.000 0.044
#> GSM38184 2 0.1767 0.77753 0.012 0.944 0.044 0.000
#> GSM38185 1 0.1443 0.80313 0.960 0.004 0.028 0.008
#> GSM38186 1 0.1389 0.81298 0.952 0.000 0.000 0.048
#> GSM38187 1 0.1302 0.82017 0.956 0.000 0.000 0.044
#> GSM38188 1 0.6511 -0.00136 0.524 0.024 0.032 0.420
#> GSM38189 1 0.6222 0.05443 0.532 0.000 0.056 0.412
#> GSM38190 1 0.2965 0.78569 0.892 0.000 0.072 0.036
#> GSM38191 3 0.5624 0.72994 0.128 0.148 0.724 0.000
#> GSM38192 1 0.1302 0.82009 0.956 0.000 0.000 0.044
#> GSM38193 3 0.5322 0.77693 0.028 0.312 0.660 0.000
#> GSM38194 3 0.5624 0.72994 0.128 0.148 0.724 0.000
#> GSM38195 1 0.5277 -0.05425 0.532 0.000 0.008 0.460
#> GSM38196 4 0.5597 0.15861 0.464 0.000 0.020 0.516
#> GSM38197 1 0.1302 0.82017 0.956 0.000 0.000 0.044
#> GSM38198 4 0.5334 0.70721 0.088 0.000 0.172 0.740
#> GSM38199 4 0.4130 0.72282 0.108 0.000 0.064 0.828
#> GSM38200 2 0.2647 0.84263 0.000 0.880 0.120 0.000
#> GSM38201 4 0.5272 0.70834 0.084 0.000 0.172 0.744
#> GSM38202 4 0.4669 0.69232 0.168 0.000 0.052 0.780
#> GSM38203 4 0.2300 0.70478 0.028 0.000 0.048 0.924
#> GSM38204 4 0.2214 0.70582 0.028 0.000 0.044 0.928
#> GSM38205 4 0.2882 0.70349 0.024 0.000 0.084 0.892
#> GSM38206 4 0.2214 0.70582 0.028 0.000 0.044 0.928
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.3400 0.8456 0.036 0.828 0.000 0.000 0.136
#> GSM38156 2 0.2929 0.8494 0.000 0.820 0.000 0.000 0.180
#> GSM38157 2 0.2929 0.8494 0.000 0.820 0.000 0.000 0.180
#> GSM38158 2 0.1704 0.8313 0.000 0.928 0.004 0.000 0.068
#> GSM38159 2 0.4970 0.6925 0.148 0.712 0.000 0.000 0.140
#> GSM38160 5 0.3671 0.7747 0.000 0.236 0.008 0.000 0.756
#> GSM38161 5 0.3039 0.8280 0.000 0.192 0.000 0.000 0.808
#> GSM38162 4 0.1883 0.4208 0.008 0.000 0.048 0.932 0.012
#> GSM38163 1 0.1756 0.8511 0.940 0.000 0.036 0.016 0.008
#> GSM38164 1 0.4831 0.7104 0.740 0.000 0.016 0.068 0.176
#> GSM38165 3 0.4066 0.6786 0.044 0.000 0.768 0.188 0.000
#> GSM38166 3 0.1915 0.7754 0.040 0.000 0.928 0.032 0.000
#> GSM38167 4 0.5770 0.6419 0.392 0.000 0.040 0.540 0.028
#> GSM38168 4 0.2559 0.4336 0.024 0.008 0.032 0.912 0.024
#> GSM38169 1 0.4890 0.7074 0.736 0.000 0.016 0.072 0.176
#> GSM38170 3 0.6549 0.1396 0.280 0.000 0.476 0.244 0.000
#> GSM38171 1 0.0898 0.8503 0.972 0.000 0.020 0.000 0.008
#> GSM38172 1 0.7082 0.4447 0.572 0.000 0.108 0.192 0.128
#> GSM38173 1 0.2664 0.8155 0.884 0.000 0.020 0.004 0.092
#> GSM38174 4 0.5701 0.6427 0.404 0.000 0.044 0.532 0.020
#> GSM38175 1 0.0671 0.8400 0.980 0.004 0.000 0.000 0.016
#> GSM38176 1 0.1756 0.8511 0.940 0.000 0.036 0.016 0.008
#> GSM38177 4 0.5849 0.6316 0.400 0.000 0.044 0.528 0.028
#> GSM38178 1 0.5286 0.6780 0.708 0.000 0.016 0.108 0.168
#> GSM38179 1 0.1386 0.8500 0.952 0.000 0.032 0.016 0.000
#> GSM38180 1 0.0609 0.8490 0.980 0.000 0.020 0.000 0.000
#> GSM38181 3 0.4021 0.6660 0.168 0.000 0.780 0.052 0.000
#> GSM38182 4 0.5462 0.5918 0.464 0.000 0.036 0.488 0.012
#> GSM38183 1 0.1386 0.8500 0.952 0.000 0.032 0.016 0.000
#> GSM38184 2 0.0486 0.7697 0.004 0.988 0.004 0.004 0.000
#> GSM38185 1 0.1116 0.8346 0.964 0.004 0.000 0.004 0.028
#> GSM38186 1 0.1549 0.8287 0.944 0.000 0.016 0.040 0.000
#> GSM38187 1 0.1386 0.8504 0.952 0.000 0.032 0.016 0.000
#> GSM38188 4 0.5914 0.5807 0.456 0.020 0.012 0.480 0.032
#> GSM38189 4 0.6115 0.5499 0.424 0.000 0.012 0.476 0.088
#> GSM38190 1 0.4795 0.7140 0.744 0.000 0.016 0.068 0.172
#> GSM38191 5 0.1082 0.7904 0.008 0.028 0.000 0.000 0.964
#> GSM38192 1 0.1386 0.8500 0.952 0.000 0.032 0.016 0.000
#> GSM38193 5 0.3039 0.8280 0.000 0.192 0.000 0.000 0.808
#> GSM38194 5 0.1082 0.7904 0.008 0.028 0.000 0.000 0.964
#> GSM38195 4 0.5462 0.5918 0.464 0.000 0.036 0.488 0.012
#> GSM38196 4 0.5687 0.6468 0.396 0.000 0.044 0.540 0.020
#> GSM38197 1 0.1386 0.8504 0.952 0.000 0.032 0.016 0.000
#> GSM38198 4 0.1883 0.4208 0.008 0.000 0.048 0.932 0.012
#> GSM38199 3 0.5687 0.1401 0.060 0.000 0.508 0.424 0.008
#> GSM38200 2 0.3143 0.8289 0.000 0.796 0.000 0.000 0.204
#> GSM38201 4 0.1830 0.4142 0.004 0.000 0.052 0.932 0.012
#> GSM38202 4 0.6179 0.0963 0.112 0.000 0.368 0.512 0.008
#> GSM38203 3 0.1211 0.7732 0.016 0.000 0.960 0.024 0.000
#> GSM38204 3 0.0912 0.7748 0.016 0.000 0.972 0.012 0.000
#> GSM38205 3 0.2731 0.7488 0.016 0.000 0.876 0.104 0.004
#> GSM38206 3 0.0912 0.7748 0.016 0.000 0.972 0.012 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.1829 0.852 0.028 0.928 0.000 0.008 0.000 0.036
#> GSM38156 2 0.1556 0.855 0.000 0.920 0.000 0.000 0.000 0.080
#> GSM38157 2 0.1556 0.855 0.000 0.920 0.000 0.000 0.000 0.080
#> GSM38158 2 0.1010 0.835 0.000 0.960 0.004 0.000 0.036 0.000
#> GSM38159 2 0.3666 0.713 0.140 0.796 0.000 0.008 0.000 0.056
#> GSM38160 6 0.3672 0.742 0.000 0.276 0.008 0.000 0.004 0.712
#> GSM38161 6 0.3050 0.826 0.000 0.236 0.000 0.000 0.000 0.764
#> GSM38162 4 0.4428 0.479 0.004 0.000 0.016 0.752 0.092 0.136
#> GSM38163 1 0.1448 0.950 0.948 0.000 0.024 0.016 0.012 0.000
#> GSM38164 5 0.3136 0.909 0.228 0.000 0.000 0.000 0.768 0.004
#> GSM38165 3 0.4639 0.656 0.036 0.000 0.724 0.196 0.036 0.008
#> GSM38166 3 0.2044 0.766 0.028 0.000 0.920 0.040 0.004 0.008
#> GSM38167 4 0.4320 0.683 0.256 0.000 0.004 0.696 0.040 0.004
#> GSM38168 4 0.4605 0.483 0.008 0.000 0.012 0.736 0.096 0.148
#> GSM38169 5 0.3248 0.910 0.224 0.000 0.000 0.004 0.768 0.004
#> GSM38170 3 0.6765 0.144 0.188 0.000 0.424 0.340 0.040 0.008
#> GSM38171 1 0.0653 0.939 0.980 0.000 0.004 0.004 0.012 0.000
#> GSM38172 5 0.5439 0.709 0.092 0.000 0.080 0.100 0.708 0.020
#> GSM38173 1 0.2256 0.845 0.892 0.000 0.004 0.008 0.092 0.004
#> GSM38174 4 0.4029 0.687 0.256 0.000 0.012 0.712 0.020 0.000
#> GSM38175 1 0.1007 0.922 0.968 0.004 0.000 0.008 0.004 0.016
#> GSM38176 1 0.1448 0.950 0.948 0.000 0.024 0.016 0.012 0.000
#> GSM38177 4 0.4470 0.676 0.264 0.000 0.008 0.684 0.040 0.004
#> GSM38178 5 0.3649 0.893 0.196 0.000 0.000 0.040 0.764 0.000
#> GSM38179 1 0.1346 0.952 0.952 0.000 0.024 0.016 0.008 0.000
#> GSM38180 1 0.0436 0.939 0.988 0.000 0.004 0.004 0.004 0.000
#> GSM38181 3 0.4158 0.689 0.076 0.000 0.764 0.148 0.004 0.008
#> GSM38182 4 0.4894 0.658 0.308 0.000 0.016 0.624 0.052 0.000
#> GSM38183 1 0.1346 0.952 0.952 0.000 0.024 0.016 0.008 0.000
#> GSM38184 2 0.2721 0.772 0.000 0.868 0.004 0.000 0.088 0.040
#> GSM38185 1 0.2024 0.891 0.924 0.008 0.000 0.036 0.012 0.020
#> GSM38186 1 0.1152 0.924 0.952 0.000 0.000 0.044 0.004 0.000
#> GSM38187 1 0.1346 0.950 0.952 0.000 0.024 0.016 0.008 0.000
#> GSM38188 4 0.5603 0.654 0.304 0.012 0.004 0.596 0.060 0.024
#> GSM38189 4 0.5619 0.606 0.316 0.000 0.000 0.540 0.136 0.008
#> GSM38190 5 0.3163 0.907 0.232 0.000 0.000 0.000 0.764 0.004
#> GSM38191 6 0.3928 0.798 0.000 0.080 0.000 0.000 0.160 0.760
#> GSM38192 1 0.1346 0.952 0.952 0.000 0.024 0.016 0.008 0.000
#> GSM38193 6 0.3050 0.826 0.000 0.236 0.000 0.000 0.000 0.764
#> GSM38194 6 0.3928 0.798 0.000 0.080 0.000 0.000 0.160 0.760
#> GSM38195 4 0.4894 0.658 0.308 0.000 0.016 0.624 0.052 0.000
#> GSM38196 4 0.3947 0.686 0.256 0.000 0.012 0.716 0.016 0.000
#> GSM38197 1 0.1346 0.950 0.952 0.000 0.024 0.016 0.008 0.000
#> GSM38198 4 0.4428 0.479 0.004 0.000 0.016 0.752 0.092 0.136
#> GSM38199 3 0.5958 0.126 0.020 0.000 0.496 0.388 0.076 0.020
#> GSM38200 2 0.2135 0.817 0.000 0.872 0.000 0.000 0.000 0.128
#> GSM38201 4 0.4289 0.474 0.000 0.000 0.016 0.756 0.092 0.136
#> GSM38202 4 0.6295 0.144 0.072 0.000 0.340 0.512 0.064 0.012
#> GSM38203 3 0.1065 0.765 0.020 0.000 0.964 0.008 0.000 0.008
#> GSM38204 3 0.0692 0.765 0.020 0.000 0.976 0.000 0.000 0.004
#> GSM38205 3 0.2980 0.741 0.020 0.000 0.872 0.040 0.008 0.060
#> GSM38206 3 0.0692 0.765 0.020 0.000 0.976 0.000 0.000 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:hclust 52 1.10e-06 2
#> MAD:hclust 49 3.92e-09 3
#> MAD:hclust 44 1.26e-06 4
#> MAD:hclust 44 1.65e-07 5
#> MAD:hclust 45 6.03e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "kmeans"]
# you can also extract it by
# res = res_list["MAD:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.688 0.882 0.934 0.4280 0.551 0.551
#> 3 3 0.457 0.655 0.822 0.4197 0.615 0.414
#> 4 4 0.588 0.658 0.810 0.1839 0.759 0.453
#> 5 5 0.726 0.743 0.803 0.0975 0.882 0.589
#> 6 6 0.795 0.801 0.841 0.0538 0.966 0.826
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
#> GSM38155 2 0.0000 0.887 0.000 1.000
#> GSM38156 2 0.0000 0.887 0.000 1.000
#> GSM38157 2 0.0000 0.887 0.000 1.000
#> GSM38158 2 0.0000 0.887 0.000 1.000
#> GSM38159 2 0.0000 0.887 0.000 1.000
#> GSM38160 2 0.0000 0.887 0.000 1.000
#> GSM38161 2 0.0000 0.887 0.000 1.000
#> GSM38162 1 0.0376 0.941 0.996 0.004
#> GSM38163 1 0.3274 0.940 0.940 0.060
#> GSM38164 1 0.3274 0.940 0.940 0.060
#> GSM38165 1 0.0000 0.940 1.000 0.000
#> GSM38166 1 0.0000 0.940 1.000 0.000
#> GSM38167 1 0.2423 0.943 0.960 0.040
#> GSM38168 1 0.3274 0.932 0.940 0.060
#> GSM38169 1 0.3274 0.940 0.940 0.060
#> GSM38170 1 0.0000 0.940 1.000 0.000
#> GSM38171 1 0.6438 0.838 0.836 0.164
#> GSM38172 1 0.0000 0.940 1.000 0.000
#> GSM38173 1 0.3733 0.933 0.928 0.072
#> GSM38174 1 0.2423 0.943 0.960 0.040
#> GSM38175 2 0.8144 0.723 0.252 0.748
#> GSM38176 1 0.6438 0.838 0.836 0.164
#> GSM38177 1 0.2423 0.943 0.960 0.040
#> GSM38178 1 0.3274 0.940 0.940 0.060
#> GSM38179 1 0.3274 0.940 0.940 0.060
#> GSM38180 1 0.3274 0.940 0.940 0.060
#> GSM38181 1 0.0000 0.940 1.000 0.000
#> GSM38182 1 0.3274 0.940 0.940 0.060
#> GSM38183 1 0.5059 0.897 0.888 0.112
#> GSM38184 2 0.0000 0.887 0.000 1.000
#> GSM38185 2 0.6712 0.809 0.176 0.824
#> GSM38186 1 0.6343 0.843 0.840 0.160
#> GSM38187 1 0.3114 0.941 0.944 0.056
#> GSM38188 2 0.9775 0.328 0.412 0.588
#> GSM38189 1 0.3274 0.940 0.940 0.060
#> GSM38190 1 0.9552 0.394 0.624 0.376
#> GSM38191 2 0.6343 0.822 0.160 0.840
#> GSM38192 2 0.8081 0.729 0.248 0.752
#> GSM38193 2 0.0000 0.887 0.000 1.000
#> GSM38194 2 0.6343 0.822 0.160 0.840
#> GSM38195 1 0.3274 0.940 0.940 0.060
#> GSM38196 1 0.0376 0.941 0.996 0.004
#> GSM38197 2 0.7453 0.774 0.212 0.788
#> GSM38198 1 0.0376 0.941 0.996 0.004
#> GSM38199 1 0.0000 0.940 1.000 0.000
#> GSM38200 2 0.0000 0.887 0.000 1.000
#> GSM38201 1 0.0000 0.940 1.000 0.000
#> GSM38202 1 0.0000 0.940 1.000 0.000
#> GSM38203 1 0.0000 0.940 1.000 0.000
#> GSM38204 1 0.0000 0.940 1.000 0.000
#> GSM38205 1 0.0000 0.940 1.000 0.000
#> GSM38206 1 0.0000 0.940 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0237 0.9863 0.004 0.996 0.000
#> GSM38156 2 0.0475 0.9858 0.004 0.992 0.004
#> GSM38157 2 0.0475 0.9853 0.004 0.992 0.004
#> GSM38158 2 0.0237 0.9863 0.004 0.996 0.000
#> GSM38159 2 0.0237 0.9863 0.004 0.996 0.000
#> GSM38160 2 0.1753 0.9738 0.000 0.952 0.048
#> GSM38161 2 0.1765 0.9765 0.004 0.956 0.040
#> GSM38162 3 0.6062 0.3850 0.384 0.000 0.616
#> GSM38163 1 0.0592 0.7335 0.988 0.000 0.012
#> GSM38164 1 0.4062 0.6968 0.836 0.000 0.164
#> GSM38165 3 0.4235 0.6894 0.176 0.000 0.824
#> GSM38166 3 0.4178 0.6912 0.172 0.000 0.828
#> GSM38167 1 0.6081 0.4386 0.652 0.004 0.344
#> GSM38168 3 0.6518 0.0644 0.484 0.004 0.512
#> GSM38169 1 0.4062 0.6968 0.836 0.000 0.164
#> GSM38170 1 0.5553 0.4046 0.724 0.004 0.272
#> GSM38171 1 0.0848 0.7338 0.984 0.008 0.008
#> GSM38172 3 0.5988 0.4175 0.368 0.000 0.632
#> GSM38173 1 0.3551 0.7110 0.868 0.000 0.132
#> GSM38174 1 0.5929 0.4883 0.676 0.004 0.320
#> GSM38175 1 0.1964 0.7160 0.944 0.056 0.000
#> GSM38176 1 0.0848 0.7338 0.984 0.008 0.008
#> GSM38177 1 0.6189 0.4238 0.632 0.004 0.364
#> GSM38178 1 0.4178 0.6933 0.828 0.000 0.172
#> GSM38179 1 0.0592 0.7335 0.988 0.000 0.012
#> GSM38180 1 0.0592 0.7335 0.988 0.000 0.012
#> GSM38181 3 0.6235 0.3598 0.436 0.000 0.564
#> GSM38182 1 0.5623 0.5038 0.716 0.004 0.280
#> GSM38183 1 0.0475 0.7349 0.992 0.004 0.004
#> GSM38184 2 0.0237 0.9863 0.004 0.996 0.000
#> GSM38185 1 0.3207 0.6904 0.904 0.084 0.012
#> GSM38186 1 0.2590 0.7322 0.924 0.004 0.072
#> GSM38187 1 0.1289 0.7254 0.968 0.000 0.032
#> GSM38188 1 0.9089 0.3840 0.524 0.312 0.164
#> GSM38189 1 0.4834 0.6658 0.792 0.004 0.204
#> GSM38190 1 0.4683 0.7038 0.836 0.024 0.140
#> GSM38191 1 0.9663 0.2463 0.416 0.372 0.212
#> GSM38192 1 0.2261 0.7098 0.932 0.068 0.000
#> GSM38193 2 0.1643 0.9746 0.000 0.956 0.044
#> GSM38194 1 0.9647 0.2555 0.428 0.360 0.212
#> GSM38195 1 0.5588 0.5027 0.720 0.004 0.276
#> GSM38196 3 0.6518 0.1011 0.484 0.004 0.512
#> GSM38197 1 0.4059 0.6587 0.860 0.128 0.012
#> GSM38198 3 0.6314 0.3617 0.392 0.004 0.604
#> GSM38199 3 0.4750 0.6563 0.216 0.000 0.784
#> GSM38200 2 0.1031 0.9815 0.000 0.976 0.024
#> GSM38201 3 0.2537 0.6615 0.080 0.000 0.920
#> GSM38202 3 0.4504 0.6275 0.196 0.000 0.804
#> GSM38203 3 0.4002 0.6931 0.160 0.000 0.840
#> GSM38204 3 0.4235 0.6894 0.176 0.000 0.824
#> GSM38205 3 0.4002 0.6931 0.160 0.000 0.840
#> GSM38206 3 0.4178 0.6912 0.172 0.000 0.828
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0188 0.9634 0.004 0.996 0.000 0.000
#> GSM38156 2 0.0992 0.9622 0.004 0.976 0.012 0.008
#> GSM38157 2 0.0992 0.9622 0.004 0.976 0.012 0.008
#> GSM38158 2 0.0712 0.9616 0.004 0.984 0.004 0.008
#> GSM38159 2 0.0524 0.9628 0.008 0.988 0.000 0.004
#> GSM38160 2 0.2949 0.9338 0.000 0.888 0.024 0.088
#> GSM38161 2 0.2597 0.9327 0.004 0.904 0.008 0.084
#> GSM38162 4 0.5694 0.6006 0.080 0.000 0.224 0.696
#> GSM38163 1 0.0336 0.8136 0.992 0.000 0.000 0.008
#> GSM38164 4 0.5244 0.3753 0.436 0.000 0.008 0.556
#> GSM38165 3 0.1389 0.8806 0.048 0.000 0.952 0.000
#> GSM38166 3 0.1767 0.8794 0.044 0.000 0.944 0.012
#> GSM38167 4 0.6313 0.6109 0.220 0.000 0.128 0.652
#> GSM38168 4 0.5536 0.6251 0.096 0.000 0.180 0.724
#> GSM38169 4 0.5244 0.3753 0.436 0.000 0.008 0.556
#> GSM38170 1 0.7043 -0.1775 0.456 0.000 0.120 0.424
#> GSM38171 1 0.0592 0.8128 0.984 0.000 0.000 0.016
#> GSM38172 4 0.4037 0.6054 0.040 0.000 0.136 0.824
#> GSM38173 4 0.5155 0.2891 0.468 0.000 0.004 0.528
#> GSM38174 4 0.5998 0.5971 0.200 0.000 0.116 0.684
#> GSM38175 1 0.0672 0.8127 0.984 0.008 0.000 0.008
#> GSM38176 1 0.0188 0.8140 0.996 0.000 0.000 0.004
#> GSM38177 4 0.5894 0.6351 0.200 0.000 0.108 0.692
#> GSM38178 4 0.4594 0.5623 0.280 0.000 0.008 0.712
#> GSM38179 1 0.0592 0.8138 0.984 0.000 0.000 0.016
#> GSM38180 1 0.0817 0.8125 0.976 0.000 0.000 0.024
#> GSM38181 3 0.4188 0.7349 0.148 0.000 0.812 0.040
#> GSM38182 1 0.7006 -0.1197 0.456 0.000 0.116 0.428
#> GSM38183 1 0.0336 0.8147 0.992 0.000 0.000 0.008
#> GSM38184 2 0.0712 0.9616 0.004 0.984 0.004 0.008
#> GSM38185 1 0.2438 0.7794 0.924 0.012 0.016 0.048
#> GSM38186 1 0.2530 0.7140 0.888 0.000 0.000 0.112
#> GSM38187 1 0.0592 0.8141 0.984 0.000 0.000 0.016
#> GSM38188 4 0.8703 0.1122 0.348 0.240 0.040 0.372
#> GSM38189 4 0.5250 0.5115 0.316 0.000 0.024 0.660
#> GSM38190 4 0.5112 0.3659 0.436 0.000 0.004 0.560
#> GSM38191 4 0.6445 0.4786 0.220 0.104 0.012 0.664
#> GSM38192 1 0.0524 0.8118 0.988 0.004 0.000 0.008
#> GSM38193 2 0.2727 0.9316 0.004 0.900 0.012 0.084
#> GSM38194 4 0.5222 0.5426 0.112 0.108 0.008 0.772
#> GSM38195 1 0.6965 -0.1145 0.460 0.000 0.112 0.428
#> GSM38196 4 0.6388 0.6090 0.156 0.000 0.192 0.652
#> GSM38197 1 0.1488 0.7884 0.956 0.032 0.000 0.012
#> GSM38198 4 0.5661 0.6026 0.080 0.000 0.220 0.700
#> GSM38199 3 0.6016 -0.0306 0.044 0.000 0.544 0.412
#> GSM38200 2 0.1297 0.9601 0.000 0.964 0.020 0.016
#> GSM38201 4 0.4914 0.4918 0.012 0.000 0.312 0.676
#> GSM38202 4 0.4883 0.5183 0.016 0.000 0.288 0.696
#> GSM38203 3 0.1209 0.8746 0.032 0.000 0.964 0.004
#> GSM38204 3 0.1489 0.8817 0.044 0.000 0.952 0.004
#> GSM38205 3 0.1209 0.8746 0.032 0.000 0.964 0.004
#> GSM38206 3 0.1489 0.8817 0.044 0.000 0.952 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0290 0.926 0.008 0.992 0.000 0.000 0.000
#> GSM38156 2 0.0854 0.924 0.008 0.976 0.000 0.004 0.012
#> GSM38157 2 0.0740 0.926 0.008 0.980 0.000 0.004 0.008
#> GSM38158 2 0.0451 0.926 0.008 0.988 0.000 0.004 0.000
#> GSM38159 2 0.0727 0.924 0.012 0.980 0.000 0.004 0.004
#> GSM38160 2 0.4514 0.839 0.000 0.760 0.008 0.068 0.164
#> GSM38161 2 0.4468 0.846 0.012 0.776 0.008 0.044 0.160
#> GSM38162 4 0.5831 0.472 0.024 0.000 0.060 0.584 0.332
#> GSM38163 1 0.0566 0.963 0.984 0.000 0.000 0.004 0.012
#> GSM38164 5 0.5010 0.749 0.224 0.000 0.000 0.088 0.688
#> GSM38165 3 0.0290 0.911 0.008 0.000 0.992 0.000 0.000
#> GSM38166 3 0.1041 0.896 0.004 0.000 0.964 0.032 0.000
#> GSM38167 4 0.5223 0.587 0.080 0.008 0.036 0.748 0.128
#> GSM38168 4 0.5404 0.477 0.016 0.000 0.044 0.612 0.328
#> GSM38169 5 0.5064 0.749 0.232 0.000 0.000 0.088 0.680
#> GSM38170 4 0.6383 0.503 0.224 0.008 0.080 0.632 0.056
#> GSM38171 1 0.0693 0.961 0.980 0.000 0.000 0.012 0.008
#> GSM38172 5 0.3670 0.490 0.012 0.000 0.008 0.188 0.792
#> GSM38173 5 0.5461 0.680 0.284 0.000 0.000 0.096 0.620
#> GSM38174 4 0.4157 0.579 0.060 0.008 0.028 0.824 0.080
#> GSM38175 1 0.0566 0.962 0.984 0.004 0.000 0.012 0.000
#> GSM38176 1 0.0566 0.963 0.984 0.000 0.000 0.004 0.012
#> GSM38177 4 0.5855 0.505 0.060 0.000 0.036 0.620 0.284
#> GSM38178 5 0.5039 0.668 0.116 0.000 0.000 0.184 0.700
#> GSM38179 1 0.0404 0.963 0.988 0.000 0.000 0.012 0.000
#> GSM38180 1 0.0693 0.961 0.980 0.000 0.000 0.012 0.008
#> GSM38181 3 0.1918 0.864 0.036 0.000 0.928 0.036 0.000
#> GSM38182 4 0.6908 0.451 0.192 0.008 0.060 0.596 0.144
#> GSM38183 1 0.0451 0.962 0.988 0.000 0.000 0.008 0.004
#> GSM38184 2 0.0451 0.926 0.008 0.988 0.000 0.004 0.000
#> GSM38185 1 0.2141 0.914 0.916 0.004 0.000 0.064 0.016
#> GSM38186 1 0.2300 0.877 0.904 0.000 0.000 0.072 0.024
#> GSM38187 1 0.1200 0.956 0.964 0.000 0.016 0.012 0.008
#> GSM38188 4 0.7358 0.351 0.144 0.164 0.000 0.548 0.144
#> GSM38189 4 0.5855 0.151 0.108 0.000 0.000 0.536 0.356
#> GSM38190 5 0.5185 0.740 0.228 0.000 0.000 0.100 0.672
#> GSM38191 5 0.3403 0.612 0.064 0.032 0.008 0.028 0.868
#> GSM38192 1 0.0854 0.958 0.976 0.004 0.000 0.008 0.012
#> GSM38193 2 0.4482 0.837 0.004 0.768 0.008 0.056 0.164
#> GSM38194 5 0.3056 0.576 0.028 0.032 0.008 0.044 0.888
#> GSM38195 4 0.7004 0.449 0.196 0.008 0.060 0.584 0.152
#> GSM38196 4 0.5213 0.591 0.056 0.008 0.056 0.752 0.128
#> GSM38197 1 0.1690 0.940 0.944 0.008 0.000 0.024 0.024
#> GSM38198 4 0.5831 0.472 0.024 0.000 0.060 0.584 0.332
#> GSM38199 3 0.6185 0.227 0.008 0.000 0.588 0.184 0.220
#> GSM38200 2 0.1907 0.911 0.000 0.928 0.000 0.044 0.028
#> GSM38201 4 0.5762 0.465 0.004 0.000 0.100 0.588 0.308
#> GSM38202 4 0.5964 0.429 0.000 0.000 0.124 0.536 0.340
#> GSM38203 3 0.0566 0.908 0.004 0.000 0.984 0.012 0.000
#> GSM38204 3 0.0290 0.911 0.008 0.000 0.992 0.000 0.000
#> GSM38205 3 0.0566 0.908 0.004 0.000 0.984 0.012 0.000
#> GSM38206 3 0.0290 0.911 0.008 0.000 0.992 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0000 0.879 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38156 2 0.0436 0.879 0.000 0.988 0.000 0.004 0.004 0.004
#> GSM38157 2 0.0436 0.879 0.000 0.988 0.000 0.004 0.004 0.004
#> GSM38158 2 0.1121 0.869 0.000 0.964 0.004 0.008 0.016 0.008
#> GSM38159 2 0.0146 0.879 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM38160 2 0.5476 0.728 0.000 0.640 0.000 0.096 0.220 0.044
#> GSM38161 2 0.5172 0.730 0.004 0.664 0.000 0.084 0.224 0.024
#> GSM38162 4 0.3459 0.935 0.000 0.000 0.016 0.824 0.052 0.108
#> GSM38163 1 0.1268 0.935 0.952 0.000 0.000 0.008 0.036 0.004
#> GSM38164 5 0.5121 0.806 0.124 0.000 0.004 0.072 0.716 0.084
#> GSM38165 3 0.0870 0.917 0.000 0.000 0.972 0.012 0.004 0.012
#> GSM38166 3 0.1605 0.904 0.000 0.000 0.940 0.012 0.016 0.032
#> GSM38167 6 0.5254 0.315 0.016 0.000 0.008 0.364 0.048 0.564
#> GSM38168 4 0.3504 0.933 0.000 0.000 0.016 0.820 0.052 0.112
#> GSM38169 5 0.5093 0.804 0.116 0.000 0.004 0.080 0.720 0.080
#> GSM38170 6 0.4720 0.658 0.068 0.000 0.024 0.112 0.036 0.760
#> GSM38171 1 0.2152 0.927 0.912 0.000 0.000 0.012 0.036 0.040
#> GSM38172 5 0.4799 0.689 0.004 0.000 0.004 0.228 0.676 0.088
#> GSM38173 5 0.5490 0.752 0.152 0.000 0.004 0.052 0.672 0.120
#> GSM38174 6 0.3161 0.656 0.004 0.000 0.008 0.156 0.012 0.820
#> GSM38175 1 0.1167 0.946 0.960 0.000 0.000 0.008 0.012 0.020
#> GSM38176 1 0.1268 0.935 0.952 0.000 0.000 0.008 0.036 0.004
#> GSM38177 4 0.4349 0.771 0.012 0.000 0.004 0.732 0.052 0.200
#> GSM38178 5 0.5255 0.763 0.056 0.000 0.004 0.092 0.696 0.152
#> GSM38179 1 0.1167 0.947 0.960 0.000 0.000 0.008 0.012 0.020
#> GSM38180 1 0.1577 0.937 0.940 0.000 0.000 0.008 0.016 0.036
#> GSM38181 3 0.1750 0.900 0.000 0.000 0.932 0.012 0.016 0.040
#> GSM38182 6 0.1760 0.701 0.048 0.000 0.020 0.000 0.004 0.928
#> GSM38183 1 0.0964 0.946 0.968 0.000 0.000 0.004 0.012 0.016
#> GSM38184 2 0.1223 0.868 0.000 0.960 0.004 0.012 0.016 0.008
#> GSM38185 1 0.2006 0.913 0.892 0.000 0.000 0.004 0.000 0.104
#> GSM38186 1 0.2652 0.884 0.868 0.000 0.000 0.008 0.020 0.104
#> GSM38187 1 0.0692 0.947 0.976 0.000 0.000 0.004 0.000 0.020
#> GSM38188 6 0.3036 0.649 0.020 0.104 0.004 0.012 0.004 0.856
#> GSM38189 6 0.4054 0.503 0.020 0.000 0.000 0.024 0.220 0.736
#> GSM38190 5 0.5199 0.802 0.120 0.004 0.004 0.060 0.716 0.096
#> GSM38191 5 0.3926 0.629 0.036 0.016 0.000 0.112 0.808 0.028
#> GSM38192 1 0.0692 0.947 0.976 0.000 0.000 0.004 0.000 0.020
#> GSM38193 2 0.5244 0.728 0.004 0.660 0.000 0.084 0.224 0.028
#> GSM38194 5 0.3795 0.619 0.020 0.016 0.000 0.128 0.808 0.028
#> GSM38195 6 0.1760 0.701 0.048 0.000 0.020 0.000 0.004 0.928
#> GSM38196 6 0.4851 0.320 0.004 0.000 0.012 0.372 0.032 0.580
#> GSM38197 1 0.1296 0.940 0.952 0.012 0.000 0.004 0.000 0.032
#> GSM38198 4 0.3459 0.935 0.000 0.000 0.016 0.824 0.052 0.108
#> GSM38199 3 0.5853 0.506 0.004 0.000 0.648 0.112 0.140 0.096
#> GSM38200 2 0.2303 0.860 0.000 0.904 0.000 0.052 0.020 0.024
#> GSM38201 4 0.3164 0.911 0.000 0.000 0.020 0.844 0.032 0.104
#> GSM38202 6 0.5361 0.406 0.000 0.000 0.036 0.284 0.068 0.612
#> GSM38203 3 0.1010 0.910 0.000 0.000 0.960 0.036 0.000 0.004
#> GSM38204 3 0.0146 0.919 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM38205 3 0.1010 0.910 0.000 0.000 0.960 0.036 0.000 0.004
#> GSM38206 3 0.0146 0.919 0.000 0.000 0.996 0.000 0.000 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> MAD:kmeans 50 8.70e-05 2
#> MAD:kmeans 39 1.42e-09 3
#> MAD:kmeans 41 2.37e-07 4
#> MAD:kmeans 41 1.59e-07 5
#> MAD:kmeans 49 3.48e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.730 0.856 0.939 0.5020 0.502 0.502
#> 3 3 0.558 0.760 0.863 0.3427 0.746 0.533
#> 4 4 0.546 0.588 0.786 0.1256 0.858 0.603
#> 5 5 0.602 0.579 0.758 0.0625 0.897 0.613
#> 6 6 0.648 0.533 0.727 0.0395 0.956 0.784
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
#> GSM38155 2 0.0000 0.942 0.000 1.000
#> GSM38156 2 0.0000 0.942 0.000 1.000
#> GSM38157 2 0.0000 0.942 0.000 1.000
#> GSM38158 2 0.0000 0.942 0.000 1.000
#> GSM38159 2 0.0000 0.942 0.000 1.000
#> GSM38160 2 0.0000 0.942 0.000 1.000
#> GSM38161 2 0.0000 0.942 0.000 1.000
#> GSM38162 1 0.0000 0.923 1.000 0.000
#> GSM38163 1 0.2043 0.906 0.968 0.032
#> GSM38164 1 0.1414 0.913 0.980 0.020
#> GSM38165 1 0.0000 0.923 1.000 0.000
#> GSM38166 1 0.0000 0.923 1.000 0.000
#> GSM38167 1 0.0000 0.923 1.000 0.000
#> GSM38168 1 0.8144 0.653 0.748 0.252
#> GSM38169 1 0.0376 0.921 0.996 0.004
#> GSM38170 1 0.0000 0.923 1.000 0.000
#> GSM38171 2 0.8327 0.633 0.264 0.736
#> GSM38172 1 0.0000 0.923 1.000 0.000
#> GSM38173 1 0.9044 0.522 0.680 0.320
#> GSM38174 1 0.3431 0.885 0.936 0.064
#> GSM38175 2 0.0000 0.942 0.000 1.000
#> GSM38176 2 0.7453 0.720 0.212 0.788
#> GSM38177 1 0.0000 0.923 1.000 0.000
#> GSM38178 1 0.6343 0.788 0.840 0.160
#> GSM38179 1 0.0000 0.923 1.000 0.000
#> GSM38180 1 0.8327 0.636 0.736 0.264
#> GSM38181 1 0.0000 0.923 1.000 0.000
#> GSM38182 1 0.9209 0.516 0.664 0.336
#> GSM38183 2 0.6148 0.804 0.152 0.848
#> GSM38184 2 0.0000 0.942 0.000 1.000
#> GSM38185 2 0.0000 0.942 0.000 1.000
#> GSM38186 2 0.9922 0.177 0.448 0.552
#> GSM38187 1 0.4431 0.862 0.908 0.092
#> GSM38188 2 0.1843 0.921 0.028 0.972
#> GSM38189 1 0.1843 0.910 0.972 0.028
#> GSM38190 2 0.0672 0.937 0.008 0.992
#> GSM38191 2 0.0000 0.942 0.000 1.000
#> GSM38192 2 0.0000 0.942 0.000 1.000
#> GSM38193 2 0.0000 0.942 0.000 1.000
#> GSM38194 2 0.0000 0.942 0.000 1.000
#> GSM38195 1 0.9988 0.127 0.520 0.480
#> GSM38196 1 0.0000 0.923 1.000 0.000
#> GSM38197 2 0.0000 0.942 0.000 1.000
#> GSM38198 1 0.0000 0.923 1.000 0.000
#> GSM38199 1 0.0000 0.923 1.000 0.000
#> GSM38200 2 0.0000 0.942 0.000 1.000
#> GSM38201 1 0.0000 0.923 1.000 0.000
#> GSM38202 1 0.0000 0.923 1.000 0.000
#> GSM38203 1 0.0000 0.923 1.000 0.000
#> GSM38204 1 0.0000 0.923 1.000 0.000
#> GSM38205 1 0.0000 0.923 1.000 0.000
#> GSM38206 1 0.0000 0.923 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38159 2 0.0747 0.949 0.016 0.984 0.000
#> GSM38160 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38162 3 0.2796 0.788 0.092 0.000 0.908
#> GSM38163 1 0.1411 0.796 0.964 0.000 0.036
#> GSM38164 1 0.5763 0.648 0.740 0.016 0.244
#> GSM38165 3 0.2796 0.801 0.092 0.000 0.908
#> GSM38166 3 0.2448 0.806 0.076 0.000 0.924
#> GSM38167 3 0.4931 0.691 0.232 0.000 0.768
#> GSM38168 3 0.7610 0.569 0.108 0.216 0.676
#> GSM38169 1 0.4452 0.720 0.808 0.000 0.192
#> GSM38170 3 0.4605 0.749 0.204 0.000 0.796
#> GSM38171 1 0.2152 0.799 0.948 0.036 0.016
#> GSM38172 3 0.3340 0.773 0.120 0.000 0.880
#> GSM38173 1 0.3610 0.781 0.888 0.016 0.096
#> GSM38174 3 0.5939 0.739 0.140 0.072 0.788
#> GSM38175 1 0.5178 0.657 0.744 0.256 0.000
#> GSM38176 1 0.1482 0.800 0.968 0.020 0.012
#> GSM38177 3 0.5988 0.452 0.368 0.000 0.632
#> GSM38178 1 0.8710 0.273 0.508 0.112 0.380
#> GSM38179 1 0.1964 0.790 0.944 0.000 0.056
#> GSM38180 1 0.2384 0.789 0.936 0.008 0.056
#> GSM38181 3 0.5058 0.693 0.244 0.000 0.756
#> GSM38182 3 0.8668 0.501 0.180 0.224 0.596
#> GSM38183 1 0.3461 0.794 0.900 0.076 0.024
#> GSM38184 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38185 2 0.4887 0.673 0.228 0.772 0.000
#> GSM38186 1 0.5267 0.755 0.816 0.044 0.140
#> GSM38187 1 0.5062 0.699 0.800 0.016 0.184
#> GSM38188 2 0.3042 0.899 0.040 0.920 0.040
#> GSM38189 3 0.7561 0.110 0.444 0.040 0.516
#> GSM38190 1 0.7698 0.545 0.624 0.304 0.072
#> GSM38191 2 0.1170 0.945 0.016 0.976 0.008
#> GSM38192 1 0.5859 0.503 0.656 0.344 0.000
#> GSM38193 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38194 2 0.3683 0.868 0.044 0.896 0.060
#> GSM38195 3 0.8793 0.406 0.140 0.308 0.552
#> GSM38196 3 0.1860 0.807 0.052 0.000 0.948
#> GSM38197 2 0.2998 0.900 0.068 0.916 0.016
#> GSM38198 3 0.2356 0.792 0.072 0.000 0.928
#> GSM38199 3 0.2356 0.812 0.072 0.000 0.928
#> GSM38200 2 0.0000 0.957 0.000 1.000 0.000
#> GSM38201 3 0.1289 0.801 0.032 0.000 0.968
#> GSM38202 3 0.1411 0.809 0.036 0.000 0.964
#> GSM38203 3 0.2165 0.808 0.064 0.000 0.936
#> GSM38204 3 0.2356 0.807 0.072 0.000 0.928
#> GSM38205 3 0.2165 0.808 0.064 0.000 0.936
#> GSM38206 3 0.2261 0.807 0.068 0.000 0.932
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.8745 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0376 0.8730 0.004 0.992 0.000 0.004
#> GSM38157 2 0.0188 0.8739 0.004 0.996 0.000 0.000
#> GSM38158 2 0.0000 0.8745 0.000 1.000 0.000 0.000
#> GSM38159 2 0.1022 0.8600 0.032 0.968 0.000 0.000
#> GSM38160 2 0.0524 0.8715 0.008 0.988 0.000 0.004
#> GSM38161 2 0.0000 0.8745 0.000 1.000 0.000 0.000
#> GSM38162 4 0.4741 0.4192 0.004 0.000 0.328 0.668
#> GSM38163 1 0.2505 0.8088 0.920 0.004 0.040 0.036
#> GSM38164 4 0.6077 0.4678 0.280 0.004 0.068 0.648
#> GSM38165 3 0.0592 0.6787 0.016 0.000 0.984 0.000
#> GSM38166 3 0.1637 0.6708 0.000 0.000 0.940 0.060
#> GSM38167 4 0.6835 0.3378 0.132 0.004 0.264 0.600
#> GSM38168 4 0.5795 0.4797 0.020 0.040 0.244 0.696
#> GSM38169 4 0.5746 0.3469 0.348 0.000 0.040 0.612
#> GSM38170 3 0.6360 0.4785 0.164 0.000 0.656 0.180
#> GSM38171 1 0.1853 0.8125 0.948 0.012 0.012 0.028
#> GSM38172 4 0.5322 0.4542 0.028 0.000 0.312 0.660
#> GSM38173 1 0.7149 0.2217 0.552 0.028 0.076 0.344
#> GSM38174 4 0.7080 0.1856 0.060 0.052 0.280 0.608
#> GSM38175 1 0.3855 0.7339 0.820 0.164 0.004 0.012
#> GSM38176 1 0.1229 0.8118 0.968 0.004 0.008 0.020
#> GSM38177 4 0.6119 0.5251 0.168 0.000 0.152 0.680
#> GSM38178 4 0.6837 0.5295 0.140 0.040 0.144 0.676
#> GSM38179 1 0.2751 0.8047 0.904 0.000 0.040 0.056
#> GSM38180 1 0.1943 0.8129 0.944 0.008 0.032 0.016
#> GSM38181 3 0.4458 0.5987 0.116 0.000 0.808 0.076
#> GSM38182 3 0.8421 0.2856 0.112 0.084 0.488 0.316
#> GSM38183 1 0.2441 0.8032 0.916 0.012 0.004 0.068
#> GSM38184 2 0.0000 0.8745 0.000 1.000 0.000 0.000
#> GSM38185 2 0.6044 0.2883 0.384 0.572 0.004 0.040
#> GSM38186 1 0.5738 0.6375 0.744 0.032 0.060 0.164
#> GSM38187 1 0.5076 0.6146 0.712 0.004 0.260 0.024
#> GSM38188 2 0.6233 0.6136 0.040 0.704 0.060 0.196
#> GSM38189 4 0.7216 0.4267 0.160 0.036 0.168 0.636
#> GSM38190 4 0.7493 0.2320 0.304 0.208 0.000 0.488
#> GSM38191 2 0.5261 0.7046 0.048 0.764 0.020 0.168
#> GSM38192 1 0.3380 0.7539 0.852 0.136 0.008 0.004
#> GSM38193 2 0.0000 0.8745 0.000 1.000 0.000 0.000
#> GSM38194 2 0.6093 0.4084 0.036 0.604 0.012 0.348
#> GSM38195 3 0.9211 0.1462 0.112 0.168 0.396 0.324
#> GSM38196 3 0.6028 0.0853 0.032 0.004 0.488 0.476
#> GSM38197 2 0.6099 0.6746 0.156 0.728 0.076 0.040
#> GSM38198 4 0.4677 0.4305 0.004 0.000 0.316 0.680
#> GSM38199 3 0.4361 0.5404 0.020 0.000 0.772 0.208
#> GSM38200 2 0.0188 0.8739 0.004 0.996 0.000 0.000
#> GSM38201 3 0.5163 -0.1157 0.004 0.000 0.516 0.480
#> GSM38202 3 0.5062 0.4157 0.020 0.000 0.680 0.300
#> GSM38203 3 0.0895 0.6754 0.004 0.000 0.976 0.020
#> GSM38204 3 0.1042 0.6792 0.008 0.000 0.972 0.020
#> GSM38205 3 0.1305 0.6714 0.004 0.000 0.960 0.036
#> GSM38206 3 0.0657 0.6784 0.004 0.000 0.984 0.012
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0162 0.8208 0.000 0.996 0.000 0.000 0.004
#> GSM38156 2 0.0324 0.8213 0.000 0.992 0.000 0.004 0.004
#> GSM38157 2 0.0404 0.8210 0.000 0.988 0.000 0.012 0.000
#> GSM38158 2 0.0000 0.8208 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.1251 0.8095 0.036 0.956 0.000 0.000 0.008
#> GSM38160 2 0.1074 0.8180 0.004 0.968 0.000 0.016 0.012
#> GSM38161 2 0.1243 0.8141 0.004 0.960 0.000 0.008 0.028
#> GSM38162 4 0.5481 0.5274 0.008 0.000 0.184 0.676 0.132
#> GSM38163 1 0.3442 0.7819 0.852 0.000 0.044 0.016 0.088
#> GSM38164 5 0.5355 0.6089 0.104 0.000 0.064 0.096 0.736
#> GSM38165 3 0.0960 0.7632 0.008 0.000 0.972 0.016 0.004
#> GSM38166 3 0.1854 0.7507 0.008 0.000 0.936 0.036 0.020
#> GSM38167 4 0.6200 0.5003 0.068 0.004 0.100 0.668 0.160
#> GSM38168 4 0.5545 0.5337 0.024 0.036 0.096 0.740 0.104
#> GSM38169 5 0.4487 0.6011 0.096 0.000 0.008 0.124 0.772
#> GSM38170 3 0.7747 0.2231 0.176 0.000 0.484 0.216 0.124
#> GSM38171 1 0.3528 0.7806 0.852 0.008 0.020 0.024 0.096
#> GSM38172 5 0.5729 0.3765 0.000 0.000 0.148 0.236 0.616
#> GSM38173 5 0.6125 0.5107 0.252 0.020 0.048 0.040 0.640
#> GSM38174 4 0.5785 0.4636 0.040 0.020 0.076 0.712 0.152
#> GSM38175 1 0.4325 0.7083 0.776 0.168 0.000 0.024 0.032
#> GSM38176 1 0.2115 0.7967 0.916 0.008 0.000 0.008 0.068
#> GSM38177 4 0.6059 0.4490 0.108 0.000 0.060 0.668 0.164
#> GSM38178 5 0.5017 0.5926 0.048 0.028 0.036 0.112 0.776
#> GSM38179 1 0.3629 0.7885 0.848 0.000 0.036 0.040 0.076
#> GSM38180 1 0.3071 0.7898 0.872 0.000 0.036 0.012 0.080
#> GSM38181 3 0.4089 0.6574 0.072 0.000 0.820 0.076 0.032
#> GSM38182 4 0.8890 0.0885 0.092 0.060 0.296 0.364 0.188
#> GSM38183 1 0.3236 0.7827 0.860 0.008 0.004 0.028 0.100
#> GSM38184 2 0.0798 0.8167 0.016 0.976 0.000 0.000 0.008
#> GSM38185 2 0.6696 -0.0171 0.428 0.460 0.016 0.052 0.044
#> GSM38186 1 0.6706 0.5748 0.644 0.048 0.028 0.148 0.132
#> GSM38187 1 0.4954 0.6070 0.688 0.004 0.264 0.016 0.028
#> GSM38188 2 0.7543 0.3259 0.032 0.532 0.044 0.236 0.156
#> GSM38189 5 0.7400 0.2525 0.080 0.012 0.116 0.260 0.532
#> GSM38190 5 0.5694 0.5968 0.132 0.112 0.004 0.044 0.708
#> GSM38191 2 0.6519 -0.0678 0.048 0.456 0.004 0.056 0.436
#> GSM38192 1 0.3496 0.7544 0.840 0.116 0.000 0.016 0.028
#> GSM38193 2 0.1493 0.8075 0.000 0.948 0.000 0.024 0.028
#> GSM38194 5 0.6679 0.1452 0.016 0.388 0.004 0.128 0.464
#> GSM38195 4 0.9023 0.0734 0.056 0.120 0.296 0.348 0.180
#> GSM38196 4 0.5263 0.5209 0.016 0.000 0.208 0.696 0.080
#> GSM38197 2 0.7347 0.4611 0.184 0.592 0.120 0.044 0.060
#> GSM38198 4 0.4981 0.5454 0.004 0.000 0.160 0.720 0.116
#> GSM38199 3 0.5732 0.5019 0.024 0.000 0.672 0.120 0.184
#> GSM38200 2 0.0404 0.8210 0.000 0.988 0.000 0.012 0.000
#> GSM38201 4 0.5302 0.3823 0.000 0.000 0.344 0.592 0.064
#> GSM38202 3 0.6366 0.2096 0.012 0.000 0.544 0.300 0.144
#> GSM38203 3 0.1894 0.7466 0.000 0.000 0.920 0.072 0.008
#> GSM38204 3 0.0798 0.7622 0.000 0.000 0.976 0.016 0.008
#> GSM38205 3 0.2439 0.7107 0.000 0.000 0.876 0.120 0.004
#> GSM38206 3 0.0510 0.7624 0.000 0.000 0.984 0.016 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0551 0.79606 0.004 0.984 0.000 0.000 0.004 0.008
#> GSM38156 2 0.1010 0.79488 0.000 0.960 0.000 0.000 0.004 0.036
#> GSM38157 2 0.1116 0.79495 0.004 0.960 0.000 0.000 0.008 0.028
#> GSM38158 2 0.0622 0.79445 0.000 0.980 0.000 0.000 0.008 0.012
#> GSM38159 2 0.2917 0.74836 0.076 0.868 0.000 0.004 0.012 0.040
#> GSM38160 2 0.2170 0.77966 0.000 0.888 0.000 0.000 0.012 0.100
#> GSM38161 2 0.2095 0.78034 0.000 0.904 0.004 0.000 0.016 0.076
#> GSM38162 4 0.2069 0.57701 0.000 0.000 0.068 0.908 0.020 0.004
#> GSM38163 1 0.4262 0.71909 0.792 0.000 0.040 0.016 0.100 0.052
#> GSM38164 5 0.4646 0.54157 0.068 0.000 0.016 0.108 0.764 0.044
#> GSM38165 3 0.1710 0.79283 0.016 0.000 0.936 0.020 0.000 0.028
#> GSM38166 3 0.2213 0.77003 0.008 0.000 0.904 0.008 0.008 0.072
#> GSM38167 4 0.6967 0.08390 0.060 0.004 0.032 0.500 0.108 0.296
#> GSM38168 4 0.4124 0.51835 0.000 0.012 0.028 0.796 0.104 0.060
#> GSM38169 5 0.4232 0.54617 0.084 0.000 0.016 0.068 0.796 0.036
#> GSM38170 3 0.8081 0.00341 0.144 0.000 0.396 0.196 0.052 0.212
#> GSM38171 1 0.5139 0.69288 0.736 0.012 0.028 0.020 0.088 0.116
#> GSM38172 5 0.5486 0.37538 0.000 0.000 0.092 0.252 0.620 0.036
#> GSM38173 5 0.6832 0.34225 0.232 0.004 0.040 0.044 0.548 0.132
#> GSM38174 6 0.6331 0.10706 0.024 0.008 0.032 0.396 0.064 0.476
#> GSM38175 1 0.5213 0.61962 0.708 0.160 0.000 0.020 0.040 0.072
#> GSM38176 1 0.2296 0.73594 0.900 0.004 0.000 0.004 0.068 0.024
#> GSM38177 4 0.5160 0.45322 0.052 0.000 0.016 0.724 0.104 0.104
#> GSM38178 5 0.5306 0.51564 0.028 0.016 0.024 0.116 0.728 0.088
#> GSM38179 1 0.4905 0.70122 0.752 0.000 0.028 0.044 0.080 0.096
#> GSM38180 1 0.3696 0.72784 0.832 0.004 0.020 0.012 0.052 0.080
#> GSM38181 3 0.3560 0.69837 0.056 0.000 0.816 0.008 0.004 0.116
#> GSM38182 6 0.6222 0.53341 0.032 0.044 0.108 0.076 0.060 0.680
#> GSM38183 1 0.5148 0.66823 0.724 0.012 0.008 0.032 0.132 0.092
#> GSM38184 2 0.1799 0.78882 0.016 0.936 0.000 0.008 0.016 0.024
#> GSM38185 2 0.7134 0.07122 0.316 0.400 0.004 0.012 0.044 0.224
#> GSM38186 1 0.7867 0.38077 0.484 0.028 0.028 0.136 0.140 0.184
#> GSM38187 1 0.6040 0.50169 0.604 0.000 0.236 0.016 0.048 0.096
#> GSM38188 2 0.7021 -0.00125 0.024 0.440 0.036 0.044 0.068 0.388
#> GSM38189 5 0.7472 0.08506 0.044 0.012 0.056 0.120 0.416 0.352
#> GSM38190 5 0.5110 0.52955 0.072 0.100 0.004 0.028 0.744 0.052
#> GSM38191 5 0.7827 0.13007 0.032 0.356 0.044 0.036 0.364 0.168
#> GSM38192 1 0.3902 0.71919 0.824 0.048 0.012 0.008 0.028 0.080
#> GSM38193 2 0.2468 0.76464 0.000 0.880 0.000 0.008 0.016 0.096
#> GSM38194 5 0.7527 0.30320 0.008 0.240 0.008 0.140 0.444 0.160
#> GSM38195 6 0.7186 0.49932 0.044 0.088 0.160 0.080 0.040 0.588
#> GSM38196 4 0.6744 0.07649 0.028 0.000 0.144 0.508 0.040 0.280
#> GSM38197 2 0.8722 0.09525 0.164 0.388 0.184 0.024 0.084 0.156
#> GSM38198 4 0.1852 0.57322 0.004 0.000 0.040 0.928 0.024 0.004
#> GSM38199 3 0.6260 0.52113 0.036 0.000 0.640 0.112 0.128 0.084
#> GSM38200 2 0.1845 0.78637 0.000 0.916 0.000 0.004 0.008 0.072
#> GSM38201 4 0.3786 0.49973 0.000 0.000 0.220 0.748 0.024 0.008
#> GSM38202 4 0.7443 0.07540 0.012 0.000 0.352 0.360 0.124 0.152
#> GSM38203 3 0.1663 0.78148 0.000 0.000 0.912 0.088 0.000 0.000
#> GSM38204 3 0.1406 0.79272 0.008 0.000 0.952 0.020 0.004 0.016
#> GSM38205 3 0.2544 0.74681 0.004 0.000 0.852 0.140 0.000 0.004
#> GSM38206 3 0.0748 0.79348 0.000 0.000 0.976 0.016 0.004 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
#> MAD:skmeans 50 7.95e-04 2
#> MAD:skmeans 48 2.17e-05 3
#> MAD:skmeans 33 1.86e-04 4
#> MAD:skmeans 38 3.45e-06 5
#> MAD:skmeans 35 8.35e-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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.842 0.884 0.955 0.4923 0.502 0.502
#> 3 3 0.861 0.870 0.924 0.3261 0.837 0.676
#> 4 4 0.908 0.878 0.951 0.1356 0.891 0.688
#> 5 5 0.839 0.766 0.898 0.0782 0.902 0.638
#> 6 6 0.843 0.755 0.884 0.0422 0.956 0.781
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
#> GSM38155 2 0.0000 0.9608 0.000 1.000
#> GSM38156 2 0.0376 0.9590 0.004 0.996
#> GSM38157 2 0.0000 0.9608 0.000 1.000
#> GSM38158 2 0.0000 0.9608 0.000 1.000
#> GSM38159 2 0.0000 0.9608 0.000 1.000
#> GSM38160 2 0.3114 0.9123 0.056 0.944
#> GSM38161 2 0.0000 0.9608 0.000 1.000
#> GSM38162 1 0.0000 0.9334 1.000 0.000
#> GSM38163 2 0.0000 0.9608 0.000 1.000
#> GSM38164 1 0.0000 0.9334 1.000 0.000
#> GSM38165 1 0.9710 0.3547 0.600 0.400
#> GSM38166 2 0.1843 0.9400 0.028 0.972
#> GSM38167 1 0.0000 0.9334 1.000 0.000
#> GSM38168 1 0.0000 0.9334 1.000 0.000
#> GSM38169 1 0.8386 0.6335 0.732 0.268
#> GSM38170 1 0.1184 0.9238 0.984 0.016
#> GSM38171 2 0.0000 0.9608 0.000 1.000
#> GSM38172 1 0.0000 0.9334 1.000 0.000
#> GSM38173 2 0.9044 0.4962 0.320 0.680
#> GSM38174 1 0.0000 0.9334 1.000 0.000
#> GSM38175 2 0.0000 0.9608 0.000 1.000
#> GSM38176 2 0.0000 0.9608 0.000 1.000
#> GSM38177 1 0.0376 0.9309 0.996 0.004
#> GSM38178 1 0.5842 0.8094 0.860 0.140
#> GSM38179 2 0.0000 0.9608 0.000 1.000
#> GSM38180 2 0.0000 0.9608 0.000 1.000
#> GSM38181 2 0.0376 0.9590 0.004 0.996
#> GSM38182 2 0.0376 0.9590 0.004 0.996
#> GSM38183 2 0.0000 0.9608 0.000 1.000
#> GSM38184 2 0.0000 0.9608 0.000 1.000
#> GSM38185 2 0.0000 0.9608 0.000 1.000
#> GSM38186 1 0.9963 0.1579 0.536 0.464
#> GSM38187 2 0.0000 0.9608 0.000 1.000
#> GSM38188 2 0.9944 0.0919 0.456 0.544
#> GSM38189 1 0.0000 0.9334 1.000 0.000
#> GSM38190 2 0.0376 0.9590 0.004 0.996
#> GSM38191 2 0.0000 0.9608 0.000 1.000
#> GSM38192 2 0.0000 0.9608 0.000 1.000
#> GSM38193 2 0.6148 0.8003 0.152 0.848
#> GSM38194 1 0.0000 0.9334 1.000 0.000
#> GSM38195 2 0.0376 0.9590 0.004 0.996
#> GSM38196 1 0.0000 0.9334 1.000 0.000
#> GSM38197 2 0.0000 0.9608 0.000 1.000
#> GSM38198 1 0.0000 0.9334 1.000 0.000
#> GSM38199 1 0.0000 0.9334 1.000 0.000
#> GSM38200 2 0.0000 0.9608 0.000 1.000
#> GSM38201 1 0.0000 0.9334 1.000 0.000
#> GSM38202 1 0.0000 0.9334 1.000 0.000
#> GSM38203 1 0.0000 0.9334 1.000 0.000
#> GSM38204 2 0.0672 0.9566 0.008 0.992
#> GSM38205 1 0.0000 0.9334 1.000 0.000
#> GSM38206 1 0.1414 0.9211 0.980 0.020
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38156 2 0.0237 0.940 0.004 0.996 0.000
#> GSM38157 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38159 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38160 2 0.0592 0.932 0.012 0.988 0.000
#> GSM38161 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38162 1 0.0237 0.912 0.996 0.000 0.004
#> GSM38163 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38164 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38165 1 0.6305 0.278 0.516 0.000 0.484
#> GSM38166 3 0.1163 0.870 0.028 0.000 0.972
#> GSM38167 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38168 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38169 1 0.5737 0.641 0.732 0.012 0.256
#> GSM38170 1 0.0747 0.906 0.984 0.000 0.016
#> GSM38171 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38172 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38173 3 0.7637 0.466 0.320 0.064 0.616
#> GSM38174 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38175 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38176 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38177 1 0.0237 0.911 0.996 0.004 0.000
#> GSM38178 1 0.3686 0.810 0.860 0.000 0.140
#> GSM38179 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38180 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38181 3 0.0237 0.888 0.000 0.004 0.996
#> GSM38182 3 0.2945 0.952 0.004 0.088 0.908
#> GSM38183 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38184 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38185 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38186 1 0.7248 0.188 0.536 0.028 0.436
#> GSM38187 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38188 2 0.7012 0.502 0.308 0.652 0.040
#> GSM38189 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38190 2 0.4931 0.689 0.004 0.784 0.212
#> GSM38191 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38192 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38193 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38194 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38195 3 0.2945 0.952 0.004 0.088 0.908
#> GSM38196 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38197 3 0.2796 0.954 0.000 0.092 0.908
#> GSM38198 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38199 1 0.1753 0.895 0.952 0.000 0.048
#> GSM38200 2 0.0000 0.943 0.000 1.000 0.000
#> GSM38201 1 0.0237 0.912 0.996 0.000 0.004
#> GSM38202 1 0.0000 0.913 1.000 0.000 0.000
#> GSM38203 1 0.2796 0.872 0.908 0.000 0.092
#> GSM38204 3 0.0237 0.883 0.004 0.000 0.996
#> GSM38205 1 0.2796 0.872 0.908 0.000 0.092
#> GSM38206 1 0.3192 0.863 0.888 0.000 0.112
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38160 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38162 4 0.0469 0.920 0.000 0.000 0.012 0.988
#> GSM38163 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38164 4 0.0779 0.918 0.016 0.000 0.004 0.980
#> GSM38165 3 0.0188 0.922 0.004 0.000 0.996 0.000
#> GSM38166 3 0.0469 0.918 0.000 0.000 0.988 0.012
#> GSM38167 4 0.0000 0.925 0.000 0.000 0.000 1.000
#> GSM38168 4 0.0000 0.925 0.000 0.000 0.000 1.000
#> GSM38169 4 0.4456 0.621 0.280 0.000 0.004 0.716
#> GSM38170 4 0.1520 0.905 0.020 0.000 0.024 0.956
#> GSM38171 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0188 0.925 0.000 0.000 0.004 0.996
#> GSM38173 1 0.4741 0.439 0.668 0.000 0.004 0.328
#> GSM38174 4 0.0188 0.925 0.000 0.000 0.004 0.996
#> GSM38175 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38177 4 0.0469 0.921 0.012 0.000 0.000 0.988
#> GSM38178 4 0.3052 0.808 0.136 0.000 0.004 0.860
#> GSM38179 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38180 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38181 3 0.1867 0.869 0.072 0.000 0.928 0.000
#> GSM38182 1 0.1406 0.939 0.960 0.000 0.024 0.016
#> GSM38183 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38184 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38185 1 0.0469 0.956 0.988 0.012 0.000 0.000
#> GSM38186 4 0.4981 0.185 0.464 0.000 0.000 0.536
#> GSM38187 1 0.0188 0.962 0.996 0.000 0.004 0.000
#> GSM38188 2 0.6082 0.492 0.064 0.640 0.004 0.292
#> GSM38189 4 0.0188 0.925 0.000 0.000 0.004 0.996
#> GSM38190 2 0.4813 0.622 0.268 0.716 0.004 0.012
#> GSM38191 1 0.0188 0.962 0.996 0.004 0.000 0.000
#> GSM38192 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38193 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38194 4 0.0336 0.923 0.008 0.000 0.000 0.992
#> GSM38195 1 0.1174 0.944 0.968 0.000 0.020 0.012
#> GSM38196 4 0.0000 0.925 0.000 0.000 0.000 1.000
#> GSM38197 1 0.0000 0.964 1.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.925 0.000 0.000 0.000 1.000
#> GSM38199 3 0.4697 0.418 0.000 0.000 0.644 0.356
#> GSM38200 2 0.0000 0.932 0.000 1.000 0.000 0.000
#> GSM38201 4 0.0469 0.920 0.000 0.000 0.012 0.988
#> GSM38202 4 0.0000 0.925 0.000 0.000 0.000 1.000
#> GSM38203 3 0.0188 0.923 0.000 0.000 0.996 0.004
#> GSM38204 3 0.0000 0.922 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0469 0.921 0.000 0.000 0.988 0.012
#> GSM38206 3 0.0188 0.923 0.000 0.000 0.996 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38160 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38162 4 0.0000 0.8118 0.000 0.000 0.000 1.000 0.000
#> GSM38163 1 0.0290 0.9521 0.992 0.000 0.000 0.000 0.008
#> GSM38164 5 0.4299 0.2653 0.004 0.000 0.000 0.388 0.608
#> GSM38165 3 0.0000 0.8987 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0162 0.8966 0.000 0.000 0.996 0.000 0.004
#> GSM38167 4 0.0000 0.8118 0.000 0.000 0.000 1.000 0.000
#> GSM38168 4 0.0000 0.8118 0.000 0.000 0.000 1.000 0.000
#> GSM38169 5 0.4540 0.3471 0.020 0.000 0.000 0.340 0.640
#> GSM38170 4 0.3527 0.6020 0.000 0.000 0.016 0.792 0.192
#> GSM38171 1 0.0290 0.9521 0.992 0.000 0.000 0.000 0.008
#> GSM38172 4 0.4060 0.3210 0.000 0.000 0.000 0.640 0.360
#> GSM38173 5 0.5538 0.4846 0.144 0.000 0.000 0.212 0.644
#> GSM38174 5 0.3983 0.3746 0.000 0.000 0.000 0.340 0.660
#> GSM38175 1 0.0000 0.9531 1.000 0.000 0.000 0.000 0.000
#> GSM38176 1 0.0290 0.9521 0.992 0.000 0.000 0.000 0.008
#> GSM38177 4 0.0000 0.8118 0.000 0.000 0.000 1.000 0.000
#> GSM38178 5 0.1544 0.5975 0.000 0.000 0.000 0.068 0.932
#> GSM38179 1 0.0290 0.9521 0.992 0.000 0.000 0.000 0.008
#> GSM38180 1 0.1965 0.8643 0.904 0.000 0.000 0.000 0.096
#> GSM38181 3 0.1831 0.8240 0.076 0.000 0.920 0.000 0.004
#> GSM38182 5 0.3849 0.5145 0.232 0.000 0.016 0.000 0.752
#> GSM38183 1 0.0000 0.9531 1.000 0.000 0.000 0.000 0.000
#> GSM38184 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38185 1 0.0290 0.9481 0.992 0.008 0.000 0.000 0.000
#> GSM38186 4 0.5591 0.0922 0.432 0.000 0.000 0.496 0.072
#> GSM38187 1 0.0000 0.9531 1.000 0.000 0.000 0.000 0.000
#> GSM38188 5 0.3885 0.4707 0.000 0.268 0.000 0.008 0.724
#> GSM38189 5 0.2690 0.5857 0.000 0.000 0.000 0.156 0.844
#> GSM38190 5 0.6455 0.3208 0.204 0.312 0.000 0.000 0.484
#> GSM38191 1 0.0566 0.9446 0.984 0.000 0.000 0.004 0.012
#> GSM38192 1 0.0000 0.9531 1.000 0.000 0.000 0.000 0.000
#> GSM38193 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38194 4 0.1544 0.7643 0.000 0.000 0.000 0.932 0.068
#> GSM38195 1 0.4371 0.4472 0.644 0.000 0.012 0.000 0.344
#> GSM38196 4 0.0000 0.8118 0.000 0.000 0.000 1.000 0.000
#> GSM38197 1 0.0000 0.9531 1.000 0.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.8118 0.000 0.000 0.000 1.000 0.000
#> GSM38199 3 0.6399 0.0553 0.000 0.000 0.496 0.308 0.196
#> GSM38200 2 0.0000 1.0000 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.0162 0.8099 0.000 0.000 0.004 0.996 0.000
#> GSM38202 4 0.3913 0.3562 0.000 0.000 0.000 0.676 0.324
#> GSM38203 3 0.0000 0.8987 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 0.8987 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0290 0.8945 0.000 0.000 0.992 0.008 0.000
#> GSM38206 3 0.0000 0.8987 0.000 0.000 1.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
#> GSM38155 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38159 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38160 2 0.0508 0.9866 0.000 0.984 0.000 0.000 0.012 0.004
#> GSM38161 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38162 4 0.0000 0.8366 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38163 1 0.2941 0.7773 0.780 0.000 0.000 0.000 0.220 0.000
#> GSM38164 5 0.3946 0.5732 0.000 0.000 0.000 0.168 0.756 0.076
#> GSM38165 3 0.0146 0.9138 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM38166 3 0.0260 0.9122 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM38167 4 0.2562 0.7650 0.000 0.000 0.000 0.828 0.000 0.172
#> GSM38168 4 0.0000 0.8366 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38169 5 0.2199 0.6704 0.000 0.000 0.000 0.020 0.892 0.088
#> GSM38170 4 0.3886 0.6669 0.000 0.000 0.000 0.708 0.028 0.264
#> GSM38171 1 0.2941 0.7773 0.780 0.000 0.000 0.000 0.220 0.000
#> GSM38172 4 0.4945 0.2919 0.000 0.000 0.000 0.588 0.328 0.084
#> GSM38173 5 0.2039 0.6562 0.020 0.000 0.000 0.000 0.904 0.076
#> GSM38174 6 0.2019 0.6025 0.000 0.000 0.000 0.088 0.012 0.900
#> GSM38175 1 0.0000 0.8322 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38176 1 0.2941 0.7773 0.780 0.000 0.000 0.000 0.220 0.000
#> GSM38177 4 0.0000 0.8366 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38178 5 0.4101 0.3359 0.000 0.000 0.000 0.012 0.580 0.408
#> GSM38179 1 0.2941 0.7773 0.780 0.000 0.000 0.000 0.220 0.000
#> GSM38180 1 0.3647 0.6230 0.640 0.000 0.000 0.000 0.360 0.000
#> GSM38181 3 0.1913 0.8303 0.080 0.000 0.908 0.000 0.000 0.012
#> GSM38182 6 0.0260 0.6057 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM38183 1 0.0000 0.8322 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38184 2 0.0000 0.9976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38185 1 0.0000 0.8322 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38186 1 0.6074 0.1417 0.376 0.000 0.000 0.356 0.268 0.000
#> GSM38187 1 0.0000 0.8322 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38188 6 0.3758 0.4200 0.000 0.284 0.000 0.000 0.016 0.700
#> GSM38189 6 0.4756 -0.0152 0.000 0.000 0.000 0.056 0.380 0.564
#> GSM38190 5 0.3915 0.4920 0.092 0.128 0.000 0.000 0.776 0.004
#> GSM38191 1 0.0363 0.8251 0.988 0.000 0.000 0.000 0.012 0.000
#> GSM38192 1 0.0000 0.8322 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38193 2 0.0146 0.9957 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38194 4 0.2730 0.7171 0.000 0.000 0.000 0.808 0.192 0.000
#> GSM38195 6 0.2969 0.5150 0.224 0.000 0.000 0.000 0.000 0.776
#> GSM38196 4 0.3101 0.7081 0.000 0.000 0.000 0.756 0.000 0.244
#> GSM38197 1 0.0000 0.8322 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.8366 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38199 3 0.5532 0.3423 0.000 0.000 0.580 0.204 0.212 0.004
#> GSM38200 2 0.0146 0.9957 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38201 4 0.0146 0.8357 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM38202 4 0.2934 0.7419 0.000 0.000 0.000 0.844 0.044 0.112
#> GSM38203 3 0.0000 0.9146 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.9146 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0146 0.9129 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM38206 3 0.0000 0.9146 0.000 0.000 1.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 48 9.53e-03 2
#> MAD:pam 49 8.13e-06 3
#> MAD:pam 48 1.41e-07 4
#> MAD:pam 41 1.54e-06 5
#> MAD:pam 45 3.25e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.974 0.978 0.970 0.3183 0.683 0.683
#> 3 3 0.594 0.844 0.886 0.7484 0.815 0.730
#> 4 4 0.919 0.892 0.953 0.3208 0.749 0.504
#> 5 5 0.798 0.803 0.851 0.0731 0.943 0.788
#> 6 6 0.762 0.718 0.831 0.0537 0.907 0.602
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM38155 2 0.3274 0.996 0.060 0.940
#> GSM38156 2 0.3274 0.996 0.060 0.940
#> GSM38157 2 0.3274 0.996 0.060 0.940
#> GSM38158 2 0.3274 0.996 0.060 0.940
#> GSM38159 2 0.3431 0.993 0.064 0.936
#> GSM38160 2 0.3431 0.993 0.064 0.936
#> GSM38161 2 0.3274 0.996 0.060 0.940
#> GSM38162 1 0.1843 0.969 0.972 0.028
#> GSM38163 1 0.2423 0.967 0.960 0.040
#> GSM38164 1 0.0672 0.979 0.992 0.008
#> GSM38165 1 0.1184 0.978 0.984 0.016
#> GSM38166 1 0.1184 0.978 0.984 0.016
#> GSM38167 1 0.0376 0.980 0.996 0.004
#> GSM38168 1 0.1633 0.977 0.976 0.024
#> GSM38169 1 0.0672 0.979 0.992 0.008
#> GSM38170 1 0.0000 0.980 1.000 0.000
#> GSM38171 1 0.2423 0.966 0.960 0.040
#> GSM38172 1 0.1633 0.972 0.976 0.024
#> GSM38173 1 0.0376 0.980 0.996 0.004
#> GSM38174 1 0.0672 0.980 0.992 0.008
#> GSM38175 1 0.3114 0.962 0.944 0.056
#> GSM38176 1 0.2236 0.966 0.964 0.036
#> GSM38177 1 0.0672 0.979 0.992 0.008
#> GSM38178 1 0.0938 0.979 0.988 0.012
#> GSM38179 1 0.2236 0.966 0.964 0.036
#> GSM38180 1 0.2423 0.966 0.960 0.040
#> GSM38181 1 0.1184 0.978 0.984 0.016
#> GSM38182 1 0.1414 0.977 0.980 0.020
#> GSM38183 1 0.2236 0.966 0.964 0.036
#> GSM38184 2 0.4298 0.969 0.088 0.912
#> GSM38185 1 0.2603 0.964 0.956 0.044
#> GSM38186 1 0.0938 0.979 0.988 0.012
#> GSM38187 1 0.1414 0.977 0.980 0.020
#> GSM38188 1 0.2948 0.957 0.948 0.052
#> GSM38189 1 0.0376 0.980 0.996 0.004
#> GSM38190 1 0.0938 0.979 0.988 0.012
#> GSM38191 1 0.1843 0.972 0.972 0.028
#> GSM38192 1 0.3274 0.960 0.940 0.060
#> GSM38193 2 0.3274 0.996 0.060 0.940
#> GSM38194 1 0.1633 0.977 0.976 0.024
#> GSM38195 1 0.1414 0.977 0.980 0.020
#> GSM38196 1 0.0376 0.980 0.996 0.004
#> GSM38197 1 0.2603 0.964 0.956 0.044
#> GSM38198 1 0.1843 0.969 0.972 0.028
#> GSM38199 1 0.0000 0.980 1.000 0.000
#> GSM38200 2 0.3274 0.996 0.060 0.940
#> GSM38201 1 0.0672 0.979 0.992 0.008
#> GSM38202 1 0.0000 0.980 1.000 0.000
#> GSM38203 1 0.1184 0.978 0.984 0.016
#> GSM38204 1 0.1184 0.978 0.984 0.016
#> GSM38205 1 0.1184 0.978 0.984 0.016
#> GSM38206 1 0.1184 0.978 0.984 0.016
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38159 2 0.0237 0.993 0.004 0.996 0.000
#> GSM38160 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38162 1 0.3038 0.759 0.896 0.000 0.104
#> GSM38163 1 0.5138 0.799 0.748 0.000 0.252
#> GSM38164 1 0.0000 0.819 1.000 0.000 0.000
#> GSM38165 3 0.1860 0.974 0.052 0.000 0.948
#> GSM38166 3 0.2066 0.969 0.060 0.000 0.940
#> GSM38167 1 0.1163 0.827 0.972 0.000 0.028
#> GSM38168 1 0.0424 0.818 0.992 0.000 0.008
#> GSM38169 1 0.0747 0.820 0.984 0.000 0.016
#> GSM38170 1 0.4887 0.798 0.772 0.000 0.228
#> GSM38171 1 0.5138 0.799 0.748 0.000 0.252
#> GSM38172 1 0.4178 0.681 0.828 0.000 0.172
#> GSM38173 1 0.2261 0.828 0.932 0.000 0.068
#> GSM38174 1 0.2066 0.831 0.940 0.000 0.060
#> GSM38175 1 0.5763 0.795 0.740 0.016 0.244
#> GSM38176 1 0.5138 0.799 0.748 0.000 0.252
#> GSM38177 1 0.0237 0.819 0.996 0.000 0.004
#> GSM38178 1 0.0237 0.819 0.996 0.000 0.004
#> GSM38179 1 0.5138 0.799 0.748 0.000 0.252
#> GSM38180 1 0.5178 0.796 0.744 0.000 0.256
#> GSM38181 3 0.3038 0.887 0.104 0.000 0.896
#> GSM38182 1 0.5156 0.800 0.776 0.008 0.216
#> GSM38183 1 0.5016 0.804 0.760 0.000 0.240
#> GSM38184 2 0.0592 0.981 0.012 0.988 0.000
#> GSM38185 1 0.5899 0.792 0.736 0.020 0.244
#> GSM38186 1 0.4346 0.821 0.816 0.000 0.184
#> GSM38187 1 0.5254 0.790 0.736 0.000 0.264
#> GSM38188 1 0.6465 0.682 0.724 0.232 0.044
#> GSM38189 1 0.1964 0.830 0.944 0.000 0.056
#> GSM38190 1 0.1411 0.817 0.964 0.000 0.036
#> GSM38191 1 0.0424 0.818 0.992 0.000 0.008
#> GSM38192 1 0.5899 0.792 0.736 0.020 0.244
#> GSM38193 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38194 1 0.0661 0.818 0.988 0.004 0.008
#> GSM38195 1 0.5109 0.802 0.780 0.008 0.212
#> GSM38196 1 0.2878 0.815 0.904 0.000 0.096
#> GSM38197 1 0.5406 0.803 0.780 0.020 0.200
#> GSM38198 1 0.2066 0.794 0.940 0.000 0.060
#> GSM38199 1 0.5650 0.586 0.688 0.000 0.312
#> GSM38200 2 0.0000 0.997 0.000 1.000 0.000
#> GSM38201 1 0.5560 0.444 0.700 0.000 0.300
#> GSM38202 1 0.4796 0.616 0.780 0.000 0.220
#> GSM38203 3 0.1860 0.974 0.052 0.000 0.948
#> GSM38204 3 0.1860 0.974 0.052 0.000 0.948
#> GSM38205 3 0.2448 0.950 0.076 0.000 0.924
#> GSM38206 3 0.1860 0.974 0.052 0.000 0.948
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38160 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38162 4 0.0000 0.900 0.000 0.000 0.000 1.000
#> GSM38163 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38164 4 0.2011 0.873 0.080 0.000 0.000 0.920
#> GSM38165 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM38166 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM38167 4 0.1940 0.877 0.076 0.000 0.000 0.924
#> GSM38168 4 0.0000 0.900 0.000 0.000 0.000 1.000
#> GSM38169 4 0.1867 0.879 0.072 0.000 0.000 0.928
#> GSM38170 1 0.1474 0.932 0.948 0.000 0.052 0.000
#> GSM38171 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0000 0.900 0.000 0.000 0.000 1.000
#> GSM38173 1 0.3024 0.821 0.852 0.000 0.000 0.148
#> GSM38174 4 0.4431 0.595 0.304 0.000 0.000 0.696
#> GSM38175 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38176 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38177 4 0.0336 0.900 0.008 0.000 0.000 0.992
#> GSM38178 4 0.1716 0.883 0.064 0.000 0.000 0.936
#> GSM38179 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38180 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38181 3 0.1637 0.931 0.060 0.000 0.940 0.000
#> GSM38182 1 0.2149 0.902 0.912 0.000 0.088 0.000
#> GSM38183 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38184 2 0.0336 0.940 0.008 0.992 0.000 0.000
#> GSM38185 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38186 1 0.0188 0.960 0.996 0.000 0.000 0.004
#> GSM38187 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38188 2 0.4877 0.281 0.408 0.592 0.000 0.000
#> GSM38189 1 0.3764 0.720 0.784 0.000 0.000 0.216
#> GSM38190 4 0.4925 0.290 0.428 0.000 0.000 0.572
#> GSM38191 4 0.0707 0.899 0.020 0.000 0.000 0.980
#> GSM38192 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM38193 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38194 4 0.0000 0.900 0.000 0.000 0.000 1.000
#> GSM38195 1 0.1724 0.936 0.948 0.000 0.032 0.020
#> GSM38196 4 0.0927 0.896 0.016 0.000 0.008 0.976
#> GSM38197 1 0.0188 0.960 0.996 0.004 0.000 0.000
#> GSM38198 4 0.0000 0.900 0.000 0.000 0.000 1.000
#> GSM38199 4 0.4477 0.545 0.000 0.000 0.312 0.688
#> GSM38200 2 0.0000 0.947 0.000 1.000 0.000 0.000
#> GSM38201 4 0.0707 0.893 0.000 0.000 0.020 0.980
#> GSM38202 4 0.0000 0.900 0.000 0.000 0.000 1.000
#> GSM38203 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM38204 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0000 0.989 0.000 0.000 1.000 0.000
#> GSM38206 3 0.0000 0.989 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38160 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38162 4 0.0290 0.750 0.000 0.000 0.000 0.992 0.008
#> GSM38163 1 0.1041 0.849 0.964 0.000 0.000 0.004 0.032
#> GSM38164 4 0.5369 0.726 0.060 0.000 0.000 0.552 0.388
#> GSM38165 3 0.0000 0.980 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0000 0.980 0.000 0.000 1.000 0.000 0.000
#> GSM38167 4 0.4697 0.780 0.032 0.000 0.000 0.648 0.320
#> GSM38168 4 0.3336 0.793 0.000 0.000 0.000 0.772 0.228
#> GSM38169 4 0.5607 0.711 0.080 0.000 0.000 0.540 0.380
#> GSM38170 1 0.4444 0.555 0.764 0.000 0.052 0.012 0.172
#> GSM38171 1 0.0404 0.847 0.988 0.000 0.000 0.000 0.012
#> GSM38172 4 0.0963 0.746 0.000 0.000 0.000 0.964 0.036
#> GSM38173 1 0.5506 0.361 0.616 0.000 0.000 0.100 0.284
#> GSM38174 4 0.5865 0.580 0.108 0.000 0.000 0.532 0.360
#> GSM38175 1 0.0404 0.847 0.988 0.000 0.000 0.000 0.012
#> GSM38176 1 0.0794 0.852 0.972 0.000 0.000 0.000 0.028
#> GSM38177 4 0.4047 0.786 0.004 0.000 0.000 0.676 0.320
#> GSM38178 4 0.4608 0.776 0.024 0.000 0.000 0.640 0.336
#> GSM38179 1 0.0955 0.851 0.968 0.000 0.000 0.004 0.028
#> GSM38180 1 0.0404 0.847 0.988 0.000 0.000 0.000 0.012
#> GSM38181 3 0.2278 0.882 0.060 0.000 0.908 0.000 0.032
#> GSM38182 5 0.5582 0.694 0.284 0.000 0.084 0.008 0.624
#> GSM38183 1 0.1124 0.847 0.960 0.000 0.000 0.004 0.036
#> GSM38184 2 0.0404 0.985 0.012 0.988 0.000 0.000 0.000
#> GSM38185 5 0.4966 0.619 0.404 0.032 0.000 0.000 0.564
#> GSM38186 1 0.2953 0.722 0.844 0.000 0.000 0.012 0.144
#> GSM38187 1 0.2519 0.737 0.884 0.000 0.016 0.000 0.100
#> GSM38188 5 0.6064 0.557 0.152 0.264 0.000 0.004 0.580
#> GSM38189 5 0.6225 0.200 0.224 0.000 0.000 0.228 0.548
#> GSM38190 4 0.6612 0.532 0.216 0.000 0.000 0.412 0.372
#> GSM38191 4 0.4526 0.782 0.028 0.000 0.000 0.672 0.300
#> GSM38192 1 0.0404 0.847 0.988 0.000 0.000 0.000 0.012
#> GSM38193 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38194 4 0.3452 0.789 0.000 0.000 0.000 0.756 0.244
#> GSM38195 5 0.5391 0.704 0.304 0.000 0.044 0.020 0.632
#> GSM38196 4 0.3115 0.769 0.012 0.000 0.020 0.860 0.108
#> GSM38197 5 0.4580 0.681 0.356 0.008 0.000 0.008 0.628
#> GSM38198 4 0.0703 0.757 0.000 0.000 0.000 0.976 0.024
#> GSM38199 4 0.4804 0.609 0.016 0.000 0.220 0.720 0.044
#> GSM38200 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.0162 0.750 0.000 0.000 0.000 0.996 0.004
#> GSM38202 4 0.2444 0.758 0.012 0.000 0.016 0.904 0.068
#> GSM38203 3 0.0000 0.980 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 0.980 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0290 0.975 0.008 0.000 0.992 0.000 0.000
#> GSM38206 3 0.0000 0.980 0.000 0.000 1.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
#> GSM38155 2 0.0260 0.974 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM38156 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38157 2 0.0260 0.974 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM38158 2 0.0260 0.974 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM38159 2 0.2491 0.876 0.000 0.868 0.000 0.112 0.000 0.020
#> GSM38160 2 0.0520 0.970 0.000 0.984 0.000 0.008 0.000 0.008
#> GSM38161 2 0.0000 0.975 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38162 4 0.2823 0.701 0.000 0.000 0.000 0.796 0.204 0.000
#> GSM38163 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38164 5 0.1649 0.590 0.000 0.000 0.000 0.032 0.932 0.036
#> GSM38165 3 0.0000 0.968 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0458 0.961 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM38167 5 0.2170 0.590 0.016 0.000 0.000 0.060 0.908 0.016
#> GSM38168 4 0.4204 0.340 0.004 0.000 0.000 0.540 0.448 0.008
#> GSM38169 5 0.1863 0.591 0.000 0.000 0.000 0.044 0.920 0.036
#> GSM38170 1 0.5493 0.325 0.572 0.000 0.032 0.000 0.072 0.324
#> GSM38171 1 0.0632 0.812 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM38172 4 0.2964 0.694 0.000 0.000 0.000 0.792 0.204 0.004
#> GSM38173 5 0.3855 0.538 0.216 0.000 0.000 0.024 0.748 0.012
#> GSM38174 5 0.6228 0.350 0.048 0.000 0.000 0.144 0.532 0.276
#> GSM38175 1 0.2996 0.694 0.772 0.000 0.000 0.000 0.000 0.228
#> GSM38176 1 0.2212 0.753 0.880 0.000 0.000 0.000 0.112 0.008
#> GSM38177 5 0.1668 0.592 0.004 0.000 0.000 0.060 0.928 0.008
#> GSM38178 5 0.2794 0.543 0.004 0.000 0.000 0.144 0.840 0.012
#> GSM38179 1 0.0000 0.811 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38180 1 0.0632 0.810 0.976 0.000 0.000 0.000 0.000 0.024
#> GSM38181 3 0.2489 0.837 0.012 0.000 0.860 0.000 0.000 0.128
#> GSM38182 6 0.1713 0.872 0.028 0.000 0.044 0.000 0.000 0.928
#> GSM38183 1 0.2980 0.661 0.800 0.000 0.000 0.000 0.192 0.008
#> GSM38184 2 0.1773 0.935 0.016 0.932 0.000 0.016 0.000 0.036
#> GSM38185 6 0.3096 0.817 0.108 0.048 0.004 0.000 0.000 0.840
#> GSM38186 5 0.4344 0.267 0.412 0.000 0.000 0.008 0.568 0.012
#> GSM38187 1 0.2869 0.733 0.832 0.000 0.020 0.000 0.000 0.148
#> GSM38188 6 0.3056 0.746 0.000 0.184 0.000 0.008 0.004 0.804
#> GSM38189 5 0.6705 0.263 0.152 0.000 0.000 0.068 0.420 0.360
#> GSM38190 5 0.4833 0.511 0.044 0.000 0.000 0.244 0.676 0.036
#> GSM38191 5 0.5479 0.267 0.012 0.000 0.000 0.408 0.492 0.088
#> GSM38192 1 0.3309 0.647 0.720 0.000 0.000 0.000 0.000 0.280
#> GSM38193 2 0.0146 0.974 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38194 4 0.3758 0.222 0.000 0.000 0.000 0.668 0.324 0.008
#> GSM38195 6 0.1562 0.882 0.032 0.000 0.024 0.000 0.004 0.940
#> GSM38196 4 0.4777 0.551 0.016 0.000 0.004 0.592 0.364 0.024
#> GSM38197 6 0.1299 0.881 0.036 0.004 0.004 0.000 0.004 0.952
#> GSM38198 4 0.3076 0.691 0.000 0.000 0.000 0.760 0.240 0.000
#> GSM38199 4 0.7159 0.194 0.172 0.000 0.328 0.412 0.076 0.012
#> GSM38200 2 0.0405 0.972 0.000 0.988 0.000 0.008 0.000 0.004
#> GSM38201 4 0.2854 0.701 0.000 0.000 0.000 0.792 0.208 0.000
#> GSM38202 4 0.4412 0.668 0.040 0.000 0.024 0.716 0.220 0.000
#> GSM38203 3 0.0000 0.968 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.968 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0547 0.953 0.000 0.000 0.980 0.000 0.020 0.000
#> GSM38206 3 0.0000 0.968 0.000 0.000 1.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:mclust 52 3.80e-08 2
#> MAD:mclust 51 8.29e-11 3
#> MAD:mclust 50 8.92e-09 4
#> MAD:mclust 50 8.03e-08 5
#> MAD:mclust 44 2.05e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.804 0.899 0.957 0.4912 0.509 0.509
#> 3 3 0.594 0.779 0.873 0.3596 0.757 0.555
#> 4 4 0.708 0.750 0.867 0.1381 0.812 0.508
#> 5 5 0.603 0.546 0.730 0.0625 0.887 0.582
#> 6 6 0.685 0.634 0.780 0.0434 0.909 0.581
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
#> GSM38155 2 0.0000 0.9573 0.000 1.000
#> GSM38156 2 0.0000 0.9573 0.000 1.000
#> GSM38157 2 0.0000 0.9573 0.000 1.000
#> GSM38158 2 0.0000 0.9573 0.000 1.000
#> GSM38159 2 0.0000 0.9573 0.000 1.000
#> GSM38160 2 0.0000 0.9573 0.000 1.000
#> GSM38161 2 0.0000 0.9573 0.000 1.000
#> GSM38162 1 0.0000 0.9485 1.000 0.000
#> GSM38163 1 0.0000 0.9485 1.000 0.000
#> GSM38164 1 0.0938 0.9423 0.988 0.012
#> GSM38165 1 0.0000 0.9485 1.000 0.000
#> GSM38166 1 0.0000 0.9485 1.000 0.000
#> GSM38167 1 0.0000 0.9485 1.000 0.000
#> GSM38168 1 0.4690 0.8759 0.900 0.100
#> GSM38169 1 0.0000 0.9485 1.000 0.000
#> GSM38170 1 0.0000 0.9485 1.000 0.000
#> GSM38171 2 0.3431 0.9069 0.064 0.936
#> GSM38172 1 0.0000 0.9485 1.000 0.000
#> GSM38173 1 0.7602 0.7362 0.780 0.220
#> GSM38174 1 0.7602 0.7392 0.780 0.220
#> GSM38175 2 0.0000 0.9573 0.000 1.000
#> GSM38176 2 0.6438 0.7851 0.164 0.836
#> GSM38177 1 0.0000 0.9485 1.000 0.000
#> GSM38178 1 0.0672 0.9445 0.992 0.008
#> GSM38179 1 0.0000 0.9485 1.000 0.000
#> GSM38180 1 0.3431 0.9087 0.936 0.064
#> GSM38181 1 0.0000 0.9485 1.000 0.000
#> GSM38182 1 0.8016 0.6948 0.756 0.244
#> GSM38183 2 0.9970 0.0384 0.468 0.532
#> GSM38184 2 0.0000 0.9573 0.000 1.000
#> GSM38185 2 0.0000 0.9573 0.000 1.000
#> GSM38186 1 0.9661 0.3859 0.608 0.392
#> GSM38187 1 0.0000 0.9485 1.000 0.000
#> GSM38188 2 0.0000 0.9573 0.000 1.000
#> GSM38189 1 0.2778 0.9204 0.952 0.048
#> GSM38190 2 0.0000 0.9573 0.000 1.000
#> GSM38191 2 0.0376 0.9550 0.004 0.996
#> GSM38192 2 0.0000 0.9573 0.000 1.000
#> GSM38193 2 0.0000 0.9573 0.000 1.000
#> GSM38194 2 0.3584 0.9034 0.068 0.932
#> GSM38195 1 0.6438 0.8092 0.836 0.164
#> GSM38196 1 0.0000 0.9485 1.000 0.000
#> GSM38197 2 0.1184 0.9470 0.016 0.984
#> GSM38198 1 0.0000 0.9485 1.000 0.000
#> GSM38199 1 0.0000 0.9485 1.000 0.000
#> GSM38200 2 0.0000 0.9573 0.000 1.000
#> GSM38201 1 0.0000 0.9485 1.000 0.000
#> GSM38202 1 0.0000 0.9485 1.000 0.000
#> GSM38203 1 0.0000 0.9485 1.000 0.000
#> GSM38204 1 0.0000 0.9485 1.000 0.000
#> GSM38205 1 0.0000 0.9485 1.000 0.000
#> GSM38206 1 0.0000 0.9485 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.2878 0.879 0.096 0.904 0.000
#> GSM38156 2 0.0892 0.902 0.020 0.980 0.000
#> GSM38157 2 0.1643 0.900 0.044 0.956 0.000
#> GSM38158 2 0.1753 0.899 0.048 0.952 0.000
#> GSM38159 2 0.5785 0.579 0.332 0.668 0.000
#> GSM38160 2 0.1163 0.890 0.000 0.972 0.028
#> GSM38161 2 0.1163 0.903 0.028 0.972 0.000
#> GSM38162 3 0.1877 0.810 0.032 0.012 0.956
#> GSM38163 1 0.1860 0.897 0.948 0.000 0.052
#> GSM38164 1 0.3816 0.820 0.852 0.000 0.148
#> GSM38165 3 0.3482 0.791 0.128 0.000 0.872
#> GSM38166 3 0.3551 0.789 0.132 0.000 0.868
#> GSM38167 3 0.6244 0.323 0.440 0.000 0.560
#> GSM38168 3 0.4994 0.714 0.024 0.160 0.816
#> GSM38169 1 0.2625 0.888 0.916 0.000 0.084
#> GSM38170 3 0.6111 0.508 0.396 0.000 0.604
#> GSM38171 1 0.1529 0.894 0.960 0.040 0.000
#> GSM38172 3 0.1711 0.812 0.032 0.008 0.960
#> GSM38173 1 0.1878 0.906 0.952 0.004 0.044
#> GSM38174 3 0.5075 0.776 0.068 0.096 0.836
#> GSM38175 1 0.3116 0.843 0.892 0.108 0.000
#> GSM38176 1 0.0592 0.905 0.988 0.012 0.000
#> GSM38177 3 0.6280 0.225 0.460 0.000 0.540
#> GSM38178 3 0.6330 0.425 0.396 0.004 0.600
#> GSM38179 1 0.1964 0.895 0.944 0.000 0.056
#> GSM38180 1 0.1529 0.903 0.960 0.000 0.040
#> GSM38181 3 0.5621 0.632 0.308 0.000 0.692
#> GSM38182 3 0.8587 0.549 0.148 0.260 0.592
#> GSM38183 1 0.0424 0.906 0.992 0.008 0.000
#> GSM38184 2 0.3686 0.847 0.140 0.860 0.000
#> GSM38185 2 0.5650 0.618 0.312 0.688 0.000
#> GSM38186 1 0.1620 0.909 0.964 0.012 0.024
#> GSM38187 1 0.3816 0.803 0.852 0.000 0.148
#> GSM38188 2 0.1170 0.902 0.016 0.976 0.008
#> GSM38189 3 0.6680 0.270 0.484 0.008 0.508
#> GSM38190 1 0.4233 0.772 0.836 0.160 0.004
#> GSM38191 2 0.3682 0.831 0.008 0.876 0.116
#> GSM38192 1 0.2878 0.855 0.904 0.096 0.000
#> GSM38193 2 0.0424 0.898 0.000 0.992 0.008
#> GSM38194 2 0.5413 0.755 0.036 0.800 0.164
#> GSM38195 3 0.4370 0.794 0.056 0.076 0.868
#> GSM38196 3 0.1529 0.813 0.040 0.000 0.960
#> GSM38197 2 0.2383 0.901 0.044 0.940 0.016
#> GSM38198 3 0.2176 0.808 0.032 0.020 0.948
#> GSM38199 3 0.2448 0.811 0.076 0.000 0.924
#> GSM38200 2 0.0592 0.897 0.000 0.988 0.012
#> GSM38201 3 0.1751 0.805 0.012 0.028 0.960
#> GSM38202 3 0.0000 0.812 0.000 0.000 1.000
#> GSM38203 3 0.1031 0.814 0.024 0.000 0.976
#> GSM38204 3 0.2448 0.809 0.076 0.000 0.924
#> GSM38205 3 0.0424 0.812 0.008 0.000 0.992
#> GSM38206 3 0.1753 0.813 0.048 0.000 0.952
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.2142 0.852 0.056 0.928 0.000 0.016
#> GSM38156 2 0.0376 0.862 0.000 0.992 0.004 0.004
#> GSM38157 2 0.0779 0.862 0.016 0.980 0.004 0.000
#> GSM38158 2 0.1256 0.861 0.028 0.964 0.000 0.008
#> GSM38159 2 0.5436 0.505 0.356 0.620 0.000 0.024
#> GSM38160 2 0.0927 0.861 0.000 0.976 0.008 0.016
#> GSM38161 2 0.1256 0.860 0.008 0.964 0.000 0.028
#> GSM38162 4 0.1302 0.842 0.000 0.000 0.044 0.956
#> GSM38163 1 0.1151 0.877 0.968 0.000 0.024 0.008
#> GSM38164 4 0.4483 0.563 0.284 0.000 0.004 0.712
#> GSM38165 3 0.0672 0.846 0.008 0.000 0.984 0.008
#> GSM38166 3 0.1042 0.845 0.020 0.000 0.972 0.008
#> GSM38167 4 0.2300 0.828 0.064 0.000 0.016 0.920
#> GSM38168 4 0.2319 0.837 0.000 0.036 0.040 0.924
#> GSM38169 4 0.4134 0.610 0.260 0.000 0.000 0.740
#> GSM38170 3 0.5306 0.488 0.348 0.000 0.632 0.020
#> GSM38171 1 0.1109 0.870 0.968 0.004 0.028 0.000
#> GSM38172 4 0.1302 0.842 0.000 0.000 0.044 0.956
#> GSM38173 1 0.3171 0.828 0.876 0.004 0.016 0.104
#> GSM38174 4 0.6334 0.686 0.040 0.192 0.068 0.700
#> GSM38175 1 0.0524 0.875 0.988 0.008 0.000 0.004
#> GSM38176 1 0.0188 0.878 0.996 0.000 0.000 0.004
#> GSM38177 4 0.1762 0.830 0.048 0.004 0.004 0.944
#> GSM38178 4 0.1297 0.842 0.020 0.000 0.016 0.964
#> GSM38179 1 0.1406 0.877 0.960 0.000 0.016 0.024
#> GSM38180 1 0.1389 0.859 0.952 0.000 0.048 0.000
#> GSM38181 3 0.2466 0.811 0.096 0.004 0.900 0.000
#> GSM38182 3 0.4182 0.764 0.036 0.140 0.820 0.004
#> GSM38183 1 0.1474 0.868 0.948 0.000 0.000 0.052
#> GSM38184 2 0.3538 0.777 0.160 0.832 0.004 0.004
#> GSM38185 2 0.5510 0.146 0.480 0.504 0.016 0.000
#> GSM38186 1 0.1209 0.876 0.964 0.000 0.004 0.032
#> GSM38187 3 0.4761 0.451 0.372 0.000 0.628 0.000
#> GSM38188 2 0.0657 0.860 0.000 0.984 0.012 0.004
#> GSM38189 1 0.8231 0.291 0.468 0.024 0.252 0.256
#> GSM38190 1 0.5699 0.326 0.588 0.032 0.000 0.380
#> GSM38191 2 0.4511 0.592 0.000 0.724 0.008 0.268
#> GSM38192 1 0.1124 0.872 0.972 0.012 0.012 0.004
#> GSM38193 2 0.1209 0.858 0.004 0.964 0.000 0.032
#> GSM38194 4 0.2401 0.808 0.004 0.092 0.000 0.904
#> GSM38195 3 0.2821 0.821 0.020 0.076 0.900 0.004
#> GSM38196 4 0.4122 0.703 0.004 0.000 0.236 0.760
#> GSM38197 2 0.4827 0.652 0.020 0.748 0.224 0.008
#> GSM38198 4 0.0921 0.843 0.000 0.000 0.028 0.972
#> GSM38199 3 0.4792 0.465 0.008 0.000 0.680 0.312
#> GSM38200 2 0.0672 0.861 0.000 0.984 0.008 0.008
#> GSM38201 4 0.3257 0.786 0.000 0.004 0.152 0.844
#> GSM38202 4 0.5085 0.435 0.000 0.008 0.376 0.616
#> GSM38203 3 0.0921 0.837 0.000 0.000 0.972 0.028
#> GSM38204 3 0.0376 0.845 0.004 0.000 0.992 0.004
#> GSM38205 3 0.1940 0.806 0.000 0.000 0.924 0.076
#> GSM38206 3 0.0895 0.842 0.004 0.000 0.976 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.3922 0.6432 0.180 0.780 0.000 0.000 0.040
#> GSM38156 2 0.3010 0.6604 0.004 0.824 0.000 0.000 0.172
#> GSM38157 2 0.2970 0.6642 0.004 0.828 0.000 0.000 0.168
#> GSM38158 2 0.2922 0.6870 0.056 0.872 0.000 0.000 0.072
#> GSM38159 1 0.4876 0.0702 0.576 0.396 0.000 0.000 0.028
#> GSM38160 2 0.3170 0.6656 0.000 0.856 0.004 0.036 0.104
#> GSM38161 2 0.5395 0.5959 0.152 0.720 0.000 0.084 0.044
#> GSM38162 4 0.0932 0.7213 0.004 0.004 0.000 0.972 0.020
#> GSM38163 1 0.2938 0.7003 0.880 0.000 0.048 0.008 0.064
#> GSM38164 4 0.5507 0.5812 0.088 0.000 0.000 0.596 0.316
#> GSM38165 3 0.0451 0.7719 0.004 0.000 0.988 0.000 0.008
#> GSM38166 3 0.2881 0.7088 0.012 0.000 0.860 0.004 0.124
#> GSM38167 4 0.4653 0.6322 0.112 0.000 0.004 0.752 0.132
#> GSM38168 4 0.2770 0.7162 0.000 0.008 0.004 0.864 0.124
#> GSM38169 4 0.5323 0.6097 0.080 0.000 0.000 0.624 0.296
#> GSM38170 1 0.7718 -0.0603 0.364 0.004 0.232 0.048 0.352
#> GSM38171 1 0.3475 0.6769 0.804 0.000 0.012 0.004 0.180
#> GSM38172 4 0.4088 0.6593 0.004 0.000 0.008 0.712 0.276
#> GSM38173 5 0.6263 0.2913 0.248 0.012 0.000 0.160 0.580
#> GSM38174 5 0.5294 0.3728 0.016 0.068 0.000 0.236 0.680
#> GSM38175 1 0.1364 0.7184 0.952 0.012 0.000 0.000 0.036
#> GSM38176 1 0.0794 0.7198 0.972 0.000 0.000 0.000 0.028
#> GSM38177 4 0.2632 0.7099 0.072 0.000 0.000 0.888 0.040
#> GSM38178 4 0.4580 0.6015 0.008 0.000 0.008 0.628 0.356
#> GSM38179 1 0.3733 0.6806 0.808 0.000 0.008 0.028 0.156
#> GSM38180 1 0.4116 0.6458 0.756 0.000 0.028 0.004 0.212
#> GSM38181 3 0.3192 0.7044 0.040 0.000 0.848 0.000 0.112
#> GSM38182 5 0.7456 0.3610 0.080 0.208 0.124 0.024 0.564
#> GSM38183 1 0.2006 0.6982 0.932 0.024 0.000 0.024 0.020
#> GSM38184 2 0.5398 0.5458 0.240 0.648 0.000 0.000 0.112
#> GSM38185 5 0.6968 0.1168 0.260 0.332 0.008 0.000 0.400
#> GSM38186 1 0.4744 0.5371 0.692 0.000 0.000 0.056 0.252
#> GSM38187 3 0.4309 0.4526 0.308 0.000 0.676 0.000 0.016
#> GSM38188 2 0.4560 0.1557 0.000 0.508 0.000 0.008 0.484
#> GSM38189 5 0.4734 0.4626 0.104 0.016 0.008 0.096 0.776
#> GSM38190 5 0.7068 0.1292 0.208 0.040 0.000 0.236 0.516
#> GSM38191 2 0.6957 0.4173 0.060 0.596 0.016 0.216 0.112
#> GSM38192 1 0.2635 0.6641 0.888 0.088 0.008 0.000 0.016
#> GSM38193 2 0.5203 0.6017 0.052 0.740 0.000 0.136 0.072
#> GSM38194 4 0.6140 0.5220 0.028 0.176 0.004 0.648 0.144
#> GSM38195 5 0.7533 0.2881 0.032 0.204 0.280 0.016 0.468
#> GSM38196 4 0.4617 0.5955 0.004 0.016 0.064 0.772 0.144
#> GSM38197 3 0.5264 0.3462 0.052 0.340 0.604 0.000 0.004
#> GSM38198 4 0.0451 0.7164 0.000 0.004 0.000 0.988 0.008
#> GSM38199 3 0.6638 -0.1436 0.000 0.000 0.436 0.328 0.236
#> GSM38200 2 0.3143 0.6374 0.000 0.796 0.000 0.000 0.204
#> GSM38201 4 0.3664 0.6590 0.000 0.024 0.096 0.840 0.040
#> GSM38202 4 0.5834 0.4282 0.000 0.000 0.108 0.544 0.348
#> GSM38203 3 0.0671 0.7717 0.000 0.004 0.980 0.016 0.000
#> GSM38204 3 0.0162 0.7727 0.004 0.000 0.996 0.000 0.000
#> GSM38205 3 0.1697 0.7521 0.000 0.008 0.932 0.060 0.000
#> GSM38206 3 0.0404 0.7728 0.000 0.000 0.988 0.012 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.3870 0.67103 0.116 0.808 0.000 0.012 0.040 0.024
#> GSM38156 2 0.3776 0.65604 0.000 0.760 0.000 0.000 0.052 0.188
#> GSM38157 2 0.3483 0.62807 0.000 0.748 0.000 0.000 0.016 0.236
#> GSM38158 2 0.2714 0.69352 0.004 0.872 0.000 0.000 0.060 0.064
#> GSM38159 1 0.4532 -0.08634 0.508 0.464 0.000 0.024 0.000 0.004
#> GSM38160 2 0.3852 0.66597 0.000 0.788 0.000 0.116 0.008 0.088
#> GSM38161 2 0.4458 0.63986 0.088 0.756 0.000 0.132 0.012 0.012
#> GSM38162 4 0.2431 0.78961 0.000 0.008 0.000 0.860 0.132 0.000
#> GSM38163 1 0.4091 0.70888 0.800 0.020 0.032 0.004 0.120 0.024
#> GSM38164 5 0.2202 0.75764 0.012 0.008 0.004 0.072 0.904 0.000
#> GSM38165 3 0.0146 0.86161 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM38166 3 0.2544 0.78854 0.012 0.000 0.864 0.000 0.004 0.120
#> GSM38167 4 0.4497 0.62416 0.144 0.000 0.000 0.732 0.012 0.112
#> GSM38168 4 0.3159 0.77042 0.000 0.000 0.008 0.820 0.152 0.020
#> GSM38169 5 0.2890 0.75482 0.016 0.004 0.000 0.120 0.852 0.008
#> GSM38170 6 0.6454 0.21080 0.300 0.004 0.020 0.196 0.004 0.476
#> GSM38171 1 0.4278 0.68396 0.712 0.000 0.000 0.000 0.076 0.212
#> GSM38172 5 0.3271 0.68398 0.000 0.000 0.000 0.232 0.760 0.008
#> GSM38173 5 0.3873 0.61655 0.040 0.000 0.000 0.020 0.780 0.160
#> GSM38174 6 0.3733 0.55794 0.004 0.000 0.004 0.208 0.024 0.760
#> GSM38175 1 0.1534 0.76739 0.944 0.004 0.000 0.016 0.004 0.032
#> GSM38176 1 0.1268 0.76990 0.952 0.004 0.000 0.000 0.008 0.036
#> GSM38177 4 0.2545 0.77724 0.084 0.004 0.000 0.884 0.008 0.020
#> GSM38178 5 0.2744 0.74610 0.000 0.000 0.000 0.144 0.840 0.016
#> GSM38179 1 0.3191 0.74280 0.832 0.000 0.000 0.024 0.016 0.128
#> GSM38180 1 0.4130 0.67686 0.728 0.000 0.012 0.008 0.020 0.232
#> GSM38181 3 0.2312 0.80468 0.012 0.000 0.876 0.000 0.000 0.112
#> GSM38182 6 0.2965 0.64726 0.016 0.060 0.008 0.036 0.004 0.876
#> GSM38183 1 0.1457 0.76173 0.948 0.004 0.000 0.028 0.016 0.004
#> GSM38184 2 0.6121 0.56854 0.144 0.620 0.000 0.004 0.124 0.108
#> GSM38185 6 0.4446 0.56406 0.120 0.152 0.000 0.000 0.004 0.724
#> GSM38186 1 0.5298 0.54095 0.624 0.000 0.000 0.080 0.028 0.268
#> GSM38187 3 0.3859 0.55741 0.292 0.008 0.692 0.000 0.000 0.008
#> GSM38188 6 0.3665 0.50498 0.000 0.212 0.000 0.012 0.016 0.760
#> GSM38189 6 0.4085 0.51738 0.004 0.020 0.000 0.016 0.228 0.732
#> GSM38190 5 0.2577 0.69379 0.016 0.040 0.000 0.000 0.888 0.056
#> GSM38191 2 0.5988 0.00847 0.016 0.472 0.008 0.076 0.416 0.012
#> GSM38192 1 0.2257 0.73564 0.900 0.076 0.004 0.000 0.008 0.012
#> GSM38193 2 0.4661 0.60070 0.044 0.696 0.000 0.236 0.008 0.016
#> GSM38194 5 0.5870 0.43959 0.000 0.164 0.000 0.280 0.540 0.016
#> GSM38195 6 0.4788 0.61548 0.016 0.096 0.092 0.028 0.008 0.760
#> GSM38196 4 0.3061 0.75396 0.012 0.004 0.008 0.852 0.012 0.112
#> GSM38197 3 0.4559 0.38809 0.020 0.344 0.620 0.004 0.000 0.012
#> GSM38198 4 0.1812 0.81702 0.000 0.008 0.000 0.912 0.080 0.000
#> GSM38199 5 0.5508 0.46725 0.000 0.000 0.340 0.088 0.552 0.020
#> GSM38200 2 0.3693 0.58189 0.000 0.708 0.000 0.008 0.004 0.280
#> GSM38201 4 0.3628 0.78840 0.000 0.020 0.060 0.828 0.084 0.008
#> GSM38202 6 0.6554 0.02461 0.000 0.000 0.024 0.328 0.264 0.384
#> GSM38203 3 0.0000 0.86181 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0146 0.86120 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM38205 3 0.0865 0.84825 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM38206 3 0.0000 0.86181 0.000 0.000 1.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:NMF 50 5.92e-04 2
#> MAD:NMF 48 2.17e-05 3
#> MAD:NMF 45 1.48e-05 4
#> MAD:NMF 37 3.29e-06 5
#> MAD:NMF 45 5.27e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 1.000 0.3174 0.683 0.683
#> 3 3 1.000 0.972 0.985 0.0579 0.984 0.977
#> 4 4 0.582 0.828 0.897 0.8317 0.686 0.530
#> 5 5 0.561 0.732 0.821 0.0690 1.000 1.000
#> 6 6 0.567 0.700 0.820 0.0463 0.955 0.872
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
#> GSM38155 2 0 1 0 1
#> GSM38156 2 0 1 0 1
#> GSM38157 2 0 1 0 1
#> GSM38158 2 0 1 0 1
#> GSM38159 2 0 1 0 1
#> GSM38160 2 0 1 0 1
#> GSM38161 2 0 1 0 1
#> GSM38162 1 0 1 1 0
#> GSM38163 1 0 1 1 0
#> GSM38164 1 0 1 1 0
#> GSM38165 1 0 1 1 0
#> GSM38166 1 0 1 1 0
#> GSM38167 1 0 1 1 0
#> GSM38168 1 0 1 1 0
#> GSM38169 1 0 1 1 0
#> GSM38170 1 0 1 1 0
#> GSM38171 1 0 1 1 0
#> GSM38172 1 0 1 1 0
#> GSM38173 1 0 1 1 0
#> GSM38174 1 0 1 1 0
#> GSM38175 1 0 1 1 0
#> GSM38176 1 0 1 1 0
#> GSM38177 1 0 1 1 0
#> GSM38178 1 0 1 1 0
#> GSM38179 1 0 1 1 0
#> GSM38180 1 0 1 1 0
#> GSM38181 1 0 1 1 0
#> GSM38182 1 0 1 1 0
#> GSM38183 1 0 1 1 0
#> GSM38184 2 0 1 0 1
#> GSM38185 1 0 1 1 0
#> GSM38186 1 0 1 1 0
#> GSM38187 1 0 1 1 0
#> GSM38188 1 0 1 1 0
#> GSM38189 1 0 1 1 0
#> GSM38190 1 0 1 1 0
#> GSM38191 1 0 1 1 0
#> GSM38192 1 0 1 1 0
#> GSM38193 2 0 1 0 1
#> GSM38194 1 0 1 1 0
#> GSM38195 1 0 1 1 0
#> GSM38196 1 0 1 1 0
#> GSM38197 1 0 1 1 0
#> GSM38198 1 0 1 1 0
#> GSM38199 1 0 1 1 0
#> GSM38200 2 0 1 0 1
#> GSM38201 1 0 1 1 0
#> GSM38202 1 0 1 1 0
#> GSM38203 1 0 1 1 0
#> GSM38204 1 0 1 1 0
#> GSM38205 1 0 1 1 0
#> GSM38206 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.2066 0.950 0.000 0.940 0.060
#> GSM38156 2 0.0000 0.963 0.000 1.000 0.000
#> GSM38157 2 0.2066 0.950 0.000 0.940 0.060
#> GSM38158 3 0.0747 0.816 0.000 0.016 0.984
#> GSM38159 2 0.2066 0.950 0.000 0.940 0.060
#> GSM38160 2 0.0000 0.963 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.963 0.000 1.000 0.000
#> GSM38162 1 0.0237 0.995 0.996 0.000 0.004
#> GSM38163 1 0.0237 0.995 0.996 0.000 0.004
#> GSM38164 1 0.0237 0.995 0.996 0.000 0.004
#> GSM38165 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38166 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38167 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38168 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38169 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38170 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38171 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38172 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38173 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38174 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38175 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38176 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38177 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38178 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38179 1 0.0237 0.995 0.996 0.000 0.004
#> GSM38180 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38181 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38182 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38183 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38184 3 0.0747 0.816 0.000 0.016 0.984
#> GSM38185 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38186 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38187 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38188 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38189 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38190 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38191 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38192 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38193 2 0.0000 0.963 0.000 1.000 0.000
#> GSM38194 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38195 1 0.0000 0.996 1.000 0.000 0.000
#> GSM38196 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38197 1 0.0237 0.994 0.996 0.000 0.004
#> GSM38198 1 0.0237 0.995 0.996 0.000 0.004
#> GSM38199 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38200 3 0.6026 0.470 0.000 0.376 0.624
#> GSM38201 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38202 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38203 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38204 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38205 1 0.0592 0.992 0.988 0.000 0.012
#> GSM38206 1 0.0592 0.992 0.988 0.000 0.012
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.1637 0.950 0.000 0.940 0.000 0.060
#> GSM38156 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM38157 2 0.1637 0.950 0.000 0.940 0.000 0.060
#> GSM38158 4 0.0000 0.815 0.000 0.000 0.000 1.000
#> GSM38159 2 0.1637 0.950 0.000 0.940 0.000 0.060
#> GSM38160 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM38162 3 0.3688 0.784 0.208 0.000 0.792 0.000
#> GSM38163 1 0.4643 0.574 0.656 0.000 0.344 0.000
#> GSM38164 3 0.4888 0.357 0.412 0.000 0.588 0.000
#> GSM38165 3 0.0188 0.802 0.004 0.000 0.996 0.000
#> GSM38166 3 0.0188 0.802 0.004 0.000 0.996 0.000
#> GSM38167 1 0.3024 0.878 0.852 0.000 0.148 0.000
#> GSM38168 3 0.4898 0.348 0.416 0.000 0.584 0.000
#> GSM38169 1 0.2530 0.898 0.888 0.000 0.112 0.000
#> GSM38170 1 0.4072 0.752 0.748 0.000 0.252 0.000
#> GSM38171 1 0.2408 0.901 0.896 0.000 0.104 0.000
#> GSM38172 3 0.3311 0.819 0.172 0.000 0.828 0.000
#> GSM38173 1 0.2469 0.900 0.892 0.000 0.108 0.000
#> GSM38174 1 0.2530 0.899 0.888 0.000 0.112 0.000
#> GSM38175 1 0.0188 0.867 0.996 0.000 0.004 0.000
#> GSM38176 1 0.3649 0.819 0.796 0.000 0.204 0.000
#> GSM38177 1 0.3024 0.878 0.852 0.000 0.148 0.000
#> GSM38178 1 0.2149 0.901 0.912 0.000 0.088 0.000
#> GSM38179 1 0.4624 0.583 0.660 0.000 0.340 0.000
#> GSM38180 1 0.2469 0.900 0.892 0.000 0.108 0.000
#> GSM38181 3 0.0188 0.802 0.004 0.000 0.996 0.000
#> GSM38182 1 0.2011 0.899 0.920 0.000 0.080 0.000
#> GSM38183 1 0.2973 0.881 0.856 0.000 0.144 0.000
#> GSM38184 4 0.0000 0.815 0.000 0.000 0.000 1.000
#> GSM38185 1 0.0188 0.867 0.996 0.000 0.004 0.000
#> GSM38186 1 0.2921 0.884 0.860 0.000 0.140 0.000
#> GSM38187 1 0.0336 0.869 0.992 0.000 0.008 0.000
#> GSM38188 1 0.0188 0.871 0.996 0.000 0.004 0.000
#> GSM38189 1 0.2149 0.901 0.912 0.000 0.088 0.000
#> GSM38190 1 0.2216 0.902 0.908 0.000 0.092 0.000
#> GSM38191 1 0.0188 0.865 0.996 0.000 0.004 0.000
#> GSM38192 1 0.0188 0.867 0.996 0.000 0.004 0.000
#> GSM38193 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM38194 1 0.0188 0.865 0.996 0.000 0.004 0.000
#> GSM38195 1 0.2281 0.900 0.904 0.000 0.096 0.000
#> GSM38196 3 0.2973 0.831 0.144 0.000 0.856 0.000
#> GSM38197 1 0.0336 0.869 0.992 0.000 0.008 0.000
#> GSM38198 3 0.3444 0.811 0.184 0.000 0.816 0.000
#> GSM38199 3 0.2973 0.831 0.144 0.000 0.856 0.000
#> GSM38200 4 0.4746 0.464 0.000 0.368 0.000 0.632
#> GSM38201 3 0.3074 0.830 0.152 0.000 0.848 0.000
#> GSM38202 3 0.3074 0.830 0.152 0.000 0.848 0.000
#> GSM38203 3 0.0188 0.802 0.004 0.000 0.996 0.000
#> GSM38204 3 0.0188 0.802 0.004 0.000 0.996 0.000
#> GSM38205 3 0.0188 0.802 0.004 0.000 0.996 0.000
#> GSM38206 3 0.0188 0.802 0.004 0.000 0.996 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.3662 0.822 0.000 0.744 0.004 0.000 NA
#> GSM38156 2 0.1121 0.855 0.000 0.956 0.000 0.000 NA
#> GSM38157 2 0.3662 0.822 0.000 0.744 0.004 0.000 NA
#> GSM38158 4 0.0000 0.818 0.000 0.000 0.000 1.000 NA
#> GSM38159 2 0.3662 0.822 0.000 0.744 0.004 0.000 NA
#> GSM38160 2 0.0162 0.853 0.000 0.996 0.000 0.000 NA
#> GSM38161 2 0.0000 0.855 0.000 1.000 0.000 0.000 NA
#> GSM38162 3 0.3177 0.780 0.208 0.000 0.792 0.000 NA
#> GSM38163 1 0.4151 0.534 0.652 0.000 0.344 0.000 NA
#> GSM38164 3 0.4210 0.377 0.412 0.000 0.588 0.000 NA
#> GSM38165 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
#> GSM38166 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
#> GSM38167 1 0.2763 0.783 0.848 0.000 0.148 0.000 NA
#> GSM38168 3 0.4359 0.370 0.412 0.000 0.584 0.000 NA
#> GSM38169 1 0.2338 0.801 0.884 0.000 0.112 0.000 NA
#> GSM38170 1 0.3508 0.678 0.748 0.000 0.252 0.000 NA
#> GSM38171 1 0.2074 0.803 0.896 0.000 0.104 0.000 NA
#> GSM38172 3 0.2852 0.817 0.172 0.000 0.828 0.000 NA
#> GSM38173 1 0.2127 0.802 0.892 0.000 0.108 0.000 NA
#> GSM38174 1 0.2179 0.802 0.888 0.000 0.112 0.000 NA
#> GSM38175 1 0.3790 0.580 0.724 0.000 0.004 0.000 NA
#> GSM38176 1 0.3300 0.731 0.792 0.000 0.204 0.000 NA
#> GSM38177 1 0.2763 0.783 0.848 0.000 0.148 0.000 NA
#> GSM38178 1 0.2011 0.803 0.908 0.000 0.088 0.000 NA
#> GSM38179 1 0.4135 0.543 0.656 0.000 0.340 0.000 NA
#> GSM38180 1 0.2127 0.802 0.892 0.000 0.108 0.000 NA
#> GSM38181 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
#> GSM38182 1 0.1892 0.799 0.916 0.000 0.080 0.000 NA
#> GSM38183 1 0.2719 0.786 0.852 0.000 0.144 0.000 NA
#> GSM38184 4 0.0000 0.818 0.000 0.000 0.000 1.000 NA
#> GSM38185 1 0.3838 0.572 0.716 0.000 0.004 0.000 NA
#> GSM38186 1 0.2674 0.790 0.856 0.000 0.140 0.000 NA
#> GSM38187 1 0.3957 0.575 0.712 0.000 0.008 0.000 NA
#> GSM38188 1 0.1571 0.741 0.936 0.000 0.004 0.000 NA
#> GSM38189 1 0.2011 0.802 0.908 0.000 0.088 0.000 NA
#> GSM38190 1 0.2068 0.803 0.904 0.000 0.092 0.000 NA
#> GSM38191 1 0.4305 0.309 0.512 0.000 0.000 0.000 NA
#> GSM38192 1 0.3790 0.580 0.724 0.000 0.004 0.000 NA
#> GSM38193 2 0.0000 0.855 0.000 1.000 0.000 0.000 NA
#> GSM38194 1 0.4305 0.309 0.512 0.000 0.000 0.000 NA
#> GSM38195 1 0.2124 0.801 0.900 0.000 0.096 0.000 NA
#> GSM38196 3 0.2561 0.834 0.144 0.000 0.856 0.000 NA
#> GSM38197 1 0.3957 0.575 0.712 0.000 0.008 0.000 NA
#> GSM38198 3 0.2966 0.806 0.184 0.000 0.816 0.000 NA
#> GSM38199 3 0.2561 0.834 0.144 0.000 0.856 0.000 NA
#> GSM38200 4 0.4225 0.499 0.000 0.364 0.000 0.632 NA
#> GSM38201 3 0.2648 0.831 0.152 0.000 0.848 0.000 NA
#> GSM38202 3 0.2648 0.831 0.152 0.000 0.848 0.000 NA
#> GSM38203 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
#> GSM38204 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
#> GSM38205 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
#> GSM38206 3 0.0162 0.813 0.004 0.000 0.996 0.000 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 6 0.2527 1.000 0.000 0.168 0.000 0.000 0.000 0.832
#> GSM38156 2 0.3854 -0.156 0.000 0.536 0.000 0.000 0.000 0.464
#> GSM38157 6 0.2527 1.000 0.000 0.168 0.000 0.000 0.000 0.832
#> GSM38158 4 0.0000 0.790 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38159 6 0.2527 1.000 0.000 0.168 0.000 0.000 0.000 0.832
#> GSM38160 2 0.0000 0.798 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38161 2 0.0146 0.800 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38162 3 0.3244 0.761 0.268 0.000 0.732 0.000 0.000 0.000
#> GSM38163 1 0.3288 0.519 0.724 0.000 0.276 0.000 0.000 0.000
#> GSM38164 3 0.3867 0.370 0.488 0.000 0.512 0.000 0.000 0.000
#> GSM38165 3 0.1267 0.796 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38166 3 0.1267 0.796 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38167 1 0.1387 0.751 0.932 0.000 0.068 0.000 0.000 0.000
#> GSM38168 3 0.3868 0.369 0.492 0.000 0.508 0.000 0.000 0.000
#> GSM38169 1 0.0790 0.766 0.968 0.000 0.032 0.000 0.000 0.000
#> GSM38170 1 0.2562 0.653 0.828 0.000 0.172 0.000 0.000 0.000
#> GSM38171 1 0.0777 0.768 0.972 0.000 0.024 0.000 0.004 0.000
#> GSM38172 3 0.3023 0.795 0.232 0.000 0.768 0.000 0.000 0.000
#> GSM38173 1 0.0858 0.768 0.968 0.000 0.028 0.000 0.004 0.000
#> GSM38174 1 0.1124 0.767 0.956 0.000 0.036 0.000 0.008 0.000
#> GSM38175 1 0.3854 0.318 0.536 0.000 0.000 0.000 0.464 0.000
#> GSM38176 1 0.2092 0.700 0.876 0.000 0.124 0.000 0.000 0.000
#> GSM38177 1 0.1387 0.751 0.932 0.000 0.068 0.000 0.000 0.000
#> GSM38178 1 0.0260 0.763 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM38179 1 0.3266 0.528 0.728 0.000 0.272 0.000 0.000 0.000
#> GSM38180 1 0.0858 0.768 0.968 0.000 0.028 0.000 0.004 0.000
#> GSM38181 3 0.1267 0.796 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38182 1 0.0508 0.757 0.984 0.000 0.004 0.000 0.012 0.000
#> GSM38183 1 0.1327 0.754 0.936 0.000 0.064 0.000 0.000 0.000
#> GSM38184 4 0.0000 0.790 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38185 1 0.3860 0.308 0.528 0.000 0.000 0.000 0.472 0.000
#> GSM38186 1 0.1267 0.757 0.940 0.000 0.060 0.000 0.000 0.000
#> GSM38187 1 0.3857 0.312 0.532 0.000 0.000 0.000 0.468 0.000
#> GSM38188 1 0.2340 0.643 0.852 0.000 0.000 0.000 0.148 0.000
#> GSM38189 1 0.0725 0.762 0.976 0.000 0.012 0.000 0.012 0.000
#> GSM38190 1 0.0363 0.764 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM38191 5 0.6382 1.000 0.236 0.000 0.060 0.000 0.536 0.168
#> GSM38192 1 0.3854 0.318 0.536 0.000 0.000 0.000 0.464 0.000
#> GSM38193 2 0.0146 0.800 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM38194 5 0.6382 1.000 0.236 0.000 0.060 0.000 0.536 0.168
#> GSM38195 1 0.0909 0.760 0.968 0.000 0.020 0.000 0.012 0.000
#> GSM38196 3 0.2823 0.811 0.204 0.000 0.796 0.000 0.000 0.000
#> GSM38197 1 0.3857 0.312 0.532 0.000 0.000 0.000 0.468 0.000
#> GSM38198 3 0.3101 0.786 0.244 0.000 0.756 0.000 0.000 0.000
#> GSM38199 3 0.2823 0.811 0.204 0.000 0.796 0.000 0.000 0.000
#> GSM38200 4 0.3672 0.399 0.000 0.368 0.000 0.632 0.000 0.000
#> GSM38201 3 0.2883 0.809 0.212 0.000 0.788 0.000 0.000 0.000
#> GSM38202 3 0.2883 0.809 0.212 0.000 0.788 0.000 0.000 0.000
#> GSM38203 3 0.1267 0.796 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38204 3 0.1267 0.796 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38205 3 0.1267 0.796 0.060 0.000 0.940 0.000 0.000 0.000
#> GSM38206 3 0.1267 0.796 0.060 0.000 0.940 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:hclust 52 3.80e-08 2
#> ATC:hclust 51 5.05e-08 3
#> ATC:hclust 49 7.42e-10 4
#> ATC:hclust 47 2.44e-09 5
#> ATC:hclust 43 1.07e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 1.000 0.3174 0.683 0.683
#> 3 3 0.598 0.843 0.892 0.9109 0.679 0.531
#> 4 4 0.681 0.832 0.886 0.1503 0.792 0.517
#> 5 5 0.667 0.664 0.794 0.0983 0.854 0.548
#> 6 6 0.709 0.598 0.729 0.0556 0.943 0.760
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
#> GSM38155 2 0 1 0 1
#> GSM38156 2 0 1 0 1
#> GSM38157 2 0 1 0 1
#> GSM38158 2 0 1 0 1
#> GSM38159 2 0 1 0 1
#> GSM38160 2 0 1 0 1
#> GSM38161 2 0 1 0 1
#> GSM38162 1 0 1 1 0
#> GSM38163 1 0 1 1 0
#> GSM38164 1 0 1 1 0
#> GSM38165 1 0 1 1 0
#> GSM38166 1 0 1 1 0
#> GSM38167 1 0 1 1 0
#> GSM38168 1 0 1 1 0
#> GSM38169 1 0 1 1 0
#> GSM38170 1 0 1 1 0
#> GSM38171 1 0 1 1 0
#> GSM38172 1 0 1 1 0
#> GSM38173 1 0 1 1 0
#> GSM38174 1 0 1 1 0
#> GSM38175 1 0 1 1 0
#> GSM38176 1 0 1 1 0
#> GSM38177 1 0 1 1 0
#> GSM38178 1 0 1 1 0
#> GSM38179 1 0 1 1 0
#> GSM38180 1 0 1 1 0
#> GSM38181 1 0 1 1 0
#> GSM38182 1 0 1 1 0
#> GSM38183 1 0 1 1 0
#> GSM38184 2 0 1 0 1
#> GSM38185 1 0 1 1 0
#> GSM38186 1 0 1 1 0
#> GSM38187 1 0 1 1 0
#> GSM38188 1 0 1 1 0
#> GSM38189 1 0 1 1 0
#> GSM38190 1 0 1 1 0
#> GSM38191 1 0 1 1 0
#> GSM38192 1 0 1 1 0
#> GSM38193 2 0 1 0 1
#> GSM38194 1 0 1 1 0
#> GSM38195 1 0 1 1 0
#> GSM38196 1 0 1 1 0
#> GSM38197 1 0 1 1 0
#> GSM38198 1 0 1 1 0
#> GSM38199 1 0 1 1 0
#> GSM38200 2 0 1 0 1
#> GSM38201 1 0 1 1 0
#> GSM38202 1 0 1 1 0
#> GSM38203 1 0 1 1 0
#> GSM38204 1 0 1 1 0
#> GSM38205 1 0 1 1 0
#> GSM38206 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.9833 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.9833 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.9833 0.000 1.000 0.000
#> GSM38158 2 0.0892 0.9814 0.000 0.980 0.020
#> GSM38159 2 0.1964 0.9553 0.056 0.944 0.000
#> GSM38160 2 0.0592 0.9826 0.000 0.988 0.012
#> GSM38161 2 0.0000 0.9833 0.000 1.000 0.000
#> GSM38162 3 0.5016 0.7129 0.240 0.000 0.760
#> GSM38163 3 0.3752 0.8132 0.144 0.000 0.856
#> GSM38164 3 0.6204 0.2416 0.424 0.000 0.576
#> GSM38165 3 0.0892 0.8859 0.020 0.000 0.980
#> GSM38166 3 0.0892 0.8859 0.020 0.000 0.980
#> GSM38167 1 0.5560 0.6536 0.700 0.000 0.300
#> GSM38168 1 0.6045 0.4695 0.620 0.000 0.380
#> GSM38169 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38170 3 0.5621 0.5848 0.308 0.000 0.692
#> GSM38171 1 0.3686 0.8908 0.860 0.000 0.140
#> GSM38172 3 0.1289 0.8850 0.032 0.000 0.968
#> GSM38173 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38174 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38175 1 0.0592 0.8362 0.988 0.000 0.012
#> GSM38176 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38177 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38178 1 0.3116 0.8919 0.892 0.000 0.108
#> GSM38179 1 0.6307 0.0873 0.512 0.000 0.488
#> GSM38180 1 0.3686 0.8908 0.860 0.000 0.140
#> GSM38181 3 0.0892 0.8859 0.020 0.000 0.980
#> GSM38182 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38183 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38184 2 0.0892 0.9814 0.000 0.980 0.020
#> GSM38185 1 0.1482 0.8166 0.968 0.020 0.012
#> GSM38186 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38187 1 0.0592 0.8362 0.988 0.000 0.012
#> GSM38188 1 0.2878 0.8877 0.904 0.000 0.096
#> GSM38189 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38190 1 0.3116 0.8919 0.892 0.000 0.108
#> GSM38191 1 0.0000 0.8394 1.000 0.000 0.000
#> GSM38192 1 0.0592 0.8362 0.988 0.000 0.012
#> GSM38193 2 0.2356 0.9445 0.072 0.928 0.000
#> GSM38194 1 0.0000 0.8394 1.000 0.000 0.000
#> GSM38195 1 0.3482 0.8946 0.872 0.000 0.128
#> GSM38196 3 0.1289 0.8850 0.032 0.000 0.968
#> GSM38197 1 0.0592 0.8362 0.988 0.000 0.012
#> GSM38198 3 0.5016 0.7129 0.240 0.000 0.760
#> GSM38199 3 0.1289 0.8850 0.032 0.000 0.968
#> GSM38200 2 0.0892 0.9814 0.000 0.980 0.020
#> GSM38201 3 0.1289 0.8850 0.032 0.000 0.968
#> GSM38202 3 0.4121 0.7983 0.168 0.000 0.832
#> GSM38203 3 0.0892 0.8859 0.020 0.000 0.980
#> GSM38204 3 0.0892 0.8859 0.020 0.000 0.980
#> GSM38205 3 0.0892 0.8859 0.020 0.000 0.980
#> GSM38206 3 0.0892 0.8859 0.020 0.000 0.980
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.931 0.000 1.000 0.000 0.000
#> GSM38158 2 0.3404 0.901 0.104 0.864 0.032 0.000
#> GSM38159 2 0.2216 0.880 0.092 0.908 0.000 0.000
#> GSM38160 2 0.1042 0.930 0.020 0.972 0.008 0.000
#> GSM38161 2 0.0376 0.930 0.004 0.992 0.004 0.000
#> GSM38162 4 0.4008 0.564 0.000 0.000 0.244 0.756
#> GSM38163 3 0.5696 0.222 0.024 0.000 0.492 0.484
#> GSM38164 4 0.1557 0.824 0.000 0.000 0.056 0.944
#> GSM38165 3 0.1302 0.864 0.000 0.000 0.956 0.044
#> GSM38166 3 0.1302 0.864 0.000 0.000 0.956 0.044
#> GSM38167 4 0.1022 0.842 0.000 0.000 0.032 0.968
#> GSM38168 4 0.1389 0.831 0.000 0.000 0.048 0.952
#> GSM38169 4 0.0469 0.855 0.012 0.000 0.000 0.988
#> GSM38170 4 0.1867 0.809 0.000 0.000 0.072 0.928
#> GSM38171 4 0.2530 0.842 0.112 0.000 0.000 0.888
#> GSM38172 3 0.4855 0.519 0.000 0.000 0.600 0.400
#> GSM38173 4 0.2469 0.843 0.108 0.000 0.000 0.892
#> GSM38174 4 0.0000 0.853 0.000 0.000 0.000 1.000
#> GSM38175 1 0.2589 0.977 0.884 0.000 0.000 0.116
#> GSM38176 4 0.1792 0.854 0.068 0.000 0.000 0.932
#> GSM38177 4 0.0000 0.853 0.000 0.000 0.000 1.000
#> GSM38178 4 0.3123 0.810 0.156 0.000 0.000 0.844
#> GSM38179 4 0.2313 0.842 0.032 0.000 0.044 0.924
#> GSM38180 4 0.3356 0.798 0.176 0.000 0.000 0.824
#> GSM38181 3 0.1302 0.864 0.000 0.000 0.956 0.044
#> GSM38182 4 0.3074 0.813 0.152 0.000 0.000 0.848
#> GSM38183 4 0.1867 0.853 0.072 0.000 0.000 0.928
#> GSM38184 2 0.3404 0.901 0.104 0.864 0.032 0.000
#> GSM38185 1 0.2796 0.962 0.892 0.016 0.000 0.092
#> GSM38186 4 0.1792 0.854 0.068 0.000 0.000 0.932
#> GSM38187 1 0.2589 0.977 0.884 0.000 0.000 0.116
#> GSM38188 4 0.3172 0.805 0.160 0.000 0.000 0.840
#> GSM38189 4 0.3074 0.813 0.152 0.000 0.000 0.848
#> GSM38190 4 0.3123 0.810 0.156 0.000 0.000 0.844
#> GSM38191 1 0.2799 0.976 0.884 0.000 0.008 0.108
#> GSM38192 1 0.2530 0.978 0.888 0.000 0.000 0.112
#> GSM38193 2 0.3852 0.784 0.180 0.808 0.012 0.000
#> GSM38194 1 0.3591 0.919 0.824 0.000 0.008 0.168
#> GSM38195 4 0.2760 0.830 0.128 0.000 0.000 0.872
#> GSM38196 3 0.3764 0.796 0.000 0.000 0.784 0.216
#> GSM38197 1 0.2469 0.977 0.892 0.000 0.000 0.108
#> GSM38198 4 0.4164 0.523 0.000 0.000 0.264 0.736
#> GSM38199 3 0.2704 0.840 0.000 0.000 0.876 0.124
#> GSM38200 2 0.3367 0.902 0.108 0.864 0.028 0.000
#> GSM38201 3 0.3837 0.791 0.000 0.000 0.776 0.224
#> GSM38202 4 0.4193 0.514 0.000 0.000 0.268 0.732
#> GSM38203 3 0.1302 0.864 0.000 0.000 0.956 0.044
#> GSM38204 3 0.1302 0.864 0.000 0.000 0.956 0.044
#> GSM38205 3 0.1302 0.864 0.000 0.000 0.956 0.044
#> GSM38206 3 0.1302 0.864 0.000 0.000 0.956 0.044
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.8951 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0290 0.8953 0.008 0.992 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.8951 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.3048 0.8536 0.004 0.820 0.000 0.176 0.000
#> GSM38159 2 0.1792 0.8561 0.084 0.916 0.000 0.000 0.000
#> GSM38160 2 0.2157 0.8895 0.040 0.920 0.004 0.036 0.000
#> GSM38161 2 0.1493 0.8879 0.028 0.948 0.000 0.024 0.000
#> GSM38162 4 0.4558 0.6725 0.000 0.000 0.060 0.724 0.216
#> GSM38163 4 0.6435 0.5161 0.008 0.000 0.184 0.540 0.268
#> GSM38164 4 0.4054 0.6322 0.000 0.000 0.020 0.732 0.248
#> GSM38165 3 0.0613 0.9450 0.004 0.000 0.984 0.004 0.008
#> GSM38166 3 0.0451 0.9462 0.004 0.000 0.988 0.000 0.008
#> GSM38167 4 0.4448 -0.0598 0.000 0.000 0.004 0.516 0.480
#> GSM38168 4 0.3885 0.6100 0.000 0.000 0.008 0.724 0.268
#> GSM38169 5 0.3876 0.5572 0.000 0.000 0.000 0.316 0.684
#> GSM38170 4 0.4703 0.4741 0.000 0.000 0.028 0.632 0.340
#> GSM38171 5 0.1830 0.6720 0.008 0.000 0.000 0.068 0.924
#> GSM38172 4 0.4955 0.6080 0.000 0.000 0.248 0.680 0.072
#> GSM38173 5 0.2011 0.6757 0.004 0.000 0.000 0.088 0.908
#> GSM38174 5 0.4182 0.2556 0.000 0.000 0.000 0.400 0.600
#> GSM38175 5 0.4242 -0.2377 0.428 0.000 0.000 0.000 0.572
#> GSM38176 5 0.3519 0.5943 0.008 0.000 0.000 0.216 0.776
#> GSM38177 5 0.4305 0.0677 0.000 0.000 0.000 0.488 0.512
#> GSM38178 5 0.3401 0.6802 0.064 0.000 0.000 0.096 0.840
#> GSM38179 5 0.5126 -0.0818 0.008 0.000 0.024 0.432 0.536
#> GSM38180 5 0.1697 0.6709 0.008 0.000 0.000 0.060 0.932
#> GSM38181 3 0.0613 0.9450 0.004 0.000 0.984 0.004 0.008
#> GSM38182 5 0.3234 0.6803 0.064 0.000 0.000 0.084 0.852
#> GSM38183 5 0.2886 0.6566 0.008 0.000 0.000 0.148 0.844
#> GSM38184 2 0.3132 0.8535 0.008 0.820 0.000 0.172 0.000
#> GSM38185 1 0.2006 0.8866 0.916 0.012 0.000 0.000 0.072
#> GSM38186 5 0.3246 0.6233 0.008 0.000 0.000 0.184 0.808
#> GSM38187 1 0.3934 0.8188 0.740 0.000 0.000 0.016 0.244
#> GSM38188 5 0.3116 0.6773 0.064 0.000 0.000 0.076 0.860
#> GSM38189 5 0.3226 0.6805 0.060 0.000 0.000 0.088 0.852
#> GSM38190 5 0.3346 0.6802 0.064 0.000 0.000 0.092 0.844
#> GSM38191 1 0.2885 0.8781 0.880 0.000 0.004 0.064 0.052
#> GSM38192 1 0.3424 0.8289 0.760 0.000 0.000 0.000 0.240
#> GSM38193 2 0.5455 0.5552 0.272 0.636 0.004 0.088 0.000
#> GSM38194 1 0.2929 0.8728 0.876 0.000 0.004 0.076 0.044
#> GSM38195 5 0.4646 0.6035 0.060 0.000 0.000 0.228 0.712
#> GSM38196 4 0.4637 0.1451 0.000 0.000 0.452 0.536 0.012
#> GSM38197 1 0.1270 0.8906 0.948 0.000 0.000 0.000 0.052
#> GSM38198 4 0.4558 0.6725 0.000 0.000 0.060 0.724 0.216
#> GSM38199 3 0.4067 0.4980 0.000 0.000 0.692 0.300 0.008
#> GSM38200 2 0.3308 0.8599 0.020 0.832 0.004 0.144 0.000
#> GSM38201 4 0.4430 0.3946 0.000 0.000 0.360 0.628 0.012
#> GSM38202 4 0.4589 0.6730 0.000 0.000 0.064 0.724 0.212
#> GSM38203 3 0.0290 0.9469 0.000 0.000 0.992 0.000 0.008
#> GSM38204 3 0.0290 0.9469 0.000 0.000 0.992 0.000 0.008
#> GSM38205 3 0.0290 0.9469 0.000 0.000 0.992 0.000 0.008
#> GSM38206 3 0.0290 0.9469 0.000 0.000 0.992 0.000 0.008
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0000 8.31e-01 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38156 2 0.0260 8.32e-01 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM38157 2 0.0000 8.31e-01 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.3515 7.42e-01 0.000 0.676 0.000 0.000 0.000 0.324
#> GSM38159 2 0.1858 7.83e-01 0.092 0.904 0.000 0.000 0.004 0.000
#> GSM38160 2 0.3051 8.21e-01 0.004 0.864 0.004 0.008 0.060 0.060
#> GSM38161 2 0.2162 8.21e-01 0.008 0.916 0.000 0.008 0.036 0.032
#> GSM38162 4 0.0922 6.71e-01 0.000 0.000 0.024 0.968 0.004 0.004
#> GSM38163 4 0.5880 4.67e-01 0.028 0.000 0.084 0.636 0.212 0.040
#> GSM38164 4 0.2250 6.39e-01 0.000 0.000 0.000 0.896 0.040 0.064
#> GSM38165 3 0.0972 8.98e-01 0.000 0.000 0.964 0.008 0.000 0.028
#> GSM38166 3 0.1333 8.92e-01 0.000 0.000 0.944 0.008 0.000 0.048
#> GSM38167 4 0.4905 2.96e-01 0.000 0.000 0.000 0.620 0.284 0.096
#> GSM38168 4 0.0632 6.63e-01 0.000 0.000 0.000 0.976 0.024 0.000
#> GSM38169 5 0.6034 3.98e-01 0.000 0.000 0.000 0.320 0.416 0.264
#> GSM38170 4 0.3803 5.22e-01 0.000 0.000 0.000 0.760 0.184 0.056
#> GSM38171 5 0.3139 5.62e-01 0.028 0.000 0.000 0.160 0.812 0.000
#> GSM38172 4 0.2257 6.34e-01 0.000 0.000 0.116 0.876 0.000 0.008
#> GSM38173 5 0.3236 5.58e-01 0.024 0.000 0.000 0.180 0.796 0.000
#> GSM38174 4 0.6094 -3.63e-01 0.000 0.000 0.000 0.364 0.356 0.280
#> GSM38175 5 0.4692 -2.57e-01 0.444 0.000 0.000 0.000 0.512 0.044
#> GSM38176 5 0.4885 4.38e-01 0.028 0.000 0.000 0.268 0.656 0.048
#> GSM38177 4 0.5070 1.85e-01 0.000 0.000 0.000 0.576 0.328 0.096
#> GSM38178 5 0.5974 5.62e-01 0.024 0.000 0.000 0.124 0.472 0.380
#> GSM38179 4 0.5536 -6.78e-05 0.028 0.000 0.000 0.476 0.432 0.064
#> GSM38180 5 0.3210 5.62e-01 0.036 0.000 0.000 0.152 0.812 0.000
#> GSM38181 3 0.1124 8.96e-01 0.000 0.000 0.956 0.008 0.000 0.036
#> GSM38182 5 0.5874 5.75e-01 0.024 0.000 0.000 0.128 0.532 0.316
#> GSM38183 5 0.5288 4.91e-01 0.028 0.000 0.000 0.232 0.644 0.096
#> GSM38184 2 0.3636 7.42e-01 0.000 0.676 0.004 0.000 0.000 0.320
#> GSM38185 1 0.1245 8.25e-01 0.952 0.000 0.000 0.000 0.032 0.016
#> GSM38186 5 0.4405 4.73e-01 0.028 0.000 0.000 0.252 0.696 0.024
#> GSM38187 1 0.4054 7.38e-01 0.748 0.000 0.008 0.000 0.192 0.052
#> GSM38188 5 0.5874 5.75e-01 0.024 0.000 0.000 0.128 0.532 0.316
#> GSM38189 5 0.5874 5.74e-01 0.024 0.000 0.000 0.128 0.532 0.316
#> GSM38190 5 0.5944 5.72e-01 0.024 0.000 0.000 0.128 0.504 0.344
#> GSM38191 1 0.3525 7.75e-01 0.800 0.000 0.000 0.012 0.032 0.156
#> GSM38192 1 0.3394 7.47e-01 0.776 0.000 0.000 0.000 0.200 0.024
#> GSM38193 2 0.6457 3.80e-01 0.236 0.536 0.000 0.008 0.044 0.176
#> GSM38194 1 0.4034 7.58e-01 0.772 0.000 0.000 0.036 0.032 0.160
#> GSM38195 5 0.6426 4.79e-01 0.020 0.000 0.000 0.252 0.424 0.304
#> GSM38196 4 0.4024 3.76e-01 0.000 0.000 0.264 0.700 0.000 0.036
#> GSM38197 1 0.0260 8.25e-01 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM38198 4 0.0858 6.71e-01 0.000 0.000 0.028 0.968 0.000 0.004
#> GSM38199 3 0.4651 7.93e-02 0.000 0.000 0.480 0.480 0.000 0.040
#> GSM38200 2 0.4020 7.53e-01 0.000 0.692 0.000 0.000 0.032 0.276
#> GSM38201 4 0.2730 5.32e-01 0.000 0.000 0.192 0.808 0.000 0.000
#> GSM38202 4 0.0790 6.71e-01 0.000 0.000 0.032 0.968 0.000 0.000
#> GSM38203 3 0.0260 9.03e-01 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38204 3 0.0260 9.03e-01 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38205 3 0.0260 9.03e-01 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38206 3 0.0717 8.99e-01 0.000 0.000 0.976 0.008 0.000 0.016
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:kmeans 52 3.80e-08 2
#> ATC:kmeans 49 4.56e-09 3
#> ATC:kmeans 51 1.40e-08 4
#> ATC:kmeans 43 4.56e-07 5
#> ATC:kmeans 38 3.28e-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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.977 0.991 0.4550 0.551 0.551
#> 3 3 0.849 0.928 0.954 0.4628 0.756 0.565
#> 4 4 0.692 0.732 0.849 0.0891 0.937 0.813
#> 5 5 0.685 0.515 0.713 0.0615 0.945 0.821
#> 6 6 0.690 0.537 0.740 0.0410 0.844 0.494
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
#> GSM38155 2 0.0000 1.000 0.000 1.000
#> GSM38156 2 0.0000 1.000 0.000 1.000
#> GSM38157 2 0.0000 1.000 0.000 1.000
#> GSM38158 2 0.0000 1.000 0.000 1.000
#> GSM38159 2 0.0000 1.000 0.000 1.000
#> GSM38160 2 0.0000 1.000 0.000 1.000
#> GSM38161 2 0.0000 1.000 0.000 1.000
#> GSM38162 1 0.0000 0.987 1.000 0.000
#> GSM38163 1 0.0000 0.987 1.000 0.000
#> GSM38164 1 0.0000 0.987 1.000 0.000
#> GSM38165 1 0.0000 0.987 1.000 0.000
#> GSM38166 1 0.0000 0.987 1.000 0.000
#> GSM38167 1 0.0000 0.987 1.000 0.000
#> GSM38168 1 0.0000 0.987 1.000 0.000
#> GSM38169 1 0.0000 0.987 1.000 0.000
#> GSM38170 1 0.0000 0.987 1.000 0.000
#> GSM38171 1 0.0000 0.987 1.000 0.000
#> GSM38172 1 0.0000 0.987 1.000 0.000
#> GSM38173 1 0.0000 0.987 1.000 0.000
#> GSM38174 1 0.0000 0.987 1.000 0.000
#> GSM38175 2 0.0000 1.000 0.000 1.000
#> GSM38176 1 0.0000 0.987 1.000 0.000
#> GSM38177 1 0.0000 0.987 1.000 0.000
#> GSM38178 1 0.0672 0.980 0.992 0.008
#> GSM38179 1 0.0000 0.987 1.000 0.000
#> GSM38180 1 0.0000 0.987 1.000 0.000
#> GSM38181 1 0.0000 0.987 1.000 0.000
#> GSM38182 1 0.0000 0.987 1.000 0.000
#> GSM38183 1 0.0000 0.987 1.000 0.000
#> GSM38184 2 0.0000 1.000 0.000 1.000
#> GSM38185 2 0.0000 1.000 0.000 1.000
#> GSM38186 1 0.0000 0.987 1.000 0.000
#> GSM38187 1 0.9732 0.322 0.596 0.404
#> GSM38188 2 0.0000 1.000 0.000 1.000
#> GSM38189 1 0.0000 0.987 1.000 0.000
#> GSM38190 1 0.2236 0.952 0.964 0.036
#> GSM38191 2 0.0000 1.000 0.000 1.000
#> GSM38192 2 0.0000 1.000 0.000 1.000
#> GSM38193 2 0.0000 1.000 0.000 1.000
#> GSM38194 2 0.0000 1.000 0.000 1.000
#> GSM38195 1 0.0000 0.987 1.000 0.000
#> GSM38196 1 0.0000 0.987 1.000 0.000
#> GSM38197 2 0.0000 1.000 0.000 1.000
#> GSM38198 1 0.0000 0.987 1.000 0.000
#> GSM38199 1 0.0000 0.987 1.000 0.000
#> GSM38200 2 0.0000 1.000 0.000 1.000
#> GSM38201 1 0.0000 0.987 1.000 0.000
#> GSM38202 1 0.0000 0.987 1.000 0.000
#> GSM38203 1 0.0000 0.987 1.000 0.000
#> GSM38204 1 0.0000 0.987 1.000 0.000
#> GSM38205 1 0.0000 0.987 1.000 0.000
#> GSM38206 1 0.0000 0.987 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38156 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38157 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38158 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38159 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38160 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38161 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38162 3 0.1860 0.945 0.052 0.000 0.948
#> GSM38163 3 0.1289 0.941 0.032 0.000 0.968
#> GSM38164 3 0.2448 0.931 0.076 0.000 0.924
#> GSM38165 3 0.0000 0.953 0.000 0.000 1.000
#> GSM38166 3 0.0000 0.953 0.000 0.000 1.000
#> GSM38167 1 0.4702 0.786 0.788 0.000 0.212
#> GSM38168 3 0.1529 0.949 0.040 0.000 0.960
#> GSM38169 1 0.1529 0.900 0.960 0.000 0.040
#> GSM38170 3 0.3879 0.848 0.152 0.000 0.848
#> GSM38171 1 0.1643 0.894 0.956 0.000 0.044
#> GSM38172 3 0.1643 0.948 0.044 0.000 0.956
#> GSM38173 1 0.1753 0.896 0.952 0.000 0.048
#> GSM38174 1 0.4399 0.811 0.812 0.000 0.188
#> GSM38175 2 0.0237 0.996 0.004 0.996 0.000
#> GSM38176 1 0.2537 0.890 0.920 0.000 0.080
#> GSM38177 1 0.5291 0.700 0.732 0.000 0.268
#> GSM38178 1 0.0592 0.894 0.988 0.000 0.012
#> GSM38179 3 0.3879 0.827 0.152 0.000 0.848
#> GSM38180 1 0.1753 0.894 0.952 0.000 0.048
#> GSM38181 3 0.0000 0.953 0.000 0.000 1.000
#> GSM38182 1 0.1289 0.896 0.968 0.000 0.032
#> GSM38183 1 0.1411 0.900 0.964 0.000 0.036
#> GSM38184 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38185 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38186 1 0.5431 0.670 0.716 0.000 0.284
#> GSM38187 3 0.2550 0.904 0.012 0.056 0.932
#> GSM38188 1 0.3532 0.830 0.884 0.108 0.008
#> GSM38189 1 0.2796 0.881 0.908 0.000 0.092
#> GSM38190 1 0.0000 0.891 1.000 0.000 0.000
#> GSM38191 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38192 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38193 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38194 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38195 3 0.4121 0.831 0.168 0.000 0.832
#> GSM38196 3 0.1163 0.952 0.028 0.000 0.972
#> GSM38197 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38198 3 0.1643 0.948 0.044 0.000 0.956
#> GSM38199 3 0.0747 0.954 0.016 0.000 0.984
#> GSM38200 2 0.0000 1.000 0.000 1.000 0.000
#> GSM38201 3 0.0592 0.954 0.012 0.000 0.988
#> GSM38202 3 0.1031 0.952 0.024 0.000 0.976
#> GSM38203 3 0.0000 0.953 0.000 0.000 1.000
#> GSM38204 3 0.0000 0.953 0.000 0.000 1.000
#> GSM38205 3 0.0000 0.953 0.000 0.000 1.000
#> GSM38206 3 0.0000 0.953 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38160 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38162 3 0.5859 0.724 0.156 0.000 0.704 0.140
#> GSM38163 3 0.4454 0.542 0.308 0.000 0.692 0.000
#> GSM38164 3 0.6025 0.707 0.140 0.000 0.688 0.172
#> GSM38165 3 0.0188 0.787 0.004 0.000 0.996 0.000
#> GSM38166 3 0.0000 0.787 0.000 0.000 1.000 0.000
#> GSM38167 1 0.7694 0.222 0.448 0.000 0.244 0.308
#> GSM38168 3 0.6123 0.702 0.132 0.000 0.676 0.192
#> GSM38169 1 0.5808 0.181 0.544 0.000 0.032 0.424
#> GSM38170 3 0.6607 0.523 0.296 0.000 0.592 0.112
#> GSM38171 1 0.3354 0.573 0.872 0.000 0.044 0.084
#> GSM38172 3 0.5116 0.761 0.108 0.000 0.764 0.128
#> GSM38173 1 0.3229 0.584 0.880 0.000 0.048 0.072
#> GSM38174 4 0.6243 0.414 0.172 0.000 0.160 0.668
#> GSM38175 2 0.2737 0.881 0.104 0.888 0.000 0.008
#> GSM38176 1 0.2111 0.613 0.932 0.000 0.024 0.044
#> GSM38177 1 0.7295 0.315 0.524 0.000 0.188 0.288
#> GSM38178 4 0.2216 0.749 0.092 0.000 0.000 0.908
#> GSM38179 1 0.5028 0.213 0.596 0.000 0.400 0.004
#> GSM38180 1 0.3372 0.562 0.868 0.000 0.036 0.096
#> GSM38181 3 0.0336 0.784 0.008 0.000 0.992 0.000
#> GSM38182 4 0.3217 0.770 0.128 0.000 0.012 0.860
#> GSM38183 1 0.3529 0.574 0.836 0.000 0.012 0.152
#> GSM38184 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38185 2 0.0188 0.975 0.004 0.996 0.000 0.000
#> GSM38186 1 0.3821 0.594 0.840 0.000 0.120 0.040
#> GSM38187 3 0.5550 0.544 0.152 0.040 0.760 0.048
#> GSM38188 4 0.4469 0.713 0.112 0.080 0.000 0.808
#> GSM38189 4 0.4436 0.743 0.148 0.000 0.052 0.800
#> GSM38190 4 0.3907 0.659 0.232 0.000 0.000 0.768
#> GSM38191 2 0.1938 0.947 0.012 0.936 0.000 0.052
#> GSM38192 2 0.1837 0.953 0.028 0.944 0.000 0.028
#> GSM38193 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38194 2 0.2652 0.930 0.028 0.912 0.004 0.056
#> GSM38195 3 0.7034 0.264 0.120 0.000 0.468 0.412
#> GSM38196 3 0.4483 0.780 0.104 0.000 0.808 0.088
#> GSM38197 2 0.1854 0.950 0.012 0.940 0.000 0.048
#> GSM38198 3 0.5582 0.740 0.136 0.000 0.728 0.136
#> GSM38199 3 0.3474 0.794 0.068 0.000 0.868 0.064
#> GSM38200 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM38201 3 0.3081 0.795 0.064 0.000 0.888 0.048
#> GSM38202 3 0.4426 0.783 0.092 0.000 0.812 0.096
#> GSM38203 3 0.0188 0.787 0.004 0.000 0.996 0.000
#> GSM38204 3 0.0188 0.787 0.004 0.000 0.996 0.000
#> GSM38205 3 0.0188 0.787 0.004 0.000 0.996 0.000
#> GSM38206 3 0.0188 0.787 0.004 0.000 0.996 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38159 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38160 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38161 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38162 4 0.2674 0.518 0.060 0.000 0.032 0.896 0.012
#> GSM38163 4 0.6071 0.186 0.288 0.000 0.140 0.568 0.004
#> GSM38164 4 0.4169 0.481 0.056 0.000 0.100 0.812 0.032
#> GSM38165 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
#> GSM38166 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
#> GSM38167 4 0.7814 -0.255 0.304 0.000 0.088 0.416 0.192
#> GSM38168 4 0.3096 0.518 0.036 0.000 0.040 0.880 0.044
#> GSM38169 1 0.8157 0.114 0.380 0.000 0.124 0.212 0.284
#> GSM38170 4 0.6022 0.347 0.200 0.000 0.096 0.656 0.048
#> GSM38171 1 0.3266 0.594 0.852 0.000 0.032 0.008 0.108
#> GSM38172 4 0.0912 0.542 0.012 0.000 0.016 0.972 0.000
#> GSM38173 1 0.3495 0.630 0.852 0.000 0.020 0.048 0.080
#> GSM38174 5 0.6353 0.255 0.060 0.000 0.048 0.372 0.520
#> GSM38175 2 0.5524 0.622 0.180 0.684 0.120 0.000 0.016
#> GSM38176 1 0.3076 0.645 0.876 0.000 0.024 0.072 0.028
#> GSM38177 4 0.7796 -0.248 0.324 0.000 0.116 0.420 0.140
#> GSM38178 5 0.3216 0.687 0.068 0.000 0.048 0.016 0.868
#> GSM38179 1 0.6387 0.205 0.492 0.000 0.112 0.380 0.016
#> GSM38180 1 0.3086 0.598 0.864 0.000 0.040 0.004 0.092
#> GSM38181 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
#> GSM38182 5 0.1921 0.709 0.044 0.000 0.012 0.012 0.932
#> GSM38183 1 0.6192 0.542 0.664 0.000 0.100 0.084 0.152
#> GSM38184 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38185 2 0.1043 0.867 0.000 0.960 0.040 0.000 0.000
#> GSM38186 1 0.4941 0.581 0.720 0.000 0.032 0.212 0.036
#> GSM38187 3 0.4611 0.000 0.048 0.004 0.736 0.208 0.004
#> GSM38188 5 0.3619 0.672 0.076 0.068 0.008 0.004 0.844
#> GSM38189 5 0.4790 0.672 0.108 0.000 0.040 0.080 0.772
#> GSM38190 5 0.5647 0.544 0.256 0.000 0.072 0.024 0.648
#> GSM38191 2 0.5430 0.603 0.032 0.616 0.324 0.000 0.028
#> GSM38192 2 0.4404 0.711 0.028 0.716 0.252 0.000 0.004
#> GSM38193 2 0.0451 0.877 0.004 0.988 0.008 0.000 0.000
#> GSM38194 2 0.6782 0.507 0.040 0.544 0.332 0.048 0.036
#> GSM38195 4 0.6241 0.149 0.036 0.000 0.068 0.536 0.360
#> GSM38196 4 0.0566 0.544 0.012 0.000 0.004 0.984 0.000
#> GSM38197 2 0.5391 0.584 0.024 0.592 0.356 0.000 0.028
#> GSM38198 4 0.1686 0.537 0.028 0.000 0.020 0.944 0.008
#> GSM38199 4 0.2488 0.500 0.004 0.000 0.124 0.872 0.000
#> GSM38200 2 0.0000 0.882 0.000 1.000 0.000 0.000 0.000
#> GSM38201 4 0.2011 0.522 0.004 0.000 0.088 0.908 0.000
#> GSM38202 4 0.1569 0.541 0.008 0.000 0.044 0.944 0.004
#> GSM38203 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
#> GSM38204 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
#> GSM38205 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
#> GSM38206 4 0.4161 0.252 0.000 0.000 0.392 0.608 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38156 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38157 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38158 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38159 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38160 2 0.0260 0.8828 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM38161 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38162 4 0.4795 0.5185 0.012 0.000 0.340 0.612 0.028 0.008
#> GSM38163 3 0.6175 0.0164 0.308 0.000 0.484 0.188 0.020 0.000
#> GSM38164 4 0.5870 0.5042 0.020 0.000 0.328 0.560 0.044 0.048
#> GSM38165 3 0.0000 0.7349 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0632 0.7197 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM38167 4 0.6469 0.3647 0.124 0.000 0.072 0.632 0.076 0.096
#> GSM38168 4 0.5665 0.5194 0.012 0.000 0.276 0.604 0.028 0.080
#> GSM38169 4 0.7489 -0.2372 0.144 0.000 0.008 0.412 0.184 0.252
#> GSM38170 4 0.6434 0.4485 0.128 0.000 0.264 0.544 0.052 0.012
#> GSM38171 1 0.2399 0.6728 0.908 0.000 0.012 0.024 0.024 0.032
#> GSM38172 4 0.4158 0.4573 0.004 0.000 0.400 0.588 0.004 0.004
#> GSM38173 1 0.2832 0.6709 0.880 0.000 0.016 0.056 0.008 0.040
#> GSM38174 4 0.6235 -0.0558 0.044 0.000 0.068 0.484 0.020 0.384
#> GSM38175 2 0.6108 0.3171 0.144 0.652 0.000 0.060 0.100 0.044
#> GSM38176 1 0.4102 0.6724 0.772 0.000 0.008 0.156 0.052 0.012
#> GSM38177 4 0.6556 0.3177 0.140 0.000 0.064 0.620 0.080 0.096
#> GSM38178 6 0.3525 0.6026 0.008 0.000 0.000 0.096 0.080 0.816
#> GSM38179 1 0.6397 0.2393 0.472 0.000 0.312 0.180 0.036 0.000
#> GSM38180 1 0.1749 0.6632 0.936 0.000 0.004 0.016 0.012 0.032
#> GSM38181 3 0.0291 0.7310 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM38182 6 0.3357 0.6189 0.060 0.000 0.020 0.064 0.008 0.848
#> GSM38183 1 0.6304 0.5301 0.580 0.000 0.004 0.216 0.100 0.100
#> GSM38184 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38185 2 0.1867 0.8013 0.000 0.916 0.000 0.020 0.064 0.000
#> GSM38186 1 0.5318 0.5783 0.680 0.000 0.052 0.208 0.032 0.028
#> GSM38187 3 0.5817 0.3285 0.036 0.000 0.616 0.088 0.244 0.016
#> GSM38188 6 0.4449 0.5800 0.084 0.052 0.000 0.044 0.032 0.788
#> GSM38189 6 0.6679 0.5481 0.124 0.000 0.072 0.128 0.068 0.608
#> GSM38190 6 0.6685 0.4307 0.152 0.000 0.000 0.124 0.192 0.532
#> GSM38191 5 0.3807 0.7975 0.000 0.368 0.000 0.004 0.628 0.000
#> GSM38192 2 0.5724 0.0858 0.032 0.616 0.000 0.080 0.256 0.016
#> GSM38193 2 0.0865 0.8524 0.000 0.964 0.000 0.000 0.036 0.000
#> GSM38194 5 0.4507 0.7573 0.000 0.284 0.000 0.052 0.660 0.004
#> GSM38195 6 0.7647 -0.1959 0.032 0.000 0.300 0.292 0.064 0.312
#> GSM38196 4 0.4224 0.3346 0.004 0.000 0.476 0.512 0.008 0.000
#> GSM38197 5 0.4310 0.6303 0.000 0.472 0.000 0.012 0.512 0.004
#> GSM38198 4 0.4022 0.4987 0.008 0.000 0.360 0.628 0.004 0.000
#> GSM38199 3 0.4109 -0.1171 0.004 0.000 0.596 0.392 0.008 0.000
#> GSM38200 2 0.0000 0.8895 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38201 3 0.4045 -0.2113 0.000 0.000 0.564 0.428 0.008 0.000
#> GSM38202 4 0.4315 0.2872 0.000 0.000 0.492 0.492 0.004 0.012
#> GSM38203 3 0.0000 0.7349 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 0.7349 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0146 0.7332 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM38206 3 0.0000 0.7349 0.000 0.000 1.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:skmeans 51 1.34e-04 2
#> ATC:skmeans 52 2.35e-05 3
#> ATC:skmeans 46 6.62e-04 4
#> ATC:skmeans 34 8.27e-03 5
#> ATC:skmeans 34 1.37e-04 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.3442 0.660 0.660
#> 3 3 0.652 0.825 0.885 0.6148 0.787 0.681
#> 4 4 0.762 0.897 0.932 0.2257 0.863 0.701
#> 5 5 0.837 0.760 0.864 0.0760 0.963 0.886
#> 6 6 0.888 0.897 0.946 0.0926 0.865 0.563
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
#> GSM38155 2 0.000 0.998 0.000 1.000
#> GSM38156 2 0.000 0.998 0.000 1.000
#> GSM38157 2 0.000 0.998 0.000 1.000
#> GSM38158 2 0.000 0.998 0.000 1.000
#> GSM38159 2 0.000 0.998 0.000 1.000
#> GSM38160 2 0.000 0.998 0.000 1.000
#> GSM38161 2 0.000 0.998 0.000 1.000
#> GSM38162 1 0.000 0.996 1.000 0.000
#> GSM38163 1 0.000 0.996 1.000 0.000
#> GSM38164 1 0.000 0.996 1.000 0.000
#> GSM38165 1 0.000 0.996 1.000 0.000
#> GSM38166 1 0.000 0.996 1.000 0.000
#> GSM38167 1 0.000 0.996 1.000 0.000
#> GSM38168 1 0.000 0.996 1.000 0.000
#> GSM38169 1 0.000 0.996 1.000 0.000
#> GSM38170 1 0.000 0.996 1.000 0.000
#> GSM38171 1 0.000 0.996 1.000 0.000
#> GSM38172 1 0.000 0.996 1.000 0.000
#> GSM38173 1 0.000 0.996 1.000 0.000
#> GSM38174 1 0.000 0.996 1.000 0.000
#> GSM38175 1 0.671 0.786 0.824 0.176
#> GSM38176 1 0.000 0.996 1.000 0.000
#> GSM38177 1 0.000 0.996 1.000 0.000
#> GSM38178 1 0.000 0.996 1.000 0.000
#> GSM38179 1 0.000 0.996 1.000 0.000
#> GSM38180 1 0.000 0.996 1.000 0.000
#> GSM38181 1 0.000 0.996 1.000 0.000
#> GSM38182 1 0.000 0.996 1.000 0.000
#> GSM38183 1 0.000 0.996 1.000 0.000
#> GSM38184 2 0.000 0.998 0.000 1.000
#> GSM38185 2 0.141 0.979 0.020 0.980
#> GSM38186 1 0.000 0.996 1.000 0.000
#> GSM38187 1 0.000 0.996 1.000 0.000
#> GSM38188 1 0.000 0.996 1.000 0.000
#> GSM38189 1 0.000 0.996 1.000 0.000
#> GSM38190 1 0.000 0.996 1.000 0.000
#> GSM38191 1 0.000 0.996 1.000 0.000
#> GSM38192 1 0.000 0.996 1.000 0.000
#> GSM38193 2 0.000 0.998 0.000 1.000
#> GSM38194 1 0.000 0.996 1.000 0.000
#> GSM38195 1 0.000 0.996 1.000 0.000
#> GSM38196 1 0.000 0.996 1.000 0.000
#> GSM38197 1 0.000 0.996 1.000 0.000
#> GSM38198 1 0.000 0.996 1.000 0.000
#> GSM38199 1 0.000 0.996 1.000 0.000
#> GSM38200 2 0.000 0.998 0.000 1.000
#> GSM38201 1 0.000 0.996 1.000 0.000
#> GSM38202 1 0.000 0.996 1.000 0.000
#> GSM38203 1 0.000 0.996 1.000 0.000
#> GSM38204 1 0.000 0.996 1.000 0.000
#> GSM38205 1 0.000 0.996 1.000 0.000
#> GSM38206 1 0.000 0.996 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0237 0.993 0.000 0.996 0.004
#> GSM38156 2 0.0000 0.993 0.000 1.000 0.000
#> GSM38157 2 0.0237 0.993 0.000 0.996 0.004
#> GSM38158 2 0.0000 0.993 0.000 1.000 0.000
#> GSM38159 2 0.0237 0.993 0.000 0.996 0.004
#> GSM38160 2 0.0000 0.993 0.000 1.000 0.000
#> GSM38161 2 0.0237 0.993 0.000 0.996 0.004
#> GSM38162 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38163 1 0.3752 0.825 0.856 0.000 0.144
#> GSM38164 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38165 1 0.5216 0.703 0.740 0.000 0.260
#> GSM38166 1 0.5178 0.704 0.744 0.000 0.256
#> GSM38167 1 0.0424 0.865 0.992 0.000 0.008
#> GSM38168 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38169 1 0.2537 0.831 0.920 0.000 0.080
#> GSM38170 1 0.0237 0.867 0.996 0.000 0.004
#> GSM38171 3 0.5905 0.762 0.352 0.000 0.648
#> GSM38172 1 0.0592 0.865 0.988 0.000 0.012
#> GSM38173 1 0.2625 0.828 0.916 0.000 0.084
#> GSM38174 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38175 3 0.6731 0.779 0.172 0.088 0.740
#> GSM38176 1 0.2537 0.831 0.920 0.000 0.080
#> GSM38177 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38178 1 0.2796 0.796 0.908 0.000 0.092
#> GSM38179 1 0.2537 0.831 0.920 0.000 0.080
#> GSM38180 3 0.5785 0.790 0.332 0.000 0.668
#> GSM38181 1 0.5254 0.702 0.736 0.000 0.264
#> GSM38182 1 0.2625 0.828 0.916 0.000 0.084
#> GSM38183 1 0.2625 0.828 0.916 0.000 0.084
#> GSM38184 2 0.0000 0.993 0.000 1.000 0.000
#> GSM38185 3 0.6155 0.334 0.008 0.328 0.664
#> GSM38186 1 0.2625 0.828 0.916 0.000 0.084
#> GSM38187 3 0.2537 0.691 0.080 0.000 0.920
#> GSM38188 3 0.5785 0.812 0.332 0.000 0.668
#> GSM38189 1 0.0237 0.866 0.996 0.000 0.004
#> GSM38190 1 0.5882 0.247 0.652 0.000 0.348
#> GSM38191 3 0.5835 0.804 0.340 0.000 0.660
#> GSM38192 3 0.5216 0.834 0.260 0.000 0.740
#> GSM38193 2 0.1860 0.947 0.000 0.948 0.052
#> GSM38194 1 0.0424 0.866 0.992 0.000 0.008
#> GSM38195 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38196 1 0.2448 0.839 0.924 0.000 0.076
#> GSM38197 3 0.5254 0.835 0.264 0.000 0.736
#> GSM38198 1 0.0000 0.867 1.000 0.000 0.000
#> GSM38199 1 0.2537 0.836 0.920 0.000 0.080
#> GSM38200 2 0.0000 0.993 0.000 1.000 0.000
#> GSM38201 1 0.1860 0.851 0.948 0.000 0.052
#> GSM38202 1 0.0237 0.866 0.996 0.000 0.004
#> GSM38203 1 0.5216 0.703 0.740 0.000 0.260
#> GSM38204 1 0.5216 0.703 0.740 0.000 0.260
#> GSM38205 1 0.5178 0.704 0.744 0.000 0.256
#> GSM38206 1 0.5178 0.704 0.744 0.000 0.256
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0336 0.969 0.008 0.992 0.000 0.000
#> GSM38156 2 0.0000 0.969 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0336 0.969 0.008 0.992 0.000 0.000
#> GSM38158 2 0.1716 0.959 0.000 0.936 0.064 0.000
#> GSM38159 2 0.0336 0.969 0.008 0.992 0.000 0.000
#> GSM38160 2 0.1716 0.959 0.000 0.936 0.064 0.000
#> GSM38161 2 0.0336 0.969 0.008 0.992 0.000 0.000
#> GSM38162 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38163 4 0.4286 0.843 0.136 0.000 0.052 0.812
#> GSM38164 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38165 3 0.1716 1.000 0.000 0.000 0.936 0.064
#> GSM38166 3 0.1716 1.000 0.000 0.000 0.936 0.064
#> GSM38167 4 0.0336 0.918 0.008 0.000 0.000 0.992
#> GSM38168 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38169 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38170 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38171 1 0.3219 0.765 0.836 0.000 0.000 0.164
#> GSM38172 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38173 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38174 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38175 1 0.0469 0.858 0.988 0.000 0.000 0.012
#> GSM38176 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38177 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38178 4 0.2469 0.842 0.108 0.000 0.000 0.892
#> GSM38179 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38180 1 0.3074 0.780 0.848 0.000 0.000 0.152
#> GSM38181 3 0.1716 1.000 0.000 0.000 0.936 0.064
#> GSM38182 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38183 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38184 2 0.1389 0.963 0.000 0.952 0.048 0.000
#> GSM38185 1 0.2868 0.759 0.864 0.136 0.000 0.000
#> GSM38186 4 0.2868 0.869 0.136 0.000 0.000 0.864
#> GSM38187 1 0.2741 0.812 0.892 0.000 0.096 0.012
#> GSM38188 1 0.3123 0.809 0.844 0.000 0.000 0.156
#> GSM38189 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38190 4 0.4948 0.344 0.440 0.000 0.000 0.560
#> GSM38191 1 0.2973 0.798 0.856 0.000 0.000 0.144
#> GSM38192 1 0.0336 0.857 0.992 0.000 0.000 0.008
#> GSM38193 2 0.1867 0.921 0.072 0.928 0.000 0.000
#> GSM38194 4 0.1118 0.905 0.036 0.000 0.000 0.964
#> GSM38195 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38196 4 0.1474 0.891 0.000 0.000 0.052 0.948
#> GSM38197 1 0.0469 0.859 0.988 0.000 0.000 0.012
#> GSM38198 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38199 4 0.1474 0.891 0.000 0.000 0.052 0.948
#> GSM38200 2 0.1716 0.959 0.000 0.936 0.064 0.000
#> GSM38201 4 0.0921 0.907 0.000 0.000 0.028 0.972
#> GSM38202 4 0.0000 0.919 0.000 0.000 0.000 1.000
#> GSM38203 3 0.1716 1.000 0.000 0.000 0.936 0.064
#> GSM38204 3 0.1716 1.000 0.000 0.000 0.936 0.064
#> GSM38205 3 0.1716 1.000 0.000 0.000 0.936 0.064
#> GSM38206 3 0.1716 1.000 0.000 0.000 0.936 0.064
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.965 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.0290 0.960 0.000 0.992 0.000 0.000 0.008
#> GSM38157 2 0.0000 0.965 0.000 1.000 0.000 0.000 0.000
#> GSM38158 5 0.3999 0.400 0.000 0.344 0.000 0.000 0.656
#> GSM38159 2 0.0162 0.964 0.000 0.996 0.000 0.000 0.004
#> GSM38160 5 0.3983 0.398 0.000 0.340 0.000 0.000 0.660
#> GSM38161 2 0.0162 0.964 0.000 0.996 0.000 0.000 0.004
#> GSM38162 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38163 4 0.6063 0.582 0.040 0.000 0.056 0.572 0.332
#> GSM38164 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38165 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38167 4 0.0880 0.825 0.000 0.000 0.000 0.968 0.032
#> GSM38168 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38169 4 0.4874 0.631 0.040 0.000 0.000 0.632 0.328
#> GSM38170 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38171 1 0.6226 0.317 0.504 0.000 0.000 0.156 0.340
#> GSM38172 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38173 4 0.4987 0.618 0.044 0.000 0.000 0.616 0.340
#> GSM38174 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38175 1 0.0000 0.800 1.000 0.000 0.000 0.000 0.000
#> GSM38176 4 0.4905 0.624 0.040 0.000 0.000 0.624 0.336
#> GSM38177 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38178 4 0.2959 0.748 0.100 0.000 0.000 0.864 0.036
#> GSM38179 4 0.4905 0.624 0.040 0.000 0.000 0.624 0.336
#> GSM38180 1 0.6134 0.335 0.516 0.000 0.000 0.144 0.340
#> GSM38181 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38182 4 0.4987 0.618 0.044 0.000 0.000 0.616 0.340
#> GSM38183 4 0.4972 0.622 0.044 0.000 0.000 0.620 0.336
#> GSM38184 2 0.2516 0.799 0.000 0.860 0.000 0.000 0.140
#> GSM38185 1 0.1043 0.775 0.960 0.040 0.000 0.000 0.000
#> GSM38186 4 0.4972 0.622 0.044 0.000 0.000 0.620 0.336
#> GSM38187 1 0.0703 0.789 0.976 0.000 0.024 0.000 0.000
#> GSM38188 1 0.2464 0.732 0.888 0.000 0.000 0.096 0.016
#> GSM38189 4 0.0324 0.830 0.004 0.000 0.000 0.992 0.004
#> GSM38190 5 0.6825 -0.279 0.336 0.000 0.000 0.324 0.340
#> GSM38191 1 0.1121 0.776 0.956 0.000 0.000 0.044 0.000
#> GSM38192 1 0.0000 0.800 1.000 0.000 0.000 0.000 0.000
#> GSM38193 2 0.0451 0.957 0.008 0.988 0.000 0.000 0.004
#> GSM38194 4 0.1124 0.816 0.036 0.000 0.000 0.960 0.004
#> GSM38195 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38196 4 0.1341 0.797 0.000 0.000 0.056 0.944 0.000
#> GSM38197 1 0.0000 0.800 1.000 0.000 0.000 0.000 0.000
#> GSM38198 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38199 4 0.1341 0.797 0.000 0.000 0.056 0.944 0.000
#> GSM38200 5 0.3999 0.400 0.000 0.344 0.000 0.000 0.656
#> GSM38201 4 0.0880 0.815 0.000 0.000 0.032 0.968 0.000
#> GSM38202 4 0.0000 0.832 0.000 0.000 0.000 1.000 0.000
#> GSM38203 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> GSM38206 3 0.0000 1.000 0.000 0.000 1.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
#> GSM38155 2 0.0146 0.970 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38156 2 0.0363 0.967 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM38157 2 0.0146 0.970 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38158 5 0.0146 0.996 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38159 2 0.0000 0.970 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM38160 5 0.0146 0.992 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38161 2 0.0146 0.969 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM38162 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38163 1 0.3023 0.815 0.768 0.000 0.000 0.232 0.000 0.000
#> GSM38164 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38165 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38167 4 0.1610 0.869 0.084 0.000 0.000 0.916 0.000 0.000
#> GSM38168 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38169 1 0.3221 0.788 0.736 0.000 0.000 0.264 0.000 0.000
#> GSM38170 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38171 1 0.0146 0.801 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM38172 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38173 1 0.0146 0.801 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM38174 4 0.1267 0.894 0.060 0.000 0.000 0.940 0.000 0.000
#> GSM38175 6 0.0458 0.925 0.016 0.000 0.000 0.000 0.000 0.984
#> GSM38176 1 0.2969 0.819 0.776 0.000 0.000 0.224 0.000 0.000
#> GSM38177 4 0.0146 0.937 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM38178 4 0.3881 0.431 0.396 0.000 0.000 0.600 0.000 0.004
#> GSM38179 1 0.3076 0.809 0.760 0.000 0.000 0.240 0.000 0.000
#> GSM38180 1 0.0000 0.798 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38181 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38182 1 0.0000 0.798 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM38183 1 0.2823 0.827 0.796 0.000 0.000 0.204 0.000 0.000
#> GSM38184 2 0.2340 0.833 0.000 0.852 0.000 0.000 0.148 0.000
#> GSM38185 6 0.0000 0.925 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM38186 1 0.2631 0.830 0.820 0.000 0.000 0.180 0.000 0.000
#> GSM38187 6 0.0508 0.924 0.012 0.000 0.000 0.004 0.000 0.984
#> GSM38188 6 0.4634 0.563 0.264 0.000 0.000 0.080 0.000 0.656
#> GSM38189 4 0.2969 0.702 0.224 0.000 0.000 0.776 0.000 0.000
#> GSM38190 1 0.0363 0.795 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM38191 6 0.0000 0.925 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM38192 6 0.0458 0.925 0.016 0.000 0.000 0.000 0.000 0.984
#> GSM38193 2 0.0291 0.968 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM38194 4 0.1594 0.896 0.052 0.000 0.000 0.932 0.000 0.016
#> GSM38195 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38196 4 0.0363 0.934 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM38197 6 0.0000 0.925 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM38198 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38199 4 0.0363 0.934 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM38200 5 0.0146 0.996 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM38201 4 0.0363 0.934 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM38202 4 0.0000 0.939 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM38203 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38204 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38205 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38206 3 0.0000 1.000 0.000 0.000 1.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:pam 52 2.41e-07 2
#> ATC:pam 50 4.76e-07 3
#> ATC:pam 51 7.81e-09 4
#> ATC:pam 46 4.56e-08 5
#> ATC:pam 51 2.87e-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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.985 0.993 0.5042 0.497 0.497
#> 3 3 0.645 0.707 0.797 0.2369 0.842 0.681
#> 4 4 0.895 0.916 0.959 0.1700 0.834 0.568
#> 5 5 0.730 0.664 0.779 0.0681 0.937 0.768
#> 6 6 0.758 0.728 0.846 0.0651 0.896 0.566
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
#> GSM38155 2 0.000 0.997 0.000 1.000
#> GSM38156 2 0.000 0.997 0.000 1.000
#> GSM38157 2 0.000 0.997 0.000 1.000
#> GSM38158 2 0.000 0.997 0.000 1.000
#> GSM38159 2 0.000 0.997 0.000 1.000
#> GSM38160 2 0.000 0.997 0.000 1.000
#> GSM38161 2 0.000 0.997 0.000 1.000
#> GSM38162 1 0.000 0.990 1.000 0.000
#> GSM38163 1 0.000 0.990 1.000 0.000
#> GSM38164 1 0.000 0.990 1.000 0.000
#> GSM38165 2 0.000 0.997 0.000 1.000
#> GSM38166 2 0.388 0.917 0.076 0.924
#> GSM38167 1 0.000 0.990 1.000 0.000
#> GSM38168 1 0.000 0.990 1.000 0.000
#> GSM38169 1 0.000 0.990 1.000 0.000
#> GSM38170 1 0.000 0.990 1.000 0.000
#> GSM38171 1 0.000 0.990 1.000 0.000
#> GSM38172 1 0.000 0.990 1.000 0.000
#> GSM38173 1 0.000 0.990 1.000 0.000
#> GSM38174 1 0.000 0.990 1.000 0.000
#> GSM38175 1 0.358 0.924 0.932 0.068
#> GSM38176 1 0.000 0.990 1.000 0.000
#> GSM38177 1 0.000 0.990 1.000 0.000
#> GSM38178 1 0.000 0.990 1.000 0.000
#> GSM38179 1 0.000 0.990 1.000 0.000
#> GSM38180 1 0.000 0.990 1.000 0.000
#> GSM38181 2 0.000 0.997 0.000 1.000
#> GSM38182 1 0.000 0.990 1.000 0.000
#> GSM38183 1 0.000 0.990 1.000 0.000
#> GSM38184 2 0.000 0.997 0.000 1.000
#> GSM38185 2 0.000 0.997 0.000 1.000
#> GSM38186 1 0.000 0.990 1.000 0.000
#> GSM38187 2 0.000 0.997 0.000 1.000
#> GSM38188 1 0.000 0.990 1.000 0.000
#> GSM38189 1 0.000 0.990 1.000 0.000
#> GSM38190 1 0.000 0.990 1.000 0.000
#> GSM38191 2 0.000 0.997 0.000 1.000
#> GSM38192 2 0.000 0.997 0.000 1.000
#> GSM38193 2 0.000 0.997 0.000 1.000
#> GSM38194 2 0.000 0.997 0.000 1.000
#> GSM38195 1 0.000 0.990 1.000 0.000
#> GSM38196 1 0.000 0.990 1.000 0.000
#> GSM38197 2 0.000 0.997 0.000 1.000
#> GSM38198 1 0.000 0.990 1.000 0.000
#> GSM38199 1 0.000 0.990 1.000 0.000
#> GSM38200 2 0.000 0.997 0.000 1.000
#> GSM38201 1 0.738 0.738 0.792 0.208
#> GSM38202 1 0.000 0.990 1.000 0.000
#> GSM38203 2 0.000 0.997 0.000 1.000
#> GSM38204 2 0.000 0.997 0.000 1.000
#> GSM38205 2 0.000 0.997 0.000 1.000
#> GSM38206 2 0.000 0.997 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38156 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38157 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38158 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38159 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38160 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38161 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38162 3 0.5138 0.214 0.252 0.000 0.748
#> GSM38163 3 0.1753 0.672 0.048 0.000 0.952
#> GSM38164 3 0.0592 0.708 0.012 0.000 0.988
#> GSM38165 2 0.6659 0.790 0.304 0.668 0.028
#> GSM38166 2 0.7536 0.762 0.304 0.632 0.064
#> GSM38167 1 0.5785 0.881 0.668 0.000 0.332
#> GSM38168 3 0.0000 0.715 0.000 0.000 1.000
#> GSM38169 1 0.5785 0.881 0.668 0.000 0.332
#> GSM38170 1 0.6307 0.722 0.512 0.000 0.488
#> GSM38171 1 0.6451 0.812 0.560 0.004 0.436
#> GSM38172 3 0.0000 0.715 0.000 0.000 1.000
#> GSM38173 1 0.6307 0.722 0.512 0.000 0.488
#> GSM38174 1 0.6225 0.816 0.568 0.000 0.432
#> GSM38175 1 0.5988 0.830 0.688 0.008 0.304
#> GSM38176 1 0.5835 0.884 0.660 0.000 0.340
#> GSM38177 1 0.5835 0.884 0.660 0.000 0.340
#> GSM38178 1 0.5859 0.883 0.656 0.000 0.344
#> GSM38179 3 0.6291 -0.651 0.468 0.000 0.532
#> GSM38180 1 0.6451 0.812 0.560 0.004 0.436
#> GSM38181 2 0.6659 0.790 0.304 0.668 0.028
#> GSM38182 1 0.6274 0.784 0.544 0.000 0.456
#> GSM38183 1 0.5810 0.883 0.664 0.000 0.336
#> GSM38184 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38185 2 0.1163 0.878 0.028 0.972 0.000
#> GSM38186 3 0.6309 -0.733 0.500 0.000 0.500
#> GSM38187 2 0.5785 0.791 0.332 0.668 0.000
#> GSM38188 1 0.6033 0.880 0.660 0.004 0.336
#> GSM38189 3 0.6309 -0.732 0.500 0.000 0.500
#> GSM38190 1 0.5785 0.881 0.668 0.000 0.332
#> GSM38191 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38192 2 0.5455 0.705 0.028 0.788 0.184
#> GSM38193 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38194 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38195 3 0.0000 0.715 0.000 0.000 1.000
#> GSM38196 3 0.0000 0.715 0.000 0.000 1.000
#> GSM38197 2 0.1163 0.878 0.028 0.972 0.000
#> GSM38198 3 0.0000 0.715 0.000 0.000 1.000
#> GSM38199 3 0.0237 0.712 0.000 0.004 0.996
#> GSM38200 2 0.0000 0.884 0.000 1.000 0.000
#> GSM38201 3 0.5291 0.377 0.000 0.268 0.732
#> GSM38202 3 0.0000 0.715 0.000 0.000 1.000
#> GSM38203 2 0.6659 0.790 0.304 0.668 0.028
#> GSM38204 2 0.6659 0.790 0.304 0.668 0.028
#> GSM38205 2 0.6659 0.790 0.304 0.668 0.028
#> GSM38206 2 0.6659 0.790 0.304 0.668 0.028
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0188 0.995 0.000 0.996 0.000 0.004
#> GSM38156 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0188 0.995 0.000 0.996 0.000 0.004
#> GSM38158 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> GSM38159 2 0.0188 0.995 0.000 0.996 0.000 0.004
#> GSM38160 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> GSM38161 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> GSM38162 1 0.4877 0.222 0.592 0.000 0.000 0.408
#> GSM38163 4 0.3610 0.798 0.200 0.000 0.000 0.800
#> GSM38164 4 0.4605 0.600 0.336 0.000 0.000 0.664
#> GSM38165 3 0.0000 0.973 0.000 0.000 1.000 0.000
#> GSM38166 3 0.0000 0.973 0.000 0.000 1.000 0.000
#> GSM38167 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38168 4 0.3074 0.829 0.152 0.000 0.000 0.848
#> GSM38169 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38170 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38171 1 0.0000 0.946 1.000 0.000 0.000 0.000
#> GSM38172 4 0.0469 0.861 0.012 0.000 0.000 0.988
#> GSM38173 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38174 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38175 1 0.2760 0.793 0.872 0.128 0.000 0.000
#> GSM38176 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38177 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38178 1 0.0336 0.950 0.992 0.000 0.000 0.008
#> GSM38179 1 0.2973 0.801 0.856 0.000 0.000 0.144
#> GSM38180 1 0.0000 0.946 1.000 0.000 0.000 0.000
#> GSM38181 3 0.0000 0.973 0.000 0.000 1.000 0.000
#> GSM38182 1 0.0000 0.946 1.000 0.000 0.000 0.000
#> GSM38183 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38184 2 0.0188 0.995 0.000 0.996 0.000 0.004
#> GSM38185 2 0.0188 0.995 0.000 0.996 0.000 0.004
#> GSM38186 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38187 3 0.1302 0.941 0.000 0.044 0.956 0.000
#> GSM38188 1 0.0000 0.946 1.000 0.000 0.000 0.000
#> GSM38189 1 0.0469 0.942 0.988 0.000 0.000 0.012
#> GSM38190 1 0.0469 0.951 0.988 0.000 0.000 0.012
#> GSM38191 2 0.0188 0.994 0.000 0.996 0.000 0.004
#> GSM38192 2 0.1109 0.961 0.028 0.968 0.004 0.000
#> GSM38193 2 0.0188 0.994 0.000 0.996 0.000 0.004
#> GSM38194 2 0.0188 0.994 0.000 0.996 0.000 0.004
#> GSM38195 4 0.4222 0.716 0.272 0.000 0.000 0.728
#> GSM38196 4 0.0336 0.860 0.008 0.000 0.000 0.992
#> GSM38197 2 0.0188 0.994 0.000 0.996 0.004 0.000
#> GSM38198 4 0.1118 0.862 0.036 0.000 0.000 0.964
#> GSM38199 4 0.0336 0.860 0.008 0.000 0.000 0.992
#> GSM38200 2 0.0000 0.995 0.000 1.000 0.000 0.000
#> GSM38201 4 0.1807 0.830 0.008 0.000 0.052 0.940
#> GSM38202 4 0.0336 0.860 0.008 0.000 0.000 0.992
#> GSM38203 3 0.0000 0.973 0.000 0.000 1.000 0.000
#> GSM38204 3 0.0000 0.973 0.000 0.000 1.000 0.000
#> GSM38205 3 0.0000 0.973 0.000 0.000 1.000 0.000
#> GSM38206 3 0.2589 0.864 0.000 0.116 0.884 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.0000 0.6530 0.000 1.000 0.000 0.000 0.000
#> GSM38156 2 0.3491 0.6439 0.000 0.768 0.000 0.004 0.228
#> GSM38157 2 0.0703 0.6599 0.000 0.976 0.000 0.000 0.024
#> GSM38158 2 0.3366 0.6445 0.000 0.768 0.000 0.000 0.232
#> GSM38159 2 0.0162 0.6526 0.000 0.996 0.000 0.000 0.004
#> GSM38160 2 0.3814 0.6125 0.000 0.720 0.000 0.004 0.276
#> GSM38161 2 0.3969 0.5879 0.000 0.692 0.000 0.004 0.304
#> GSM38162 4 0.3752 0.6381 0.292 0.000 0.000 0.708 0.000
#> GSM38163 4 0.4262 0.7684 0.124 0.000 0.000 0.776 0.100
#> GSM38164 4 0.3336 0.7775 0.228 0.000 0.000 0.772 0.000
#> GSM38165 3 0.0000 0.9503 0.000 0.000 1.000 0.000 0.000
#> GSM38166 3 0.0000 0.9503 0.000 0.000 1.000 0.000 0.000
#> GSM38167 1 0.0000 0.7625 1.000 0.000 0.000 0.000 0.000
#> GSM38168 4 0.3424 0.7657 0.240 0.000 0.000 0.760 0.000
#> GSM38169 1 0.0000 0.7625 1.000 0.000 0.000 0.000 0.000
#> GSM38170 1 0.4761 0.7504 0.616 0.000 0.000 0.028 0.356
#> GSM38171 1 0.4276 0.7515 0.616 0.000 0.000 0.004 0.380
#> GSM38172 4 0.1197 0.8515 0.048 0.000 0.000 0.952 0.000
#> GSM38173 1 0.4276 0.7515 0.616 0.000 0.000 0.004 0.380
#> GSM38174 1 0.0162 0.7632 0.996 0.000 0.000 0.000 0.004
#> GSM38175 5 0.4886 -0.6331 0.448 0.024 0.000 0.000 0.528
#> GSM38176 1 0.0000 0.7625 1.000 0.000 0.000 0.000 0.000
#> GSM38177 1 0.0162 0.7632 0.996 0.000 0.000 0.000 0.004
#> GSM38178 1 0.0000 0.7625 1.000 0.000 0.000 0.000 0.000
#> GSM38179 1 0.5154 0.7293 0.580 0.000 0.000 0.048 0.372
#> GSM38180 1 0.4288 0.7490 0.612 0.000 0.000 0.004 0.384
#> GSM38181 3 0.0000 0.9503 0.000 0.000 1.000 0.000 0.000
#> GSM38182 1 0.4276 0.7515 0.616 0.000 0.000 0.004 0.380
#> GSM38183 1 0.0000 0.7625 1.000 0.000 0.000 0.000 0.000
#> GSM38184 2 0.0609 0.6464 0.000 0.980 0.000 0.020 0.000
#> GSM38185 2 0.4269 0.3791 0.000 0.732 0.000 0.036 0.232
#> GSM38186 1 0.4863 0.7506 0.672 0.000 0.000 0.056 0.272
#> GSM38187 3 0.2891 0.8018 0.000 0.000 0.824 0.000 0.176
#> GSM38188 1 0.4304 0.6335 0.516 0.000 0.000 0.000 0.484
#> GSM38189 1 0.4126 0.7525 0.620 0.000 0.000 0.000 0.380
#> GSM38190 1 0.0000 0.7625 1.000 0.000 0.000 0.000 0.000
#> GSM38191 5 0.4276 -0.0331 0.000 0.380 0.000 0.004 0.616
#> GSM38192 2 0.5557 0.3089 0.008 0.668 0.040 0.032 0.252
#> GSM38193 2 0.4517 0.3242 0.000 0.556 0.000 0.008 0.436
#> GSM38194 5 0.4276 -0.0331 0.000 0.380 0.000 0.004 0.616
#> GSM38195 4 0.3707 0.7052 0.284 0.000 0.000 0.716 0.000
#> GSM38196 4 0.1282 0.8490 0.044 0.000 0.004 0.952 0.000
#> GSM38197 5 0.5399 -0.2133 0.000 0.440 0.028 0.016 0.516
#> GSM38198 4 0.1270 0.8524 0.052 0.000 0.000 0.948 0.000
#> GSM38199 4 0.2074 0.8412 0.044 0.000 0.036 0.920 0.000
#> GSM38200 2 0.3790 0.6147 0.000 0.724 0.000 0.004 0.272
#> GSM38201 4 0.3617 0.7672 0.044 0.004 0.128 0.824 0.000
#> GSM38202 4 0.1197 0.8515 0.048 0.000 0.000 0.952 0.000
#> GSM38203 3 0.0000 0.9503 0.000 0.000 1.000 0.000 0.000
#> GSM38204 3 0.0000 0.9503 0.000 0.000 1.000 0.000 0.000
#> GSM38205 3 0.0000 0.9503 0.000 0.000 1.000 0.000 0.000
#> GSM38206 3 0.2773 0.8043 0.000 0.000 0.836 0.000 0.164
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 6 0.3607 0.7598 0.000 0.348 0.000 0.000 0.000 0.652
#> GSM38156 2 0.2527 0.4505 0.000 0.832 0.000 0.000 0.000 0.168
#> GSM38157 6 0.3634 0.7490 0.000 0.356 0.000 0.000 0.000 0.644
#> GSM38158 2 0.3819 -0.1570 0.000 0.624 0.000 0.000 0.004 0.372
#> GSM38159 6 0.3607 0.7598 0.000 0.348 0.000 0.000 0.000 0.652
#> GSM38160 2 0.0935 0.6411 0.000 0.964 0.000 0.000 0.004 0.032
#> GSM38161 2 0.0260 0.6492 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM38162 4 0.2442 0.8601 0.048 0.000 0.000 0.884 0.068 0.000
#> GSM38163 4 0.3766 0.6047 0.256 0.000 0.000 0.720 0.024 0.000
#> GSM38164 4 0.2214 0.8683 0.016 0.000 0.000 0.888 0.096 0.000
#> GSM38165 3 0.0000 0.9583 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38166 3 0.0260 0.9603 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38167 5 0.0865 0.7933 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM38168 4 0.2214 0.8680 0.016 0.000 0.000 0.888 0.096 0.000
#> GSM38169 5 0.0865 0.7933 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM38170 1 0.3832 0.7185 0.776 0.000 0.000 0.120 0.104 0.000
#> GSM38171 1 0.1075 0.8155 0.952 0.000 0.000 0.000 0.048 0.000
#> GSM38172 4 0.0146 0.8969 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM38173 1 0.1910 0.7909 0.892 0.000 0.000 0.000 0.108 0.000
#> GSM38174 5 0.3394 0.7359 0.236 0.000 0.000 0.012 0.752 0.000
#> GSM38175 1 0.1082 0.7764 0.956 0.004 0.000 0.000 0.000 0.040
#> GSM38176 5 0.0865 0.7933 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM38177 5 0.3592 0.6384 0.344 0.000 0.000 0.000 0.656 0.000
#> GSM38178 5 0.3706 0.6377 0.380 0.000 0.000 0.000 0.620 0.000
#> GSM38179 1 0.4556 0.6167 0.688 0.000 0.000 0.212 0.100 0.000
#> GSM38180 1 0.0458 0.8073 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM38181 3 0.0000 0.9583 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM38182 1 0.1204 0.8136 0.944 0.000 0.000 0.000 0.056 0.000
#> GSM38183 5 0.1075 0.7909 0.048 0.000 0.000 0.000 0.952 0.000
#> GSM38184 6 0.3714 0.7581 0.000 0.340 0.000 0.000 0.004 0.656
#> GSM38185 6 0.5280 0.3593 0.036 0.412 0.020 0.004 0.004 0.524
#> GSM38186 1 0.5917 0.0428 0.404 0.000 0.000 0.208 0.388 0.000
#> GSM38187 3 0.2189 0.8914 0.032 0.000 0.904 0.000 0.004 0.060
#> GSM38188 1 0.0458 0.7993 0.984 0.000 0.000 0.000 0.016 0.000
#> GSM38189 1 0.1471 0.8131 0.932 0.000 0.000 0.004 0.064 0.000
#> GSM38190 5 0.3647 0.6621 0.360 0.000 0.000 0.000 0.640 0.000
#> GSM38191 2 0.3984 0.5420 0.000 0.648 0.000 0.000 0.016 0.336
#> GSM38192 6 0.6839 0.3632 0.144 0.316 0.080 0.000 0.004 0.456
#> GSM38193 2 0.1958 0.6477 0.000 0.896 0.000 0.000 0.004 0.100
#> GSM38194 2 0.4064 0.5407 0.000 0.644 0.000 0.000 0.020 0.336
#> GSM38195 4 0.2214 0.8680 0.016 0.000 0.000 0.888 0.096 0.000
#> GSM38196 4 0.0146 0.8969 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM38197 2 0.4484 0.5862 0.036 0.772 0.048 0.004 0.012 0.128
#> GSM38198 4 0.0146 0.8969 0.000 0.000 0.000 0.996 0.004 0.000
#> GSM38199 4 0.0146 0.8959 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM38200 2 0.1644 0.6064 0.000 0.920 0.000 0.000 0.004 0.076
#> GSM38201 4 0.3419 0.7524 0.004 0.040 0.152 0.804 0.000 0.000
#> GSM38202 4 0.0146 0.8959 0.004 0.000 0.000 0.996 0.000 0.000
#> GSM38203 3 0.0260 0.9603 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38204 3 0.0260 0.9603 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38205 3 0.0260 0.9603 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38206 3 0.2765 0.8205 0.000 0.132 0.848 0.000 0.004 0.016
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) k
#> ATC:mclust 52 1.57e-03 2
#> ATC:mclust 47 1.13e-02 3
#> ATC:mclust 51 5.74e-06 4
#> ATC:mclust 45 3.85e-08 5
#> ATC:mclust 47 4.74e-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", "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 21168 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.983 0.992 0.3422 0.660 0.660
#> 3 3 0.461 0.738 0.838 0.5342 0.904 0.855
#> 4 4 0.551 0.656 0.815 0.3130 0.716 0.507
#> 5 5 0.599 0.711 0.805 0.0969 0.798 0.449
#> 6 6 0.569 0.630 0.807 0.0275 0.974 0.894
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
#> GSM38155 2 0.000 0.984 0.000 1.000
#> GSM38156 2 0.000 0.984 0.000 1.000
#> GSM38157 2 0.000 0.984 0.000 1.000
#> GSM38158 2 0.000 0.984 0.000 1.000
#> GSM38159 2 0.000 0.984 0.000 1.000
#> GSM38160 2 0.000 0.984 0.000 1.000
#> GSM38161 2 0.000 0.984 0.000 1.000
#> GSM38162 1 0.000 0.994 1.000 0.000
#> GSM38163 1 0.000 0.994 1.000 0.000
#> GSM38164 1 0.000 0.994 1.000 0.000
#> GSM38165 1 0.000 0.994 1.000 0.000
#> GSM38166 1 0.000 0.994 1.000 0.000
#> GSM38167 1 0.000 0.994 1.000 0.000
#> GSM38168 1 0.000 0.994 1.000 0.000
#> GSM38169 1 0.000 0.994 1.000 0.000
#> GSM38170 1 0.000 0.994 1.000 0.000
#> GSM38171 1 0.000 0.994 1.000 0.000
#> GSM38172 1 0.000 0.994 1.000 0.000
#> GSM38173 1 0.000 0.994 1.000 0.000
#> GSM38174 1 0.000 0.994 1.000 0.000
#> GSM38175 1 0.373 0.923 0.928 0.072
#> GSM38176 1 0.000 0.994 1.000 0.000
#> GSM38177 1 0.000 0.994 1.000 0.000
#> GSM38178 1 0.000 0.994 1.000 0.000
#> GSM38179 1 0.000 0.994 1.000 0.000
#> GSM38180 1 0.000 0.994 1.000 0.000
#> GSM38181 1 0.000 0.994 1.000 0.000
#> GSM38182 1 0.000 0.994 1.000 0.000
#> GSM38183 1 0.000 0.994 1.000 0.000
#> GSM38184 2 0.000 0.984 0.000 1.000
#> GSM38185 2 0.625 0.812 0.156 0.844
#> GSM38186 1 0.000 0.994 1.000 0.000
#> GSM38187 1 0.000 0.994 1.000 0.000
#> GSM38188 1 0.000 0.994 1.000 0.000
#> GSM38189 1 0.000 0.994 1.000 0.000
#> GSM38190 1 0.000 0.994 1.000 0.000
#> GSM38191 1 0.163 0.972 0.976 0.024
#> GSM38192 1 0.118 0.980 0.984 0.016
#> GSM38193 2 0.000 0.984 0.000 1.000
#> GSM38194 1 0.000 0.994 1.000 0.000
#> GSM38195 1 0.000 0.994 1.000 0.000
#> GSM38196 1 0.000 0.994 1.000 0.000
#> GSM38197 1 0.574 0.845 0.864 0.136
#> GSM38198 1 0.000 0.994 1.000 0.000
#> GSM38199 1 0.000 0.994 1.000 0.000
#> GSM38200 2 0.000 0.984 0.000 1.000
#> GSM38201 1 0.000 0.994 1.000 0.000
#> GSM38202 1 0.000 0.994 1.000 0.000
#> GSM38203 1 0.000 0.994 1.000 0.000
#> GSM38204 1 0.000 0.994 1.000 0.000
#> GSM38205 1 0.000 0.994 1.000 0.000
#> GSM38206 1 0.000 0.994 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM38155 2 0.0237 0.844 0.000 0.996 0.004
#> GSM38156 2 0.0237 0.844 0.000 0.996 0.004
#> GSM38157 2 0.0000 0.844 0.000 1.000 0.000
#> GSM38158 2 0.0237 0.843 0.000 0.996 0.004
#> GSM38159 2 0.2663 0.795 0.024 0.932 0.044
#> GSM38160 2 0.6008 0.384 0.000 0.628 0.372
#> GSM38161 2 0.6295 0.131 0.000 0.528 0.472
#> GSM38162 1 0.3340 0.822 0.880 0.000 0.120
#> GSM38163 1 0.2537 0.829 0.920 0.000 0.080
#> GSM38164 1 0.3482 0.822 0.872 0.000 0.128
#> GSM38165 1 0.5785 0.714 0.668 0.000 0.332
#> GSM38166 1 0.5785 0.716 0.668 0.000 0.332
#> GSM38167 1 0.1964 0.810 0.944 0.000 0.056
#> GSM38168 1 0.4002 0.813 0.840 0.000 0.160
#> GSM38169 1 0.1753 0.813 0.952 0.000 0.048
#> GSM38170 1 0.0592 0.825 0.988 0.000 0.012
#> GSM38171 1 0.1964 0.809 0.944 0.000 0.056
#> GSM38172 1 0.4796 0.792 0.780 0.000 0.220
#> GSM38173 1 0.1411 0.815 0.964 0.000 0.036
#> GSM38174 1 0.1860 0.825 0.948 0.000 0.052
#> GSM38175 1 0.5471 0.690 0.812 0.128 0.060
#> GSM38176 1 0.2711 0.794 0.912 0.000 0.088
#> GSM38177 1 0.2066 0.807 0.940 0.000 0.060
#> GSM38178 1 0.1411 0.817 0.964 0.000 0.036
#> GSM38179 1 0.1411 0.827 0.964 0.000 0.036
#> GSM38180 1 0.2165 0.811 0.936 0.000 0.064
#> GSM38181 1 0.5733 0.721 0.676 0.000 0.324
#> GSM38182 1 0.1964 0.830 0.944 0.000 0.056
#> GSM38183 1 0.2625 0.796 0.916 0.000 0.084
#> GSM38184 2 0.1031 0.831 0.000 0.976 0.024
#> GSM38185 2 0.4749 0.713 0.012 0.816 0.172
#> GSM38186 1 0.1860 0.812 0.948 0.000 0.052
#> GSM38187 1 0.5785 0.713 0.668 0.000 0.332
#> GSM38188 1 0.1999 0.811 0.952 0.012 0.036
#> GSM38189 1 0.1964 0.829 0.944 0.000 0.056
#> GSM38190 1 0.2537 0.798 0.920 0.000 0.080
#> GSM38191 3 0.4660 0.668 0.072 0.072 0.856
#> GSM38192 1 0.6091 0.706 0.784 0.124 0.092
#> GSM38193 3 0.6215 -0.129 0.000 0.428 0.572
#> GSM38194 3 0.5072 0.605 0.196 0.012 0.792
#> GSM38195 1 0.3879 0.813 0.848 0.000 0.152
#> GSM38196 1 0.5291 0.766 0.732 0.000 0.268
#> GSM38197 3 0.4058 0.616 0.044 0.076 0.880
#> GSM38198 1 0.4887 0.768 0.772 0.000 0.228
#> GSM38199 1 0.5650 0.735 0.688 0.000 0.312
#> GSM38200 2 0.0424 0.843 0.000 0.992 0.008
#> GSM38201 1 0.5882 0.701 0.652 0.000 0.348
#> GSM38202 1 0.4887 0.782 0.772 0.000 0.228
#> GSM38203 1 0.5859 0.705 0.656 0.000 0.344
#> GSM38204 1 0.5859 0.705 0.656 0.000 0.344
#> GSM38205 1 0.5859 0.705 0.656 0.000 0.344
#> GSM38206 1 0.5926 0.693 0.644 0.000 0.356
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM38155 2 0.0000 0.9262 0.000 1.000 0.000 0.000
#> GSM38156 2 0.0000 0.9262 0.000 1.000 0.000 0.000
#> GSM38157 2 0.0000 0.9262 0.000 1.000 0.000 0.000
#> GSM38158 2 0.0188 0.9250 0.000 0.996 0.000 0.004
#> GSM38159 2 0.3557 0.8083 0.108 0.856 0.000 0.036
#> GSM38160 4 0.4746 0.6086 0.000 0.368 0.000 0.632
#> GSM38161 4 0.4746 0.5959 0.000 0.368 0.000 0.632
#> GSM38162 1 0.6206 0.5983 0.632 0.000 0.280 0.088
#> GSM38163 3 0.5478 -0.0372 0.444 0.000 0.540 0.016
#> GSM38164 1 0.6326 0.4297 0.556 0.000 0.376 0.068
#> GSM38165 3 0.0672 0.7512 0.008 0.000 0.984 0.008
#> GSM38166 3 0.0779 0.7521 0.016 0.000 0.980 0.004
#> GSM38167 1 0.2399 0.7765 0.920 0.000 0.032 0.048
#> GSM38168 1 0.6924 0.4259 0.536 0.000 0.340 0.124
#> GSM38169 1 0.2021 0.7805 0.936 0.000 0.040 0.024
#> GSM38170 1 0.3907 0.7113 0.768 0.000 0.232 0.000
#> GSM38171 1 0.3474 0.7561 0.868 0.000 0.068 0.064
#> GSM38172 3 0.6791 0.0420 0.392 0.000 0.508 0.100
#> GSM38173 1 0.3486 0.7754 0.864 0.000 0.092 0.044
#> GSM38174 1 0.4452 0.7518 0.796 0.000 0.156 0.048
#> GSM38175 1 0.5241 0.5475 0.760 0.164 0.008 0.068
#> GSM38176 1 0.1022 0.7572 0.968 0.000 0.000 0.032
#> GSM38177 1 0.2882 0.7843 0.892 0.000 0.084 0.024
#> GSM38178 1 0.3367 0.7797 0.864 0.000 0.108 0.028
#> GSM38179 1 0.5312 0.6703 0.692 0.000 0.268 0.040
#> GSM38180 1 0.4514 0.7399 0.800 0.000 0.136 0.064
#> GSM38181 3 0.0672 0.7512 0.008 0.000 0.984 0.008
#> GSM38182 1 0.5182 0.6420 0.684 0.000 0.288 0.028
#> GSM38183 1 0.0895 0.7561 0.976 0.000 0.004 0.020
#> GSM38184 2 0.2207 0.8794 0.024 0.932 0.004 0.040
#> GSM38185 2 0.4460 0.7518 0.032 0.808 0.012 0.148
#> GSM38186 1 0.1256 0.7642 0.964 0.000 0.008 0.028
#> GSM38187 3 0.1004 0.7470 0.004 0.000 0.972 0.024
#> GSM38188 1 0.3561 0.7754 0.876 0.040 0.068 0.016
#> GSM38189 1 0.5279 0.4355 0.588 0.000 0.400 0.012
#> GSM38190 1 0.2197 0.7826 0.928 0.000 0.048 0.024
#> GSM38191 4 0.2846 0.7243 0.028 0.052 0.012 0.908
#> GSM38192 3 0.8975 0.0208 0.228 0.316 0.392 0.064
#> GSM38193 4 0.3486 0.7263 0.000 0.188 0.000 0.812
#> GSM38194 4 0.2011 0.6814 0.080 0.000 0.000 0.920
#> GSM38195 3 0.6504 -0.1467 0.452 0.000 0.476 0.072
#> GSM38196 3 0.6837 0.2104 0.340 0.000 0.544 0.116
#> GSM38197 4 0.6547 0.5952 0.000 0.124 0.260 0.616
#> GSM38198 1 0.7001 0.5698 0.580 0.000 0.224 0.196
#> GSM38199 3 0.2376 0.7275 0.068 0.000 0.916 0.016
#> GSM38200 2 0.0336 0.9219 0.000 0.992 0.000 0.008
#> GSM38201 3 0.1520 0.7491 0.024 0.000 0.956 0.020
#> GSM38202 3 0.5221 0.5403 0.208 0.000 0.732 0.060
#> GSM38203 3 0.0524 0.7473 0.004 0.000 0.988 0.008
#> GSM38204 3 0.0376 0.7484 0.004 0.000 0.992 0.004
#> GSM38205 3 0.0376 0.7484 0.004 0.000 0.992 0.004
#> GSM38206 3 0.0779 0.7444 0.004 0.000 0.980 0.016
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM38155 2 0.4481 0.3718 0.416 0.576 0.000 0.000 0.008
#> GSM38156 2 0.0451 0.8110 0.008 0.988 0.000 0.000 0.004
#> GSM38157 2 0.3039 0.7554 0.152 0.836 0.000 0.000 0.012
#> GSM38158 2 0.0609 0.8111 0.020 0.980 0.000 0.000 0.000
#> GSM38159 1 0.2676 0.6131 0.884 0.080 0.000 0.000 0.036
#> GSM38160 5 0.3728 0.7238 0.008 0.244 0.000 0.000 0.748
#> GSM38161 5 0.4163 0.7250 0.032 0.228 0.000 0.000 0.740
#> GSM38162 4 0.2783 0.8138 0.004 0.000 0.116 0.868 0.012
#> GSM38163 1 0.6282 0.3380 0.496 0.000 0.340 0.164 0.000
#> GSM38164 4 0.3355 0.7856 0.000 0.000 0.184 0.804 0.012
#> GSM38165 3 0.0671 0.8954 0.004 0.000 0.980 0.016 0.000
#> GSM38166 3 0.1704 0.8680 0.004 0.000 0.928 0.068 0.000
#> GSM38167 4 0.1168 0.7961 0.032 0.000 0.000 0.960 0.008
#> GSM38168 4 0.3619 0.8100 0.008 0.000 0.124 0.828 0.040
#> GSM38169 4 0.1831 0.7804 0.076 0.000 0.000 0.920 0.004
#> GSM38170 4 0.3497 0.8104 0.048 0.000 0.112 0.836 0.004
#> GSM38171 1 0.4170 0.6407 0.712 0.000 0.012 0.272 0.004
#> GSM38172 4 0.3551 0.7991 0.000 0.000 0.136 0.820 0.044
#> GSM38173 4 0.4613 0.3516 0.360 0.000 0.020 0.620 0.000
#> GSM38174 4 0.1202 0.8128 0.004 0.004 0.032 0.960 0.000
#> GSM38175 1 0.1525 0.6741 0.948 0.012 0.000 0.036 0.004
#> GSM38176 1 0.3895 0.6705 0.728 0.000 0.004 0.264 0.004
#> GSM38177 4 0.2178 0.7986 0.048 0.000 0.008 0.920 0.024
#> GSM38178 4 0.1404 0.7994 0.008 0.004 0.004 0.956 0.028
#> GSM38179 1 0.4805 0.6682 0.728 0.000 0.128 0.144 0.000
#> GSM38180 1 0.2900 0.7079 0.864 0.000 0.028 0.108 0.000
#> GSM38181 3 0.0510 0.8952 0.000 0.000 0.984 0.016 0.000
#> GSM38182 4 0.3221 0.8095 0.008 0.016 0.060 0.876 0.040
#> GSM38183 4 0.4562 -0.0959 0.444 0.000 0.004 0.548 0.004
#> GSM38184 2 0.3888 0.7484 0.108 0.828 0.004 0.020 0.040
#> GSM38185 1 0.5291 0.4917 0.716 0.124 0.020 0.000 0.140
#> GSM38186 1 0.4367 0.3776 0.580 0.000 0.000 0.416 0.004
#> GSM38187 3 0.3857 0.4638 0.312 0.000 0.688 0.000 0.000
#> GSM38188 4 0.4812 0.7259 0.064 0.096 0.016 0.788 0.036
#> GSM38189 4 0.3723 0.8016 0.004 0.004 0.160 0.808 0.024
#> GSM38190 4 0.1809 0.7863 0.060 0.000 0.000 0.928 0.012
#> GSM38191 5 0.1461 0.8034 0.004 0.016 0.000 0.028 0.952
#> GSM38192 1 0.2916 0.6600 0.884 0.000 0.048 0.012 0.056
#> GSM38193 5 0.1732 0.8081 0.000 0.080 0.000 0.000 0.920
#> GSM38194 5 0.1430 0.7885 0.004 0.000 0.000 0.052 0.944
#> GSM38195 4 0.3583 0.7968 0.016 0.000 0.168 0.808 0.008
#> GSM38196 4 0.4558 0.7346 0.000 0.000 0.216 0.724 0.060
#> GSM38197 5 0.6226 0.6078 0.084 0.060 0.224 0.000 0.632
#> GSM38198 4 0.3886 0.8052 0.020 0.000 0.068 0.828 0.084
#> GSM38199 3 0.3521 0.6393 0.000 0.000 0.764 0.232 0.004
#> GSM38200 2 0.0807 0.8063 0.012 0.976 0.000 0.000 0.012
#> GSM38201 3 0.2352 0.8447 0.004 0.000 0.896 0.092 0.008
#> GSM38202 4 0.4707 0.4701 0.000 0.000 0.392 0.588 0.020
#> GSM38203 3 0.0727 0.8944 0.004 0.000 0.980 0.012 0.004
#> GSM38204 3 0.0486 0.8877 0.004 0.000 0.988 0.004 0.004
#> GSM38205 3 0.0566 0.8949 0.000 0.000 0.984 0.012 0.004
#> GSM38206 3 0.0566 0.8949 0.000 0.000 0.984 0.012 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM38155 2 0.4798 0.352 0.376 0.564 0.000 0.000 0.000 0.060
#> GSM38156 2 0.1693 0.594 0.020 0.936 0.000 0.000 0.012 0.032
#> GSM38157 2 0.3872 0.517 0.264 0.712 0.004 0.000 0.000 0.020
#> GSM38158 2 0.2320 0.492 0.004 0.864 0.000 0.000 0.000 0.132
#> GSM38159 1 0.1873 0.563 0.924 0.048 0.000 0.000 0.008 0.020
#> GSM38160 5 0.3945 0.612 0.000 0.200 0.004 0.000 0.748 0.048
#> GSM38161 5 0.3947 0.652 0.016 0.112 0.000 0.000 0.788 0.084
#> GSM38162 4 0.3486 0.815 0.000 0.000 0.116 0.820 0.016 0.048
#> GSM38163 1 0.7185 0.206 0.404 0.000 0.336 0.176 0.016 0.068
#> GSM38164 4 0.4256 0.771 0.000 0.000 0.176 0.748 0.020 0.056
#> GSM38165 3 0.0260 0.824 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38166 3 0.2389 0.750 0.000 0.000 0.864 0.128 0.000 0.008
#> GSM38167 4 0.0909 0.815 0.012 0.000 0.000 0.968 0.000 0.020
#> GSM38168 4 0.3099 0.829 0.000 0.000 0.096 0.848 0.012 0.044
#> GSM38169 4 0.1908 0.802 0.028 0.000 0.000 0.916 0.000 0.056
#> GSM38170 4 0.2456 0.832 0.008 0.000 0.076 0.888 0.000 0.028
#> GSM38171 1 0.5137 0.567 0.668 0.004 0.012 0.192 0.000 0.124
#> GSM38172 4 0.3140 0.824 0.000 0.000 0.108 0.844 0.024 0.024
#> GSM38173 1 0.5307 0.190 0.476 0.008 0.008 0.452 0.000 0.056
#> GSM38174 4 0.1294 0.819 0.008 0.000 0.008 0.956 0.004 0.024
#> GSM38175 1 0.2706 0.540 0.832 0.000 0.000 0.000 0.008 0.160
#> GSM38176 1 0.5033 0.538 0.644 0.000 0.000 0.260 0.016 0.080
#> GSM38177 4 0.2742 0.797 0.012 0.000 0.008 0.852 0.000 0.128
#> GSM38178 4 0.0717 0.816 0.008 0.000 0.000 0.976 0.000 0.016
#> GSM38179 1 0.5902 0.500 0.632 0.000 0.120 0.148 0.000 0.100
#> GSM38180 1 0.2562 0.609 0.896 0.008 0.016 0.048 0.000 0.032
#> GSM38181 3 0.0837 0.821 0.004 0.000 0.972 0.020 0.000 0.004
#> GSM38182 4 0.3546 0.805 0.016 0.044 0.024 0.840 0.000 0.076
#> GSM38183 4 0.6140 0.123 0.232 0.000 0.000 0.524 0.024 0.220
#> GSM38184 6 0.3298 0.000 0.008 0.236 0.000 0.000 0.000 0.756
#> GSM38185 1 0.3921 0.453 0.792 0.144 0.008 0.000 0.028 0.028
#> GSM38186 1 0.4956 0.508 0.624 0.008 0.008 0.308 0.000 0.052
#> GSM38187 3 0.3531 0.404 0.328 0.000 0.672 0.000 0.000 0.000
#> GSM38188 4 0.5616 0.533 0.044 0.236 0.004 0.628 0.000 0.088
#> GSM38189 4 0.4518 0.797 0.020 0.048 0.076 0.780 0.000 0.076
#> GSM38190 4 0.2549 0.791 0.036 0.008 0.000 0.884 0.000 0.072
#> GSM38191 5 0.0363 0.742 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM38192 1 0.2488 0.568 0.900 0.000 0.036 0.004 0.024 0.036
#> GSM38193 5 0.1237 0.741 0.004 0.020 0.000 0.000 0.956 0.020
#> GSM38194 5 0.0508 0.740 0.000 0.000 0.000 0.004 0.984 0.012
#> GSM38195 4 0.2765 0.828 0.004 0.000 0.104 0.864 0.004 0.024
#> GSM38196 4 0.4555 0.751 0.000 0.000 0.184 0.720 0.080 0.016
#> GSM38197 5 0.6309 0.232 0.092 0.036 0.404 0.000 0.452 0.016
#> GSM38198 4 0.3649 0.817 0.000 0.000 0.056 0.820 0.092 0.032
#> GSM38199 3 0.4002 0.189 0.000 0.000 0.588 0.404 0.000 0.008
#> GSM38200 2 0.1313 0.575 0.000 0.952 0.004 0.000 0.016 0.028
#> GSM38201 3 0.3089 0.687 0.000 0.000 0.800 0.188 0.004 0.008
#> GSM38202 4 0.3855 0.748 0.000 0.000 0.216 0.748 0.012 0.024
#> GSM38203 3 0.0260 0.824 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM38204 3 0.0520 0.819 0.008 0.000 0.984 0.008 0.000 0.000
#> GSM38205 3 0.0363 0.825 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM38206 3 0.0363 0.825 0.000 0.000 0.988 0.012 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:NMF 52 2.41e-07 2
#> ATC:NMF 49 6.40e-06 3
#> ATC:NMF 44 5.95e-07 4
#> ATC:NMF 44 1.69e-05 5
#> ATC:NMF 42 4.60e-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.
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