Date: 2019-12-25 21:09:50 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 51882 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] 51882 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:hclust | 2 | 1.000 | 0.964 | 0.984 | ** | |
SD:kmeans | 3 | 1.000 | 0.995 | 0.995 | ** | 2 |
SD:skmeans | 3 | 1.000 | 0.978 | 0.990 | ** | 2 |
CV:hclust | 2 | 1.000 | 0.964 | 0.985 | ** | |
CV:kmeans | 3 | 1.000 | 0.985 | 0.990 | ** | 2 |
MAD:hclust | 2 | 1.000 | 0.965 | 0.984 | ** | |
MAD:kmeans | 3 | 1.000 | 0.977 | 0.988 | ** | |
MAD:skmeans | 3 | 1.000 | 0.963 | 0.987 | ** | 2 |
ATC:kmeans | 3 | 1.000 | 0.964 | 0.988 | ** | 2 |
ATC:skmeans | 2 | 1.000 | 0.991 | 0.996 | ** | |
ATC:NMF | 2 | 1.000 | 0.967 | 0.987 | ** | |
CV:skmeans | 3 | 0.969 | 0.957 | 0.982 | ** | 2 |
MAD:NMF | 3 | 0.969 | 0.937 | 0.974 | ** | |
ATC:pam | 4 | 0.966 | 0.926 | 0.963 | ** | 2,3 |
SD:NMF | 2 | 0.959 | 0.938 | 0.975 | ** | |
SD:mclust | 3 | 0.958 | 0.915 | 0.953 | ** | |
CV:NMF | 3 | 0.950 | 0.919 | 0.969 | * | 2 |
ATC:mclust | 2 | 0.919 | 0.945 | 0.977 | * | |
MAD:pam | 2 | 0.919 | 0.927 | 0.970 | * | |
ATC:hclust | 5 | 0.910 | 0.907 | 0.967 | * | 3 |
MAD:mclust | 3 | 0.832 | 0.943 | 0.969 | ||
SD:pam | 3 | 0.659 | 0.816 | 0.912 | ||
CV:pam | 3 | 0.646 | 0.796 | 0.911 | ||
CV:mclust | 3 | 0.596 | 0.747 | 0.875 |
**: 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.959 0.938 0.975 0.364 0.660 0.660
#> CV:NMF 2 0.959 0.955 0.981 0.384 0.618 0.618
#> MAD:NMF 2 0.845 0.895 0.959 0.401 0.618 0.618
#> ATC:NMF 2 1.000 0.967 0.987 0.429 0.581 0.581
#> SD:skmeans 2 1.000 0.980 0.991 0.491 0.509 0.509
#> CV:skmeans 2 1.000 0.975 0.989 0.487 0.517 0.517
#> MAD:skmeans 2 1.000 0.946 0.979 0.500 0.497 0.497
#> ATC:skmeans 2 1.000 0.991 0.996 0.416 0.581 0.581
#> SD:mclust 2 0.597 0.887 0.946 0.384 0.638 0.638
#> CV:mclust 2 0.881 0.893 0.958 0.355 0.638 0.638
#> MAD:mclust 2 0.880 0.890 0.955 0.367 0.660 0.660
#> ATC:mclust 2 0.919 0.945 0.977 0.470 0.527 0.527
#> SD:kmeans 2 1.000 0.999 1.000 0.318 0.683 0.683
#> CV:kmeans 2 0.960 0.977 0.988 0.329 0.683 0.683
#> MAD:kmeans 2 0.726 0.859 0.870 0.376 0.683 0.683
#> ATC:kmeans 2 1.000 1.000 1.000 0.317 0.683 0.683
#> SD:pam 2 0.885 0.945 0.976 0.344 0.683 0.683
#> CV:pam 2 0.885 0.953 0.978 0.341 0.683 0.683
#> MAD:pam 2 0.919 0.927 0.970 0.365 0.660 0.660
#> ATC:pam 2 1.000 0.999 1.000 0.267 0.735 0.735
#> SD:hclust 2 1.000 0.964 0.984 0.329 0.683 0.683
#> CV:hclust 2 1.000 0.964 0.985 0.330 0.683 0.683
#> MAD:hclust 2 1.000 0.965 0.984 0.333 0.683 0.683
#> ATC:hclust 2 0.823 0.895 0.959 0.265 0.792 0.792
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.894 0.922 0.966 0.741 0.697 0.546
#> CV:NMF 3 0.950 0.919 0.969 0.660 0.726 0.564
#> MAD:NMF 3 0.969 0.937 0.974 0.585 0.716 0.549
#> ATC:NMF 3 0.572 0.609 0.771 0.322 0.833 0.723
#> SD:skmeans 3 1.000 0.978 0.990 0.300 0.793 0.617
#> CV:skmeans 3 0.969 0.957 0.982 0.296 0.796 0.627
#> MAD:skmeans 3 1.000 0.963 0.987 0.282 0.796 0.614
#> ATC:skmeans 3 0.675 0.696 0.869 0.272 0.973 0.953
#> SD:mclust 3 0.958 0.915 0.953 0.632 0.701 0.545
#> CV:mclust 3 0.596 0.747 0.875 0.787 0.707 0.548
#> MAD:mclust 3 0.832 0.943 0.969 0.707 0.697 0.548
#> ATC:mclust 3 0.514 0.622 0.794 0.258 0.974 0.951
#> SD:kmeans 3 1.000 0.995 0.995 0.956 0.695 0.553
#> CV:kmeans 3 1.000 0.985 0.990 0.880 0.695 0.553
#> MAD:kmeans 3 1.000 0.977 0.988 0.655 0.695 0.553
#> ATC:kmeans 3 1.000 0.964 0.988 0.407 0.827 0.753
#> SD:pam 3 0.659 0.816 0.912 0.738 0.716 0.584
#> CV:pam 3 0.646 0.796 0.911 0.791 0.686 0.541
#> MAD:pam 3 0.622 0.764 0.881 0.699 0.667 0.508
#> ATC:pam 3 1.000 0.958 0.983 0.448 0.894 0.856
#> SD:hclust 3 0.596 0.652 0.800 0.757 0.837 0.762
#> CV:hclust 3 0.548 0.670 0.851 0.840 0.674 0.523
#> MAD:hclust 3 0.589 0.722 0.869 0.845 0.649 0.492
#> ATC:hclust 3 0.965 0.977 0.989 0.423 0.845 0.805
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.774 0.736 0.872 0.0954 0.946 0.855
#> CV:NMF 4 0.745 0.737 0.880 0.0985 0.900 0.744
#> MAD:NMF 4 0.637 0.788 0.839 0.1090 0.971 0.921
#> ATC:NMF 4 0.462 0.475 0.683 0.1437 0.825 0.651
#> SD:skmeans 4 0.798 0.836 0.897 0.1860 0.855 0.613
#> CV:skmeans 4 0.798 0.869 0.911 0.1962 0.864 0.636
#> MAD:skmeans 4 0.871 0.927 0.939 0.1840 0.846 0.587
#> ATC:skmeans 4 0.613 0.737 0.846 0.0979 0.936 0.885
#> SD:mclust 4 0.520 0.546 0.771 0.0857 0.854 0.677
#> CV:mclust 4 0.568 0.552 0.771 0.1179 0.821 0.573
#> MAD:mclust 4 0.823 0.833 0.867 0.0674 1.000 1.000
#> ATC:mclust 4 0.440 0.544 0.756 0.1877 0.738 0.493
#> SD:kmeans 4 0.650 0.565 0.816 0.1481 0.946 0.856
#> CV:kmeans 4 0.678 0.547 0.813 0.1518 0.946 0.856
#> MAD:kmeans 4 0.687 0.744 0.806 0.1661 0.872 0.661
#> ATC:kmeans 4 0.872 0.738 0.890 0.1553 0.973 0.950
#> SD:pam 4 0.498 0.634 0.772 0.1739 0.817 0.575
#> CV:pam 4 0.586 0.471 0.746 0.1629 0.820 0.564
#> MAD:pam 4 0.730 0.792 0.846 0.1957 0.772 0.457
#> ATC:pam 4 0.966 0.926 0.963 0.2693 0.872 0.801
#> SD:hclust 4 0.514 0.613 0.735 0.1379 0.793 0.605
#> CV:hclust 4 0.553 0.524 0.757 0.1027 0.987 0.964
#> MAD:hclust 4 0.632 0.795 0.860 0.1390 0.828 0.571
#> ATC:hclust 4 0.933 0.946 0.968 0.0693 0.995 0.993
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.744 0.753 0.867 0.0783 0.903 0.717
#> CV:NMF 5 0.731 0.722 0.861 0.0780 0.928 0.778
#> MAD:NMF 5 0.611 0.519 0.727 0.0781 0.866 0.639
#> ATC:NMF 5 0.459 0.429 0.719 0.0866 0.819 0.584
#> SD:skmeans 5 0.775 0.756 0.827 0.0573 0.952 0.803
#> CV:skmeans 5 0.773 0.637 0.814 0.0534 0.946 0.783
#> MAD:skmeans 5 0.802 0.779 0.814 0.0542 0.980 0.921
#> ATC:skmeans 5 0.535 0.669 0.804 0.0801 0.956 0.910
#> SD:mclust 5 0.561 0.510 0.717 0.0990 0.778 0.471
#> CV:mclust 5 0.566 0.442 0.719 0.0765 0.807 0.470
#> MAD:mclust 5 0.685 0.813 0.855 0.0588 0.950 0.868
#> ATC:mclust 5 0.537 0.420 0.705 0.0882 0.837 0.489
#> SD:kmeans 5 0.629 0.563 0.743 0.0809 0.848 0.563
#> CV:kmeans 5 0.635 0.494 0.731 0.0811 0.860 0.587
#> MAD:kmeans 5 0.662 0.657 0.793 0.0766 0.958 0.836
#> ATC:kmeans 5 0.653 0.800 0.880 0.3169 0.751 0.524
#> SD:pam 5 0.689 0.726 0.843 0.0951 0.884 0.625
#> CV:pam 5 0.639 0.534 0.758 0.0931 0.843 0.521
#> MAD:pam 5 0.686 0.755 0.855 0.0534 0.957 0.833
#> ATC:pam 5 0.822 0.914 0.947 0.0556 0.994 0.989
#> SD:hclust 5 0.534 0.665 0.779 0.0574 0.864 0.626
#> CV:hclust 5 0.551 0.456 0.723 0.0507 0.951 0.859
#> MAD:hclust 5 0.707 0.788 0.881 0.0458 0.963 0.873
#> ATC:hclust 5 0.910 0.907 0.967 0.2889 0.842 0.750
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.710 0.734 0.857 0.0512 0.949 0.815
#> CV:NMF 6 0.719 0.690 0.854 0.0583 0.905 0.659
#> MAD:NMF 6 0.647 0.627 0.800 0.0467 0.947 0.794
#> ATC:NMF 6 0.498 0.499 0.711 0.0665 0.890 0.681
#> SD:skmeans 6 0.776 0.649 0.780 0.0277 0.940 0.715
#> CV:skmeans 6 0.784 0.716 0.803 0.0315 0.928 0.671
#> MAD:skmeans 6 0.811 0.735 0.816 0.0298 0.952 0.803
#> ATC:skmeans 6 0.583 0.321 0.730 0.0584 0.913 0.806
#> SD:mclust 6 0.580 0.411 0.619 0.0630 0.910 0.649
#> CV:mclust 6 0.622 0.536 0.724 0.0617 0.829 0.415
#> MAD:mclust 6 0.636 0.604 0.708 0.0951 0.875 0.630
#> ATC:mclust 6 0.626 0.623 0.763 0.0456 0.860 0.461
#> SD:kmeans 6 0.658 0.488 0.717 0.0477 0.939 0.744
#> CV:kmeans 6 0.648 0.472 0.701 0.0417 0.944 0.758
#> MAD:kmeans 6 0.701 0.557 0.755 0.0426 0.977 0.900
#> ATC:kmeans 6 0.764 0.788 0.875 0.0725 0.981 0.934
#> SD:pam 6 0.674 0.618 0.800 0.0452 0.925 0.686
#> CV:pam 6 0.675 0.411 0.703 0.0391 0.873 0.513
#> MAD:pam 6 0.755 0.662 0.826 0.0579 0.901 0.597
#> ATC:pam 6 0.750 0.900 0.929 0.0252 0.998 0.996
#> SD:hclust 6 0.601 0.668 0.776 0.0892 0.916 0.715
#> CV:hclust 6 0.552 0.589 0.708 0.0730 0.772 0.416
#> MAD:hclust 6 0.721 0.747 0.883 0.0501 0.980 0.925
#> ATC:hclust 6 0.832 0.839 0.938 0.0321 0.996 0.992
Following heatmap plots the partition for each combination of methods and the lightness correspond to the silhouette scores for samples in each method. On top the consensus subgroup is inferred from all methods by taking the mean silhouette scores as weight.
collect_stats(res_list, k = 2)
collect_stats(res_list, k = 3)
collect_stats(res_list, k = 4)
collect_stats(res_list, k = 5)
collect_stats(res_list, k = 6)
Collect partitions from all methods:
collect_classes(res_list, k = 2)
collect_classes(res_list, k = 3)
collect_classes(res_list, k = 4)
collect_classes(res_list, k = 5)
collect_classes(res_list, k = 6)
Overlap of top rows from different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "euler")
top_rows_overlap(res_list, top_n = 2000, method = "euler")
top_rows_overlap(res_list, top_n = 3000, method = "euler")
top_rows_overlap(res_list, top_n = 4000, method = "euler")
top_rows_overlap(res_list, top_n = 5000, method = "euler")
Also visualize the correspondance of rankings between different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "correspondance")
top_rows_overlap(res_list, top_n = 2000, method = "correspondance")
top_rows_overlap(res_list, top_n = 3000, method = "correspondance")
top_rows_overlap(res_list, top_n = 4000, method = "correspondance")
top_rows_overlap(res_list, top_n = 5000, method = "correspondance")
Heatmaps of the top rows:
top_rows_heatmap(res_list, top_n = 1000)
top_rows_heatmap(res_list, top_n = 2000)
top_rows_heatmap(res_list, top_n = 3000)
top_rows_heatmap(res_list, top_n = 4000)
top_rows_heatmap(res_list, top_n = 5000)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res_list, k = 2)
#> n tissue(p) k
#> SD:NMF 50 1.75e-03 2
#> CV:NMF 52 1.79e-03 2
#> MAD:NMF 49 1.92e-04 2
#> ATC:NMF 51 1.50e-03 2
#> SD:skmeans 52 3.12e-08 2
#> CV:skmeans 51 3.69e-07 2
#> MAD:skmeans 50 2.94e-07 2
#> ATC:skmeans 52 1.20e-03 2
#> SD:mclust 52 6.62e-03 2
#> CV:mclust 47 5.19e-04 2
#> MAD:mclust 49 2.14e-03 2
#> ATC:mclust 50 8.39e-03 2
#> SD:kmeans 52 7.46e-04 2
#> CV:kmeans 52 7.46e-04 2
#> MAD:kmeans 52 7.46e-04 2
#> ATC:kmeans 52 7.46e-04 2
#> SD:pam 51 9.13e-04 2
#> CV:pam 51 9.13e-04 2
#> MAD:pam 50 7.77e-04 2
#> ATC:pam 52 7.71e-04 2
#> SD:hclust 52 7.46e-04 2
#> CV:hclust 52 7.46e-04 2
#> MAD:hclust 51 9.13e-04 2
#> ATC:hclust 47 3.87e-04 2
test_to_known_factors(res_list, k = 3)
#> n tissue(p) k
#> SD:NMF 51 6.97e-05 3
#> CV:NMF 49 1.35e-04 3
#> MAD:NMF 50 9.68e-05 3
#> ATC:NMF 38 5.98e-01 3
#> SD:skmeans 52 6.68e-06 3
#> CV:skmeans 51 1.24e-05 3
#> MAD:skmeans 51 9.48e-06 3
#> ATC:skmeans 46 4.68e-03 3
#> SD:mclust 50 4.54e-06 3
#> CV:mclust 46 2.98e-06 3
#> MAD:mclust 52 1.34e-05 3
#> ATC:mclust 43 3.15e-03 3
#> SD:kmeans 52 1.34e-05 3
#> CV:kmeans 52 1.34e-05 3
#> MAD:kmeans 51 1.10e-05 3
#> ATC:kmeans 51 1.03e-04 3
#> SD:pam 49 2.54e-06 3
#> CV:pam 47 5.41e-06 3
#> MAD:pam 47 1.84e-04 3
#> ATC:pam 50 4.85e-04 3
#> SD:hclust 44 1.11e-08 3
#> CV:hclust 43 1.58e-06 3
#> MAD:hclust 44 1.96e-04 3
#> ATC:hclust 52 3.13e-04 3
test_to_known_factors(res_list, k = 4)
#> n tissue(p) k
#> SD:NMF 46 2.51e-04 4
#> CV:NMF 46 2.51e-04 4
#> MAD:NMF 51 1.30e-04 4
#> ATC:NMF 30 1.03e-02 4
#> SD:skmeans 51 2.40e-04 4
#> CV:skmeans 52 1.75e-04 4
#> MAD:skmeans 52 1.75e-04 4
#> ATC:skmeans 47 4.57e-03 4
#> SD:mclust 39 2.62e-06 4
#> CV:mclust 37 2.61e-05 4
#> MAD:mclust 50 8.40e-06 4
#> ATC:mclust 39 1.08e-04 4
#> SD:kmeans 33 3.20e-03 4
#> CV:kmeans 31 8.05e-03 4
#> MAD:kmeans 48 1.12e-04 4
#> ATC:kmeans 42 2.20e-04 4
#> SD:pam 42 2.57e-05 4
#> CV:pam 25 6.07e-04 4
#> MAD:pam 45 5.46e-06 4
#> ATC:pam 51 6.57e-04 4
#> SD:hclust 38 8.01e-07 4
#> CV:hclust 29 1.51e-05 4
#> MAD:hclust 50 1.61e-07 4
#> ATC:hclust 52 3.24e-04 4
test_to_known_factors(res_list, k = 5)
#> n tissue(p) k
#> SD:NMF 48 6.59e-05 5
#> CV:NMF 45 1.43e-05 5
#> MAD:NMF 31 6.10e-05 5
#> ATC:NMF 27 7.50e-05 5
#> SD:skmeans 48 3.89e-04 5
#> CV:skmeans 40 1.96e-03 5
#> MAD:skmeans 47 1.82e-04 5
#> ATC:skmeans 45 8.55e-04 5
#> SD:mclust 27 1.42e-04 5
#> CV:mclust 20 1.41e-02 5
#> MAD:mclust 51 6.66e-08 5
#> ATC:mclust 27 2.74e-03 5
#> SD:kmeans 37 2.25e-05 5
#> CV:kmeans 28 1.10e-04 5
#> MAD:kmeans 44 5.13e-05 5
#> ATC:kmeans 46 1.13e-03 5
#> SD:pam 46 1.06e-05 5
#> CV:pam 31 7.09e-05 5
#> MAD:pam 48 5.97e-05 5
#> ATC:pam 51 8.77e-04 5
#> SD:hclust 42 8.79e-07 5
#> CV:hclust 24 1.44e-04 5
#> MAD:hclust 49 4.55e-08 5
#> ATC:hclust 50 6.28e-04 5
test_to_known_factors(res_list, k = 6)
#> n tissue(p) k
#> SD:NMF 45 4.90e-04 6
#> CV:NMF 41 7.12e-05 6
#> MAD:NMF 42 5.57e-04 6
#> ATC:NMF 30 4.82e-05 6
#> SD:skmeans 36 2.60e-04 6
#> CV:skmeans 42 6.90e-05 6
#> MAD:skmeans 48 3.89e-04 6
#> ATC:skmeans 18 2.73e-02 6
#> SD:mclust 21 6.34e-04 6
#> CV:mclust 34 4.38e-06 6
#> MAD:mclust 34 4.54e-05 6
#> ATC:mclust 38 1.43e-03 6
#> SD:kmeans 29 6.73e-05 6
#> CV:kmeans 30 1.30e-04 6
#> MAD:kmeans 36 9.68e-05 6
#> ATC:kmeans 48 4.60e-04 6
#> SD:pam 36 7.58e-05 6
#> CV:pam 23 7.90e-04 6
#> MAD:pam 40 2.45e-04 6
#> ATC:pam 51 8.77e-04 6
#> SD:hclust 47 3.99e-07 6
#> CV:hclust 35 1.42e-05 6
#> MAD:hclust 47 1.06e-07 6
#> ATC:hclust 46 2.29e-04 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 51882 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 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.964 0.984 0.3292 0.683 0.683
#> 3 3 0.596 0.652 0.800 0.7570 0.837 0.762
#> 4 4 0.514 0.613 0.735 0.1379 0.793 0.605
#> 5 5 0.534 0.665 0.779 0.0574 0.864 0.626
#> 6 6 0.601 0.668 0.776 0.0892 0.916 0.715
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
#> GSM414924 1 0.000 0.983 1.000 0.000
#> GSM414925 1 0.000 0.983 1.000 0.000
#> GSM414926 1 0.000 0.983 1.000 0.000
#> GSM414927 2 0.278 0.959 0.048 0.952
#> GSM414929 1 0.000 0.983 1.000 0.000
#> GSM414931 1 0.000 0.983 1.000 0.000
#> GSM414933 1 0.000 0.983 1.000 0.000
#> GSM414935 1 0.000 0.983 1.000 0.000
#> GSM414936 1 0.000 0.983 1.000 0.000
#> GSM414937 1 0.000 0.983 1.000 0.000
#> GSM414939 1 0.000 0.983 1.000 0.000
#> GSM414941 1 0.000 0.983 1.000 0.000
#> GSM414943 1 0.000 0.983 1.000 0.000
#> GSM414944 1 0.000 0.983 1.000 0.000
#> GSM414945 2 0.000 0.984 0.000 1.000
#> GSM414946 1 0.000 0.983 1.000 0.000
#> GSM414948 1 0.000 0.983 1.000 0.000
#> GSM414949 1 0.416 0.898 0.916 0.084
#> GSM414950 1 0.000 0.983 1.000 0.000
#> GSM414951 1 0.000 0.983 1.000 0.000
#> GSM414952 1 0.000 0.983 1.000 0.000
#> GSM414954 1 0.000 0.983 1.000 0.000
#> GSM414956 1 0.000 0.983 1.000 0.000
#> GSM414958 1 0.000 0.983 1.000 0.000
#> GSM414959 1 0.000 0.983 1.000 0.000
#> GSM414960 1 0.000 0.983 1.000 0.000
#> GSM414961 1 0.000 0.983 1.000 0.000
#> GSM414962 1 0.886 0.570 0.696 0.304
#> GSM414964 1 0.000 0.983 1.000 0.000
#> GSM414965 1 0.000 0.983 1.000 0.000
#> GSM414967 1 0.000 0.983 1.000 0.000
#> GSM414968 1 0.000 0.983 1.000 0.000
#> GSM414969 1 0.000 0.983 1.000 0.000
#> GSM414971 1 0.000 0.983 1.000 0.000
#> GSM414973 1 0.000 0.983 1.000 0.000
#> GSM414974 1 0.881 0.577 0.700 0.300
#> GSM414928 2 0.278 0.959 0.048 0.952
#> GSM414930 2 0.000 0.984 0.000 1.000
#> GSM414932 1 0.000 0.983 1.000 0.000
#> GSM414934 1 0.000 0.983 1.000 0.000
#> GSM414938 1 0.000 0.983 1.000 0.000
#> GSM414940 1 0.000 0.983 1.000 0.000
#> GSM414942 2 0.000 0.984 0.000 1.000
#> GSM414947 2 0.000 0.984 0.000 1.000
#> GSM414953 1 0.000 0.983 1.000 0.000
#> GSM414955 1 0.000 0.983 1.000 0.000
#> GSM414957 2 0.242 0.964 0.040 0.960
#> GSM414963 1 0.000 0.983 1.000 0.000
#> GSM414966 2 0.000 0.984 0.000 1.000
#> GSM414970 1 0.000 0.983 1.000 0.000
#> GSM414972 2 0.000 0.984 0.000 1.000
#> GSM414975 2 0.000 0.984 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.5948 0.6585 0.640 0.000 0.360
#> GSM414925 1 0.5948 0.6585 0.640 0.000 0.360
#> GSM414926 1 0.5948 0.6585 0.640 0.000 0.360
#> GSM414927 2 0.1878 0.9592 0.004 0.952 0.044
#> GSM414929 1 0.5968 0.6575 0.636 0.000 0.364
#> GSM414931 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414933 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414935 1 0.2878 0.5086 0.904 0.000 0.096
#> GSM414936 1 0.0237 0.6010 0.996 0.000 0.004
#> GSM414937 1 0.0424 0.5986 0.992 0.000 0.008
#> GSM414939 1 0.0424 0.5986 0.992 0.000 0.008
#> GSM414941 1 0.2959 0.6124 0.900 0.000 0.100
#> GSM414943 1 0.0237 0.6010 0.996 0.000 0.004
#> GSM414944 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414945 2 0.0000 0.9842 0.000 1.000 0.000
#> GSM414946 1 0.5948 0.6585 0.640 0.000 0.360
#> GSM414948 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414949 1 0.8085 -0.0999 0.584 0.084 0.332
#> GSM414950 1 0.4654 0.2828 0.792 0.000 0.208
#> GSM414951 1 0.2537 0.5271 0.920 0.000 0.080
#> GSM414952 1 0.5327 0.0762 0.728 0.000 0.272
#> GSM414954 1 0.1964 0.5573 0.944 0.000 0.056
#> GSM414956 1 0.0237 0.6010 0.996 0.000 0.004
#> GSM414958 1 0.5968 0.6575 0.636 0.000 0.364
#> GSM414959 1 0.1411 0.6165 0.964 0.000 0.036
#> GSM414960 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414961 1 0.2878 0.5086 0.904 0.000 0.096
#> GSM414962 1 0.9717 0.0331 0.448 0.304 0.248
#> GSM414964 1 0.2066 0.5693 0.940 0.000 0.060
#> GSM414965 1 0.0237 0.6010 0.996 0.000 0.004
#> GSM414967 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414968 1 0.3752 0.4296 0.856 0.000 0.144
#> GSM414969 1 0.5650 0.6586 0.688 0.000 0.312
#> GSM414971 1 0.5988 0.6560 0.632 0.000 0.368
#> GSM414973 1 0.5621 0.6590 0.692 0.000 0.308
#> GSM414974 1 0.9702 0.0347 0.452 0.300 0.248
#> GSM414928 2 0.1878 0.9592 0.004 0.952 0.044
#> GSM414930 2 0.0000 0.9842 0.000 1.000 0.000
#> GSM414932 3 0.6008 1.0000 0.372 0.000 0.628
#> GSM414934 3 0.6008 1.0000 0.372 0.000 0.628
#> GSM414938 1 0.5465 -0.0545 0.712 0.000 0.288
#> GSM414940 3 0.6008 1.0000 0.372 0.000 0.628
#> GSM414942 2 0.0000 0.9842 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.9842 0.000 1.000 0.000
#> GSM414953 3 0.6008 1.0000 0.372 0.000 0.628
#> GSM414955 1 0.5327 0.0762 0.728 0.000 0.272
#> GSM414957 2 0.1529 0.9637 0.000 0.960 0.040
#> GSM414963 3 0.6008 1.0000 0.372 0.000 0.628
#> GSM414966 2 0.0000 0.9842 0.000 1.000 0.000
#> GSM414970 3 0.6008 1.0000 0.372 0.000 0.628
#> GSM414972 2 0.0000 0.9842 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.9842 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.4948 -0.1590 0.560 0.000 0.000 0.440
#> GSM414925 1 0.4916 -0.1193 0.576 0.000 0.000 0.424
#> GSM414926 1 0.4961 -0.1799 0.552 0.000 0.000 0.448
#> GSM414927 2 0.3399 0.9088 0.000 0.868 0.092 0.040
#> GSM414929 4 0.4454 0.8790 0.308 0.000 0.000 0.692
#> GSM414931 4 0.3942 0.9674 0.236 0.000 0.000 0.764
#> GSM414933 4 0.3975 0.9636 0.240 0.000 0.000 0.760
#> GSM414935 1 0.1302 0.5659 0.956 0.000 0.044 0.000
#> GSM414936 1 0.2345 0.6369 0.900 0.000 0.000 0.100
#> GSM414937 1 0.1867 0.6381 0.928 0.000 0.000 0.072
#> GSM414939 1 0.1867 0.6381 0.928 0.000 0.000 0.072
#> GSM414941 1 0.2149 0.6299 0.912 0.000 0.000 0.088
#> GSM414943 1 0.2345 0.6369 0.900 0.000 0.000 0.100
#> GSM414944 4 0.3942 0.9674 0.236 0.000 0.000 0.764
#> GSM414945 2 0.0188 0.9635 0.000 0.996 0.004 0.000
#> GSM414946 1 0.4933 -0.1379 0.568 0.000 0.000 0.432
#> GSM414948 4 0.3942 0.9674 0.236 0.000 0.000 0.764
#> GSM414949 1 0.6171 -0.0680 0.588 0.000 0.348 0.064
#> GSM414950 1 0.3486 0.3251 0.812 0.000 0.188 0.000
#> GSM414951 1 0.3245 0.5842 0.880 0.000 0.064 0.056
#> GSM414952 1 0.3907 0.1675 0.768 0.000 0.232 0.000
#> GSM414954 1 0.0000 0.6080 1.000 0.000 0.000 0.000
#> GSM414956 1 0.2345 0.6369 0.900 0.000 0.000 0.100
#> GSM414958 4 0.4454 0.8790 0.308 0.000 0.000 0.692
#> GSM414959 1 0.2868 0.6246 0.864 0.000 0.000 0.136
#> GSM414960 4 0.3942 0.9674 0.236 0.000 0.000 0.764
#> GSM414961 1 0.1302 0.5659 0.956 0.000 0.044 0.000
#> GSM414962 1 0.8705 0.0385 0.492 0.220 0.212 0.076
#> GSM414964 1 0.0469 0.6155 0.988 0.000 0.000 0.012
#> GSM414965 1 0.2345 0.6369 0.900 0.000 0.000 0.100
#> GSM414967 4 0.3942 0.9674 0.236 0.000 0.000 0.764
#> GSM414968 1 0.2149 0.4971 0.912 0.000 0.088 0.000
#> GSM414969 1 0.4746 0.0665 0.632 0.000 0.000 0.368
#> GSM414971 4 0.3942 0.9674 0.236 0.000 0.000 0.764
#> GSM414973 1 0.4855 -0.0124 0.600 0.000 0.000 0.400
#> GSM414974 1 0.8706 0.0367 0.492 0.216 0.216 0.076
#> GSM414928 2 0.3399 0.9088 0.000 0.868 0.092 0.040
#> GSM414930 2 0.0000 0.9646 0.000 1.000 0.000 0.000
#> GSM414932 3 0.4790 0.8579 0.380 0.000 0.620 0.000
#> GSM414934 3 0.6055 0.8444 0.372 0.000 0.576 0.052
#> GSM414938 3 0.7589 0.1050 0.396 0.000 0.408 0.196
#> GSM414940 3 0.4761 0.8563 0.372 0.000 0.628 0.000
#> GSM414942 2 0.0000 0.9646 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 0.9646 0.000 1.000 0.000 0.000
#> GSM414953 3 0.6055 0.8444 0.372 0.000 0.576 0.052
#> GSM414955 1 0.3907 0.1675 0.768 0.000 0.232 0.000
#> GSM414957 2 0.2983 0.9211 0.000 0.892 0.068 0.040
#> GSM414963 3 0.4790 0.8579 0.380 0.000 0.620 0.000
#> GSM414966 2 0.0000 0.9646 0.000 1.000 0.000 0.000
#> GSM414970 3 0.4790 0.8579 0.380 0.000 0.620 0.000
#> GSM414972 2 0.0000 0.9646 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.9646 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.4856 0.405 0.584 0.000 0.028 0.000 0.388
#> GSM414925 1 0.4893 0.380 0.568 0.000 0.028 0.000 0.404
#> GSM414926 1 0.4835 0.413 0.592 0.000 0.028 0.000 0.380
#> GSM414927 2 0.4755 0.736 0.000 0.696 0.244 0.060 0.000
#> GSM414929 1 0.1671 0.708 0.924 0.000 0.000 0.000 0.076
#> GSM414931 1 0.0000 0.702 1.000 0.000 0.000 0.000 0.000
#> GSM414933 1 0.0290 0.703 0.992 0.000 0.000 0.000 0.008
#> GSM414935 5 0.2674 0.745 0.140 0.000 0.004 0.000 0.856
#> GSM414936 5 0.3707 0.701 0.284 0.000 0.000 0.000 0.716
#> GSM414937 5 0.3635 0.722 0.248 0.000 0.004 0.000 0.748
#> GSM414939 5 0.3635 0.722 0.248 0.000 0.004 0.000 0.748
#> GSM414941 5 0.3783 0.673 0.252 0.000 0.008 0.000 0.740
#> GSM414943 5 0.3707 0.701 0.284 0.000 0.000 0.000 0.716
#> GSM414944 1 0.0000 0.702 1.000 0.000 0.000 0.000 0.000
#> GSM414945 2 0.3214 0.825 0.000 0.844 0.120 0.036 0.000
#> GSM414946 1 0.4876 0.394 0.576 0.000 0.028 0.000 0.396
#> GSM414948 1 0.0000 0.702 1.000 0.000 0.000 0.000 0.000
#> GSM414949 5 0.4229 0.284 0.000 0.000 0.276 0.020 0.704
#> GSM414950 5 0.4425 0.602 0.108 0.000 0.116 0.004 0.772
#> GSM414951 5 0.3132 0.740 0.172 0.000 0.008 0.000 0.820
#> GSM414952 5 0.1478 0.521 0.000 0.000 0.064 0.000 0.936
#> GSM414954 5 0.2929 0.744 0.180 0.000 0.000 0.000 0.820
#> GSM414956 5 0.3707 0.701 0.284 0.000 0.000 0.000 0.716
#> GSM414958 1 0.1671 0.708 0.924 0.000 0.000 0.000 0.076
#> GSM414959 5 0.4213 0.651 0.308 0.000 0.012 0.000 0.680
#> GSM414960 1 0.0162 0.703 0.996 0.000 0.000 0.000 0.004
#> GSM414961 5 0.2674 0.745 0.140 0.000 0.004 0.000 0.856
#> GSM414962 5 0.6470 0.152 0.000 0.048 0.296 0.088 0.568
#> GSM414964 5 0.3160 0.741 0.188 0.000 0.004 0.000 0.808
#> GSM414965 5 0.3707 0.701 0.284 0.000 0.000 0.000 0.716
#> GSM414967 1 0.0000 0.702 1.000 0.000 0.000 0.000 0.000
#> GSM414968 5 0.2193 0.719 0.092 0.000 0.008 0.000 0.900
#> GSM414969 1 0.4971 0.229 0.512 0.000 0.028 0.000 0.460
#> GSM414971 1 0.0000 0.702 1.000 0.000 0.000 0.000 0.000
#> GSM414973 1 0.4937 0.294 0.544 0.000 0.028 0.000 0.428
#> GSM414974 5 0.6423 0.154 0.000 0.044 0.300 0.088 0.568
#> GSM414928 2 0.4755 0.736 0.000 0.696 0.244 0.060 0.000
#> GSM414930 2 0.0000 0.876 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.4321 0.949 0.000 0.000 0.600 0.004 0.396
#> GSM414934 3 0.3774 0.899 0.000 0.000 0.704 0.000 0.296
#> GSM414938 4 0.1410 0.000 0.000 0.000 0.000 0.940 0.060
#> GSM414940 3 0.4161 0.947 0.000 0.000 0.608 0.000 0.392
#> GSM414942 2 0.0000 0.876 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.876 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.3774 0.899 0.000 0.000 0.704 0.000 0.296
#> GSM414955 5 0.1478 0.521 0.000 0.000 0.064 0.000 0.936
#> GSM414957 2 0.4400 0.766 0.000 0.736 0.212 0.052 0.000
#> GSM414963 3 0.4321 0.949 0.000 0.000 0.600 0.004 0.396
#> GSM414966 2 0.0000 0.876 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.4321 0.949 0.000 0.000 0.600 0.004 0.396
#> GSM414972 2 0.0000 0.876 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.876 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.6070 0.514 0.404 0.000 0.000 0.292 0.304 0.00
#> GSM414925 1 0.6075 0.496 0.396 0.000 0.000 0.280 0.324 0.00
#> GSM414926 1 0.6063 0.520 0.408 0.000 0.000 0.292 0.300 0.00
#> GSM414927 2 0.3620 0.677 0.000 0.648 0.000 0.352 0.000 0.00
#> GSM414929 1 0.3652 0.732 0.720 0.000 0.000 0.016 0.264 0.00
#> GSM414931 1 0.2527 0.747 0.832 0.000 0.000 0.000 0.168 0.00
#> GSM414933 1 0.3122 0.752 0.804 0.000 0.000 0.020 0.176 0.00
#> GSM414935 5 0.1572 0.740 0.000 0.000 0.028 0.036 0.936 0.00
#> GSM414936 5 0.1910 0.748 0.108 0.000 0.000 0.000 0.892 0.00
#> GSM414937 5 0.1285 0.760 0.052 0.000 0.000 0.004 0.944 0.00
#> GSM414939 5 0.1285 0.760 0.052 0.000 0.000 0.004 0.944 0.00
#> GSM414941 5 0.3372 0.626 0.084 0.000 0.000 0.100 0.816 0.00
#> GSM414943 5 0.1910 0.748 0.108 0.000 0.000 0.000 0.892 0.00
#> GSM414944 1 0.2912 0.595 0.852 0.000 0.000 0.072 0.076 0.00
#> GSM414945 2 0.5584 0.675 0.068 0.664 0.048 0.200 0.000 0.02
#> GSM414946 1 0.6067 0.507 0.404 0.000 0.000 0.284 0.312 0.00
#> GSM414948 1 0.2562 0.749 0.828 0.000 0.000 0.000 0.172 0.00
#> GSM414949 4 0.5102 0.581 0.000 0.000 0.228 0.624 0.148 0.00
#> GSM414950 5 0.4590 0.408 0.000 0.000 0.224 0.096 0.680 0.00
#> GSM414951 5 0.2250 0.748 0.040 0.000 0.064 0.000 0.896 0.00
#> GSM414952 5 0.4121 0.533 0.000 0.000 0.116 0.136 0.748 0.00
#> GSM414954 5 0.0458 0.757 0.000 0.000 0.000 0.016 0.984 0.00
#> GSM414956 5 0.1910 0.748 0.108 0.000 0.000 0.000 0.892 0.00
#> GSM414958 1 0.3652 0.732 0.720 0.000 0.000 0.016 0.264 0.00
#> GSM414959 5 0.2784 0.718 0.124 0.000 0.000 0.028 0.848 0.00
#> GSM414960 1 0.3168 0.753 0.792 0.000 0.000 0.016 0.192 0.00
#> GSM414961 5 0.1492 0.741 0.000 0.000 0.024 0.036 0.940 0.00
#> GSM414962 4 0.2092 0.792 0.000 0.000 0.000 0.876 0.124 0.00
#> GSM414964 5 0.0806 0.757 0.008 0.000 0.000 0.020 0.972 0.00
#> GSM414965 5 0.1910 0.748 0.108 0.000 0.000 0.000 0.892 0.00
#> GSM414967 1 0.2912 0.595 0.852 0.000 0.000 0.072 0.076 0.00
#> GSM414968 5 0.2250 0.706 0.000 0.000 0.064 0.040 0.896 0.00
#> GSM414969 5 0.6088 -0.471 0.340 0.000 0.000 0.280 0.380 0.00
#> GSM414971 1 0.2527 0.747 0.832 0.000 0.000 0.000 0.168 0.00
#> GSM414973 5 0.6100 -0.504 0.356 0.000 0.000 0.284 0.360 0.00
#> GSM414974 4 0.2234 0.794 0.000 0.000 0.004 0.872 0.124 0.00
#> GSM414928 2 0.3620 0.677 0.000 0.648 0.000 0.352 0.000 0.00
#> GSM414930 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM414932 3 0.2971 0.942 0.000 0.000 0.844 0.104 0.052 0.00
#> GSM414934 3 0.1075 0.890 0.000 0.000 0.952 0.000 0.048 0.00
#> GSM414938 6 0.0547 0.000 0.000 0.000 0.000 0.020 0.000 0.98
#> GSM414940 3 0.2860 0.940 0.000 0.000 0.852 0.100 0.048 0.00
#> GSM414942 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM414947 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM414953 3 0.1075 0.890 0.000 0.000 0.952 0.000 0.048 0.00
#> GSM414955 5 0.4121 0.533 0.000 0.000 0.116 0.136 0.748 0.00
#> GSM414957 2 0.3446 0.713 0.000 0.692 0.000 0.308 0.000 0.00
#> GSM414963 3 0.2971 0.942 0.000 0.000 0.844 0.104 0.052 0.00
#> GSM414966 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM414970 3 0.2971 0.942 0.000 0.000 0.844 0.104 0.052 0.00
#> GSM414972 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 0.00
#> GSM414975 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 0.00
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> SD:hclust 52 7.46e-04 2
#> SD:hclust 44 1.11e-08 3
#> SD:hclust 38 8.01e-07 4
#> SD:hclust 42 8.79e-07 5
#> SD:hclust 47 3.99e-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", "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 51882 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 1.000 0.999 1.000 0.3177 0.683 0.683
#> 3 3 1.000 0.995 0.995 0.9563 0.695 0.553
#> 4 4 0.650 0.565 0.816 0.1481 0.946 0.856
#> 5 5 0.629 0.563 0.743 0.0809 0.848 0.563
#> 6 6 0.658 0.488 0.717 0.0477 0.939 0.744
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.0000 1.000 1.000 0.000
#> GSM414925 1 0.0000 1.000 1.000 0.000
#> GSM414926 1 0.0000 1.000 1.000 0.000
#> GSM414927 2 0.0000 1.000 0.000 1.000
#> GSM414929 1 0.0000 1.000 1.000 0.000
#> GSM414931 1 0.0000 1.000 1.000 0.000
#> GSM414933 1 0.0000 1.000 1.000 0.000
#> GSM414935 1 0.0000 1.000 1.000 0.000
#> GSM414936 1 0.0000 1.000 1.000 0.000
#> GSM414937 1 0.0000 1.000 1.000 0.000
#> GSM414939 1 0.0000 1.000 1.000 0.000
#> GSM414941 1 0.0000 1.000 1.000 0.000
#> GSM414943 1 0.0000 1.000 1.000 0.000
#> GSM414944 1 0.0000 1.000 1.000 0.000
#> GSM414945 2 0.0000 1.000 0.000 1.000
#> GSM414946 1 0.0000 1.000 1.000 0.000
#> GSM414948 1 0.0000 1.000 1.000 0.000
#> GSM414949 1 0.0376 0.996 0.996 0.004
#> GSM414950 1 0.0000 1.000 1.000 0.000
#> GSM414951 1 0.0000 1.000 1.000 0.000
#> GSM414952 1 0.0000 1.000 1.000 0.000
#> GSM414954 1 0.0000 1.000 1.000 0.000
#> GSM414956 1 0.0000 1.000 1.000 0.000
#> GSM414958 1 0.0000 1.000 1.000 0.000
#> GSM414959 1 0.0000 1.000 1.000 0.000
#> GSM414960 1 0.0000 1.000 1.000 0.000
#> GSM414961 1 0.0000 1.000 1.000 0.000
#> GSM414962 1 0.0376 0.996 0.996 0.004
#> GSM414964 1 0.0000 1.000 1.000 0.000
#> GSM414965 1 0.0000 1.000 1.000 0.000
#> GSM414967 1 0.0000 1.000 1.000 0.000
#> GSM414968 1 0.0000 1.000 1.000 0.000
#> GSM414969 1 0.0000 1.000 1.000 0.000
#> GSM414971 1 0.0000 1.000 1.000 0.000
#> GSM414973 1 0.0000 1.000 1.000 0.000
#> GSM414974 1 0.0376 0.996 0.996 0.004
#> GSM414928 2 0.0000 1.000 0.000 1.000
#> GSM414930 2 0.0000 1.000 0.000 1.000
#> GSM414932 1 0.0000 1.000 1.000 0.000
#> GSM414934 1 0.0000 1.000 1.000 0.000
#> GSM414938 1 0.0000 1.000 1.000 0.000
#> GSM414940 1 0.0000 1.000 1.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000
#> GSM414947 2 0.0000 1.000 0.000 1.000
#> GSM414953 1 0.0000 1.000 1.000 0.000
#> GSM414955 1 0.0000 1.000 1.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000
#> GSM414963 1 0.0376 0.996 0.996 0.004
#> GSM414966 2 0.0000 1.000 0.000 1.000
#> GSM414970 1 0.0376 0.996 0.996 0.004
#> GSM414972 2 0.0000 1.000 0.000 1.000
#> GSM414975 2 0.0000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414927 2 0.0424 0.997 0.000 0.992 0.008
#> GSM414929 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414935 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414936 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414937 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414939 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414941 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414943 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414944 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414945 2 0.0424 0.997 0.000 0.992 0.008
#> GSM414946 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414948 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414949 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414950 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414951 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414952 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414954 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414956 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414958 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414959 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414960 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414961 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414962 3 0.0000 0.989 0.000 0.000 1.000
#> GSM414964 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414965 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414967 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414968 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414969 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414971 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414973 1 0.0000 0.996 1.000 0.000 0.000
#> GSM414974 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414928 2 0.0424 0.997 0.000 0.992 0.008
#> GSM414930 2 0.0000 0.998 0.000 1.000 0.000
#> GSM414932 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414934 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414938 1 0.3038 0.881 0.896 0.000 0.104
#> GSM414940 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414942 2 0.0000 0.998 0.000 1.000 0.000
#> GSM414947 2 0.0237 0.998 0.000 0.996 0.004
#> GSM414953 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414955 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414957 2 0.0237 0.998 0.000 0.996 0.004
#> GSM414963 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414966 2 0.0000 0.998 0.000 1.000 0.000
#> GSM414970 3 0.0424 0.999 0.008 0.000 0.992
#> GSM414972 2 0.0000 0.998 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.998 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.4985 -0.15861 0.532 0.000 0.000 0.468
#> GSM414925 1 0.4454 0.36637 0.692 0.000 0.000 0.308
#> GSM414926 1 0.4916 -0.13536 0.576 0.000 0.000 0.424
#> GSM414927 2 0.2281 0.93909 0.000 0.904 0.000 0.096
#> GSM414929 4 0.4985 0.30602 0.468 0.000 0.000 0.532
#> GSM414931 1 0.4564 0.17394 0.672 0.000 0.000 0.328
#> GSM414933 1 0.4933 -0.23701 0.568 0.000 0.000 0.432
#> GSM414935 3 0.5396 0.79544 0.156 0.000 0.740 0.104
#> GSM414936 1 0.0592 0.55099 0.984 0.000 0.000 0.016
#> GSM414937 1 0.1211 0.54859 0.960 0.000 0.000 0.040
#> GSM414939 1 0.1118 0.54876 0.964 0.000 0.000 0.036
#> GSM414941 1 0.3764 0.46751 0.784 0.000 0.000 0.216
#> GSM414943 1 0.0469 0.55142 0.988 0.000 0.000 0.012
#> GSM414944 1 0.4961 -0.35900 0.552 0.000 0.000 0.448
#> GSM414945 2 0.4040 0.84029 0.000 0.752 0.000 0.248
#> GSM414946 1 0.4382 0.38609 0.704 0.000 0.000 0.296
#> GSM414948 1 0.4500 0.18665 0.684 0.000 0.000 0.316
#> GSM414949 3 0.2988 0.85916 0.012 0.000 0.876 0.112
#> GSM414950 3 0.5507 0.79468 0.156 0.000 0.732 0.112
#> GSM414951 1 0.2048 0.53712 0.928 0.000 0.008 0.064
#> GSM414952 3 0.0000 0.87782 0.000 0.000 1.000 0.000
#> GSM414954 1 0.3390 0.48104 0.852 0.000 0.016 0.132
#> GSM414956 1 0.1743 0.53881 0.940 0.000 0.004 0.056
#> GSM414958 1 0.4761 -0.00149 0.628 0.000 0.000 0.372
#> GSM414959 1 0.1940 0.54714 0.924 0.000 0.000 0.076
#> GSM414960 1 0.4972 -0.35467 0.544 0.000 0.000 0.456
#> GSM414961 3 0.5396 0.79544 0.156 0.000 0.740 0.104
#> GSM414962 3 0.6166 0.62764 0.024 0.020 0.572 0.384
#> GSM414964 1 0.3300 0.48368 0.848 0.000 0.008 0.144
#> GSM414965 1 0.0921 0.54837 0.972 0.000 0.000 0.028
#> GSM414967 4 0.4989 0.34097 0.472 0.000 0.000 0.528
#> GSM414968 3 0.5277 0.80503 0.132 0.000 0.752 0.116
#> GSM414969 1 0.5165 -0.03653 0.512 0.000 0.004 0.484
#> GSM414971 1 0.3528 0.40776 0.808 0.000 0.000 0.192
#> GSM414973 1 0.3764 0.43966 0.784 0.000 0.000 0.216
#> GSM414974 3 0.4839 0.81982 0.052 0.000 0.764 0.184
#> GSM414928 2 0.2281 0.93909 0.000 0.904 0.000 0.096
#> GSM414930 2 0.0000 0.94356 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0188 0.87738 0.000 0.000 0.996 0.004
#> GSM414934 3 0.1118 0.86810 0.000 0.000 0.964 0.036
#> GSM414938 4 0.4669 0.42327 0.200 0.000 0.036 0.764
#> GSM414940 3 0.0469 0.87646 0.000 0.000 0.988 0.012
#> GSM414942 2 0.0707 0.94207 0.000 0.980 0.000 0.020
#> GSM414947 2 0.2216 0.94005 0.000 0.908 0.000 0.092
#> GSM414953 3 0.1118 0.86810 0.000 0.000 0.964 0.036
#> GSM414955 3 0.0000 0.87782 0.000 0.000 1.000 0.000
#> GSM414957 2 0.2216 0.94005 0.000 0.908 0.000 0.092
#> GSM414963 3 0.0469 0.87675 0.000 0.000 0.988 0.012
#> GSM414966 2 0.0707 0.94207 0.000 0.980 0.000 0.020
#> GSM414970 3 0.0469 0.87675 0.000 0.000 0.988 0.012
#> GSM414972 2 0.0707 0.94207 0.000 0.980 0.000 0.020
#> GSM414975 2 0.0707 0.94207 0.000 0.980 0.000 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.5928 0.5643 0.596 0.000 0.000 0.192 0.212
#> GSM414925 1 0.6582 0.3594 0.416 0.000 0.000 0.208 0.376
#> GSM414926 1 0.5739 0.5873 0.596 0.000 0.000 0.124 0.280
#> GSM414927 2 0.3419 0.8613 0.016 0.804 0.000 0.180 0.000
#> GSM414929 1 0.5191 0.5524 0.684 0.000 0.000 0.192 0.124
#> GSM414931 1 0.4390 0.4641 0.568 0.000 0.000 0.004 0.428
#> GSM414933 1 0.3861 0.6042 0.728 0.000 0.000 0.008 0.264
#> GSM414935 3 0.6586 0.0549 0.016 0.000 0.548 0.216 0.220
#> GSM414936 5 0.0794 0.7570 0.028 0.000 0.000 0.000 0.972
#> GSM414937 5 0.0671 0.7596 0.016 0.000 0.000 0.004 0.980
#> GSM414939 5 0.0510 0.7599 0.016 0.000 0.000 0.000 0.984
#> GSM414941 5 0.6106 0.2061 0.204 0.000 0.000 0.228 0.568
#> GSM414943 5 0.0794 0.7570 0.028 0.000 0.000 0.000 0.972
#> GSM414944 1 0.5773 0.3353 0.512 0.000 0.000 0.092 0.396
#> GSM414945 2 0.5338 0.6105 0.056 0.544 0.000 0.400 0.000
#> GSM414946 1 0.6582 0.3594 0.416 0.000 0.000 0.208 0.376
#> GSM414948 1 0.4403 0.4472 0.560 0.000 0.000 0.004 0.436
#> GSM414949 3 0.3835 0.2769 0.000 0.000 0.744 0.244 0.012
#> GSM414950 3 0.6366 0.0521 0.012 0.000 0.572 0.224 0.192
#> GSM414951 5 0.1653 0.7448 0.024 0.000 0.004 0.028 0.944
#> GSM414952 3 0.0880 0.6185 0.000 0.000 0.968 0.032 0.000
#> GSM414954 5 0.3708 0.6258 0.044 0.000 0.004 0.136 0.816
#> GSM414956 5 0.1116 0.7569 0.028 0.000 0.004 0.004 0.964
#> GSM414958 1 0.4584 0.5852 0.660 0.000 0.000 0.028 0.312
#> GSM414959 5 0.1357 0.7537 0.048 0.000 0.000 0.004 0.948
#> GSM414960 1 0.3783 0.5997 0.740 0.000 0.000 0.008 0.252
#> GSM414961 3 0.6586 0.0549 0.016 0.000 0.548 0.216 0.220
#> GSM414962 4 0.5226 0.6904 0.044 0.000 0.308 0.636 0.012
#> GSM414964 5 0.4220 0.5747 0.048 0.000 0.004 0.180 0.768
#> GSM414965 5 0.0963 0.7521 0.036 0.000 0.000 0.000 0.964
#> GSM414967 1 0.5379 0.5130 0.636 0.000 0.000 0.096 0.268
#> GSM414968 3 0.6438 0.0886 0.016 0.000 0.572 0.216 0.196
#> GSM414969 1 0.6526 0.4387 0.464 0.000 0.000 0.324 0.212
#> GSM414971 5 0.3876 0.1887 0.316 0.000 0.000 0.000 0.684
#> GSM414973 5 0.5353 -0.1143 0.328 0.000 0.000 0.072 0.600
#> GSM414974 4 0.6138 0.6180 0.036 0.000 0.428 0.484 0.052
#> GSM414928 2 0.3419 0.8613 0.016 0.804 0.000 0.180 0.000
#> GSM414930 2 0.0794 0.8838 0.000 0.972 0.000 0.028 0.000
#> GSM414932 3 0.0162 0.6295 0.000 0.000 0.996 0.004 0.000
#> GSM414934 3 0.2488 0.5583 0.004 0.000 0.872 0.124 0.000
#> GSM414938 1 0.5192 0.1550 0.488 0.000 0.004 0.476 0.032
#> GSM414940 3 0.1341 0.6077 0.000 0.000 0.944 0.056 0.000
#> GSM414942 2 0.0510 0.8805 0.016 0.984 0.000 0.000 0.000
#> GSM414947 2 0.3055 0.8744 0.016 0.840 0.000 0.144 0.000
#> GSM414953 3 0.2488 0.5583 0.004 0.000 0.872 0.124 0.000
#> GSM414955 3 0.0290 0.6298 0.000 0.000 0.992 0.008 0.000
#> GSM414957 2 0.3055 0.8744 0.016 0.840 0.000 0.144 0.000
#> GSM414963 3 0.0162 0.6295 0.000 0.000 0.996 0.004 0.000
#> GSM414966 2 0.0510 0.8805 0.016 0.984 0.000 0.000 0.000
#> GSM414970 3 0.0162 0.6295 0.000 0.000 0.996 0.004 0.000
#> GSM414972 2 0.0510 0.8805 0.016 0.984 0.000 0.000 0.000
#> GSM414975 2 0.0510 0.8805 0.016 0.984 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.1668 0.3800 0.928 0.000 0.000 0.008 0.060 0.004
#> GSM414925 1 0.3520 0.4197 0.776 0.000 0.000 0.036 0.188 0.000
#> GSM414926 1 0.2600 0.3694 0.860 0.000 0.000 0.008 0.124 0.008
#> GSM414927 2 0.0937 0.7553 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM414929 1 0.6378 -0.0322 0.488 0.000 0.000 0.264 0.032 0.216
#> GSM414931 1 0.5751 -0.2003 0.512 0.000 0.000 0.000 0.232 0.256
#> GSM414933 1 0.5252 -0.1133 0.592 0.000 0.000 0.000 0.144 0.264
#> GSM414935 3 0.7227 0.1795 0.108 0.000 0.404 0.240 0.248 0.000
#> GSM414936 5 0.0547 0.8321 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM414937 5 0.1168 0.8316 0.028 0.000 0.000 0.016 0.956 0.000
#> GSM414939 5 0.0713 0.8387 0.028 0.000 0.000 0.000 0.972 0.000
#> GSM414941 1 0.5308 0.1980 0.544 0.000 0.000 0.100 0.352 0.004
#> GSM414943 5 0.0547 0.8321 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM414944 6 0.6744 0.8448 0.296 0.000 0.000 0.060 0.196 0.448
#> GSM414945 2 0.4992 0.3781 0.000 0.624 0.000 0.260 0.000 0.116
#> GSM414946 1 0.3551 0.4189 0.772 0.000 0.000 0.036 0.192 0.000
#> GSM414948 1 0.5738 -0.1368 0.516 0.000 0.000 0.000 0.244 0.240
#> GSM414949 3 0.4943 0.3347 0.060 0.000 0.644 0.276 0.020 0.000
#> GSM414950 3 0.7144 0.1843 0.104 0.000 0.424 0.248 0.224 0.000
#> GSM414951 5 0.1679 0.8225 0.028 0.000 0.008 0.028 0.936 0.000
#> GSM414952 3 0.1082 0.6324 0.000 0.000 0.956 0.040 0.004 0.000
#> GSM414954 5 0.3318 0.7273 0.100 0.000 0.008 0.052 0.836 0.004
#> GSM414956 5 0.0405 0.8353 0.000 0.000 0.000 0.008 0.988 0.004
#> GSM414958 1 0.5335 0.1309 0.640 0.000 0.000 0.016 0.188 0.156
#> GSM414959 5 0.1829 0.8084 0.064 0.000 0.000 0.004 0.920 0.012
#> GSM414960 1 0.5859 -0.1468 0.536 0.000 0.000 0.016 0.156 0.292
#> GSM414961 3 0.7227 0.1795 0.108 0.000 0.404 0.240 0.248 0.000
#> GSM414962 4 0.7639 0.4461 0.208 0.172 0.188 0.420 0.008 0.004
#> GSM414964 5 0.4847 0.5597 0.140 0.000 0.008 0.148 0.700 0.004
#> GSM414965 5 0.0547 0.8321 0.020 0.000 0.000 0.000 0.980 0.000
#> GSM414967 6 0.6494 0.8388 0.360 0.000 0.000 0.060 0.132 0.448
#> GSM414968 3 0.7048 0.2224 0.108 0.000 0.452 0.244 0.196 0.000
#> GSM414969 1 0.4526 0.2728 0.708 0.000 0.000 0.188 0.100 0.004
#> GSM414971 5 0.5630 -0.2797 0.228 0.000 0.000 0.000 0.540 0.232
#> GSM414973 1 0.4041 0.3061 0.584 0.000 0.000 0.004 0.408 0.004
#> GSM414974 4 0.7449 0.3039 0.216 0.060 0.288 0.404 0.032 0.000
#> GSM414928 2 0.0937 0.7553 0.000 0.960 0.000 0.040 0.000 0.000
#> GSM414930 2 0.3641 0.7945 0.000 0.748 0.000 0.028 0.000 0.224
#> GSM414932 3 0.0260 0.6376 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM414934 3 0.3032 0.5720 0.000 0.000 0.840 0.104 0.000 0.056
#> GSM414938 4 0.5757 -0.0116 0.276 0.000 0.004 0.528 0.000 0.192
#> GSM414940 3 0.1845 0.6137 0.000 0.000 0.920 0.052 0.000 0.028
#> GSM414942 2 0.4020 0.7911 0.000 0.692 0.000 0.032 0.000 0.276
#> GSM414947 2 0.0000 0.7732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.3032 0.5720 0.000 0.000 0.840 0.104 0.000 0.056
#> GSM414955 3 0.0363 0.6391 0.000 0.000 0.988 0.012 0.000 0.000
#> GSM414957 2 0.0000 0.7732 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.0260 0.6376 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM414966 2 0.4020 0.7911 0.000 0.692 0.000 0.032 0.000 0.276
#> GSM414970 3 0.0260 0.6376 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM414972 2 0.4020 0.7911 0.000 0.692 0.000 0.032 0.000 0.276
#> GSM414975 2 0.4020 0.7911 0.000 0.692 0.000 0.032 0.000 0.276
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> SD:kmeans 52 7.46e-04 2
#> SD:kmeans 52 1.34e-05 3
#> SD:kmeans 33 3.20e-03 4
#> SD:kmeans 37 2.25e-05 5
#> SD:kmeans 29 6.73e-05 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "skmeans"]
# you can also extract it by
# res = res_list["SD:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 51882 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 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.980 0.991 0.4907 0.509 0.509
#> 3 3 1.000 0.978 0.990 0.2996 0.793 0.617
#> 4 4 0.798 0.836 0.897 0.1860 0.855 0.613
#> 5 5 0.775 0.756 0.827 0.0573 0.952 0.803
#> 6 6 0.776 0.649 0.780 0.0277 0.940 0.715
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.000 0.994 1.000 0.000
#> GSM414925 1 0.000 0.994 1.000 0.000
#> GSM414926 1 0.000 0.994 1.000 0.000
#> GSM414927 2 0.000 0.987 0.000 1.000
#> GSM414929 1 0.000 0.994 1.000 0.000
#> GSM414931 1 0.000 0.994 1.000 0.000
#> GSM414933 1 0.000 0.994 1.000 0.000
#> GSM414935 1 0.000 0.994 1.000 0.000
#> GSM414936 1 0.000 0.994 1.000 0.000
#> GSM414937 1 0.000 0.994 1.000 0.000
#> GSM414939 1 0.000 0.994 1.000 0.000
#> GSM414941 1 0.000 0.994 1.000 0.000
#> GSM414943 1 0.000 0.994 1.000 0.000
#> GSM414944 1 0.000 0.994 1.000 0.000
#> GSM414945 2 0.000 0.987 0.000 1.000
#> GSM414946 1 0.000 0.994 1.000 0.000
#> GSM414948 1 0.000 0.994 1.000 0.000
#> GSM414949 2 0.000 0.987 0.000 1.000
#> GSM414950 1 0.000 0.994 1.000 0.000
#> GSM414951 1 0.000 0.994 1.000 0.000
#> GSM414952 1 0.689 0.772 0.816 0.184
#> GSM414954 1 0.000 0.994 1.000 0.000
#> GSM414956 1 0.000 0.994 1.000 0.000
#> GSM414958 1 0.000 0.994 1.000 0.000
#> GSM414959 1 0.000 0.994 1.000 0.000
#> GSM414960 1 0.000 0.994 1.000 0.000
#> GSM414961 1 0.000 0.994 1.000 0.000
#> GSM414962 2 0.000 0.987 0.000 1.000
#> GSM414964 1 0.000 0.994 1.000 0.000
#> GSM414965 1 0.000 0.994 1.000 0.000
#> GSM414967 1 0.000 0.994 1.000 0.000
#> GSM414968 1 0.000 0.994 1.000 0.000
#> GSM414969 1 0.000 0.994 1.000 0.000
#> GSM414971 1 0.000 0.994 1.000 0.000
#> GSM414973 1 0.000 0.994 1.000 0.000
#> GSM414974 2 0.000 0.987 0.000 1.000
#> GSM414928 2 0.000 0.987 0.000 1.000
#> GSM414930 2 0.000 0.987 0.000 1.000
#> GSM414932 2 0.000 0.987 0.000 1.000
#> GSM414934 2 0.000 0.987 0.000 1.000
#> GSM414938 2 0.827 0.648 0.260 0.740
#> GSM414940 2 0.000 0.987 0.000 1.000
#> GSM414942 2 0.000 0.987 0.000 1.000
#> GSM414947 2 0.000 0.987 0.000 1.000
#> GSM414953 2 0.000 0.987 0.000 1.000
#> GSM414955 2 0.000 0.987 0.000 1.000
#> GSM414957 2 0.000 0.987 0.000 1.000
#> GSM414963 2 0.000 0.987 0.000 1.000
#> GSM414966 2 0.000 0.987 0.000 1.000
#> GSM414970 2 0.000 0.987 0.000 1.000
#> GSM414972 2 0.000 0.987 0.000 1.000
#> GSM414975 2 0.000 0.987 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.000 0.993 1.000 0.000 0.000
#> GSM414925 1 0.000 0.993 1.000 0.000 0.000
#> GSM414926 1 0.000 0.993 1.000 0.000 0.000
#> GSM414927 2 0.000 0.986 0.000 1.000 0.000
#> GSM414929 1 0.000 0.993 1.000 0.000 0.000
#> GSM414931 1 0.000 0.993 1.000 0.000 0.000
#> GSM414933 1 0.000 0.993 1.000 0.000 0.000
#> GSM414935 3 0.000 0.984 0.000 0.000 1.000
#> GSM414936 1 0.000 0.993 1.000 0.000 0.000
#> GSM414937 1 0.000 0.993 1.000 0.000 0.000
#> GSM414939 1 0.000 0.993 1.000 0.000 0.000
#> GSM414941 1 0.000 0.993 1.000 0.000 0.000
#> GSM414943 1 0.000 0.993 1.000 0.000 0.000
#> GSM414944 1 0.000 0.993 1.000 0.000 0.000
#> GSM414945 2 0.000 0.986 0.000 1.000 0.000
#> GSM414946 1 0.000 0.993 1.000 0.000 0.000
#> GSM414948 1 0.000 0.993 1.000 0.000 0.000
#> GSM414949 3 0.450 0.760 0.000 0.196 0.804
#> GSM414950 3 0.000 0.984 0.000 0.000 1.000
#> GSM414951 1 0.406 0.802 0.836 0.000 0.164
#> GSM414952 3 0.000 0.984 0.000 0.000 1.000
#> GSM414954 1 0.000 0.993 1.000 0.000 0.000
#> GSM414956 1 0.000 0.993 1.000 0.000 0.000
#> GSM414958 1 0.000 0.993 1.000 0.000 0.000
#> GSM414959 1 0.000 0.993 1.000 0.000 0.000
#> GSM414960 1 0.000 0.993 1.000 0.000 0.000
#> GSM414961 3 0.000 0.984 0.000 0.000 1.000
#> GSM414962 2 0.000 0.986 0.000 1.000 0.000
#> GSM414964 1 0.000 0.993 1.000 0.000 0.000
#> GSM414965 1 0.000 0.993 1.000 0.000 0.000
#> GSM414967 1 0.000 0.993 1.000 0.000 0.000
#> GSM414968 3 0.000 0.984 0.000 0.000 1.000
#> GSM414969 1 0.000 0.993 1.000 0.000 0.000
#> GSM414971 1 0.000 0.993 1.000 0.000 0.000
#> GSM414973 1 0.000 0.993 1.000 0.000 0.000
#> GSM414974 2 0.000 0.986 0.000 1.000 0.000
#> GSM414928 2 0.000 0.986 0.000 1.000 0.000
#> GSM414930 2 0.000 0.986 0.000 1.000 0.000
#> GSM414932 3 0.000 0.984 0.000 0.000 1.000
#> GSM414934 3 0.000 0.984 0.000 0.000 1.000
#> GSM414938 2 0.390 0.824 0.128 0.864 0.008
#> GSM414940 3 0.000 0.984 0.000 0.000 1.000
#> GSM414942 2 0.000 0.986 0.000 1.000 0.000
#> GSM414947 2 0.000 0.986 0.000 1.000 0.000
#> GSM414953 3 0.000 0.984 0.000 0.000 1.000
#> GSM414955 3 0.000 0.984 0.000 0.000 1.000
#> GSM414957 2 0.000 0.986 0.000 1.000 0.000
#> GSM414963 3 0.000 0.984 0.000 0.000 1.000
#> GSM414966 2 0.000 0.986 0.000 1.000 0.000
#> GSM414970 3 0.000 0.984 0.000 0.000 1.000
#> GSM414972 2 0.000 0.986 0.000 1.000 0.000
#> GSM414975 2 0.000 0.986 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.3444 0.746 0.816 0.000 0.000 0.184
#> GSM414925 1 0.3837 0.734 0.776 0.000 0.000 0.224
#> GSM414926 1 0.0188 0.816 0.996 0.000 0.000 0.004
#> GSM414927 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414929 1 0.0000 0.815 1.000 0.000 0.000 0.000
#> GSM414931 1 0.1302 0.802 0.956 0.000 0.000 0.044
#> GSM414933 1 0.0000 0.815 1.000 0.000 0.000 0.000
#> GSM414935 3 0.4356 0.773 0.000 0.000 0.708 0.292
#> GSM414936 4 0.3649 0.907 0.204 0.000 0.000 0.796
#> GSM414937 4 0.3610 0.909 0.200 0.000 0.000 0.800
#> GSM414939 4 0.3610 0.909 0.200 0.000 0.000 0.800
#> GSM414941 1 0.4907 0.548 0.580 0.000 0.000 0.420
#> GSM414943 4 0.3610 0.909 0.200 0.000 0.000 0.800
#> GSM414944 1 0.4989 -0.342 0.528 0.000 0.000 0.472
#> GSM414945 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414946 1 0.3873 0.737 0.772 0.000 0.000 0.228
#> GSM414948 1 0.1389 0.800 0.952 0.000 0.000 0.048
#> GSM414949 3 0.3610 0.745 0.000 0.200 0.800 0.000
#> GSM414950 3 0.4331 0.776 0.000 0.000 0.712 0.288
#> GSM414951 4 0.3610 0.909 0.200 0.000 0.000 0.800
#> GSM414952 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414954 4 0.0000 0.713 0.000 0.000 0.000 1.000
#> GSM414956 4 0.3610 0.909 0.200 0.000 0.000 0.800
#> GSM414958 1 0.0000 0.815 1.000 0.000 0.000 0.000
#> GSM414959 4 0.4356 0.816 0.292 0.000 0.000 0.708
#> GSM414960 1 0.0469 0.813 0.988 0.000 0.000 0.012
#> GSM414961 3 0.4356 0.773 0.000 0.000 0.708 0.292
#> GSM414962 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414964 4 0.0000 0.713 0.000 0.000 0.000 1.000
#> GSM414965 4 0.3726 0.902 0.212 0.000 0.000 0.788
#> GSM414967 1 0.1302 0.796 0.956 0.000 0.000 0.044
#> GSM414968 3 0.4304 0.778 0.000 0.000 0.716 0.284
#> GSM414969 1 0.3649 0.732 0.796 0.000 0.000 0.204
#> GSM414971 4 0.4382 0.809 0.296 0.000 0.000 0.704
#> GSM414973 1 0.2704 0.728 0.876 0.000 0.000 0.124
#> GSM414974 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414928 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414934 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414938 1 0.4307 0.691 0.808 0.144 0.048 0.000
#> GSM414940 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414953 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414955 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414963 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0000 0.895 0.000 0.000 1.000 0.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 4 0.4540 0.577 0.340 0.000 0.000 0.640 0.020
#> GSM414925 4 0.3741 0.690 0.264 0.000 0.000 0.732 0.004
#> GSM414926 4 0.4890 0.557 0.332 0.000 0.000 0.628 0.040
#> GSM414927 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414929 1 0.4354 0.488 0.712 0.000 0.000 0.256 0.032
#> GSM414931 1 0.4926 0.626 0.716 0.000 0.000 0.152 0.132
#> GSM414933 1 0.4100 0.600 0.764 0.000 0.000 0.192 0.044
#> GSM414935 3 0.6171 0.638 0.004 0.000 0.572 0.248 0.176
#> GSM414936 5 0.1908 0.833 0.092 0.000 0.000 0.000 0.908
#> GSM414937 5 0.1725 0.828 0.044 0.000 0.000 0.020 0.936
#> GSM414939 5 0.1671 0.838 0.076 0.000 0.000 0.000 0.924
#> GSM414941 4 0.4796 0.586 0.120 0.000 0.000 0.728 0.152
#> GSM414943 5 0.1792 0.835 0.084 0.000 0.000 0.000 0.916
#> GSM414944 1 0.3612 0.539 0.764 0.000 0.000 0.008 0.228
#> GSM414945 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414946 4 0.4430 0.695 0.256 0.000 0.000 0.708 0.036
#> GSM414948 1 0.5150 0.586 0.692 0.000 0.000 0.172 0.136
#> GSM414949 3 0.4226 0.699 0.012 0.188 0.768 0.032 0.000
#> GSM414950 3 0.6224 0.662 0.016 0.000 0.596 0.236 0.152
#> GSM414951 5 0.2067 0.820 0.048 0.000 0.000 0.032 0.920
#> GSM414952 3 0.0451 0.843 0.000 0.000 0.988 0.008 0.004
#> GSM414954 5 0.2561 0.707 0.000 0.000 0.000 0.144 0.856
#> GSM414956 5 0.1608 0.837 0.072 0.000 0.000 0.000 0.928
#> GSM414958 1 0.4400 0.580 0.736 0.000 0.000 0.212 0.052
#> GSM414959 5 0.4930 0.643 0.220 0.000 0.000 0.084 0.696
#> GSM414960 1 0.3437 0.662 0.832 0.000 0.000 0.120 0.048
#> GSM414961 3 0.6111 0.645 0.004 0.000 0.580 0.248 0.168
#> GSM414962 2 0.0162 0.996 0.004 0.996 0.000 0.000 0.000
#> GSM414964 5 0.3550 0.601 0.004 0.000 0.000 0.236 0.760
#> GSM414965 5 0.2074 0.823 0.104 0.000 0.000 0.000 0.896
#> GSM414967 1 0.3459 0.636 0.832 0.000 0.000 0.052 0.116
#> GSM414968 3 0.6344 0.655 0.020 0.000 0.588 0.236 0.156
#> GSM414969 4 0.2329 0.650 0.124 0.000 0.000 0.876 0.000
#> GSM414971 5 0.4574 0.250 0.412 0.000 0.000 0.012 0.576
#> GSM414973 4 0.6406 0.421 0.248 0.000 0.000 0.512 0.240
#> GSM414974 2 0.0566 0.986 0.012 0.984 0.000 0.004 0.000
#> GSM414928 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414934 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414938 1 0.5972 0.359 0.644 0.072 0.024 0.248 0.012
#> GSM414940 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414942 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.0162 0.845 0.000 0.000 0.996 0.004 0.000
#> GSM414957 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414966 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414972 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.2034 0.509 0.912 0.000 0.024 0.000 0.004 0.060
#> GSM414925 1 0.2638 0.533 0.888 0.000 0.012 0.068 0.020 0.012
#> GSM414926 1 0.2365 0.499 0.896 0.000 0.012 0.000 0.024 0.068
#> GSM414927 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414929 6 0.3343 0.355 0.176 0.000 0.004 0.000 0.024 0.796
#> GSM414931 1 0.7589 -0.406 0.336 0.000 0.184 0.000 0.212 0.268
#> GSM414933 1 0.6955 -0.309 0.444 0.000 0.180 0.000 0.092 0.284
#> GSM414935 4 0.2146 0.737 0.044 0.000 0.004 0.908 0.044 0.000
#> GSM414936 5 0.0582 0.783 0.004 0.000 0.004 0.004 0.984 0.004
#> GSM414937 5 0.1970 0.773 0.008 0.000 0.000 0.092 0.900 0.000
#> GSM414939 5 0.0914 0.787 0.016 0.000 0.000 0.016 0.968 0.000
#> GSM414941 1 0.5645 0.452 0.684 0.000 0.064 0.132 0.100 0.020
#> GSM414943 5 0.0260 0.786 0.000 0.000 0.000 0.008 0.992 0.000
#> GSM414944 6 0.7617 0.401 0.132 0.000 0.288 0.004 0.284 0.292
#> GSM414945 2 0.0260 0.979 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM414946 1 0.2172 0.534 0.912 0.000 0.020 0.044 0.024 0.000
#> GSM414948 1 0.7491 -0.343 0.372 0.000 0.164 0.000 0.228 0.236
#> GSM414949 4 0.5952 -0.144 0.000 0.120 0.244 0.584 0.000 0.052
#> GSM414950 4 0.1623 0.719 0.004 0.000 0.004 0.940 0.032 0.020
#> GSM414951 5 0.3331 0.744 0.008 0.000 0.008 0.128 0.828 0.028
#> GSM414952 3 0.3857 0.891 0.000 0.000 0.532 0.468 0.000 0.000
#> GSM414954 5 0.5026 0.562 0.048 0.000 0.024 0.284 0.640 0.004
#> GSM414956 5 0.0790 0.788 0.000 0.000 0.000 0.032 0.968 0.000
#> GSM414958 6 0.6812 0.351 0.316 0.000 0.100 0.000 0.132 0.452
#> GSM414959 5 0.4467 0.607 0.088 0.000 0.076 0.004 0.772 0.060
#> GSM414960 6 0.7314 0.370 0.288 0.000 0.176 0.000 0.144 0.392
#> GSM414961 4 0.2078 0.737 0.040 0.000 0.004 0.912 0.044 0.000
#> GSM414962 2 0.1518 0.946 0.000 0.944 0.008 0.024 0.000 0.024
#> GSM414964 5 0.5501 0.408 0.056 0.000 0.028 0.376 0.536 0.004
#> GSM414965 5 0.0767 0.775 0.008 0.000 0.012 0.000 0.976 0.004
#> GSM414967 6 0.7707 0.422 0.184 0.000 0.288 0.004 0.204 0.320
#> GSM414968 4 0.4331 0.646 0.020 0.000 0.064 0.776 0.016 0.124
#> GSM414969 1 0.5056 0.454 0.716 0.000 0.080 0.092 0.000 0.112
#> GSM414971 5 0.5958 0.104 0.072 0.000 0.156 0.000 0.616 0.156
#> GSM414973 1 0.5527 0.364 0.644 0.000 0.096 0.008 0.220 0.032
#> GSM414974 2 0.3023 0.877 0.000 0.864 0.028 0.056 0.000 0.052
#> GSM414928 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.3797 0.979 0.000 0.000 0.580 0.420 0.000 0.000
#> GSM414934 3 0.3789 0.984 0.000 0.000 0.584 0.416 0.000 0.000
#> GSM414938 6 0.3748 0.303 0.060 0.020 0.048 0.016 0.016 0.840
#> GSM414940 3 0.3789 0.984 0.000 0.000 0.584 0.416 0.000 0.000
#> GSM414942 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.3789 0.984 0.000 0.000 0.584 0.416 0.000 0.000
#> GSM414955 3 0.3789 0.984 0.000 0.000 0.584 0.416 0.000 0.000
#> GSM414957 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.3789 0.984 0.000 0.000 0.584 0.416 0.000 0.000
#> GSM414966 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.3789 0.984 0.000 0.000 0.584 0.416 0.000 0.000
#> GSM414972 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.984 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> SD:skmeans 52 3.12e-08 2
#> SD:skmeans 52 6.68e-06 3
#> SD:skmeans 51 2.40e-04 4
#> SD:skmeans 48 3.89e-04 5
#> SD:skmeans 36 2.60e-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["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 51882 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.885 0.945 0.976 0.3437 0.683 0.683
#> 3 3 0.659 0.816 0.912 0.7376 0.716 0.584
#> 4 4 0.498 0.634 0.772 0.1739 0.817 0.575
#> 5 5 0.689 0.726 0.843 0.0951 0.884 0.625
#> 6 6 0.674 0.618 0.800 0.0452 0.925 0.686
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
#> GSM414924 1 0.000 0.969 1.000 0.000
#> GSM414925 1 0.000 0.969 1.000 0.000
#> GSM414926 1 0.000 0.969 1.000 0.000
#> GSM414927 2 0.000 1.000 0.000 1.000
#> GSM414929 1 0.000 0.969 1.000 0.000
#> GSM414931 1 0.000 0.969 1.000 0.000
#> GSM414933 1 0.000 0.969 1.000 0.000
#> GSM414935 1 0.000 0.969 1.000 0.000
#> GSM414936 1 0.000 0.969 1.000 0.000
#> GSM414937 1 0.000 0.969 1.000 0.000
#> GSM414939 1 0.000 0.969 1.000 0.000
#> GSM414941 1 0.000 0.969 1.000 0.000
#> GSM414943 1 0.000 0.969 1.000 0.000
#> GSM414944 1 0.000 0.969 1.000 0.000
#> GSM414945 2 0.000 1.000 0.000 1.000
#> GSM414946 1 0.000 0.969 1.000 0.000
#> GSM414948 1 0.000 0.969 1.000 0.000
#> GSM414949 1 0.518 0.861 0.884 0.116
#> GSM414950 1 0.000 0.969 1.000 0.000
#> GSM414951 1 0.000 0.969 1.000 0.000
#> GSM414952 1 0.000 0.969 1.000 0.000
#> GSM414954 1 0.000 0.969 1.000 0.000
#> GSM414956 1 0.000 0.969 1.000 0.000
#> GSM414958 1 0.000 0.969 1.000 0.000
#> GSM414959 1 0.000 0.969 1.000 0.000
#> GSM414960 1 0.000 0.969 1.000 0.000
#> GSM414961 1 0.000 0.969 1.000 0.000
#> GSM414962 1 0.993 0.237 0.548 0.452
#> GSM414964 1 0.000 0.969 1.000 0.000
#> GSM414965 1 0.000 0.969 1.000 0.000
#> GSM414967 1 0.000 0.969 1.000 0.000
#> GSM414968 1 0.000 0.969 1.000 0.000
#> GSM414969 1 0.000 0.969 1.000 0.000
#> GSM414971 1 0.000 0.969 1.000 0.000
#> GSM414973 1 0.000 0.969 1.000 0.000
#> GSM414974 1 0.689 0.782 0.816 0.184
#> GSM414928 2 0.000 1.000 0.000 1.000
#> GSM414930 2 0.000 1.000 0.000 1.000
#> GSM414932 1 0.000 0.969 1.000 0.000
#> GSM414934 1 0.000 0.969 1.000 0.000
#> GSM414938 1 0.000 0.969 1.000 0.000
#> GSM414940 1 0.000 0.969 1.000 0.000
#> GSM414942 2 0.000 1.000 0.000 1.000
#> GSM414947 2 0.000 1.000 0.000 1.000
#> GSM414953 1 0.000 0.969 1.000 0.000
#> GSM414955 1 0.000 0.969 1.000 0.000
#> GSM414957 2 0.000 1.000 0.000 1.000
#> GSM414963 1 0.881 0.602 0.700 0.300
#> GSM414966 2 0.000 1.000 0.000 1.000
#> GSM414970 1 0.689 0.782 0.816 0.184
#> GSM414972 2 0.000 1.000 0.000 1.000
#> GSM414975 2 0.000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.000 0.864 1.000 0.000 0.000
#> GSM414925 1 0.000 0.864 1.000 0.000 0.000
#> GSM414926 1 0.000 0.864 1.000 0.000 0.000
#> GSM414927 2 0.000 0.978 0.000 1.000 0.000
#> GSM414929 1 0.000 0.864 1.000 0.000 0.000
#> GSM414931 1 0.000 0.864 1.000 0.000 0.000
#> GSM414933 1 0.000 0.864 1.000 0.000 0.000
#> GSM414935 1 0.590 0.609 0.648 0.000 0.352
#> GSM414936 1 0.355 0.857 0.868 0.000 0.132
#> GSM414937 1 0.406 0.849 0.836 0.000 0.164
#> GSM414939 1 0.406 0.849 0.836 0.000 0.164
#> GSM414941 1 0.382 0.854 0.852 0.000 0.148
#> GSM414943 1 0.406 0.849 0.836 0.000 0.164
#> GSM414944 1 0.000 0.864 1.000 0.000 0.000
#> GSM414945 2 0.455 0.761 0.000 0.800 0.200
#> GSM414946 1 0.406 0.849 0.836 0.000 0.164
#> GSM414948 1 0.000 0.864 1.000 0.000 0.000
#> GSM414949 3 0.000 0.868 0.000 0.000 1.000
#> GSM414950 1 0.489 0.804 0.772 0.000 0.228
#> GSM414951 1 0.475 0.816 0.784 0.000 0.216
#> GSM414952 3 0.000 0.868 0.000 0.000 1.000
#> GSM414954 3 0.630 -0.213 0.484 0.000 0.516
#> GSM414956 1 0.475 0.816 0.784 0.000 0.216
#> GSM414958 1 0.000 0.864 1.000 0.000 0.000
#> GSM414959 1 0.475 0.816 0.784 0.000 0.216
#> GSM414960 1 0.000 0.864 1.000 0.000 0.000
#> GSM414961 3 0.630 -0.213 0.484 0.000 0.516
#> GSM414962 3 0.424 0.659 0.000 0.176 0.824
#> GSM414964 1 0.475 0.816 0.784 0.000 0.216
#> GSM414965 1 0.141 0.864 0.964 0.000 0.036
#> GSM414967 1 0.000 0.864 1.000 0.000 0.000
#> GSM414968 1 0.620 0.437 0.576 0.000 0.424
#> GSM414969 1 0.418 0.846 0.828 0.000 0.172
#> GSM414971 1 0.000 0.864 1.000 0.000 0.000
#> GSM414973 1 0.000 0.864 1.000 0.000 0.000
#> GSM414974 3 0.000 0.868 0.000 0.000 1.000
#> GSM414928 2 0.000 0.978 0.000 1.000 0.000
#> GSM414930 2 0.000 0.978 0.000 1.000 0.000
#> GSM414932 3 0.000 0.868 0.000 0.000 1.000
#> GSM414934 3 0.000 0.868 0.000 0.000 1.000
#> GSM414938 1 0.489 0.806 0.772 0.000 0.228
#> GSM414940 3 0.000 0.868 0.000 0.000 1.000
#> GSM414942 2 0.000 0.978 0.000 1.000 0.000
#> GSM414947 2 0.000 0.978 0.000 1.000 0.000
#> GSM414953 3 0.000 0.868 0.000 0.000 1.000
#> GSM414955 3 0.000 0.868 0.000 0.000 1.000
#> GSM414957 2 0.000 0.978 0.000 1.000 0.000
#> GSM414963 3 0.000 0.868 0.000 0.000 1.000
#> GSM414966 2 0.000 0.978 0.000 1.000 0.000
#> GSM414970 3 0.000 0.868 0.000 0.000 1.000
#> GSM414972 2 0.000 0.978 0.000 1.000 0.000
#> GSM414975 2 0.000 0.978 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 4 0.4406 0.746 0.300 0.000 0.000 0.700
#> GSM414925 4 0.4985 0.351 0.468 0.000 0.000 0.532
#> GSM414926 4 0.4585 0.725 0.332 0.000 0.000 0.668
#> GSM414927 2 0.0000 0.885 0.000 1.000 0.000 0.000
#> GSM414929 4 0.3123 0.674 0.156 0.000 0.000 0.844
#> GSM414931 4 0.4961 0.570 0.448 0.000 0.000 0.552
#> GSM414933 4 0.4431 0.746 0.304 0.000 0.000 0.696
#> GSM414935 1 0.3088 0.632 0.888 0.000 0.060 0.052
#> GSM414936 1 0.0707 0.641 0.980 0.000 0.000 0.020
#> GSM414937 1 0.0000 0.657 1.000 0.000 0.000 0.000
#> GSM414939 1 0.0000 0.657 1.000 0.000 0.000 0.000
#> GSM414941 1 0.3123 0.568 0.844 0.000 0.000 0.156
#> GSM414943 1 0.0000 0.657 1.000 0.000 0.000 0.000
#> GSM414944 1 0.4040 0.191 0.752 0.000 0.000 0.248
#> GSM414945 2 0.3610 0.686 0.000 0.800 0.200 0.000
#> GSM414946 1 0.4331 0.398 0.712 0.000 0.000 0.288
#> GSM414948 1 0.4916 -0.377 0.576 0.000 0.000 0.424
#> GSM414949 3 0.3447 0.928 0.128 0.000 0.852 0.020
#> GSM414950 1 0.1520 0.652 0.956 0.000 0.020 0.024
#> GSM414951 1 0.0336 0.658 0.992 0.000 0.008 0.000
#> GSM414952 3 0.3088 0.935 0.128 0.000 0.864 0.008
#> GSM414954 1 0.5268 0.214 0.592 0.000 0.396 0.012
#> GSM414956 1 0.0336 0.658 0.992 0.000 0.008 0.000
#> GSM414958 4 0.4830 0.502 0.392 0.000 0.000 0.608
#> GSM414959 1 0.3249 0.584 0.852 0.000 0.008 0.140
#> GSM414960 4 0.3123 0.674 0.156 0.000 0.000 0.844
#> GSM414961 1 0.5571 0.194 0.580 0.000 0.396 0.024
#> GSM414962 3 0.8687 0.522 0.096 0.156 0.504 0.244
#> GSM414964 1 0.3545 0.582 0.828 0.000 0.008 0.164
#> GSM414965 1 0.2281 0.535 0.904 0.000 0.000 0.096
#> GSM414967 4 0.4830 0.687 0.392 0.000 0.000 0.608
#> GSM414968 1 0.2741 0.603 0.892 0.000 0.096 0.012
#> GSM414969 1 0.4406 0.393 0.700 0.000 0.000 0.300
#> GSM414971 1 0.4916 -0.377 0.576 0.000 0.000 0.424
#> GSM414973 1 0.4564 0.131 0.672 0.000 0.000 0.328
#> GSM414974 3 0.5800 0.781 0.128 0.000 0.708 0.164
#> GSM414928 2 0.0000 0.885 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 0.885 0.000 1.000 0.000 0.000
#> GSM414932 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414934 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414938 1 0.5203 0.192 0.576 0.000 0.008 0.416
#> GSM414940 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414942 2 0.5483 0.851 0.000 0.736 0.128 0.136
#> GSM414947 2 0.0000 0.885 0.000 1.000 0.000 0.000
#> GSM414953 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414955 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414957 2 0.0000 0.885 0.000 1.000 0.000 0.000
#> GSM414963 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414966 2 0.5483 0.851 0.000 0.736 0.128 0.136
#> GSM414970 3 0.2760 0.939 0.128 0.000 0.872 0.000
#> GSM414972 2 0.5483 0.851 0.000 0.736 0.128 0.136
#> GSM414975 2 0.5483 0.851 0.000 0.736 0.128 0.136
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.2848 0.747 0.840 0.000 0.000 0.004 0.156
#> GSM414925 1 0.5702 0.415 0.628 0.000 0.000 0.180 0.192
#> GSM414926 1 0.3231 0.734 0.800 0.000 0.000 0.004 0.196
#> GSM414927 2 0.0000 0.845 0.000 1.000 0.000 0.000 0.000
#> GSM414929 1 0.0000 0.660 1.000 0.000 0.000 0.000 0.000
#> GSM414931 1 0.4060 0.641 0.640 0.000 0.000 0.000 0.360
#> GSM414933 1 0.2732 0.747 0.840 0.000 0.000 0.000 0.160
#> GSM414935 5 0.3513 0.716 0.020 0.000 0.000 0.180 0.800
#> GSM414936 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414937 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414939 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414941 5 0.1952 0.757 0.084 0.000 0.000 0.004 0.912
#> GSM414943 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414944 5 0.2424 0.656 0.132 0.000 0.000 0.000 0.868
#> GSM414945 2 0.3074 0.690 0.000 0.804 0.196 0.000 0.000
#> GSM414946 5 0.5421 0.510 0.276 0.000 0.000 0.096 0.628
#> GSM414948 1 0.4256 0.573 0.564 0.000 0.000 0.000 0.436
#> GSM414949 3 0.2891 0.774 0.000 0.000 0.824 0.176 0.000
#> GSM414950 5 0.2929 0.717 0.000 0.000 0.000 0.180 0.820
#> GSM414951 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414952 3 0.1608 0.830 0.000 0.000 0.928 0.072 0.000
#> GSM414954 3 0.5519 0.441 0.000 0.000 0.584 0.084 0.332
#> GSM414956 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414958 1 0.3424 0.645 0.760 0.000 0.000 0.000 0.240
#> GSM414959 5 0.1792 0.757 0.084 0.000 0.000 0.000 0.916
#> GSM414960 1 0.0000 0.660 1.000 0.000 0.000 0.000 0.000
#> GSM414961 3 0.5980 0.515 0.000 0.000 0.584 0.176 0.240
#> GSM414962 2 0.6455 0.422 0.036 0.548 0.320 0.096 0.000
#> GSM414964 5 0.4612 0.688 0.084 0.000 0.000 0.180 0.736
#> GSM414965 5 0.0000 0.793 0.000 0.000 0.000 0.000 1.000
#> GSM414967 1 0.3707 0.711 0.716 0.000 0.000 0.000 0.284
#> GSM414968 5 0.2068 0.762 0.000 0.000 0.004 0.092 0.904
#> GSM414969 5 0.6200 0.457 0.280 0.000 0.000 0.180 0.540
#> GSM414971 1 0.4256 0.573 0.564 0.000 0.000 0.000 0.436
#> GSM414973 5 0.4074 0.107 0.364 0.000 0.000 0.000 0.636
#> GSM414974 3 0.4612 0.708 0.084 0.000 0.736 0.180 0.000
#> GSM414928 2 0.0000 0.845 0.000 1.000 0.000 0.000 0.000
#> GSM414930 2 0.0162 0.842 0.000 0.996 0.000 0.004 0.000
#> GSM414932 3 0.0000 0.852 0.000 0.000 1.000 0.000 0.000
#> GSM414934 3 0.0510 0.849 0.000 0.000 0.984 0.016 0.000
#> GSM414938 5 0.4256 0.402 0.436 0.000 0.000 0.000 0.564
#> GSM414940 3 0.0000 0.852 0.000 0.000 1.000 0.000 0.000
#> GSM414942 4 0.3074 1.000 0.000 0.196 0.000 0.804 0.000
#> GSM414947 2 0.0000 0.845 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0510 0.849 0.000 0.000 0.984 0.016 0.000
#> GSM414955 3 0.0162 0.853 0.000 0.000 0.996 0.004 0.000
#> GSM414957 2 0.0000 0.845 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0000 0.852 0.000 0.000 1.000 0.000 0.000
#> GSM414966 4 0.3074 1.000 0.000 0.196 0.000 0.804 0.000
#> GSM414970 3 0.0000 0.852 0.000 0.000 1.000 0.000 0.000
#> GSM414972 4 0.3074 1.000 0.000 0.196 0.000 0.804 0.000
#> GSM414975 4 0.3074 1.000 0.000 0.196 0.000 0.804 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 6 0.375 0.74714 0.072 0.000 0.000 0.000 0.152 0.776
#> GSM414925 1 0.551 0.41941 0.556 0.000 0.000 0.000 0.184 0.260
#> GSM414926 6 0.587 0.08551 0.384 0.000 0.000 0.000 0.196 0.420
#> GSM414927 2 0.000 0.83459 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414929 1 0.399 0.00321 0.528 0.000 0.000 0.004 0.000 0.468
#> GSM414931 6 0.364 0.75859 0.028 0.000 0.000 0.000 0.224 0.748
#> GSM414933 6 0.344 0.75517 0.048 0.000 0.000 0.000 0.156 0.796
#> GSM414935 5 0.344 0.48933 0.260 0.000 0.000 0.000 0.732 0.008
#> GSM414936 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414937 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414939 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414941 5 0.424 0.08249 0.368 0.000 0.000 0.000 0.608 0.024
#> GSM414943 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414944 5 0.226 0.61637 0.000 0.000 0.000 0.000 0.860 0.140
#> GSM414945 2 0.273 0.68587 0.000 0.808 0.192 0.000 0.000 0.000
#> GSM414946 1 0.507 0.19781 0.476 0.000 0.000 0.000 0.448 0.076
#> GSM414948 6 0.329 0.73953 0.000 0.000 0.000 0.000 0.276 0.724
#> GSM414949 3 0.276 0.74557 0.196 0.000 0.804 0.000 0.000 0.000
#> GSM414950 5 0.285 0.54790 0.208 0.000 0.000 0.000 0.792 0.000
#> GSM414951 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414952 3 0.161 0.81872 0.084 0.000 0.916 0.000 0.000 0.000
#> GSM414954 3 0.503 0.40490 0.100 0.000 0.596 0.000 0.304 0.000
#> GSM414956 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414958 6 0.322 0.47882 0.192 0.000 0.000 0.004 0.012 0.792
#> GSM414959 5 0.417 0.14395 0.344 0.000 0.000 0.000 0.632 0.024
#> GSM414960 6 0.026 0.61536 0.008 0.000 0.000 0.000 0.000 0.992
#> GSM414961 3 0.540 0.43175 0.204 0.000 0.584 0.000 0.212 0.000
#> GSM414962 2 0.604 0.30291 0.232 0.456 0.308 0.000 0.000 0.004
#> GSM414964 1 0.438 0.17184 0.540 0.000 0.000 0.000 0.436 0.024
#> GSM414965 5 0.000 0.75830 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414967 6 0.374 0.75139 0.032 0.000 0.000 0.000 0.228 0.740
#> GSM414968 5 0.205 0.65764 0.120 0.000 0.000 0.000 0.880 0.000
#> GSM414969 1 0.492 0.33620 0.576 0.000 0.000 0.000 0.348 0.076
#> GSM414971 6 0.329 0.73953 0.000 0.000 0.000 0.000 0.276 0.724
#> GSM414973 5 0.573 -0.16619 0.360 0.000 0.000 0.000 0.468 0.172
#> GSM414974 1 0.433 0.03123 0.572 0.000 0.404 0.000 0.000 0.024
#> GSM414928 2 0.000 0.83459 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414930 2 0.026 0.82841 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM414932 3 0.000 0.84107 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414934 3 0.270 0.79510 0.004 0.000 0.824 0.172 0.000 0.000
#> GSM414938 1 0.400 0.25954 0.744 0.000 0.000 0.020 0.024 0.212
#> GSM414940 3 0.000 0.84107 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414942 4 0.273 1.00000 0.000 0.192 0.000 0.808 0.000 0.000
#> GSM414947 2 0.000 0.83459 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.270 0.79510 0.004 0.000 0.824 0.172 0.000 0.000
#> GSM414955 3 0.026 0.84094 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM414957 2 0.000 0.83459 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.000 0.84107 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414966 4 0.273 1.00000 0.000 0.192 0.000 0.808 0.000 0.000
#> GSM414970 3 0.000 0.84107 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414972 4 0.273 1.00000 0.000 0.192 0.000 0.808 0.000 0.000
#> GSM414975 4 0.273 1.00000 0.000 0.192 0.000 0.808 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> SD:pam 51 9.13e-04 2
#> SD:pam 49 2.54e-06 3
#> SD:pam 42 2.57e-05 4
#> SD:pam 46 1.06e-05 5
#> SD:pam 36 7.58e-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", "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 51882 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.597 0.887 0.946 0.3842 0.638 0.638
#> 3 3 0.958 0.915 0.953 0.6323 0.701 0.545
#> 4 4 0.520 0.546 0.771 0.0857 0.854 0.677
#> 5 5 0.561 0.510 0.717 0.0990 0.778 0.471
#> 6 6 0.580 0.411 0.619 0.0630 0.910 0.649
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
#> GSM414924 1 0.000 0.937 1.000 0.000
#> GSM414925 1 0.000 0.937 1.000 0.000
#> GSM414926 1 0.000 0.937 1.000 0.000
#> GSM414927 2 0.000 0.936 0.000 1.000
#> GSM414929 1 0.000 0.937 1.000 0.000
#> GSM414931 1 0.000 0.937 1.000 0.000
#> GSM414933 1 0.000 0.937 1.000 0.000
#> GSM414935 1 0.000 0.937 1.000 0.000
#> GSM414936 1 0.000 0.937 1.000 0.000
#> GSM414937 1 0.000 0.937 1.000 0.000
#> GSM414939 1 0.000 0.937 1.000 0.000
#> GSM414941 1 0.000 0.937 1.000 0.000
#> GSM414943 1 0.000 0.937 1.000 0.000
#> GSM414944 1 0.855 0.591 0.720 0.280
#> GSM414945 2 0.644 0.798 0.164 0.836
#> GSM414946 1 0.000 0.937 1.000 0.000
#> GSM414948 1 0.000 0.937 1.000 0.000
#> GSM414949 1 0.730 0.768 0.796 0.204
#> GSM414950 1 0.000 0.937 1.000 0.000
#> GSM414951 1 0.000 0.937 1.000 0.000
#> GSM414952 1 0.482 0.870 0.896 0.104
#> GSM414954 1 0.000 0.937 1.000 0.000
#> GSM414956 1 0.000 0.937 1.000 0.000
#> GSM414958 1 0.000 0.937 1.000 0.000
#> GSM414959 1 0.000 0.937 1.000 0.000
#> GSM414960 1 0.000 0.937 1.000 0.000
#> GSM414961 1 0.000 0.937 1.000 0.000
#> GSM414962 2 0.644 0.798 0.164 0.836
#> GSM414964 1 0.000 0.937 1.000 0.000
#> GSM414965 1 0.000 0.937 1.000 0.000
#> GSM414967 1 0.855 0.591 0.720 0.280
#> GSM414968 1 0.000 0.937 1.000 0.000
#> GSM414969 1 0.000 0.937 1.000 0.000
#> GSM414971 1 0.000 0.937 1.000 0.000
#> GSM414973 1 0.000 0.937 1.000 0.000
#> GSM414974 2 0.876 0.578 0.296 0.704
#> GSM414928 2 0.000 0.936 0.000 1.000
#> GSM414930 2 0.000 0.936 0.000 1.000
#> GSM414932 1 0.605 0.836 0.852 0.148
#> GSM414934 1 0.605 0.836 0.852 0.148
#> GSM414938 1 0.839 0.616 0.732 0.268
#> GSM414940 1 0.605 0.836 0.852 0.148
#> GSM414942 2 0.000 0.936 0.000 1.000
#> GSM414947 2 0.000 0.936 0.000 1.000
#> GSM414953 1 0.605 0.836 0.852 0.148
#> GSM414955 1 0.605 0.836 0.852 0.148
#> GSM414957 2 0.000 0.936 0.000 1.000
#> GSM414963 1 0.605 0.836 0.852 0.148
#> GSM414966 2 0.000 0.936 0.000 1.000
#> GSM414970 1 0.605 0.836 0.852 0.148
#> GSM414972 2 0.000 0.936 0.000 1.000
#> GSM414975 2 0.000 0.936 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.2165 0.926 0.936 0.000 0.064
#> GSM414925 1 0.1964 0.930 0.944 0.000 0.056
#> GSM414926 1 0.2165 0.926 0.936 0.000 0.064
#> GSM414927 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414929 1 0.0592 0.939 0.988 0.000 0.012
#> GSM414931 1 0.0592 0.933 0.988 0.000 0.012
#> GSM414933 1 0.0592 0.933 0.988 0.000 0.012
#> GSM414935 3 0.1163 0.954 0.028 0.000 0.972
#> GSM414936 1 0.0747 0.944 0.984 0.000 0.016
#> GSM414937 1 0.0892 0.944 0.980 0.000 0.020
#> GSM414939 1 0.0892 0.944 0.980 0.000 0.020
#> GSM414941 1 0.2261 0.924 0.932 0.000 0.068
#> GSM414943 1 0.0747 0.944 0.984 0.000 0.016
#> GSM414944 1 0.1267 0.926 0.972 0.004 0.024
#> GSM414945 2 0.4349 0.842 0.020 0.852 0.128
#> GSM414946 1 0.2066 0.929 0.940 0.000 0.060
#> GSM414948 1 0.0747 0.944 0.984 0.000 0.016
#> GSM414949 3 0.0592 0.961 0.012 0.000 0.988
#> GSM414950 3 0.1163 0.954 0.028 0.000 0.972
#> GSM414951 1 0.1411 0.940 0.964 0.000 0.036
#> GSM414952 3 0.0892 0.959 0.020 0.000 0.980
#> GSM414954 1 0.1529 0.939 0.960 0.000 0.040
#> GSM414956 1 0.0747 0.944 0.984 0.000 0.016
#> GSM414958 1 0.0424 0.942 0.992 0.000 0.008
#> GSM414959 1 0.0592 0.943 0.988 0.000 0.012
#> GSM414960 1 0.0592 0.933 0.988 0.000 0.012
#> GSM414961 3 0.1529 0.945 0.040 0.000 0.960
#> GSM414962 3 0.6521 0.596 0.040 0.248 0.712
#> GSM414964 1 0.2261 0.924 0.932 0.000 0.068
#> GSM414965 1 0.0747 0.944 0.984 0.000 0.016
#> GSM414967 1 0.1267 0.926 0.972 0.004 0.024
#> GSM414968 3 0.3038 0.871 0.104 0.000 0.896
#> GSM414969 1 0.6126 0.379 0.600 0.000 0.400
#> GSM414971 1 0.0424 0.942 0.992 0.000 0.008
#> GSM414973 1 0.0892 0.944 0.980 0.000 0.020
#> GSM414974 3 0.0592 0.942 0.000 0.012 0.988
#> GSM414928 2 0.0592 0.976 0.000 0.988 0.012
#> GSM414930 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414932 3 0.0592 0.961 0.012 0.000 0.988
#> GSM414934 3 0.0747 0.959 0.016 0.000 0.984
#> GSM414938 1 0.9569 0.224 0.480 0.240 0.280
#> GSM414940 3 0.0592 0.961 0.012 0.000 0.988
#> GSM414942 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414953 3 0.0747 0.959 0.016 0.000 0.984
#> GSM414955 3 0.0592 0.961 0.012 0.000 0.988
#> GSM414957 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414963 3 0.0592 0.961 0.012 0.000 0.988
#> GSM414966 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414970 3 0.0592 0.961 0.012 0.000 0.988
#> GSM414972 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.983 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.2973 0.5546 0.884 0.000 0.096 0.020
#> GSM414925 1 0.2473 0.6244 0.908 0.000 0.012 0.080
#> GSM414926 1 0.2973 0.5546 0.884 0.000 0.096 0.020
#> GSM414927 2 0.0188 0.9325 0.000 0.996 0.004 0.000
#> GSM414929 1 0.6668 -0.5085 0.528 0.000 0.092 0.380
#> GSM414931 1 0.5694 0.2971 0.696 0.000 0.080 0.224
#> GSM414933 1 0.4830 -0.1958 0.608 0.000 0.000 0.392
#> GSM414935 1 0.7463 -0.0553 0.456 0.000 0.364 0.180
#> GSM414936 1 0.1576 0.6205 0.948 0.000 0.004 0.048
#> GSM414937 1 0.1545 0.6364 0.952 0.000 0.040 0.008
#> GSM414939 1 0.0672 0.6352 0.984 0.000 0.008 0.008
#> GSM414941 1 0.2892 0.6267 0.896 0.000 0.036 0.068
#> GSM414943 1 0.2048 0.6137 0.928 0.000 0.008 0.064
#> GSM414944 4 0.4605 1.0000 0.336 0.000 0.000 0.664
#> GSM414945 2 0.6491 0.3785 0.000 0.528 0.076 0.396
#> GSM414946 1 0.2271 0.6295 0.916 0.000 0.008 0.076
#> GSM414948 1 0.2530 0.5862 0.888 0.000 0.000 0.112
#> GSM414949 3 0.6139 0.7183 0.120 0.008 0.696 0.176
#> GSM414950 1 0.7495 -0.1455 0.428 0.000 0.392 0.180
#> GSM414951 1 0.1211 0.6371 0.960 0.000 0.040 0.000
#> GSM414952 3 0.6285 0.6815 0.168 0.000 0.664 0.168
#> GSM414954 1 0.2500 0.6321 0.916 0.000 0.040 0.044
#> GSM414956 1 0.2799 0.5792 0.884 0.000 0.008 0.108
#> GSM414958 1 0.3447 0.5536 0.852 0.000 0.020 0.128
#> GSM414959 1 0.2345 0.5769 0.900 0.000 0.000 0.100
#> GSM414960 1 0.4916 -0.2877 0.576 0.000 0.000 0.424
#> GSM414961 1 0.7441 -0.0178 0.468 0.000 0.352 0.180
#> GSM414962 3 0.9336 0.1438 0.088 0.284 0.352 0.276
#> GSM414964 1 0.3128 0.6179 0.884 0.000 0.040 0.076
#> GSM414965 1 0.1978 0.6116 0.928 0.000 0.004 0.068
#> GSM414967 4 0.4605 1.0000 0.336 0.000 0.000 0.664
#> GSM414968 1 0.7500 -0.1753 0.416 0.000 0.404 0.180
#> GSM414969 1 0.3796 0.6053 0.848 0.000 0.056 0.096
#> GSM414971 1 0.4581 0.4795 0.800 0.000 0.080 0.120
#> GSM414973 1 0.1022 0.6389 0.968 0.000 0.032 0.000
#> GSM414974 3 0.9407 0.2233 0.108 0.236 0.380 0.276
#> GSM414928 2 0.0188 0.9325 0.000 0.996 0.004 0.000
#> GSM414930 2 0.0000 0.9331 0.000 1.000 0.000 0.000
#> GSM414932 3 0.2345 0.8029 0.100 0.000 0.900 0.000
#> GSM414934 3 0.4731 0.7592 0.100 0.004 0.800 0.096
#> GSM414938 1 0.9278 -0.5771 0.372 0.104 0.192 0.332
#> GSM414940 3 0.2345 0.8029 0.100 0.000 0.900 0.000
#> GSM414942 2 0.1302 0.9293 0.000 0.956 0.000 0.044
#> GSM414947 2 0.0000 0.9331 0.000 1.000 0.000 0.000
#> GSM414953 3 0.4731 0.7592 0.100 0.004 0.800 0.096
#> GSM414955 3 0.2469 0.8009 0.108 0.000 0.892 0.000
#> GSM414957 2 0.0469 0.9283 0.000 0.988 0.012 0.000
#> GSM414963 3 0.2281 0.8025 0.096 0.000 0.904 0.000
#> GSM414966 2 0.1389 0.9286 0.000 0.952 0.000 0.048
#> GSM414970 3 0.2281 0.8025 0.096 0.000 0.904 0.000
#> GSM414972 2 0.1389 0.9286 0.000 0.952 0.000 0.048
#> GSM414975 2 0.1302 0.9293 0.000 0.956 0.000 0.044
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 4 0.4227 0.3017 0.420 0.000 0.000 0.580 0.000
#> GSM414925 4 0.4287 0.2195 0.460 0.000 0.000 0.540 0.000
#> GSM414926 4 0.4306 0.0742 0.492 0.000 0.000 0.508 0.000
#> GSM414927 2 0.0000 0.9746 0.000 1.000 0.000 0.000 0.000
#> GSM414929 1 0.5558 0.3137 0.620 0.000 0.000 0.268 0.112
#> GSM414931 1 0.3389 0.5626 0.836 0.000 0.000 0.116 0.048
#> GSM414933 1 0.4930 0.4071 0.684 0.000 0.000 0.244 0.072
#> GSM414935 3 0.7316 0.3785 0.296 0.000 0.412 0.264 0.028
#> GSM414936 1 0.2037 0.6302 0.920 0.000 0.064 0.012 0.004
#> GSM414937 1 0.3593 0.5908 0.824 0.000 0.116 0.060 0.000
#> GSM414939 1 0.3584 0.5912 0.832 0.000 0.108 0.056 0.004
#> GSM414941 1 0.4610 0.0488 0.596 0.000 0.016 0.388 0.000
#> GSM414943 1 0.2938 0.6285 0.880 0.000 0.064 0.048 0.008
#> GSM414944 5 0.6615 0.2232 0.376 0.000 0.000 0.216 0.408
#> GSM414945 5 0.5409 0.1359 0.004 0.332 0.000 0.064 0.600
#> GSM414946 1 0.4273 -0.1192 0.552 0.000 0.000 0.448 0.000
#> GSM414948 1 0.3796 0.4100 0.700 0.000 0.000 0.300 0.000
#> GSM414949 3 0.4820 0.5551 0.012 0.016 0.708 0.248 0.016
#> GSM414950 3 0.7186 0.4563 0.244 0.000 0.456 0.272 0.028
#> GSM414951 1 0.3242 0.5974 0.844 0.000 0.116 0.040 0.000
#> GSM414952 3 0.3838 0.6384 0.108 0.000 0.820 0.064 0.008
#> GSM414954 1 0.4827 0.4768 0.724 0.000 0.160 0.116 0.000
#> GSM414956 1 0.3736 0.5971 0.836 0.000 0.020 0.052 0.092
#> GSM414958 1 0.3563 0.5036 0.780 0.000 0.000 0.208 0.012
#> GSM414959 1 0.3042 0.6349 0.880 0.000 0.044 0.056 0.020
#> GSM414960 1 0.5027 0.4206 0.700 0.000 0.000 0.188 0.112
#> GSM414961 3 0.7244 0.4265 0.268 0.000 0.440 0.264 0.028
#> GSM414962 4 0.7130 0.2487 0.044 0.204 0.156 0.576 0.020
#> GSM414964 1 0.5072 0.3889 0.696 0.000 0.116 0.188 0.000
#> GSM414965 1 0.2284 0.6367 0.912 0.000 0.056 0.028 0.004
#> GSM414967 5 0.6682 0.2214 0.368 0.000 0.000 0.236 0.396
#> GSM414968 3 0.7165 0.4782 0.236 0.000 0.476 0.256 0.032
#> GSM414969 4 0.5268 0.4006 0.320 0.000 0.068 0.612 0.000
#> GSM414971 1 0.2069 0.6026 0.912 0.000 0.000 0.076 0.012
#> GSM414973 1 0.4060 0.2547 0.640 0.000 0.000 0.360 0.000
#> GSM414974 4 0.7315 0.2872 0.072 0.176 0.164 0.572 0.016
#> GSM414928 2 0.0290 0.9708 0.000 0.992 0.000 0.008 0.000
#> GSM414930 2 0.0000 0.9746 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.0162 0.6476 0.000 0.000 0.996 0.004 0.000
#> GSM414934 5 0.4219 0.0790 0.000 0.000 0.416 0.000 0.584
#> GSM414938 5 0.7042 0.1453 0.232 0.004 0.008 0.352 0.404
#> GSM414940 3 0.0000 0.6470 0.000 0.000 1.000 0.000 0.000
#> GSM414942 2 0.1282 0.9697 0.000 0.952 0.000 0.004 0.044
#> GSM414947 2 0.0000 0.9746 0.000 1.000 0.000 0.000 0.000
#> GSM414953 5 0.4219 0.0790 0.000 0.000 0.416 0.000 0.584
#> GSM414955 3 0.0404 0.6487 0.012 0.000 0.988 0.000 0.000
#> GSM414957 2 0.0162 0.9732 0.000 0.996 0.000 0.000 0.004
#> GSM414963 3 0.0162 0.6465 0.000 0.000 0.996 0.000 0.004
#> GSM414966 2 0.1282 0.9697 0.000 0.952 0.000 0.004 0.044
#> GSM414970 3 0.0000 0.6470 0.000 0.000 1.000 0.000 0.000
#> GSM414972 2 0.1282 0.9697 0.000 0.952 0.000 0.004 0.044
#> GSM414975 2 0.1282 0.9697 0.000 0.952 0.000 0.004 0.044
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.5504 0.5611 0.604 0.000 0.000 0.136 0.244 0.016
#> GSM414925 1 0.6210 0.4905 0.452 0.000 0.000 0.164 0.360 0.024
#> GSM414926 1 0.5582 0.5198 0.588 0.000 0.000 0.100 0.284 0.028
#> GSM414927 2 0.0865 0.9333 0.036 0.964 0.000 0.000 0.000 0.000
#> GSM414929 5 0.5475 -0.0878 0.064 0.000 0.008 0.012 0.488 0.428
#> GSM414931 5 0.3879 0.3130 0.020 0.000 0.000 0.000 0.688 0.292
#> GSM414933 5 0.5482 0.0850 0.064 0.000 0.004 0.020 0.524 0.388
#> GSM414935 4 0.2778 0.5833 0.008 0.000 0.000 0.824 0.168 0.000
#> GSM414936 5 0.2092 0.4973 0.000 0.000 0.000 0.124 0.876 0.000
#> GSM414937 5 0.5551 0.0905 0.096 0.000 0.004 0.336 0.552 0.012
#> GSM414939 5 0.4801 0.2270 0.060 0.000 0.004 0.272 0.656 0.008
#> GSM414941 5 0.5956 -0.4511 0.380 0.000 0.000 0.188 0.428 0.004
#> GSM414943 5 0.2263 0.4924 0.000 0.000 0.000 0.100 0.884 0.016
#> GSM414944 6 0.4433 0.3573 0.000 0.000 0.040 0.000 0.344 0.616
#> GSM414945 6 0.7324 0.1404 0.048 0.292 0.308 0.000 0.020 0.332
#> GSM414946 1 0.5907 0.4350 0.424 0.000 0.000 0.176 0.396 0.004
#> GSM414948 5 0.5689 0.2717 0.200 0.000 0.000 0.004 0.548 0.248
#> GSM414949 4 0.5767 -0.3102 0.256 0.004 0.208 0.532 0.000 0.000
#> GSM414950 4 0.2834 0.5608 0.016 0.000 0.008 0.848 0.128 0.000
#> GSM414951 5 0.5027 0.0346 0.040 0.000 0.004 0.360 0.580 0.016
#> GSM414952 4 0.5176 -0.3566 0.004 0.000 0.384 0.532 0.080 0.000
#> GSM414954 4 0.5473 0.0959 0.072 0.000 0.004 0.464 0.448 0.012
#> GSM414956 5 0.3862 0.4580 0.000 0.000 0.088 0.100 0.796 0.016
#> GSM414958 5 0.4929 0.3034 0.100 0.000 0.000 0.000 0.620 0.280
#> GSM414959 5 0.3256 0.4899 0.012 0.000 0.008 0.112 0.840 0.028
#> GSM414960 5 0.4332 0.0792 0.016 0.000 0.004 0.000 0.564 0.416
#> GSM414961 4 0.3849 0.5809 0.032 0.000 0.008 0.752 0.208 0.000
#> GSM414962 1 0.6481 0.1545 0.584 0.076 0.088 0.228 0.020 0.004
#> GSM414964 4 0.5345 0.1453 0.068 0.000 0.004 0.472 0.448 0.008
#> GSM414965 5 0.1958 0.4965 0.000 0.000 0.000 0.100 0.896 0.004
#> GSM414967 6 0.4606 0.3159 0.000 0.000 0.052 0.000 0.344 0.604
#> GSM414968 4 0.3317 0.5530 0.004 0.000 0.032 0.808 0.156 0.000
#> GSM414969 1 0.5647 0.5526 0.552 0.000 0.000 0.184 0.260 0.004
#> GSM414971 5 0.3811 0.3688 0.016 0.000 0.004 0.004 0.732 0.244
#> GSM414973 5 0.4870 0.1242 0.320 0.000 0.000 0.008 0.612 0.060
#> GSM414974 1 0.6460 0.1571 0.588 0.076 0.088 0.224 0.020 0.004
#> GSM414928 2 0.1829 0.9095 0.056 0.920 0.000 0.024 0.000 0.000
#> GSM414930 2 0.0363 0.9398 0.012 0.988 0.000 0.000 0.000 0.000
#> GSM414932 3 0.3868 0.6240 0.000 0.000 0.508 0.492 0.000 0.000
#> GSM414934 3 0.4576 0.1255 0.072 0.000 0.692 0.008 0.000 0.228
#> GSM414938 6 0.7932 0.2638 0.276 0.024 0.136 0.000 0.232 0.332
#> GSM414940 3 0.3866 0.6293 0.000 0.000 0.516 0.484 0.000 0.000
#> GSM414942 2 0.1501 0.9374 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM414947 2 0.0363 0.9398 0.012 0.988 0.000 0.000 0.000 0.000
#> GSM414953 3 0.4541 0.1479 0.072 0.000 0.708 0.012 0.000 0.208
#> GSM414955 3 0.3997 0.6232 0.000 0.000 0.508 0.488 0.004 0.000
#> GSM414957 2 0.2077 0.9146 0.020 0.924 0.012 0.024 0.000 0.020
#> GSM414963 3 0.4211 0.6227 0.004 0.000 0.532 0.456 0.000 0.008
#> GSM414966 2 0.1501 0.9374 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM414970 3 0.3993 0.6301 0.004 0.000 0.520 0.476 0.000 0.000
#> GSM414972 2 0.1501 0.9374 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM414975 2 0.1501 0.9374 0.000 0.924 0.000 0.000 0.000 0.076
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> SD:mclust 52 6.62e-03 2
#> SD:mclust 50 4.54e-06 3
#> SD:mclust 39 2.62e-06 4
#> SD:mclust 27 1.42e-04 5
#> SD:mclust 21 6.34e-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["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 51882 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.959 0.938 0.975 0.3643 0.660 0.660
#> 3 3 0.894 0.922 0.966 0.7409 0.697 0.546
#> 4 4 0.774 0.736 0.872 0.0954 0.946 0.855
#> 5 5 0.744 0.753 0.867 0.0783 0.903 0.717
#> 6 6 0.710 0.734 0.857 0.0512 0.949 0.815
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
#> GSM414924 1 0.000 0.969 1.000 0.000
#> GSM414925 1 0.000 0.969 1.000 0.000
#> GSM414926 1 0.000 0.969 1.000 0.000
#> GSM414927 2 0.000 0.993 0.000 1.000
#> GSM414929 1 0.000 0.969 1.000 0.000
#> GSM414931 1 0.000 0.969 1.000 0.000
#> GSM414933 1 0.000 0.969 1.000 0.000
#> GSM414935 1 0.000 0.969 1.000 0.000
#> GSM414936 1 0.000 0.969 1.000 0.000
#> GSM414937 1 0.000 0.969 1.000 0.000
#> GSM414939 1 0.000 0.969 1.000 0.000
#> GSM414941 1 0.000 0.969 1.000 0.000
#> GSM414943 1 0.000 0.969 1.000 0.000
#> GSM414944 1 0.000 0.969 1.000 0.000
#> GSM414945 2 0.000 0.993 0.000 1.000
#> GSM414946 1 0.000 0.969 1.000 0.000
#> GSM414948 1 0.000 0.969 1.000 0.000
#> GSM414949 1 0.714 0.753 0.804 0.196
#> GSM414950 1 0.000 0.969 1.000 0.000
#> GSM414951 1 0.000 0.969 1.000 0.000
#> GSM414952 1 0.000 0.969 1.000 0.000
#> GSM414954 1 0.000 0.969 1.000 0.000
#> GSM414956 1 0.000 0.969 1.000 0.000
#> GSM414958 1 0.000 0.969 1.000 0.000
#> GSM414959 1 0.000 0.969 1.000 0.000
#> GSM414960 1 0.000 0.969 1.000 0.000
#> GSM414961 1 0.000 0.969 1.000 0.000
#> GSM414962 2 0.343 0.928 0.064 0.936
#> GSM414964 1 0.000 0.969 1.000 0.000
#> GSM414965 1 0.000 0.969 1.000 0.000
#> GSM414967 1 0.000 0.969 1.000 0.000
#> GSM414968 1 0.000 0.969 1.000 0.000
#> GSM414969 1 0.000 0.969 1.000 0.000
#> GSM414971 1 0.000 0.969 1.000 0.000
#> GSM414973 1 0.000 0.969 1.000 0.000
#> GSM414974 1 0.992 0.227 0.552 0.448
#> GSM414928 2 0.000 0.993 0.000 1.000
#> GSM414930 2 0.000 0.993 0.000 1.000
#> GSM414932 1 0.000 0.969 1.000 0.000
#> GSM414934 1 0.000 0.969 1.000 0.000
#> GSM414938 1 0.000 0.969 1.000 0.000
#> GSM414940 1 0.000 0.969 1.000 0.000
#> GSM414942 2 0.000 0.993 0.000 1.000
#> GSM414947 2 0.000 0.993 0.000 1.000
#> GSM414953 1 0.000 0.969 1.000 0.000
#> GSM414955 1 0.000 0.969 1.000 0.000
#> GSM414957 2 0.000 0.993 0.000 1.000
#> GSM414963 1 0.990 0.251 0.560 0.440
#> GSM414966 2 0.000 0.993 0.000 1.000
#> GSM414970 1 0.584 0.825 0.860 0.140
#> GSM414972 2 0.000 0.993 0.000 1.000
#> GSM414975 2 0.000 0.993 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414925 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414926 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414927 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414929 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414931 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414933 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414935 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414936 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414937 1 0.0237 0.947 0.996 0.0 0.004
#> GSM414939 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414941 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414943 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414944 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414945 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414946 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414948 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414949 3 0.4555 0.756 0.000 0.2 0.800
#> GSM414950 3 0.3340 0.856 0.120 0.0 0.880
#> GSM414951 1 0.5706 0.546 0.680 0.0 0.320
#> GSM414952 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414954 1 0.6267 0.232 0.548 0.0 0.452
#> GSM414956 1 0.5216 0.655 0.740 0.0 0.260
#> GSM414958 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414959 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414960 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414961 3 0.1411 0.929 0.036 0.0 0.964
#> GSM414962 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414964 1 0.4605 0.738 0.796 0.0 0.204
#> GSM414965 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414967 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414968 3 0.3816 0.823 0.148 0.0 0.852
#> GSM414969 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414971 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414973 1 0.0000 0.950 1.000 0.0 0.000
#> GSM414974 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414928 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414930 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414932 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414934 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414938 1 0.0237 0.947 0.996 0.0 0.004
#> GSM414940 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414942 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414953 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414955 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414957 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414963 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414966 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414970 3 0.0000 0.952 0.000 0.0 1.000
#> GSM414972 2 0.0000 1.000 0.000 1.0 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.3074 0.685 0.848 0.000 0.000 0.152
#> GSM414925 1 0.1637 0.802 0.940 0.000 0.000 0.060
#> GSM414926 1 0.2814 0.720 0.868 0.000 0.000 0.132
#> GSM414927 2 0.0707 0.919 0.000 0.980 0.000 0.020
#> GSM414929 4 0.4855 0.661 0.400 0.000 0.000 0.600
#> GSM414931 1 0.0336 0.820 0.992 0.000 0.000 0.008
#> GSM414933 1 0.1211 0.812 0.960 0.000 0.000 0.040
#> GSM414935 3 0.2868 0.809 0.000 0.000 0.864 0.136
#> GSM414936 1 0.0336 0.820 0.992 0.000 0.000 0.008
#> GSM414937 1 0.0336 0.820 0.992 0.000 0.008 0.000
#> GSM414939 1 0.0188 0.821 0.996 0.000 0.000 0.004
#> GSM414941 1 0.2081 0.784 0.916 0.000 0.000 0.084
#> GSM414943 1 0.1151 0.804 0.968 0.000 0.024 0.008
#> GSM414944 1 0.0336 0.820 0.992 0.000 0.000 0.008
#> GSM414945 2 0.2654 0.847 0.004 0.888 0.000 0.108
#> GSM414946 1 0.3308 0.733 0.872 0.000 0.036 0.092
#> GSM414948 1 0.0188 0.821 0.996 0.000 0.000 0.004
#> GSM414949 3 0.6603 0.614 0.000 0.100 0.572 0.328
#> GSM414950 3 0.6240 0.633 0.076 0.000 0.604 0.320
#> GSM414951 1 0.5000 -0.174 0.504 0.000 0.496 0.000
#> GSM414952 3 0.0469 0.819 0.000 0.000 0.988 0.012
#> GSM414954 1 0.5047 0.211 0.668 0.000 0.316 0.016
#> GSM414956 1 0.4722 0.218 0.692 0.000 0.300 0.008
#> GSM414958 1 0.1716 0.801 0.936 0.000 0.000 0.064
#> GSM414959 1 0.1022 0.815 0.968 0.000 0.000 0.032
#> GSM414960 1 0.2011 0.780 0.920 0.000 0.000 0.080
#> GSM414961 3 0.3447 0.803 0.020 0.000 0.852 0.128
#> GSM414962 2 0.5990 0.564 0.000 0.608 0.056 0.336
#> GSM414964 1 0.4741 0.407 0.744 0.000 0.228 0.028
#> GSM414965 1 0.0376 0.820 0.992 0.000 0.004 0.004
#> GSM414967 1 0.0336 0.820 0.992 0.000 0.000 0.008
#> GSM414968 3 0.6633 0.225 0.084 0.000 0.500 0.416
#> GSM414969 4 0.6130 0.383 0.400 0.000 0.052 0.548
#> GSM414971 1 0.0336 0.820 0.992 0.000 0.000 0.008
#> GSM414973 1 0.1637 0.802 0.940 0.000 0.000 0.060
#> GSM414974 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414928 2 0.4401 0.707 0.000 0.724 0.004 0.272
#> GSM414930 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414932 3 0.3688 0.784 0.000 0.000 0.792 0.208
#> GSM414934 3 0.1557 0.802 0.000 0.000 0.944 0.056
#> GSM414938 4 0.5253 0.678 0.360 0.000 0.016 0.624
#> GSM414940 3 0.0592 0.819 0.000 0.000 0.984 0.016
#> GSM414942 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414953 3 0.1557 0.802 0.000 0.000 0.944 0.056
#> GSM414955 3 0.0592 0.815 0.000 0.000 0.984 0.016
#> GSM414957 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414963 3 0.1389 0.808 0.000 0.000 0.952 0.048
#> GSM414966 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414970 3 0.4250 0.744 0.000 0.000 0.724 0.276
#> GSM414972 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.929 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3669 0.8253 0.816 0.000 0.000 0.128 0.056
#> GSM414925 1 0.3061 0.8374 0.844 0.000 0.000 0.136 0.020
#> GSM414926 1 0.3389 0.8348 0.836 0.000 0.000 0.116 0.048
#> GSM414927 2 0.1121 0.9332 0.000 0.956 0.000 0.044 0.000
#> GSM414929 5 0.0963 0.9141 0.036 0.000 0.000 0.000 0.964
#> GSM414931 1 0.1310 0.8607 0.956 0.000 0.000 0.020 0.024
#> GSM414933 1 0.2006 0.8607 0.916 0.000 0.000 0.072 0.012
#> GSM414935 3 0.3884 0.5435 0.000 0.000 0.708 0.288 0.004
#> GSM414936 1 0.1661 0.8565 0.940 0.000 0.000 0.036 0.024
#> GSM414937 1 0.1591 0.8571 0.940 0.000 0.052 0.004 0.004
#> GSM414939 1 0.1074 0.8665 0.968 0.000 0.004 0.012 0.016
#> GSM414941 1 0.3622 0.8260 0.816 0.000 0.000 0.136 0.048
#> GSM414943 1 0.2459 0.8457 0.904 0.000 0.052 0.040 0.004
#> GSM414944 1 0.2426 0.8414 0.900 0.000 0.000 0.064 0.036
#> GSM414945 2 0.4216 0.7758 0.020 0.804 0.000 0.104 0.072
#> GSM414946 1 0.3141 0.8339 0.832 0.000 0.000 0.152 0.016
#> GSM414948 1 0.1106 0.8663 0.964 0.000 0.000 0.024 0.012
#> GSM414949 4 0.3511 0.6426 0.000 0.012 0.184 0.800 0.004
#> GSM414950 4 0.3395 0.5670 0.000 0.000 0.236 0.764 0.000
#> GSM414951 3 0.4567 0.1402 0.448 0.000 0.544 0.004 0.004
#> GSM414952 3 0.1197 0.7048 0.000 0.000 0.952 0.048 0.000
#> GSM414954 1 0.5158 0.5585 0.640 0.000 0.308 0.040 0.012
#> GSM414956 3 0.6057 0.2830 0.388 0.000 0.524 0.060 0.028
#> GSM414958 1 0.3430 0.7624 0.776 0.000 0.000 0.004 0.220
#> GSM414959 1 0.1106 0.8679 0.964 0.000 0.000 0.012 0.024
#> GSM414960 1 0.4666 0.6538 0.704 0.000 0.000 0.056 0.240
#> GSM414961 3 0.4302 0.4533 0.004 0.000 0.648 0.344 0.004
#> GSM414962 4 0.2439 0.6879 0.000 0.120 0.004 0.876 0.000
#> GSM414964 1 0.5957 0.5331 0.604 0.000 0.160 0.232 0.004
#> GSM414965 1 0.0451 0.8663 0.988 0.000 0.004 0.008 0.000
#> GSM414967 1 0.2491 0.8397 0.896 0.000 0.000 0.068 0.036
#> GSM414968 5 0.2672 0.8194 0.004 0.000 0.116 0.008 0.872
#> GSM414969 4 0.2959 0.5768 0.100 0.000 0.000 0.864 0.036
#> GSM414971 1 0.1741 0.8552 0.936 0.000 0.000 0.040 0.024
#> GSM414973 1 0.2707 0.8490 0.876 0.000 0.000 0.100 0.024
#> GSM414974 2 0.0671 0.9543 0.000 0.980 0.000 0.016 0.004
#> GSM414928 4 0.3913 0.5001 0.000 0.324 0.000 0.676 0.000
#> GSM414930 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.3612 0.5601 0.000 0.000 0.732 0.268 0.000
#> GSM414934 3 0.0000 0.7057 0.000 0.000 1.000 0.000 0.000
#> GSM414938 5 0.0963 0.9141 0.036 0.000 0.000 0.000 0.964
#> GSM414940 3 0.1121 0.7064 0.000 0.000 0.956 0.044 0.000
#> GSM414942 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.7057 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.0404 0.7081 0.000 0.000 0.988 0.012 0.000
#> GSM414957 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0290 0.7067 0.000 0.000 0.992 0.008 0.000
#> GSM414966 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.4306 0.0878 0.000 0.000 0.508 0.492 0.000
#> GSM414972 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9695 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.2638 0.804 0.032 0.000 0.000 0.036 0.888 0.044
#> GSM414925 5 0.1334 0.814 0.000 0.000 0.000 0.032 0.948 0.020
#> GSM414926 5 0.2613 0.804 0.032 0.000 0.000 0.016 0.884 0.068
#> GSM414927 2 0.1444 0.913 0.000 0.928 0.000 0.072 0.000 0.000
#> GSM414929 1 0.0806 0.949 0.972 0.000 0.000 0.000 0.008 0.020
#> GSM414931 5 0.3337 0.661 0.000 0.000 0.000 0.004 0.736 0.260
#> GSM414933 5 0.2821 0.768 0.000 0.000 0.000 0.016 0.832 0.152
#> GSM414935 3 0.4569 0.679 0.000 0.000 0.748 0.136 0.056 0.060
#> GSM414936 5 0.1152 0.809 0.004 0.000 0.000 0.000 0.952 0.044
#> GSM414937 5 0.2752 0.764 0.004 0.000 0.096 0.000 0.864 0.036
#> GSM414939 5 0.1674 0.812 0.004 0.000 0.004 0.000 0.924 0.068
#> GSM414941 5 0.1675 0.813 0.008 0.000 0.000 0.032 0.936 0.024
#> GSM414943 5 0.3456 0.702 0.004 0.000 0.156 0.000 0.800 0.040
#> GSM414944 6 0.2730 0.708 0.000 0.000 0.000 0.000 0.192 0.808
#> GSM414945 6 0.4524 0.485 0.020 0.204 0.000 0.060 0.000 0.716
#> GSM414946 5 0.1498 0.813 0.000 0.000 0.000 0.028 0.940 0.032
#> GSM414948 5 0.1524 0.810 0.000 0.000 0.000 0.008 0.932 0.060
#> GSM414949 4 0.1588 0.732 0.000 0.000 0.072 0.924 0.004 0.000
#> GSM414950 4 0.2402 0.696 0.000 0.000 0.140 0.856 0.000 0.004
#> GSM414951 3 0.4476 0.455 0.000 0.000 0.640 0.000 0.308 0.052
#> GSM414952 3 0.1265 0.770 0.000 0.000 0.948 0.044 0.000 0.008
#> GSM414954 5 0.4280 0.610 0.004 0.000 0.232 0.000 0.708 0.056
#> GSM414956 3 0.5603 0.269 0.004 0.000 0.520 0.000 0.140 0.336
#> GSM414958 5 0.3810 0.693 0.208 0.000 0.000 0.004 0.752 0.036
#> GSM414959 5 0.3490 0.628 0.008 0.000 0.000 0.000 0.724 0.268
#> GSM414960 5 0.5861 0.180 0.308 0.000 0.000 0.000 0.472 0.220
#> GSM414961 3 0.5396 0.543 0.004 0.000 0.636 0.240 0.096 0.024
#> GSM414962 4 0.0405 0.706 0.000 0.008 0.004 0.988 0.000 0.000
#> GSM414964 5 0.6721 0.353 0.004 0.000 0.148 0.244 0.516 0.088
#> GSM414965 5 0.1003 0.812 0.004 0.000 0.004 0.000 0.964 0.028
#> GSM414967 6 0.2300 0.728 0.000 0.000 0.000 0.000 0.144 0.856
#> GSM414968 1 0.0865 0.936 0.964 0.000 0.036 0.000 0.000 0.000
#> GSM414969 4 0.3424 0.516 0.000 0.000 0.000 0.772 0.204 0.024
#> GSM414971 5 0.1908 0.804 0.004 0.000 0.000 0.000 0.900 0.096
#> GSM414973 5 0.1138 0.814 0.004 0.000 0.000 0.012 0.960 0.024
#> GSM414974 2 0.0767 0.963 0.000 0.976 0.000 0.004 0.012 0.008
#> GSM414928 4 0.2527 0.591 0.000 0.168 0.000 0.832 0.000 0.000
#> GSM414930 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.3714 0.425 0.000 0.000 0.656 0.340 0.000 0.004
#> GSM414934 3 0.0405 0.768 0.004 0.000 0.988 0.000 0.000 0.008
#> GSM414938 1 0.0291 0.957 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM414940 3 0.1777 0.759 0.004 0.000 0.928 0.024 0.000 0.044
#> GSM414942 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.769 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414955 3 0.1225 0.772 0.000 0.000 0.952 0.036 0.000 0.012
#> GSM414957 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.1124 0.772 0.000 0.000 0.956 0.036 0.000 0.008
#> GSM414966 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 4 0.3810 0.123 0.000 0.000 0.428 0.572 0.000 0.000
#> GSM414972 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.986 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> SD:NMF 50 1.75e-03 2
#> SD:NMF 51 6.97e-05 3
#> SD:NMF 46 2.51e-04 4
#> SD:NMF 48 6.59e-05 5
#> SD:NMF 45 4.90e-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", "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 51882 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 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.964 0.985 0.3303 0.683 0.683
#> 3 3 0.548 0.670 0.851 0.8403 0.674 0.523
#> 4 4 0.553 0.524 0.757 0.1027 0.987 0.964
#> 5 5 0.551 0.456 0.723 0.0507 0.951 0.859
#> 6 6 0.552 0.589 0.708 0.0730 0.772 0.416
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
#> GSM414924 1 0.0000 0.983 1.000 0.000
#> GSM414925 1 0.0000 0.983 1.000 0.000
#> GSM414926 1 0.0000 0.983 1.000 0.000
#> GSM414927 2 0.0000 0.988 0.000 1.000
#> GSM414929 1 0.0000 0.983 1.000 0.000
#> GSM414931 1 0.0000 0.983 1.000 0.000
#> GSM414933 1 0.0000 0.983 1.000 0.000
#> GSM414935 1 0.0000 0.983 1.000 0.000
#> GSM414936 1 0.0000 0.983 1.000 0.000
#> GSM414937 1 0.0000 0.983 1.000 0.000
#> GSM414939 1 0.0000 0.983 1.000 0.000
#> GSM414941 1 0.0000 0.983 1.000 0.000
#> GSM414943 1 0.0000 0.983 1.000 0.000
#> GSM414944 1 0.0000 0.983 1.000 0.000
#> GSM414945 2 0.4690 0.885 0.100 0.900
#> GSM414946 1 0.0000 0.983 1.000 0.000
#> GSM414948 1 0.0000 0.983 1.000 0.000
#> GSM414949 1 0.4022 0.903 0.920 0.080
#> GSM414950 1 0.0376 0.979 0.996 0.004
#> GSM414951 1 0.0000 0.983 1.000 0.000
#> GSM414952 1 0.0000 0.983 1.000 0.000
#> GSM414954 1 0.0000 0.983 1.000 0.000
#> GSM414956 1 0.0000 0.983 1.000 0.000
#> GSM414958 1 0.0000 0.983 1.000 0.000
#> GSM414959 1 0.0000 0.983 1.000 0.000
#> GSM414960 1 0.0000 0.983 1.000 0.000
#> GSM414961 1 0.0000 0.983 1.000 0.000
#> GSM414962 1 0.8861 0.572 0.696 0.304
#> GSM414964 1 0.0000 0.983 1.000 0.000
#> GSM414965 1 0.0000 0.983 1.000 0.000
#> GSM414967 1 0.0000 0.983 1.000 0.000
#> GSM414968 1 0.0000 0.983 1.000 0.000
#> GSM414969 1 0.0000 0.983 1.000 0.000
#> GSM414971 1 0.0000 0.983 1.000 0.000
#> GSM414973 1 0.0000 0.983 1.000 0.000
#> GSM414974 1 0.8861 0.572 0.696 0.304
#> GSM414928 2 0.0000 0.988 0.000 1.000
#> GSM414930 2 0.0000 0.988 0.000 1.000
#> GSM414932 1 0.0000 0.983 1.000 0.000
#> GSM414934 1 0.0000 0.983 1.000 0.000
#> GSM414938 1 0.0000 0.983 1.000 0.000
#> GSM414940 1 0.0000 0.983 1.000 0.000
#> GSM414942 2 0.0000 0.988 0.000 1.000
#> GSM414947 2 0.0000 0.988 0.000 1.000
#> GSM414953 1 0.0000 0.983 1.000 0.000
#> GSM414955 1 0.0000 0.983 1.000 0.000
#> GSM414957 2 0.0000 0.988 0.000 1.000
#> GSM414963 1 0.0000 0.983 1.000 0.000
#> GSM414966 2 0.0000 0.988 0.000 1.000
#> GSM414970 1 0.0000 0.983 1.000 0.000
#> GSM414972 2 0.0000 0.988 0.000 1.000
#> GSM414975 2 0.0000 0.988 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.1289 0.800 0.968 0.000 0.032
#> GSM414925 1 0.1753 0.795 0.952 0.000 0.048
#> GSM414926 1 0.1289 0.800 0.968 0.000 0.032
#> GSM414927 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414929 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414935 3 0.6267 0.207 0.452 0.000 0.548
#> GSM414936 1 0.5785 0.519 0.668 0.000 0.332
#> GSM414937 1 0.5785 0.519 0.668 0.000 0.332
#> GSM414939 1 0.5785 0.519 0.668 0.000 0.332
#> GSM414941 1 0.3038 0.769 0.896 0.000 0.104
#> GSM414943 1 0.5785 0.519 0.668 0.000 0.332
#> GSM414944 1 0.0237 0.795 0.996 0.000 0.004
#> GSM414945 2 0.3112 0.892 0.004 0.900 0.096
#> GSM414946 1 0.1411 0.799 0.964 0.000 0.036
#> GSM414948 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414949 3 0.5981 0.618 0.132 0.080 0.788
#> GSM414950 3 0.3573 0.651 0.120 0.004 0.876
#> GSM414951 3 0.6308 0.052 0.492 0.000 0.508
#> GSM414952 3 0.4702 0.603 0.212 0.000 0.788
#> GSM414954 3 0.6302 0.101 0.480 0.000 0.520
#> GSM414956 1 0.5785 0.519 0.668 0.000 0.332
#> GSM414958 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414959 1 0.5760 0.524 0.672 0.000 0.328
#> GSM414960 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414961 3 0.6126 0.343 0.400 0.000 0.600
#> GSM414962 3 0.9813 0.217 0.268 0.304 0.428
#> GSM414964 1 0.6111 0.281 0.604 0.000 0.396
#> GSM414965 1 0.5785 0.519 0.668 0.000 0.332
#> GSM414967 1 0.0237 0.795 0.996 0.000 0.004
#> GSM414968 3 0.6062 0.376 0.384 0.000 0.616
#> GSM414969 1 0.2711 0.778 0.912 0.000 0.088
#> GSM414971 1 0.0000 0.797 1.000 0.000 0.000
#> GSM414973 1 0.2165 0.790 0.936 0.000 0.064
#> GSM414974 3 0.9813 0.217 0.268 0.304 0.428
#> GSM414928 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.676 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.676 0.000 0.000 1.000
#> GSM414938 3 0.6045 0.397 0.380 0.000 0.620
#> GSM414940 3 0.0000 0.676 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.676 0.000 0.000 1.000
#> GSM414955 3 0.4702 0.603 0.212 0.000 0.788
#> GSM414957 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.676 0.000 0.000 1.000
#> GSM414966 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.676 0.000 0.000 1.000
#> GSM414972 2 0.0000 0.989 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.989 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.5055 0.5916 0.712 0.000 0.032 0.256
#> GSM414925 1 0.5646 0.5621 0.656 0.000 0.048 0.296
#> GSM414926 1 0.5085 0.5909 0.708 0.000 0.032 0.260
#> GSM414927 2 0.1118 0.9531 0.000 0.964 0.000 0.036
#> GSM414929 1 0.1867 0.5077 0.928 0.000 0.000 0.072
#> GSM414931 1 0.0000 0.5691 1.000 0.000 0.000 0.000
#> GSM414933 1 0.0000 0.5691 1.000 0.000 0.000 0.000
#> GSM414935 3 0.7372 0.2502 0.240 0.000 0.524 0.236
#> GSM414936 1 0.7517 0.4298 0.484 0.000 0.304 0.212
#> GSM414937 1 0.7517 0.4298 0.484 0.000 0.304 0.212
#> GSM414939 1 0.7517 0.4298 0.484 0.000 0.304 0.212
#> GSM414941 1 0.6319 0.5401 0.604 0.000 0.084 0.312
#> GSM414943 1 0.7517 0.4298 0.484 0.000 0.304 0.212
#> GSM414944 1 0.0188 0.5663 0.996 0.000 0.000 0.004
#> GSM414945 2 0.4362 0.7963 0.000 0.816 0.088 0.096
#> GSM414946 1 0.5282 0.5842 0.688 0.000 0.036 0.276
#> GSM414948 1 0.0000 0.5691 1.000 0.000 0.000 0.000
#> GSM414949 3 0.5172 0.3982 0.076 0.012 0.776 0.136
#> GSM414950 3 0.3542 0.4867 0.060 0.000 0.864 0.076
#> GSM414951 3 0.7572 0.1147 0.288 0.000 0.480 0.232
#> GSM414952 3 0.4655 0.4092 0.032 0.000 0.760 0.208
#> GSM414954 3 0.7525 0.1556 0.276 0.000 0.492 0.232
#> GSM414956 1 0.7517 0.4298 0.484 0.000 0.304 0.212
#> GSM414958 1 0.1867 0.5077 0.928 0.000 0.000 0.072
#> GSM414959 1 0.7527 0.4311 0.484 0.000 0.300 0.216
#> GSM414960 1 0.0921 0.5422 0.972 0.000 0.000 0.028
#> GSM414961 3 0.7005 0.3156 0.172 0.000 0.572 0.256
#> GSM414962 3 0.9452 -0.0982 0.148 0.236 0.416 0.200
#> GSM414964 1 0.7772 0.1657 0.392 0.000 0.368 0.240
#> GSM414965 1 0.7517 0.4298 0.484 0.000 0.304 0.212
#> GSM414967 1 0.0188 0.5663 0.996 0.000 0.000 0.004
#> GSM414968 3 0.6773 0.3162 0.132 0.000 0.584 0.284
#> GSM414969 1 0.6078 0.5484 0.620 0.000 0.068 0.312
#> GSM414971 1 0.0000 0.5691 1.000 0.000 0.000 0.000
#> GSM414973 1 0.5472 0.5830 0.676 0.000 0.044 0.280
#> GSM414974 3 0.9452 -0.0982 0.148 0.236 0.416 0.200
#> GSM414928 2 0.1118 0.9531 0.000 0.964 0.000 0.036
#> GSM414930 2 0.0000 0.9711 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0188 0.5014 0.000 0.000 0.996 0.004
#> GSM414934 3 0.1302 0.4759 0.000 0.000 0.956 0.044
#> GSM414938 4 0.3528 0.0000 0.000 0.000 0.192 0.808
#> GSM414940 3 0.0817 0.4842 0.000 0.000 0.976 0.024
#> GSM414942 2 0.0000 0.9711 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 0.9711 0.000 1.000 0.000 0.000
#> GSM414953 3 0.1302 0.4759 0.000 0.000 0.956 0.044
#> GSM414955 3 0.4655 0.4092 0.032 0.000 0.760 0.208
#> GSM414957 2 0.0000 0.9711 0.000 1.000 0.000 0.000
#> GSM414963 3 0.0188 0.5014 0.000 0.000 0.996 0.004
#> GSM414966 2 0.0000 0.9711 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0188 0.5014 0.000 0.000 0.996 0.004
#> GSM414972 2 0.0000 0.9711 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.9711 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.4288 0.4853 0.612 0.000 0.004 0.000 0.384
#> GSM414925 1 0.4522 0.4408 0.552 0.000 0.008 0.000 0.440
#> GSM414926 1 0.4299 0.4835 0.608 0.000 0.004 0.000 0.388
#> GSM414927 2 0.3177 0.7291 0.000 0.792 0.000 0.208 0.000
#> GSM414929 1 0.1981 0.4820 0.924 0.000 0.000 0.028 0.048
#> GSM414931 1 0.0000 0.5258 1.000 0.000 0.000 0.000 0.000
#> GSM414933 1 0.0000 0.5258 1.000 0.000 0.000 0.000 0.000
#> GSM414935 3 0.6465 0.1827 0.184 0.000 0.440 0.000 0.376
#> GSM414936 1 0.6622 0.2598 0.456 0.000 0.260 0.000 0.284
#> GSM414937 1 0.6634 0.2550 0.452 0.000 0.260 0.000 0.288
#> GSM414939 1 0.6634 0.2550 0.452 0.000 0.260 0.000 0.288
#> GSM414941 1 0.4905 0.4006 0.500 0.000 0.024 0.000 0.476
#> GSM414943 1 0.6622 0.2598 0.456 0.000 0.260 0.000 0.284
#> GSM414944 1 0.0324 0.5226 0.992 0.000 0.000 0.004 0.004
#> GSM414945 4 0.4192 -0.1600 0.000 0.404 0.000 0.596 0.000
#> GSM414946 1 0.4350 0.4720 0.588 0.000 0.004 0.000 0.408
#> GSM414948 1 0.0000 0.5258 1.000 0.000 0.000 0.000 0.000
#> GSM414949 3 0.5821 0.1978 0.000 0.004 0.628 0.176 0.192
#> GSM414950 3 0.5139 0.4281 0.008 0.000 0.708 0.104 0.180
#> GSM414951 3 0.6687 0.0589 0.252 0.000 0.424 0.000 0.324
#> GSM414952 3 0.3884 0.4973 0.004 0.000 0.708 0.000 0.288
#> GSM414954 3 0.6636 0.0931 0.232 0.000 0.432 0.000 0.336
#> GSM414956 1 0.6622 0.2598 0.456 0.000 0.260 0.000 0.284
#> GSM414958 1 0.1981 0.4820 0.924 0.000 0.000 0.028 0.048
#> GSM414959 1 0.6631 0.2546 0.452 0.000 0.256 0.000 0.292
#> GSM414960 1 0.0912 0.5091 0.972 0.000 0.000 0.016 0.012
#> GSM414961 3 0.6012 0.3007 0.116 0.000 0.484 0.000 0.400
#> GSM414962 4 0.8556 0.6013 0.064 0.040 0.264 0.364 0.268
#> GSM414964 5 0.6811 -0.4146 0.328 0.000 0.308 0.000 0.364
#> GSM414965 1 0.6622 0.2598 0.456 0.000 0.260 0.000 0.284
#> GSM414967 1 0.0324 0.5226 0.992 0.000 0.000 0.004 0.004
#> GSM414968 3 0.5853 0.3452 0.084 0.000 0.500 0.004 0.412
#> GSM414969 1 0.4559 0.4124 0.512 0.000 0.008 0.000 0.480
#> GSM414971 1 0.0000 0.5258 1.000 0.000 0.000 0.000 0.000
#> GSM414973 1 0.4473 0.4676 0.580 0.000 0.008 0.000 0.412
#> GSM414974 4 0.8556 0.6013 0.064 0.040 0.264 0.364 0.268
#> GSM414928 2 0.3177 0.7291 0.000 0.792 0.000 0.208 0.000
#> GSM414930 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.0794 0.5635 0.000 0.000 0.972 0.000 0.028
#> GSM414934 3 0.1579 0.5329 0.000 0.000 0.944 0.032 0.024
#> GSM414938 5 0.4734 -0.3967 0.000 0.000 0.024 0.372 0.604
#> GSM414940 3 0.0162 0.5408 0.000 0.000 0.996 0.000 0.004
#> GSM414942 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.1579 0.5329 0.000 0.000 0.944 0.032 0.024
#> GSM414955 3 0.3884 0.4973 0.004 0.000 0.708 0.000 0.288
#> GSM414957 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0794 0.5635 0.000 0.000 0.972 0.000 0.028
#> GSM414966 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0794 0.5635 0.000 0.000 0.972 0.000 0.028
#> GSM414972 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9355 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.602 0.2859 0.000 0.000 0.168 0.016 0.496 0.320
#> GSM414925 5 0.645 0.3316 0.000 0.000 0.172 0.052 0.504 0.272
#> GSM414926 5 0.591 0.3069 0.000 0.000 0.168 0.012 0.512 0.308
#> GSM414927 2 0.308 0.7129 0.000 0.760 0.000 0.240 0.000 0.000
#> GSM414929 6 0.400 0.8217 0.048 0.000 0.000 0.012 0.180 0.760
#> GSM414931 6 0.191 0.8524 0.000 0.000 0.000 0.000 0.108 0.892
#> GSM414933 6 0.240 0.8575 0.000 0.000 0.000 0.004 0.140 0.856
#> GSM414935 5 0.388 0.2908 0.000 0.000 0.180 0.064 0.756 0.000
#> GSM414936 5 0.353 0.5446 0.000 0.000 0.000 0.004 0.700 0.296
#> GSM414937 5 0.337 0.5500 0.000 0.000 0.000 0.000 0.708 0.292
#> GSM414939 5 0.335 0.5503 0.000 0.000 0.000 0.000 0.712 0.288
#> GSM414941 5 0.617 0.4115 0.000 0.000 0.164 0.052 0.564 0.220
#> GSM414943 5 0.355 0.5388 0.000 0.000 0.000 0.004 0.696 0.300
#> GSM414944 6 0.328 0.6868 0.000 0.000 0.068 0.020 0.068 0.844
#> GSM414945 4 0.257 0.0389 0.012 0.136 0.000 0.852 0.000 0.000
#> GSM414946 5 0.604 0.3171 0.000 0.000 0.168 0.020 0.512 0.300
#> GSM414948 6 0.223 0.8589 0.000 0.000 0.000 0.004 0.124 0.872
#> GSM414949 3 0.584 0.3814 0.000 0.000 0.488 0.244 0.268 0.000
#> GSM414950 3 0.572 0.5102 0.000 0.000 0.460 0.168 0.372 0.000
#> GSM414951 5 0.238 0.4965 0.000 0.000 0.068 0.000 0.888 0.044
#> GSM414952 5 0.359 -0.0881 0.000 0.000 0.344 0.000 0.656 0.000
#> GSM414954 5 0.240 0.4786 0.000 0.000 0.080 0.000 0.884 0.036
#> GSM414956 5 0.363 0.5399 0.000 0.000 0.000 0.008 0.696 0.296
#> GSM414958 6 0.400 0.8217 0.048 0.000 0.000 0.012 0.180 0.760
#> GSM414959 5 0.373 0.5545 0.000 0.000 0.004 0.008 0.700 0.288
#> GSM414960 6 0.323 0.8442 0.012 0.000 0.000 0.012 0.168 0.808
#> GSM414961 5 0.333 0.3347 0.000 0.000 0.120 0.064 0.816 0.000
#> GSM414962 4 0.503 0.6243 0.000 0.000 0.444 0.484 0.072 0.000
#> GSM414964 5 0.263 0.5525 0.000 0.000 0.068 0.000 0.872 0.060
#> GSM414965 5 0.355 0.5388 0.000 0.000 0.000 0.004 0.696 0.300
#> GSM414967 6 0.328 0.6868 0.000 0.000 0.068 0.020 0.068 0.844
#> GSM414968 5 0.416 0.2764 0.036 0.000 0.132 0.056 0.776 0.000
#> GSM414969 5 0.631 0.3900 0.000 0.000 0.168 0.056 0.544 0.232
#> GSM414971 6 0.191 0.8524 0.000 0.000 0.000 0.000 0.108 0.892
#> GSM414973 5 0.572 0.3445 0.000 0.000 0.168 0.004 0.520 0.308
#> GSM414974 4 0.503 0.6243 0.000 0.000 0.444 0.484 0.072 0.000
#> GSM414928 2 0.308 0.7129 0.000 0.760 0.000 0.240 0.000 0.000
#> GSM414930 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.315 0.8159 0.000 0.000 0.748 0.000 0.252 0.000
#> GSM414934 3 0.497 0.7591 0.036 0.000 0.632 0.036 0.296 0.000
#> GSM414938 1 0.123 0.0000 0.952 0.000 0.036 0.000 0.012 0.000
#> GSM414940 3 0.384 0.8106 0.028 0.000 0.716 0.000 0.256 0.000
#> GSM414942 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.497 0.7591 0.036 0.000 0.632 0.036 0.296 0.000
#> GSM414955 5 0.359 -0.0881 0.000 0.000 0.344 0.000 0.656 0.000
#> GSM414957 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.315 0.8159 0.000 0.000 0.748 0.000 0.252 0.000
#> GSM414966 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.315 0.8159 0.000 0.000 0.748 0.000 0.252 0.000
#> GSM414972 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.000 0.9314 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> CV:hclust 52 7.46e-04 2
#> CV:hclust 43 1.58e-06 3
#> CV:hclust 29 1.51e-05 4
#> CV:hclust 24 1.44e-04 5
#> CV:hclust 35 1.42e-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", "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 51882 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.960 0.977 0.988 0.3294 0.683 0.683
#> 3 3 1.000 0.985 0.990 0.8797 0.695 0.553
#> 4 4 0.678 0.547 0.813 0.1518 0.946 0.856
#> 5 5 0.635 0.494 0.731 0.0811 0.860 0.587
#> 6 6 0.648 0.472 0.701 0.0417 0.944 0.758
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.0000 0.985 1.000 0.000
#> GSM414925 1 0.0000 0.985 1.000 0.000
#> GSM414926 1 0.0000 0.985 1.000 0.000
#> GSM414927 2 0.0376 1.000 0.004 0.996
#> GSM414929 1 0.0000 0.985 1.000 0.000
#> GSM414931 1 0.0000 0.985 1.000 0.000
#> GSM414933 1 0.0000 0.985 1.000 0.000
#> GSM414935 1 0.0000 0.985 1.000 0.000
#> GSM414936 1 0.0000 0.985 1.000 0.000
#> GSM414937 1 0.0000 0.985 1.000 0.000
#> GSM414939 1 0.0000 0.985 1.000 0.000
#> GSM414941 1 0.0000 0.985 1.000 0.000
#> GSM414943 1 0.0000 0.985 1.000 0.000
#> GSM414944 1 0.0000 0.985 1.000 0.000
#> GSM414945 2 0.0376 1.000 0.004 0.996
#> GSM414946 1 0.0000 0.985 1.000 0.000
#> GSM414948 1 0.0000 0.985 1.000 0.000
#> GSM414949 1 0.5519 0.863 0.872 0.128
#> GSM414950 1 0.0000 0.985 1.000 0.000
#> GSM414951 1 0.0000 0.985 1.000 0.000
#> GSM414952 1 0.0376 0.983 0.996 0.004
#> GSM414954 1 0.0000 0.985 1.000 0.000
#> GSM414956 1 0.0000 0.985 1.000 0.000
#> GSM414958 1 0.0000 0.985 1.000 0.000
#> GSM414959 1 0.0000 0.985 1.000 0.000
#> GSM414960 1 0.0000 0.985 1.000 0.000
#> GSM414961 1 0.0000 0.985 1.000 0.000
#> GSM414962 1 0.5059 0.881 0.888 0.112
#> GSM414964 1 0.0000 0.985 1.000 0.000
#> GSM414965 1 0.0000 0.985 1.000 0.000
#> GSM414967 1 0.0000 0.985 1.000 0.000
#> GSM414968 1 0.0000 0.985 1.000 0.000
#> GSM414969 1 0.0000 0.985 1.000 0.000
#> GSM414971 1 0.0000 0.985 1.000 0.000
#> GSM414973 1 0.0000 0.985 1.000 0.000
#> GSM414974 1 0.5519 0.863 0.872 0.128
#> GSM414928 2 0.0376 1.000 0.004 0.996
#> GSM414930 2 0.0376 1.000 0.004 0.996
#> GSM414932 1 0.0376 0.983 0.996 0.004
#> GSM414934 1 0.0376 0.983 0.996 0.004
#> GSM414938 1 0.0000 0.985 1.000 0.000
#> GSM414940 1 0.0376 0.983 0.996 0.004
#> GSM414942 2 0.0376 1.000 0.004 0.996
#> GSM414947 2 0.0376 1.000 0.004 0.996
#> GSM414953 1 0.0376 0.983 0.996 0.004
#> GSM414955 1 0.0376 0.983 0.996 0.004
#> GSM414957 2 0.0376 1.000 0.004 0.996
#> GSM414963 1 0.6887 0.796 0.816 0.184
#> GSM414966 2 0.0376 1.000 0.004 0.996
#> GSM414970 1 0.1843 0.965 0.972 0.028
#> GSM414972 2 0.0376 1.000 0.004 0.996
#> GSM414975 2 0.0376 1.000 0.004 0.996
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414927 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414929 1 0.0424 0.991 0.992 0.000 0.008
#> GSM414931 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414935 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414936 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414937 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414939 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414941 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414943 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414944 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414945 2 0.3686 0.839 0.000 0.860 0.140
#> GSM414946 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414948 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414949 3 0.0661 0.985 0.008 0.004 0.988
#> GSM414950 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414951 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414952 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414954 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414956 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414958 1 0.0424 0.991 0.992 0.000 0.008
#> GSM414959 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414960 1 0.0424 0.991 0.992 0.000 0.008
#> GSM414961 3 0.0747 0.984 0.016 0.000 0.984
#> GSM414962 3 0.0661 0.981 0.004 0.008 0.988
#> GSM414964 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414965 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414967 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414968 3 0.3192 0.859 0.112 0.000 0.888
#> GSM414969 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414971 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414973 1 0.0000 0.998 1.000 0.000 0.000
#> GSM414974 3 0.0661 0.985 0.008 0.004 0.988
#> GSM414928 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414932 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414934 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414938 1 0.1529 0.962 0.960 0.000 0.040
#> GSM414940 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414942 2 0.0237 0.983 0.000 0.996 0.004
#> GSM414947 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414953 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414955 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414957 2 0.0000 0.983 0.000 1.000 0.000
#> GSM414963 3 0.0661 0.985 0.008 0.004 0.988
#> GSM414966 2 0.0237 0.983 0.000 0.996 0.004
#> GSM414970 3 0.0592 0.988 0.012 0.000 0.988
#> GSM414972 2 0.0237 0.983 0.000 0.996 0.004
#> GSM414975 2 0.0237 0.983 0.000 0.996 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 4 0.5000 0.3522 0.500 0.000 0.000 0.500
#> GSM414925 1 0.4830 -0.2474 0.608 0.000 0.000 0.392
#> GSM414926 1 0.4898 -0.2739 0.584 0.000 0.000 0.416
#> GSM414927 2 0.1867 0.9370 0.000 0.928 0.000 0.072
#> GSM414929 1 0.4961 -0.2445 0.552 0.000 0.000 0.448
#> GSM414931 1 0.4222 0.3066 0.728 0.000 0.000 0.272
#> GSM414933 1 0.4713 0.1013 0.640 0.000 0.000 0.360
#> GSM414935 3 0.4919 0.8085 0.048 0.000 0.752 0.200
#> GSM414936 1 0.0000 0.5237 1.000 0.000 0.000 0.000
#> GSM414937 1 0.2011 0.4722 0.920 0.000 0.000 0.080
#> GSM414939 1 0.0817 0.5162 0.976 0.000 0.000 0.024
#> GSM414941 1 0.4790 -0.1708 0.620 0.000 0.000 0.380
#> GSM414943 1 0.0188 0.5231 0.996 0.000 0.000 0.004
#> GSM414944 1 0.3801 0.3767 0.780 0.000 0.000 0.220
#> GSM414945 2 0.6111 0.7073 0.000 0.652 0.092 0.256
#> GSM414946 1 0.4713 -0.1387 0.640 0.000 0.000 0.360
#> GSM414948 1 0.4222 0.3074 0.728 0.000 0.000 0.272
#> GSM414949 3 0.2868 0.8530 0.000 0.000 0.864 0.136
#> GSM414950 3 0.4755 0.8141 0.040 0.000 0.760 0.200
#> GSM414951 1 0.2799 0.4347 0.884 0.000 0.008 0.108
#> GSM414952 3 0.0469 0.8721 0.000 0.000 0.988 0.012
#> GSM414954 1 0.3688 0.2780 0.792 0.000 0.000 0.208
#> GSM414956 1 0.0707 0.5176 0.980 0.000 0.000 0.020
#> GSM414958 1 0.4761 -0.0264 0.628 0.000 0.000 0.372
#> GSM414959 1 0.1474 0.5089 0.948 0.000 0.000 0.052
#> GSM414960 1 0.4697 0.1222 0.644 0.000 0.000 0.356
#> GSM414961 3 0.5035 0.8026 0.052 0.000 0.744 0.204
#> GSM414962 3 0.5057 0.7378 0.000 0.012 0.648 0.340
#> GSM414964 1 0.3837 0.2445 0.776 0.000 0.000 0.224
#> GSM414965 1 0.0000 0.5237 1.000 0.000 0.000 0.000
#> GSM414967 1 0.4624 0.2324 0.660 0.000 0.000 0.340
#> GSM414968 3 0.5619 0.7623 0.064 0.000 0.688 0.248
#> GSM414969 4 0.4996 0.3917 0.484 0.000 0.000 0.516
#> GSM414971 1 0.2530 0.4757 0.888 0.000 0.000 0.112
#> GSM414973 1 0.3907 0.3078 0.768 0.000 0.000 0.232
#> GSM414974 3 0.5099 0.7149 0.008 0.000 0.612 0.380
#> GSM414928 2 0.1867 0.9370 0.000 0.928 0.000 0.072
#> GSM414930 2 0.0000 0.9565 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0188 0.8715 0.000 0.000 0.996 0.004
#> GSM414934 3 0.1302 0.8646 0.000 0.000 0.956 0.044
#> GSM414938 4 0.4741 0.2968 0.328 0.000 0.004 0.668
#> GSM414940 3 0.0707 0.8680 0.000 0.000 0.980 0.020
#> GSM414942 2 0.0188 0.9565 0.000 0.996 0.000 0.004
#> GSM414947 2 0.0707 0.9546 0.000 0.980 0.000 0.020
#> GSM414953 3 0.1302 0.8646 0.000 0.000 0.956 0.044
#> GSM414955 3 0.0469 0.8721 0.000 0.000 0.988 0.012
#> GSM414957 2 0.0707 0.9546 0.000 0.980 0.000 0.020
#> GSM414963 3 0.0188 0.8715 0.000 0.000 0.996 0.004
#> GSM414966 2 0.0188 0.9565 0.000 0.996 0.000 0.004
#> GSM414970 3 0.0188 0.8715 0.000 0.000 0.996 0.004
#> GSM414972 2 0.0188 0.9565 0.000 0.996 0.000 0.004
#> GSM414975 2 0.0188 0.9565 0.000 0.996 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3863 0.5601 0.772 0.000 0.000 0.028 0.200
#> GSM414925 1 0.4166 0.4920 0.648 0.000 0.000 0.004 0.348
#> GSM414926 1 0.4602 0.5192 0.656 0.000 0.000 0.028 0.316
#> GSM414927 2 0.2286 0.9042 0.004 0.888 0.000 0.108 0.000
#> GSM414929 1 0.6203 0.4096 0.544 0.000 0.000 0.268 0.188
#> GSM414931 5 0.5562 -0.0720 0.408 0.000 0.000 0.072 0.520
#> GSM414933 1 0.5765 0.1785 0.488 0.000 0.000 0.088 0.424
#> GSM414935 3 0.6684 0.4122 0.256 0.000 0.576 0.060 0.108
#> GSM414936 5 0.0162 0.6101 0.004 0.000 0.000 0.000 0.996
#> GSM414937 5 0.1270 0.5930 0.052 0.000 0.000 0.000 0.948
#> GSM414939 5 0.0703 0.6068 0.024 0.000 0.000 0.000 0.976
#> GSM414941 1 0.4675 0.3820 0.600 0.000 0.000 0.020 0.380
#> GSM414943 5 0.0000 0.6094 0.000 0.000 0.000 0.000 1.000
#> GSM414944 5 0.6131 0.2301 0.228 0.000 0.000 0.208 0.564
#> GSM414945 4 0.4974 -0.2462 0.000 0.408 0.032 0.560 0.000
#> GSM414946 1 0.4367 0.4586 0.620 0.000 0.000 0.008 0.372
#> GSM414948 5 0.5454 -0.0493 0.404 0.000 0.000 0.064 0.532
#> GSM414949 3 0.5334 0.4961 0.180 0.000 0.672 0.148 0.000
#> GSM414950 3 0.7021 0.4154 0.208 0.000 0.572 0.124 0.096
#> GSM414951 5 0.2880 0.5286 0.108 0.000 0.020 0.004 0.868
#> GSM414952 3 0.0162 0.7310 0.004 0.000 0.996 0.000 0.000
#> GSM414954 5 0.4421 0.2915 0.268 0.000 0.024 0.004 0.704
#> GSM414956 5 0.0566 0.6081 0.012 0.000 0.004 0.000 0.984
#> GSM414958 1 0.5989 0.3977 0.536 0.000 0.000 0.128 0.336
#> GSM414959 5 0.1571 0.5852 0.060 0.000 0.000 0.004 0.936
#> GSM414960 1 0.6352 0.2215 0.456 0.000 0.000 0.164 0.380
#> GSM414961 3 0.6684 0.4122 0.256 0.000 0.576 0.060 0.108
#> GSM414962 4 0.6899 0.0670 0.228 0.008 0.368 0.396 0.000
#> GSM414964 5 0.5276 0.1638 0.324 0.000 0.024 0.028 0.624
#> GSM414965 5 0.0000 0.6094 0.000 0.000 0.000 0.000 1.000
#> GSM414967 5 0.6572 -0.0616 0.364 0.000 0.000 0.208 0.428
#> GSM414968 3 0.6265 0.4274 0.292 0.000 0.588 0.052 0.068
#> GSM414969 1 0.4528 0.5053 0.728 0.000 0.000 0.060 0.212
#> GSM414971 5 0.4462 0.3900 0.196 0.000 0.000 0.064 0.740
#> GSM414973 5 0.4182 -0.0944 0.400 0.000 0.000 0.000 0.600
#> GSM414974 4 0.6876 0.0307 0.256 0.000 0.368 0.372 0.004
#> GSM414928 2 0.2286 0.9042 0.004 0.888 0.000 0.108 0.000
#> GSM414930 2 0.0609 0.9557 0.000 0.980 0.000 0.020 0.000
#> GSM414932 3 0.0510 0.7290 0.000 0.000 0.984 0.016 0.000
#> GSM414934 3 0.1845 0.7021 0.016 0.000 0.928 0.056 0.000
#> GSM414938 4 0.5895 -0.2386 0.436 0.000 0.008 0.480 0.076
#> GSM414940 3 0.1557 0.7124 0.008 0.000 0.940 0.052 0.000
#> GSM414942 2 0.0566 0.9553 0.012 0.984 0.000 0.004 0.000
#> GSM414947 2 0.0955 0.9535 0.004 0.968 0.000 0.028 0.000
#> GSM414953 3 0.1845 0.7021 0.016 0.000 0.928 0.056 0.000
#> GSM414955 3 0.0162 0.7310 0.004 0.000 0.996 0.000 0.000
#> GSM414957 2 0.0794 0.9545 0.000 0.972 0.000 0.028 0.000
#> GSM414963 3 0.0609 0.7279 0.000 0.000 0.980 0.020 0.000
#> GSM414966 2 0.0566 0.9553 0.012 0.984 0.000 0.004 0.000
#> GSM414970 3 0.0609 0.7279 0.000 0.000 0.980 0.020 0.000
#> GSM414972 2 0.0566 0.9553 0.012 0.984 0.000 0.004 0.000
#> GSM414975 2 0.0566 0.9553 0.012 0.984 0.000 0.004 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.3213 0.4778 0.820 0.000 0.000 0.000 0.132 0.048
#> GSM414925 1 0.3514 0.5305 0.752 0.000 0.000 0.020 0.228 0.000
#> GSM414926 1 0.3290 0.4957 0.776 0.000 0.000 0.000 0.208 0.016
#> GSM414927 2 0.2633 0.8497 0.004 0.864 0.000 0.112 0.000 0.020
#> GSM414929 1 0.6420 0.0368 0.452 0.000 0.000 0.152 0.044 0.352
#> GSM414931 5 0.6118 -0.6354 0.304 0.000 0.000 0.000 0.360 0.336
#> GSM414933 1 0.6047 -0.5260 0.400 0.000 0.000 0.000 0.260 0.340
#> GSM414935 3 0.6653 0.3012 0.200 0.000 0.536 0.176 0.084 0.004
#> GSM414936 5 0.0260 0.6520 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM414937 5 0.1674 0.6485 0.068 0.000 0.000 0.004 0.924 0.004
#> GSM414939 5 0.0937 0.6557 0.040 0.000 0.000 0.000 0.960 0.000
#> GSM414941 1 0.4352 0.4857 0.668 0.000 0.000 0.052 0.280 0.000
#> GSM414943 5 0.0000 0.6475 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414944 6 0.5977 0.5895 0.088 0.000 0.000 0.044 0.388 0.480
#> GSM414945 4 0.6502 0.2046 0.000 0.216 0.064 0.524 0.000 0.196
#> GSM414946 1 0.3509 0.5269 0.744 0.000 0.000 0.016 0.240 0.000
#> GSM414948 5 0.6106 -0.6000 0.324 0.000 0.000 0.000 0.376 0.300
#> GSM414949 3 0.4760 0.2423 0.068 0.000 0.604 0.328 0.000 0.000
#> GSM414950 3 0.6432 0.2705 0.120 0.000 0.544 0.256 0.076 0.004
#> GSM414951 5 0.2698 0.6139 0.120 0.000 0.008 0.008 0.860 0.004
#> GSM414952 3 0.0000 0.6622 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414954 5 0.3676 0.5362 0.184 0.000 0.020 0.012 0.780 0.004
#> GSM414956 5 0.0790 0.6384 0.000 0.000 0.000 0.000 0.968 0.032
#> GSM414958 1 0.6349 -0.1953 0.472 0.000 0.000 0.028 0.200 0.300
#> GSM414959 5 0.1642 0.6438 0.028 0.000 0.000 0.004 0.936 0.032
#> GSM414960 6 0.6217 0.3479 0.344 0.000 0.000 0.008 0.240 0.408
#> GSM414961 3 0.6694 0.2968 0.200 0.000 0.532 0.176 0.088 0.004
#> GSM414962 4 0.5657 0.4896 0.136 0.012 0.300 0.552 0.000 0.000
#> GSM414964 5 0.5165 0.3591 0.244 0.000 0.020 0.080 0.652 0.004
#> GSM414965 5 0.0000 0.6475 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414967 6 0.6367 0.6738 0.156 0.000 0.000 0.044 0.312 0.488
#> GSM414968 3 0.6636 0.2977 0.208 0.000 0.532 0.180 0.076 0.004
#> GSM414969 1 0.4393 0.4780 0.720 0.000 0.000 0.140 0.140 0.000
#> GSM414971 5 0.5003 -0.2991 0.104 0.000 0.000 0.000 0.608 0.288
#> GSM414973 1 0.3841 0.3993 0.616 0.000 0.000 0.000 0.380 0.004
#> GSM414974 4 0.5641 0.4617 0.164 0.000 0.292 0.540 0.004 0.000
#> GSM414928 2 0.2633 0.8497 0.004 0.864 0.000 0.112 0.000 0.020
#> GSM414930 2 0.0000 0.9156 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.0632 0.6585 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM414934 3 0.3096 0.5863 0.004 0.000 0.840 0.108 0.000 0.048
#> GSM414938 1 0.6455 -0.0172 0.352 0.000 0.008 0.308 0.004 0.328
#> GSM414940 3 0.2231 0.6239 0.004 0.000 0.900 0.068 0.000 0.028
#> GSM414942 2 0.1812 0.9136 0.008 0.912 0.000 0.000 0.000 0.080
#> GSM414947 2 0.0891 0.9105 0.000 0.968 0.000 0.024 0.000 0.008
#> GSM414953 3 0.3096 0.5863 0.004 0.000 0.840 0.108 0.000 0.048
#> GSM414955 3 0.0000 0.6622 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414957 2 0.0777 0.9116 0.000 0.972 0.000 0.024 0.000 0.004
#> GSM414963 3 0.0713 0.6569 0.000 0.000 0.972 0.028 0.000 0.000
#> GSM414966 2 0.1812 0.9136 0.008 0.912 0.000 0.000 0.000 0.080
#> GSM414970 3 0.0713 0.6569 0.000 0.000 0.972 0.028 0.000 0.000
#> GSM414972 2 0.1812 0.9136 0.008 0.912 0.000 0.000 0.000 0.080
#> GSM414975 2 0.1812 0.9136 0.008 0.912 0.000 0.000 0.000 0.080
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> CV:kmeans 52 7.46e-04 2
#> CV:kmeans 52 1.34e-05 3
#> CV:kmeans 31 8.05e-03 4
#> CV:kmeans 28 1.10e-04 5
#> CV:kmeans 30 1.30e-04 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "skmeans"]
# you can also extract it by
# res = res_list["CV:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 51882 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 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.975 0.989 0.4874 0.517 0.517
#> 3 3 0.969 0.957 0.982 0.2961 0.796 0.627
#> 4 4 0.798 0.869 0.911 0.1962 0.864 0.636
#> 5 5 0.773 0.637 0.814 0.0534 0.946 0.783
#> 6 6 0.784 0.716 0.803 0.0315 0.928 0.671
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.000 0.982 1.000 0.000
#> GSM414925 1 0.000 0.982 1.000 0.000
#> GSM414926 1 0.000 0.982 1.000 0.000
#> GSM414927 2 0.000 1.000 0.000 1.000
#> GSM414929 1 0.000 0.982 1.000 0.000
#> GSM414931 1 0.000 0.982 1.000 0.000
#> GSM414933 1 0.000 0.982 1.000 0.000
#> GSM414935 1 0.000 0.982 1.000 0.000
#> GSM414936 1 0.000 0.982 1.000 0.000
#> GSM414937 1 0.000 0.982 1.000 0.000
#> GSM414939 1 0.000 0.982 1.000 0.000
#> GSM414941 1 0.000 0.982 1.000 0.000
#> GSM414943 1 0.000 0.982 1.000 0.000
#> GSM414944 1 0.000 0.982 1.000 0.000
#> GSM414945 2 0.000 1.000 0.000 1.000
#> GSM414946 1 0.000 0.982 1.000 0.000
#> GSM414948 1 0.000 0.982 1.000 0.000
#> GSM414949 2 0.000 1.000 0.000 1.000
#> GSM414950 1 0.689 0.773 0.816 0.184
#> GSM414951 1 0.000 0.982 1.000 0.000
#> GSM414952 1 0.946 0.442 0.636 0.364
#> GSM414954 1 0.000 0.982 1.000 0.000
#> GSM414956 1 0.000 0.982 1.000 0.000
#> GSM414958 1 0.000 0.982 1.000 0.000
#> GSM414959 1 0.000 0.982 1.000 0.000
#> GSM414960 1 0.000 0.982 1.000 0.000
#> GSM414961 1 0.000 0.982 1.000 0.000
#> GSM414962 2 0.000 1.000 0.000 1.000
#> GSM414964 1 0.000 0.982 1.000 0.000
#> GSM414965 1 0.000 0.982 1.000 0.000
#> GSM414967 1 0.000 0.982 1.000 0.000
#> GSM414968 1 0.000 0.982 1.000 0.000
#> GSM414969 1 0.000 0.982 1.000 0.000
#> GSM414971 1 0.000 0.982 1.000 0.000
#> GSM414973 1 0.000 0.982 1.000 0.000
#> GSM414974 2 0.000 1.000 0.000 1.000
#> GSM414928 2 0.000 1.000 0.000 1.000
#> GSM414930 2 0.000 1.000 0.000 1.000
#> GSM414932 2 0.000 1.000 0.000 1.000
#> GSM414934 2 0.000 1.000 0.000 1.000
#> GSM414938 1 0.000 0.982 1.000 0.000
#> GSM414940 2 0.000 1.000 0.000 1.000
#> GSM414942 2 0.000 1.000 0.000 1.000
#> GSM414947 2 0.000 1.000 0.000 1.000
#> GSM414953 2 0.000 1.000 0.000 1.000
#> GSM414955 2 0.000 1.000 0.000 1.000
#> GSM414957 2 0.000 1.000 0.000 1.000
#> GSM414963 2 0.000 1.000 0.000 1.000
#> GSM414966 2 0.000 1.000 0.000 1.000
#> GSM414970 2 0.000 1.000 0.000 1.000
#> GSM414972 2 0.000 1.000 0.000 1.000
#> GSM414975 2 0.000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.000 0.977 1.000 0.0 0.000
#> GSM414925 1 0.000 0.977 1.000 0.0 0.000
#> GSM414926 1 0.000 0.977 1.000 0.0 0.000
#> GSM414927 2 0.000 1.000 0.000 1.0 0.000
#> GSM414929 1 0.000 0.977 1.000 0.0 0.000
#> GSM414931 1 0.000 0.977 1.000 0.0 0.000
#> GSM414933 1 0.000 0.977 1.000 0.0 0.000
#> GSM414935 3 0.000 0.971 0.000 0.0 1.000
#> GSM414936 1 0.000 0.977 1.000 0.0 0.000
#> GSM414937 1 0.000 0.977 1.000 0.0 0.000
#> GSM414939 1 0.000 0.977 1.000 0.0 0.000
#> GSM414941 1 0.000 0.977 1.000 0.0 0.000
#> GSM414943 1 0.000 0.977 1.000 0.0 0.000
#> GSM414944 1 0.000 0.977 1.000 0.0 0.000
#> GSM414945 2 0.000 1.000 0.000 1.0 0.000
#> GSM414946 1 0.000 0.977 1.000 0.0 0.000
#> GSM414948 1 0.000 0.977 1.000 0.0 0.000
#> GSM414949 3 0.455 0.755 0.000 0.2 0.800
#> GSM414950 3 0.000 0.971 0.000 0.0 1.000
#> GSM414951 1 0.418 0.781 0.828 0.0 0.172
#> GSM414952 3 0.000 0.971 0.000 0.0 1.000
#> GSM414954 1 0.000 0.977 1.000 0.0 0.000
#> GSM414956 1 0.000 0.977 1.000 0.0 0.000
#> GSM414958 1 0.000 0.977 1.000 0.0 0.000
#> GSM414959 1 0.000 0.977 1.000 0.0 0.000
#> GSM414960 1 0.000 0.977 1.000 0.0 0.000
#> GSM414961 3 0.000 0.971 0.000 0.0 1.000
#> GSM414962 2 0.000 1.000 0.000 1.0 0.000
#> GSM414964 1 0.000 0.977 1.000 0.0 0.000
#> GSM414965 1 0.000 0.977 1.000 0.0 0.000
#> GSM414967 1 0.000 0.977 1.000 0.0 0.000
#> GSM414968 3 0.327 0.842 0.116 0.0 0.884
#> GSM414969 1 0.000 0.977 1.000 0.0 0.000
#> GSM414971 1 0.000 0.977 1.000 0.0 0.000
#> GSM414973 1 0.000 0.977 1.000 0.0 0.000
#> GSM414974 2 0.000 1.000 0.000 1.0 0.000
#> GSM414928 2 0.000 1.000 0.000 1.0 0.000
#> GSM414930 2 0.000 1.000 0.000 1.0 0.000
#> GSM414932 3 0.000 0.971 0.000 0.0 1.000
#> GSM414934 3 0.000 0.971 0.000 0.0 1.000
#> GSM414938 1 0.716 0.292 0.572 0.4 0.028
#> GSM414940 3 0.000 0.971 0.000 0.0 1.000
#> GSM414942 2 0.000 1.000 0.000 1.0 0.000
#> GSM414947 2 0.000 1.000 0.000 1.0 0.000
#> GSM414953 3 0.000 0.971 0.000 0.0 1.000
#> GSM414955 3 0.000 0.971 0.000 0.0 1.000
#> GSM414957 2 0.000 1.000 0.000 1.0 0.000
#> GSM414963 3 0.000 0.971 0.000 0.0 1.000
#> GSM414966 2 0.000 1.000 0.000 1.0 0.000
#> GSM414970 3 0.000 0.971 0.000 0.0 1.000
#> GSM414972 2 0.000 1.000 0.000 1.0 0.000
#> GSM414975 2 0.000 1.000 0.000 1.0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.0000 0.754 1.000 0.000 0.000 0.000
#> GSM414925 1 0.0592 0.756 0.984 0.000 0.000 0.016
#> GSM414926 1 0.3528 0.826 0.808 0.000 0.000 0.192
#> GSM414927 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414929 1 0.3726 0.826 0.788 0.000 0.000 0.212
#> GSM414931 1 0.4564 0.754 0.672 0.000 0.000 0.328
#> GSM414933 1 0.3801 0.825 0.780 0.000 0.000 0.220
#> GSM414935 3 0.4245 0.837 0.196 0.000 0.784 0.020
#> GSM414936 4 0.0336 0.913 0.008 0.000 0.000 0.992
#> GSM414937 4 0.0000 0.909 0.000 0.000 0.000 1.000
#> GSM414939 4 0.0336 0.913 0.008 0.000 0.000 0.992
#> GSM414941 1 0.1867 0.733 0.928 0.000 0.000 0.072
#> GSM414943 4 0.0336 0.913 0.008 0.000 0.000 0.992
#> GSM414944 4 0.3356 0.694 0.176 0.000 0.000 0.824
#> GSM414945 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414946 1 0.1389 0.752 0.952 0.000 0.000 0.048
#> GSM414948 1 0.4477 0.773 0.688 0.000 0.000 0.312
#> GSM414949 3 0.3726 0.747 0.000 0.212 0.788 0.000
#> GSM414950 3 0.4019 0.839 0.196 0.000 0.792 0.012
#> GSM414951 4 0.0000 0.909 0.000 0.000 0.000 1.000
#> GSM414952 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414954 4 0.3444 0.722 0.184 0.000 0.000 0.816
#> GSM414956 4 0.0336 0.913 0.008 0.000 0.000 0.992
#> GSM414958 1 0.3764 0.825 0.784 0.000 0.000 0.216
#> GSM414959 4 0.0817 0.903 0.024 0.000 0.000 0.976
#> GSM414960 1 0.4164 0.805 0.736 0.000 0.000 0.264
#> GSM414961 3 0.4284 0.834 0.200 0.000 0.780 0.020
#> GSM414962 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414964 4 0.3873 0.679 0.228 0.000 0.000 0.772
#> GSM414965 4 0.0336 0.913 0.008 0.000 0.000 0.992
#> GSM414967 1 0.4933 0.554 0.568 0.000 0.000 0.432
#> GSM414968 3 0.4426 0.829 0.204 0.000 0.772 0.024
#> GSM414969 1 0.0336 0.749 0.992 0.000 0.000 0.008
#> GSM414971 4 0.1716 0.863 0.064 0.000 0.000 0.936
#> GSM414973 1 0.4454 0.774 0.692 0.000 0.000 0.308
#> GSM414974 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414928 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414934 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414938 1 0.4465 0.822 0.776 0.004 0.020 0.200
#> GSM414940 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414953 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414955 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414963 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0000 0.917 0.000 0.000 1.000 0.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.1628 0.559 0.936 0.000 0.000 0.056 0.008
#> GSM414925 1 0.1918 0.586 0.928 0.000 0.000 0.036 0.036
#> GSM414926 1 0.3234 0.501 0.852 0.000 0.000 0.084 0.064
#> GSM414927 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414929 4 0.5511 0.488 0.344 0.000 0.000 0.576 0.080
#> GSM414931 5 0.6820 -0.574 0.332 0.000 0.000 0.316 0.352
#> GSM414933 1 0.6538 -0.458 0.444 0.000 0.000 0.352 0.204
#> GSM414935 3 0.6249 0.648 0.144 0.000 0.572 0.272 0.012
#> GSM414936 5 0.0000 0.724 0.000 0.000 0.000 0.000 1.000
#> GSM414937 5 0.1670 0.710 0.012 0.000 0.000 0.052 0.936
#> GSM414939 5 0.0290 0.724 0.000 0.000 0.000 0.008 0.992
#> GSM414941 1 0.3090 0.542 0.856 0.000 0.000 0.104 0.040
#> GSM414943 5 0.0000 0.724 0.000 0.000 0.000 0.000 1.000
#> GSM414944 5 0.6240 -0.259 0.152 0.000 0.000 0.360 0.488
#> GSM414945 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414946 1 0.2012 0.587 0.920 0.000 0.000 0.020 0.060
#> GSM414948 1 0.6734 -0.413 0.404 0.000 0.000 0.264 0.332
#> GSM414949 3 0.4898 0.638 0.000 0.248 0.684 0.068 0.000
#> GSM414950 3 0.5907 0.667 0.132 0.000 0.596 0.268 0.004
#> GSM414951 5 0.2533 0.689 0.008 0.000 0.008 0.096 0.888
#> GSM414952 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414954 5 0.4818 0.552 0.100 0.000 0.000 0.180 0.720
#> GSM414956 5 0.0510 0.723 0.000 0.000 0.000 0.016 0.984
#> GSM414958 4 0.6294 0.497 0.404 0.000 0.000 0.444 0.152
#> GSM414959 5 0.2790 0.663 0.052 0.000 0.000 0.068 0.880
#> GSM414960 4 0.6691 0.439 0.360 0.000 0.000 0.400 0.240
#> GSM414961 3 0.6216 0.649 0.136 0.000 0.572 0.280 0.012
#> GSM414962 2 0.0162 0.996 0.000 0.996 0.000 0.004 0.000
#> GSM414964 5 0.6026 0.406 0.192 0.000 0.000 0.228 0.580
#> GSM414965 5 0.0162 0.723 0.000 0.000 0.000 0.004 0.996
#> GSM414967 4 0.6694 0.387 0.244 0.000 0.000 0.408 0.348
#> GSM414968 3 0.5810 0.619 0.076 0.000 0.540 0.376 0.008
#> GSM414969 1 0.2377 0.532 0.872 0.000 0.000 0.128 0.000
#> GSM414971 5 0.4898 0.287 0.068 0.000 0.000 0.248 0.684
#> GSM414973 1 0.4840 0.354 0.688 0.000 0.000 0.064 0.248
#> GSM414974 2 0.0290 0.993 0.000 0.992 0.000 0.008 0.000
#> GSM414928 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414934 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414938 4 0.5621 0.459 0.320 0.004 0.004 0.600 0.072
#> GSM414940 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414942 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414957 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414966 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0000 0.846 0.000 0.000 1.000 0.000 0.000
#> GSM414972 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.2230 0.7909 0.892 0.000 0.000 0.024 0.000 0.084
#> GSM414925 1 0.2401 0.7983 0.892 0.000 0.000 0.028 0.008 0.072
#> GSM414926 1 0.3164 0.7632 0.844 0.000 0.000 0.032 0.020 0.104
#> GSM414927 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414929 6 0.5780 0.2570 0.160 0.000 0.000 0.264 0.016 0.560
#> GSM414931 6 0.5501 0.5588 0.144 0.000 0.000 0.000 0.336 0.520
#> GSM414933 6 0.5943 0.4895 0.296 0.000 0.000 0.012 0.180 0.512
#> GSM414935 4 0.5571 0.7474 0.080 0.000 0.432 0.468 0.020 0.000
#> GSM414936 5 0.0146 0.7711 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM414937 5 0.1332 0.7658 0.012 0.000 0.000 0.028 0.952 0.008
#> GSM414939 5 0.0551 0.7706 0.004 0.000 0.000 0.004 0.984 0.008
#> GSM414941 1 0.2947 0.7719 0.864 0.000 0.000 0.080 0.032 0.024
#> GSM414943 5 0.0146 0.7724 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM414944 6 0.5791 0.4356 0.052 0.000 0.000 0.064 0.364 0.520
#> GSM414945 2 0.0363 0.9831 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM414946 1 0.2147 0.8054 0.912 0.000 0.000 0.012 0.032 0.044
#> GSM414948 6 0.5912 0.5463 0.224 0.000 0.000 0.000 0.324 0.452
#> GSM414949 3 0.5434 -0.0711 0.000 0.160 0.616 0.212 0.000 0.012
#> GSM414950 4 0.5297 0.7056 0.048 0.000 0.464 0.468 0.012 0.008
#> GSM414951 5 0.3299 0.7053 0.008 0.000 0.004 0.084 0.840 0.064
#> GSM414952 3 0.1152 0.8386 0.000 0.000 0.952 0.044 0.000 0.004
#> GSM414954 5 0.4970 0.5499 0.060 0.000 0.000 0.252 0.660 0.028
#> GSM414956 5 0.0405 0.7713 0.000 0.000 0.000 0.008 0.988 0.004
#> GSM414958 6 0.6559 0.4541 0.196 0.000 0.000 0.128 0.128 0.548
#> GSM414959 5 0.4533 0.5810 0.072 0.000 0.000 0.056 0.756 0.116
#> GSM414960 6 0.5318 0.6017 0.148 0.000 0.000 0.008 0.224 0.620
#> GSM414961 4 0.5561 0.7482 0.068 0.000 0.408 0.496 0.028 0.000
#> GSM414962 2 0.1010 0.9643 0.000 0.960 0.000 0.036 0.000 0.004
#> GSM414964 5 0.6093 0.3808 0.124 0.000 0.000 0.316 0.520 0.040
#> GSM414965 5 0.0291 0.7703 0.000 0.000 0.000 0.004 0.992 0.004
#> GSM414967 6 0.5599 0.5382 0.056 0.000 0.000 0.064 0.284 0.596
#> GSM414968 4 0.6548 0.4933 0.016 0.000 0.380 0.396 0.012 0.196
#> GSM414969 1 0.2301 0.7751 0.884 0.000 0.000 0.096 0.000 0.020
#> GSM414971 5 0.4663 -0.2299 0.036 0.000 0.000 0.004 0.552 0.408
#> GSM414973 1 0.5466 0.3874 0.628 0.000 0.000 0.036 0.240 0.096
#> GSM414974 2 0.1668 0.9387 0.004 0.928 0.000 0.060 0.000 0.008
#> GSM414928 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.0146 0.8892 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414934 3 0.0260 0.8883 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM414938 6 0.5810 0.1882 0.144 0.000 0.000 0.332 0.012 0.512
#> GSM414940 3 0.0146 0.8900 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414942 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.0260 0.8883 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM414955 3 0.0632 0.8716 0.000 0.000 0.976 0.024 0.000 0.000
#> GSM414957 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.0000 0.8900 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414966 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.0146 0.8892 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414972 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9902 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> CV:skmeans 51 3.69e-07 2
#> CV:skmeans 51 1.24e-05 3
#> CV:skmeans 52 1.75e-04 4
#> CV:skmeans 40 1.96e-03 5
#> CV:skmeans 42 6.90e-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", "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 51882 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 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.885 0.953 0.978 0.3410 0.683 0.683
#> 3 3 0.646 0.796 0.911 0.7913 0.686 0.541
#> 4 4 0.586 0.471 0.746 0.1629 0.820 0.564
#> 5 5 0.639 0.534 0.758 0.0931 0.843 0.521
#> 6 6 0.675 0.411 0.703 0.0391 0.873 0.513
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
#> GSM414924 1 0.000 0.972 1.000 0.000
#> GSM414925 1 0.000 0.972 1.000 0.000
#> GSM414926 1 0.000 0.972 1.000 0.000
#> GSM414927 2 0.000 1.000 0.000 1.000
#> GSM414929 1 0.000 0.972 1.000 0.000
#> GSM414931 1 0.000 0.972 1.000 0.000
#> GSM414933 1 0.000 0.972 1.000 0.000
#> GSM414935 1 0.000 0.972 1.000 0.000
#> GSM414936 1 0.000 0.972 1.000 0.000
#> GSM414937 1 0.000 0.972 1.000 0.000
#> GSM414939 1 0.000 0.972 1.000 0.000
#> GSM414941 1 0.000 0.972 1.000 0.000
#> GSM414943 1 0.000 0.972 1.000 0.000
#> GSM414944 1 0.000 0.972 1.000 0.000
#> GSM414945 2 0.000 1.000 0.000 1.000
#> GSM414946 1 0.000 0.972 1.000 0.000
#> GSM414948 1 0.000 0.972 1.000 0.000
#> GSM414949 1 0.697 0.784 0.812 0.188
#> GSM414950 1 0.000 0.972 1.000 0.000
#> GSM414951 1 0.000 0.972 1.000 0.000
#> GSM414952 1 0.000 0.972 1.000 0.000
#> GSM414954 1 0.000 0.972 1.000 0.000
#> GSM414956 1 0.000 0.972 1.000 0.000
#> GSM414958 1 0.000 0.972 1.000 0.000
#> GSM414959 1 0.000 0.972 1.000 0.000
#> GSM414960 1 0.000 0.972 1.000 0.000
#> GSM414961 1 0.000 0.972 1.000 0.000
#> GSM414962 1 0.955 0.448 0.624 0.376
#> GSM414964 1 0.000 0.972 1.000 0.000
#> GSM414965 1 0.000 0.972 1.000 0.000
#> GSM414967 1 0.000 0.972 1.000 0.000
#> GSM414968 1 0.000 0.972 1.000 0.000
#> GSM414969 1 0.000 0.972 1.000 0.000
#> GSM414971 1 0.000 0.972 1.000 0.000
#> GSM414973 1 0.000 0.972 1.000 0.000
#> GSM414974 1 0.697 0.784 0.812 0.188
#> GSM414928 2 0.000 1.000 0.000 1.000
#> GSM414930 2 0.000 1.000 0.000 1.000
#> GSM414932 1 0.000 0.972 1.000 0.000
#> GSM414934 1 0.000 0.972 1.000 0.000
#> GSM414938 1 0.000 0.972 1.000 0.000
#> GSM414940 1 0.000 0.972 1.000 0.000
#> GSM414942 2 0.000 1.000 0.000 1.000
#> GSM414947 2 0.000 1.000 0.000 1.000
#> GSM414953 1 0.000 0.972 1.000 0.000
#> GSM414955 1 0.000 0.972 1.000 0.000
#> GSM414957 2 0.000 1.000 0.000 1.000
#> GSM414963 1 0.706 0.779 0.808 0.192
#> GSM414966 2 0.000 1.000 0.000 1.000
#> GSM414970 1 0.697 0.784 0.812 0.188
#> GSM414972 2 0.000 1.000 0.000 1.000
#> GSM414975 2 0.000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414925 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414926 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414927 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414929 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414931 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414933 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414935 3 0.6309 -0.00988 0.496 0.00 0.504
#> GSM414936 1 0.0747 0.89060 0.984 0.00 0.016
#> GSM414937 1 0.3941 0.83983 0.844 0.00 0.156
#> GSM414939 1 0.3941 0.83983 0.844 0.00 0.156
#> GSM414941 1 0.3879 0.84235 0.848 0.00 0.152
#> GSM414943 1 0.3879 0.84235 0.848 0.00 0.152
#> GSM414944 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414945 2 0.5835 0.54019 0.000 0.66 0.340
#> GSM414946 1 0.3941 0.83983 0.844 0.00 0.156
#> GSM414948 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414949 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414950 3 0.6225 0.19338 0.432 0.00 0.568
#> GSM414951 1 0.4399 0.80866 0.812 0.00 0.188
#> GSM414952 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414954 3 0.5882 0.45401 0.348 0.00 0.652
#> GSM414956 1 0.4178 0.82653 0.828 0.00 0.172
#> GSM414958 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414959 1 0.4178 0.82653 0.828 0.00 0.172
#> GSM414960 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414961 3 0.5882 0.45401 0.348 0.00 0.652
#> GSM414962 3 0.5016 0.51537 0.000 0.24 0.760
#> GSM414964 1 0.5397 0.66398 0.720 0.00 0.280
#> GSM414965 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414967 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414968 3 0.5988 0.41066 0.368 0.00 0.632
#> GSM414969 1 0.4235 0.82292 0.824 0.00 0.176
#> GSM414971 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414973 1 0.0000 0.89419 1.000 0.00 0.000
#> GSM414974 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414928 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414930 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414932 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414934 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414938 1 0.5529 0.63673 0.704 0.00 0.296
#> GSM414940 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414942 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414947 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414953 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414955 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414957 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414963 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414966 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414970 3 0.0000 0.79671 0.000 0.00 1.000
#> GSM414972 2 0.0000 0.96233 0.000 1.00 0.000
#> GSM414975 2 0.0000 0.96233 0.000 1.00 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.4916 0.04370 0.576 0.000 0.000 0.424
#> GSM414925 1 0.4916 -0.05999 0.576 0.000 0.000 0.424
#> GSM414926 1 0.4697 0.07680 0.644 0.000 0.000 0.356
#> GSM414927 2 0.3444 0.89108 0.000 0.816 0.000 0.184
#> GSM414929 4 0.4761 0.12175 0.372 0.000 0.000 0.628
#> GSM414931 1 0.2814 0.50555 0.868 0.000 0.000 0.132
#> GSM414933 1 0.4877 0.07815 0.592 0.000 0.000 0.408
#> GSM414935 4 0.7145 0.27406 0.348 0.000 0.144 0.508
#> GSM414936 1 0.0707 0.54254 0.980 0.000 0.000 0.020
#> GSM414937 1 0.3377 0.49477 0.848 0.000 0.012 0.140
#> GSM414939 1 0.3377 0.49477 0.848 0.000 0.012 0.140
#> GSM414941 1 0.5404 -0.22330 0.512 0.000 0.012 0.476
#> GSM414943 1 0.3377 0.49477 0.848 0.000 0.012 0.140
#> GSM414944 1 0.1118 0.53931 0.964 0.000 0.000 0.036
#> GSM414945 2 0.7520 0.40233 0.000 0.456 0.352 0.192
#> GSM414946 4 0.5388 0.23891 0.456 0.000 0.012 0.532
#> GSM414948 1 0.2149 0.52013 0.912 0.000 0.000 0.088
#> GSM414949 3 0.3486 0.68402 0.000 0.000 0.812 0.188
#> GSM414950 1 0.7336 0.03972 0.520 0.000 0.284 0.196
#> GSM414951 1 0.3606 0.48824 0.840 0.000 0.020 0.140
#> GSM414952 3 0.0188 0.86379 0.000 0.000 0.996 0.004
#> GSM414954 3 0.5253 0.30426 0.360 0.000 0.624 0.016
#> GSM414956 1 0.3495 0.49141 0.844 0.000 0.016 0.140
#> GSM414958 1 0.4356 0.30025 0.708 0.000 0.000 0.292
#> GSM414959 1 0.4599 0.38428 0.736 0.000 0.016 0.248
#> GSM414960 4 0.4996 -0.00637 0.484 0.000 0.000 0.516
#> GSM414961 3 0.6677 0.22199 0.348 0.000 0.552 0.100
#> GSM414962 4 0.5476 -0.09774 0.000 0.020 0.396 0.584
#> GSM414964 4 0.5604 0.19482 0.476 0.000 0.020 0.504
#> GSM414965 1 0.0336 0.54330 0.992 0.000 0.000 0.008
#> GSM414967 1 0.2814 0.51368 0.868 0.000 0.000 0.132
#> GSM414968 1 0.7510 -0.06188 0.436 0.000 0.380 0.184
#> GSM414969 4 0.5388 0.23891 0.456 0.000 0.012 0.532
#> GSM414971 1 0.2149 0.52013 0.912 0.000 0.000 0.088
#> GSM414973 1 0.4585 0.09164 0.668 0.000 0.000 0.332
#> GSM414974 4 0.4985 -0.02921 0.000 0.000 0.468 0.532
#> GSM414928 2 0.3444 0.89108 0.000 0.816 0.000 0.184
#> GSM414930 2 0.3400 0.89203 0.000 0.820 0.000 0.180
#> GSM414932 3 0.0336 0.86168 0.000 0.000 0.992 0.008
#> GSM414934 3 0.0000 0.86446 0.000 0.000 1.000 0.000
#> GSM414938 4 0.5453 0.29283 0.304 0.000 0.036 0.660
#> GSM414940 3 0.0000 0.86446 0.000 0.000 1.000 0.000
#> GSM414942 2 0.0000 0.87147 0.000 1.000 0.000 0.000
#> GSM414947 2 0.3400 0.89203 0.000 0.820 0.000 0.180
#> GSM414953 3 0.0000 0.86446 0.000 0.000 1.000 0.000
#> GSM414955 3 0.0000 0.86446 0.000 0.000 1.000 0.000
#> GSM414957 2 0.3400 0.89203 0.000 0.820 0.000 0.180
#> GSM414963 3 0.0000 0.86446 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0000 0.87147 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0188 0.86379 0.000 0.000 0.996 0.004
#> GSM414972 2 0.0000 0.87147 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.87147 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.5757 0.3820 0.496 0.000 0.000 0.088 0.416
#> GSM414925 1 0.3003 0.5668 0.812 0.000 0.000 0.000 0.188
#> GSM414926 1 0.4448 0.3437 0.516 0.000 0.000 0.004 0.480
#> GSM414927 4 0.4262 0.1098 0.000 0.440 0.000 0.560 0.000
#> GSM414929 1 0.6190 0.4366 0.444 0.000 0.000 0.420 0.136
#> GSM414931 5 0.3912 0.5751 0.108 0.000 0.000 0.088 0.804
#> GSM414933 1 0.5773 0.3556 0.476 0.000 0.000 0.088 0.436
#> GSM414935 1 0.1484 0.5495 0.944 0.000 0.008 0.000 0.048
#> GSM414936 5 0.2074 0.7540 0.104 0.000 0.000 0.000 0.896
#> GSM414937 5 0.2732 0.7451 0.160 0.000 0.000 0.000 0.840
#> GSM414939 5 0.2732 0.7451 0.160 0.000 0.000 0.000 0.840
#> GSM414941 1 0.4074 0.3279 0.636 0.000 0.000 0.000 0.364
#> GSM414943 5 0.2732 0.7451 0.160 0.000 0.000 0.000 0.840
#> GSM414944 5 0.2325 0.7432 0.068 0.000 0.000 0.028 0.904
#> GSM414945 4 0.6302 0.3618 0.012 0.144 0.284 0.560 0.000
#> GSM414946 1 0.1121 0.5713 0.956 0.000 0.000 0.000 0.044
#> GSM414948 5 0.2248 0.6687 0.012 0.000 0.000 0.088 0.900
#> GSM414949 3 0.4101 0.5020 0.372 0.000 0.628 0.000 0.000
#> GSM414950 1 0.6012 -0.0649 0.504 0.000 0.120 0.000 0.376
#> GSM414951 5 0.2732 0.7451 0.160 0.000 0.000 0.000 0.840
#> GSM414952 3 0.0162 0.8559 0.004 0.000 0.996 0.000 0.000
#> GSM414954 3 0.4934 0.5594 0.104 0.000 0.708 0.000 0.188
#> GSM414956 5 0.2732 0.7451 0.160 0.000 0.000 0.000 0.840
#> GSM414958 5 0.4878 0.2652 0.024 0.000 0.000 0.440 0.536
#> GSM414959 5 0.4256 0.2065 0.436 0.000 0.000 0.000 0.564
#> GSM414960 1 0.6557 0.4367 0.472 0.000 0.000 0.240 0.288
#> GSM414961 3 0.5314 0.4040 0.420 0.000 0.528 0.000 0.052
#> GSM414962 4 0.6056 0.3206 0.324 0.000 0.140 0.536 0.000
#> GSM414964 1 0.2127 0.5436 0.892 0.000 0.000 0.000 0.108
#> GSM414965 5 0.1908 0.7524 0.092 0.000 0.000 0.000 0.908
#> GSM414967 5 0.3704 0.5981 0.092 0.000 0.000 0.088 0.820
#> GSM414968 1 0.6812 -0.0257 0.364 0.000 0.312 0.000 0.324
#> GSM414969 1 0.0404 0.5622 0.988 0.000 0.000 0.000 0.012
#> GSM414971 5 0.2248 0.6687 0.012 0.000 0.000 0.088 0.900
#> GSM414973 1 0.4974 0.3327 0.508 0.000 0.000 0.028 0.464
#> GSM414974 1 0.2179 0.4991 0.888 0.000 0.112 0.000 0.000
#> GSM414928 4 0.4262 0.1098 0.000 0.440 0.000 0.560 0.000
#> GSM414930 2 0.4210 0.2123 0.000 0.588 0.000 0.412 0.000
#> GSM414932 3 0.0290 0.8537 0.008 0.000 0.992 0.000 0.000
#> GSM414934 3 0.0000 0.8564 0.000 0.000 1.000 0.000 0.000
#> GSM414938 1 0.5719 0.4658 0.552 0.000 0.000 0.352 0.096
#> GSM414940 3 0.0000 0.8564 0.000 0.000 1.000 0.000 0.000
#> GSM414942 2 0.0000 0.6637 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.4210 0.2123 0.000 0.588 0.000 0.412 0.000
#> GSM414953 3 0.0000 0.8564 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.0000 0.8564 0.000 0.000 1.000 0.000 0.000
#> GSM414957 2 0.4210 0.2123 0.000 0.588 0.000 0.412 0.000
#> GSM414963 3 0.0000 0.8564 0.000 0.000 1.000 0.000 0.000
#> GSM414966 2 0.0000 0.6637 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0162 0.8559 0.004 0.000 0.996 0.000 0.000
#> GSM414972 2 0.0000 0.6637 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.6637 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 6 0.2562 0.5787 0.000 0.000 0.000 0.000 0.172 0.828
#> GSM414925 6 0.5254 -0.2248 0.392 0.000 0.000 0.000 0.100 0.508
#> GSM414926 6 0.4889 0.3220 0.060 0.000 0.000 0.000 0.436 0.504
#> GSM414927 4 0.3672 0.2378 0.000 0.368 0.000 0.632 0.000 0.000
#> GSM414929 1 0.6149 0.1926 0.576 0.000 0.000 0.176 0.056 0.192
#> GSM414931 6 0.3833 0.2217 0.000 0.000 0.000 0.000 0.444 0.556
#> GSM414933 6 0.2730 0.5762 0.000 0.000 0.000 0.000 0.192 0.808
#> GSM414935 1 0.6030 0.3653 0.464 0.000 0.008 0.000 0.196 0.332
#> GSM414936 5 0.1501 0.5635 0.000 0.000 0.000 0.000 0.924 0.076
#> GSM414937 5 0.0000 0.6119 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414939 5 0.0000 0.6119 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414941 5 0.4779 -0.1752 0.060 0.000 0.000 0.000 0.572 0.368
#> GSM414943 5 0.0000 0.6119 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414944 5 0.2697 0.4571 0.000 0.000 0.000 0.000 0.812 0.188
#> GSM414945 4 0.5165 0.3732 0.012 0.108 0.244 0.636 0.000 0.000
#> GSM414946 1 0.5813 0.3170 0.432 0.000 0.000 0.000 0.184 0.384
#> GSM414948 5 0.3843 -0.0458 0.000 0.000 0.000 0.000 0.548 0.452
#> GSM414949 3 0.5243 0.3186 0.376 0.000 0.532 0.004 0.088 0.000
#> GSM414950 5 0.5047 0.0457 0.416 0.000 0.064 0.004 0.516 0.000
#> GSM414951 5 0.0260 0.6085 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM414952 3 0.0146 0.8125 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM414954 3 0.4278 0.5976 0.040 0.000 0.720 0.000 0.224 0.016
#> GSM414956 5 0.0000 0.6119 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414958 1 0.5612 0.1393 0.524 0.000 0.000 0.176 0.000 0.300
#> GSM414959 5 0.4011 0.1839 0.056 0.000 0.000 0.000 0.732 0.212
#> GSM414960 6 0.2908 0.5104 0.048 0.000 0.000 0.000 0.104 0.848
#> GSM414961 3 0.5171 0.3155 0.416 0.000 0.496 0.000 0.088 0.000
#> GSM414962 4 0.5894 0.2310 0.372 0.000 0.100 0.496 0.032 0.000
#> GSM414964 1 0.5912 0.3420 0.440 0.000 0.000 0.000 0.216 0.344
#> GSM414965 5 0.1663 0.5508 0.000 0.000 0.000 0.000 0.912 0.088
#> GSM414967 6 0.3854 0.1872 0.000 0.000 0.000 0.000 0.464 0.536
#> GSM414968 5 0.5676 0.1644 0.272 0.000 0.204 0.000 0.524 0.000
#> GSM414969 1 0.5603 0.3751 0.476 0.000 0.000 0.000 0.148 0.376
#> GSM414971 5 0.3843 -0.0458 0.000 0.000 0.000 0.000 0.548 0.452
#> GSM414973 6 0.4747 0.4275 0.056 0.000 0.000 0.000 0.376 0.568
#> GSM414974 1 0.6324 0.3610 0.476 0.000 0.064 0.004 0.088 0.368
#> GSM414928 4 0.3672 0.2378 0.000 0.368 0.000 0.632 0.000 0.000
#> GSM414930 2 0.3847 0.1550 0.000 0.544 0.000 0.456 0.000 0.000
#> GSM414932 3 0.0291 0.8112 0.004 0.000 0.992 0.000 0.004 0.000
#> GSM414934 3 0.2697 0.7471 0.000 0.000 0.812 0.188 0.000 0.000
#> GSM414938 1 0.6019 0.1956 0.596 0.000 0.000 0.176 0.056 0.172
#> GSM414940 3 0.0000 0.8123 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414942 2 0.0000 0.6494 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.3847 0.1550 0.000 0.544 0.000 0.456 0.000 0.000
#> GSM414953 3 0.2697 0.7471 0.000 0.000 0.812 0.188 0.000 0.000
#> GSM414955 3 0.0000 0.8123 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414957 2 0.3847 0.1550 0.000 0.544 0.000 0.456 0.000 0.000
#> GSM414963 3 0.0000 0.8123 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414966 2 0.0000 0.6494 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.0146 0.8125 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM414972 2 0.0000 0.6494 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.6494 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> CV:pam 51 9.13e-04 2
#> CV:pam 47 5.41e-06 3
#> CV:pam 25 6.07e-04 4
#> CV:pam 31 7.09e-05 5
#> CV:pam 23 7.90e-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", "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 51882 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.881 0.893 0.958 0.3548 0.638 0.638
#> 3 3 0.596 0.747 0.875 0.7872 0.707 0.548
#> 4 4 0.568 0.552 0.771 0.1179 0.821 0.573
#> 5 5 0.566 0.442 0.719 0.0765 0.807 0.470
#> 6 6 0.622 0.536 0.724 0.0617 0.829 0.415
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
#> GSM414924 1 0.0000 0.969 1.000 0.000
#> GSM414925 1 0.0000 0.969 1.000 0.000
#> GSM414926 1 0.0000 0.969 1.000 0.000
#> GSM414927 2 0.0000 0.884 0.000 1.000
#> GSM414929 1 0.0000 0.969 1.000 0.000
#> GSM414931 1 0.0000 0.969 1.000 0.000
#> GSM414933 1 0.0000 0.969 1.000 0.000
#> GSM414935 1 0.0000 0.969 1.000 0.000
#> GSM414936 1 0.0000 0.969 1.000 0.000
#> GSM414937 1 0.0000 0.969 1.000 0.000
#> GSM414939 1 0.0000 0.969 1.000 0.000
#> GSM414941 1 0.0000 0.969 1.000 0.000
#> GSM414943 1 0.0000 0.969 1.000 0.000
#> GSM414944 1 0.9460 0.330 0.636 0.364
#> GSM414945 2 0.9608 0.445 0.384 0.616
#> GSM414946 1 0.0000 0.969 1.000 0.000
#> GSM414948 1 0.0000 0.969 1.000 0.000
#> GSM414949 1 0.4298 0.881 0.912 0.088
#> GSM414950 1 0.0000 0.969 1.000 0.000
#> GSM414951 1 0.0000 0.969 1.000 0.000
#> GSM414952 1 0.0672 0.965 0.992 0.008
#> GSM414954 1 0.0000 0.969 1.000 0.000
#> GSM414956 1 0.0000 0.969 1.000 0.000
#> GSM414958 1 0.0000 0.969 1.000 0.000
#> GSM414959 1 0.0000 0.969 1.000 0.000
#> GSM414960 1 0.0000 0.969 1.000 0.000
#> GSM414961 1 0.0000 0.969 1.000 0.000
#> GSM414962 2 0.9661 0.428 0.392 0.608
#> GSM414964 1 0.0000 0.969 1.000 0.000
#> GSM414965 1 0.0000 0.969 1.000 0.000
#> GSM414967 1 0.9460 0.330 0.636 0.364
#> GSM414968 1 0.0000 0.969 1.000 0.000
#> GSM414969 1 0.0000 0.969 1.000 0.000
#> GSM414971 1 0.0000 0.969 1.000 0.000
#> GSM414973 1 0.0000 0.969 1.000 0.000
#> GSM414974 2 0.9686 0.418 0.396 0.604
#> GSM414928 2 0.0000 0.884 0.000 1.000
#> GSM414930 2 0.0000 0.884 0.000 1.000
#> GSM414932 1 0.0938 0.962 0.988 0.012
#> GSM414934 1 0.0938 0.962 0.988 0.012
#> GSM414938 1 0.5519 0.826 0.872 0.128
#> GSM414940 1 0.0938 0.962 0.988 0.012
#> GSM414942 2 0.0000 0.884 0.000 1.000
#> GSM414947 2 0.0000 0.884 0.000 1.000
#> GSM414953 1 0.0938 0.962 0.988 0.012
#> GSM414955 1 0.0938 0.962 0.988 0.012
#> GSM414957 2 0.0000 0.884 0.000 1.000
#> GSM414963 1 0.0938 0.962 0.988 0.012
#> GSM414966 2 0.0000 0.884 0.000 1.000
#> GSM414970 1 0.0938 0.962 0.988 0.012
#> GSM414972 2 0.0000 0.884 0.000 1.000
#> GSM414975 2 0.0000 0.884 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.6180 0.46136 0.584 0.000 0.416
#> GSM414925 1 0.5560 0.69214 0.700 0.000 0.300
#> GSM414926 1 0.5968 0.57175 0.636 0.000 0.364
#> GSM414927 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414929 1 0.2066 0.82734 0.940 0.000 0.060
#> GSM414931 1 0.0237 0.82466 0.996 0.000 0.004
#> GSM414933 1 0.0237 0.82383 0.996 0.000 0.004
#> GSM414935 3 0.1643 0.84112 0.044 0.000 0.956
#> GSM414936 1 0.0892 0.82837 0.980 0.000 0.020
#> GSM414937 1 0.4178 0.79884 0.828 0.000 0.172
#> GSM414939 1 0.3752 0.81022 0.856 0.000 0.144
#> GSM414941 1 0.5810 0.64237 0.664 0.000 0.336
#> GSM414943 1 0.1031 0.82812 0.976 0.000 0.024
#> GSM414944 1 0.3148 0.78944 0.916 0.036 0.048
#> GSM414945 2 0.3851 0.79844 0.004 0.860 0.136
#> GSM414946 1 0.5560 0.69297 0.700 0.000 0.300
#> GSM414948 1 0.2356 0.82726 0.928 0.000 0.072
#> GSM414949 3 0.1411 0.82667 0.000 0.036 0.964
#> GSM414950 3 0.1529 0.84357 0.040 0.000 0.960
#> GSM414951 1 0.4504 0.78480 0.804 0.000 0.196
#> GSM414952 3 0.0747 0.85167 0.016 0.000 0.984
#> GSM414954 1 0.5327 0.72417 0.728 0.000 0.272
#> GSM414956 1 0.1163 0.82624 0.972 0.000 0.028
#> GSM414958 1 0.1753 0.83104 0.952 0.000 0.048
#> GSM414959 1 0.1860 0.83032 0.948 0.000 0.052
#> GSM414960 1 0.0000 0.82387 1.000 0.000 0.000
#> GSM414961 3 0.1643 0.84127 0.044 0.000 0.956
#> GSM414962 2 0.6521 -0.00906 0.004 0.504 0.492
#> GSM414964 1 0.5650 0.68265 0.688 0.000 0.312
#> GSM414965 1 0.0892 0.82837 0.980 0.000 0.020
#> GSM414967 1 0.3148 0.78944 0.916 0.036 0.048
#> GSM414968 3 0.6357 0.44756 0.296 0.020 0.684
#> GSM414969 3 0.6280 -0.13024 0.460 0.000 0.540
#> GSM414971 1 0.0747 0.82791 0.984 0.000 0.016
#> GSM414973 1 0.4002 0.80286 0.840 0.000 0.160
#> GSM414974 3 0.6460 0.09611 0.004 0.440 0.556
#> GSM414928 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.85092 0.000 0.000 1.000
#> GSM414934 3 0.3686 0.75150 0.140 0.000 0.860
#> GSM414938 1 0.7681 0.12198 0.540 0.048 0.412
#> GSM414940 3 0.0000 0.85092 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414953 3 0.3686 0.75150 0.140 0.000 0.860
#> GSM414955 3 0.0424 0.85186 0.008 0.000 0.992
#> GSM414957 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.85092 0.000 0.000 1.000
#> GSM414966 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.85092 0.000 0.000 1.000
#> GSM414972 2 0.0000 0.93086 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.93086 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.2002 0.5726 0.936 0.000 0.044 0.020
#> GSM414925 1 0.1824 0.5793 0.936 0.000 0.060 0.004
#> GSM414926 1 0.2142 0.5667 0.928 0.000 0.016 0.056
#> GSM414927 2 0.0188 0.9582 0.000 0.996 0.000 0.004
#> GSM414929 1 0.4720 0.1848 0.672 0.000 0.004 0.324
#> GSM414931 4 0.4996 0.5958 0.484 0.000 0.000 0.516
#> GSM414933 4 0.4855 0.6653 0.400 0.000 0.000 0.600
#> GSM414935 3 0.6672 0.2439 0.408 0.000 0.504 0.088
#> GSM414936 1 0.4252 0.3563 0.744 0.000 0.004 0.252
#> GSM414937 1 0.4010 0.5496 0.836 0.000 0.064 0.100
#> GSM414939 1 0.4070 0.5262 0.824 0.000 0.044 0.132
#> GSM414941 1 0.1743 0.5788 0.940 0.000 0.056 0.004
#> GSM414943 1 0.4699 0.1849 0.676 0.000 0.004 0.320
#> GSM414944 4 0.3972 0.5975 0.204 0.000 0.008 0.788
#> GSM414945 2 0.6323 0.5962 0.000 0.640 0.112 0.248
#> GSM414946 1 0.2197 0.5808 0.916 0.000 0.080 0.004
#> GSM414948 1 0.4981 -0.5371 0.536 0.000 0.000 0.464
#> GSM414949 3 0.4036 0.7574 0.076 0.000 0.836 0.088
#> GSM414950 3 0.6412 0.4681 0.320 0.000 0.592 0.088
#> GSM414951 1 0.4163 0.5543 0.828 0.000 0.096 0.076
#> GSM414952 3 0.2443 0.7925 0.060 0.000 0.916 0.024
#> GSM414954 1 0.3638 0.5711 0.848 0.000 0.120 0.032
#> GSM414956 1 0.5150 -0.0156 0.596 0.000 0.008 0.396
#> GSM414958 1 0.5256 -0.3011 0.596 0.000 0.012 0.392
#> GSM414959 1 0.5471 0.3279 0.684 0.000 0.048 0.268
#> GSM414960 4 0.5155 0.6283 0.468 0.000 0.004 0.528
#> GSM414961 1 0.6707 -0.1463 0.468 0.000 0.444 0.088
#> GSM414962 3 0.9104 0.2680 0.116 0.320 0.416 0.148
#> GSM414964 1 0.3547 0.5572 0.840 0.000 0.144 0.016
#> GSM414965 1 0.4632 0.2153 0.688 0.000 0.004 0.308
#> GSM414967 4 0.3972 0.5972 0.204 0.000 0.008 0.788
#> GSM414968 1 0.6650 0.3756 0.676 0.032 0.192 0.100
#> GSM414969 1 0.3873 0.5099 0.844 0.000 0.060 0.096
#> GSM414971 4 0.4998 0.5721 0.488 0.000 0.000 0.512
#> GSM414973 1 0.2928 0.5223 0.880 0.000 0.012 0.108
#> GSM414974 3 0.8881 0.4179 0.116 0.252 0.484 0.148
#> GSM414928 2 0.0188 0.9582 0.000 0.996 0.000 0.004
#> GSM414930 2 0.0000 0.9589 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0779 0.8070 0.004 0.000 0.980 0.016
#> GSM414934 3 0.2466 0.7881 0.028 0.000 0.916 0.056
#> GSM414938 1 0.8164 -0.0507 0.484 0.028 0.200 0.288
#> GSM414940 3 0.0592 0.8058 0.000 0.000 0.984 0.016
#> GSM414942 2 0.0469 0.9584 0.000 0.988 0.000 0.012
#> GSM414947 2 0.0000 0.9589 0.000 1.000 0.000 0.000
#> GSM414953 3 0.2466 0.7881 0.028 0.000 0.916 0.056
#> GSM414955 3 0.1610 0.8064 0.032 0.000 0.952 0.016
#> GSM414957 2 0.0188 0.9580 0.000 0.996 0.000 0.004
#> GSM414963 3 0.0000 0.8071 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0469 0.9584 0.000 0.988 0.000 0.012
#> GSM414970 3 0.0336 0.8071 0.000 0.000 0.992 0.008
#> GSM414972 2 0.0469 0.9584 0.000 0.988 0.000 0.012
#> GSM414975 2 0.0469 0.9584 0.000 0.988 0.000 0.012
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3751 0.3930 0.772 0.000 0.004 0.012 0.212
#> GSM414925 1 0.4088 0.3735 0.712 0.000 0.004 0.008 0.276
#> GSM414926 1 0.4789 0.0448 0.608 0.000 0.004 0.020 0.368
#> GSM414927 2 0.0162 0.9502 0.004 0.996 0.000 0.000 0.000
#> GSM414929 5 0.5626 0.0574 0.420 0.000 0.000 0.076 0.504
#> GSM414931 5 0.5813 -0.2724 0.112 0.000 0.000 0.328 0.560
#> GSM414933 5 0.6248 -0.4929 0.148 0.000 0.000 0.384 0.468
#> GSM414935 1 0.6480 0.2216 0.416 0.000 0.184 0.000 0.400
#> GSM414936 5 0.0807 0.4866 0.012 0.000 0.000 0.012 0.976
#> GSM414937 5 0.2570 0.4874 0.084 0.000 0.028 0.000 0.888
#> GSM414939 5 0.2116 0.5020 0.076 0.000 0.008 0.004 0.912
#> GSM414941 1 0.4449 0.3200 0.636 0.000 0.004 0.008 0.352
#> GSM414943 5 0.0771 0.4767 0.004 0.000 0.000 0.020 0.976
#> GSM414944 4 0.4734 0.9802 0.024 0.000 0.000 0.604 0.372
#> GSM414945 2 0.6198 0.4066 0.056 0.528 0.020 0.384 0.012
#> GSM414946 1 0.4759 0.2921 0.600 0.000 0.012 0.008 0.380
#> GSM414948 5 0.6068 0.0890 0.328 0.000 0.000 0.140 0.532
#> GSM414949 3 0.5555 0.3465 0.380 0.000 0.556 0.056 0.008
#> GSM414950 1 0.6573 0.2151 0.456 0.000 0.224 0.000 0.320
#> GSM414951 5 0.3321 0.4697 0.136 0.000 0.032 0.000 0.832
#> GSM414952 3 0.5418 0.5050 0.092 0.000 0.684 0.016 0.208
#> GSM414954 5 0.4686 0.3314 0.160 0.000 0.104 0.000 0.736
#> GSM414956 5 0.2497 0.3867 0.004 0.000 0.004 0.112 0.880
#> GSM414958 5 0.5717 0.1238 0.368 0.000 0.000 0.092 0.540
#> GSM414959 5 0.2295 0.4688 0.088 0.000 0.004 0.008 0.900
#> GSM414960 5 0.6330 -0.4423 0.164 0.000 0.000 0.364 0.472
#> GSM414961 1 0.6161 0.1984 0.444 0.000 0.132 0.000 0.424
#> GSM414962 1 0.8020 0.0414 0.464 0.240 0.208 0.064 0.024
#> GSM414964 5 0.4823 0.2146 0.228 0.000 0.072 0.000 0.700
#> GSM414965 5 0.0609 0.4790 0.000 0.000 0.000 0.020 0.980
#> GSM414967 4 0.4824 0.9801 0.020 0.000 0.004 0.596 0.380
#> GSM414968 5 0.6496 -0.1421 0.408 0.020 0.096 0.004 0.472
#> GSM414969 1 0.3562 0.4191 0.788 0.000 0.016 0.000 0.196
#> GSM414971 5 0.5018 -0.0122 0.068 0.000 0.000 0.268 0.664
#> GSM414973 5 0.4613 0.2498 0.408 0.000 0.004 0.008 0.580
#> GSM414974 1 0.8000 0.0113 0.468 0.204 0.240 0.064 0.024
#> GSM414928 2 0.0510 0.9434 0.016 0.984 0.000 0.000 0.000
#> GSM414930 2 0.0162 0.9502 0.004 0.996 0.000 0.000 0.000
#> GSM414932 3 0.0912 0.7833 0.012 0.000 0.972 0.000 0.016
#> GSM414934 3 0.4759 0.6186 0.016 0.000 0.592 0.388 0.004
#> GSM414938 1 0.7215 0.0688 0.504 0.004 0.036 0.232 0.224
#> GSM414940 3 0.1560 0.7796 0.028 0.000 0.948 0.004 0.020
#> GSM414942 2 0.0000 0.9506 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0162 0.9502 0.004 0.996 0.000 0.000 0.000
#> GSM414953 3 0.4759 0.6186 0.016 0.000 0.592 0.388 0.004
#> GSM414955 3 0.1579 0.7754 0.024 0.000 0.944 0.000 0.032
#> GSM414957 2 0.0162 0.9491 0.000 0.996 0.000 0.004 0.000
#> GSM414963 3 0.1116 0.7797 0.004 0.000 0.964 0.028 0.004
#> GSM414966 2 0.0000 0.9506 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0324 0.7819 0.004 0.000 0.992 0.000 0.004
#> GSM414972 2 0.0000 0.9506 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9506 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.0914 0.6991 0.968 0.000 0.000 0.016 0.000 0.016
#> GSM414925 1 0.1147 0.7031 0.960 0.000 0.004 0.004 0.028 0.004
#> GSM414926 1 0.1794 0.7055 0.932 0.000 0.000 0.016 0.028 0.024
#> GSM414927 2 0.0713 0.9663 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM414929 1 0.5580 -0.1479 0.488 0.000 0.004 0.032 0.052 0.424
#> GSM414931 6 0.3927 0.5957 0.072 0.000 0.000 0.000 0.172 0.756
#> GSM414933 6 0.3252 0.6227 0.124 0.000 0.004 0.008 0.032 0.832
#> GSM414935 5 0.6589 0.3306 0.184 0.000 0.196 0.088 0.532 0.000
#> GSM414936 5 0.5035 0.5425 0.168 0.000 0.000 0.000 0.640 0.192
#> GSM414937 5 0.4260 0.6180 0.248 0.000 0.000 0.004 0.700 0.048
#> GSM414939 5 0.4468 0.5777 0.316 0.000 0.000 0.004 0.640 0.040
#> GSM414941 1 0.2163 0.6663 0.892 0.000 0.000 0.004 0.096 0.008
#> GSM414943 5 0.5199 0.5207 0.152 0.000 0.004 0.000 0.628 0.216
#> GSM414944 6 0.2969 0.6030 0.008 0.000 0.012 0.088 0.028 0.864
#> GSM414945 6 0.8621 0.0208 0.008 0.116 0.128 0.276 0.136 0.336
#> GSM414946 1 0.3679 0.4492 0.764 0.000 0.004 0.016 0.208 0.008
#> GSM414948 6 0.5152 0.1316 0.432 0.000 0.000 0.004 0.072 0.492
#> GSM414949 3 0.7556 -0.1157 0.220 0.000 0.392 0.172 0.212 0.004
#> GSM414950 5 0.6720 0.2760 0.212 0.000 0.200 0.084 0.504 0.000
#> GSM414951 5 0.4539 0.6174 0.264 0.000 0.008 0.012 0.684 0.032
#> GSM414952 4 0.5951 -0.6379 0.004 0.000 0.356 0.448 0.192 0.000
#> GSM414954 5 0.4037 0.6187 0.232 0.000 0.000 0.028 0.728 0.012
#> GSM414956 5 0.6110 0.4477 0.128 0.000 0.016 0.024 0.564 0.268
#> GSM414958 6 0.5606 0.1240 0.424 0.000 0.000 0.020 0.084 0.472
#> GSM414959 5 0.6046 0.4564 0.176 0.000 0.012 0.016 0.568 0.228
#> GSM414960 6 0.3543 0.6224 0.120 0.000 0.004 0.008 0.052 0.816
#> GSM414961 5 0.5785 0.4672 0.188 0.000 0.152 0.044 0.616 0.000
#> GSM414962 4 0.8177 0.4175 0.268 0.064 0.064 0.380 0.208 0.016
#> GSM414964 5 0.4152 0.6005 0.268 0.000 0.004 0.012 0.700 0.016
#> GSM414965 5 0.5151 0.5281 0.152 0.000 0.004 0.000 0.636 0.208
#> GSM414967 6 0.3100 0.6058 0.008 0.000 0.024 0.084 0.024 0.860
#> GSM414968 5 0.6511 0.4586 0.228 0.000 0.096 0.120 0.552 0.004
#> GSM414969 1 0.0622 0.6969 0.980 0.000 0.000 0.012 0.008 0.000
#> GSM414971 6 0.3858 0.5481 0.044 0.000 0.000 0.000 0.216 0.740
#> GSM414973 1 0.4483 0.5337 0.728 0.000 0.000 0.008 0.120 0.144
#> GSM414974 4 0.8096 0.4217 0.268 0.048 0.072 0.384 0.212 0.016
#> GSM414928 2 0.2482 0.8570 0.004 0.848 0.000 0.148 0.000 0.000
#> GSM414930 2 0.0458 0.9700 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM414932 3 0.4389 0.6419 0.004 0.000 0.512 0.468 0.016 0.000
#> GSM414934 3 0.0146 0.4156 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM414938 1 0.8176 -0.0588 0.372 0.000 0.080 0.136 0.132 0.280
#> GSM414940 3 0.4902 0.6312 0.000 0.000 0.480 0.460 0.060 0.000
#> GSM414942 2 0.0000 0.9699 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0458 0.9700 0.000 0.984 0.000 0.016 0.000 0.000
#> GSM414953 3 0.0291 0.4121 0.000 0.000 0.992 0.000 0.004 0.004
#> GSM414955 3 0.5319 0.5967 0.004 0.000 0.456 0.452 0.088 0.000
#> GSM414957 2 0.1219 0.9535 0.000 0.948 0.004 0.048 0.000 0.000
#> GSM414963 3 0.4715 0.6390 0.000 0.000 0.536 0.416 0.048 0.000
#> GSM414966 2 0.0146 0.9706 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM414970 3 0.4399 0.6461 0.000 0.000 0.516 0.460 0.024 0.000
#> GSM414972 2 0.0146 0.9706 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM414975 2 0.0146 0.9706 0.000 0.996 0.000 0.004 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> CV:mclust 47 5.19e-04 2
#> CV:mclust 46 2.98e-06 3
#> CV:mclust 37 2.61e-05 4
#> CV:mclust 20 1.41e-02 5
#> CV:mclust 34 4.38e-06 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["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 51882 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 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.959 0.955 0.981 0.3840 0.618 0.618
#> 3 3 0.950 0.919 0.969 0.6599 0.726 0.564
#> 4 4 0.745 0.737 0.880 0.0985 0.900 0.744
#> 5 5 0.731 0.722 0.861 0.0780 0.928 0.778
#> 6 6 0.719 0.690 0.854 0.0583 0.905 0.659
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.0000 0.984 1.000 0.000
#> GSM414925 1 0.0000 0.984 1.000 0.000
#> GSM414926 1 0.0000 0.984 1.000 0.000
#> GSM414927 2 0.0000 0.962 0.000 1.000
#> GSM414929 1 0.0000 0.984 1.000 0.000
#> GSM414931 1 0.0000 0.984 1.000 0.000
#> GSM414933 1 0.0000 0.984 1.000 0.000
#> GSM414935 1 0.0000 0.984 1.000 0.000
#> GSM414936 1 0.0000 0.984 1.000 0.000
#> GSM414937 1 0.0000 0.984 1.000 0.000
#> GSM414939 1 0.0000 0.984 1.000 0.000
#> GSM414941 1 0.0000 0.984 1.000 0.000
#> GSM414943 1 0.0000 0.984 1.000 0.000
#> GSM414944 1 0.0000 0.984 1.000 0.000
#> GSM414945 2 0.0000 0.962 0.000 1.000
#> GSM414946 1 0.0000 0.984 1.000 0.000
#> GSM414948 1 0.0000 0.984 1.000 0.000
#> GSM414949 1 0.8813 0.560 0.700 0.300
#> GSM414950 1 0.0000 0.984 1.000 0.000
#> GSM414951 1 0.0000 0.984 1.000 0.000
#> GSM414952 1 0.0000 0.984 1.000 0.000
#> GSM414954 1 0.0000 0.984 1.000 0.000
#> GSM414956 1 0.0000 0.984 1.000 0.000
#> GSM414958 1 0.0000 0.984 1.000 0.000
#> GSM414959 1 0.0000 0.984 1.000 0.000
#> GSM414960 1 0.0000 0.984 1.000 0.000
#> GSM414961 1 0.0000 0.984 1.000 0.000
#> GSM414962 2 0.0000 0.962 0.000 1.000
#> GSM414964 1 0.0000 0.984 1.000 0.000
#> GSM414965 1 0.0000 0.984 1.000 0.000
#> GSM414967 1 0.0000 0.984 1.000 0.000
#> GSM414968 1 0.0000 0.984 1.000 0.000
#> GSM414969 1 0.0000 0.984 1.000 0.000
#> GSM414971 1 0.0000 0.984 1.000 0.000
#> GSM414973 1 0.0000 0.984 1.000 0.000
#> GSM414974 2 0.6148 0.816 0.152 0.848
#> GSM414928 2 0.0000 0.962 0.000 1.000
#> GSM414930 2 0.0000 0.962 0.000 1.000
#> GSM414932 1 0.0376 0.981 0.996 0.004
#> GSM414934 1 0.0000 0.984 1.000 0.000
#> GSM414938 1 0.0000 0.984 1.000 0.000
#> GSM414940 1 0.2778 0.937 0.952 0.048
#> GSM414942 2 0.0000 0.962 0.000 1.000
#> GSM414947 2 0.0000 0.962 0.000 1.000
#> GSM414953 1 0.0000 0.984 1.000 0.000
#> GSM414955 1 0.0000 0.984 1.000 0.000
#> GSM414957 2 0.0000 0.962 0.000 1.000
#> GSM414963 2 0.8608 0.609 0.284 0.716
#> GSM414966 2 0.0000 0.962 0.000 1.000
#> GSM414970 1 0.7453 0.722 0.788 0.212
#> GSM414972 2 0.0000 0.962 0.000 1.000
#> GSM414975 2 0.0000 0.962 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414927 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414929 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414935 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414936 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414937 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414939 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414941 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414943 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414944 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414945 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414946 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414948 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414949 3 0.4605 0.711 0.000 0.204 0.796
#> GSM414950 3 0.0237 0.922 0.004 0.000 0.996
#> GSM414951 1 0.6062 0.338 0.616 0.000 0.384
#> GSM414952 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414954 3 0.6180 0.257 0.416 0.000 0.584
#> GSM414956 1 0.0892 0.949 0.980 0.000 0.020
#> GSM414958 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414959 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414960 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414961 3 0.0237 0.922 0.004 0.000 0.996
#> GSM414962 2 0.0424 0.992 0.000 0.992 0.008
#> GSM414964 1 0.5926 0.429 0.644 0.000 0.356
#> GSM414965 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414967 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414968 3 0.4555 0.730 0.200 0.000 0.800
#> GSM414969 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414971 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414973 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414974 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414928 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414938 1 0.0000 0.967 1.000 0.000 0.000
#> GSM414940 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414955 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414957 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414966 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.924 0.000 0.000 1.000
#> GSM414972 2 0.0000 0.999 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.999 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.2868 0.7471 0.864 0.000 0.000 0.136
#> GSM414925 1 0.1398 0.8280 0.956 0.000 0.004 0.040
#> GSM414926 1 0.3219 0.7096 0.836 0.000 0.000 0.164
#> GSM414927 2 0.0188 0.9406 0.000 0.996 0.000 0.004
#> GSM414929 4 0.4605 0.6952 0.336 0.000 0.000 0.664
#> GSM414931 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414933 1 0.0592 0.8385 0.984 0.000 0.000 0.016
#> GSM414935 3 0.3801 0.7714 0.000 0.000 0.780 0.220
#> GSM414936 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414937 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414939 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414941 1 0.1389 0.8249 0.952 0.000 0.000 0.048
#> GSM414943 1 0.0188 0.8395 0.996 0.000 0.004 0.000
#> GSM414944 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414945 2 0.2999 0.8283 0.004 0.864 0.000 0.132
#> GSM414946 1 0.2973 0.7703 0.884 0.000 0.020 0.096
#> GSM414948 1 0.0188 0.8406 0.996 0.000 0.000 0.004
#> GSM414949 3 0.6770 0.5931 0.000 0.140 0.592 0.268
#> GSM414950 3 0.4482 0.7375 0.008 0.000 0.728 0.264
#> GSM414951 3 0.4996 -0.1092 0.484 0.000 0.516 0.000
#> GSM414952 3 0.0592 0.7956 0.000 0.000 0.984 0.016
#> GSM414954 1 0.5212 0.1100 0.572 0.000 0.420 0.008
#> GSM414956 1 0.3893 0.5819 0.796 0.000 0.196 0.008
#> GSM414958 1 0.4761 0.1324 0.628 0.000 0.000 0.372
#> GSM414959 1 0.0592 0.8378 0.984 0.000 0.000 0.016
#> GSM414960 1 0.2760 0.7321 0.872 0.000 0.000 0.128
#> GSM414961 3 0.3074 0.7976 0.000 0.000 0.848 0.152
#> GSM414962 2 0.6133 0.5768 0.000 0.644 0.088 0.268
#> GSM414964 1 0.5400 0.2132 0.608 0.000 0.372 0.020
#> GSM414965 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414967 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414968 4 0.6411 0.4132 0.092 0.000 0.308 0.600
#> GSM414969 1 0.6285 0.0774 0.528 0.000 0.060 0.412
#> GSM414971 1 0.0000 0.8413 1.000 0.000 0.000 0.000
#> GSM414973 1 0.1022 0.8318 0.968 0.000 0.000 0.032
#> GSM414974 2 0.0469 0.9362 0.000 0.988 0.000 0.012
#> GSM414928 2 0.2647 0.8569 0.000 0.880 0.000 0.120
#> GSM414930 2 0.0000 0.9420 0.000 1.000 0.000 0.000
#> GSM414932 3 0.3172 0.7960 0.000 0.000 0.840 0.160
#> GSM414934 3 0.1716 0.7708 0.000 0.000 0.936 0.064
#> GSM414938 4 0.4655 0.7185 0.312 0.000 0.004 0.684
#> GSM414940 3 0.0707 0.8024 0.000 0.000 0.980 0.020
#> GSM414942 2 0.0000 0.9420 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 0.9420 0.000 1.000 0.000 0.000
#> GSM414953 3 0.1716 0.7708 0.000 0.000 0.936 0.064
#> GSM414955 3 0.0000 0.8000 0.000 0.000 1.000 0.000
#> GSM414957 2 0.0000 0.9420 0.000 1.000 0.000 0.000
#> GSM414963 3 0.0592 0.7985 0.000 0.000 0.984 0.016
#> GSM414966 2 0.0000 0.9420 0.000 1.000 0.000 0.000
#> GSM414970 3 0.3486 0.7873 0.000 0.000 0.812 0.188
#> GSM414972 2 0.0000 0.9420 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.9420 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3779 0.8042 0.776 0.000 0.000 0.200 0.024
#> GSM414925 1 0.3300 0.8095 0.792 0.000 0.000 0.204 0.004
#> GSM414926 1 0.3656 0.8077 0.784 0.000 0.000 0.196 0.020
#> GSM414927 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414929 5 0.0290 0.8690 0.008 0.000 0.000 0.000 0.992
#> GSM414931 1 0.0671 0.8384 0.980 0.000 0.000 0.016 0.004
#> GSM414933 1 0.2909 0.8315 0.848 0.000 0.000 0.140 0.012
#> GSM414935 4 0.4359 0.3262 0.004 0.000 0.412 0.584 0.000
#> GSM414936 1 0.0510 0.8386 0.984 0.000 0.000 0.016 0.000
#> GSM414937 1 0.0609 0.8440 0.980 0.000 0.000 0.020 0.000
#> GSM414939 1 0.1043 0.8446 0.960 0.000 0.000 0.040 0.000
#> GSM414941 1 0.3563 0.8038 0.780 0.000 0.000 0.208 0.012
#> GSM414943 1 0.0771 0.8365 0.976 0.000 0.004 0.020 0.000
#> GSM414944 1 0.0865 0.8353 0.972 0.000 0.000 0.024 0.004
#> GSM414945 2 0.4028 0.7747 0.044 0.824 0.000 0.044 0.088
#> GSM414946 1 0.3861 0.7677 0.728 0.000 0.000 0.264 0.008
#> GSM414948 1 0.2629 0.8325 0.860 0.000 0.000 0.136 0.004
#> GSM414949 4 0.4066 0.6869 0.000 0.044 0.188 0.768 0.000
#> GSM414950 4 0.3534 0.6468 0.000 0.000 0.256 0.744 0.000
#> GSM414951 3 0.4585 0.2542 0.396 0.000 0.592 0.008 0.004
#> GSM414952 3 0.0510 0.7492 0.000 0.000 0.984 0.016 0.000
#> GSM414954 1 0.4613 0.4947 0.620 0.000 0.360 0.020 0.000
#> GSM414956 1 0.4801 0.2697 0.604 0.000 0.372 0.020 0.004
#> GSM414958 5 0.3551 0.6323 0.220 0.000 0.000 0.008 0.772
#> GSM414959 1 0.1082 0.8446 0.964 0.000 0.000 0.028 0.008
#> GSM414960 1 0.3596 0.6804 0.776 0.000 0.000 0.012 0.212
#> GSM414961 3 0.4397 0.0392 0.004 0.000 0.564 0.432 0.000
#> GSM414962 4 0.3835 0.6322 0.000 0.156 0.048 0.796 0.000
#> GSM414964 1 0.5702 0.5302 0.628 0.000 0.180 0.192 0.000
#> GSM414965 1 0.0324 0.8408 0.992 0.000 0.004 0.004 0.000
#> GSM414967 1 0.0992 0.8350 0.968 0.000 0.000 0.024 0.008
#> GSM414968 5 0.0833 0.8592 0.004 0.000 0.016 0.004 0.976
#> GSM414969 4 0.1809 0.5590 0.060 0.000 0.000 0.928 0.012
#> GSM414971 1 0.0771 0.8371 0.976 0.000 0.000 0.020 0.004
#> GSM414973 1 0.3246 0.8156 0.808 0.000 0.000 0.184 0.008
#> GSM414974 2 0.0609 0.9157 0.000 0.980 0.000 0.020 0.000
#> GSM414928 2 0.4302 0.0976 0.000 0.520 0.000 0.480 0.000
#> GSM414930 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.3003 0.6107 0.000 0.000 0.812 0.188 0.000
#> GSM414934 3 0.0000 0.7447 0.000 0.000 1.000 0.000 0.000
#> GSM414938 5 0.0324 0.8678 0.004 0.000 0.004 0.000 0.992
#> GSM414940 3 0.1410 0.7322 0.000 0.000 0.940 0.060 0.000
#> GSM414942 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.7447 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.0404 0.7488 0.000 0.000 0.988 0.012 0.000
#> GSM414957 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0609 0.7483 0.000 0.000 0.980 0.020 0.000
#> GSM414966 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.4249 0.0403 0.000 0.000 0.568 0.432 0.000
#> GSM414972 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9298 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.2866 0.8104 0.012 0.000 0.000 0.060 0.868 0.060
#> GSM414925 5 0.2468 0.8144 0.004 0.000 0.000 0.060 0.888 0.048
#> GSM414926 5 0.3209 0.8005 0.008 0.000 0.000 0.064 0.840 0.088
#> GSM414927 2 0.0547 0.9739 0.000 0.980 0.000 0.020 0.000 0.000
#> GSM414929 1 0.0000 0.9281 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM414931 5 0.3898 0.4596 0.000 0.000 0.000 0.012 0.652 0.336
#> GSM414933 6 0.4157 0.0780 0.000 0.000 0.000 0.012 0.444 0.544
#> GSM414935 3 0.5516 0.1835 0.000 0.000 0.488 0.424 0.040 0.048
#> GSM414936 5 0.0937 0.8219 0.000 0.000 0.000 0.000 0.960 0.040
#> GSM414937 5 0.1341 0.8170 0.000 0.000 0.028 0.000 0.948 0.024
#> GSM414939 5 0.1152 0.8219 0.000 0.000 0.004 0.000 0.952 0.044
#> GSM414941 5 0.2573 0.8130 0.008 0.000 0.000 0.064 0.884 0.044
#> GSM414943 5 0.2119 0.7946 0.000 0.000 0.060 0.000 0.904 0.036
#> GSM414944 6 0.2378 0.6274 0.000 0.000 0.000 0.000 0.152 0.848
#> GSM414945 6 0.3025 0.4514 0.000 0.156 0.000 0.024 0.000 0.820
#> GSM414946 5 0.3277 0.7851 0.000 0.000 0.000 0.084 0.824 0.092
#> GSM414948 5 0.1367 0.8230 0.000 0.000 0.000 0.012 0.944 0.044
#> GSM414949 4 0.1285 0.6252 0.000 0.000 0.052 0.944 0.000 0.004
#> GSM414950 4 0.1863 0.5961 0.000 0.000 0.104 0.896 0.000 0.000
#> GSM414951 3 0.4130 0.4741 0.000 0.000 0.696 0.000 0.260 0.044
#> GSM414952 3 0.0520 0.7759 0.000 0.000 0.984 0.008 0.000 0.008
#> GSM414954 5 0.4150 0.6044 0.000 0.000 0.228 0.012 0.724 0.036
#> GSM414956 6 0.5799 0.1097 0.000 0.000 0.392 0.000 0.180 0.428
#> GSM414958 1 0.2346 0.7706 0.868 0.000 0.000 0.000 0.124 0.008
#> GSM414959 5 0.3011 0.7009 0.004 0.000 0.004 0.000 0.800 0.192
#> GSM414960 5 0.5025 0.5036 0.276 0.000 0.000 0.012 0.632 0.080
#> GSM414961 3 0.5949 0.3658 0.000 0.000 0.532 0.308 0.132 0.028
#> GSM414962 4 0.0935 0.6290 0.000 0.032 0.004 0.964 0.000 0.000
#> GSM414964 5 0.5302 0.5785 0.000 0.000 0.064 0.216 0.660 0.060
#> GSM414965 5 0.1124 0.8253 0.000 0.000 0.008 0.000 0.956 0.036
#> GSM414967 6 0.2178 0.6271 0.000 0.000 0.000 0.000 0.132 0.868
#> GSM414968 1 0.0146 0.9253 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM414969 4 0.4201 0.3737 0.012 0.000 0.000 0.716 0.236 0.036
#> GSM414971 5 0.1444 0.8155 0.000 0.000 0.000 0.000 0.928 0.072
#> GSM414973 5 0.1700 0.8231 0.000 0.000 0.000 0.048 0.928 0.024
#> GSM414974 2 0.1364 0.9428 0.000 0.952 0.000 0.016 0.020 0.012
#> GSM414928 4 0.3867 -0.0696 0.000 0.488 0.000 0.512 0.000 0.000
#> GSM414930 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.3578 0.4679 0.000 0.000 0.660 0.340 0.000 0.000
#> GSM414934 3 0.0000 0.7748 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414938 1 0.0000 0.9281 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM414940 3 0.1176 0.7672 0.000 0.000 0.956 0.024 0.000 0.020
#> GSM414942 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.7748 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414955 3 0.0806 0.7741 0.000 0.000 0.972 0.020 0.000 0.008
#> GSM414957 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.0865 0.7717 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM414966 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 4 0.3828 -0.0970 0.000 0.000 0.440 0.560 0.000 0.000
#> GSM414972 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9903 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> CV:NMF 52 1.79e-03 2
#> CV:NMF 49 1.35e-04 3
#> CV:NMF 46 2.51e-04 4
#> CV:NMF 45 1.43e-05 5
#> CV:NMF 41 7.12e-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", "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 51882 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 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.965 0.984 0.3327 0.683 0.683
#> 3 3 0.589 0.722 0.869 0.8451 0.649 0.492
#> 4 4 0.632 0.795 0.860 0.1390 0.828 0.571
#> 5 5 0.707 0.788 0.881 0.0458 0.963 0.873
#> 6 6 0.721 0.747 0.883 0.0501 0.980 0.925
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
#> GSM414924 1 0.0000 0.981 1.000 0.000
#> GSM414925 1 0.0000 0.981 1.000 0.000
#> GSM414926 1 0.0000 0.981 1.000 0.000
#> GSM414927 2 0.0000 1.000 0.000 1.000
#> GSM414929 1 0.0000 0.981 1.000 0.000
#> GSM414931 1 0.0000 0.981 1.000 0.000
#> GSM414933 1 0.0000 0.981 1.000 0.000
#> GSM414935 1 0.1184 0.976 0.984 0.016
#> GSM414936 1 0.0000 0.981 1.000 0.000
#> GSM414937 1 0.0000 0.981 1.000 0.000
#> GSM414939 1 0.0000 0.981 1.000 0.000
#> GSM414941 1 0.0000 0.981 1.000 0.000
#> GSM414943 1 0.0000 0.981 1.000 0.000
#> GSM414944 1 0.0000 0.981 1.000 0.000
#> GSM414945 2 0.0000 1.000 0.000 1.000
#> GSM414946 1 0.0000 0.981 1.000 0.000
#> GSM414948 1 0.0000 0.981 1.000 0.000
#> GSM414949 1 0.1414 0.974 0.980 0.020
#> GSM414950 1 0.1414 0.974 0.980 0.020
#> GSM414951 1 0.0000 0.981 1.000 0.000
#> GSM414952 1 0.1414 0.974 0.980 0.020
#> GSM414954 1 0.0376 0.980 0.996 0.004
#> GSM414956 1 0.0000 0.981 1.000 0.000
#> GSM414958 1 0.0000 0.981 1.000 0.000
#> GSM414959 1 0.0000 0.981 1.000 0.000
#> GSM414960 1 0.0000 0.981 1.000 0.000
#> GSM414961 1 0.1184 0.976 0.984 0.016
#> GSM414962 1 0.9996 0.074 0.512 0.488
#> GSM414964 1 0.0000 0.981 1.000 0.000
#> GSM414965 1 0.0000 0.981 1.000 0.000
#> GSM414967 1 0.0000 0.981 1.000 0.000
#> GSM414968 1 0.0376 0.980 0.996 0.004
#> GSM414969 1 0.0000 0.981 1.000 0.000
#> GSM414971 1 0.0000 0.981 1.000 0.000
#> GSM414973 1 0.0000 0.981 1.000 0.000
#> GSM414974 1 0.2043 0.966 0.968 0.032
#> GSM414928 2 0.0000 1.000 0.000 1.000
#> GSM414930 2 0.0000 1.000 0.000 1.000
#> GSM414932 1 0.1633 0.972 0.976 0.024
#> GSM414934 1 0.1633 0.972 0.976 0.024
#> GSM414938 1 0.1633 0.972 0.976 0.024
#> GSM414940 1 0.1633 0.972 0.976 0.024
#> GSM414942 2 0.0000 1.000 0.000 1.000
#> GSM414947 2 0.0000 1.000 0.000 1.000
#> GSM414953 1 0.1633 0.972 0.976 0.024
#> GSM414955 1 0.1414 0.974 0.980 0.020
#> GSM414957 2 0.0000 1.000 0.000 1.000
#> GSM414963 1 0.1633 0.972 0.976 0.024
#> GSM414966 2 0.0000 1.000 0.000 1.000
#> GSM414970 1 0.1633 0.972 0.976 0.024
#> GSM414972 2 0.0000 1.000 0.000 1.000
#> GSM414975 2 0.0000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414927 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414929 1 0.0424 0.87076 0.992 0.000 0.008
#> GSM414931 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414935 3 0.4346 0.80690 0.184 0.000 0.816
#> GSM414936 3 0.6309 0.32019 0.500 0.000 0.500
#> GSM414937 3 0.5948 0.63391 0.360 0.000 0.640
#> GSM414939 3 0.5948 0.63391 0.360 0.000 0.640
#> GSM414941 1 0.6244 -0.13307 0.560 0.000 0.440
#> GSM414943 3 0.6309 0.32019 0.500 0.000 0.500
#> GSM414944 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414945 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414946 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414948 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414949 3 0.4002 0.80634 0.160 0.000 0.840
#> GSM414950 3 0.4002 0.80634 0.160 0.000 0.840
#> GSM414951 3 0.5138 0.76113 0.252 0.000 0.748
#> GSM414952 3 0.4235 0.80768 0.176 0.000 0.824
#> GSM414954 3 0.4452 0.80435 0.192 0.000 0.808
#> GSM414956 1 0.6309 -0.38587 0.500 0.000 0.500
#> GSM414958 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414959 3 0.6309 0.32019 0.500 0.000 0.500
#> GSM414960 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414961 3 0.4346 0.80690 0.184 0.000 0.816
#> GSM414962 2 0.9497 -0.00678 0.200 0.468 0.332
#> GSM414964 3 0.6244 0.45557 0.440 0.000 0.560
#> GSM414965 1 0.6309 -0.38587 0.500 0.000 0.500
#> GSM414967 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414968 3 0.4654 0.79545 0.208 0.000 0.792
#> GSM414969 1 0.1289 0.84986 0.968 0.000 0.032
#> GSM414971 1 0.0000 0.87663 1.000 0.000 0.000
#> GSM414973 1 0.1163 0.85245 0.972 0.000 0.028
#> GSM414974 3 0.4861 0.80540 0.180 0.012 0.808
#> GSM414928 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.73692 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.73692 0.000 0.000 1.000
#> GSM414938 3 0.4605 0.79682 0.204 0.000 0.796
#> GSM414940 3 0.0000 0.73692 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.73692 0.000 0.000 1.000
#> GSM414955 3 0.4235 0.80768 0.176 0.000 0.824
#> GSM414957 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.73692 0.000 0.000 1.000
#> GSM414966 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.73692 0.000 0.000 1.000
#> GSM414972 2 0.0000 0.94604 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.94604 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.4281 0.8177 0.792 0.000 0.180 0.028
#> GSM414925 1 0.4281 0.8177 0.792 0.000 0.180 0.028
#> GSM414926 1 0.4281 0.8177 0.792 0.000 0.180 0.028
#> GSM414927 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414929 1 0.3598 0.8423 0.848 0.000 0.124 0.028
#> GSM414931 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414933 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414935 3 0.0657 0.7215 0.004 0.000 0.984 0.012
#> GSM414936 3 0.4564 0.5690 0.328 0.000 0.672 0.000
#> GSM414937 3 0.3400 0.7165 0.180 0.000 0.820 0.000
#> GSM414939 3 0.3400 0.7165 0.180 0.000 0.820 0.000
#> GSM414941 3 0.5174 0.3407 0.368 0.000 0.620 0.012
#> GSM414943 3 0.4585 0.5673 0.332 0.000 0.668 0.000
#> GSM414944 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414945 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414946 1 0.4281 0.8177 0.792 0.000 0.180 0.028
#> GSM414948 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414949 3 0.1867 0.6680 0.000 0.000 0.928 0.072
#> GSM414950 3 0.1867 0.6680 0.000 0.000 0.928 0.072
#> GSM414951 3 0.1867 0.7401 0.072 0.000 0.928 0.000
#> GSM414952 3 0.0188 0.7199 0.000 0.000 0.996 0.004
#> GSM414954 3 0.0779 0.7293 0.016 0.000 0.980 0.004
#> GSM414956 3 0.4585 0.5673 0.332 0.000 0.668 0.000
#> GSM414958 1 0.2813 0.8539 0.896 0.000 0.080 0.024
#> GSM414959 3 0.4585 0.5673 0.332 0.000 0.668 0.000
#> GSM414960 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414961 3 0.0524 0.7224 0.004 0.000 0.988 0.008
#> GSM414962 3 0.6214 -0.0228 0.000 0.468 0.480 0.052
#> GSM414964 3 0.4485 0.6007 0.248 0.000 0.740 0.012
#> GSM414965 3 0.4585 0.5673 0.332 0.000 0.668 0.000
#> GSM414967 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414968 3 0.0921 0.7340 0.028 0.000 0.972 0.000
#> GSM414969 1 0.4599 0.7798 0.760 0.000 0.212 0.028
#> GSM414971 1 0.0000 0.8579 1.000 0.000 0.000 0.000
#> GSM414973 1 0.4524 0.7862 0.768 0.000 0.204 0.028
#> GSM414974 3 0.1388 0.7093 0.000 0.012 0.960 0.028
#> GSM414928 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414932 4 0.4008 0.9891 0.000 0.000 0.244 0.756
#> GSM414934 4 0.3801 0.9783 0.000 0.000 0.220 0.780
#> GSM414938 3 0.4585 0.5784 0.000 0.000 0.668 0.332
#> GSM414940 4 0.4008 0.9891 0.000 0.000 0.244 0.756
#> GSM414942 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414953 4 0.3801 0.9783 0.000 0.000 0.220 0.780
#> GSM414955 3 0.0188 0.7199 0.000 0.000 0.996 0.004
#> GSM414957 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414963 4 0.4008 0.9891 0.000 0.000 0.244 0.756
#> GSM414966 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414970 4 0.4008 0.9891 0.000 0.000 0.244 0.756
#> GSM414972 2 0.0000 1.0000 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 1.0000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.2864 0.8470 0.864 0.000 0.000 0.024 0.112
#> GSM414925 1 0.2864 0.8470 0.864 0.000 0.000 0.024 0.112
#> GSM414926 1 0.2864 0.8470 0.864 0.000 0.000 0.024 0.112
#> GSM414927 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414929 1 0.2067 0.8606 0.920 0.000 0.000 0.032 0.048
#> GSM414931 1 0.1704 0.8627 0.928 0.000 0.004 0.068 0.000
#> GSM414933 1 0.1704 0.8627 0.928 0.000 0.004 0.068 0.000
#> GSM414935 5 0.0566 0.7657 0.004 0.000 0.012 0.000 0.984
#> GSM414936 5 0.4299 0.6339 0.316 0.000 0.008 0.004 0.672
#> GSM414937 5 0.2929 0.7528 0.180 0.000 0.000 0.000 0.820
#> GSM414939 5 0.2929 0.7528 0.180 0.000 0.000 0.000 0.820
#> GSM414941 5 0.4537 0.3259 0.396 0.000 0.000 0.012 0.592
#> GSM414943 5 0.4317 0.6323 0.320 0.000 0.008 0.004 0.668
#> GSM414944 1 0.2006 0.8564 0.916 0.000 0.012 0.072 0.000
#> GSM414945 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414946 1 0.2864 0.8470 0.864 0.000 0.000 0.024 0.112
#> GSM414948 1 0.1704 0.8627 0.928 0.000 0.004 0.068 0.000
#> GSM414949 5 0.1608 0.7278 0.000 0.000 0.072 0.000 0.928
#> GSM414950 5 0.1608 0.7278 0.000 0.000 0.072 0.000 0.928
#> GSM414951 5 0.1608 0.7734 0.072 0.000 0.000 0.000 0.928
#> GSM414952 5 0.0162 0.7631 0.000 0.000 0.004 0.000 0.996
#> GSM414954 5 0.0671 0.7702 0.016 0.000 0.004 0.000 0.980
#> GSM414956 5 0.4317 0.6323 0.320 0.000 0.008 0.004 0.668
#> GSM414958 1 0.0880 0.8663 0.968 0.000 0.000 0.000 0.032
#> GSM414959 5 0.4183 0.6302 0.324 0.000 0.008 0.000 0.668
#> GSM414960 1 0.1704 0.8627 0.928 0.000 0.004 0.068 0.000
#> GSM414961 5 0.0451 0.7657 0.004 0.000 0.008 0.000 0.988
#> GSM414962 2 0.6901 0.0189 0.072 0.468 0.024 0.032 0.404
#> GSM414964 5 0.4040 0.5989 0.276 0.000 0.000 0.012 0.712
#> GSM414965 5 0.4317 0.6323 0.320 0.000 0.008 0.004 0.668
#> GSM414967 1 0.2006 0.8564 0.916 0.000 0.012 0.072 0.000
#> GSM414968 5 0.0794 0.7730 0.028 0.000 0.000 0.000 0.972
#> GSM414969 1 0.3194 0.8164 0.832 0.000 0.000 0.020 0.148
#> GSM414971 1 0.1704 0.8627 0.928 0.000 0.004 0.068 0.000
#> GSM414973 1 0.3106 0.8220 0.840 0.000 0.000 0.020 0.140
#> GSM414974 5 0.2116 0.7402 0.016 0.012 0.024 0.016 0.932
#> GSM414928 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.1341 0.9651 0.000 0.000 0.944 0.000 0.056
#> GSM414934 3 0.1012 0.9288 0.000 0.000 0.968 0.020 0.012
#> GSM414938 4 0.2344 0.0000 0.064 0.000 0.000 0.904 0.032
#> GSM414940 3 0.1341 0.9651 0.000 0.000 0.944 0.000 0.056
#> GSM414942 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.1012 0.9288 0.000 0.000 0.968 0.020 0.012
#> GSM414955 5 0.0162 0.7631 0.000 0.000 0.004 0.000 0.996
#> GSM414957 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.1341 0.9651 0.000 0.000 0.944 0.000 0.056
#> GSM414966 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.1341 0.9651 0.000 0.000 0.944 0.000 0.056
#> GSM414972 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9299 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.0260 0.8243 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM414925 1 0.0260 0.8243 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM414926 1 0.0260 0.8243 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM414927 2 0.0146 0.9336 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM414929 1 0.1563 0.8239 0.932 0.000 0.000 0.012 0.000 0.056
#> GSM414931 1 0.2793 0.7667 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM414933 1 0.2793 0.7667 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM414935 5 0.1218 0.7674 0.028 0.000 0.012 0.000 0.956 0.004
#> GSM414936 5 0.4774 0.6813 0.192 0.000 0.000 0.000 0.672 0.136
#> GSM414937 5 0.3270 0.7648 0.120 0.000 0.000 0.000 0.820 0.060
#> GSM414939 5 0.3270 0.7648 0.120 0.000 0.000 0.000 0.820 0.060
#> GSM414941 5 0.3828 0.2857 0.440 0.000 0.000 0.000 0.560 0.000
#> GSM414943 5 0.4801 0.6796 0.196 0.000 0.000 0.000 0.668 0.136
#> GSM414944 6 0.1267 0.0923 0.060 0.000 0.000 0.000 0.000 0.940
#> GSM414945 2 0.0146 0.9330 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM414946 1 0.0260 0.8243 0.992 0.000 0.000 0.000 0.008 0.000
#> GSM414948 1 0.2793 0.7667 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM414949 5 0.3273 0.6972 0.036 0.000 0.072 0.000 0.848 0.044
#> GSM414950 5 0.3205 0.7005 0.036 0.000 0.072 0.000 0.852 0.040
#> GSM414951 5 0.1444 0.7804 0.072 0.000 0.000 0.000 0.928 0.000
#> GSM414952 5 0.0146 0.7703 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM414954 5 0.0603 0.7769 0.016 0.000 0.004 0.000 0.980 0.000
#> GSM414956 5 0.4801 0.6796 0.196 0.000 0.000 0.000 0.668 0.136
#> GSM414958 1 0.1765 0.8184 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM414959 5 0.4783 0.6775 0.204 0.000 0.000 0.000 0.668 0.128
#> GSM414960 1 0.2793 0.7667 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM414961 5 0.0551 0.7717 0.004 0.000 0.008 0.000 0.984 0.004
#> GSM414962 2 0.7255 0.0897 0.196 0.464 0.024 0.008 0.260 0.048
#> GSM414964 5 0.3464 0.5462 0.312 0.000 0.000 0.000 0.688 0.000
#> GSM414965 5 0.4801 0.6796 0.196 0.000 0.000 0.000 0.668 0.136
#> GSM414967 6 0.3843 0.0127 0.452 0.000 0.000 0.000 0.000 0.548
#> GSM414968 5 0.0713 0.7796 0.028 0.000 0.000 0.000 0.972 0.000
#> GSM414969 1 0.1007 0.7913 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM414971 1 0.2793 0.7667 0.800 0.000 0.000 0.000 0.000 0.200
#> GSM414973 1 0.0937 0.7961 0.960 0.000 0.000 0.000 0.040 0.000
#> GSM414974 5 0.3828 0.6820 0.088 0.008 0.024 0.008 0.824 0.048
#> GSM414928 2 0.0146 0.9336 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM414930 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.1007 0.9630 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM414934 3 0.0717 0.9243 0.000 0.000 0.976 0.016 0.000 0.008
#> GSM414938 4 0.0458 0.0000 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM414940 3 0.1007 0.9630 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM414942 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.0717 0.9243 0.000 0.000 0.976 0.016 0.000 0.008
#> GSM414955 5 0.0146 0.7703 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM414957 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.1007 0.9630 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM414966 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.1007 0.9630 0.000 0.000 0.956 0.000 0.044 0.000
#> GSM414972 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9357 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> MAD:hclust 51 9.13e-04 2
#> MAD:hclust 44 1.96e-04 3
#> MAD:hclust 50 1.61e-07 4
#> MAD:hclust 49 4.55e-08 5
#> MAD:hclust 47 1.06e-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 51882 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.726 0.859 0.870 0.3762 0.683 0.683
#> 3 3 1.000 0.977 0.988 0.6547 0.695 0.553
#> 4 4 0.687 0.744 0.806 0.1661 0.872 0.661
#> 5 5 0.662 0.657 0.793 0.0766 0.958 0.836
#> 6 6 0.701 0.557 0.755 0.0426 0.977 0.900
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
#> GSM414924 1 0.000 0.905 1.000 0.000
#> GSM414925 1 0.000 0.905 1.000 0.000
#> GSM414926 1 0.000 0.905 1.000 0.000
#> GSM414927 2 0.000 1.000 0.000 1.000
#> GSM414929 1 0.000 0.905 1.000 0.000
#> GSM414931 1 0.000 0.905 1.000 0.000
#> GSM414933 1 0.000 0.905 1.000 0.000
#> GSM414935 1 0.000 0.905 1.000 0.000
#> GSM414936 1 0.000 0.905 1.000 0.000
#> GSM414937 1 0.000 0.905 1.000 0.000
#> GSM414939 1 0.000 0.905 1.000 0.000
#> GSM414941 1 0.000 0.905 1.000 0.000
#> GSM414943 1 0.000 0.905 1.000 0.000
#> GSM414944 1 0.000 0.905 1.000 0.000
#> GSM414945 2 0.000 1.000 0.000 1.000
#> GSM414946 1 0.000 0.905 1.000 0.000
#> GSM414948 1 0.000 0.905 1.000 0.000
#> GSM414949 1 0.936 0.575 0.648 0.352
#> GSM414950 1 0.000 0.905 1.000 0.000
#> GSM414951 1 0.000 0.905 1.000 0.000
#> GSM414952 1 0.000 0.905 1.000 0.000
#> GSM414954 1 0.000 0.905 1.000 0.000
#> GSM414956 1 0.000 0.905 1.000 0.000
#> GSM414958 1 0.000 0.905 1.000 0.000
#> GSM414959 1 0.000 0.905 1.000 0.000
#> GSM414960 1 0.000 0.905 1.000 0.000
#> GSM414961 1 0.000 0.905 1.000 0.000
#> GSM414962 1 0.936 0.575 0.648 0.352
#> GSM414964 1 0.000 0.905 1.000 0.000
#> GSM414965 1 0.000 0.905 1.000 0.000
#> GSM414967 1 0.000 0.905 1.000 0.000
#> GSM414968 1 0.000 0.905 1.000 0.000
#> GSM414969 1 0.000 0.905 1.000 0.000
#> GSM414971 1 0.000 0.905 1.000 0.000
#> GSM414973 1 0.000 0.905 1.000 0.000
#> GSM414974 1 0.936 0.575 0.648 0.352
#> GSM414928 2 0.000 1.000 0.000 1.000
#> GSM414930 2 0.000 1.000 0.000 1.000
#> GSM414932 1 0.936 0.575 0.648 0.352
#> GSM414934 1 0.936 0.575 0.648 0.352
#> GSM414938 1 0.000 0.905 1.000 0.000
#> GSM414940 1 0.936 0.575 0.648 0.352
#> GSM414942 2 0.000 1.000 0.000 1.000
#> GSM414947 2 0.000 1.000 0.000 1.000
#> GSM414953 1 0.936 0.575 0.648 0.352
#> GSM414955 1 0.936 0.575 0.648 0.352
#> GSM414957 2 0.000 1.000 0.000 1.000
#> GSM414963 1 0.949 0.547 0.632 0.368
#> GSM414966 2 0.000 1.000 0.000 1.000
#> GSM414970 1 0.939 0.568 0.644 0.356
#> GSM414972 2 0.000 1.000 0.000 1.000
#> GSM414975 2 0.000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414927 2 0.0424 0.998 0.000 0.992 0.008
#> GSM414929 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414935 3 0.0592 0.964 0.012 0.000 0.988
#> GSM414936 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414937 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414939 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414941 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414943 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414944 1 0.0424 0.993 0.992 0.008 0.000
#> GSM414945 2 0.0000 0.992 0.000 1.000 0.000
#> GSM414946 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414948 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414949 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414950 3 0.0592 0.964 0.012 0.000 0.988
#> GSM414951 1 0.0237 0.995 0.996 0.000 0.004
#> GSM414952 3 0.0592 0.964 0.012 0.000 0.988
#> GSM414954 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414956 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414958 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414959 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414960 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414961 3 0.0592 0.964 0.012 0.000 0.988
#> GSM414962 3 0.6095 0.346 0.000 0.392 0.608
#> GSM414964 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414965 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414967 1 0.0424 0.993 0.992 0.008 0.000
#> GSM414968 3 0.0592 0.964 0.012 0.000 0.988
#> GSM414969 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414971 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414973 1 0.0000 0.999 1.000 0.000 0.000
#> GSM414974 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414928 2 0.0424 0.998 0.000 0.992 0.008
#> GSM414930 2 0.0424 0.998 0.000 0.992 0.008
#> GSM414932 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414934 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414938 1 0.0424 0.993 0.992 0.008 0.000
#> GSM414940 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414942 2 0.0592 0.998 0.000 0.988 0.012
#> GSM414947 2 0.0424 0.998 0.000 0.992 0.008
#> GSM414953 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414955 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414957 2 0.0424 0.998 0.000 0.992 0.008
#> GSM414963 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414966 2 0.0592 0.998 0.000 0.988 0.012
#> GSM414970 3 0.0237 0.967 0.004 0.000 0.996
#> GSM414972 2 0.0592 0.998 0.000 0.988 0.012
#> GSM414975 2 0.0592 0.998 0.000 0.988 0.012
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.1302 0.7188 0.956 0.000 0.000 0.044
#> GSM414925 1 0.2216 0.7013 0.908 0.000 0.000 0.092
#> GSM414926 1 0.1118 0.7223 0.964 0.000 0.000 0.036
#> GSM414927 2 0.1389 0.9656 0.000 0.952 0.000 0.048
#> GSM414929 1 0.1211 0.7214 0.960 0.000 0.000 0.040
#> GSM414931 1 0.2760 0.6923 0.872 0.000 0.000 0.128
#> GSM414933 1 0.1389 0.7236 0.952 0.000 0.000 0.048
#> GSM414935 3 0.4304 0.7668 0.000 0.000 0.716 0.284
#> GSM414936 4 0.4916 0.8644 0.424 0.000 0.000 0.576
#> GSM414937 4 0.4843 0.8771 0.396 0.000 0.000 0.604
#> GSM414939 4 0.4866 0.8788 0.404 0.000 0.000 0.596
#> GSM414941 1 0.4972 -0.3037 0.544 0.000 0.000 0.456
#> GSM414943 4 0.4916 0.8644 0.424 0.000 0.000 0.576
#> GSM414944 1 0.4985 0.0426 0.532 0.000 0.000 0.468
#> GSM414945 2 0.2704 0.9247 0.000 0.876 0.000 0.124
#> GSM414946 1 0.2469 0.6896 0.892 0.000 0.000 0.108
#> GSM414948 1 0.2469 0.7050 0.892 0.000 0.000 0.108
#> GSM414949 3 0.2216 0.8497 0.000 0.000 0.908 0.092
#> GSM414950 3 0.4304 0.7668 0.000 0.000 0.716 0.284
#> GSM414951 4 0.5039 0.8644 0.404 0.000 0.004 0.592
#> GSM414952 3 0.1792 0.8537 0.000 0.000 0.932 0.068
#> GSM414954 4 0.4624 0.7582 0.340 0.000 0.000 0.660
#> GSM414956 4 0.4843 0.8730 0.396 0.000 0.000 0.604
#> GSM414958 1 0.2149 0.7099 0.912 0.000 0.000 0.088
#> GSM414959 4 0.4981 0.8249 0.464 0.000 0.000 0.536
#> GSM414960 1 0.2281 0.7149 0.904 0.000 0.000 0.096
#> GSM414961 3 0.4331 0.7632 0.000 0.000 0.712 0.288
#> GSM414962 3 0.9177 0.1944 0.076 0.308 0.368 0.248
#> GSM414964 4 0.4697 0.7438 0.356 0.000 0.000 0.644
#> GSM414965 4 0.4977 0.8010 0.460 0.000 0.000 0.540
#> GSM414967 1 0.3873 0.6124 0.772 0.000 0.000 0.228
#> GSM414968 3 0.3569 0.8197 0.000 0.000 0.804 0.196
#> GSM414969 1 0.3266 0.6006 0.832 0.000 0.000 0.168
#> GSM414971 1 0.4888 -0.2265 0.588 0.000 0.000 0.412
#> GSM414973 1 0.3569 0.5352 0.804 0.000 0.000 0.196
#> GSM414974 3 0.5839 0.7160 0.060 0.000 0.648 0.292
#> GSM414928 2 0.1389 0.9656 0.000 0.952 0.000 0.048
#> GSM414930 2 0.0000 0.9667 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0000 0.8575 0.000 0.000 1.000 0.000
#> GSM414934 3 0.0592 0.8537 0.000 0.000 0.984 0.016
#> GSM414938 1 0.3486 0.6233 0.812 0.000 0.000 0.188
#> GSM414940 3 0.0336 0.8559 0.000 0.000 0.992 0.008
#> GSM414942 2 0.0817 0.9642 0.000 0.976 0.000 0.024
#> GSM414947 2 0.1389 0.9656 0.000 0.952 0.000 0.048
#> GSM414953 3 0.0592 0.8537 0.000 0.000 0.984 0.016
#> GSM414955 3 0.0000 0.8575 0.000 0.000 1.000 0.000
#> GSM414957 2 0.1389 0.9656 0.000 0.952 0.000 0.048
#> GSM414963 3 0.0000 0.8575 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0921 0.9640 0.000 0.972 0.000 0.028
#> GSM414970 3 0.0000 0.8575 0.000 0.000 1.000 0.000
#> GSM414972 2 0.0921 0.9640 0.000 0.972 0.000 0.028
#> GSM414975 2 0.0921 0.9640 0.000 0.972 0.000 0.028
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.1121 0.6599 0.956 0.000 0.000 0.000 0.044
#> GSM414925 1 0.2464 0.6594 0.888 0.000 0.000 0.016 0.096
#> GSM414926 1 0.1121 0.6599 0.956 0.000 0.000 0.000 0.044
#> GSM414927 2 0.2966 0.8808 0.000 0.816 0.000 0.184 0.000
#> GSM414929 1 0.3825 0.6448 0.804 0.000 0.000 0.136 0.060
#> GSM414931 1 0.5608 0.6236 0.640 0.000 0.000 0.172 0.188
#> GSM414933 1 0.4844 0.6538 0.720 0.000 0.000 0.172 0.108
#> GSM414935 3 0.6366 0.5732 0.016 0.000 0.576 0.164 0.244
#> GSM414936 5 0.1831 0.8368 0.076 0.000 0.000 0.004 0.920
#> GSM414937 5 0.1952 0.8364 0.084 0.000 0.000 0.004 0.912
#> GSM414939 5 0.1792 0.8403 0.084 0.000 0.000 0.000 0.916
#> GSM414941 1 0.5689 0.0724 0.480 0.000 0.000 0.080 0.440
#> GSM414943 5 0.1831 0.8368 0.076 0.000 0.000 0.004 0.920
#> GSM414944 4 0.6588 -0.2506 0.208 0.000 0.000 0.400 0.392
#> GSM414945 2 0.4367 0.7026 0.008 0.620 0.000 0.372 0.000
#> GSM414946 1 0.2813 0.6501 0.868 0.000 0.000 0.024 0.108
#> GSM414948 1 0.5478 0.6362 0.656 0.000 0.000 0.164 0.180
#> GSM414949 3 0.4147 0.7071 0.004 0.000 0.776 0.172 0.048
#> GSM414950 3 0.6150 0.5810 0.008 0.000 0.588 0.164 0.240
#> GSM414951 5 0.2653 0.8141 0.096 0.000 0.000 0.024 0.880
#> GSM414952 3 0.2853 0.7472 0.000 0.000 0.876 0.072 0.052
#> GSM414954 5 0.3102 0.7302 0.084 0.000 0.000 0.056 0.860
#> GSM414956 5 0.1341 0.8387 0.056 0.000 0.000 0.000 0.944
#> GSM414958 1 0.5237 0.6501 0.684 0.000 0.000 0.160 0.156
#> GSM414959 5 0.2719 0.7903 0.144 0.000 0.000 0.004 0.852
#> GSM414960 1 0.5233 0.6373 0.680 0.000 0.000 0.192 0.128
#> GSM414961 3 0.6366 0.5732 0.016 0.000 0.576 0.164 0.244
#> GSM414962 4 0.7826 -0.1583 0.192 0.052 0.208 0.512 0.036
#> GSM414964 5 0.4121 0.6473 0.112 0.000 0.000 0.100 0.788
#> GSM414965 5 0.2233 0.8144 0.104 0.000 0.000 0.004 0.892
#> GSM414967 1 0.6392 0.2624 0.432 0.000 0.000 0.400 0.168
#> GSM414968 3 0.5760 0.6552 0.020 0.000 0.668 0.164 0.148
#> GSM414969 1 0.4617 0.4507 0.744 0.000 0.000 0.148 0.108
#> GSM414971 5 0.5844 0.2874 0.244 0.000 0.000 0.156 0.600
#> GSM414973 1 0.3715 0.5580 0.736 0.000 0.000 0.004 0.260
#> GSM414974 3 0.8056 0.2839 0.180 0.000 0.432 0.240 0.148
#> GSM414928 2 0.2966 0.8808 0.000 0.816 0.000 0.184 0.000
#> GSM414930 2 0.1197 0.8927 0.000 0.952 0.000 0.048 0.000
#> GSM414932 3 0.0000 0.7670 0.000 0.000 1.000 0.000 0.000
#> GSM414934 3 0.1041 0.7553 0.000 0.000 0.964 0.032 0.004
#> GSM414938 1 0.5164 0.3257 0.660 0.000 0.000 0.256 0.084
#> GSM414940 3 0.0404 0.7629 0.000 0.000 0.988 0.012 0.000
#> GSM414942 2 0.0000 0.8877 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.2773 0.8865 0.000 0.836 0.000 0.164 0.000
#> GSM414953 3 0.1041 0.7553 0.000 0.000 0.964 0.032 0.004
#> GSM414955 3 0.0162 0.7668 0.000 0.000 0.996 0.004 0.000
#> GSM414957 2 0.2852 0.8847 0.000 0.828 0.000 0.172 0.000
#> GSM414963 3 0.0000 0.7670 0.000 0.000 1.000 0.000 0.000
#> GSM414966 2 0.0000 0.8877 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0000 0.7670 0.000 0.000 1.000 0.000 0.000
#> GSM414972 2 0.0000 0.8877 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.8877 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.1268 0.5551 0.952 0.000 0.000 0.008 0.036 0.004
#> GSM414925 1 0.2622 0.5519 0.868 0.000 0.000 0.024 0.104 0.004
#> GSM414926 1 0.1268 0.5551 0.952 0.000 0.000 0.008 0.036 0.004
#> GSM414927 2 0.3782 0.8389 0.008 0.788 0.000 0.140 0.000 0.064
#> GSM414929 1 0.5158 0.4290 0.676 0.000 0.000 0.072 0.048 0.204
#> GSM414931 1 0.5643 0.2175 0.476 0.000 0.000 0.000 0.156 0.368
#> GSM414933 1 0.4808 0.3226 0.576 0.000 0.000 0.000 0.064 0.360
#> GSM414935 3 0.6103 0.0941 0.016 0.000 0.420 0.400 0.164 0.000
#> GSM414936 5 0.0891 0.7912 0.024 0.000 0.000 0.000 0.968 0.008
#> GSM414937 5 0.1984 0.7891 0.032 0.000 0.000 0.056 0.912 0.000
#> GSM414939 5 0.1320 0.8002 0.036 0.000 0.000 0.016 0.948 0.000
#> GSM414941 1 0.5610 0.1301 0.516 0.000 0.000 0.168 0.316 0.000
#> GSM414943 5 0.0891 0.7912 0.024 0.000 0.000 0.000 0.968 0.008
#> GSM414944 6 0.5220 0.7320 0.052 0.000 0.000 0.048 0.260 0.640
#> GSM414945 2 0.6161 0.5282 0.016 0.480 0.000 0.300 0.000 0.204
#> GSM414946 1 0.3096 0.5410 0.840 0.000 0.000 0.048 0.108 0.004
#> GSM414948 1 0.5457 0.2921 0.512 0.000 0.000 0.000 0.132 0.356
#> GSM414949 3 0.4371 0.2923 0.000 0.000 0.580 0.396 0.020 0.004
#> GSM414950 3 0.6133 0.0947 0.012 0.000 0.420 0.404 0.160 0.004
#> GSM414951 5 0.2537 0.7694 0.032 0.000 0.000 0.096 0.872 0.000
#> GSM414952 3 0.3122 0.5475 0.000 0.000 0.804 0.176 0.020 0.000
#> GSM414954 5 0.3313 0.7207 0.036 0.000 0.004 0.148 0.812 0.000
#> GSM414956 5 0.0551 0.7963 0.004 0.000 0.000 0.008 0.984 0.004
#> GSM414958 1 0.5011 0.4168 0.620 0.000 0.000 0.000 0.116 0.264
#> GSM414959 5 0.2252 0.7513 0.072 0.000 0.000 0.012 0.900 0.016
#> GSM414960 1 0.5134 0.2634 0.524 0.000 0.000 0.000 0.088 0.388
#> GSM414961 3 0.6103 0.0941 0.016 0.000 0.420 0.400 0.164 0.000
#> GSM414962 4 0.5929 0.6581 0.196 0.004 0.112 0.628 0.004 0.056
#> GSM414964 5 0.4294 0.5572 0.060 0.000 0.000 0.248 0.692 0.000
#> GSM414965 5 0.1245 0.7781 0.032 0.000 0.000 0.000 0.952 0.016
#> GSM414967 6 0.5578 0.6887 0.184 0.000 0.000 0.048 0.124 0.644
#> GSM414968 3 0.5470 0.2183 0.016 0.000 0.504 0.400 0.080 0.000
#> GSM414969 1 0.4561 0.2386 0.692 0.000 0.000 0.240 0.052 0.016
#> GSM414971 5 0.5478 -0.3231 0.136 0.000 0.000 0.000 0.512 0.352
#> GSM414973 1 0.3852 0.4797 0.732 0.000 0.000 0.016 0.240 0.012
#> GSM414974 4 0.6641 0.5993 0.204 0.000 0.196 0.536 0.048 0.016
#> GSM414928 2 0.3782 0.8389 0.008 0.788 0.000 0.140 0.000 0.064
#> GSM414930 2 0.0713 0.8561 0.000 0.972 0.000 0.028 0.000 0.000
#> GSM414932 3 0.0260 0.6514 0.000 0.000 0.992 0.008 0.000 0.000
#> GSM414934 3 0.1950 0.6182 0.000 0.000 0.912 0.024 0.000 0.064
#> GSM414938 1 0.6604 0.0948 0.432 0.000 0.000 0.348 0.052 0.168
#> GSM414940 3 0.0717 0.6449 0.000 0.000 0.976 0.016 0.000 0.008
#> GSM414942 2 0.0632 0.8521 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM414947 2 0.3587 0.8442 0.008 0.804 0.000 0.132 0.000 0.056
#> GSM414953 3 0.1950 0.6182 0.000 0.000 0.912 0.024 0.000 0.064
#> GSM414955 3 0.0146 0.6518 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414957 2 0.3627 0.8431 0.008 0.800 0.000 0.136 0.000 0.056
#> GSM414963 3 0.0146 0.6513 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414966 2 0.0632 0.8521 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM414970 3 0.0146 0.6513 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414972 2 0.0632 0.8521 0.000 0.976 0.000 0.000 0.000 0.024
#> GSM414975 2 0.0632 0.8521 0.000 0.976 0.000 0.000 0.000 0.024
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> MAD:kmeans 52 7.46e-04 2
#> MAD:kmeans 51 1.10e-05 3
#> MAD:kmeans 48 1.12e-04 4
#> MAD:kmeans 44 5.13e-05 5
#> MAD:kmeans 36 9.68e-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", "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 51882 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 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.946 0.979 0.4997 0.497 0.497
#> 3 3 1.000 0.963 0.987 0.2818 0.796 0.614
#> 4 4 0.871 0.927 0.939 0.1840 0.846 0.587
#> 5 5 0.802 0.779 0.814 0.0542 0.980 0.921
#> 6 6 0.811 0.735 0.816 0.0298 0.952 0.803
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.000 0.993 1.000 0.000
#> GSM414925 1 0.000 0.993 1.000 0.000
#> GSM414926 1 0.000 0.993 1.000 0.000
#> GSM414927 2 0.000 0.960 0.000 1.000
#> GSM414929 1 0.000 0.993 1.000 0.000
#> GSM414931 1 0.000 0.993 1.000 0.000
#> GSM414933 1 0.000 0.993 1.000 0.000
#> GSM414935 1 0.000 0.993 1.000 0.000
#> GSM414936 1 0.000 0.993 1.000 0.000
#> GSM414937 1 0.000 0.993 1.000 0.000
#> GSM414939 1 0.000 0.993 1.000 0.000
#> GSM414941 1 0.000 0.993 1.000 0.000
#> GSM414943 1 0.000 0.993 1.000 0.000
#> GSM414944 1 0.000 0.993 1.000 0.000
#> GSM414945 2 0.000 0.960 0.000 1.000
#> GSM414946 1 0.000 0.993 1.000 0.000
#> GSM414948 1 0.000 0.993 1.000 0.000
#> GSM414949 2 0.000 0.960 0.000 1.000
#> GSM414950 1 0.714 0.741 0.804 0.196
#> GSM414951 1 0.000 0.993 1.000 0.000
#> GSM414952 2 0.163 0.939 0.024 0.976
#> GSM414954 1 0.000 0.993 1.000 0.000
#> GSM414956 1 0.000 0.993 1.000 0.000
#> GSM414958 1 0.000 0.993 1.000 0.000
#> GSM414959 1 0.000 0.993 1.000 0.000
#> GSM414960 1 0.000 0.993 1.000 0.000
#> GSM414961 1 0.000 0.993 1.000 0.000
#> GSM414962 2 0.000 0.960 0.000 1.000
#> GSM414964 1 0.000 0.993 1.000 0.000
#> GSM414965 1 0.000 0.993 1.000 0.000
#> GSM414967 1 0.000 0.993 1.000 0.000
#> GSM414968 2 0.999 0.102 0.484 0.516
#> GSM414969 1 0.000 0.993 1.000 0.000
#> GSM414971 1 0.000 0.993 1.000 0.000
#> GSM414973 1 0.000 0.993 1.000 0.000
#> GSM414974 2 0.000 0.960 0.000 1.000
#> GSM414928 2 0.000 0.960 0.000 1.000
#> GSM414930 2 0.000 0.960 0.000 1.000
#> GSM414932 2 0.000 0.960 0.000 1.000
#> GSM414934 2 0.000 0.960 0.000 1.000
#> GSM414938 2 0.946 0.444 0.364 0.636
#> GSM414940 2 0.000 0.960 0.000 1.000
#> GSM414942 2 0.000 0.960 0.000 1.000
#> GSM414947 2 0.000 0.960 0.000 1.000
#> GSM414953 2 0.000 0.960 0.000 1.000
#> GSM414955 2 0.000 0.960 0.000 1.000
#> GSM414957 2 0.000 0.960 0.000 1.000
#> GSM414963 2 0.000 0.960 0.000 1.000
#> GSM414966 2 0.000 0.960 0.000 1.000
#> GSM414970 2 0.000 0.960 0.000 1.000
#> GSM414972 2 0.000 0.960 0.000 1.000
#> GSM414975 2 0.000 0.960 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414925 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414926 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414927 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414929 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414931 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414933 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414935 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414936 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414937 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414939 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414941 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414943 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414944 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414945 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414946 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414948 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414949 3 0.0592 0.945 0.000 0.012 0.988
#> GSM414950 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414951 3 0.6274 0.161 0.456 0.000 0.544
#> GSM414952 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414954 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414956 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414958 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414959 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414960 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414961 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414962 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414964 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414965 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414967 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414968 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414969 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414971 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414973 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414974 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414928 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414938 2 0.4452 0.745 0.192 0.808 0.000
#> GSM414940 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414955 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414957 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414966 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.956 0.000 0.000 1.000
#> GSM414972 2 0.0000 0.980 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.980 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM414925 1 0.0336 0.900 0.992 0.000 0.000 0.008
#> GSM414926 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM414927 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414929 1 0.2011 0.898 0.920 0.000 0.000 0.080
#> GSM414931 1 0.2345 0.890 0.900 0.000 0.000 0.100
#> GSM414933 1 0.1389 0.903 0.952 0.000 0.000 0.048
#> GSM414935 3 0.2011 0.945 0.000 0.000 0.920 0.080
#> GSM414936 4 0.2011 0.943 0.080 0.000 0.000 0.920
#> GSM414937 4 0.1211 0.925 0.040 0.000 0.000 0.960
#> GSM414939 4 0.2011 0.943 0.080 0.000 0.000 0.920
#> GSM414941 1 0.3311 0.786 0.828 0.000 0.000 0.172
#> GSM414943 4 0.2011 0.943 0.080 0.000 0.000 0.920
#> GSM414944 4 0.3569 0.827 0.196 0.000 0.000 0.804
#> GSM414945 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414946 1 0.0469 0.900 0.988 0.000 0.000 0.012
#> GSM414948 1 0.2345 0.892 0.900 0.000 0.000 0.100
#> GSM414949 3 0.2408 0.894 0.000 0.104 0.896 0.000
#> GSM414950 3 0.2011 0.945 0.000 0.000 0.920 0.080
#> GSM414951 4 0.1211 0.925 0.040 0.000 0.000 0.960
#> GSM414952 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414954 4 0.1637 0.856 0.060 0.000 0.000 0.940
#> GSM414956 4 0.2011 0.943 0.080 0.000 0.000 0.920
#> GSM414958 1 0.2011 0.898 0.920 0.000 0.000 0.080
#> GSM414959 4 0.2530 0.922 0.112 0.000 0.000 0.888
#> GSM414960 1 0.2081 0.897 0.916 0.000 0.000 0.084
#> GSM414961 3 0.2011 0.945 0.000 0.000 0.920 0.080
#> GSM414962 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414964 4 0.2589 0.815 0.116 0.000 0.000 0.884
#> GSM414965 4 0.2011 0.943 0.080 0.000 0.000 0.920
#> GSM414967 1 0.2704 0.867 0.876 0.000 0.000 0.124
#> GSM414968 3 0.2011 0.945 0.000 0.000 0.920 0.080
#> GSM414969 1 0.2011 0.840 0.920 0.000 0.000 0.080
#> GSM414971 4 0.2081 0.941 0.084 0.000 0.000 0.916
#> GSM414973 1 0.0707 0.898 0.980 0.000 0.000 0.020
#> GSM414974 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414928 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414932 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414934 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414938 1 0.6621 0.500 0.588 0.316 0.004 0.092
#> GSM414940 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414953 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414955 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414963 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3966 0.656 0.664 0.000 0.000 NA 0.000
#> GSM414925 1 0.4270 0.656 0.668 0.000 0.000 NA 0.012
#> GSM414926 1 0.3999 0.654 0.656 0.000 0.000 NA 0.000
#> GSM414927 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414929 1 0.5191 0.601 0.660 0.000 0.000 NA 0.088
#> GSM414931 1 0.3203 0.622 0.820 0.000 0.000 NA 0.168
#> GSM414933 1 0.1579 0.673 0.944 0.000 0.000 NA 0.032
#> GSM414935 3 0.4088 0.780 0.000 0.000 0.688 NA 0.008
#> GSM414936 5 0.0000 0.843 0.000 0.000 0.000 NA 1.000
#> GSM414937 5 0.2280 0.814 0.000 0.000 0.000 NA 0.880
#> GSM414939 5 0.0162 0.843 0.000 0.000 0.000 NA 0.996
#> GSM414941 1 0.6133 0.453 0.436 0.000 0.000 NA 0.128
#> GSM414943 5 0.0000 0.843 0.000 0.000 0.000 NA 1.000
#> GSM414944 1 0.6434 0.111 0.432 0.000 0.000 NA 0.392
#> GSM414945 2 0.0290 0.990 0.000 0.992 0.000 NA 0.000
#> GSM414946 1 0.4356 0.652 0.648 0.000 0.000 NA 0.012
#> GSM414948 1 0.3194 0.641 0.832 0.000 0.000 NA 0.148
#> GSM414949 3 0.3719 0.809 0.000 0.116 0.816 NA 0.000
#> GSM414950 3 0.4088 0.780 0.000 0.000 0.688 NA 0.008
#> GSM414951 5 0.2719 0.805 0.000 0.000 0.004 NA 0.852
#> GSM414952 3 0.0290 0.892 0.000 0.000 0.992 NA 0.000
#> GSM414954 5 0.4026 0.726 0.020 0.000 0.000 NA 0.736
#> GSM414956 5 0.0000 0.843 0.000 0.000 0.000 NA 1.000
#> GSM414958 1 0.3365 0.654 0.836 0.000 0.000 NA 0.120
#> GSM414959 5 0.4194 0.679 0.088 0.000 0.000 NA 0.780
#> GSM414960 1 0.3828 0.629 0.808 0.000 0.000 NA 0.120
#> GSM414961 3 0.4213 0.775 0.000 0.000 0.680 NA 0.012
#> GSM414962 2 0.0162 0.992 0.000 0.996 0.000 NA 0.000
#> GSM414964 5 0.4527 0.691 0.036 0.000 0.000 NA 0.692
#> GSM414965 5 0.0510 0.835 0.016 0.000 0.000 NA 0.984
#> GSM414967 1 0.5714 0.488 0.624 0.000 0.000 NA 0.212
#> GSM414968 3 0.3969 0.783 0.000 0.000 0.692 NA 0.004
#> GSM414969 1 0.4300 0.593 0.524 0.000 0.000 NA 0.000
#> GSM414971 5 0.4232 0.430 0.312 0.000 0.000 NA 0.676
#> GSM414973 1 0.5329 0.627 0.596 0.000 0.000 NA 0.068
#> GSM414974 2 0.1341 0.952 0.000 0.944 0.000 NA 0.000
#> GSM414928 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414930 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414932 3 0.0000 0.893 0.000 0.000 1.000 NA 0.000
#> GSM414934 3 0.0000 0.893 0.000 0.000 1.000 NA 0.000
#> GSM414938 1 0.7458 0.473 0.464 0.084 0.008 NA 0.100
#> GSM414940 3 0.0000 0.893 0.000 0.000 1.000 NA 0.000
#> GSM414942 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414947 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414953 3 0.0000 0.893 0.000 0.000 1.000 NA 0.000
#> GSM414955 3 0.0162 0.892 0.000 0.000 0.996 NA 0.000
#> GSM414957 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414963 3 0.0000 0.893 0.000 0.000 1.000 NA 0.000
#> GSM414966 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414970 3 0.0000 0.893 0.000 0.000 1.000 NA 0.000
#> GSM414972 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
#> GSM414975 2 0.0000 0.995 0.000 1.000 0.000 NA 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.1225 0.7396 0.952 0.000 0.000 NA 0.000 0.036
#> GSM414925 1 0.1398 0.7404 0.940 0.000 0.000 NA 0.000 0.052
#> GSM414926 1 0.1168 0.7436 0.956 0.000 0.000 NA 0.000 0.028
#> GSM414927 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414929 6 0.6166 0.4884 0.264 0.000 0.000 NA 0.032 0.528
#> GSM414931 6 0.5467 0.6357 0.332 0.000 0.000 NA 0.112 0.548
#> GSM414933 6 0.4627 0.5147 0.456 0.000 0.000 NA 0.024 0.512
#> GSM414935 3 0.4446 0.6482 0.004 0.000 0.520 NA 0.008 0.008
#> GSM414936 5 0.0777 0.7833 0.000 0.000 0.000 NA 0.972 0.024
#> GSM414937 5 0.1387 0.7753 0.000 0.000 0.000 NA 0.932 0.000
#> GSM414939 5 0.0146 0.7877 0.000 0.000 0.000 NA 0.996 0.004
#> GSM414941 1 0.5732 0.5677 0.620 0.000 0.000 NA 0.136 0.044
#> GSM414943 5 0.0363 0.7866 0.000 0.000 0.000 NA 0.988 0.012
#> GSM414944 6 0.5270 0.4653 0.060 0.000 0.000 NA 0.260 0.636
#> GSM414945 2 0.0935 0.9523 0.000 0.964 0.000 NA 0.000 0.032
#> GSM414946 1 0.1297 0.7507 0.948 0.000 0.000 NA 0.000 0.040
#> GSM414948 6 0.5491 0.5974 0.372 0.000 0.000 NA 0.116 0.508
#> GSM414949 3 0.4781 0.7406 0.000 0.064 0.724 NA 0.000 0.052
#> GSM414950 3 0.4916 0.6727 0.000 0.000 0.548 NA 0.008 0.048
#> GSM414951 5 0.3534 0.7057 0.000 0.000 0.004 NA 0.772 0.024
#> GSM414952 3 0.1556 0.8182 0.000 0.000 0.920 NA 0.000 0.000
#> GSM414954 5 0.4352 0.6243 0.020 0.000 0.000 NA 0.644 0.012
#> GSM414956 5 0.0508 0.7879 0.000 0.000 0.000 NA 0.984 0.012
#> GSM414958 6 0.5442 0.6155 0.364 0.000 0.000 NA 0.064 0.544
#> GSM414959 5 0.5701 0.5257 0.068 0.000 0.000 NA 0.644 0.164
#> GSM414960 6 0.4787 0.6501 0.312 0.000 0.000 NA 0.064 0.620
#> GSM414961 3 0.4263 0.6355 0.000 0.000 0.504 NA 0.016 0.000
#> GSM414962 2 0.1391 0.9414 0.000 0.944 0.000 NA 0.000 0.040
#> GSM414964 5 0.4869 0.5664 0.044 0.000 0.000 NA 0.584 0.012
#> GSM414965 5 0.1225 0.7759 0.000 0.000 0.000 NA 0.952 0.036
#> GSM414967 6 0.5337 0.5898 0.148 0.000 0.000 NA 0.128 0.676
#> GSM414968 3 0.4452 0.6639 0.000 0.000 0.548 NA 0.008 0.016
#> GSM414969 1 0.4198 0.6412 0.708 0.000 0.000 NA 0.000 0.060
#> GSM414971 5 0.4756 -0.0569 0.052 0.000 0.000 NA 0.540 0.408
#> GSM414973 1 0.5689 0.5837 0.652 0.000 0.000 NA 0.080 0.128
#> GSM414974 2 0.3782 0.7944 0.000 0.780 0.000 NA 0.000 0.096
#> GSM414928 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414930 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414932 3 0.0000 0.8373 0.000 0.000 1.000 NA 0.000 0.000
#> GSM414934 3 0.0000 0.8373 0.000 0.000 1.000 NA 0.000 0.000
#> GSM414938 6 0.6624 0.3103 0.084 0.048 0.004 NA 0.036 0.540
#> GSM414940 3 0.0000 0.8373 0.000 0.000 1.000 NA 0.000 0.000
#> GSM414942 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414947 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414953 3 0.0000 0.8373 0.000 0.000 1.000 NA 0.000 0.000
#> GSM414955 3 0.0260 0.8355 0.000 0.000 0.992 NA 0.000 0.000
#> GSM414957 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414963 3 0.0000 0.8373 0.000 0.000 1.000 NA 0.000 0.000
#> GSM414966 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414970 3 0.0000 0.8373 0.000 0.000 1.000 NA 0.000 0.000
#> GSM414972 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
#> GSM414975 2 0.0000 0.9756 0.000 1.000 0.000 NA 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> MAD:skmeans 50 2.94e-07 2
#> MAD:skmeans 51 9.48e-06 3
#> MAD:skmeans 52 1.75e-04 4
#> MAD:skmeans 47 1.82e-04 5
#> MAD:skmeans 48 3.89e-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["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 51882 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 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.919 0.927 0.970 0.3650 0.660 0.660
#> 3 3 0.622 0.764 0.881 0.6993 0.667 0.508
#> 4 4 0.730 0.792 0.846 0.1957 0.772 0.457
#> 5 5 0.686 0.755 0.855 0.0534 0.957 0.833
#> 6 6 0.755 0.662 0.826 0.0579 0.901 0.597
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
#> GSM414924 1 0.000 0.964 1.000 0.000
#> GSM414925 1 0.000 0.964 1.000 0.000
#> GSM414926 1 0.000 0.964 1.000 0.000
#> GSM414927 2 0.000 0.984 0.000 1.000
#> GSM414929 1 0.000 0.964 1.000 0.000
#> GSM414931 1 0.000 0.964 1.000 0.000
#> GSM414933 1 0.000 0.964 1.000 0.000
#> GSM414935 1 0.000 0.964 1.000 0.000
#> GSM414936 1 0.000 0.964 1.000 0.000
#> GSM414937 1 0.000 0.964 1.000 0.000
#> GSM414939 1 0.000 0.964 1.000 0.000
#> GSM414941 1 0.000 0.964 1.000 0.000
#> GSM414943 1 0.000 0.964 1.000 0.000
#> GSM414944 1 0.000 0.964 1.000 0.000
#> GSM414945 2 0.000 0.984 0.000 1.000
#> GSM414946 1 0.000 0.964 1.000 0.000
#> GSM414948 1 0.000 0.964 1.000 0.000
#> GSM414949 1 0.722 0.752 0.800 0.200
#> GSM414950 1 0.000 0.964 1.000 0.000
#> GSM414951 1 0.000 0.964 1.000 0.000
#> GSM414952 1 0.000 0.964 1.000 0.000
#> GSM414954 1 0.000 0.964 1.000 0.000
#> GSM414956 1 0.000 0.964 1.000 0.000
#> GSM414958 1 0.000 0.964 1.000 0.000
#> GSM414959 1 0.000 0.964 1.000 0.000
#> GSM414960 1 0.000 0.964 1.000 0.000
#> GSM414961 1 0.000 0.964 1.000 0.000
#> GSM414962 2 0.605 0.812 0.148 0.852
#> GSM414964 1 0.000 0.964 1.000 0.000
#> GSM414965 1 0.000 0.964 1.000 0.000
#> GSM414967 1 0.000 0.964 1.000 0.000
#> GSM414968 1 0.000 0.964 1.000 0.000
#> GSM414969 1 0.000 0.964 1.000 0.000
#> GSM414971 1 0.000 0.964 1.000 0.000
#> GSM414973 1 0.000 0.964 1.000 0.000
#> GSM414974 1 0.373 0.901 0.928 0.072
#> GSM414928 2 0.000 0.984 0.000 1.000
#> GSM414930 2 0.000 0.984 0.000 1.000
#> GSM414932 1 0.311 0.916 0.944 0.056
#> GSM414934 1 0.000 0.964 1.000 0.000
#> GSM414938 1 0.000 0.964 1.000 0.000
#> GSM414940 1 0.697 0.768 0.812 0.188
#> GSM414942 2 0.000 0.984 0.000 1.000
#> GSM414947 2 0.000 0.984 0.000 1.000
#> GSM414953 1 0.000 0.964 1.000 0.000
#> GSM414955 1 0.000 0.964 1.000 0.000
#> GSM414957 2 0.000 0.984 0.000 1.000
#> GSM414963 1 0.991 0.242 0.556 0.444
#> GSM414966 2 0.000 0.984 0.000 1.000
#> GSM414970 1 0.991 0.242 0.556 0.444
#> GSM414972 2 0.000 0.984 0.000 1.000
#> GSM414975 2 0.000 0.984 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414927 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414929 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414935 3 0.5397 0.7144 0.280 0.000 0.720
#> GSM414936 1 0.3619 0.7388 0.864 0.000 0.136
#> GSM414937 3 0.6126 0.5841 0.400 0.000 0.600
#> GSM414939 3 0.6126 0.5841 0.400 0.000 0.600
#> GSM414941 1 0.5948 0.1450 0.640 0.000 0.360
#> GSM414943 3 0.6291 0.4436 0.468 0.000 0.532
#> GSM414944 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414945 2 0.0592 0.9893 0.000 0.988 0.012
#> GSM414946 3 0.6308 0.3774 0.492 0.000 0.508
#> GSM414948 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414949 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414950 3 0.5254 0.7203 0.264 0.000 0.736
#> GSM414951 3 0.5760 0.6813 0.328 0.000 0.672
#> GSM414952 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414954 3 0.4702 0.7410 0.212 0.000 0.788
#> GSM414956 3 0.5733 0.6847 0.324 0.000 0.676
#> GSM414958 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414959 3 0.6079 0.6070 0.388 0.000 0.612
#> GSM414960 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414961 3 0.4654 0.7417 0.208 0.000 0.792
#> GSM414962 3 0.6460 -0.0567 0.004 0.440 0.556
#> GSM414964 3 0.5760 0.6813 0.328 0.000 0.672
#> GSM414965 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414967 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414968 3 0.4702 0.7410 0.212 0.000 0.788
#> GSM414969 1 0.6280 -0.2741 0.540 0.000 0.460
#> GSM414971 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414973 1 0.0000 0.9168 1.000 0.000 0.000
#> GSM414974 3 0.3752 0.7413 0.144 0.000 0.856
#> GSM414928 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414938 3 0.5760 0.6813 0.328 0.000 0.672
#> GSM414940 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414955 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414957 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414966 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.7364 0.000 0.000 1.000
#> GSM414972 2 0.0000 0.9988 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.9988 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 4 0.0592 0.844 0.016 0.000 0.000 0.984
#> GSM414925 4 0.2760 0.779 0.128 0.000 0.000 0.872
#> GSM414926 4 0.1637 0.835 0.060 0.000 0.000 0.940
#> GSM414927 2 0.0000 0.940 0.000 1.000 0.000 0.000
#> GSM414929 4 0.0469 0.845 0.012 0.000 0.000 0.988
#> GSM414931 4 0.3123 0.811 0.156 0.000 0.000 0.844
#> GSM414933 4 0.0336 0.844 0.008 0.000 0.000 0.992
#> GSM414935 1 0.2773 0.831 0.900 0.000 0.028 0.072
#> GSM414936 1 0.0707 0.841 0.980 0.000 0.000 0.020
#> GSM414937 1 0.0000 0.848 1.000 0.000 0.000 0.000
#> GSM414939 1 0.0000 0.848 1.000 0.000 0.000 0.000
#> GSM414941 1 0.2760 0.809 0.872 0.000 0.000 0.128
#> GSM414943 1 0.0336 0.846 0.992 0.000 0.000 0.008
#> GSM414944 1 0.4331 0.459 0.712 0.000 0.000 0.288
#> GSM414945 2 0.0469 0.934 0.000 0.988 0.012 0.000
#> GSM414946 1 0.4972 0.289 0.544 0.000 0.000 0.456
#> GSM414948 4 0.4072 0.739 0.252 0.000 0.000 0.748
#> GSM414949 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414950 1 0.0524 0.845 0.988 0.000 0.008 0.004
#> GSM414951 1 0.0000 0.848 1.000 0.000 0.000 0.000
#> GSM414952 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414954 1 0.4857 0.446 0.668 0.000 0.324 0.008
#> GSM414956 1 0.0336 0.846 0.992 0.000 0.000 0.008
#> GSM414958 4 0.3024 0.822 0.148 0.000 0.000 0.852
#> GSM414959 1 0.2281 0.823 0.904 0.000 0.000 0.096
#> GSM414960 4 0.0469 0.845 0.012 0.000 0.000 0.988
#> GSM414961 3 0.4961 0.218 0.448 0.000 0.552 0.000
#> GSM414962 2 0.4877 0.345 0.000 0.592 0.408 0.000
#> GSM414964 1 0.2408 0.821 0.896 0.000 0.000 0.104
#> GSM414965 1 0.1557 0.816 0.944 0.000 0.000 0.056
#> GSM414967 4 0.2281 0.844 0.096 0.000 0.000 0.904
#> GSM414968 1 0.1824 0.821 0.936 0.000 0.060 0.004
#> GSM414969 1 0.4250 0.678 0.724 0.000 0.000 0.276
#> GSM414971 4 0.4072 0.739 0.252 0.000 0.000 0.748
#> GSM414973 4 0.4955 0.285 0.444 0.000 0.000 0.556
#> GSM414974 3 0.6567 0.426 0.308 0.000 0.588 0.104
#> GSM414928 2 0.0000 0.940 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 0.940 0.000 1.000 0.000 0.000
#> GSM414932 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414934 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414938 1 0.4008 0.706 0.756 0.000 0.000 0.244
#> GSM414940 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414942 2 0.1722 0.932 0.000 0.944 0.048 0.008
#> GSM414947 2 0.0000 0.940 0.000 1.000 0.000 0.000
#> GSM414953 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414955 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414957 2 0.0000 0.940 0.000 1.000 0.000 0.000
#> GSM414963 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414966 2 0.1722 0.932 0.000 0.944 0.048 0.008
#> GSM414970 3 0.1389 0.909 0.048 0.000 0.952 0.000
#> GSM414972 2 0.1722 0.932 0.000 0.944 0.048 0.008
#> GSM414975 2 0.1722 0.932 0.000 0.944 0.048 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.0000 0.782 1.000 0.000 0.000 0.000 0.000
#> GSM414925 1 0.3282 0.664 0.804 0.000 0.000 0.188 0.008
#> GSM414926 1 0.1270 0.777 0.948 0.000 0.000 0.000 0.052
#> GSM414927 2 0.0000 0.925 0.000 1.000 0.000 0.000 0.000
#> GSM414929 1 0.0000 0.782 1.000 0.000 0.000 0.000 0.000
#> GSM414931 1 0.2813 0.747 0.832 0.000 0.000 0.000 0.168
#> GSM414933 1 0.0000 0.782 1.000 0.000 0.000 0.000 0.000
#> GSM414935 5 0.5751 0.657 0.068 0.000 0.036 0.244 0.652
#> GSM414936 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414937 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414939 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414941 5 0.2127 0.745 0.108 0.000 0.000 0.000 0.892
#> GSM414943 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414944 5 0.3508 0.548 0.252 0.000 0.000 0.000 0.748
#> GSM414945 2 0.0404 0.914 0.000 0.988 0.012 0.000 0.000
#> GSM414946 1 0.6339 0.115 0.508 0.000 0.000 0.188 0.304
#> GSM414948 1 0.3636 0.666 0.728 0.000 0.000 0.000 0.272
#> GSM414949 3 0.3395 0.766 0.000 0.000 0.764 0.236 0.000
#> GSM414950 5 0.3452 0.698 0.000 0.000 0.000 0.244 0.756
#> GSM414951 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414952 3 0.3003 0.798 0.000 0.000 0.812 0.188 0.000
#> GSM414954 5 0.5113 0.270 0.000 0.000 0.380 0.044 0.576
#> GSM414956 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414958 1 0.2732 0.759 0.840 0.000 0.000 0.000 0.160
#> GSM414959 5 0.2127 0.745 0.108 0.000 0.000 0.000 0.892
#> GSM414960 1 0.0000 0.782 1.000 0.000 0.000 0.000 0.000
#> GSM414961 3 0.5334 0.669 0.000 0.000 0.652 0.244 0.104
#> GSM414962 2 0.4042 0.608 0.000 0.756 0.032 0.212 0.000
#> GSM414964 5 0.5195 0.666 0.108 0.000 0.000 0.216 0.676
#> GSM414965 5 0.0000 0.792 0.000 0.000 0.000 0.000 1.000
#> GSM414967 1 0.2127 0.785 0.892 0.000 0.000 0.000 0.108
#> GSM414968 5 0.4793 0.677 0.000 0.000 0.076 0.216 0.708
#> GSM414969 5 0.6532 0.439 0.280 0.000 0.000 0.240 0.480
#> GSM414971 1 0.3661 0.662 0.724 0.000 0.000 0.000 0.276
#> GSM414973 1 0.4268 0.363 0.556 0.000 0.000 0.000 0.444
#> GSM414974 3 0.6884 0.573 0.108 0.000 0.568 0.244 0.080
#> GSM414928 2 0.0000 0.925 0.000 1.000 0.000 0.000 0.000
#> GSM414930 2 0.0404 0.914 0.000 0.988 0.000 0.012 0.000
#> GSM414932 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> GSM414934 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> GSM414938 5 0.3957 0.588 0.280 0.000 0.000 0.008 0.712
#> GSM414940 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> GSM414942 4 0.3452 1.000 0.000 0.244 0.000 0.756 0.000
#> GSM414947 2 0.0000 0.925 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.0880 0.860 0.000 0.000 0.968 0.032 0.000
#> GSM414957 2 0.0000 0.925 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> GSM414966 4 0.3452 1.000 0.000 0.244 0.000 0.756 0.000
#> GSM414970 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> GSM414972 4 0.3452 1.000 0.000 0.244 0.000 0.756 0.000
#> GSM414975 4 0.3452 1.000 0.000 0.244 0.000 0.756 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 6 0.1714 0.8463 0.092 0.000 0.000 0.000 0.000 0.908
#> GSM414925 1 0.3323 0.5747 0.752 0.000 0.000 0.000 0.008 0.240
#> GSM414926 1 0.4712 0.4031 0.564 0.000 0.000 0.000 0.052 0.384
#> GSM414927 2 0.2793 0.9345 0.000 0.800 0.000 0.200 0.000 0.000
#> GSM414929 1 0.3833 0.3143 0.556 0.000 0.000 0.000 0.000 0.444
#> GSM414931 6 0.1411 0.9244 0.004 0.000 0.000 0.000 0.060 0.936
#> GSM414933 6 0.1663 0.8471 0.088 0.000 0.000 0.000 0.000 0.912
#> GSM414935 1 0.3881 -0.0763 0.600 0.000 0.004 0.000 0.396 0.000
#> GSM414936 5 0.0000 0.6930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414937 5 0.0000 0.6930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414939 5 0.0000 0.6930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414941 5 0.3862 -0.2057 0.476 0.000 0.000 0.000 0.524 0.000
#> GSM414943 5 0.0000 0.6930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414944 5 0.3151 0.4560 0.000 0.000 0.000 0.000 0.748 0.252
#> GSM414945 2 0.3046 0.9256 0.000 0.800 0.012 0.188 0.000 0.000
#> GSM414946 1 0.3835 0.5598 0.756 0.000 0.000 0.000 0.188 0.056
#> GSM414948 6 0.1267 0.9256 0.000 0.000 0.000 0.000 0.060 0.940
#> GSM414949 3 0.3782 0.6187 0.412 0.000 0.588 0.000 0.000 0.000
#> GSM414950 5 0.3797 0.3118 0.420 0.000 0.000 0.000 0.580 0.000
#> GSM414951 5 0.0790 0.6756 0.032 0.000 0.000 0.000 0.968 0.000
#> GSM414952 3 0.3515 0.6903 0.324 0.000 0.676 0.000 0.000 0.000
#> GSM414954 5 0.5783 -0.0664 0.180 0.000 0.372 0.000 0.448 0.000
#> GSM414956 5 0.0000 0.6930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414958 6 0.1141 0.9252 0.000 0.000 0.000 0.000 0.052 0.948
#> GSM414959 5 0.3862 -0.2057 0.476 0.000 0.000 0.000 0.524 0.000
#> GSM414960 6 0.0146 0.8997 0.004 0.000 0.000 0.000 0.000 0.996
#> GSM414961 3 0.4116 0.6016 0.416 0.000 0.572 0.000 0.012 0.000
#> GSM414962 2 0.2854 0.6587 0.208 0.792 0.000 0.000 0.000 0.000
#> GSM414964 1 0.2597 0.5033 0.824 0.000 0.000 0.000 0.176 0.000
#> GSM414965 5 0.0000 0.6930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414967 6 0.1714 0.8947 0.000 0.000 0.000 0.000 0.092 0.908
#> GSM414968 5 0.3872 0.3464 0.392 0.000 0.004 0.000 0.604 0.000
#> GSM414969 1 0.1657 0.5825 0.928 0.000 0.000 0.000 0.016 0.056
#> GSM414971 6 0.1327 0.9235 0.000 0.000 0.000 0.000 0.064 0.936
#> GSM414973 1 0.5817 0.3876 0.476 0.000 0.000 0.000 0.320 0.204
#> GSM414974 1 0.2020 0.4943 0.896 0.000 0.096 0.000 0.008 0.000
#> GSM414928 2 0.2793 0.9345 0.000 0.800 0.000 0.200 0.000 0.000
#> GSM414930 2 0.2912 0.9211 0.000 0.784 0.000 0.216 0.000 0.000
#> GSM414932 3 0.0146 0.8038 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM414934 3 0.2933 0.7556 0.004 0.200 0.796 0.000 0.000 0.000
#> GSM414938 1 0.4856 0.3701 0.572 0.000 0.000 0.000 0.360 0.068
#> GSM414940 3 0.0000 0.8029 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414942 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM414947 2 0.2793 0.9345 0.000 0.800 0.000 0.200 0.000 0.000
#> GSM414953 3 0.2933 0.7556 0.004 0.200 0.796 0.000 0.000 0.000
#> GSM414955 3 0.2527 0.7672 0.168 0.000 0.832 0.000 0.000 0.000
#> GSM414957 2 0.2793 0.9345 0.000 0.800 0.000 0.200 0.000 0.000
#> GSM414963 3 0.0000 0.8029 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414966 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0146 0.8038 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM414972 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM414975 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> MAD:pam 50 7.77e-04 2
#> MAD:pam 47 1.84e-04 3
#> MAD:pam 45 5.46e-06 4
#> MAD:pam 48 5.97e-05 5
#> MAD:pam 40 2.45e-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["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 51882 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.880 0.890 0.955 0.3666 0.660 0.660
#> 3 3 0.832 0.943 0.969 0.7074 0.697 0.548
#> 4 4 0.823 0.833 0.867 0.0674 1.000 1.000
#> 5 5 0.685 0.813 0.855 0.0588 0.950 0.868
#> 6 6 0.636 0.604 0.708 0.0951 0.875 0.630
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
#> GSM414924 1 0.000 0.949 1.000 0.000
#> GSM414925 1 0.000 0.949 1.000 0.000
#> GSM414926 1 0.000 0.949 1.000 0.000
#> GSM414927 2 0.000 0.951 0.000 1.000
#> GSM414929 1 0.000 0.949 1.000 0.000
#> GSM414931 1 0.000 0.949 1.000 0.000
#> GSM414933 1 0.000 0.949 1.000 0.000
#> GSM414935 1 0.000 0.949 1.000 0.000
#> GSM414936 1 0.000 0.949 1.000 0.000
#> GSM414937 1 0.000 0.949 1.000 0.000
#> GSM414939 1 0.000 0.949 1.000 0.000
#> GSM414941 1 0.000 0.949 1.000 0.000
#> GSM414943 1 0.000 0.949 1.000 0.000
#> GSM414944 1 0.985 0.212 0.572 0.428
#> GSM414945 2 0.891 0.535 0.308 0.692
#> GSM414946 1 0.000 0.949 1.000 0.000
#> GSM414948 1 0.000 0.949 1.000 0.000
#> GSM414949 1 0.260 0.926 0.956 0.044
#> GSM414950 1 0.000 0.949 1.000 0.000
#> GSM414951 1 0.000 0.949 1.000 0.000
#> GSM414952 1 0.224 0.929 0.964 0.036
#> GSM414954 1 0.000 0.949 1.000 0.000
#> GSM414956 1 0.000 0.949 1.000 0.000
#> GSM414958 1 0.000 0.949 1.000 0.000
#> GSM414959 1 0.000 0.949 1.000 0.000
#> GSM414960 1 0.000 0.949 1.000 0.000
#> GSM414961 1 0.000 0.949 1.000 0.000
#> GSM414962 2 0.615 0.811 0.152 0.848
#> GSM414964 1 0.000 0.949 1.000 0.000
#> GSM414965 1 0.000 0.949 1.000 0.000
#> GSM414967 1 0.966 0.318 0.608 0.392
#> GSM414968 1 0.000 0.949 1.000 0.000
#> GSM414969 1 0.000 0.949 1.000 0.000
#> GSM414971 1 0.000 0.949 1.000 0.000
#> GSM414973 1 0.000 0.949 1.000 0.000
#> GSM414974 1 0.574 0.831 0.864 0.136
#> GSM414928 2 0.000 0.951 0.000 1.000
#> GSM414930 2 0.000 0.951 0.000 1.000
#> GSM414932 1 0.327 0.916 0.940 0.060
#> GSM414934 1 0.327 0.916 0.940 0.060
#> GSM414938 1 0.985 0.212 0.572 0.428
#> GSM414940 1 0.327 0.916 0.940 0.060
#> GSM414942 2 0.000 0.951 0.000 1.000
#> GSM414947 2 0.000 0.951 0.000 1.000
#> GSM414953 1 0.327 0.916 0.940 0.060
#> GSM414955 1 0.327 0.916 0.940 0.060
#> GSM414957 2 0.000 0.951 0.000 1.000
#> GSM414963 1 0.327 0.916 0.940 0.060
#> GSM414966 2 0.000 0.951 0.000 1.000
#> GSM414970 1 0.327 0.916 0.940 0.060
#> GSM414972 2 0.000 0.951 0.000 1.000
#> GSM414975 2 0.000 0.951 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.3340 0.890 0.880 0.000 0.120
#> GSM414925 1 0.3340 0.890 0.880 0.000 0.120
#> GSM414926 1 0.3340 0.890 0.880 0.000 0.120
#> GSM414927 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414929 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414935 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414936 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414937 1 0.0237 0.955 0.996 0.000 0.004
#> GSM414939 1 0.0237 0.955 0.996 0.000 0.004
#> GSM414941 1 0.3340 0.890 0.880 0.000 0.120
#> GSM414943 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414944 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414945 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414946 1 0.3340 0.890 0.880 0.000 0.120
#> GSM414948 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414949 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414950 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414951 1 0.0237 0.955 0.996 0.000 0.004
#> GSM414952 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414954 1 0.0237 0.955 0.996 0.000 0.004
#> GSM414956 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414958 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414959 1 0.0237 0.955 0.996 0.000 0.004
#> GSM414960 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414961 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414962 3 0.8423 0.505 0.156 0.228 0.616
#> GSM414964 1 0.3340 0.890 0.880 0.000 0.120
#> GSM414965 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414967 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414968 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414969 1 0.4346 0.820 0.816 0.000 0.184
#> GSM414971 1 0.0000 0.956 1.000 0.000 0.000
#> GSM414973 1 0.0237 0.955 0.996 0.000 0.004
#> GSM414974 3 0.3030 0.862 0.092 0.004 0.904
#> GSM414928 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414930 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414938 1 0.4346 0.799 0.816 0.184 0.000
#> GSM414940 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414955 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.965 0.000 0.000 1.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.2882 0.893 0.892 0.000 0.024 NA
#> GSM414925 1 0.0188 0.938 0.996 0.000 0.000 NA
#> GSM414926 1 0.2882 0.893 0.892 0.000 0.024 NA
#> GSM414927 2 0.0707 0.934 0.000 0.980 0.000 NA
#> GSM414929 1 0.0921 0.933 0.972 0.000 0.000 NA
#> GSM414931 1 0.1867 0.920 0.928 0.000 0.000 NA
#> GSM414933 1 0.2149 0.912 0.912 0.000 0.000 NA
#> GSM414935 3 0.1118 0.718 0.036 0.000 0.964 NA
#> GSM414936 1 0.0336 0.938 0.992 0.000 0.000 NA
#> GSM414937 1 0.1004 0.929 0.972 0.000 0.024 NA
#> GSM414939 1 0.0188 0.938 0.996 0.000 0.004 NA
#> GSM414941 1 0.0895 0.934 0.976 0.000 0.020 NA
#> GSM414943 1 0.0336 0.938 0.992 0.000 0.000 NA
#> GSM414944 1 0.2345 0.904 0.900 0.000 0.000 NA
#> GSM414945 2 0.2563 0.891 0.020 0.908 0.000 NA
#> GSM414946 1 0.0000 0.938 1.000 0.000 0.000 NA
#> GSM414948 1 0.0469 0.938 0.988 0.000 0.000 NA
#> GSM414949 3 0.1118 0.709 0.000 0.000 0.964 NA
#> GSM414950 3 0.1118 0.718 0.036 0.000 0.964 NA
#> GSM414951 1 0.1970 0.907 0.932 0.000 0.060 NA
#> GSM414952 3 0.0817 0.719 0.024 0.000 0.976 NA
#> GSM414954 1 0.1211 0.922 0.960 0.000 0.040 NA
#> GSM414956 1 0.0188 0.938 0.996 0.000 0.000 NA
#> GSM414958 1 0.0188 0.938 0.996 0.000 0.000 NA
#> GSM414959 1 0.0000 0.938 1.000 0.000 0.000 NA
#> GSM414960 1 0.2149 0.912 0.912 0.000 0.000 NA
#> GSM414961 3 0.1118 0.718 0.036 0.000 0.964 NA
#> GSM414962 3 0.8879 0.195 0.072 0.192 0.432 NA
#> GSM414964 1 0.4500 0.581 0.684 0.000 0.316 NA
#> GSM414965 1 0.0000 0.938 1.000 0.000 0.000 NA
#> GSM414967 1 0.2408 0.903 0.896 0.000 0.000 NA
#> GSM414968 3 0.1209 0.718 0.032 0.000 0.964 NA
#> GSM414969 1 0.5742 0.599 0.664 0.000 0.276 NA
#> GSM414971 1 0.0336 0.938 0.992 0.000 0.000 NA
#> GSM414973 1 0.0188 0.938 0.996 0.000 0.000 NA
#> GSM414974 3 0.8570 0.264 0.188 0.052 0.456 NA
#> GSM414928 2 0.0707 0.934 0.000 0.980 0.000 NA
#> GSM414930 2 0.0000 0.939 0.000 1.000 0.000 NA
#> GSM414932 3 0.5592 0.720 0.024 0.000 0.572 NA
#> GSM414934 3 0.5657 0.713 0.024 0.000 0.540 NA
#> GSM414938 1 0.4121 0.862 0.848 0.064 0.016 NA
#> GSM414940 3 0.4866 0.717 0.000 0.000 0.596 NA
#> GSM414942 2 0.2814 0.922 0.000 0.868 0.000 NA
#> GSM414947 2 0.0000 0.939 0.000 1.000 0.000 NA
#> GSM414953 3 0.5657 0.713 0.024 0.000 0.540 NA
#> GSM414955 3 0.5602 0.720 0.024 0.000 0.568 NA
#> GSM414957 2 0.0000 0.939 0.000 1.000 0.000 NA
#> GSM414963 3 0.4916 0.712 0.000 0.000 0.576 NA
#> GSM414966 2 0.2814 0.922 0.000 0.868 0.000 NA
#> GSM414970 3 0.4866 0.717 0.000 0.000 0.596 NA
#> GSM414972 2 0.2814 0.922 0.000 0.868 0.000 NA
#> GSM414975 2 0.2814 0.922 0.000 0.868 0.000 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.4923 0.620 0.680 0.000 0.000 0.252 0.068
#> GSM414925 1 0.3966 0.750 0.796 0.000 0.000 0.132 0.072
#> GSM414926 1 0.4329 0.673 0.716 0.000 0.000 0.252 0.032
#> GSM414927 2 0.0963 0.915 0.000 0.964 0.000 0.036 0.000
#> GSM414929 1 0.1211 0.845 0.960 0.000 0.000 0.024 0.016
#> GSM414931 1 0.0510 0.846 0.984 0.000 0.000 0.000 0.016
#> GSM414933 1 0.1117 0.844 0.964 0.000 0.000 0.020 0.016
#> GSM414935 5 0.1965 0.873 0.000 0.000 0.096 0.000 0.904
#> GSM414936 1 0.2522 0.837 0.880 0.000 0.000 0.012 0.108
#> GSM414937 1 0.3146 0.825 0.844 0.000 0.000 0.028 0.128
#> GSM414939 1 0.2969 0.827 0.852 0.000 0.000 0.020 0.128
#> GSM414941 1 0.5006 0.730 0.704 0.000 0.000 0.116 0.180
#> GSM414943 1 0.2411 0.837 0.884 0.000 0.000 0.008 0.108
#> GSM414944 1 0.3362 0.811 0.864 0.000 0.064 0.040 0.032
#> GSM414945 2 0.4202 0.762 0.004 0.804 0.124 0.016 0.052
#> GSM414946 1 0.3400 0.787 0.828 0.000 0.000 0.136 0.036
#> GSM414948 1 0.0579 0.848 0.984 0.000 0.000 0.008 0.008
#> GSM414949 3 0.6040 0.396 0.000 0.000 0.556 0.152 0.292
#> GSM414950 5 0.1792 0.855 0.000 0.000 0.084 0.000 0.916
#> GSM414951 1 0.2966 0.824 0.848 0.000 0.000 0.016 0.136
#> GSM414952 5 0.3707 0.691 0.000 0.000 0.284 0.000 0.716
#> GSM414954 1 0.3193 0.824 0.840 0.000 0.000 0.028 0.132
#> GSM414956 1 0.3201 0.828 0.844 0.000 0.016 0.008 0.132
#> GSM414958 1 0.0404 0.847 0.988 0.000 0.000 0.000 0.012
#> GSM414959 1 0.1942 0.848 0.920 0.000 0.000 0.012 0.068
#> GSM414960 1 0.1117 0.844 0.964 0.000 0.000 0.020 0.016
#> GSM414961 5 0.2329 0.885 0.000 0.000 0.124 0.000 0.876
#> GSM414962 4 0.6825 0.758 0.084 0.136 0.004 0.612 0.164
#> GSM414964 1 0.4086 0.735 0.736 0.000 0.000 0.024 0.240
#> GSM414965 1 0.2470 0.838 0.884 0.000 0.000 0.012 0.104
#> GSM414967 1 0.2747 0.810 0.884 0.000 0.088 0.012 0.016
#> GSM414968 5 0.2732 0.860 0.000 0.000 0.160 0.000 0.840
#> GSM414969 1 0.5216 0.625 0.660 0.000 0.000 0.248 0.092
#> GSM414971 1 0.0510 0.846 0.984 0.000 0.000 0.000 0.016
#> GSM414973 1 0.1965 0.826 0.904 0.000 0.000 0.096 0.000
#> GSM414974 4 0.6684 0.768 0.172 0.036 0.012 0.612 0.168
#> GSM414928 2 0.0880 0.915 0.000 0.968 0.000 0.032 0.000
#> GSM414930 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.2516 0.838 0.000 0.000 0.860 0.000 0.140
#> GSM414934 3 0.2424 0.691 0.000 0.000 0.868 0.132 0.000
#> GSM414938 1 0.4176 0.791 0.820 0.004 0.088 0.052 0.036
#> GSM414940 3 0.2516 0.838 0.000 0.000 0.860 0.000 0.140
#> GSM414942 2 0.2011 0.917 0.000 0.908 0.000 0.088 0.004
#> GSM414947 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.2424 0.691 0.000 0.000 0.868 0.132 0.000
#> GSM414955 3 0.2629 0.839 0.000 0.000 0.860 0.004 0.136
#> GSM414957 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.2629 0.839 0.000 0.000 0.860 0.004 0.136
#> GSM414966 2 0.2011 0.917 0.000 0.908 0.000 0.088 0.004
#> GSM414970 3 0.2471 0.839 0.000 0.000 0.864 0.000 0.136
#> GSM414972 2 0.2068 0.916 0.000 0.904 0.000 0.092 0.004
#> GSM414975 2 0.2011 0.917 0.000 0.908 0.000 0.088 0.004
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.3023 0.5691 0.784 0.000 0.000 0.000 0.212 0.004
#> GSM414925 1 0.3725 0.5275 0.676 0.000 0.000 0.000 0.316 0.008
#> GSM414926 1 0.3023 0.5691 0.784 0.000 0.000 0.000 0.212 0.004
#> GSM414927 2 0.0000 0.9284 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414929 5 0.6334 0.3384 0.244 0.000 0.000 0.020 0.460 0.276
#> GSM414931 5 0.6334 0.3940 0.224 0.000 0.000 0.040 0.520 0.216
#> GSM414933 5 0.6369 0.3275 0.248 0.000 0.000 0.020 0.448 0.284
#> GSM414935 6 0.5571 0.8409 0.004 0.000 0.324 0.000 0.140 0.532
#> GSM414936 5 0.0000 0.5780 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414937 5 0.1715 0.5669 0.008 0.000 0.020 0.016 0.940 0.016
#> GSM414939 5 0.1140 0.5689 0.008 0.000 0.008 0.008 0.964 0.012
#> GSM414941 1 0.3797 0.4325 0.580 0.000 0.000 0.000 0.420 0.000
#> GSM414943 5 0.0146 0.5778 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM414944 5 0.6195 0.3417 0.044 0.000 0.000 0.184 0.552 0.220
#> GSM414945 2 0.5227 0.5633 0.004 0.652 0.008 0.188 0.000 0.148
#> GSM414946 1 0.4144 0.4128 0.580 0.000 0.000 0.008 0.408 0.004
#> GSM414948 5 0.6473 0.3769 0.224 0.000 0.000 0.040 0.488 0.248
#> GSM414949 3 0.5423 0.0739 0.172 0.000 0.620 0.012 0.000 0.196
#> GSM414950 6 0.5743 0.8223 0.004 0.000 0.308 0.004 0.152 0.532
#> GSM414951 5 0.2657 0.5392 0.008 0.000 0.084 0.008 0.880 0.020
#> GSM414952 6 0.5029 0.7381 0.004 0.000 0.452 0.000 0.060 0.484
#> GSM414954 5 0.3423 0.4922 0.008 0.000 0.152 0.012 0.812 0.016
#> GSM414956 5 0.0790 0.5761 0.000 0.000 0.000 0.032 0.968 0.000
#> GSM414958 5 0.6458 0.3809 0.224 0.000 0.000 0.040 0.492 0.244
#> GSM414959 5 0.2796 0.5584 0.048 0.000 0.000 0.012 0.872 0.068
#> GSM414960 5 0.6592 0.3456 0.228 0.000 0.000 0.040 0.452 0.280
#> GSM414961 6 0.5781 0.8082 0.004 0.000 0.316 0.008 0.140 0.532
#> GSM414962 1 0.6850 0.0222 0.532 0.084 0.016 0.216 0.000 0.152
#> GSM414964 5 0.5052 0.3540 0.040 0.000 0.144 0.008 0.716 0.092
#> GSM414965 5 0.0000 0.5780 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414967 5 0.6875 0.3148 0.112 0.000 0.000 0.132 0.456 0.300
#> GSM414968 6 0.4983 0.8003 0.004 0.000 0.404 0.000 0.060 0.532
#> GSM414969 1 0.5392 0.5468 0.612 0.000 0.000 0.072 0.280 0.036
#> GSM414971 5 0.5172 0.4788 0.172 0.000 0.000 0.040 0.684 0.104
#> GSM414973 1 0.4328 0.1794 0.520 0.000 0.000 0.000 0.460 0.020
#> GSM414974 1 0.7107 0.1451 0.532 0.020 0.016 0.216 0.064 0.152
#> GSM414928 2 0.0260 0.9258 0.008 0.992 0.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.9284 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 3 0.0458 0.8220 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM414934 4 0.3804 1.0000 0.000 0.000 0.424 0.576 0.000 0.000
#> GSM414938 5 0.6850 0.2866 0.080 0.000 0.004 0.176 0.488 0.252
#> GSM414940 3 0.0000 0.8278 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414942 2 0.1501 0.9209 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM414947 2 0.0000 0.9284 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 4 0.3804 1.0000 0.000 0.000 0.424 0.576 0.000 0.000
#> GSM414955 3 0.1265 0.7668 0.000 0.000 0.948 0.000 0.044 0.008
#> GSM414957 2 0.0405 0.9247 0.000 0.988 0.004 0.008 0.000 0.000
#> GSM414963 3 0.0000 0.8278 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414966 2 0.1501 0.9209 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM414970 3 0.0000 0.8278 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM414972 2 0.1501 0.9209 0.000 0.924 0.000 0.076 0.000 0.000
#> GSM414975 2 0.1501 0.9209 0.000 0.924 0.000 0.076 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> MAD:mclust 49 2.14e-03 2
#> MAD:mclust 52 1.34e-05 3
#> MAD:mclust 50 8.40e-06 4
#> MAD:mclust 51 6.66e-08 5
#> MAD:mclust 34 4.54e-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", "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 51882 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.845 0.895 0.959 0.4010 0.618 0.618
#> 3 3 0.969 0.937 0.974 0.5851 0.716 0.549
#> 4 4 0.637 0.788 0.839 0.1090 0.971 0.921
#> 5 5 0.611 0.519 0.727 0.0781 0.866 0.639
#> 6 6 0.647 0.627 0.800 0.0467 0.947 0.794
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
#> GSM414924 1 0.000 0.953 1.000 0.000
#> GSM414925 1 0.000 0.953 1.000 0.000
#> GSM414926 1 0.000 0.953 1.000 0.000
#> GSM414927 2 0.000 0.959 0.000 1.000
#> GSM414929 1 0.000 0.953 1.000 0.000
#> GSM414931 1 0.000 0.953 1.000 0.000
#> GSM414933 1 0.000 0.953 1.000 0.000
#> GSM414935 1 0.000 0.953 1.000 0.000
#> GSM414936 1 0.000 0.953 1.000 0.000
#> GSM414937 1 0.000 0.953 1.000 0.000
#> GSM414939 1 0.000 0.953 1.000 0.000
#> GSM414941 1 0.000 0.953 1.000 0.000
#> GSM414943 1 0.000 0.953 1.000 0.000
#> GSM414944 1 0.000 0.953 1.000 0.000
#> GSM414945 2 0.000 0.959 0.000 1.000
#> GSM414946 1 0.000 0.953 1.000 0.000
#> GSM414948 1 0.000 0.953 1.000 0.000
#> GSM414949 1 0.904 0.549 0.680 0.320
#> GSM414950 1 0.000 0.953 1.000 0.000
#> GSM414951 1 0.000 0.953 1.000 0.000
#> GSM414952 1 0.000 0.953 1.000 0.000
#> GSM414954 1 0.000 0.953 1.000 0.000
#> GSM414956 1 0.000 0.953 1.000 0.000
#> GSM414958 1 0.000 0.953 1.000 0.000
#> GSM414959 1 0.000 0.953 1.000 0.000
#> GSM414960 1 0.000 0.953 1.000 0.000
#> GSM414961 1 0.000 0.953 1.000 0.000
#> GSM414962 2 0.000 0.959 0.000 1.000
#> GSM414964 1 0.000 0.953 1.000 0.000
#> GSM414965 1 0.000 0.953 1.000 0.000
#> GSM414967 1 0.000 0.953 1.000 0.000
#> GSM414968 1 0.000 0.953 1.000 0.000
#> GSM414969 1 0.000 0.953 1.000 0.000
#> GSM414971 1 0.000 0.953 1.000 0.000
#> GSM414973 1 0.000 0.953 1.000 0.000
#> GSM414974 2 0.988 0.133 0.436 0.564
#> GSM414928 2 0.000 0.959 0.000 1.000
#> GSM414930 2 0.000 0.959 0.000 1.000
#> GSM414932 1 0.730 0.742 0.796 0.204
#> GSM414934 1 0.634 0.799 0.840 0.160
#> GSM414938 1 0.000 0.953 1.000 0.000
#> GSM414940 1 0.946 0.456 0.636 0.364
#> GSM414942 2 0.000 0.959 0.000 1.000
#> GSM414947 2 0.000 0.959 0.000 1.000
#> GSM414953 1 0.204 0.927 0.968 0.032
#> GSM414955 1 0.552 0.836 0.872 0.128
#> GSM414957 2 0.000 0.959 0.000 1.000
#> GSM414963 2 0.141 0.941 0.020 0.980
#> GSM414966 2 0.000 0.959 0.000 1.000
#> GSM414970 1 0.999 0.114 0.520 0.480
#> GSM414972 2 0.000 0.959 0.000 1.000
#> GSM414975 2 0.000 0.959 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414925 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414926 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414927 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414929 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414931 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414933 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414935 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414936 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414937 1 0.0424 0.988 0.992 0.000 0.008
#> GSM414939 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414941 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414943 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414944 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414945 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414946 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414948 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414949 3 0.4555 0.709 0.000 0.200 0.800
#> GSM414950 3 0.4465 0.760 0.176 0.004 0.820
#> GSM414951 3 0.5948 0.494 0.360 0.000 0.640
#> GSM414952 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414954 1 0.1529 0.955 0.960 0.000 0.040
#> GSM414956 3 0.6299 0.187 0.476 0.000 0.524
#> GSM414958 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414959 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414960 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414961 3 0.1289 0.877 0.032 0.000 0.968
#> GSM414962 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414964 1 0.2066 0.932 0.940 0.000 0.060
#> GSM414965 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414967 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414968 3 0.0592 0.888 0.012 0.000 0.988
#> GSM414969 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414971 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414973 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414974 2 0.0237 0.996 0.000 0.996 0.004
#> GSM414928 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414930 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414932 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414934 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414938 1 0.0000 0.995 1.000 0.000 0.000
#> GSM414940 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414953 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414955 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414963 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414970 3 0.0000 0.893 0.000 0.000 1.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.2647 0.797 0.880 0.000 0.000 NA
#> GSM414925 1 0.0921 0.826 0.972 0.000 0.000 NA
#> GSM414926 1 0.2973 0.784 0.856 0.000 0.000 NA
#> GSM414927 2 0.3626 0.808 0.000 0.812 0.004 NA
#> GSM414929 1 0.4790 0.573 0.620 0.000 0.000 NA
#> GSM414931 1 0.3311 0.820 0.828 0.000 0.000 NA
#> GSM414933 1 0.0469 0.829 0.988 0.000 0.000 NA
#> GSM414935 3 0.3837 0.840 0.000 0.000 0.776 NA
#> GSM414936 1 0.4018 0.807 0.772 0.000 0.004 NA
#> GSM414937 1 0.5277 0.777 0.752 0.000 0.116 NA
#> GSM414939 1 0.4004 0.818 0.812 0.000 0.024 NA
#> GSM414941 1 0.0921 0.826 0.972 0.000 0.000 NA
#> GSM414943 1 0.5681 0.763 0.704 0.000 0.088 NA
#> GSM414944 1 0.3873 0.804 0.772 0.000 0.000 NA
#> GSM414945 2 0.4643 0.646 0.000 0.656 0.000 NA
#> GSM414946 1 0.1792 0.821 0.932 0.000 0.000 NA
#> GSM414948 1 0.1474 0.833 0.948 0.000 0.000 NA
#> GSM414949 3 0.6831 0.639 0.000 0.112 0.536 NA
#> GSM414950 3 0.6466 0.740 0.104 0.000 0.608 NA
#> GSM414951 3 0.4635 0.568 0.268 0.000 0.720 NA
#> GSM414952 3 0.0336 0.847 0.000 0.000 0.992 NA
#> GSM414954 1 0.4284 0.732 0.780 0.000 0.200 NA
#> GSM414956 1 0.7756 0.295 0.412 0.000 0.348 NA
#> GSM414958 1 0.1474 0.823 0.948 0.000 0.000 NA
#> GSM414959 1 0.1211 0.833 0.960 0.000 0.000 NA
#> GSM414960 1 0.3266 0.809 0.832 0.000 0.000 NA
#> GSM414961 3 0.3708 0.847 0.020 0.000 0.832 NA
#> GSM414962 2 0.5110 0.682 0.000 0.656 0.016 NA
#> GSM414964 1 0.4567 0.681 0.740 0.000 0.244 NA
#> GSM414965 1 0.3647 0.823 0.832 0.000 0.016 NA
#> GSM414967 1 0.3837 0.806 0.776 0.000 0.000 NA
#> GSM414968 3 0.3726 0.845 0.000 0.000 0.788 NA
#> GSM414969 1 0.4158 0.704 0.768 0.000 0.008 NA
#> GSM414971 1 0.3764 0.809 0.784 0.000 0.000 NA
#> GSM414973 1 0.0707 0.827 0.980 0.000 0.000 NA
#> GSM414974 2 0.1543 0.884 0.004 0.956 0.008 NA
#> GSM414928 2 0.5090 0.688 0.000 0.660 0.016 NA
#> GSM414930 2 0.0000 0.900 0.000 1.000 0.000 NA
#> GSM414932 3 0.3649 0.840 0.000 0.000 0.796 NA
#> GSM414934 3 0.0707 0.843 0.000 0.000 0.980 NA
#> GSM414938 1 0.5150 0.546 0.596 0.000 0.008 NA
#> GSM414940 3 0.2408 0.847 0.000 0.000 0.896 NA
#> GSM414942 2 0.0000 0.900 0.000 1.000 0.000 NA
#> GSM414947 2 0.0000 0.900 0.000 1.000 0.000 NA
#> GSM414953 3 0.0707 0.843 0.000 0.000 0.980 NA
#> GSM414955 3 0.0592 0.849 0.000 0.000 0.984 NA
#> GSM414957 2 0.0000 0.900 0.000 1.000 0.000 NA
#> GSM414963 3 0.0921 0.849 0.000 0.000 0.972 NA
#> GSM414966 2 0.0000 0.900 0.000 1.000 0.000 NA
#> GSM414970 3 0.4134 0.819 0.000 0.000 0.740 NA
#> GSM414972 2 0.0000 0.900 0.000 1.000 0.000 NA
#> GSM414975 2 0.0000 0.900 0.000 1.000 0.000 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3090 0.5627 0.856 0.000 0.000 0.040 0.104
#> GSM414925 1 0.0992 0.6498 0.968 0.000 0.000 0.024 0.008
#> GSM414926 1 0.3359 0.5416 0.840 0.000 0.000 0.052 0.108
#> GSM414927 2 0.3857 0.4615 0.000 0.688 0.000 0.312 0.000
#> GSM414929 5 0.6515 0.2174 0.328 0.000 0.000 0.208 0.464
#> GSM414931 1 0.3913 0.5377 0.676 0.000 0.000 0.000 0.324
#> GSM414933 1 0.1942 0.6410 0.920 0.000 0.000 0.012 0.068
#> GSM414935 3 0.4242 0.2242 0.000 0.000 0.572 0.428 0.000
#> GSM414936 1 0.4380 0.4509 0.616 0.000 0.008 0.000 0.376
#> GSM414937 1 0.5678 0.4538 0.612 0.000 0.128 0.000 0.260
#> GSM414939 1 0.4130 0.5543 0.696 0.000 0.012 0.000 0.292
#> GSM414941 1 0.1485 0.6336 0.948 0.000 0.000 0.020 0.032
#> GSM414943 1 0.5825 0.3831 0.564 0.000 0.116 0.000 0.320
#> GSM414944 5 0.4886 -0.2112 0.448 0.000 0.000 0.024 0.528
#> GSM414945 5 0.5867 -0.1521 0.004 0.352 0.000 0.096 0.548
#> GSM414946 1 0.2408 0.6257 0.892 0.000 0.000 0.092 0.016
#> GSM414948 1 0.2648 0.6385 0.848 0.000 0.000 0.000 0.152
#> GSM414949 4 0.4750 0.4910 0.004 0.044 0.260 0.692 0.000
#> GSM414950 4 0.4875 0.3734 0.008 0.008 0.336 0.636 0.012
#> GSM414951 3 0.3203 0.5657 0.168 0.000 0.820 0.000 0.012
#> GSM414952 3 0.0992 0.7388 0.000 0.000 0.968 0.024 0.008
#> GSM414954 1 0.4775 0.6015 0.768 0.000 0.100 0.028 0.104
#> GSM414956 5 0.6647 0.0816 0.232 0.000 0.344 0.000 0.424
#> GSM414958 1 0.2770 0.6087 0.880 0.000 0.000 0.044 0.076
#> GSM414959 1 0.3844 0.6140 0.804 0.000 0.000 0.064 0.132
#> GSM414960 1 0.4891 0.3608 0.640 0.000 0.000 0.044 0.316
#> GSM414961 3 0.4852 0.4075 0.016 0.000 0.644 0.324 0.016
#> GSM414962 4 0.3884 0.4744 0.004 0.288 0.000 0.708 0.000
#> GSM414964 1 0.6119 0.4801 0.672 0.000 0.140 0.108 0.080
#> GSM414965 1 0.3582 0.6088 0.768 0.000 0.008 0.000 0.224
#> GSM414967 5 0.4882 -0.2032 0.444 0.000 0.000 0.024 0.532
#> GSM414968 3 0.4229 0.5569 0.000 0.000 0.704 0.276 0.020
#> GSM414969 1 0.4557 0.1305 0.584 0.000 0.000 0.404 0.012
#> GSM414971 1 0.3999 0.5125 0.656 0.000 0.000 0.000 0.344
#> GSM414973 1 0.1012 0.6509 0.968 0.000 0.000 0.012 0.020
#> GSM414974 2 0.2103 0.8706 0.020 0.920 0.000 0.056 0.004
#> GSM414928 4 0.3999 0.3751 0.000 0.344 0.000 0.656 0.000
#> GSM414930 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
#> GSM414932 3 0.4302 -0.0558 0.000 0.000 0.520 0.480 0.000
#> GSM414934 3 0.0000 0.7345 0.000 0.000 1.000 0.000 0.000
#> GSM414938 5 0.6852 0.2384 0.300 0.000 0.012 0.220 0.468
#> GSM414940 3 0.2127 0.7041 0.000 0.000 0.892 0.108 0.000
#> GSM414942 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
#> GSM414953 3 0.0000 0.7345 0.000 0.000 1.000 0.000 0.000
#> GSM414955 3 0.1168 0.7388 0.000 0.000 0.960 0.032 0.008
#> GSM414957 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0880 0.7359 0.000 0.000 0.968 0.032 0.000
#> GSM414966 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
#> GSM414970 4 0.4283 0.0401 0.000 0.000 0.456 0.544 0.000
#> GSM414972 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9414 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.4053 0.57803 0.204 0.000 0.000 0.040 0.744 0.012
#> GSM414925 5 0.2959 0.67731 0.104 0.000 0.000 0.036 0.852 0.008
#> GSM414926 5 0.4074 0.57651 0.212 0.000 0.000 0.028 0.740 0.020
#> GSM414927 2 0.3515 0.49812 0.000 0.676 0.000 0.324 0.000 0.000
#> GSM414929 1 0.1866 0.58894 0.908 0.000 0.000 0.000 0.084 0.008
#> GSM414931 5 0.2955 0.67291 0.004 0.000 0.000 0.008 0.816 0.172
#> GSM414933 5 0.4124 0.65509 0.128 0.000 0.000 0.024 0.776 0.072
#> GSM414935 3 0.5370 0.36156 0.004 0.000 0.560 0.360 0.044 0.032
#> GSM414936 5 0.3402 0.65169 0.008 0.000 0.004 0.008 0.784 0.196
#> GSM414937 5 0.4722 0.56690 0.012 0.000 0.136 0.004 0.720 0.128
#> GSM414939 5 0.2742 0.69327 0.008 0.000 0.004 0.008 0.856 0.124
#> GSM414941 5 0.3306 0.65260 0.136 0.000 0.000 0.036 0.820 0.008
#> GSM414943 5 0.5214 0.48356 0.012 0.000 0.188 0.008 0.668 0.124
#> GSM414944 6 0.2738 0.55889 0.004 0.000 0.000 0.000 0.176 0.820
#> GSM414945 6 0.5902 0.27533 0.168 0.104 0.000 0.100 0.000 0.628
#> GSM414946 5 0.3387 0.67406 0.088 0.000 0.000 0.052 0.836 0.024
#> GSM414948 5 0.1820 0.71090 0.016 0.000 0.000 0.012 0.928 0.044
#> GSM414949 4 0.2266 0.69674 0.000 0.012 0.108 0.880 0.000 0.000
#> GSM414950 4 0.2958 0.68100 0.000 0.000 0.160 0.824 0.008 0.008
#> GSM414951 3 0.3627 0.64815 0.016 0.000 0.808 0.016 0.144 0.016
#> GSM414952 3 0.2112 0.77049 0.020 0.000 0.916 0.036 0.000 0.028
#> GSM414954 5 0.4730 0.61235 0.020 0.000 0.096 0.024 0.752 0.108
#> GSM414956 6 0.6633 0.25765 0.016 0.000 0.316 0.012 0.236 0.420
#> GSM414958 5 0.3711 0.58254 0.260 0.000 0.000 0.000 0.720 0.020
#> GSM414959 5 0.5934 0.27455 0.240 0.000 0.000 0.008 0.516 0.236
#> GSM414960 1 0.5712 -0.00732 0.440 0.000 0.000 0.004 0.416 0.140
#> GSM414961 3 0.6474 0.22887 0.016 0.000 0.480 0.352 0.112 0.040
#> GSM414962 4 0.2170 0.66877 0.000 0.100 0.000 0.888 0.012 0.000
#> GSM414964 5 0.6120 0.46282 0.020 0.000 0.096 0.148 0.640 0.096
#> GSM414965 5 0.2425 0.70107 0.008 0.000 0.000 0.012 0.880 0.100
#> GSM414967 6 0.2631 0.55852 0.012 0.000 0.000 0.004 0.128 0.856
#> GSM414968 3 0.5316 0.61101 0.144 0.000 0.656 0.180 0.016 0.004
#> GSM414969 4 0.5560 0.08099 0.100 0.000 0.000 0.540 0.344 0.016
#> GSM414971 5 0.3166 0.66676 0.008 0.000 0.000 0.008 0.800 0.184
#> GSM414973 5 0.2666 0.69420 0.092 0.000 0.000 0.008 0.872 0.028
#> GSM414974 2 0.2656 0.82275 0.008 0.884 0.000 0.028 0.072 0.008
#> GSM414928 4 0.2955 0.60850 0.004 0.172 0.000 0.816 0.000 0.008
#> GSM414930 2 0.0146 0.93275 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM414932 4 0.3555 0.56146 0.000 0.000 0.280 0.712 0.000 0.008
#> GSM414934 3 0.0951 0.77357 0.020 0.000 0.968 0.008 0.000 0.004
#> GSM414938 1 0.1534 0.54590 0.944 0.000 0.016 0.004 0.032 0.004
#> GSM414940 3 0.3164 0.74037 0.020 0.000 0.844 0.104 0.000 0.032
#> GSM414942 2 0.0000 0.93504 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.93504 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 3 0.0146 0.77438 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM414955 3 0.2039 0.77223 0.012 0.000 0.916 0.052 0.000 0.020
#> GSM414957 2 0.0000 0.93504 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.1531 0.77456 0.000 0.000 0.928 0.068 0.000 0.004
#> GSM414966 2 0.0000 0.93504 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 4 0.3175 0.60611 0.000 0.000 0.256 0.744 0.000 0.000
#> GSM414972 2 0.0000 0.93504 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.93504 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> MAD:NMF 49 1.92e-04 2
#> MAD:NMF 50 9.68e-05 3
#> MAD:NMF 51 1.30e-04 4
#> MAD:NMF 31 6.10e-05 5
#> MAD:NMF 42 5.57e-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", "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 51882 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 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.823 0.895 0.959 0.2653 0.792 0.792
#> 3 3 0.965 0.977 0.989 0.4227 0.845 0.805
#> 4 4 0.933 0.946 0.968 0.0693 0.995 0.993
#> 5 5 0.910 0.907 0.967 0.2889 0.842 0.750
#> 6 6 0.832 0.839 0.938 0.0321 0.996 0.992
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 3
There is also optional best \(k\) = 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.000 0.950 1.000 0.000
#> GSM414925 1 0.000 0.950 1.000 0.000
#> GSM414926 1 0.000 0.950 1.000 0.000
#> GSM414927 1 0.985 0.318 0.572 0.428
#> GSM414929 1 0.000 0.950 1.000 0.000
#> GSM414931 1 0.000 0.950 1.000 0.000
#> GSM414933 1 0.000 0.950 1.000 0.000
#> GSM414935 1 0.000 0.950 1.000 0.000
#> GSM414936 1 0.000 0.950 1.000 0.000
#> GSM414937 1 0.000 0.950 1.000 0.000
#> GSM414939 1 0.000 0.950 1.000 0.000
#> GSM414941 1 0.000 0.950 1.000 0.000
#> GSM414943 1 0.000 0.950 1.000 0.000
#> GSM414944 1 0.000 0.950 1.000 0.000
#> GSM414945 1 0.000 0.950 1.000 0.000
#> GSM414946 1 0.000 0.950 1.000 0.000
#> GSM414948 1 0.000 0.950 1.000 0.000
#> GSM414949 1 0.000 0.950 1.000 0.000
#> GSM414950 1 0.000 0.950 1.000 0.000
#> GSM414951 1 0.000 0.950 1.000 0.000
#> GSM414952 1 0.000 0.950 1.000 0.000
#> GSM414954 1 0.000 0.950 1.000 0.000
#> GSM414956 1 0.000 0.950 1.000 0.000
#> GSM414958 1 0.000 0.950 1.000 0.000
#> GSM414959 1 0.000 0.950 1.000 0.000
#> GSM414960 1 0.985 0.318 0.572 0.428
#> GSM414961 1 0.000 0.950 1.000 0.000
#> GSM414962 1 0.985 0.318 0.572 0.428
#> GSM414964 1 0.000 0.950 1.000 0.000
#> GSM414965 1 0.000 0.950 1.000 0.000
#> GSM414967 1 0.000 0.950 1.000 0.000
#> GSM414968 1 0.000 0.950 1.000 0.000
#> GSM414969 1 0.000 0.950 1.000 0.000
#> GSM414971 1 0.000 0.950 1.000 0.000
#> GSM414973 1 0.000 0.950 1.000 0.000
#> GSM414974 1 0.000 0.950 1.000 0.000
#> GSM414928 1 0.985 0.318 0.572 0.428
#> GSM414930 1 0.985 0.318 0.572 0.428
#> GSM414932 1 0.000 0.950 1.000 0.000
#> GSM414934 1 0.000 0.950 1.000 0.000
#> GSM414938 1 0.000 0.950 1.000 0.000
#> GSM414940 1 0.000 0.950 1.000 0.000
#> GSM414942 2 0.000 1.000 0.000 1.000
#> GSM414947 2 0.000 1.000 0.000 1.000
#> GSM414953 1 0.000 0.950 1.000 0.000
#> GSM414955 1 0.000 0.950 1.000 0.000
#> GSM414957 2 0.000 1.000 0.000 1.000
#> GSM414963 1 0.000 0.950 1.000 0.000
#> GSM414966 2 0.000 1.000 0.000 1.000
#> GSM414970 1 0.000 0.950 1.000 0.000
#> GSM414972 2 0.000 1.000 0.000 1.000
#> GSM414975 2 0.000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 0.985 1.000 0 0.000
#> GSM414925 1 0.0000 0.985 1.000 0 0.000
#> GSM414926 1 0.0000 0.985 1.000 0 0.000
#> GSM414927 3 0.0000 1.000 0.000 0 1.000
#> GSM414929 1 0.0000 0.985 1.000 0 0.000
#> GSM414931 1 0.0000 0.985 1.000 0 0.000
#> GSM414933 1 0.0000 0.985 1.000 0 0.000
#> GSM414935 1 0.0000 0.985 1.000 0 0.000
#> GSM414936 1 0.0000 0.985 1.000 0 0.000
#> GSM414937 1 0.0000 0.985 1.000 0 0.000
#> GSM414939 1 0.0000 0.985 1.000 0 0.000
#> GSM414941 1 0.0000 0.985 1.000 0 0.000
#> GSM414943 1 0.0000 0.985 1.000 0 0.000
#> GSM414944 1 0.0000 0.985 1.000 0 0.000
#> GSM414945 1 0.3038 0.889 0.896 0 0.104
#> GSM414946 1 0.0000 0.985 1.000 0 0.000
#> GSM414948 1 0.0000 0.985 1.000 0 0.000
#> GSM414949 1 0.0000 0.985 1.000 0 0.000
#> GSM414950 1 0.0000 0.985 1.000 0 0.000
#> GSM414951 1 0.0000 0.985 1.000 0 0.000
#> GSM414952 1 0.0000 0.985 1.000 0 0.000
#> GSM414954 1 0.0000 0.985 1.000 0 0.000
#> GSM414956 1 0.0000 0.985 1.000 0 0.000
#> GSM414958 1 0.0000 0.985 1.000 0 0.000
#> GSM414959 1 0.0000 0.985 1.000 0 0.000
#> GSM414960 3 0.0000 1.000 0.000 0 1.000
#> GSM414961 1 0.0000 0.985 1.000 0 0.000
#> GSM414962 3 0.0000 1.000 0.000 0 1.000
#> GSM414964 1 0.0000 0.985 1.000 0 0.000
#> GSM414965 1 0.0000 0.985 1.000 0 0.000
#> GSM414967 1 0.0892 0.969 0.980 0 0.020
#> GSM414968 1 0.0000 0.985 1.000 0 0.000
#> GSM414969 1 0.0000 0.985 1.000 0 0.000
#> GSM414971 1 0.0237 0.982 0.996 0 0.004
#> GSM414973 1 0.0000 0.985 1.000 0 0.000
#> GSM414974 1 0.4291 0.799 0.820 0 0.180
#> GSM414928 3 0.0000 1.000 0.000 0 1.000
#> GSM414930 3 0.0000 1.000 0.000 0 1.000
#> GSM414932 1 0.0000 0.985 1.000 0 0.000
#> GSM414934 1 0.0000 0.985 1.000 0 0.000
#> GSM414938 1 0.0000 0.985 1.000 0 0.000
#> GSM414940 1 0.0000 0.985 1.000 0 0.000
#> GSM414942 2 0.0000 1.000 0.000 1 0.000
#> GSM414947 2 0.0000 1.000 0.000 1 0.000
#> GSM414953 1 0.0000 0.985 1.000 0 0.000
#> GSM414955 1 0.0000 0.985 1.000 0 0.000
#> GSM414957 2 0.0000 1.000 0.000 1 0.000
#> GSM414963 1 0.3686 0.850 0.860 0 0.140
#> GSM414966 2 0.0000 1.000 0.000 1 0.000
#> GSM414970 1 0.3686 0.850 0.860 0 0.140
#> GSM414972 2 0.0000 1.000 0.000 1 0.000
#> GSM414975 2 0.0000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414925 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414926 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414927 4 0.0000 0.982 0.000 0 0.000 1.000
#> GSM414929 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414931 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414933 1 0.1389 0.932 0.952 0 0.048 0.000
#> GSM414935 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414936 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414937 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414939 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414941 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414943 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414944 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414945 1 0.3975 0.735 0.760 0 0.240 0.000
#> GSM414946 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414948 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414949 1 0.1022 0.945 0.968 0 0.032 0.000
#> GSM414950 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414951 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414952 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414954 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414956 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414958 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414959 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414960 3 0.2868 1.000 0.000 0 0.864 0.136
#> GSM414961 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414962 3 0.2868 1.000 0.000 0 0.864 0.136
#> GSM414964 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414965 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414967 1 0.2530 0.878 0.888 0 0.112 0.000
#> GSM414968 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414969 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414971 1 0.2149 0.899 0.912 0 0.088 0.000
#> GSM414973 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414974 1 0.4500 0.620 0.684 0 0.316 0.000
#> GSM414928 4 0.0921 0.964 0.000 0 0.028 0.972
#> GSM414930 4 0.0000 0.982 0.000 0 0.000 1.000
#> GSM414932 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414934 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414938 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414940 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM414953 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414955 1 0.0000 0.966 1.000 0 0.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM414963 1 0.4250 0.684 0.724 0 0.276 0.000
#> GSM414966 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM414970 1 0.4250 0.684 0.724 0 0.276 0.000
#> GSM414972 2 0.0000 1.000 0.000 1 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414925 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414926 1 0.0510 0.964 0.984 0 0.016 0.000 0.000
#> GSM414927 5 0.0000 0.984 0.000 0 0.000 0.000 1.000
#> GSM414929 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414931 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414933 1 0.1544 0.910 0.932 0 0.068 0.000 0.000
#> GSM414935 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414936 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414937 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414939 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414941 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414943 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414944 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414945 3 0.0609 0.575 0.020 0 0.980 0.000 0.000
#> GSM414946 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414948 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414949 3 0.4171 0.367 0.396 0 0.604 0.000 0.000
#> GSM414950 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414951 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414952 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414954 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414956 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414958 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414959 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414960 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM414961 1 0.3274 0.674 0.780 0 0.220 0.000 0.000
#> GSM414962 4 0.0000 1.000 0.000 0 0.000 1.000 0.000
#> GSM414964 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414965 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414967 3 0.4256 0.322 0.436 0 0.564 0.000 0.000
#> GSM414968 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414969 1 0.0162 0.974 0.996 0 0.004 0.000 0.000
#> GSM414971 1 0.2471 0.820 0.864 0 0.136 0.000 0.000
#> GSM414973 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414974 3 0.1341 0.536 0.000 0 0.944 0.056 0.000
#> GSM414928 5 0.0794 0.968 0.000 0 0.000 0.028 0.972
#> GSM414930 5 0.0000 0.984 0.000 0 0.000 0.000 1.000
#> GSM414932 1 0.3274 0.674 0.780 0 0.220 0.000 0.000
#> GSM414934 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414938 1 0.0510 0.964 0.984 0 0.016 0.000 0.000
#> GSM414940 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM414953 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414955 1 0.0000 0.976 1.000 0 0.000 0.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM414963 3 0.0912 0.579 0.012 0 0.972 0.016 0.000
#> GSM414966 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM414970 3 0.0912 0.579 0.012 0 0.972 0.016 0.000
#> GSM414972 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.0937 0.941 0.040 0.000 0.000 0.000 0.960 0.000
#> GSM414925 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414926 5 0.1267 0.929 0.060 0.000 0.000 0.000 0.940 0.000
#> GSM414927 4 0.0000 0.987 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM414929 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414931 5 0.1075 0.937 0.048 0.000 0.000 0.000 0.952 0.000
#> GSM414933 5 0.2214 0.880 0.096 0.000 0.016 0.000 0.888 0.000
#> GSM414935 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414936 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414937 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414939 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414941 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414943 5 0.1007 0.939 0.044 0.000 0.000 0.000 0.956 0.000
#> GSM414944 5 0.1075 0.937 0.048 0.000 0.000 0.000 0.952 0.000
#> GSM414945 1 0.3499 0.000 0.680 0.000 0.320 0.000 0.000 0.000
#> GSM414946 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414948 5 0.1007 0.939 0.044 0.000 0.000 0.000 0.956 0.000
#> GSM414949 3 0.4871 0.269 0.072 0.000 0.580 0.000 0.348 0.000
#> GSM414950 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414951 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414952 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414954 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414956 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414958 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414959 5 0.1075 0.937 0.048 0.000 0.000 0.000 0.952 0.000
#> GSM414960 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM414961 5 0.4067 0.617 0.060 0.000 0.212 0.000 0.728 0.000
#> GSM414962 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM414964 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414965 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414967 3 0.5205 0.224 0.096 0.000 0.520 0.000 0.384 0.000
#> GSM414968 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414969 5 0.1075 0.937 0.048 0.000 0.000 0.000 0.952 0.000
#> GSM414971 5 0.3325 0.789 0.096 0.000 0.084 0.000 0.820 0.000
#> GSM414973 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414974 3 0.1074 0.151 0.028 0.000 0.960 0.000 0.000 0.012
#> GSM414928 4 0.0713 0.973 0.028 0.000 0.000 0.972 0.000 0.000
#> GSM414930 4 0.0000 0.987 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM414932 5 0.4067 0.617 0.060 0.000 0.212 0.000 0.728 0.000
#> GSM414934 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414938 5 0.1528 0.927 0.048 0.000 0.016 0.000 0.936 0.000
#> GSM414940 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414942 2 0.0000 0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.3244 0.773 0.268 0.732 0.000 0.000 0.000 0.000
#> GSM414953 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414955 5 0.0000 0.958 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM414957 2 0.2697 0.832 0.188 0.812 0.000 0.000 0.000 0.000
#> GSM414963 3 0.0146 0.188 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM414966 2 0.0000 0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.0146 0.188 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM414972 2 0.0000 0.917 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.917 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> ATC:hclust 47 0.000387 2
#> ATC:hclust 52 0.000313 3
#> ATC:hclust 52 0.000324 4
#> ATC:hclust 50 0.000628 5
#> ATC:hclust 46 0.000229 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 51882 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.3174 0.683 0.683
#> 3 3 1.000 0.964 0.988 0.4067 0.827 0.753
#> 4 4 0.872 0.738 0.890 0.1553 0.973 0.950
#> 5 5 0.653 0.800 0.880 0.3169 0.751 0.524
#> 6 6 0.764 0.788 0.875 0.0725 0.981 0.934
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0 1 1 0
#> GSM414925 1 0 1 1 0
#> GSM414926 1 0 1 1 0
#> GSM414927 2 0 1 0 1
#> GSM414929 1 0 1 1 0
#> GSM414931 1 0 1 1 0
#> GSM414933 1 0 1 1 0
#> GSM414935 1 0 1 1 0
#> GSM414936 1 0 1 1 0
#> GSM414937 1 0 1 1 0
#> GSM414939 1 0 1 1 0
#> GSM414941 1 0 1 1 0
#> GSM414943 1 0 1 1 0
#> GSM414944 1 0 1 1 0
#> GSM414945 1 0 1 1 0
#> GSM414946 1 0 1 1 0
#> GSM414948 1 0 1 1 0
#> GSM414949 1 0 1 1 0
#> GSM414950 1 0 1 1 0
#> GSM414951 1 0 1 1 0
#> GSM414952 1 0 1 1 0
#> GSM414954 1 0 1 1 0
#> GSM414956 1 0 1 1 0
#> GSM414958 1 0 1 1 0
#> GSM414959 1 0 1 1 0
#> GSM414960 1 0 1 1 0
#> GSM414961 1 0 1 1 0
#> GSM414962 2 0 1 0 1
#> GSM414964 1 0 1 1 0
#> GSM414965 1 0 1 1 0
#> GSM414967 1 0 1 1 0
#> GSM414968 1 0 1 1 0
#> GSM414969 1 0 1 1 0
#> GSM414971 1 0 1 1 0
#> GSM414973 1 0 1 1 0
#> GSM414974 1 0 1 1 0
#> GSM414928 2 0 1 0 1
#> GSM414930 2 0 1 0 1
#> GSM414932 1 0 1 1 0
#> GSM414934 1 0 1 1 0
#> GSM414938 1 0 1 1 0
#> GSM414940 1 0 1 1 0
#> GSM414942 2 0 1 0 1
#> GSM414947 2 0 1 0 1
#> GSM414953 1 0 1 1 0
#> GSM414955 1 0 1 1 0
#> GSM414957 2 0 1 0 1
#> GSM414963 1 0 1 1 0
#> GSM414966 2 0 1 0 1
#> GSM414970 1 0 1 1 0
#> GSM414972 2 0 1 0 1
#> GSM414975 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414925 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414926 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414927 3 0.0000 0.864 0.000 0.000 1.000
#> GSM414929 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414931 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414933 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414935 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414936 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414937 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414939 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414941 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414943 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414944 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414945 3 0.6026 0.391 0.376 0.000 0.624
#> GSM414946 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414948 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414949 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414950 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414951 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414952 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414954 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414956 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414958 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414959 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414960 3 0.0000 0.864 0.000 0.000 1.000
#> GSM414961 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414962 3 0.0000 0.864 0.000 0.000 1.000
#> GSM414964 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414965 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414967 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414968 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414969 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414971 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414973 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414974 3 0.0000 0.864 0.000 0.000 1.000
#> GSM414928 3 0.0000 0.864 0.000 0.000 1.000
#> GSM414930 3 0.0424 0.859 0.000 0.008 0.992
#> GSM414932 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414934 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414938 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414940 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414947 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414953 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414955 1 0.0000 1.000 1.000 0.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414963 3 0.3192 0.782 0.112 0.000 0.888
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414970 3 0.3192 0.782 0.112 0.000 0.888
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.0817 0.962 0.976 0.000 0.000 0.024
#> GSM414925 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414926 1 0.0921 0.961 0.972 0.000 0.000 0.028
#> GSM414927 3 0.4992 0.337 0.000 0.000 0.524 0.476
#> GSM414929 1 0.0817 0.962 0.976 0.000 0.000 0.024
#> GSM414931 1 0.0921 0.961 0.972 0.000 0.000 0.028
#> GSM414933 1 0.1557 0.943 0.944 0.000 0.000 0.056
#> GSM414935 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414936 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414937 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414939 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414941 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414943 1 0.0707 0.963 0.980 0.000 0.000 0.020
#> GSM414944 1 0.0817 0.962 0.976 0.000 0.000 0.024
#> GSM414945 3 0.5862 -0.628 0.032 0.000 0.484 0.484
#> GSM414946 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414948 1 0.0707 0.963 0.980 0.000 0.000 0.020
#> GSM414949 1 0.3649 0.742 0.796 0.000 0.000 0.204
#> GSM414950 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414951 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414952 1 0.0469 0.962 0.988 0.000 0.000 0.012
#> GSM414954 1 0.0707 0.963 0.980 0.000 0.000 0.020
#> GSM414956 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414958 1 0.0817 0.962 0.976 0.000 0.000 0.024
#> GSM414959 1 0.0817 0.962 0.976 0.000 0.000 0.024
#> GSM414960 3 0.4406 -0.196 0.000 0.000 0.700 0.300
#> GSM414961 1 0.3837 0.738 0.776 0.000 0.000 0.224
#> GSM414962 3 0.0000 0.153 0.000 0.000 1.000 0.000
#> GSM414964 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM414965 1 0.0707 0.963 0.980 0.000 0.000 0.020
#> GSM414967 4 0.6791 0.000 0.100 0.000 0.392 0.508
#> GSM414968 1 0.0469 0.962 0.988 0.000 0.000 0.012
#> GSM414969 1 0.1474 0.951 0.948 0.000 0.000 0.052
#> GSM414971 1 0.3975 0.704 0.760 0.000 0.000 0.240
#> GSM414973 1 0.0707 0.963 0.980 0.000 0.000 0.020
#> GSM414974 3 0.4967 -0.423 0.000 0.000 0.548 0.452
#> GSM414928 3 0.4992 0.337 0.000 0.000 0.524 0.476
#> GSM414930 3 0.5161 0.336 0.000 0.004 0.520 0.476
#> GSM414932 1 0.0592 0.961 0.984 0.000 0.000 0.016
#> GSM414934 1 0.0469 0.962 0.988 0.000 0.000 0.012
#> GSM414938 1 0.1792 0.938 0.932 0.000 0.000 0.068
#> GSM414940 1 0.0469 0.962 0.988 0.000 0.000 0.012
#> GSM414942 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM414947 2 0.3801 0.768 0.000 0.780 0.000 0.220
#> GSM414953 1 0.0469 0.962 0.988 0.000 0.000 0.012
#> GSM414955 1 0.0469 0.962 0.988 0.000 0.000 0.012
#> GSM414957 2 0.0188 0.956 0.000 0.996 0.000 0.004
#> GSM414963 3 0.5168 -0.507 0.004 0.000 0.500 0.496
#> GSM414966 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM414970 3 0.5168 -0.507 0.004 0.000 0.500 0.496
#> GSM414972 2 0.0000 0.958 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.958 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.3707 0.761 0.716 0.000 0.000 0.000 0.284
#> GSM414925 5 0.0162 0.911 0.004 0.000 0.000 0.000 0.996
#> GSM414926 1 0.3039 0.836 0.808 0.000 0.000 0.000 0.192
#> GSM414927 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000
#> GSM414929 1 0.4287 0.422 0.540 0.000 0.000 0.000 0.460
#> GSM414931 1 0.3074 0.835 0.804 0.000 0.000 0.000 0.196
#> GSM414933 1 0.2891 0.830 0.824 0.000 0.000 0.000 0.176
#> GSM414935 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414936 5 0.0162 0.911 0.004 0.000 0.000 0.000 0.996
#> GSM414937 5 0.0162 0.911 0.004 0.000 0.000 0.000 0.996
#> GSM414939 5 0.0162 0.911 0.004 0.000 0.000 0.000 0.996
#> GSM414941 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414943 5 0.3039 0.694 0.192 0.000 0.000 0.000 0.808
#> GSM414944 1 0.3039 0.836 0.808 0.000 0.000 0.000 0.192
#> GSM414945 3 0.3814 0.627 0.276 0.000 0.720 0.000 0.004
#> GSM414946 5 0.0162 0.911 0.004 0.000 0.000 0.000 0.996
#> GSM414948 5 0.4074 0.268 0.364 0.000 0.000 0.000 0.636
#> GSM414949 1 0.5798 0.509 0.604 0.000 0.148 0.000 0.248
#> GSM414950 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414951 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414952 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414954 5 0.2230 0.803 0.116 0.000 0.000 0.000 0.884
#> GSM414956 5 0.0162 0.911 0.004 0.000 0.000 0.000 0.996
#> GSM414958 5 0.3774 0.474 0.296 0.000 0.000 0.000 0.704
#> GSM414959 1 0.3983 0.681 0.660 0.000 0.000 0.000 0.340
#> GSM414960 3 0.3359 0.746 0.072 0.000 0.844 0.084 0.000
#> GSM414961 1 0.3123 0.832 0.812 0.000 0.004 0.000 0.184
#> GSM414962 3 0.4424 0.603 0.048 0.000 0.728 0.224 0.000
#> GSM414964 5 0.2230 0.803 0.116 0.000 0.000 0.000 0.884
#> GSM414965 5 0.0609 0.899 0.020 0.000 0.000 0.000 0.980
#> GSM414967 1 0.3656 0.442 0.784 0.000 0.196 0.000 0.020
#> GSM414968 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414969 1 0.3003 0.835 0.812 0.000 0.000 0.000 0.188
#> GSM414971 1 0.2848 0.814 0.840 0.000 0.004 0.000 0.156
#> GSM414973 5 0.3730 0.493 0.288 0.000 0.000 0.000 0.712
#> GSM414974 3 0.1430 0.830 0.052 0.000 0.944 0.004 0.000
#> GSM414928 4 0.0162 0.996 0.000 0.000 0.004 0.996 0.000
#> GSM414930 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000
#> GSM414932 1 0.4307 0.320 0.500 0.000 0.000 0.000 0.500
#> GSM414934 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414938 1 0.2719 0.793 0.852 0.000 0.004 0.000 0.144
#> GSM414940 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414942 2 0.0000 0.942 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.4221 0.672 0.032 0.732 0.000 0.236 0.000
#> GSM414953 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414955 5 0.0000 0.911 0.000 0.000 0.000 0.000 1.000
#> GSM414957 2 0.0880 0.928 0.032 0.968 0.000 0.000 0.000
#> GSM414963 3 0.1410 0.831 0.060 0.000 0.940 0.000 0.000
#> GSM414966 2 0.0000 0.942 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.1478 0.831 0.064 0.000 0.936 0.000 0.000
#> GSM414972 2 0.0000 0.942 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.942 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.1610 0.857 0.916 0.000 0.000 0.000 0.084 0.000
#> GSM414925 5 0.0622 0.868 0.008 0.000 0.000 0.012 0.980 0.000
#> GSM414926 1 0.1267 0.863 0.940 0.000 0.000 0.000 0.060 0.000
#> GSM414927 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM414929 1 0.3515 0.521 0.676 0.000 0.000 0.000 0.324 0.000
#> GSM414931 1 0.2609 0.841 0.868 0.000 0.000 0.036 0.096 0.000
#> GSM414933 1 0.1151 0.850 0.956 0.000 0.000 0.012 0.032 0.000
#> GSM414935 5 0.0146 0.867 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM414936 5 0.0972 0.866 0.008 0.000 0.000 0.028 0.964 0.000
#> GSM414937 5 0.0972 0.862 0.008 0.000 0.000 0.028 0.964 0.000
#> GSM414939 5 0.1074 0.861 0.012 0.000 0.000 0.028 0.960 0.000
#> GSM414941 5 0.0622 0.868 0.008 0.000 0.000 0.012 0.980 0.000
#> GSM414943 5 0.3970 0.573 0.280 0.000 0.000 0.028 0.692 0.000
#> GSM414944 1 0.1524 0.864 0.932 0.000 0.000 0.008 0.060 0.000
#> GSM414945 3 0.3566 0.498 0.024 0.000 0.752 0.224 0.000 0.000
#> GSM414946 5 0.0622 0.868 0.008 0.000 0.000 0.012 0.980 0.000
#> GSM414948 5 0.4417 0.231 0.416 0.000 0.000 0.028 0.556 0.000
#> GSM414949 3 0.6422 0.248 0.336 0.000 0.484 0.084 0.096 0.000
#> GSM414950 5 0.1610 0.851 0.000 0.000 0.000 0.084 0.916 0.000
#> GSM414951 5 0.0713 0.865 0.000 0.000 0.000 0.028 0.972 0.000
#> GSM414952 5 0.1663 0.850 0.000 0.000 0.000 0.088 0.912 0.000
#> GSM414954 5 0.2988 0.769 0.144 0.000 0.000 0.028 0.828 0.000
#> GSM414956 5 0.1074 0.861 0.012 0.000 0.000 0.028 0.960 0.000
#> GSM414958 5 0.3990 0.569 0.284 0.000 0.000 0.028 0.688 0.000
#> GSM414959 1 0.2618 0.831 0.860 0.000 0.000 0.024 0.116 0.000
#> GSM414960 4 0.4507 0.973 0.012 0.000 0.372 0.596 0.000 0.020
#> GSM414961 1 0.2138 0.853 0.908 0.000 0.004 0.036 0.052 0.000
#> GSM414962 4 0.4432 0.973 0.000 0.000 0.364 0.600 0.000 0.036
#> GSM414964 5 0.2909 0.777 0.136 0.000 0.000 0.028 0.836 0.000
#> GSM414965 5 0.1970 0.838 0.060 0.000 0.000 0.028 0.912 0.000
#> GSM414967 1 0.1434 0.788 0.940 0.000 0.048 0.012 0.000 0.000
#> GSM414968 5 0.1918 0.846 0.008 0.000 0.000 0.088 0.904 0.000
#> GSM414969 1 0.1007 0.860 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM414971 1 0.1793 0.849 0.928 0.000 0.004 0.032 0.036 0.000
#> GSM414973 5 0.3950 0.584 0.276 0.000 0.000 0.028 0.696 0.000
#> GSM414974 3 0.0547 0.637 0.020 0.000 0.980 0.000 0.000 0.000
#> GSM414928 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM414930 6 0.0000 1.000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM414932 1 0.5123 0.155 0.508 0.000 0.000 0.084 0.408 0.000
#> GSM414934 5 0.2070 0.842 0.008 0.000 0.000 0.100 0.892 0.000
#> GSM414938 1 0.1523 0.852 0.940 0.000 0.008 0.008 0.044 0.000
#> GSM414940 5 0.2070 0.842 0.008 0.000 0.000 0.100 0.892 0.000
#> GSM414942 2 0.0000 0.934 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.4346 0.658 0.020 0.712 0.000 0.036 0.000 0.232
#> GSM414953 5 0.1663 0.850 0.000 0.000 0.000 0.088 0.912 0.000
#> GSM414955 5 0.1663 0.850 0.000 0.000 0.000 0.088 0.912 0.000
#> GSM414957 2 0.1408 0.909 0.020 0.944 0.000 0.036 0.000 0.000
#> GSM414963 3 0.0547 0.637 0.020 0.000 0.980 0.000 0.000 0.000
#> GSM414966 2 0.0000 0.934 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.0547 0.637 0.020 0.000 0.980 0.000 0.000 0.000
#> GSM414972 2 0.0000 0.934 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.934 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> ATC:kmeans 52 0.000746 2
#> ATC:kmeans 51 0.000103 3
#> ATC:kmeans 42 0.000220 4
#> ATC:kmeans 46 0.001128 5
#> ATC:kmeans 48 0.000460 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 51882 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.991 0.996 0.4157 0.581 0.581
#> 3 3 0.675 0.696 0.869 0.2719 0.973 0.953
#> 4 4 0.613 0.737 0.846 0.0979 0.936 0.885
#> 5 5 0.535 0.669 0.804 0.0801 0.956 0.910
#> 6 6 0.583 0.321 0.730 0.0584 0.913 0.806
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
#> GSM414924 1 0.000 1.000 1.0 0.0
#> GSM414925 1 0.000 1.000 1.0 0.0
#> GSM414926 1 0.000 1.000 1.0 0.0
#> GSM414927 2 0.000 0.986 0.0 1.0
#> GSM414929 1 0.000 1.000 1.0 0.0
#> GSM414931 1 0.000 1.000 1.0 0.0
#> GSM414933 1 0.000 1.000 1.0 0.0
#> GSM414935 1 0.000 1.000 1.0 0.0
#> GSM414936 1 0.000 1.000 1.0 0.0
#> GSM414937 1 0.000 1.000 1.0 0.0
#> GSM414939 1 0.000 1.000 1.0 0.0
#> GSM414941 1 0.000 1.000 1.0 0.0
#> GSM414943 1 0.000 1.000 1.0 0.0
#> GSM414944 1 0.000 1.000 1.0 0.0
#> GSM414945 2 0.722 0.750 0.2 0.8
#> GSM414946 1 0.000 1.000 1.0 0.0
#> GSM414948 1 0.000 1.000 1.0 0.0
#> GSM414949 1 0.000 1.000 1.0 0.0
#> GSM414950 1 0.000 1.000 1.0 0.0
#> GSM414951 1 0.000 1.000 1.0 0.0
#> GSM414952 1 0.000 1.000 1.0 0.0
#> GSM414954 1 0.000 1.000 1.0 0.0
#> GSM414956 1 0.000 1.000 1.0 0.0
#> GSM414958 1 0.000 1.000 1.0 0.0
#> GSM414959 1 0.000 1.000 1.0 0.0
#> GSM414960 2 0.000 0.986 0.0 1.0
#> GSM414961 1 0.000 1.000 1.0 0.0
#> GSM414962 2 0.000 0.986 0.0 1.0
#> GSM414964 1 0.000 1.000 1.0 0.0
#> GSM414965 1 0.000 1.000 1.0 0.0
#> GSM414967 1 0.000 1.000 1.0 0.0
#> GSM414968 1 0.000 1.000 1.0 0.0
#> GSM414969 1 0.000 1.000 1.0 0.0
#> GSM414971 1 0.000 1.000 1.0 0.0
#> GSM414973 1 0.000 1.000 1.0 0.0
#> GSM414974 2 0.000 0.986 0.0 1.0
#> GSM414928 2 0.000 0.986 0.0 1.0
#> GSM414930 2 0.000 0.986 0.0 1.0
#> GSM414932 1 0.000 1.000 1.0 0.0
#> GSM414934 1 0.000 1.000 1.0 0.0
#> GSM414938 1 0.000 1.000 1.0 0.0
#> GSM414940 1 0.000 1.000 1.0 0.0
#> GSM414942 2 0.000 0.986 0.0 1.0
#> GSM414947 2 0.000 0.986 0.0 1.0
#> GSM414953 1 0.000 1.000 1.0 0.0
#> GSM414955 1 0.000 1.000 1.0 0.0
#> GSM414957 2 0.000 0.986 0.0 1.0
#> GSM414963 2 0.000 0.986 0.0 1.0
#> GSM414966 2 0.000 0.986 0.0 1.0
#> GSM414970 2 0.000 0.986 0.0 1.0
#> GSM414972 2 0.000 0.986 0.0 1.0
#> GSM414975 2 0.000 0.986 0.0 1.0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.3267 0.697 0.884 0.000 0.116
#> GSM414925 1 0.2448 0.741 0.924 0.000 0.076
#> GSM414926 1 0.3482 0.654 0.872 0.000 0.128
#> GSM414927 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414929 1 0.2796 0.696 0.908 0.000 0.092
#> GSM414931 1 0.4750 0.450 0.784 0.000 0.216
#> GSM414933 1 0.6026 -0.370 0.624 0.000 0.376
#> GSM414935 1 0.3619 0.720 0.864 0.000 0.136
#> GSM414936 1 0.1860 0.744 0.948 0.000 0.052
#> GSM414937 1 0.0892 0.736 0.980 0.000 0.020
#> GSM414939 1 0.1163 0.733 0.972 0.000 0.028
#> GSM414941 1 0.2711 0.737 0.912 0.000 0.088
#> GSM414943 1 0.1643 0.724 0.956 0.000 0.044
#> GSM414944 1 0.4702 0.468 0.788 0.000 0.212
#> GSM414945 2 0.6489 0.507 0.004 0.540 0.456
#> GSM414946 1 0.2356 0.741 0.928 0.000 0.072
#> GSM414948 1 0.3267 0.669 0.884 0.000 0.116
#> GSM414949 1 0.6225 0.105 0.568 0.000 0.432
#> GSM414950 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414951 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414952 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414954 1 0.1411 0.729 0.964 0.000 0.036
#> GSM414956 1 0.1163 0.733 0.972 0.000 0.028
#> GSM414958 1 0.3412 0.659 0.876 0.000 0.124
#> GSM414959 1 0.3412 0.659 0.876 0.000 0.124
#> GSM414960 2 0.0424 0.967 0.000 0.992 0.008
#> GSM414961 1 0.2261 0.738 0.932 0.000 0.068
#> GSM414962 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414964 1 0.0592 0.742 0.988 0.000 0.012
#> GSM414965 1 0.3192 0.673 0.888 0.000 0.112
#> GSM414967 3 0.6244 0.000 0.440 0.000 0.560
#> GSM414968 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414969 1 0.3686 0.656 0.860 0.000 0.140
#> GSM414971 1 0.6026 -0.380 0.624 0.000 0.376
#> GSM414973 1 0.3412 0.659 0.876 0.000 0.124
#> GSM414974 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414928 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414930 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414932 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414934 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414938 1 0.5529 0.572 0.704 0.000 0.296
#> GSM414940 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414942 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414953 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414955 1 0.3816 0.713 0.852 0.000 0.148
#> GSM414957 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414963 2 0.0747 0.963 0.000 0.984 0.016
#> GSM414966 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414970 2 0.0892 0.961 0.000 0.980 0.020
#> GSM414972 2 0.0000 0.971 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.971 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.3697 0.79149 0.852 0.000 0.048 0.100
#> GSM414925 1 0.2469 0.80314 0.892 0.000 0.108 0.000
#> GSM414926 1 0.3249 0.74691 0.852 0.000 0.008 0.140
#> GSM414927 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414929 1 0.3051 0.79748 0.884 0.000 0.028 0.088
#> GSM414931 1 0.3311 0.69774 0.828 0.000 0.000 0.172
#> GSM414933 1 0.4992 -0.20094 0.524 0.000 0.000 0.476
#> GSM414935 1 0.3528 0.77029 0.808 0.000 0.192 0.000
#> GSM414936 1 0.1824 0.81144 0.936 0.000 0.060 0.004
#> GSM414937 1 0.0657 0.80797 0.984 0.000 0.004 0.012
#> GSM414939 1 0.1118 0.80129 0.964 0.000 0.000 0.036
#> GSM414941 1 0.2868 0.79558 0.864 0.000 0.136 0.000
#> GSM414943 1 0.1637 0.79249 0.940 0.000 0.000 0.060
#> GSM414944 1 0.3448 0.71275 0.828 0.000 0.004 0.168
#> GSM414945 3 0.6603 0.00510 0.000 0.328 0.572 0.100
#> GSM414946 1 0.2530 0.80555 0.896 0.000 0.100 0.004
#> GSM414948 1 0.2081 0.78116 0.916 0.000 0.000 0.084
#> GSM414949 3 0.4250 -0.00485 0.276 0.000 0.724 0.000
#> GSM414950 1 0.3873 0.74938 0.772 0.000 0.228 0.000
#> GSM414951 1 0.3764 0.75711 0.784 0.000 0.216 0.000
#> GSM414952 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414954 1 0.1389 0.79701 0.952 0.000 0.000 0.048
#> GSM414956 1 0.0707 0.80508 0.980 0.000 0.000 0.020
#> GSM414958 1 0.2408 0.76732 0.896 0.000 0.000 0.104
#> GSM414959 1 0.2593 0.76518 0.892 0.000 0.004 0.104
#> GSM414960 2 0.1211 0.89777 0.000 0.960 0.000 0.040
#> GSM414961 1 0.3239 0.79776 0.880 0.000 0.068 0.052
#> GSM414962 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414964 1 0.1209 0.81266 0.964 0.000 0.032 0.004
#> GSM414965 1 0.2081 0.78118 0.916 0.000 0.000 0.084
#> GSM414967 4 0.2928 0.57056 0.108 0.000 0.012 0.880
#> GSM414968 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414969 1 0.3734 0.78237 0.848 0.000 0.044 0.108
#> GSM414971 4 0.4477 0.60189 0.312 0.000 0.000 0.688
#> GSM414973 1 0.2149 0.77916 0.912 0.000 0.000 0.088
#> GSM414974 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414928 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414930 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414932 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414934 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414938 1 0.6916 0.54483 0.588 0.000 0.236 0.176
#> GSM414940 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414942 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414947 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414953 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414955 1 0.3907 0.74687 0.768 0.000 0.232 0.000
#> GSM414957 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414963 2 0.6617 0.45523 0.000 0.600 0.280 0.120
#> GSM414966 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414970 2 0.6753 0.47974 0.000 0.608 0.228 0.164
#> GSM414972 2 0.0000 0.93014 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 0.93014 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.4244 0.6953 0.804 0.000 0.024 0.104 0.068
#> GSM414925 1 0.3132 0.7250 0.820 0.000 0.000 0.172 0.008
#> GSM414926 1 0.4209 0.6127 0.804 0.000 0.032 0.044 0.120
#> GSM414927 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414929 1 0.3410 0.7148 0.856 0.000 0.016 0.076 0.052
#> GSM414931 1 0.3851 0.4308 0.768 0.000 0.016 0.004 0.212
#> GSM414933 5 0.5010 0.2120 0.484 0.000 0.012 0.012 0.492
#> GSM414935 1 0.3586 0.6999 0.736 0.000 0.000 0.264 0.000
#> GSM414936 1 0.2233 0.7353 0.892 0.000 0.000 0.104 0.004
#> GSM414937 1 0.0880 0.7251 0.968 0.000 0.000 0.032 0.000
#> GSM414939 1 0.0671 0.7192 0.980 0.000 0.000 0.016 0.004
#> GSM414941 1 0.3461 0.7125 0.772 0.000 0.000 0.224 0.004
#> GSM414943 1 0.2026 0.6846 0.924 0.000 0.012 0.008 0.056
#> GSM414944 1 0.4000 0.5440 0.784 0.000 0.016 0.020 0.180
#> GSM414945 4 0.7160 -0.3501 0.000 0.216 0.176 0.540 0.068
#> GSM414946 1 0.3039 0.7288 0.836 0.000 0.000 0.152 0.012
#> GSM414948 1 0.2228 0.6612 0.908 0.000 0.012 0.004 0.076
#> GSM414949 4 0.3760 0.0913 0.188 0.000 0.028 0.784 0.000
#> GSM414950 1 0.4088 0.6371 0.632 0.000 0.000 0.368 0.000
#> GSM414951 1 0.3661 0.6958 0.724 0.000 0.000 0.276 0.000
#> GSM414952 1 0.4114 0.6310 0.624 0.000 0.000 0.376 0.000
#> GSM414954 1 0.1195 0.7074 0.960 0.000 0.000 0.012 0.028
#> GSM414956 1 0.0898 0.7190 0.972 0.000 0.000 0.020 0.008
#> GSM414958 1 0.2352 0.6535 0.896 0.000 0.004 0.008 0.092
#> GSM414959 1 0.2588 0.6461 0.884 0.000 0.008 0.008 0.100
#> GSM414960 2 0.4185 0.6422 0.000 0.796 0.112 0.008 0.084
#> GSM414961 1 0.4141 0.6377 0.800 0.000 0.008 0.088 0.104
#> GSM414962 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414964 1 0.1792 0.7341 0.916 0.000 0.000 0.084 0.000
#> GSM414965 1 0.1571 0.6835 0.936 0.000 0.000 0.004 0.060
#> GSM414967 5 0.3175 0.0767 0.040 0.000 0.044 0.040 0.876
#> GSM414968 1 0.4114 0.6354 0.624 0.000 0.000 0.376 0.000
#> GSM414969 1 0.4249 0.6780 0.792 0.000 0.008 0.100 0.100
#> GSM414971 5 0.4269 0.4652 0.300 0.000 0.016 0.000 0.684
#> GSM414973 1 0.2037 0.6746 0.920 0.000 0.004 0.012 0.064
#> GSM414974 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414928 2 0.0162 0.9696 0.000 0.996 0.000 0.004 0.000
#> GSM414930 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414932 1 0.4114 0.6310 0.624 0.000 0.000 0.376 0.000
#> GSM414934 1 0.4138 0.6241 0.616 0.000 0.000 0.384 0.000
#> GSM414938 1 0.7387 0.2519 0.464 0.000 0.064 0.312 0.160
#> GSM414940 1 0.4126 0.6282 0.620 0.000 0.000 0.380 0.000
#> GSM414942 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414953 1 0.4114 0.6310 0.624 0.000 0.000 0.376 0.000
#> GSM414955 1 0.4114 0.6310 0.624 0.000 0.000 0.376 0.000
#> GSM414957 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.4805 0.7116 0.000 0.312 0.648 0.040 0.000
#> GSM414966 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.4192 0.7108 0.000 0.232 0.736 0.000 0.032
#> GSM414972 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9740 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.5268 -0.0915 0.312 0.000 0.004 0.052 0.604 0.028
#> GSM414925 5 0.3030 0.3550 0.168 0.000 0.000 0.008 0.816 0.008
#> GSM414926 1 0.5301 0.5726 0.476 0.000 0.000 0.044 0.452 0.028
#> GSM414927 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414929 5 0.4490 -0.1686 0.348 0.000 0.000 0.028 0.616 0.008
#> GSM414931 1 0.5258 0.5591 0.540 0.000 0.000 0.004 0.364 0.092
#> GSM414933 6 0.6111 0.2884 0.312 0.000 0.000 0.016 0.188 0.484
#> GSM414935 5 0.2346 0.3961 0.124 0.000 0.000 0.008 0.868 0.000
#> GSM414936 5 0.3290 0.2119 0.252 0.000 0.000 0.000 0.744 0.004
#> GSM414937 5 0.3578 -0.1042 0.340 0.000 0.000 0.000 0.660 0.000
#> GSM414939 5 0.3747 -0.3004 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM414941 5 0.2482 0.3770 0.148 0.000 0.000 0.000 0.848 0.004
#> GSM414943 5 0.3982 -0.5659 0.460 0.000 0.000 0.000 0.536 0.004
#> GSM414944 5 0.5604 -0.5783 0.436 0.000 0.000 0.012 0.452 0.100
#> GSM414945 4 0.3653 -0.1939 0.000 0.132 0.048 0.804 0.000 0.016
#> GSM414946 5 0.3262 0.3222 0.196 0.000 0.000 0.008 0.788 0.008
#> GSM414948 1 0.3998 0.5985 0.504 0.000 0.000 0.000 0.492 0.004
#> GSM414949 4 0.5975 0.1630 0.072 0.000 0.044 0.460 0.420 0.004
#> GSM414950 5 0.0363 0.4392 0.000 0.000 0.000 0.012 0.988 0.000
#> GSM414951 5 0.2313 0.4138 0.100 0.000 0.000 0.012 0.884 0.004
#> GSM414952 5 0.1320 0.4348 0.016 0.000 0.000 0.036 0.948 0.000
#> GSM414954 5 0.3833 -0.4796 0.444 0.000 0.000 0.000 0.556 0.000
#> GSM414956 5 0.3747 -0.3046 0.396 0.000 0.000 0.000 0.604 0.000
#> GSM414958 5 0.4264 -0.6632 0.488 0.000 0.000 0.000 0.496 0.016
#> GSM414959 1 0.4709 0.6330 0.488 0.000 0.004 0.012 0.480 0.016
#> GSM414960 2 0.5025 0.6360 0.088 0.736 0.096 0.012 0.000 0.068
#> GSM414961 5 0.4776 -0.2636 0.412 0.000 0.004 0.008 0.548 0.028
#> GSM414962 2 0.0603 0.9560 0.016 0.980 0.000 0.004 0.000 0.000
#> GSM414964 5 0.3266 0.1526 0.272 0.000 0.000 0.000 0.728 0.000
#> GSM414965 5 0.3986 -0.5660 0.464 0.000 0.000 0.004 0.532 0.000
#> GSM414967 6 0.1257 0.0876 0.020 0.000 0.000 0.028 0.000 0.952
#> GSM414968 5 0.1492 0.4351 0.036 0.000 0.000 0.024 0.940 0.000
#> GSM414969 5 0.5418 -0.1752 0.348 0.000 0.004 0.060 0.564 0.024
#> GSM414971 6 0.4809 0.4328 0.412 0.000 0.008 0.008 0.024 0.548
#> GSM414973 5 0.3995 -0.5957 0.480 0.000 0.000 0.004 0.516 0.000
#> GSM414974 2 0.0146 0.9690 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM414928 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414930 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414932 5 0.2389 0.4184 0.060 0.000 0.000 0.052 0.888 0.000
#> GSM414934 5 0.2134 0.4132 0.044 0.000 0.000 0.052 0.904 0.000
#> GSM414938 5 0.6525 0.0772 0.144 0.000 0.004 0.280 0.512 0.060
#> GSM414940 5 0.2066 0.4179 0.040 0.000 0.000 0.052 0.908 0.000
#> GSM414942 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414947 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414953 5 0.1564 0.4300 0.024 0.000 0.000 0.040 0.936 0.000
#> GSM414955 5 0.1391 0.4350 0.016 0.000 0.000 0.040 0.944 0.000
#> GSM414957 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414963 3 0.2937 0.6841 0.000 0.096 0.848 0.056 0.000 0.000
#> GSM414966 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414970 3 0.4749 0.6929 0.144 0.076 0.740 0.012 0.000 0.028
#> GSM414972 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 0.9719 0.000 1.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> ATC:skmeans 52 0.001197 2
#> ATC:skmeans 46 0.004682 3
#> ATC:skmeans 47 0.004568 4
#> ATC:skmeans 45 0.000855 5
#> ATC:skmeans 18 0.027324 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 51882 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 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 1.000 0.999 1.000 0.2668 0.735 0.735
#> 3 3 1.000 0.958 0.983 0.4477 0.894 0.856
#> 4 4 0.966 0.926 0.963 0.2693 0.872 0.801
#> 5 5 0.822 0.914 0.947 0.0556 0.994 0.989
#> 6 6 0.750 0.900 0.929 0.0252 0.998 0.996
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM414924 1 0.0000 0.999 1.000 0.000
#> GSM414925 1 0.0000 0.999 1.000 0.000
#> GSM414926 1 0.0000 0.999 1.000 0.000
#> GSM414927 2 0.0000 1.000 0.000 1.000
#> GSM414929 1 0.0000 0.999 1.000 0.000
#> GSM414931 1 0.0000 0.999 1.000 0.000
#> GSM414933 1 0.0000 0.999 1.000 0.000
#> GSM414935 1 0.0000 0.999 1.000 0.000
#> GSM414936 1 0.0000 0.999 1.000 0.000
#> GSM414937 1 0.0000 0.999 1.000 0.000
#> GSM414939 1 0.0000 0.999 1.000 0.000
#> GSM414941 1 0.0000 0.999 1.000 0.000
#> GSM414943 1 0.0000 0.999 1.000 0.000
#> GSM414944 1 0.0000 0.999 1.000 0.000
#> GSM414945 1 0.0000 0.999 1.000 0.000
#> GSM414946 1 0.0000 0.999 1.000 0.000
#> GSM414948 1 0.0000 0.999 1.000 0.000
#> GSM414949 1 0.0000 0.999 1.000 0.000
#> GSM414950 1 0.0000 0.999 1.000 0.000
#> GSM414951 1 0.0000 0.999 1.000 0.000
#> GSM414952 1 0.0000 0.999 1.000 0.000
#> GSM414954 1 0.0000 0.999 1.000 0.000
#> GSM414956 1 0.0000 0.999 1.000 0.000
#> GSM414958 1 0.0000 0.999 1.000 0.000
#> GSM414959 1 0.0000 0.999 1.000 0.000
#> GSM414960 1 0.0000 0.999 1.000 0.000
#> GSM414961 1 0.0000 0.999 1.000 0.000
#> GSM414962 1 0.0938 0.988 0.988 0.012
#> GSM414964 1 0.0000 0.999 1.000 0.000
#> GSM414965 1 0.0000 0.999 1.000 0.000
#> GSM414967 1 0.0000 0.999 1.000 0.000
#> GSM414968 1 0.0000 0.999 1.000 0.000
#> GSM414969 1 0.0000 0.999 1.000 0.000
#> GSM414971 1 0.0000 0.999 1.000 0.000
#> GSM414973 1 0.0000 0.999 1.000 0.000
#> GSM414974 1 0.0000 0.999 1.000 0.000
#> GSM414928 1 0.0938 0.988 0.988 0.012
#> GSM414930 2 0.0000 1.000 0.000 1.000
#> GSM414932 1 0.0000 0.999 1.000 0.000
#> GSM414934 1 0.0000 0.999 1.000 0.000
#> GSM414938 1 0.0000 0.999 1.000 0.000
#> GSM414940 1 0.0000 0.999 1.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000
#> GSM414947 2 0.0000 1.000 0.000 1.000
#> GSM414953 1 0.0000 0.999 1.000 0.000
#> GSM414955 1 0.0000 0.999 1.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000
#> GSM414963 1 0.0000 0.999 1.000 0.000
#> GSM414966 2 0.0000 1.000 0.000 1.000
#> GSM414970 1 0.0000 0.999 1.000 0.000
#> GSM414972 2 0.0000 1.000 0.000 1.000
#> GSM414975 2 0.0000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.000 0.978 1.000 0 0.000
#> GSM414925 1 0.000 0.978 1.000 0 0.000
#> GSM414926 1 0.000 0.978 1.000 0 0.000
#> GSM414927 3 0.000 1.000 0.000 0 1.000
#> GSM414929 1 0.000 0.978 1.000 0 0.000
#> GSM414931 1 0.000 0.978 1.000 0 0.000
#> GSM414933 1 0.000 0.978 1.000 0 0.000
#> GSM414935 1 0.000 0.978 1.000 0 0.000
#> GSM414936 1 0.000 0.978 1.000 0 0.000
#> GSM414937 1 0.000 0.978 1.000 0 0.000
#> GSM414939 1 0.000 0.978 1.000 0 0.000
#> GSM414941 1 0.000 0.978 1.000 0 0.000
#> GSM414943 1 0.000 0.978 1.000 0 0.000
#> GSM414944 1 0.000 0.978 1.000 0 0.000
#> GSM414945 1 0.581 0.497 0.664 0 0.336
#> GSM414946 1 0.000 0.978 1.000 0 0.000
#> GSM414948 1 0.000 0.978 1.000 0 0.000
#> GSM414949 1 0.000 0.978 1.000 0 0.000
#> GSM414950 1 0.000 0.978 1.000 0 0.000
#> GSM414951 1 0.000 0.978 1.000 0 0.000
#> GSM414952 1 0.000 0.978 1.000 0 0.000
#> GSM414954 1 0.000 0.978 1.000 0 0.000
#> GSM414956 1 0.000 0.978 1.000 0 0.000
#> GSM414958 1 0.000 0.978 1.000 0 0.000
#> GSM414959 1 0.000 0.978 1.000 0 0.000
#> GSM414960 1 0.615 0.328 0.592 0 0.408
#> GSM414961 1 0.000 0.978 1.000 0 0.000
#> GSM414962 3 0.000 1.000 0.000 0 1.000
#> GSM414964 1 0.000 0.978 1.000 0 0.000
#> GSM414965 1 0.000 0.978 1.000 0 0.000
#> GSM414967 1 0.000 0.978 1.000 0 0.000
#> GSM414968 1 0.000 0.978 1.000 0 0.000
#> GSM414969 1 0.000 0.978 1.000 0 0.000
#> GSM414971 1 0.000 0.978 1.000 0 0.000
#> GSM414973 1 0.000 0.978 1.000 0 0.000
#> GSM414974 3 0.000 1.000 0.000 0 1.000
#> GSM414928 3 0.000 1.000 0.000 0 1.000
#> GSM414930 3 0.000 1.000 0.000 0 1.000
#> GSM414932 1 0.000 0.978 1.000 0 0.000
#> GSM414934 1 0.000 0.978 1.000 0 0.000
#> GSM414938 1 0.000 0.978 1.000 0 0.000
#> GSM414940 1 0.000 0.978 1.000 0 0.000
#> GSM414942 2 0.000 1.000 0.000 1 0.000
#> GSM414947 2 0.000 1.000 0.000 1 0.000
#> GSM414953 1 0.000 0.978 1.000 0 0.000
#> GSM414955 1 0.000 0.978 1.000 0 0.000
#> GSM414957 2 0.000 1.000 0.000 1 0.000
#> GSM414963 1 0.226 0.914 0.932 0 0.068
#> GSM414966 2 0.000 1.000 0.000 1 0.000
#> GSM414970 1 0.226 0.914 0.932 0 0.068
#> GSM414972 2 0.000 1.000 0.000 1 0.000
#> GSM414975 2 0.000 1.000 0.000 1 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> GSM414925 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414926 1 0.2081 0.936 0.916 0.000 0.084 0.000
#> GSM414927 4 0.0000 0.853 0.000 0.000 0.000 1.000
#> GSM414929 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> GSM414931 1 0.2011 0.938 0.920 0.000 0.080 0.000
#> GSM414933 1 0.2011 0.938 0.920 0.000 0.080 0.000
#> GSM414935 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414936 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414937 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414939 1 0.0188 0.969 0.996 0.000 0.004 0.000
#> GSM414941 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414943 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> GSM414944 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> GSM414945 3 0.2704 0.694 0.124 0.000 0.876 0.000
#> GSM414946 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414948 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> GSM414949 1 0.2216 0.930 0.908 0.000 0.092 0.000
#> GSM414950 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414951 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414952 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414954 1 0.0707 0.966 0.980 0.000 0.020 0.000
#> GSM414956 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414958 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414959 1 0.1637 0.949 0.940 0.000 0.060 0.000
#> GSM414960 3 0.0817 0.881 0.000 0.000 0.976 0.024
#> GSM414961 1 0.2081 0.936 0.916 0.000 0.084 0.000
#> GSM414962 3 0.3356 0.764 0.000 0.000 0.824 0.176
#> GSM414964 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414965 1 0.0188 0.969 0.996 0.000 0.004 0.000
#> GSM414967 1 0.3873 0.770 0.772 0.000 0.228 0.000
#> GSM414968 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414969 1 0.2011 0.938 0.920 0.000 0.080 0.000
#> GSM414971 1 0.2081 0.936 0.916 0.000 0.084 0.000
#> GSM414973 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414974 3 0.1474 0.866 0.000 0.000 0.948 0.052
#> GSM414928 4 0.0000 0.853 0.000 0.000 0.000 1.000
#> GSM414930 4 0.0000 0.853 0.000 0.000 0.000 1.000
#> GSM414932 1 0.2081 0.936 0.916 0.000 0.084 0.000
#> GSM414934 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414938 1 0.2011 0.938 0.920 0.000 0.080 0.000
#> GSM414940 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414947 4 0.4877 0.304 0.000 0.408 0.000 0.592
#> GSM414953 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414955 1 0.0000 0.969 1.000 0.000 0.000 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414963 3 0.0000 0.882 0.000 0.000 1.000 0.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414970 3 0.0000 0.882 0.000 0.000 1.000 0.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.1082 0.938 0.964 0.000 0.028 0.008 0.000
#> GSM414925 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414926 1 0.3421 0.815 0.788 0.000 0.204 0.008 0.000
#> GSM414927 5 0.0000 0.821 0.000 0.000 0.000 0.000 1.000
#> GSM414929 1 0.0771 0.941 0.976 0.000 0.020 0.004 0.000
#> GSM414931 1 0.2304 0.906 0.892 0.000 0.100 0.008 0.000
#> GSM414933 1 0.2249 0.908 0.896 0.000 0.096 0.008 0.000
#> GSM414935 1 0.0404 0.943 0.988 0.000 0.000 0.012 0.000
#> GSM414936 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414937 1 0.0290 0.943 0.992 0.000 0.000 0.008 0.000
#> GSM414939 1 0.0162 0.943 0.996 0.000 0.004 0.000 0.000
#> GSM414941 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414943 1 0.1168 0.937 0.960 0.000 0.032 0.008 0.000
#> GSM414944 1 0.1251 0.936 0.956 0.000 0.036 0.008 0.000
#> GSM414945 3 0.0000 0.930 0.000 0.000 1.000 0.000 0.000
#> GSM414946 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414948 1 0.1168 0.937 0.960 0.000 0.032 0.008 0.000
#> GSM414949 1 0.3487 0.807 0.780 0.000 0.212 0.008 0.000
#> GSM414950 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414951 1 0.0404 0.943 0.988 0.000 0.000 0.012 0.000
#> GSM414952 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414954 1 0.1168 0.937 0.960 0.000 0.032 0.008 0.000
#> GSM414956 1 0.0000 0.943 1.000 0.000 0.000 0.000 0.000
#> GSM414958 1 0.0000 0.943 1.000 0.000 0.000 0.000 0.000
#> GSM414959 1 0.1894 0.921 0.920 0.000 0.072 0.008 0.000
#> GSM414960 4 0.0703 0.970 0.000 0.000 0.024 0.976 0.000
#> GSM414961 1 0.3421 0.815 0.788 0.000 0.204 0.008 0.000
#> GSM414962 4 0.1310 0.970 0.000 0.000 0.020 0.956 0.024
#> GSM414964 1 0.0000 0.943 1.000 0.000 0.000 0.000 0.000
#> GSM414965 1 0.0162 0.943 0.996 0.000 0.000 0.004 0.000
#> GSM414967 1 0.3642 0.787 0.760 0.000 0.232 0.008 0.000
#> GSM414968 1 0.0404 0.943 0.988 0.000 0.000 0.012 0.000
#> GSM414969 1 0.2249 0.908 0.896 0.000 0.096 0.008 0.000
#> GSM414971 1 0.3421 0.815 0.788 0.000 0.204 0.008 0.000
#> GSM414973 1 0.0000 0.943 1.000 0.000 0.000 0.000 0.000
#> GSM414974 3 0.1251 0.967 0.000 0.000 0.956 0.036 0.008
#> GSM414928 5 0.0000 0.821 0.000 0.000 0.000 0.000 1.000
#> GSM414930 5 0.0000 0.821 0.000 0.000 0.000 0.000 1.000
#> GSM414932 1 0.2462 0.898 0.880 0.000 0.112 0.008 0.000
#> GSM414934 1 0.0671 0.942 0.980 0.000 0.004 0.016 0.000
#> GSM414938 1 0.2249 0.908 0.896 0.000 0.096 0.008 0.000
#> GSM414940 1 0.0671 0.942 0.980 0.000 0.004 0.016 0.000
#> GSM414942 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM414947 5 0.4201 0.311 0.000 0.408 0.000 0.000 0.592
#> GSM414953 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414955 1 0.0510 0.942 0.984 0.000 0.000 0.016 0.000
#> GSM414957 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM414963 3 0.0963 0.973 0.000 0.000 0.964 0.036 0.000
#> GSM414966 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM414970 3 0.0963 0.973 0.000 0.000 0.964 0.036 0.000
#> GSM414972 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM414975 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.0865 0.925 0.036 0.000 0.000 0 0.964 0.000
#> GSM414925 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414926 5 0.3408 0.831 0.048 0.000 0.152 0 0.800 0.000
#> GSM414927 6 0.3446 1.000 0.308 0.000 0.000 0 0.000 0.692
#> GSM414929 5 0.0713 0.926 0.028 0.000 0.000 0 0.972 0.000
#> GSM414931 5 0.2384 0.895 0.048 0.000 0.064 0 0.888 0.000
#> GSM414933 5 0.2325 0.897 0.048 0.000 0.060 0 0.892 0.000
#> GSM414935 5 0.1141 0.922 0.052 0.000 0.000 0 0.948 0.000
#> GSM414936 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414937 5 0.0363 0.928 0.012 0.000 0.000 0 0.988 0.000
#> GSM414939 5 0.0146 0.928 0.004 0.000 0.000 0 0.996 0.000
#> GSM414941 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414943 5 0.1007 0.923 0.044 0.000 0.000 0 0.956 0.000
#> GSM414944 5 0.1075 0.922 0.048 0.000 0.000 0 0.952 0.000
#> GSM414945 3 0.3584 0.685 0.004 0.000 0.688 0 0.000 0.308
#> GSM414946 5 0.1267 0.920 0.060 0.000 0.000 0 0.940 0.000
#> GSM414948 5 0.1007 0.923 0.044 0.000 0.000 0 0.956 0.000
#> GSM414949 5 0.3585 0.816 0.048 0.000 0.172 0 0.780 0.000
#> GSM414950 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414951 5 0.1075 0.923 0.048 0.000 0.000 0 0.952 0.000
#> GSM414952 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414954 5 0.1007 0.923 0.044 0.000 0.000 0 0.956 0.000
#> GSM414956 5 0.0000 0.928 0.000 0.000 0.000 0 1.000 0.000
#> GSM414958 5 0.0000 0.928 0.000 0.000 0.000 0 1.000 0.000
#> GSM414959 5 0.1934 0.909 0.044 0.000 0.040 0 0.916 0.000
#> GSM414960 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM414961 5 0.3516 0.824 0.048 0.000 0.164 0 0.788 0.000
#> GSM414962 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM414964 5 0.0000 0.928 0.000 0.000 0.000 0 1.000 0.000
#> GSM414965 5 0.0146 0.928 0.004 0.000 0.000 0 0.996 0.000
#> GSM414967 5 0.3715 0.799 0.048 0.000 0.188 0 0.764 0.000
#> GSM414968 5 0.1007 0.924 0.044 0.000 0.000 0 0.956 0.000
#> GSM414969 5 0.2325 0.897 0.048 0.000 0.060 0 0.892 0.000
#> GSM414971 5 0.3516 0.824 0.048 0.000 0.164 0 0.788 0.000
#> GSM414973 5 0.0000 0.928 0.000 0.000 0.000 0 1.000 0.000
#> GSM414974 3 0.0260 0.898 0.000 0.000 0.992 0 0.000 0.008
#> GSM414928 6 0.3446 1.000 0.308 0.000 0.000 0 0.000 0.692
#> GSM414930 6 0.3446 1.000 0.308 0.000 0.000 0 0.000 0.692
#> GSM414932 5 0.2660 0.885 0.048 0.000 0.084 0 0.868 0.000
#> GSM414934 5 0.1327 0.921 0.064 0.000 0.000 0 0.936 0.000
#> GSM414938 5 0.2325 0.897 0.048 0.000 0.060 0 0.892 0.000
#> GSM414940 5 0.1267 0.922 0.060 0.000 0.000 0 0.940 0.000
#> GSM414942 2 0.0000 0.993 0.000 1.000 0.000 0 0.000 0.000
#> GSM414947 1 0.1957 0.000 0.888 0.112 0.000 0 0.000 0.000
#> GSM414953 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414955 5 0.1327 0.918 0.064 0.000 0.000 0 0.936 0.000
#> GSM414957 2 0.0632 0.973 0.024 0.976 0.000 0 0.000 0.000
#> GSM414963 3 0.0000 0.903 0.000 0.000 1.000 0 0.000 0.000
#> GSM414966 2 0.0000 0.993 0.000 1.000 0.000 0 0.000 0.000
#> GSM414970 3 0.0000 0.903 0.000 0.000 1.000 0 0.000 0.000
#> GSM414972 2 0.0000 0.993 0.000 1.000 0.000 0 0.000 0.000
#> GSM414975 2 0.0000 0.993 0.000 1.000 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> ATC:pam 52 0.000771 2
#> ATC:pam 50 0.000485 3
#> ATC:pam 51 0.000657 4
#> ATC:pam 51 0.000877 5
#> ATC:pam 51 0.000877 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 51882 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 0.919 0.945 0.977 0.4697 0.527 0.527
#> 3 3 0.514 0.622 0.794 0.2577 0.974 0.951
#> 4 4 0.440 0.544 0.756 0.1877 0.738 0.493
#> 5 5 0.537 0.420 0.705 0.0882 0.837 0.489
#> 6 6 0.626 0.623 0.763 0.0456 0.860 0.461
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
#> GSM414924 1 0.0000 0.984 1.000 0.000
#> GSM414925 1 0.0000 0.984 1.000 0.000
#> GSM414926 1 0.0000 0.984 1.000 0.000
#> GSM414927 2 0.0000 0.959 0.000 1.000
#> GSM414929 1 0.0000 0.984 1.000 0.000
#> GSM414931 1 0.0000 0.984 1.000 0.000
#> GSM414933 1 0.9323 0.426 0.652 0.348
#> GSM414935 1 0.0000 0.984 1.000 0.000
#> GSM414936 1 0.0000 0.984 1.000 0.000
#> GSM414937 1 0.0000 0.984 1.000 0.000
#> GSM414939 1 0.0000 0.984 1.000 0.000
#> GSM414941 1 0.0000 0.984 1.000 0.000
#> GSM414943 1 0.0000 0.984 1.000 0.000
#> GSM414944 1 0.0000 0.984 1.000 0.000
#> GSM414945 2 0.0000 0.959 0.000 1.000
#> GSM414946 1 0.0000 0.984 1.000 0.000
#> GSM414948 1 0.0000 0.984 1.000 0.000
#> GSM414949 2 0.0000 0.959 0.000 1.000
#> GSM414950 1 0.0000 0.984 1.000 0.000
#> GSM414951 1 0.0000 0.984 1.000 0.000
#> GSM414952 1 0.0000 0.984 1.000 0.000
#> GSM414954 1 0.0000 0.984 1.000 0.000
#> GSM414956 1 0.0000 0.984 1.000 0.000
#> GSM414958 1 0.0000 0.984 1.000 0.000
#> GSM414959 1 0.0000 0.984 1.000 0.000
#> GSM414960 2 0.0000 0.959 0.000 1.000
#> GSM414961 1 0.0938 0.973 0.988 0.012
#> GSM414962 2 0.0000 0.959 0.000 1.000
#> GSM414964 1 0.0000 0.984 1.000 0.000
#> GSM414965 1 0.0000 0.984 1.000 0.000
#> GSM414967 2 0.6801 0.786 0.180 0.820
#> GSM414968 1 0.0000 0.984 1.000 0.000
#> GSM414969 1 0.0000 0.984 1.000 0.000
#> GSM414971 2 0.6247 0.814 0.156 0.844
#> GSM414973 1 0.0000 0.984 1.000 0.000
#> GSM414974 2 0.0000 0.959 0.000 1.000
#> GSM414928 2 0.0000 0.959 0.000 1.000
#> GSM414930 2 0.0000 0.959 0.000 1.000
#> GSM414932 1 0.0938 0.973 0.988 0.012
#> GSM414934 1 0.5059 0.864 0.888 0.112
#> GSM414938 2 0.9608 0.403 0.384 0.616
#> GSM414940 1 0.0000 0.984 1.000 0.000
#> GSM414942 2 0.0000 0.959 0.000 1.000
#> GSM414947 2 0.0000 0.959 0.000 1.000
#> GSM414953 1 0.0000 0.984 1.000 0.000
#> GSM414955 1 0.0000 0.984 1.000 0.000
#> GSM414957 2 0.0000 0.959 0.000 1.000
#> GSM414963 2 0.0000 0.959 0.000 1.000
#> GSM414966 2 0.0000 0.959 0.000 1.000
#> GSM414970 2 0.0000 0.959 0.000 1.000
#> GSM414972 2 0.0000 0.959 0.000 1.000
#> GSM414975 2 0.0000 0.959 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.1411 0.810 0.964 0.000 0.036
#> GSM414925 1 0.5621 0.746 0.692 0.000 0.308
#> GSM414926 1 0.0892 0.808 0.980 0.000 0.020
#> GSM414927 2 0.5560 0.544 0.000 0.700 0.300
#> GSM414929 1 0.0237 0.812 0.996 0.000 0.004
#> GSM414931 1 0.1289 0.804 0.968 0.000 0.032
#> GSM414933 1 0.6662 0.598 0.736 0.072 0.192
#> GSM414935 1 0.4002 0.806 0.840 0.000 0.160
#> GSM414936 1 0.5363 0.760 0.724 0.000 0.276
#> GSM414937 1 0.3619 0.811 0.864 0.000 0.136
#> GSM414939 1 0.3619 0.811 0.864 0.000 0.136
#> GSM414941 1 0.5621 0.746 0.692 0.000 0.308
#> GSM414943 1 0.0424 0.812 0.992 0.000 0.008
#> GSM414944 1 0.4172 0.725 0.840 0.004 0.156
#> GSM414945 2 0.6126 0.508 0.004 0.644 0.352
#> GSM414946 1 0.5591 0.747 0.696 0.000 0.304
#> GSM414948 1 0.0424 0.812 0.992 0.000 0.008
#> GSM414949 3 0.7729 -0.228 0.048 0.436 0.516
#> GSM414950 1 0.6168 0.681 0.588 0.000 0.412
#> GSM414951 1 0.3686 0.809 0.860 0.000 0.140
#> GSM414952 1 0.6168 0.681 0.588 0.000 0.412
#> GSM414954 1 0.0424 0.812 0.992 0.000 0.008
#> GSM414956 1 0.3619 0.811 0.864 0.000 0.136
#> GSM414958 1 0.1031 0.814 0.976 0.000 0.024
#> GSM414959 1 0.0747 0.810 0.984 0.000 0.016
#> GSM414960 2 0.5882 0.523 0.000 0.652 0.348
#> GSM414961 1 0.6990 0.531 0.728 0.108 0.164
#> GSM414962 2 0.5835 0.529 0.000 0.660 0.340
#> GSM414964 1 0.1289 0.817 0.968 0.000 0.032
#> GSM414965 1 0.1411 0.816 0.964 0.000 0.036
#> GSM414967 2 0.7736 0.269 0.052 0.548 0.400
#> GSM414968 1 0.4842 0.790 0.776 0.000 0.224
#> GSM414969 1 0.4235 0.709 0.824 0.000 0.176
#> GSM414971 2 0.7551 0.270 0.048 0.580 0.372
#> GSM414973 1 0.1031 0.814 0.976 0.000 0.024
#> GSM414974 2 0.6215 0.400 0.000 0.572 0.428
#> GSM414928 2 0.5785 0.533 0.000 0.668 0.332
#> GSM414930 2 0.5560 0.544 0.000 0.700 0.300
#> GSM414932 1 0.3551 0.787 0.868 0.000 0.132
#> GSM414934 1 0.9112 0.388 0.524 0.168 0.308
#> GSM414938 3 0.9665 0.270 0.260 0.276 0.464
#> GSM414940 1 0.6168 0.681 0.588 0.000 0.412
#> GSM414942 2 0.0000 0.501 0.000 1.000 0.000
#> GSM414947 2 0.0000 0.501 0.000 1.000 0.000
#> GSM414953 1 0.6126 0.689 0.600 0.000 0.400
#> GSM414955 1 0.6140 0.686 0.596 0.000 0.404
#> GSM414957 2 0.0237 0.499 0.000 0.996 0.004
#> GSM414963 2 0.6309 0.212 0.000 0.504 0.496
#> GSM414966 2 0.0000 0.501 0.000 1.000 0.000
#> GSM414970 2 0.6309 0.212 0.000 0.504 0.496
#> GSM414972 2 0.0000 0.501 0.000 1.000 0.000
#> GSM414975 2 0.0000 0.501 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.4139 0.601 0.816 0.000 0.144 0.040
#> GSM414925 3 0.4250 0.648 0.276 0.000 0.724 0.000
#> GSM414926 1 0.3796 0.630 0.852 0.044 0.100 0.004
#> GSM414927 2 0.4898 0.242 0.000 0.584 0.000 0.416
#> GSM414929 1 0.3182 0.635 0.876 0.000 0.096 0.028
#> GSM414931 1 0.0336 0.644 0.992 0.000 0.008 0.000
#> GSM414933 1 0.7578 0.429 0.620 0.200 0.100 0.080
#> GSM414935 3 0.5487 0.574 0.328 0.024 0.644 0.004
#> GSM414936 3 0.5427 0.577 0.336 0.004 0.640 0.020
#> GSM414937 1 0.5165 -0.304 0.512 0.000 0.484 0.004
#> GSM414939 1 0.5158 -0.270 0.524 0.000 0.472 0.004
#> GSM414941 3 0.4304 0.644 0.284 0.000 0.716 0.000
#> GSM414943 1 0.3447 0.620 0.852 0.000 0.128 0.020
#> GSM414944 1 0.5551 0.580 0.772 0.040 0.112 0.076
#> GSM414945 2 0.4296 0.650 0.004 0.824 0.060 0.112
#> GSM414946 3 0.4941 0.445 0.436 0.000 0.564 0.000
#> GSM414948 1 0.3099 0.631 0.876 0.000 0.104 0.020
#> GSM414949 2 0.3181 0.629 0.044 0.888 0.064 0.004
#> GSM414950 3 0.2401 0.712 0.092 0.004 0.904 0.000
#> GSM414951 3 0.5088 0.429 0.424 0.000 0.572 0.004
#> GSM414952 3 0.2125 0.704 0.076 0.004 0.920 0.000
#> GSM414954 1 0.3501 0.616 0.848 0.000 0.132 0.020
#> GSM414956 1 0.5161 -0.288 0.520 0.000 0.476 0.004
#> GSM414958 1 0.3841 0.638 0.832 0.004 0.144 0.020
#> GSM414959 1 0.0469 0.646 0.988 0.000 0.012 0.000
#> GSM414960 2 0.4882 0.622 0.004 0.776 0.056 0.164
#> GSM414961 1 0.6568 0.387 0.572 0.332 0.096 0.000
#> GSM414962 2 0.3356 0.620 0.000 0.824 0.000 0.176
#> GSM414964 1 0.4647 0.515 0.704 0.008 0.288 0.000
#> GSM414965 1 0.3501 0.616 0.848 0.000 0.132 0.020
#> GSM414967 2 0.6372 0.540 0.172 0.704 0.088 0.036
#> GSM414968 3 0.4088 0.673 0.232 0.004 0.764 0.000
#> GSM414969 1 0.6535 0.537 0.716 0.092 0.112 0.080
#> GSM414971 2 0.7141 0.514 0.216 0.640 0.092 0.052
#> GSM414973 1 0.3878 0.627 0.824 0.004 0.156 0.016
#> GSM414974 2 0.2385 0.661 0.000 0.920 0.028 0.052
#> GSM414928 2 0.4543 0.455 0.000 0.676 0.000 0.324
#> GSM414930 2 0.4907 0.237 0.000 0.580 0.000 0.420
#> GSM414932 1 0.6409 0.289 0.560 0.076 0.364 0.000
#> GSM414934 3 0.8370 0.202 0.252 0.172 0.516 0.060
#> GSM414938 2 0.9161 0.341 0.296 0.428 0.144 0.132
#> GSM414940 3 0.2915 0.694 0.080 0.028 0.892 0.000
#> GSM414942 4 0.2408 0.887 0.000 0.104 0.000 0.896
#> GSM414947 4 0.4277 0.723 0.000 0.280 0.000 0.720
#> GSM414953 3 0.2675 0.713 0.100 0.008 0.892 0.000
#> GSM414955 3 0.2266 0.709 0.084 0.004 0.912 0.000
#> GSM414957 4 0.4277 0.723 0.000 0.280 0.000 0.720
#> GSM414963 2 0.1732 0.651 0.004 0.948 0.040 0.008
#> GSM414966 4 0.2408 0.887 0.000 0.104 0.000 0.896
#> GSM414970 2 0.1489 0.650 0.004 0.952 0.044 0.000
#> GSM414972 4 0.2408 0.887 0.000 0.104 0.000 0.896
#> GSM414975 4 0.2408 0.887 0.000 0.104 0.000 0.896
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.6194 0.27816 0.472 0.000 0.140 0.000 0.388
#> GSM414925 3 0.4161 0.28204 0.000 0.000 0.608 0.000 0.392
#> GSM414926 1 0.6197 0.28790 0.480 0.004 0.092 0.008 0.416
#> GSM414927 4 0.6235 0.13692 0.156 0.296 0.004 0.544 0.000
#> GSM414929 5 0.5948 -0.23512 0.408 0.000 0.108 0.000 0.484
#> GSM414931 5 0.4066 0.22230 0.324 0.004 0.000 0.000 0.672
#> GSM414933 1 0.4966 0.53499 0.756 0.000 0.040 0.076 0.128
#> GSM414935 3 0.4292 0.51902 0.024 0.000 0.704 0.000 0.272
#> GSM414936 3 0.6028 -0.02986 0.116 0.000 0.468 0.000 0.416
#> GSM414937 5 0.4551 0.23112 0.016 0.000 0.368 0.000 0.616
#> GSM414939 5 0.3427 0.52769 0.012 0.000 0.192 0.000 0.796
#> GSM414941 3 0.4192 0.25815 0.000 0.000 0.596 0.000 0.404
#> GSM414943 5 0.1012 0.62307 0.020 0.000 0.012 0.000 0.968
#> GSM414944 1 0.5274 0.41633 0.612 0.000 0.040 0.012 0.336
#> GSM414945 4 0.1885 0.62170 0.032 0.020 0.012 0.936 0.000
#> GSM414946 5 0.4390 0.12156 0.004 0.000 0.428 0.000 0.568
#> GSM414948 5 0.0771 0.61468 0.020 0.004 0.000 0.000 0.976
#> GSM414949 4 0.5410 0.31285 0.332 0.000 0.056 0.604 0.008
#> GSM414950 3 0.1571 0.67779 0.000 0.000 0.936 0.004 0.060
#> GSM414951 5 0.4637 0.04817 0.012 0.000 0.452 0.000 0.536
#> GSM414952 3 0.1502 0.68000 0.000 0.000 0.940 0.004 0.056
#> GSM414954 5 0.0404 0.62473 0.000 0.000 0.012 0.000 0.988
#> GSM414956 5 0.4016 0.41686 0.012 0.000 0.272 0.000 0.716
#> GSM414958 5 0.2984 0.56401 0.124 0.004 0.016 0.000 0.856
#> GSM414959 5 0.3906 0.34743 0.292 0.004 0.000 0.000 0.704
#> GSM414960 4 0.3265 0.61556 0.088 0.040 0.012 0.860 0.000
#> GSM414961 4 0.6813 0.00293 0.420 0.000 0.080 0.440 0.060
#> GSM414962 4 0.3003 0.58362 0.064 0.040 0.016 0.880 0.000
#> GSM414964 5 0.3812 0.53845 0.024 0.000 0.204 0.000 0.772
#> GSM414965 5 0.1638 0.60890 0.064 0.004 0.000 0.000 0.932
#> GSM414967 1 0.5482 0.10273 0.572 0.000 0.016 0.372 0.040
#> GSM414968 3 0.3242 0.60341 0.000 0.000 0.784 0.000 0.216
#> GSM414969 1 0.5310 0.20406 0.508 0.000 0.040 0.004 0.448
#> GSM414971 1 0.5683 0.09693 0.560 0.004 0.008 0.372 0.056
#> GSM414973 5 0.2886 0.57012 0.116 0.004 0.016 0.000 0.864
#> GSM414974 4 0.2214 0.61651 0.028 0.000 0.052 0.916 0.004
#> GSM414928 4 0.6015 0.25417 0.156 0.248 0.004 0.592 0.000
#> GSM414930 4 0.6235 0.15858 0.144 0.292 0.008 0.556 0.000
#> GSM414932 3 0.7268 0.01158 0.268 0.000 0.492 0.052 0.188
#> GSM414934 3 0.6772 0.22950 0.300 0.000 0.544 0.072 0.084
#> GSM414938 1 0.7583 0.27188 0.444 0.000 0.104 0.328 0.124
#> GSM414940 3 0.1518 0.67793 0.004 0.000 0.944 0.004 0.048
#> GSM414942 2 0.0162 0.81732 0.000 0.996 0.000 0.004 0.000
#> GSM414947 2 0.5351 0.50141 0.068 0.624 0.004 0.304 0.000
#> GSM414953 3 0.1831 0.67664 0.000 0.000 0.920 0.004 0.076
#> GSM414955 3 0.1041 0.67252 0.000 0.000 0.964 0.004 0.032
#> GSM414957 2 0.5368 0.50353 0.068 0.620 0.004 0.308 0.000
#> GSM414963 4 0.4764 0.50822 0.224 0.000 0.052 0.716 0.008
#> GSM414966 2 0.0162 0.81732 0.000 0.996 0.000 0.004 0.000
#> GSM414970 4 0.5403 0.46991 0.280 0.000 0.052 0.648 0.020
#> GSM414972 2 0.0404 0.81657 0.000 0.988 0.000 0.012 0.000
#> GSM414975 2 0.0290 0.81668 0.000 0.992 0.000 0.008 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 1 0.3948 0.7622 0.748 0.000 0.064 0.000 0.188 0.000
#> GSM414925 3 0.3628 0.6020 0.008 0.000 0.720 0.004 0.268 0.000
#> GSM414926 1 0.4309 0.7644 0.760 0.000 0.060 0.008 0.156 0.016
#> GSM414927 4 0.1074 0.8370 0.000 0.028 0.000 0.960 0.000 0.012
#> GSM414929 1 0.4091 0.7481 0.720 0.000 0.056 0.000 0.224 0.000
#> GSM414931 1 0.4763 0.6346 0.620 0.000 0.052 0.008 0.320 0.000
#> GSM414933 1 0.2335 0.6447 0.904 0.000 0.024 0.000 0.028 0.044
#> GSM414935 3 0.3426 0.6234 0.004 0.000 0.764 0.000 0.220 0.012
#> GSM414936 3 0.4529 0.5843 0.064 0.000 0.676 0.004 0.256 0.000
#> GSM414937 3 0.3995 0.2833 0.004 0.000 0.516 0.000 0.480 0.000
#> GSM414939 5 0.1958 0.8625 0.004 0.000 0.100 0.000 0.896 0.000
#> GSM414941 3 0.3744 0.6043 0.008 0.000 0.720 0.004 0.264 0.004
#> GSM414943 5 0.2164 0.8843 0.028 0.000 0.056 0.008 0.908 0.000
#> GSM414944 1 0.2968 0.7533 0.840 0.000 0.028 0.000 0.128 0.004
#> GSM414945 6 0.4453 0.3260 0.020 0.000 0.000 0.328 0.016 0.636
#> GSM414946 3 0.4418 0.4529 0.016 0.000 0.584 0.004 0.392 0.004
#> GSM414948 5 0.2240 0.8812 0.032 0.000 0.056 0.008 0.904 0.000
#> GSM414949 6 0.3032 0.6172 0.096 0.000 0.040 0.012 0.000 0.852
#> GSM414950 3 0.1167 0.7022 0.000 0.000 0.960 0.008 0.020 0.012
#> GSM414951 3 0.4135 0.4408 0.008 0.000 0.584 0.004 0.404 0.000
#> GSM414952 3 0.0976 0.6997 0.000 0.000 0.968 0.008 0.008 0.016
#> GSM414954 5 0.1769 0.8908 0.012 0.000 0.060 0.004 0.924 0.000
#> GSM414956 5 0.3383 0.5760 0.004 0.000 0.268 0.000 0.728 0.000
#> GSM414958 5 0.2263 0.8854 0.048 0.000 0.056 0.000 0.896 0.000
#> GSM414959 1 0.4880 0.5351 0.564 0.000 0.056 0.004 0.376 0.000
#> GSM414960 6 0.6392 0.2877 0.092 0.028 0.004 0.284 0.036 0.556
#> GSM414961 6 0.5650 0.1011 0.404 0.000 0.068 0.008 0.020 0.500
#> GSM414962 6 0.6536 -0.0402 0.072 0.044 0.004 0.380 0.028 0.472
#> GSM414964 5 0.3921 0.6926 0.036 0.000 0.224 0.000 0.736 0.004
#> GSM414965 5 0.1820 0.8858 0.012 0.000 0.056 0.008 0.924 0.000
#> GSM414967 6 0.4782 0.5333 0.332 0.000 0.024 0.008 0.016 0.620
#> GSM414968 3 0.3219 0.6341 0.012 0.000 0.792 0.000 0.192 0.004
#> GSM414969 1 0.3676 0.7277 0.808 0.000 0.052 0.000 0.120 0.020
#> GSM414971 6 0.5087 0.4959 0.316 0.000 0.028 0.008 0.032 0.616
#> GSM414973 5 0.2263 0.8854 0.048 0.000 0.056 0.000 0.896 0.000
#> GSM414974 6 0.3806 0.4923 0.012 0.000 0.032 0.172 0.004 0.780
#> GSM414928 4 0.3201 0.7764 0.008 0.028 0.000 0.824 0.000 0.140
#> GSM414930 4 0.3238 0.8301 0.024 0.056 0.000 0.848 0.000 0.072
#> GSM414932 1 0.7244 0.4976 0.428 0.000 0.244 0.000 0.144 0.184
#> GSM414934 3 0.5642 0.1831 0.316 0.000 0.568 0.012 0.012 0.092
#> GSM414938 1 0.6235 0.4501 0.540 0.000 0.052 0.000 0.144 0.264
#> GSM414940 3 0.1346 0.7007 0.000 0.000 0.952 0.008 0.024 0.016
#> GSM414942 2 0.0363 0.8037 0.000 0.988 0.000 0.012 0.000 0.000
#> GSM414947 2 0.4701 0.3724 0.000 0.556 0.004 0.408 0.008 0.024
#> GSM414953 3 0.1078 0.6991 0.000 0.000 0.964 0.008 0.012 0.016
#> GSM414955 3 0.0767 0.6974 0.000 0.000 0.976 0.008 0.004 0.012
#> GSM414957 2 0.4989 0.4632 0.004 0.604 0.004 0.340 0.020 0.028
#> GSM414963 6 0.2444 0.6116 0.068 0.000 0.028 0.012 0.000 0.892
#> GSM414966 2 0.0146 0.8044 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM414970 6 0.2675 0.6116 0.080 0.000 0.024 0.012 0.004 0.880
#> GSM414972 2 0.0653 0.7996 0.004 0.980 0.000 0.004 0.000 0.012
#> GSM414975 2 0.0146 0.8044 0.004 0.996 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n tissue(p) k
#> ATC:mclust 50 0.008389 2
#> ATC:mclust 43 0.003150 3
#> ATC:mclust 39 0.000108 4
#> ATC:mclust 27 0.002740 5
#> ATC:mclust 38 0.001431 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 51882 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.967 0.987 0.4286 0.581 0.581
#> 3 3 0.572 0.609 0.771 0.3224 0.833 0.723
#> 4 4 0.462 0.475 0.683 0.1437 0.825 0.651
#> 5 5 0.459 0.429 0.719 0.0866 0.819 0.584
#> 6 6 0.498 0.499 0.711 0.0665 0.890 0.681
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
#> GSM414924 1 0.0000 0.982 1.000 0.000
#> GSM414925 1 0.0000 0.982 1.000 0.000
#> GSM414926 1 0.0000 0.982 1.000 0.000
#> GSM414927 2 0.0000 0.999 0.000 1.000
#> GSM414929 1 0.0000 0.982 1.000 0.000
#> GSM414931 1 0.0000 0.982 1.000 0.000
#> GSM414933 1 0.0000 0.982 1.000 0.000
#> GSM414935 1 0.0000 0.982 1.000 0.000
#> GSM414936 1 0.0000 0.982 1.000 0.000
#> GSM414937 1 0.0000 0.982 1.000 0.000
#> GSM414939 1 0.0000 0.982 1.000 0.000
#> GSM414941 1 0.0000 0.982 1.000 0.000
#> GSM414943 1 0.0000 0.982 1.000 0.000
#> GSM414944 1 0.0000 0.982 1.000 0.000
#> GSM414945 2 0.0000 0.999 0.000 1.000
#> GSM414946 1 0.0000 0.982 1.000 0.000
#> GSM414948 1 0.0000 0.982 1.000 0.000
#> GSM414949 1 0.5519 0.847 0.872 0.128
#> GSM414950 1 0.0000 0.982 1.000 0.000
#> GSM414951 1 0.0000 0.982 1.000 0.000
#> GSM414952 1 0.0000 0.982 1.000 0.000
#> GSM414954 1 0.0000 0.982 1.000 0.000
#> GSM414956 1 0.0000 0.982 1.000 0.000
#> GSM414958 1 0.0000 0.982 1.000 0.000
#> GSM414959 1 0.0000 0.982 1.000 0.000
#> GSM414960 2 0.0000 0.999 0.000 1.000
#> GSM414961 1 0.0938 0.972 0.988 0.012
#> GSM414962 2 0.0000 0.999 0.000 1.000
#> GSM414964 1 0.0000 0.982 1.000 0.000
#> GSM414965 1 0.0000 0.982 1.000 0.000
#> GSM414967 1 0.9977 0.121 0.528 0.472
#> GSM414968 1 0.0000 0.982 1.000 0.000
#> GSM414969 1 0.0000 0.982 1.000 0.000
#> GSM414971 1 0.1633 0.961 0.976 0.024
#> GSM414973 1 0.0000 0.982 1.000 0.000
#> GSM414974 2 0.0000 0.999 0.000 1.000
#> GSM414928 2 0.0000 0.999 0.000 1.000
#> GSM414930 2 0.0000 0.999 0.000 1.000
#> GSM414932 1 0.0000 0.982 1.000 0.000
#> GSM414934 1 0.0000 0.982 1.000 0.000
#> GSM414938 1 0.0000 0.982 1.000 0.000
#> GSM414940 1 0.0000 0.982 1.000 0.000
#> GSM414942 2 0.0000 0.999 0.000 1.000
#> GSM414947 2 0.0000 0.999 0.000 1.000
#> GSM414953 1 0.0000 0.982 1.000 0.000
#> GSM414955 1 0.0000 0.982 1.000 0.000
#> GSM414957 2 0.0000 0.999 0.000 1.000
#> GSM414963 2 0.0672 0.992 0.008 0.992
#> GSM414966 2 0.0000 0.999 0.000 1.000
#> GSM414970 2 0.0672 0.992 0.008 0.992
#> GSM414972 2 0.0000 0.999 0.000 1.000
#> GSM414975 2 0.0000 0.999 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM414924 1 0.2066 0.84104 0.940 0.060 0.000
#> GSM414925 1 0.0000 0.84361 1.000 0.000 0.000
#> GSM414926 2 0.6280 -0.42445 0.460 0.540 0.000
#> GSM414927 3 0.1031 0.68126 0.000 0.024 0.976
#> GSM414929 1 0.5058 0.77318 0.756 0.244 0.000
#> GSM414931 1 0.6111 0.64205 0.604 0.396 0.000
#> GSM414933 1 0.6126 0.63600 0.600 0.400 0.000
#> GSM414935 1 0.0000 0.84361 1.000 0.000 0.000
#> GSM414936 1 0.0424 0.84491 0.992 0.008 0.000
#> GSM414937 1 0.0892 0.84546 0.980 0.020 0.000
#> GSM414939 1 0.2878 0.83389 0.904 0.096 0.000
#> GSM414941 1 0.0000 0.84361 1.000 0.000 0.000
#> GSM414943 1 0.5968 0.68079 0.636 0.364 0.000
#> GSM414944 1 0.5968 0.68079 0.636 0.364 0.000
#> GSM414945 3 0.1163 0.65564 0.000 0.028 0.972
#> GSM414946 1 0.0000 0.84361 1.000 0.000 0.000
#> GSM414948 1 0.5968 0.68079 0.636 0.364 0.000
#> GSM414949 3 0.7156 0.22327 0.400 0.028 0.572
#> GSM414950 1 0.1620 0.82662 0.964 0.024 0.012
#> GSM414951 1 0.0237 0.84453 0.996 0.004 0.000
#> GSM414952 1 0.1751 0.82398 0.960 0.028 0.012
#> GSM414954 1 0.5216 0.76337 0.740 0.260 0.000
#> GSM414956 1 0.2711 0.83581 0.912 0.088 0.000
#> GSM414958 1 0.5706 0.72010 0.680 0.320 0.000
#> GSM414959 1 0.5968 0.68079 0.636 0.364 0.000
#> GSM414960 2 0.1163 0.35946 0.000 0.972 0.028
#> GSM414961 1 0.6235 0.52473 0.564 0.436 0.000
#> GSM414962 2 0.5529 0.33932 0.000 0.704 0.296
#> GSM414964 1 0.1031 0.84523 0.976 0.024 0.000
#> GSM414965 1 0.5098 0.77089 0.752 0.248 0.000
#> GSM414967 2 0.1643 0.35129 0.044 0.956 0.000
#> GSM414968 1 0.0237 0.84241 0.996 0.004 0.000
#> GSM414969 1 0.3482 0.82397 0.872 0.128 0.000
#> GSM414971 2 0.5327 0.13683 0.272 0.728 0.000
#> GSM414973 1 0.5397 0.75027 0.720 0.280 0.000
#> GSM414974 3 0.1031 0.68126 0.000 0.024 0.976
#> GSM414928 3 0.0592 0.67910 0.000 0.012 0.988
#> GSM414930 3 0.1163 0.67894 0.000 0.028 0.972
#> GSM414932 1 0.0237 0.84453 0.996 0.004 0.000
#> GSM414934 1 0.0237 0.84241 0.996 0.004 0.000
#> GSM414938 1 0.2301 0.82836 0.936 0.060 0.004
#> GSM414940 1 0.1267 0.83128 0.972 0.024 0.004
#> GSM414942 2 0.6291 0.24242 0.000 0.532 0.468
#> GSM414947 3 0.6026 0.00808 0.000 0.376 0.624
#> GSM414953 1 0.0892 0.83546 0.980 0.020 0.000
#> GSM414955 1 0.1031 0.83354 0.976 0.024 0.000
#> GSM414957 2 0.6280 0.24859 0.000 0.540 0.460
#> GSM414963 3 0.8688 -0.10702 0.112 0.372 0.516
#> GSM414966 2 0.6295 0.23705 0.000 0.528 0.472
#> GSM414970 2 0.6714 0.33910 0.032 0.672 0.296
#> GSM414972 2 0.6309 0.18369 0.000 0.504 0.496
#> GSM414975 2 0.6299 0.23049 0.000 0.524 0.476
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM414924 1 0.4776 0.2548 0.624 0.000 0.000 0.376
#> GSM414925 1 0.2281 0.6711 0.904 0.000 0.000 0.096
#> GSM414926 1 0.7535 -0.2180 0.468 0.148 0.008 0.376
#> GSM414927 3 0.4817 0.5741 0.000 0.388 0.612 0.000
#> GSM414929 1 0.4866 0.1795 0.596 0.000 0.000 0.404
#> GSM414931 4 0.5292 0.1355 0.480 0.008 0.000 0.512
#> GSM414933 4 0.3216 0.6044 0.124 0.004 0.008 0.864
#> GSM414935 1 0.1356 0.6702 0.960 0.000 0.032 0.008
#> GSM414936 1 0.4699 0.4232 0.676 0.000 0.004 0.320
#> GSM414937 1 0.2011 0.6773 0.920 0.000 0.000 0.080
#> GSM414939 1 0.2921 0.6411 0.860 0.000 0.000 0.140
#> GSM414941 1 0.0592 0.6815 0.984 0.000 0.000 0.016
#> GSM414943 1 0.4222 0.5032 0.728 0.000 0.000 0.272
#> GSM414944 4 0.4643 0.5025 0.344 0.000 0.000 0.656
#> GSM414945 3 0.6457 0.3081 0.000 0.100 0.604 0.296
#> GSM414946 1 0.2469 0.6647 0.892 0.000 0.000 0.108
#> GSM414948 1 0.4857 0.3902 0.668 0.008 0.000 0.324
#> GSM414949 3 0.5583 0.1951 0.320 0.008 0.648 0.024
#> GSM414950 1 0.1807 0.6582 0.940 0.000 0.052 0.008
#> GSM414951 1 0.1302 0.6835 0.956 0.000 0.000 0.044
#> GSM414952 1 0.2142 0.6574 0.928 0.000 0.056 0.016
#> GSM414954 1 0.2197 0.6806 0.916 0.000 0.004 0.080
#> GSM414956 1 0.2281 0.6722 0.904 0.000 0.000 0.096
#> GSM414958 1 0.4790 0.2814 0.620 0.000 0.000 0.380
#> GSM414959 1 0.5119 0.0338 0.556 0.000 0.004 0.440
#> GSM414960 2 0.5807 0.4452 0.000 0.596 0.040 0.364
#> GSM414961 1 0.6018 0.4069 0.740 0.128 0.040 0.092
#> GSM414962 2 0.5830 0.4784 0.000 0.620 0.048 0.332
#> GSM414964 1 0.1305 0.6809 0.960 0.000 0.004 0.036
#> GSM414965 1 0.4164 0.5128 0.736 0.000 0.000 0.264
#> GSM414967 4 0.4996 0.4238 0.056 0.192 0.000 0.752
#> GSM414968 1 0.1890 0.6569 0.936 0.000 0.056 0.008
#> GSM414969 4 0.5688 0.3000 0.464 0.000 0.024 0.512
#> GSM414971 4 0.6581 0.5799 0.200 0.128 0.012 0.660
#> GSM414973 1 0.4643 0.3783 0.656 0.000 0.000 0.344
#> GSM414974 3 0.4624 0.5997 0.000 0.340 0.660 0.000
#> GSM414928 3 0.4661 0.6027 0.000 0.348 0.652 0.000
#> GSM414930 3 0.4817 0.5790 0.000 0.388 0.612 0.000
#> GSM414932 1 0.2466 0.6514 0.916 0.000 0.056 0.028
#> GSM414934 1 0.7488 -0.2107 0.436 0.000 0.180 0.384
#> GSM414938 4 0.8180 0.4587 0.308 0.028 0.192 0.472
#> GSM414940 1 0.3377 0.5702 0.848 0.000 0.140 0.012
#> GSM414942 2 0.0336 0.6121 0.000 0.992 0.008 0.000
#> GSM414947 2 0.4277 0.2582 0.000 0.720 0.280 0.000
#> GSM414953 1 0.2142 0.6574 0.928 0.000 0.056 0.016
#> GSM414955 1 0.2222 0.6553 0.924 0.000 0.060 0.016
#> GSM414957 2 0.1677 0.6111 0.000 0.948 0.012 0.040
#> GSM414963 2 0.7683 0.2508 0.256 0.568 0.140 0.036
#> GSM414966 2 0.1557 0.5959 0.000 0.944 0.056 0.000
#> GSM414970 2 0.7477 0.4617 0.148 0.624 0.052 0.176
#> GSM414972 2 0.4049 0.3870 0.000 0.780 0.212 0.008
#> GSM414975 2 0.1637 0.5940 0.000 0.940 0.060 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM414924 1 0.5490 0.45184 0.708 0.000 0.116 0.032 0.144
#> GSM414925 1 0.2462 0.64171 0.880 0.000 0.112 0.000 0.008
#> GSM414926 1 0.6596 -0.03774 0.488 0.000 0.068 0.388 0.056
#> GSM414927 2 0.0162 0.79223 0.000 0.996 0.004 0.000 0.000
#> GSM414929 1 0.4796 0.53604 0.772 0.000 0.044 0.072 0.112
#> GSM414931 1 0.4686 0.50306 0.756 0.000 0.008 0.124 0.112
#> GSM414933 5 0.4181 0.38495 0.244 0.000 0.004 0.020 0.732
#> GSM414935 1 0.3949 0.41396 0.696 0.000 0.300 0.000 0.004
#> GSM414936 1 0.2661 0.65766 0.888 0.000 0.056 0.000 0.056
#> GSM414937 1 0.1830 0.65083 0.924 0.000 0.068 0.000 0.008
#> GSM414939 1 0.0566 0.65993 0.984 0.000 0.012 0.000 0.004
#> GSM414941 1 0.2891 0.57769 0.824 0.000 0.176 0.000 0.000
#> GSM414943 1 0.2633 0.64063 0.896 0.000 0.024 0.068 0.012
#> GSM414944 1 0.5452 -0.12100 0.536 0.000 0.020 0.028 0.416
#> GSM414945 5 0.6036 0.19701 0.000 0.116 0.340 0.004 0.540
#> GSM414946 1 0.2653 0.63689 0.880 0.000 0.096 0.000 0.024
#> GSM414948 1 0.3100 0.62186 0.868 0.000 0.020 0.092 0.020
#> GSM414949 3 0.3802 0.24734 0.036 0.120 0.824 0.000 0.020
#> GSM414950 1 0.4101 0.15118 0.628 0.000 0.372 0.000 0.000
#> GSM414951 1 0.3304 0.60897 0.816 0.000 0.168 0.000 0.016
#> GSM414952 1 0.4430 -0.10422 0.540 0.000 0.456 0.000 0.004
#> GSM414954 1 0.3308 0.59688 0.832 0.000 0.144 0.004 0.020
#> GSM414956 1 0.1740 0.65294 0.932 0.000 0.056 0.000 0.012
#> GSM414958 1 0.2629 0.63760 0.880 0.000 0.012 0.004 0.104
#> GSM414959 1 0.4059 0.57902 0.808 0.000 0.012 0.112 0.068
#> GSM414960 4 0.0865 0.49319 0.004 0.000 0.000 0.972 0.024
#> GSM414961 1 0.6952 -0.29849 0.356 0.000 0.324 0.316 0.004
#> GSM414962 4 0.3079 0.46787 0.004 0.004 0.004 0.840 0.148
#> GSM414964 1 0.3628 0.49847 0.772 0.000 0.216 0.000 0.012
#> GSM414965 1 0.0992 0.65974 0.968 0.000 0.008 0.000 0.024
#> GSM414967 5 0.7155 0.11142 0.240 0.004 0.016 0.296 0.444
#> GSM414968 3 0.4659 0.05761 0.488 0.000 0.500 0.000 0.012
#> GSM414969 5 0.7928 -0.12716 0.284 0.004 0.236 0.072 0.404
#> GSM414971 4 0.6535 -0.13122 0.392 0.000 0.008 0.448 0.152
#> GSM414973 1 0.2012 0.65504 0.920 0.000 0.020 0.000 0.060
#> GSM414974 2 0.2102 0.76742 0.000 0.916 0.068 0.004 0.012
#> GSM414928 2 0.1809 0.77133 0.000 0.928 0.060 0.000 0.012
#> GSM414930 2 0.0486 0.79309 0.000 0.988 0.004 0.004 0.004
#> GSM414932 3 0.5877 0.19819 0.416 0.000 0.500 0.076 0.008
#> GSM414934 3 0.6581 0.19290 0.180 0.000 0.444 0.004 0.372
#> GSM414938 5 0.6432 0.36168 0.272 0.004 0.176 0.004 0.544
#> GSM414940 3 0.4065 0.44642 0.264 0.000 0.720 0.000 0.016
#> GSM414942 2 0.4151 0.74518 0.000 0.652 0.000 0.344 0.004
#> GSM414947 2 0.3039 0.82095 0.000 0.808 0.000 0.192 0.000
#> GSM414953 1 0.4350 0.04759 0.588 0.000 0.408 0.000 0.004
#> GSM414955 1 0.4440 -0.15103 0.528 0.000 0.468 0.000 0.004
#> GSM414957 2 0.4434 0.61661 0.000 0.536 0.000 0.460 0.004
#> GSM414963 3 0.5943 0.00493 0.028 0.040 0.568 0.356 0.008
#> GSM414966 2 0.3508 0.80802 0.000 0.748 0.000 0.252 0.000
#> GSM414970 4 0.4762 0.27713 0.004 0.020 0.296 0.672 0.008
#> GSM414972 2 0.3391 0.82054 0.000 0.800 0.000 0.188 0.012
#> GSM414975 2 0.3561 0.80500 0.000 0.740 0.000 0.260 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM414924 5 0.5732 0.2507 0.136 0.000 0.012 0.004 0.564 0.284
#> GSM414925 5 0.4239 0.6295 0.008 0.000 0.088 0.000 0.748 0.156
#> GSM414926 5 0.7151 -0.0885 0.080 0.008 0.012 0.340 0.436 0.124
#> GSM414927 2 0.1053 0.8276 0.004 0.964 0.012 0.000 0.000 0.020
#> GSM414929 5 0.5108 0.5319 0.112 0.000 0.020 0.056 0.732 0.080
#> GSM414931 5 0.3197 0.6301 0.072 0.000 0.004 0.068 0.848 0.008
#> GSM414933 1 0.5569 0.2676 0.580 0.000 0.004 0.020 0.304 0.092
#> GSM414935 5 0.5379 -0.0206 0.016 0.000 0.352 0.000 0.552 0.080
#> GSM414936 5 0.3203 0.6764 0.080 0.000 0.052 0.000 0.848 0.020
#> GSM414937 5 0.2408 0.6580 0.012 0.000 0.108 0.000 0.876 0.004
#> GSM414939 5 0.1605 0.6935 0.016 0.000 0.044 0.004 0.936 0.000
#> GSM414941 5 0.3317 0.6205 0.004 0.000 0.156 0.000 0.808 0.032
#> GSM414943 5 0.2357 0.6869 0.004 0.000 0.032 0.048 0.904 0.012
#> GSM414944 5 0.6324 0.0663 0.204 0.000 0.008 0.032 0.544 0.212
#> GSM414945 6 0.4357 0.3755 0.132 0.036 0.060 0.004 0.000 0.768
#> GSM414946 5 0.4434 0.5978 0.028 0.000 0.060 0.000 0.740 0.172
#> GSM414948 5 0.2594 0.6634 0.020 0.000 0.008 0.072 0.888 0.012
#> GSM414949 3 0.3665 0.2723 0.000 0.032 0.784 0.000 0.012 0.172
#> GSM414950 3 0.3982 0.4090 0.000 0.000 0.536 0.000 0.460 0.004
#> GSM414951 5 0.5163 0.5284 0.044 0.000 0.180 0.004 0.692 0.080
#> GSM414952 3 0.3578 0.6074 0.000 0.000 0.660 0.000 0.340 0.000
#> GSM414954 5 0.3966 0.4937 0.028 0.000 0.236 0.008 0.728 0.000
#> GSM414956 5 0.2400 0.6533 0.008 0.000 0.116 0.004 0.872 0.000
#> GSM414958 5 0.2445 0.6491 0.120 0.000 0.008 0.000 0.868 0.004
#> GSM414959 5 0.4407 0.5521 0.160 0.000 0.012 0.064 0.752 0.012
#> GSM414960 4 0.0870 0.4511 0.012 0.000 0.012 0.972 0.000 0.004
#> GSM414961 3 0.6038 0.3353 0.004 0.000 0.428 0.356 0.212 0.000
#> GSM414962 4 0.4232 0.3963 0.200 0.012 0.012 0.744 0.000 0.032
#> GSM414964 5 0.4054 0.3712 0.024 0.000 0.284 0.004 0.688 0.000
#> GSM414965 5 0.2585 0.6766 0.068 0.000 0.048 0.004 0.880 0.000
#> GSM414967 1 0.6511 0.3251 0.532 0.016 0.008 0.212 0.216 0.016
#> GSM414968 3 0.5965 0.4918 0.040 0.000 0.508 0.008 0.372 0.072
#> GSM414969 1 0.6269 0.1286 0.548 0.000 0.248 0.060 0.144 0.000
#> GSM414971 4 0.5787 -0.1556 0.128 0.000 0.004 0.504 0.356 0.008
#> GSM414973 5 0.3567 0.6368 0.124 0.000 0.068 0.004 0.804 0.000
#> GSM414974 2 0.5052 0.6717 0.060 0.716 0.156 0.008 0.000 0.060
#> GSM414928 2 0.3765 0.7327 0.016 0.804 0.084 0.000 0.000 0.096
#> GSM414930 2 0.0767 0.8312 0.012 0.976 0.004 0.000 0.000 0.008
#> GSM414932 3 0.4255 0.6300 0.004 0.000 0.700 0.036 0.256 0.004
#> GSM414934 3 0.6497 0.4061 0.160 0.000 0.588 0.012 0.100 0.140
#> GSM414938 6 0.7304 0.1133 0.280 0.008 0.068 0.016 0.176 0.452
#> GSM414940 3 0.6045 0.3124 0.040 0.000 0.536 0.000 0.124 0.300
#> GSM414942 2 0.3816 0.7845 0.028 0.760 0.000 0.200 0.000 0.012
#> GSM414947 2 0.1913 0.8484 0.012 0.908 0.000 0.080 0.000 0.000
#> GSM414953 3 0.3899 0.5291 0.004 0.000 0.592 0.000 0.404 0.000
#> GSM414955 3 0.3446 0.6277 0.000 0.000 0.692 0.000 0.308 0.000
#> GSM414957 2 0.4058 0.6114 0.004 0.616 0.000 0.372 0.000 0.008
#> GSM414963 3 0.4663 0.1673 0.008 0.016 0.664 0.288 0.004 0.020
#> GSM414966 2 0.2526 0.8460 0.024 0.876 0.000 0.096 0.000 0.004
#> GSM414970 4 0.5186 0.2402 0.052 0.016 0.356 0.572 0.000 0.004
#> GSM414972 2 0.2507 0.8465 0.040 0.884 0.000 0.072 0.000 0.004
#> GSM414975 2 0.2622 0.8447 0.024 0.868 0.000 0.104 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 tissue(p) k
#> ATC:NMF 51 1.50e-03 2
#> ATC:NMF 38 5.98e-01 3
#> ATC:NMF 30 1.03e-02 4
#> ATC:NMF 27 7.50e-05 5
#> ATC:NMF 30 4.82e-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