Date: 2019-12-25 20:17:16 CET, cola version: 1.3.2
Document is loading...
All available functions which can be applied to this res_list
object:
res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4, anno = anno)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 21168 56
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_list),
col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
SD:skmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
SD:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:kmeans | 2 | 1.000 | 0.996 | 0.997 | ** | |
CV:skmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:kmeans | 2 | 1.000 | 0.991 | 0.993 | ** | |
MAD:mclust | 6 | 1.000 | 0.962 | 0.974 | ** | |
ATC:pam | 2 | 1.000 | 0.954 | 0.984 | ** | |
CV:mclust | 6 | 0.997 | 0.965 | 0.978 | ** | 2 |
ATC:NMF | 3 | 0.978 | 0.960 | 0.980 | ** | |
SD:mclust | 6 | 0.977 | 0.958 | 0.979 | ** | 2 |
MAD:NMF | 3 | 0.957 | 0.916 | 0.963 | ** | 2 |
CV:pam | 6 | 0.946 | 0.896 | 0.959 | * | 2 |
ATC:skmeans | 6 | 0.934 | 0.906 | 0.941 | * | 5 |
SD:hclust | 6 | 0.919 | 0.938 | 0.962 | * | |
SD:pam | 6 | 0.911 | 0.872 | 0.950 | * | 2 |
CV:hclust | 6 | 0.910 | 0.861 | 0.909 | * | |
MAD:hclust | 4 | 0.909 | 0.932 | 0.962 | * | |
MAD:skmeans | 3 | 0.909 | 0.938 | 0.964 | * | 2 |
MAD:pam | 4 | 0.904 | 0.857 | 0.940 | * | 2 |
ATC:kmeans | 3 | 0.890 | 0.902 | 0.952 | ||
ATC:hclust | 3 | 0.616 | 0.746 | 0.886 | ||
ATC:mclust | 2 | 0.556 | 0.945 | 0.944 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> MAD:NMF 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:NMF 2 0.856 0.935 0.971 0.507 0.492 0.492
#> SD:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> MAD:skmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> ATC:skmeans 2 0.795 0.858 0.947 0.505 0.494 0.494
#> SD:mclust 2 1.000 0.987 0.993 0.507 0.492 0.492
#> CV:mclust 2 1.000 0.999 1.000 0.509 0.492 0.492
#> MAD:mclust 2 0.834 0.984 0.991 0.507 0.492 0.492
#> ATC:mclust 2 0.556 0.945 0.944 0.479 0.492 0.492
#> SD:kmeans 2 1.000 1.000 1.000 0.509 0.492 0.492
#> CV:kmeans 2 1.000 0.996 0.997 0.509 0.492 0.492
#> MAD:kmeans 2 1.000 0.991 0.993 0.508 0.492 0.492
#> ATC:kmeans 2 0.734 0.890 0.951 0.496 0.501 0.501
#> SD:pam 2 1.000 0.968 0.987 0.509 0.492 0.492
#> CV:pam 2 1.000 0.971 0.988 0.509 0.491 0.491
#> MAD:pam 2 1.000 0.976 0.991 0.509 0.491 0.491
#> ATC:pam 2 1.000 0.954 0.984 0.493 0.514 0.514
#> SD:hclust 2 0.805 0.897 0.951 0.497 0.507 0.507
#> CV:hclust 2 0.805 0.894 0.947 0.501 0.492 0.492
#> MAD:hclust 2 0.805 0.902 0.957 0.500 0.507 0.507
#> ATC:hclust 2 0.671 0.867 0.933 0.344 0.725 0.725
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.885 0.890 0.953 0.246 0.865 0.730
#> CV:NMF 3 0.863 0.856 0.945 0.252 0.856 0.713
#> MAD:NMF 3 0.957 0.916 0.963 0.250 0.821 0.649
#> ATC:NMF 3 0.978 0.960 0.980 0.320 0.747 0.528
#> SD:skmeans 3 0.805 0.891 0.936 0.260 0.821 0.649
#> CV:skmeans 3 0.805 0.904 0.941 0.260 0.821 0.649
#> MAD:skmeans 3 0.909 0.938 0.964 0.249 0.834 0.674
#> ATC:skmeans 3 0.877 0.956 0.972 0.324 0.756 0.541
#> SD:mclust 3 0.761 0.905 0.936 0.238 0.882 0.760
#> CV:mclust 3 0.685 0.907 0.934 0.232 0.882 0.760
#> MAD:mclust 3 0.653 0.853 0.900 0.224 0.882 0.760
#> ATC:mclust 3 0.724 0.829 0.920 0.306 0.910 0.818
#> SD:kmeans 3 0.731 0.825 0.861 0.249 0.821 0.649
#> CV:kmeans 3 0.689 0.787 0.857 0.253 0.821 0.649
#> MAD:kmeans 3 0.686 0.831 0.895 0.248 0.821 0.649
#> ATC:kmeans 3 0.890 0.902 0.952 0.316 0.794 0.611
#> SD:pam 3 0.734 0.798 0.827 0.240 0.910 0.818
#> CV:pam 3 0.679 0.760 0.865 0.250 0.850 0.702
#> MAD:pam 3 0.747 0.846 0.894 0.237 0.885 0.769
#> ATC:pam 3 0.705 0.870 0.920 0.259 0.865 0.737
#> SD:hclust 3 0.747 0.761 0.884 0.294 0.831 0.667
#> CV:hclust 3 0.736 0.849 0.900 0.272 0.882 0.760
#> MAD:hclust 3 0.777 0.916 0.943 0.268 0.843 0.690
#> ATC:hclust 3 0.616 0.746 0.886 0.868 0.637 0.504
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.772 0.727 0.857 0.1487 0.822 0.565
#> CV:NMF 4 0.765 0.628 0.830 0.1482 0.851 0.624
#> MAD:NMF 4 0.729 0.711 0.849 0.1478 0.883 0.682
#> ATC:NMF 4 0.777 0.801 0.887 0.0818 0.916 0.760
#> SD:skmeans 4 0.798 0.855 0.926 0.1327 0.864 0.646
#> CV:skmeans 4 0.814 0.728 0.825 0.1400 0.804 0.574
#> MAD:skmeans 4 0.801 0.836 0.917 0.1374 0.875 0.674
#> ATC:skmeans 4 0.883 0.890 0.936 0.0909 0.930 0.789
#> SD:mclust 4 0.749 0.684 0.862 0.1367 0.864 0.657
#> CV:mclust 4 0.802 0.704 0.881 0.1535 0.846 0.618
#> MAD:mclust 4 0.718 0.779 0.876 0.1878 0.799 0.513
#> ATC:mclust 4 0.773 0.821 0.898 0.1126 0.918 0.796
#> SD:kmeans 4 0.664 0.754 0.809 0.1174 0.864 0.646
#> CV:kmeans 4 0.679 0.726 0.821 0.1305 0.864 0.646
#> MAD:kmeans 4 0.725 0.767 0.828 0.1146 0.962 0.894
#> ATC:kmeans 4 0.862 0.869 0.926 0.1267 0.895 0.711
#> SD:pam 4 0.817 0.765 0.896 0.1689 0.875 0.693
#> CV:pam 4 0.756 0.699 0.881 0.1698 0.805 0.522
#> MAD:pam 4 0.904 0.857 0.940 0.1418 0.901 0.745
#> ATC:pam 4 0.732 0.800 0.887 0.1674 0.876 0.686
#> SD:hclust 4 0.743 0.879 0.903 0.0982 0.945 0.839
#> CV:hclust 4 0.685 0.852 0.892 0.1372 0.910 0.760
#> MAD:hclust 4 0.909 0.932 0.962 0.0802 0.981 0.944
#> ATC:hclust 4 0.660 0.761 0.857 0.1026 0.905 0.747
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.840 0.774 0.891 0.0776 0.888 0.618
#> CV:NMF 5 0.851 0.813 0.903 0.0825 0.864 0.554
#> MAD:NMF 5 0.831 0.787 0.884 0.0721 0.903 0.673
#> ATC:NMF 5 0.761 0.662 0.837 0.0663 0.892 0.662
#> SD:skmeans 5 0.840 0.856 0.886 0.0667 0.969 0.890
#> CV:skmeans 5 0.837 0.850 0.885 0.0674 0.840 0.572
#> MAD:skmeans 5 0.835 0.868 0.880 0.0644 0.952 0.836
#> ATC:skmeans 5 0.949 0.964 0.969 0.0781 0.920 0.714
#> SD:mclust 5 0.816 0.870 0.905 0.0939 0.864 0.572
#> CV:mclust 5 0.825 0.850 0.897 0.0849 0.875 0.595
#> MAD:mclust 5 0.712 0.690 0.816 0.0454 0.875 0.595
#> ATC:mclust 5 0.792 0.783 0.891 0.1034 0.873 0.629
#> SD:kmeans 5 0.681 0.787 0.768 0.0757 0.971 0.897
#> CV:kmeans 5 0.692 0.738 0.774 0.0715 0.920 0.730
#> MAD:kmeans 5 0.726 0.716 0.753 0.0765 0.882 0.644
#> ATC:kmeans 5 0.818 0.748 0.824 0.0713 0.917 0.704
#> SD:pam 5 0.829 0.839 0.875 0.0417 0.962 0.869
#> CV:pam 5 0.817 0.703 0.825 0.0545 0.946 0.798
#> MAD:pam 5 0.811 0.883 0.926 0.0537 0.960 0.862
#> ATC:pam 5 0.851 0.774 0.888 0.1040 0.852 0.530
#> SD:hclust 5 0.867 0.944 0.951 0.0556 0.971 0.897
#> CV:hclust 5 0.824 0.904 0.923 0.0569 0.971 0.897
#> MAD:hclust 5 0.849 0.916 0.915 0.0897 0.924 0.770
#> ATC:hclust 5 0.739 0.709 0.832 0.0953 0.873 0.602
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.829 0.764 0.809 0.0408 0.938 0.733
#> CV:NMF 6 0.823 0.706 0.820 0.0407 0.945 0.754
#> MAD:NMF 6 0.810 0.727 0.834 0.0432 0.945 0.768
#> ATC:NMF 6 0.791 0.707 0.847 0.0379 0.932 0.732
#> SD:skmeans 6 0.856 0.892 0.898 0.0530 0.942 0.769
#> CV:skmeans 6 0.865 0.848 0.873 0.0500 0.896 0.594
#> MAD:skmeans 6 0.896 0.859 0.887 0.0594 0.942 0.769
#> ATC:skmeans 6 0.934 0.906 0.941 0.0261 0.977 0.891
#> SD:mclust 6 0.977 0.958 0.979 0.0409 0.977 0.890
#> CV:mclust 6 0.997 0.965 0.978 0.0338 0.977 0.890
#> MAD:mclust 6 1.000 0.962 0.974 0.0559 0.938 0.746
#> ATC:mclust 6 0.772 0.808 0.839 0.0683 0.832 0.419
#> SD:kmeans 6 0.698 0.664 0.762 0.0499 0.961 0.847
#> CV:kmeans 6 0.709 0.700 0.736 0.0508 0.930 0.704
#> MAD:kmeans 6 0.706 0.758 0.780 0.0524 0.902 0.623
#> ATC:kmeans 6 0.776 0.670 0.802 0.0415 0.927 0.687
#> SD:pam 6 0.911 0.872 0.950 0.0810 0.916 0.666
#> CV:pam 6 0.946 0.896 0.959 0.0627 0.903 0.601
#> MAD:pam 6 0.882 0.864 0.931 0.0905 0.922 0.694
#> ATC:pam 6 0.805 0.673 0.840 0.0411 0.872 0.479
#> SD:hclust 6 0.919 0.938 0.962 0.0871 0.942 0.770
#> CV:hclust 6 0.910 0.861 0.909 0.0631 0.942 0.770
#> MAD:hclust 6 0.811 0.864 0.871 0.0823 0.942 0.770
#> ATC:hclust 6 0.809 0.756 0.878 0.0474 0.964 0.844
Following heatmap plots the partition for each combination of methods and the lightness correspond to the silhouette scores for samples in each method. On top the consensus subgroup is inferred from all methods by taking the mean silhouette scores as weight.
collect_stats(res_list, k = 2)
collect_stats(res_list, k = 3)
collect_stats(res_list, k = 4)
collect_stats(res_list, k = 5)
collect_stats(res_list, k = 6)
Collect partitions from all methods:
collect_classes(res_list, k = 2)
collect_classes(res_list, k = 3)
collect_classes(res_list, k = 4)
collect_classes(res_list, k = 5)
collect_classes(res_list, k = 6)
Overlap of top rows from different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "euler")
top_rows_overlap(res_list, top_n = 2000, method = "euler")
top_rows_overlap(res_list, top_n = 3000, method = "euler")
top_rows_overlap(res_list, top_n = 4000, method = "euler")
top_rows_overlap(res_list, top_n = 5000, method = "euler")
Also visualize the correspondance of rankings between different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "correspondance")
top_rows_overlap(res_list, top_n = 2000, method = "correspondance")
top_rows_overlap(res_list, top_n = 3000, method = "correspondance")
top_rows_overlap(res_list, top_n = 4000, method = "correspondance")
top_rows_overlap(res_list, top_n = 5000, method = "correspondance")
Heatmaps of the top rows:
top_rows_heatmap(res_list, top_n = 1000)
top_rows_heatmap(res_list, top_n = 2000)
top_rows_heatmap(res_list, top_n = 3000)
top_rows_heatmap(res_list, top_n = 4000)
top_rows_heatmap(res_list, top_n = 5000)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res_list, k = 2)
#> n disease.state(p) cell.type(p) k
#> SD:NMF 56 2.95e-05 5.37e-13 2
#> CV:NMF 56 2.95e-05 5.37e-13 2
#> MAD:NMF 56 2.95e-05 5.37e-13 2
#> ATC:NMF 55 1.82e-03 8.70e-05 2
#> SD:skmeans 56 2.95e-05 5.37e-13 2
#> CV:skmeans 56 2.95e-05 5.37e-13 2
#> MAD:skmeans 56 2.95e-05 5.37e-13 2
#> ATC:skmeans 49 5.21e-05 6.13e-08 2
#> SD:mclust 56 2.95e-05 5.37e-13 2
#> CV:mclust 56 2.95e-05 5.37e-13 2
#> MAD:mclust 56 2.95e-05 5.37e-13 2
#> ATC:mclust 56 2.95e-05 5.37e-13 2
#> SD:kmeans 56 2.95e-05 5.37e-13 2
#> CV:kmeans 56 2.95e-05 5.37e-13 2
#> MAD:kmeans 56 2.95e-05 5.37e-13 2
#> ATC:kmeans 54 7.93e-05 7.47e-08 2
#> SD:pam 55 2.84e-05 8.91e-13 2
#> CV:pam 55 2.84e-05 8.91e-13 2
#> MAD:pam 55 2.84e-05 8.91e-13 2
#> ATC:pam 54 1.48e-05 2.22e-08 2
#> SD:hclust 50 1.67e-05 1.15e-11 2
#> CV:hclust 50 1.67e-05 1.15e-11 2
#> MAD:hclust 50 1.67e-05 1.15e-11 2
#> ATC:hclust 52 1.66e-02 8.99e-01 2
test_to_known_factors(res_list, k = 3)
#> n disease.state(p) cell.type(p) k
#> SD:NMF 54 3.85e-07 3.79e-11 3
#> CV:NMF 52 5.37e-07 2.95e-11 3
#> MAD:NMF 53 3.17e-07 1.69e-10 3
#> ATC:NMF 56 4.41e-08 1.22e-09 3
#> SD:skmeans 55 2.96e-07 1.72e-10 3
#> CV:skmeans 55 2.96e-07 1.72e-10 3
#> MAD:skmeans 55 2.96e-07 1.72e-10 3
#> ATC:skmeans 56 1.84e-08 1.84e-09 3
#> SD:mclust 56 2.39e-11 6.91e-13 3
#> CV:mclust 56 2.39e-11 6.91e-13 3
#> MAD:mclust 56 2.39e-11 6.91e-13 3
#> ATC:mclust 55 9.35e-06 1.14e-12 3
#> SD:kmeans 52 9.60e-07 8.90e-11 3
#> CV:kmeans 47 2.85e-05 6.22e-11 3
#> MAD:kmeans 55 2.96e-07 1.72e-10 3
#> ATC:kmeans 53 5.19e-08 5.05e-10 3
#> SD:pam 53 3.03e-06 3.10e-12 3
#> CV:pam 52 1.87e-06 5.11e-12 3
#> MAD:pam 53 3.03e-06 3.10e-12 3
#> ATC:pam 54 2.42e-07 1.57e-08 3
#> SD:hclust 40 1.79e-08 2.06e-09 3
#> CV:hclust 56 2.39e-11 6.91e-13 3
#> MAD:hclust 56 1.16e-07 1.63e-10 3
#> ATC:hclust 47 2.36e-07 5.40e-09 3
test_to_known_factors(res_list, k = 4)
#> n disease.state(p) cell.type(p) k
#> SD:NMF 42 8.31e-12 7.58e-10 4
#> CV:NMF 38 2.67e-07 5.60e-09 4
#> MAD:NMF 42 7.13e-11 1.48e-08 4
#> ATC:NMF 52 8.20e-08 5.56e-09 4
#> SD:skmeans 55 1.40e-11 6.87e-12 4
#> CV:skmeans 50 2.27e-11 1.39e-11 4
#> MAD:skmeans 53 4.79e-12 1.83e-11 4
#> ATC:skmeans 56 5.02e-08 2.31e-09 4
#> SD:mclust 42 9.71e-14 4.01e-09 4
#> CV:mclust 44 3.51e-15 8.14e-09 4
#> MAD:mclust 50 4.25e-15 7.99e-11 4
#> ATC:mclust 50 1.07e-06 7.99e-11 4
#> SD:kmeans 50 1.30e-11 7.99e-11 4
#> CV:kmeans 45 6.15e-10 9.25e-10 4
#> MAD:kmeans 55 1.20e-07 6.87e-12 4
#> ATC:kmeans 55 3.37e-07 4.23e-10 4
#> SD:pam 51 1.09e-11 4.89e-11 4
#> CV:pam 44 3.76e-11 1.51e-09 4
#> MAD:pam 53 8.62e-10 1.00e-10 4
#> ATC:pam 51 1.77e-05 8.12e-10 4
#> SD:hclust 55 9.32e-13 6.87e-12 4
#> CV:hclust 56 5.30e-12 4.20e-12 4
#> MAD:hclust 55 7.62e-08 6.87e-12 4
#> ATC:hclust 54 9.57e-07 8.76e-10 4
test_to_known_factors(res_list, k = 5)
#> n disease.state(p) cell.type(p) k
#> SD:NMF 48 1.01e-14 4.45e-08 5
#> CV:NMF 52 3.54e-14 3.71e-09 5
#> MAD:NMF 47 3.67e-13 1.98e-08 5
#> ATC:NMF 44 4.65e-07 1.51e-09 5
#> SD:skmeans 51 1.40e-11 2.23e-10 5
#> CV:skmeans 54 2.14e-11 5.26e-11 5
#> MAD:skmeans 55 1.62e-13 3.25e-11 5
#> ATC:skmeans 56 2.03e-06 5.51e-09 5
#> SD:mclust 55 1.17e-16 3.25e-11 5
#> CV:mclust 56 4.23e-17 2.01e-11 5
#> MAD:mclust 40 7.75e-12 4.33e-08 5
#> ATC:mclust 49 3.88e-06 2.11e-09 5
#> SD:kmeans 51 2.33e-12 2.23e-10 5
#> CV:kmeans 48 4.07e-13 9.44e-10 5
#> MAD:kmeans 50 6.36e-12 3.61e-10 5
#> ATC:kmeans 48 1.22e-04 3.41e-08 5
#> SD:pam 53 6.83e-13 8.52e-11 5
#> CV:pam 48 1.18e-12 9.44e-10 5
#> MAD:pam 55 3.46e-11 3.25e-11 5
#> ATC:pam 53 3.48e-05 1.33e-09 5
#> SD:hclust 55 2.83e-14 3.25e-11 5
#> CV:hclust 56 1.91e-13 2.01e-11 5
#> MAD:hclust 55 5.43e-13 3.25e-11 5
#> ATC:hclust 48 5.23e-06 4.66e-09 5
test_to_known_factors(res_list, k = 6)
#> n disease.state(p) cell.type(p) k
#> SD:NMF 50 6.72e-14 1.39e-09 6
#> CV:NMF 47 5.22e-14 5.68e-09 6
#> MAD:NMF 49 1.82e-13 2.22e-09 6
#> ATC:NMF 47 5.50e-11 1.52e-09 6
#> SD:skmeans 56 2.16e-15 8.13e-11 6
#> CV:skmeans 52 2.53e-15 5.39e-10 6
#> MAD:skmeans 55 5.59e-15 1.31e-10 6
#> ATC:skmeans 54 1.08e-07 5.20e-08 6
#> SD:mclust 56 1.08e-15 8.13e-11 6
#> CV:mclust 56 1.08e-15 8.13e-11 6
#> MAD:mclust 56 5.68e-15 8.13e-11 6
#> ATC:mclust 54 2.32e-07 1.01e-09 6
#> SD:kmeans 36 4.25e-09 2.89e-07 6
#> CV:kmeans 42 4.86e-16 1.67e-08 6
#> MAD:kmeans 47 3.71e-17 5.68e-09 6
#> ATC:kmeans 40 1.01e-04 1.07e-08 6
#> SD:pam 52 1.87e-18 5.39e-10 6
#> CV:pam 51 3.12e-19 8.65e-10 6
#> MAD:pam 53 2.80e-15 3.36e-10 6
#> ATC:pam 43 2.07e-07 3.70e-08 6
#> SD:hclust 55 6.58e-17 1.31e-10 6
#> CV:hclust 56 4.07e-16 8.13e-11 6
#> MAD:hclust 56 4.07e-16 8.13e-11 6
#> ATC:hclust 50 2.80e-06 1.39e-09 6
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "hclust"]
# you can also extract it by
# res = res_list["SD:hclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.805 0.897 0.951 0.4973 0.507 0.507
#> 3 3 0.747 0.761 0.884 0.2940 0.831 0.667
#> 4 4 0.743 0.879 0.903 0.0982 0.945 0.839
#> 5 5 0.867 0.944 0.951 0.0556 0.971 0.897
#> 6 6 0.919 0.938 0.962 0.0871 0.942 0.770
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM154423 2 0.0000 1.000 0.000 1.000
#> GSM154424 2 0.0000 1.000 0.000 1.000
#> GSM154425 1 0.9710 0.426 0.600 0.400
#> GSM154426 2 0.0000 1.000 0.000 1.000
#> GSM154427 2 0.0000 1.000 0.000 1.000
#> GSM154428 2 0.0000 1.000 0.000 1.000
#> GSM154429 2 0.0000 1.000 0.000 1.000
#> GSM154430 2 0.0000 1.000 0.000 1.000
#> GSM154434 1 0.0376 0.911 0.996 0.004
#> GSM154436 1 0.0000 0.908 1.000 0.000
#> GSM154437 1 0.0000 0.908 1.000 0.000
#> GSM154438 1 0.0000 0.908 1.000 0.000
#> GSM154439 1 0.0000 0.908 1.000 0.000
#> GSM154403 2 0.0000 1.000 0.000 1.000
#> GSM154404 2 0.0000 1.000 0.000 1.000
#> GSM154405 2 0.0000 1.000 0.000 1.000
#> GSM154406 2 0.0000 1.000 0.000 1.000
#> GSM154407 2 0.0000 1.000 0.000 1.000
#> GSM154408 1 0.9710 0.426 0.600 0.400
#> GSM154409 1 0.9710 0.426 0.600 0.400
#> GSM154410 1 0.9710 0.426 0.600 0.400
#> GSM154411 1 0.9710 0.426 0.600 0.400
#> GSM154412 1 0.9710 0.426 0.600 0.400
#> GSM154413 1 0.1184 0.916 0.984 0.016
#> GSM154414 1 0.1184 0.916 0.984 0.016
#> GSM154415 1 0.1184 0.916 0.984 0.016
#> GSM154416 1 0.1184 0.916 0.984 0.016
#> GSM154417 1 0.1184 0.916 0.984 0.016
#> GSM154418 1 0.1184 0.916 0.984 0.016
#> GSM154419 1 0.1184 0.916 0.984 0.016
#> GSM154420 1 0.0000 0.908 1.000 0.000
#> GSM154421 1 0.1184 0.916 0.984 0.016
#> GSM154422 1 0.1184 0.916 0.984 0.016
#> GSM154203 2 0.0000 1.000 0.000 1.000
#> GSM154204 2 0.0000 1.000 0.000 1.000
#> GSM154205 2 0.0000 1.000 0.000 1.000
#> GSM154206 2 0.0000 1.000 0.000 1.000
#> GSM154207 2 0.0000 1.000 0.000 1.000
#> GSM154208 2 0.0000 1.000 0.000 1.000
#> GSM154209 2 0.0000 1.000 0.000 1.000
#> GSM154210 2 0.0000 1.000 0.000 1.000
#> GSM154211 2 0.0000 1.000 0.000 1.000
#> GSM154213 2 0.0000 1.000 0.000 1.000
#> GSM154214 2 0.0000 1.000 0.000 1.000
#> GSM154217 1 0.1184 0.916 0.984 0.016
#> GSM154219 1 0.1184 0.916 0.984 0.016
#> GSM154220 1 0.1184 0.916 0.984 0.016
#> GSM154221 1 0.1184 0.916 0.984 0.016
#> GSM154223 1 0.1184 0.916 0.984 0.016
#> GSM154224 1 0.1184 0.916 0.984 0.016
#> GSM154225 1 0.1184 0.916 0.984 0.016
#> GSM154227 1 0.1184 0.916 0.984 0.016
#> GSM154228 1 0.1184 0.916 0.984 0.016
#> GSM154229 1 0.1184 0.916 0.984 0.016
#> GSM154231 1 0.1184 0.916 0.984 0.016
#> GSM154232 1 0.1184 0.916 0.984 0.016
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.000 1.000 0.000 1.0 0.000
#> GSM154424 2 0.000 1.000 0.000 1.0 0.000
#> GSM154425 3 0.613 0.283 0.000 0.4 0.600
#> GSM154426 2 0.000 1.000 0.000 1.0 0.000
#> GSM154427 2 0.000 1.000 0.000 1.0 0.000
#> GSM154428 2 0.000 1.000 0.000 1.0 0.000
#> GSM154429 2 0.000 1.000 0.000 1.0 0.000
#> GSM154430 2 0.000 1.000 0.000 1.0 0.000
#> GSM154434 1 0.617 0.251 0.588 0.0 0.412
#> GSM154436 3 0.000 0.552 0.000 0.0 1.000
#> GSM154437 3 0.000 0.552 0.000 0.0 1.000
#> GSM154438 3 0.000 0.552 0.000 0.0 1.000
#> GSM154439 3 0.000 0.552 0.000 0.0 1.000
#> GSM154403 2 0.000 1.000 0.000 1.0 0.000
#> GSM154404 2 0.000 1.000 0.000 1.0 0.000
#> GSM154405 2 0.000 1.000 0.000 1.0 0.000
#> GSM154406 2 0.000 1.000 0.000 1.0 0.000
#> GSM154407 2 0.000 1.000 0.000 1.0 0.000
#> GSM154408 3 0.613 0.283 0.000 0.4 0.600
#> GSM154409 3 0.613 0.283 0.000 0.4 0.600
#> GSM154410 3 0.613 0.283 0.000 0.4 0.600
#> GSM154411 3 0.613 0.283 0.000 0.4 0.600
#> GSM154412 3 0.613 0.283 0.000 0.4 0.600
#> GSM154413 3 0.615 0.374 0.408 0.0 0.592
#> GSM154414 3 0.615 0.374 0.408 0.0 0.592
#> GSM154415 3 0.615 0.374 0.408 0.0 0.592
#> GSM154416 3 0.615 0.374 0.408 0.0 0.592
#> GSM154417 3 0.615 0.374 0.408 0.0 0.592
#> GSM154418 3 0.614 0.378 0.404 0.0 0.596
#> GSM154419 3 0.615 0.374 0.408 0.0 0.592
#> GSM154420 3 0.000 0.552 0.000 0.0 1.000
#> GSM154421 3 0.614 0.378 0.404 0.0 0.596
#> GSM154422 3 0.614 0.378 0.404 0.0 0.596
#> GSM154203 2 0.000 1.000 0.000 1.0 0.000
#> GSM154204 2 0.000 1.000 0.000 1.0 0.000
#> GSM154205 2 0.000 1.000 0.000 1.0 0.000
#> GSM154206 2 0.000 1.000 0.000 1.0 0.000
#> GSM154207 2 0.000 1.000 0.000 1.0 0.000
#> GSM154208 2 0.000 1.000 0.000 1.0 0.000
#> GSM154209 2 0.000 1.000 0.000 1.0 0.000
#> GSM154210 2 0.000 1.000 0.000 1.0 0.000
#> GSM154211 2 0.000 1.000 0.000 1.0 0.000
#> GSM154213 2 0.000 1.000 0.000 1.0 0.000
#> GSM154214 2 0.000 1.000 0.000 1.0 0.000
#> GSM154217 1 0.000 0.960 1.000 0.0 0.000
#> GSM154219 1 0.000 0.960 1.000 0.0 0.000
#> GSM154220 1 0.000 0.960 1.000 0.0 0.000
#> GSM154221 1 0.000 0.960 1.000 0.0 0.000
#> GSM154223 1 0.000 0.960 1.000 0.0 0.000
#> GSM154224 1 0.000 0.960 1.000 0.0 0.000
#> GSM154225 1 0.000 0.960 1.000 0.0 0.000
#> GSM154227 1 0.000 0.960 1.000 0.0 0.000
#> GSM154228 1 0.000 0.960 1.000 0.0 0.000
#> GSM154229 1 0.000 0.960 1.000 0.0 0.000
#> GSM154231 1 0.000 0.960 1.000 0.0 0.000
#> GSM154232 1 0.000 0.960 1.000 0.0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154424 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154425 4 0.000 1.000 0.000 0.0 0.000 1.000
#> GSM154426 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154427 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154428 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154429 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154430 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154434 1 0.679 0.188 0.588 0.0 0.272 0.140
#> GSM154436 3 0.365 0.635 0.000 0.0 0.796 0.204
#> GSM154437 3 0.365 0.635 0.000 0.0 0.796 0.204
#> GSM154438 3 0.365 0.635 0.000 0.0 0.796 0.204
#> GSM154439 3 0.365 0.635 0.000 0.0 0.796 0.204
#> GSM154403 2 0.000 0.791 0.000 1.0 0.000 0.000
#> GSM154404 2 0.000 0.791 0.000 1.0 0.000 0.000
#> GSM154405 2 0.000 0.791 0.000 1.0 0.000 0.000
#> GSM154406 2 0.000 0.791 0.000 1.0 0.000 0.000
#> GSM154407 2 0.000 0.791 0.000 1.0 0.000 0.000
#> GSM154408 4 0.000 1.000 0.000 0.0 0.000 1.000
#> GSM154409 4 0.000 1.000 0.000 0.0 0.000 1.000
#> GSM154410 4 0.000 1.000 0.000 0.0 0.000 1.000
#> GSM154411 4 0.000 1.000 0.000 0.0 0.000 1.000
#> GSM154412 4 0.000 1.000 0.000 0.0 0.000 1.000
#> GSM154413 3 0.365 0.820 0.204 0.0 0.796 0.000
#> GSM154414 3 0.365 0.820 0.204 0.0 0.796 0.000
#> GSM154415 3 0.365 0.820 0.204 0.0 0.796 0.000
#> GSM154416 3 0.365 0.820 0.204 0.0 0.796 0.000
#> GSM154417 3 0.365 0.820 0.204 0.0 0.796 0.000
#> GSM154418 3 0.361 0.820 0.200 0.0 0.800 0.000
#> GSM154419 3 0.365 0.820 0.204 0.0 0.796 0.000
#> GSM154420 3 0.365 0.635 0.000 0.0 0.796 0.204
#> GSM154421 3 0.361 0.820 0.200 0.0 0.800 0.000
#> GSM154422 3 0.361 0.820 0.200 0.0 0.800 0.000
#> GSM154203 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154204 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154205 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154206 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154207 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154208 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154209 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154210 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154211 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154213 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154214 2 0.361 0.944 0.000 0.8 0.000 0.200
#> GSM154217 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154219 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154220 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154221 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154223 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154224 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154225 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154227 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154228 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154229 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154231 1 0.000 0.960 1.000 0.0 0.000 0.000
#> GSM154232 1 0.000 0.960 1.000 0.0 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154424 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154425 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> GSM154426 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154427 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154428 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154429 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154430 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154434 1 0.4779 0.309 0.588 0.000 0.024 0.000 0.388
#> GSM154436 5 0.0703 1.000 0.000 0.000 0.024 0.000 0.976
#> GSM154437 5 0.0703 1.000 0.000 0.000 0.024 0.000 0.976
#> GSM154438 5 0.0703 1.000 0.000 0.000 0.024 0.000 0.976
#> GSM154439 5 0.0703 1.000 0.000 0.000 0.024 0.000 0.976
#> GSM154403 2 0.3565 0.797 0.000 0.800 0.000 0.176 0.024
#> GSM154404 2 0.3565 0.797 0.000 0.800 0.000 0.176 0.024
#> GSM154405 2 0.3565 0.797 0.000 0.800 0.000 0.176 0.024
#> GSM154406 2 0.3565 0.797 0.000 0.800 0.000 0.176 0.024
#> GSM154407 2 0.3565 0.797 0.000 0.800 0.000 0.176 0.024
#> GSM154408 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> GSM154409 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> GSM154410 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> GSM154411 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> GSM154412 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> GSM154413 3 0.0162 0.998 0.004 0.000 0.996 0.000 0.000
#> GSM154414 3 0.0162 0.998 0.004 0.000 0.996 0.000 0.000
#> GSM154415 3 0.0162 0.998 0.004 0.000 0.996 0.000 0.000
#> GSM154416 3 0.0162 0.998 0.004 0.000 0.996 0.000 0.000
#> GSM154417 3 0.0162 0.998 0.004 0.000 0.996 0.000 0.000
#> GSM154418 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM154419 3 0.0162 0.998 0.004 0.000 0.996 0.000 0.000
#> GSM154420 5 0.0703 1.000 0.000 0.000 0.024 0.000 0.976
#> GSM154421 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM154422 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM154203 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154206 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154208 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154210 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154211 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154213 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.0000 0.895 0.000 1.000 0.000 0 0.0 0.000
#> GSM154424 2 0.0146 0.896 0.000 0.996 0.000 0 0.0 0.004
#> GSM154425 4 0.0000 1.000 0.000 0.000 0.000 1 0.0 0.000
#> GSM154426 2 0.0000 0.895 0.000 1.000 0.000 0 0.0 0.000
#> GSM154427 2 0.0146 0.896 0.000 0.996 0.000 0 0.0 0.004
#> GSM154428 2 0.0000 0.895 0.000 1.000 0.000 0 0.0 0.000
#> GSM154429 2 0.0146 0.896 0.000 0.996 0.000 0 0.0 0.004
#> GSM154430 2 0.0146 0.896 0.000 0.996 0.000 0 0.0 0.004
#> GSM154434 1 0.4084 0.309 0.588 0.000 0.012 0 0.4 0.000
#> GSM154436 5 0.0000 1.000 0.000 0.000 0.000 0 1.0 0.000
#> GSM154437 5 0.0000 1.000 0.000 0.000 0.000 0 1.0 0.000
#> GSM154438 5 0.0000 1.000 0.000 0.000 0.000 0 1.0 0.000
#> GSM154439 5 0.0000 1.000 0.000 0.000 0.000 0 1.0 0.000
#> GSM154403 6 0.0260 1.000 0.000 0.008 0.000 0 0.0 0.992
#> GSM154404 6 0.0260 1.000 0.000 0.008 0.000 0 0.0 0.992
#> GSM154405 6 0.0260 1.000 0.000 0.008 0.000 0 0.0 0.992
#> GSM154406 6 0.0260 1.000 0.000 0.008 0.000 0 0.0 0.992
#> GSM154407 6 0.0260 1.000 0.000 0.008 0.000 0 0.0 0.992
#> GSM154408 4 0.0000 1.000 0.000 0.000 0.000 1 0.0 0.000
#> GSM154409 4 0.0000 1.000 0.000 0.000 0.000 1 0.0 0.000
#> GSM154410 4 0.0000 1.000 0.000 0.000 0.000 1 0.0 0.000
#> GSM154411 4 0.0000 1.000 0.000 0.000 0.000 1 0.0 0.000
#> GSM154412 4 0.0000 1.000 0.000 0.000 0.000 1 0.0 0.000
#> GSM154413 3 0.0000 0.997 0.000 0.000 1.000 0 0.0 0.000
#> GSM154414 3 0.0000 0.997 0.000 0.000 1.000 0 0.0 0.000
#> GSM154415 3 0.0000 0.997 0.000 0.000 1.000 0 0.0 0.000
#> GSM154416 3 0.0000 0.997 0.000 0.000 1.000 0 0.0 0.000
#> GSM154417 3 0.0000 0.997 0.000 0.000 1.000 0 0.0 0.000
#> GSM154418 3 0.0260 0.995 0.000 0.000 0.992 0 0.0 0.008
#> GSM154419 3 0.0000 0.997 0.000 0.000 1.000 0 0.0 0.000
#> GSM154420 5 0.0000 1.000 0.000 0.000 0.000 0 1.0 0.000
#> GSM154421 3 0.0260 0.995 0.000 0.000 0.992 0 0.0 0.008
#> GSM154422 3 0.0260 0.995 0.000 0.000 0.992 0 0.0 0.008
#> GSM154203 2 0.2491 0.861 0.000 0.836 0.000 0 0.0 0.164
#> GSM154204 2 0.2854 0.842 0.000 0.792 0.000 0 0.0 0.208
#> GSM154205 2 0.2491 0.861 0.000 0.836 0.000 0 0.0 0.164
#> GSM154206 2 0.2883 0.840 0.000 0.788 0.000 0 0.0 0.212
#> GSM154207 2 0.2883 0.840 0.000 0.788 0.000 0 0.0 0.212
#> GSM154208 2 0.2883 0.840 0.000 0.788 0.000 0 0.0 0.212
#> GSM154209 2 0.0000 0.895 0.000 1.000 0.000 0 0.0 0.000
#> GSM154210 2 0.0000 0.895 0.000 1.000 0.000 0 0.0 0.000
#> GSM154211 2 0.0000 0.895 0.000 1.000 0.000 0 0.0 0.000
#> GSM154213 2 0.2883 0.840 0.000 0.788 0.000 0 0.0 0.212
#> GSM154214 2 0.2883 0.840 0.000 0.788 0.000 0 0.0 0.212
#> GSM154217 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154219 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154220 1 0.0146 0.962 0.996 0.000 0.004 0 0.0 0.000
#> GSM154221 1 0.0146 0.962 0.996 0.000 0.004 0 0.0 0.000
#> GSM154223 1 0.0146 0.962 0.996 0.000 0.004 0 0.0 0.000
#> GSM154224 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154225 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154227 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154228 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154229 1 0.0146 0.962 0.996 0.000 0.004 0 0.0 0.000
#> GSM154231 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
#> GSM154232 1 0.0000 0.964 1.000 0.000 0.000 0 0.0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> SD:hclust 50 1.67e-05 1.15e-11 2
#> SD:hclust 40 1.79e-08 2.06e-09 3
#> SD:hclust 55 9.32e-13 6.87e-12 4
#> SD:hclust 55 2.83e-14 3.25e-11 5
#> SD:hclust 55 6.58e-17 1.31e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "kmeans"]
# you can also extract it by
# res = res_list["SD:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.731 0.825 0.861 0.2494 0.821 0.649
#> 4 4 0.664 0.754 0.809 0.1174 0.864 0.646
#> 5 5 0.681 0.787 0.768 0.0757 0.971 0.897
#> 6 6 0.698 0.664 0.762 0.0499 0.961 0.847
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.3192 0.908 0.000 0.888 0.112
#> GSM154424 2 0.1411 0.946 0.000 0.964 0.036
#> GSM154425 3 0.5254 0.541 0.000 0.264 0.736
#> GSM154426 2 0.3192 0.908 0.000 0.888 0.112
#> GSM154427 2 0.1031 0.948 0.000 0.976 0.024
#> GSM154428 2 0.3192 0.908 0.000 0.888 0.112
#> GSM154429 2 0.1031 0.948 0.000 0.976 0.024
#> GSM154430 2 0.1031 0.948 0.000 0.976 0.024
#> GSM154434 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154436 3 0.4842 0.592 0.224 0.000 0.776
#> GSM154437 3 0.4842 0.592 0.224 0.000 0.776
#> GSM154438 3 0.5363 0.498 0.276 0.000 0.724
#> GSM154439 3 0.4842 0.592 0.224 0.000 0.776
#> GSM154403 2 0.2878 0.921 0.000 0.904 0.096
#> GSM154404 2 0.2878 0.921 0.000 0.904 0.096
#> GSM154405 2 0.2066 0.938 0.000 0.940 0.060
#> GSM154406 2 0.2356 0.932 0.000 0.928 0.072
#> GSM154407 2 0.2878 0.921 0.000 0.904 0.096
#> GSM154408 2 0.4504 0.831 0.000 0.804 0.196
#> GSM154409 3 0.5706 0.468 0.000 0.320 0.680
#> GSM154410 3 0.5706 0.468 0.000 0.320 0.680
#> GSM154411 3 0.5254 0.541 0.000 0.264 0.736
#> GSM154412 3 0.5706 0.468 0.000 0.320 0.680
#> GSM154413 1 0.4974 0.796 0.764 0.000 0.236
#> GSM154414 1 0.4974 0.796 0.764 0.000 0.236
#> GSM154415 1 0.4750 0.801 0.784 0.000 0.216
#> GSM154416 1 0.4750 0.801 0.784 0.000 0.216
#> GSM154417 1 0.4974 0.796 0.764 0.000 0.236
#> GSM154418 3 0.4842 0.592 0.224 0.000 0.776
#> GSM154419 1 0.4750 0.801 0.784 0.000 0.216
#> GSM154420 3 0.4842 0.592 0.224 0.000 0.776
#> GSM154421 1 0.5291 0.745 0.732 0.000 0.268
#> GSM154422 1 0.4974 0.796 0.764 0.000 0.236
#> GSM154203 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154209 2 0.2448 0.916 0.000 0.924 0.076
#> GSM154210 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154211 2 0.2448 0.916 0.000 0.924 0.076
#> GSM154213 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.948 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154221 1 0.0592 0.883 0.988 0.000 0.012
#> GSM154223 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.891 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.891 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.451 0.554 0.004 0.708 0.000 0.288
#> GSM154424 2 0.205 0.814 0.004 0.924 0.000 0.072
#> GSM154425 4 0.298 0.836 0.008 0.120 0.000 0.872
#> GSM154426 2 0.451 0.554 0.004 0.708 0.000 0.288
#> GSM154427 2 0.198 0.816 0.004 0.928 0.000 0.068
#> GSM154428 2 0.451 0.554 0.004 0.708 0.000 0.288
#> GSM154429 2 0.198 0.816 0.004 0.928 0.000 0.068
#> GSM154430 2 0.198 0.816 0.004 0.928 0.000 0.068
#> GSM154434 1 0.561 0.901 0.612 0.000 0.356 0.032
#> GSM154436 3 0.763 0.443 0.204 0.000 0.404 0.392
#> GSM154437 3 0.763 0.443 0.204 0.000 0.404 0.392
#> GSM154438 3 0.760 0.468 0.204 0.000 0.436 0.360
#> GSM154439 3 0.763 0.443 0.204 0.000 0.404 0.392
#> GSM154403 2 0.415 0.759 0.056 0.824 0.000 0.120
#> GSM154404 2 0.415 0.759 0.056 0.824 0.000 0.120
#> GSM154405 2 0.373 0.781 0.056 0.852 0.000 0.092
#> GSM154406 2 0.392 0.770 0.056 0.840 0.000 0.104
#> GSM154407 2 0.415 0.759 0.056 0.824 0.000 0.120
#> GSM154408 4 0.496 0.220 0.000 0.448 0.000 0.552
#> GSM154409 4 0.336 0.866 0.000 0.176 0.000 0.824
#> GSM154410 4 0.344 0.862 0.000 0.184 0.000 0.816
#> GSM154411 4 0.283 0.836 0.004 0.120 0.000 0.876
#> GSM154412 4 0.336 0.866 0.000 0.176 0.000 0.824
#> GSM154413 3 0.145 0.620 0.036 0.000 0.956 0.008
#> GSM154414 3 0.145 0.620 0.036 0.000 0.956 0.008
#> GSM154415 3 0.112 0.623 0.036 0.000 0.964 0.000
#> GSM154416 3 0.112 0.623 0.036 0.000 0.964 0.000
#> GSM154417 3 0.197 0.590 0.060 0.000 0.932 0.008
#> GSM154418 3 0.518 0.589 0.196 0.000 0.740 0.064
#> GSM154419 3 0.112 0.623 0.036 0.000 0.964 0.000
#> GSM154420 3 0.763 0.443 0.204 0.000 0.404 0.392
#> GSM154421 3 0.000 0.630 0.000 0.000 1.000 0.000
#> GSM154422 3 0.182 0.592 0.060 0.000 0.936 0.004
#> GSM154203 2 0.147 0.827 0.052 0.948 0.000 0.000
#> GSM154204 2 0.139 0.828 0.048 0.952 0.000 0.000
#> GSM154205 2 0.147 0.827 0.052 0.948 0.000 0.000
#> GSM154206 2 0.139 0.828 0.048 0.952 0.000 0.000
#> GSM154207 2 0.139 0.828 0.048 0.952 0.000 0.000
#> GSM154208 2 0.139 0.828 0.048 0.952 0.000 0.000
#> GSM154209 2 0.514 0.601 0.052 0.732 0.000 0.216
#> GSM154210 2 0.147 0.827 0.052 0.948 0.000 0.000
#> GSM154211 2 0.528 0.572 0.052 0.716 0.000 0.232
#> GSM154213 2 0.139 0.828 0.048 0.952 0.000 0.000
#> GSM154214 2 0.139 0.828 0.048 0.952 0.000 0.000
#> GSM154217 1 0.494 0.980 0.672 0.000 0.316 0.012
#> GSM154219 1 0.505 0.979 0.668 0.000 0.316 0.016
#> GSM154220 1 0.505 0.980 0.668 0.000 0.316 0.016
#> GSM154221 1 0.515 0.979 0.664 0.000 0.316 0.020
#> GSM154223 1 0.525 0.978 0.660 0.000 0.316 0.024
#> GSM154224 1 0.494 0.977 0.672 0.000 0.316 0.012
#> GSM154225 1 0.494 0.977 0.672 0.000 0.316 0.012
#> GSM154227 1 0.494 0.977 0.672 0.000 0.316 0.012
#> GSM154228 1 0.494 0.979 0.672 0.000 0.316 0.012
#> GSM154229 1 0.515 0.979 0.664 0.000 0.316 0.020
#> GSM154231 1 0.494 0.979 0.672 0.000 0.316 0.012
#> GSM154232 1 0.494 0.977 0.672 0.000 0.316 0.012
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.7134 0.348 0.000 0.452 0.172 0.340 0.036
#> GSM154424 2 0.5180 0.681 0.000 0.732 0.156 0.076 0.036
#> GSM154425 4 0.4334 0.912 0.000 0.048 0.020 0.784 0.148
#> GSM154426 2 0.7134 0.348 0.000 0.452 0.172 0.340 0.036
#> GSM154427 2 0.4988 0.686 0.000 0.744 0.156 0.068 0.032
#> GSM154428 2 0.7134 0.348 0.000 0.452 0.172 0.340 0.036
#> GSM154429 2 0.4988 0.686 0.000 0.744 0.156 0.068 0.032
#> GSM154430 2 0.4988 0.686 0.000 0.744 0.156 0.068 0.032
#> GSM154434 1 0.2136 0.864 0.904 0.000 0.008 0.000 0.088
#> GSM154436 5 0.1282 0.990 0.044 0.000 0.000 0.004 0.952
#> GSM154437 5 0.1121 0.990 0.044 0.000 0.000 0.000 0.956
#> GSM154438 5 0.1557 0.970 0.052 0.000 0.008 0.000 0.940
#> GSM154439 5 0.1121 0.990 0.044 0.000 0.000 0.000 0.956
#> GSM154403 2 0.5927 0.544 0.000 0.540 0.340 0.120 0.000
#> GSM154404 2 0.5927 0.544 0.000 0.540 0.340 0.120 0.000
#> GSM154405 2 0.5759 0.570 0.000 0.568 0.324 0.108 0.000
#> GSM154406 2 0.5820 0.569 0.000 0.572 0.308 0.120 0.000
#> GSM154407 2 0.5927 0.544 0.000 0.540 0.340 0.120 0.000
#> GSM154408 4 0.2813 0.774 0.000 0.168 0.000 0.832 0.000
#> GSM154409 4 0.3719 0.940 0.000 0.068 0.000 0.816 0.116
#> GSM154410 4 0.3719 0.940 0.000 0.068 0.000 0.816 0.116
#> GSM154411 4 0.3752 0.917 0.000 0.048 0.000 0.804 0.148
#> GSM154412 4 0.3719 0.940 0.000 0.068 0.000 0.816 0.116
#> GSM154413 3 0.6245 0.918 0.220 0.000 0.544 0.000 0.236
#> GSM154414 3 0.6245 0.918 0.220 0.000 0.544 0.000 0.236
#> GSM154415 3 0.6362 0.919 0.224 0.000 0.520 0.000 0.256
#> GSM154416 3 0.6362 0.919 0.224 0.000 0.520 0.000 0.256
#> GSM154417 3 0.6245 0.905 0.236 0.000 0.544 0.000 0.220
#> GSM154418 3 0.6199 0.501 0.044 0.000 0.488 0.048 0.420
#> GSM154419 3 0.6362 0.919 0.224 0.000 0.520 0.000 0.256
#> GSM154420 5 0.1282 0.990 0.044 0.000 0.000 0.004 0.952
#> GSM154421 3 0.6913 0.873 0.192 0.000 0.496 0.024 0.288
#> GSM154422 3 0.6799 0.904 0.236 0.000 0.520 0.020 0.224
#> GSM154203 2 0.1717 0.712 0.000 0.936 0.052 0.004 0.008
#> GSM154204 2 0.0162 0.722 0.000 0.996 0.000 0.004 0.000
#> GSM154205 2 0.1717 0.712 0.000 0.936 0.052 0.004 0.008
#> GSM154206 2 0.0162 0.722 0.000 0.996 0.000 0.004 0.000
#> GSM154207 2 0.1571 0.712 0.000 0.936 0.060 0.004 0.000
#> GSM154208 2 0.0000 0.722 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.4996 0.490 0.000 0.704 0.060 0.224 0.012
#> GSM154210 2 0.1717 0.712 0.000 0.936 0.052 0.004 0.008
#> GSM154211 2 0.5297 0.420 0.000 0.656 0.060 0.272 0.012
#> GSM154213 2 0.0000 0.722 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.722 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0566 0.936 0.984 0.000 0.004 0.012 0.000
#> GSM154219 1 0.1557 0.931 0.940 0.000 0.008 0.052 0.000
#> GSM154220 1 0.1386 0.933 0.952 0.000 0.016 0.032 0.000
#> GSM154221 1 0.1469 0.932 0.948 0.000 0.016 0.036 0.000
#> GSM154223 1 0.1469 0.932 0.948 0.000 0.016 0.036 0.000
#> GSM154224 1 0.2208 0.921 0.908 0.000 0.020 0.072 0.000
#> GSM154225 1 0.2208 0.921 0.908 0.000 0.020 0.072 0.000
#> GSM154227 1 0.2208 0.921 0.908 0.000 0.020 0.072 0.000
#> GSM154228 1 0.1750 0.934 0.936 0.000 0.028 0.036 0.000
#> GSM154229 1 0.1661 0.936 0.940 0.000 0.024 0.036 0.000
#> GSM154231 1 0.1750 0.934 0.936 0.000 0.028 0.036 0.000
#> GSM154232 1 0.2208 0.921 0.908 0.000 0.020 0.072 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 6 0.6786 1.0000 0.000 0.344 0.020 0.208 0.020 0.408
#> GSM154424 2 0.4591 -0.1845 0.000 0.552 0.000 0.040 0.000 0.408
#> GSM154425 4 0.2071 0.9498 0.000 0.044 0.000 0.916 0.028 0.012
#> GSM154426 6 0.6786 1.0000 0.000 0.344 0.020 0.208 0.020 0.408
#> GSM154427 2 0.4508 -0.1432 0.000 0.568 0.000 0.036 0.000 0.396
#> GSM154428 6 0.6786 1.0000 0.000 0.344 0.020 0.208 0.020 0.408
#> GSM154429 2 0.4508 -0.1432 0.000 0.568 0.000 0.036 0.000 0.396
#> GSM154430 2 0.4508 -0.1432 0.000 0.568 0.000 0.036 0.000 0.396
#> GSM154434 1 0.4634 0.8532 0.772 0.000 0.032 0.040 0.056 0.100
#> GSM154436 5 0.3755 0.9971 0.016 0.000 0.172 0.032 0.780 0.000
#> GSM154437 5 0.3755 0.9971 0.016 0.000 0.172 0.032 0.780 0.000
#> GSM154438 5 0.3789 0.9926 0.016 0.000 0.176 0.032 0.776 0.000
#> GSM154439 5 0.3825 0.9956 0.016 0.000 0.172 0.036 0.776 0.000
#> GSM154403 2 0.7686 0.1706 0.000 0.376 0.076 0.068 0.128 0.352
#> GSM154404 2 0.7686 0.1706 0.000 0.376 0.076 0.068 0.128 0.352
#> GSM154405 2 0.7473 0.1718 0.000 0.396 0.064 0.056 0.132 0.352
#> GSM154406 2 0.7596 0.1700 0.000 0.384 0.064 0.068 0.132 0.352
#> GSM154407 2 0.7686 0.1706 0.000 0.376 0.076 0.068 0.128 0.352
#> GSM154408 4 0.2602 0.9066 0.000 0.072 0.024 0.884 0.000 0.020
#> GSM154409 4 0.1952 0.9626 0.000 0.052 0.016 0.920 0.012 0.000
#> GSM154410 4 0.1655 0.9582 0.000 0.052 0.008 0.932 0.000 0.008
#> GSM154411 4 0.1713 0.9541 0.000 0.044 0.000 0.928 0.028 0.000
#> GSM154412 4 0.1500 0.9633 0.000 0.052 0.000 0.936 0.012 0.000
#> GSM154413 3 0.1910 0.9343 0.108 0.000 0.892 0.000 0.000 0.000
#> GSM154414 3 0.1910 0.9343 0.108 0.000 0.892 0.000 0.000 0.000
#> GSM154415 3 0.2358 0.9360 0.108 0.000 0.876 0.000 0.016 0.000
#> GSM154416 3 0.2358 0.9360 0.108 0.000 0.876 0.000 0.016 0.000
#> GSM154417 3 0.2048 0.9254 0.120 0.000 0.880 0.000 0.000 0.000
#> GSM154418 3 0.4259 0.7667 0.016 0.000 0.784 0.020 0.112 0.068
#> GSM154419 3 0.2501 0.9359 0.108 0.000 0.872 0.000 0.016 0.004
#> GSM154420 5 0.3755 0.9971 0.016 0.000 0.172 0.032 0.780 0.000
#> GSM154421 3 0.4291 0.8839 0.088 0.000 0.788 0.008 0.048 0.068
#> GSM154422 3 0.4073 0.8947 0.120 0.000 0.788 0.008 0.016 0.068
#> GSM154203 2 0.1858 0.3815 0.000 0.904 0.004 0.000 0.000 0.092
#> GSM154204 2 0.0000 0.4399 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154205 2 0.1806 0.3842 0.000 0.908 0.004 0.000 0.000 0.088
#> GSM154206 2 0.0000 0.4399 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.1806 0.3825 0.000 0.908 0.004 0.000 0.000 0.088
#> GSM154208 2 0.0000 0.4399 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154209 2 0.4905 0.0662 0.000 0.736 0.024 0.112 0.020 0.108
#> GSM154210 2 0.1858 0.3815 0.000 0.904 0.004 0.000 0.000 0.092
#> GSM154211 2 0.5445 -0.0662 0.000 0.676 0.024 0.172 0.020 0.108
#> GSM154213 2 0.0000 0.4399 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.4399 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154217 1 0.2230 0.8885 0.904 0.000 0.000 0.016 0.016 0.064
#> GSM154219 1 0.3111 0.8797 0.840 0.000 0.000 0.020 0.020 0.120
#> GSM154220 1 0.0665 0.8900 0.980 0.000 0.000 0.008 0.004 0.008
#> GSM154221 1 0.0551 0.8888 0.984 0.000 0.000 0.008 0.004 0.004
#> GSM154223 1 0.1390 0.8835 0.948 0.000 0.000 0.016 0.004 0.032
#> GSM154224 1 0.3816 0.8655 0.760 0.000 0.000 0.012 0.028 0.200
#> GSM154225 1 0.3816 0.8655 0.760 0.000 0.000 0.012 0.028 0.200
#> GSM154227 1 0.3816 0.8655 0.760 0.000 0.000 0.012 0.028 0.200
#> GSM154228 1 0.2545 0.8862 0.888 0.000 0.000 0.020 0.024 0.068
#> GSM154229 1 0.0976 0.8916 0.968 0.000 0.000 0.008 0.008 0.016
#> GSM154231 1 0.2545 0.8862 0.888 0.000 0.000 0.020 0.024 0.068
#> GSM154232 1 0.3816 0.8655 0.760 0.000 0.000 0.012 0.028 0.200
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> SD:kmeans 56 2.95e-05 5.37e-13 2
#> SD:kmeans 52 9.60e-07 8.90e-11 3
#> SD:kmeans 50 1.30e-11 7.99e-11 4
#> SD:kmeans 51 2.33e-12 2.23e-10 5
#> SD:kmeans 36 4.25e-09 2.89e-07 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "skmeans"]
# you can also extract it by
# res = res_list["SD:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.805 0.891 0.936 0.2597 0.821 0.649
#> 4 4 0.798 0.855 0.926 0.1327 0.864 0.646
#> 5 5 0.840 0.856 0.886 0.0667 0.969 0.890
#> 6 6 0.856 0.892 0.898 0.0530 0.942 0.769
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154424 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154425 3 0.4974 0.7577 0.000 0.236 0.764
#> GSM154426 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154427 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154428 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154429 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154434 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154436 3 0.0424 0.7823 0.008 0.000 0.992
#> GSM154437 3 0.0424 0.7823 0.008 0.000 0.992
#> GSM154438 3 0.5988 0.0781 0.368 0.000 0.632
#> GSM154439 3 0.0424 0.7823 0.008 0.000 0.992
#> GSM154403 2 0.0237 0.9962 0.000 0.996 0.004
#> GSM154404 2 0.0237 0.9962 0.000 0.996 0.004
#> GSM154405 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154406 2 0.0237 0.9962 0.000 0.996 0.004
#> GSM154407 2 0.0237 0.9962 0.000 0.996 0.004
#> GSM154408 2 0.0424 0.9940 0.000 0.992 0.008
#> GSM154409 3 0.4974 0.7577 0.000 0.236 0.764
#> GSM154410 3 0.4974 0.7577 0.000 0.236 0.764
#> GSM154411 3 0.4974 0.7577 0.000 0.236 0.764
#> GSM154412 3 0.4974 0.7577 0.000 0.236 0.764
#> GSM154413 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154414 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154415 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154416 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154417 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154418 3 0.0424 0.7823 0.008 0.000 0.992
#> GSM154419 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154420 3 0.0424 0.7823 0.008 0.000 0.992
#> GSM154421 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154422 1 0.4974 0.8151 0.764 0.000 0.236
#> GSM154203 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154209 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154210 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154211 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154213 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.9980 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.8976 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.8976 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.2973 0.841 0.000 0.856 0.000 0.144
#> GSM154424 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154425 4 0.0921 0.854 0.000 0.028 0.000 0.972
#> GSM154426 2 0.2868 0.848 0.000 0.864 0.000 0.136
#> GSM154427 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154428 2 0.2921 0.845 0.000 0.860 0.000 0.140
#> GSM154429 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154434 1 0.1978 0.913 0.928 0.000 0.068 0.004
#> GSM154436 3 0.4843 0.575 0.000 0.000 0.604 0.396
#> GSM154437 3 0.4843 0.575 0.000 0.000 0.604 0.396
#> GSM154438 3 0.4978 0.630 0.012 0.000 0.664 0.324
#> GSM154439 3 0.4843 0.575 0.000 0.000 0.604 0.396
#> GSM154403 2 0.2814 0.847 0.000 0.868 0.000 0.132
#> GSM154404 2 0.2814 0.847 0.000 0.868 0.000 0.132
#> GSM154405 2 0.0707 0.925 0.000 0.980 0.000 0.020
#> GSM154406 2 0.2814 0.847 0.000 0.868 0.000 0.132
#> GSM154407 2 0.2814 0.847 0.000 0.868 0.000 0.132
#> GSM154408 4 0.4790 0.226 0.000 0.380 0.000 0.620
#> GSM154409 4 0.0469 0.867 0.000 0.012 0.000 0.988
#> GSM154410 4 0.0469 0.867 0.000 0.012 0.000 0.988
#> GSM154411 4 0.0469 0.867 0.000 0.012 0.000 0.988
#> GSM154412 4 0.0469 0.867 0.000 0.012 0.000 0.988
#> GSM154413 3 0.0469 0.793 0.012 0.000 0.988 0.000
#> GSM154414 3 0.0336 0.793 0.008 0.000 0.992 0.000
#> GSM154415 3 0.0188 0.794 0.004 0.000 0.996 0.000
#> GSM154416 3 0.0188 0.794 0.004 0.000 0.996 0.000
#> GSM154417 3 0.3610 0.645 0.200 0.000 0.800 0.000
#> GSM154418 3 0.1389 0.784 0.000 0.000 0.952 0.048
#> GSM154419 3 0.0469 0.793 0.012 0.000 0.988 0.000
#> GSM154420 3 0.4843 0.575 0.000 0.000 0.604 0.396
#> GSM154421 3 0.0000 0.792 0.000 0.000 1.000 0.000
#> GSM154422 3 0.3123 0.690 0.156 0.000 0.844 0.000
#> GSM154203 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154209 2 0.2921 0.845 0.000 0.860 0.000 0.140
#> GSM154210 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154211 2 0.2973 0.841 0.000 0.856 0.000 0.144
#> GSM154213 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.934 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.993 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.5664 0.423 0.000 0.560 0.000 0.348 0.092
#> GSM154424 2 0.1121 0.811 0.000 0.956 0.000 0.000 0.044
#> GSM154425 4 0.0290 0.967 0.000 0.000 0.000 0.992 0.008
#> GSM154426 2 0.5600 0.479 0.000 0.588 0.000 0.316 0.096
#> GSM154427 2 0.1121 0.811 0.000 0.956 0.000 0.000 0.044
#> GSM154428 2 0.5630 0.466 0.000 0.580 0.000 0.324 0.096
#> GSM154429 2 0.1121 0.811 0.000 0.956 0.000 0.000 0.044
#> GSM154430 2 0.1121 0.811 0.000 0.956 0.000 0.000 0.044
#> GSM154434 1 0.2929 0.816 0.840 0.000 0.008 0.000 0.152
#> GSM154436 5 0.5358 0.959 0.000 0.000 0.248 0.104 0.648
#> GSM154437 5 0.5358 0.959 0.000 0.000 0.248 0.104 0.648
#> GSM154438 5 0.5264 0.951 0.000 0.000 0.256 0.092 0.652
#> GSM154439 5 0.5358 0.959 0.000 0.000 0.248 0.104 0.648
#> GSM154403 2 0.4297 0.673 0.000 0.692 0.000 0.020 0.288
#> GSM154404 2 0.4297 0.673 0.000 0.692 0.000 0.020 0.288
#> GSM154405 2 0.3884 0.684 0.000 0.708 0.000 0.004 0.288
#> GSM154406 2 0.4297 0.673 0.000 0.692 0.000 0.020 0.288
#> GSM154407 2 0.4297 0.673 0.000 0.692 0.000 0.020 0.288
#> GSM154408 4 0.2409 0.869 0.000 0.032 0.000 0.900 0.068
#> GSM154409 4 0.0000 0.971 0.000 0.000 0.000 1.000 0.000
#> GSM154410 4 0.0000 0.971 0.000 0.000 0.000 1.000 0.000
#> GSM154411 4 0.0162 0.969 0.000 0.000 0.000 0.996 0.004
#> GSM154412 4 0.0000 0.971 0.000 0.000 0.000 1.000 0.000
#> GSM154413 3 0.0162 0.990 0.004 0.000 0.996 0.000 0.000
#> GSM154414 3 0.0162 0.990 0.004 0.000 0.996 0.000 0.000
#> GSM154415 3 0.0162 0.990 0.004 0.000 0.996 0.000 0.000
#> GSM154416 3 0.0162 0.990 0.004 0.000 0.996 0.000 0.000
#> GSM154417 3 0.0703 0.965 0.024 0.000 0.976 0.000 0.000
#> GSM154418 5 0.4264 0.779 0.000 0.000 0.376 0.004 0.620
#> GSM154419 3 0.0162 0.990 0.004 0.000 0.996 0.000 0.000
#> GSM154420 5 0.5358 0.959 0.000 0.000 0.248 0.104 0.648
#> GSM154421 3 0.0162 0.980 0.000 0.000 0.996 0.000 0.004
#> GSM154422 3 0.0510 0.977 0.016 0.000 0.984 0.000 0.000
#> GSM154203 2 0.1341 0.802 0.000 0.944 0.000 0.000 0.056
#> GSM154204 2 0.0000 0.814 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.1341 0.802 0.000 0.944 0.000 0.000 0.056
#> GSM154206 2 0.0000 0.814 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0703 0.810 0.000 0.976 0.000 0.000 0.024
#> GSM154208 2 0.0000 0.814 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.5160 0.445 0.000 0.608 0.000 0.336 0.056
#> GSM154210 2 0.1341 0.802 0.000 0.944 0.000 0.000 0.056
#> GSM154211 2 0.5240 0.397 0.000 0.584 0.000 0.360 0.056
#> GSM154213 2 0.0000 0.814 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.814 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0162 0.985 0.996 0.000 0.000 0.000 0.004
#> GSM154220 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0162 0.985 0.996 0.000 0.000 0.000 0.004
#> GSM154225 1 0.0162 0.985 0.996 0.000 0.000 0.000 0.004
#> GSM154227 1 0.0162 0.985 0.996 0.000 0.000 0.000 0.004
#> GSM154228 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.986 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.5499 0.674 0.000 0.680 0.004 0.088 0.144 0.084
#> GSM154424 2 0.5245 0.660 0.000 0.612 0.004 0.000 0.136 0.248
#> GSM154425 4 0.0363 0.987 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM154426 2 0.5406 0.680 0.000 0.688 0.004 0.080 0.144 0.084
#> GSM154427 2 0.5284 0.659 0.000 0.604 0.004 0.000 0.136 0.256
#> GSM154428 2 0.5453 0.677 0.000 0.684 0.004 0.084 0.144 0.084
#> GSM154429 2 0.5284 0.659 0.000 0.604 0.004 0.000 0.136 0.256
#> GSM154430 2 0.5284 0.659 0.000 0.604 0.004 0.000 0.136 0.256
#> GSM154434 1 0.3043 0.750 0.796 0.000 0.004 0.000 0.196 0.004
#> GSM154436 5 0.2826 0.975 0.000 0.000 0.128 0.028 0.844 0.000
#> GSM154437 5 0.2826 0.975 0.000 0.000 0.128 0.028 0.844 0.000
#> GSM154438 5 0.2826 0.975 0.000 0.000 0.128 0.028 0.844 0.000
#> GSM154439 5 0.2826 0.975 0.000 0.000 0.128 0.028 0.844 0.000
#> GSM154403 6 0.1501 0.997 0.000 0.076 0.000 0.000 0.000 0.924
#> GSM154404 6 0.1501 0.997 0.000 0.076 0.000 0.000 0.000 0.924
#> GSM154405 6 0.1501 0.997 0.000 0.076 0.000 0.000 0.000 0.924
#> GSM154406 6 0.1610 0.990 0.000 0.084 0.000 0.000 0.000 0.916
#> GSM154407 6 0.1501 0.997 0.000 0.076 0.000 0.000 0.000 0.924
#> GSM154408 4 0.0964 0.952 0.000 0.012 0.000 0.968 0.016 0.004
#> GSM154409 4 0.0260 0.989 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM154410 4 0.0260 0.989 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM154411 4 0.0363 0.987 0.000 0.000 0.000 0.988 0.012 0.000
#> GSM154412 4 0.0260 0.989 0.000 0.000 0.000 0.992 0.008 0.000
#> GSM154413 3 0.0405 0.972 0.004 0.000 0.988 0.000 0.008 0.000
#> GSM154414 3 0.0405 0.972 0.004 0.000 0.988 0.000 0.008 0.000
#> GSM154415 3 0.0405 0.972 0.004 0.000 0.988 0.000 0.008 0.000
#> GSM154416 3 0.0405 0.972 0.004 0.000 0.988 0.000 0.008 0.000
#> GSM154417 3 0.0951 0.959 0.020 0.000 0.968 0.000 0.004 0.008
#> GSM154418 5 0.3714 0.862 0.000 0.000 0.196 0.000 0.760 0.044
#> GSM154419 3 0.0146 0.970 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM154420 5 0.2826 0.975 0.000 0.000 0.128 0.028 0.844 0.000
#> GSM154421 3 0.1934 0.920 0.000 0.000 0.916 0.000 0.040 0.044
#> GSM154422 3 0.1908 0.936 0.020 0.000 0.924 0.000 0.012 0.044
#> GSM154203 2 0.0777 0.783 0.000 0.972 0.000 0.004 0.000 0.024
#> GSM154204 2 0.2048 0.777 0.000 0.880 0.000 0.000 0.000 0.120
#> GSM154205 2 0.0713 0.784 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM154206 2 0.2092 0.775 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM154207 2 0.0508 0.787 0.000 0.984 0.000 0.000 0.004 0.012
#> GSM154208 2 0.2378 0.765 0.000 0.848 0.000 0.000 0.000 0.152
#> GSM154209 2 0.1728 0.751 0.000 0.924 0.000 0.064 0.004 0.008
#> GSM154210 2 0.0858 0.784 0.000 0.968 0.000 0.004 0.000 0.028
#> GSM154211 2 0.2013 0.744 0.000 0.908 0.000 0.076 0.008 0.008
#> GSM154213 2 0.2416 0.763 0.000 0.844 0.000 0.000 0.000 0.156
#> GSM154214 2 0.2454 0.760 0.000 0.840 0.000 0.000 0.000 0.160
#> GSM154217 1 0.0146 0.979 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154219 1 0.0146 0.979 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154220 1 0.0260 0.980 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM154221 1 0.0146 0.981 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154223 1 0.0146 0.981 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154224 1 0.0000 0.981 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.981 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.981 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0146 0.981 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154229 1 0.0146 0.981 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154231 1 0.0146 0.981 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154232 1 0.0000 0.981 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> SD:skmeans 56 2.95e-05 5.37e-13 2
#> SD:skmeans 55 2.96e-07 1.72e-10 3
#> SD:skmeans 55 1.40e-11 6.87e-12 4
#> SD:skmeans 51 1.40e-11 2.23e-10 5
#> SD:skmeans 56 2.16e-15 8.13e-11 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "pam"]
# you can also extract it by
# res = res_list["SD:pam"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.968 0.987 0.5089 0.492 0.492
#> 3 3 0.734 0.798 0.827 0.2400 0.910 0.818
#> 4 4 0.817 0.765 0.896 0.1689 0.875 0.693
#> 5 5 0.829 0.839 0.875 0.0417 0.962 0.869
#> 6 6 0.911 0.872 0.950 0.0810 0.916 0.666
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
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
#> GSM154423 2 0.000 0.975 0.000 1.000
#> GSM154424 2 0.000 0.975 0.000 1.000
#> GSM154425 2 0.634 0.808 0.160 0.840
#> GSM154426 2 0.000 0.975 0.000 1.000
#> GSM154427 2 0.000 0.975 0.000 1.000
#> GSM154428 2 0.000 0.975 0.000 1.000
#> GSM154429 2 0.000 0.975 0.000 1.000
#> GSM154430 2 0.000 0.975 0.000 1.000
#> GSM154434 1 0.000 1.000 1.000 0.000
#> GSM154436 1 0.000 1.000 1.000 0.000
#> GSM154437 1 0.000 1.000 1.000 0.000
#> GSM154438 1 0.000 1.000 1.000 0.000
#> GSM154439 1 0.000 1.000 1.000 0.000
#> GSM154403 2 0.000 0.975 0.000 1.000
#> GSM154404 2 0.000 0.975 0.000 1.000
#> GSM154405 2 0.000 0.975 0.000 1.000
#> GSM154406 2 0.000 0.975 0.000 1.000
#> GSM154407 2 0.000 0.975 0.000 1.000
#> GSM154408 2 0.000 0.975 0.000 1.000
#> GSM154409 2 0.443 0.888 0.092 0.908
#> GSM154410 2 0.000 0.975 0.000 1.000
#> GSM154411 2 0.994 0.189 0.456 0.544
#> GSM154412 2 0.000 0.975 0.000 1.000
#> GSM154413 1 0.000 1.000 1.000 0.000
#> GSM154414 1 0.000 1.000 1.000 0.000
#> GSM154415 1 0.000 1.000 1.000 0.000
#> GSM154416 1 0.000 1.000 1.000 0.000
#> GSM154417 1 0.000 1.000 1.000 0.000
#> GSM154418 1 0.000 1.000 1.000 0.000
#> GSM154419 1 0.000 1.000 1.000 0.000
#> GSM154420 1 0.000 1.000 1.000 0.000
#> GSM154421 1 0.000 1.000 1.000 0.000
#> GSM154422 1 0.000 1.000 1.000 0.000
#> GSM154203 2 0.000 0.975 0.000 1.000
#> GSM154204 2 0.000 0.975 0.000 1.000
#> GSM154205 2 0.000 0.975 0.000 1.000
#> GSM154206 2 0.000 0.975 0.000 1.000
#> GSM154207 2 0.000 0.975 0.000 1.000
#> GSM154208 2 0.000 0.975 0.000 1.000
#> GSM154209 2 0.000 0.975 0.000 1.000
#> GSM154210 2 0.000 0.975 0.000 1.000
#> GSM154211 2 0.000 0.975 0.000 1.000
#> GSM154213 2 0.000 0.975 0.000 1.000
#> GSM154214 2 0.000 0.975 0.000 1.000
#> GSM154217 1 0.000 1.000 1.000 0.000
#> GSM154219 1 0.000 1.000 1.000 0.000
#> GSM154220 1 0.000 1.000 1.000 0.000
#> GSM154221 1 0.000 1.000 1.000 0.000
#> GSM154223 1 0.000 1.000 1.000 0.000
#> GSM154224 1 0.000 1.000 1.000 0.000
#> GSM154225 1 0.000 1.000 1.000 0.000
#> GSM154227 1 0.000 1.000 1.000 0.000
#> GSM154228 1 0.000 1.000 1.000 0.000
#> GSM154229 1 0.000 1.000 1.000 0.000
#> GSM154231 1 0.000 1.000 1.000 0.000
#> GSM154232 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.312 0.8708 0.000 0.892 0.108
#> GSM154424 2 0.280 0.8882 0.000 0.908 0.092
#> GSM154425 3 0.615 0.9394 0.000 0.408 0.592
#> GSM154426 2 0.312 0.8708 0.000 0.892 0.108
#> GSM154427 2 0.116 0.9207 0.000 0.972 0.028
#> GSM154428 2 0.312 0.8708 0.000 0.892 0.108
#> GSM154429 2 0.280 0.8882 0.000 0.908 0.092
#> GSM154430 2 0.280 0.8882 0.000 0.908 0.092
#> GSM154434 1 0.175 0.7448 0.952 0.000 0.048
#> GSM154436 1 0.630 0.0465 0.516 0.000 0.484
#> GSM154437 1 0.568 0.4017 0.684 0.000 0.316
#> GSM154438 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154439 1 0.460 0.5601 0.796 0.000 0.204
#> GSM154403 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154404 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154405 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154406 2 0.312 0.8708 0.000 0.892 0.108
#> GSM154407 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154408 3 0.615 0.9394 0.000 0.408 0.592
#> GSM154409 3 0.615 0.9394 0.000 0.408 0.592
#> GSM154410 3 0.615 0.9394 0.000 0.408 0.592
#> GSM154411 3 0.849 0.7469 0.132 0.276 0.592
#> GSM154412 3 0.615 0.9394 0.000 0.408 0.592
#> GSM154413 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154414 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154415 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154416 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154417 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154418 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154419 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154420 1 0.597 0.3168 0.636 0.000 0.364
#> GSM154421 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154422 1 0.000 0.7436 1.000 0.000 0.000
#> GSM154203 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154204 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154205 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154206 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154207 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154208 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154209 2 0.263 0.8935 0.000 0.916 0.084
#> GSM154210 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154211 2 0.280 0.8882 0.000 0.908 0.092
#> GSM154213 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154214 2 0.000 0.9301 0.000 1.000 0.000
#> GSM154217 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154219 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154220 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154221 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154223 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154224 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154225 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154227 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154228 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154229 1 0.614 0.7328 0.596 0.000 0.404
#> GSM154231 1 0.615 0.7325 0.592 0.000 0.408
#> GSM154232 1 0.615 0.7325 0.592 0.000 0.408
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.4925 0.5421 0.000 0.572 0.000 0.428
#> GSM154424 2 0.4679 0.6415 0.000 0.648 0.000 0.352
#> GSM154425 4 0.0000 0.9082 0.000 0.000 0.000 1.000
#> GSM154426 2 0.4925 0.5421 0.000 0.572 0.000 0.428
#> GSM154427 2 0.4585 0.6578 0.000 0.668 0.000 0.332
#> GSM154428 2 0.4925 0.5421 0.000 0.572 0.000 0.428
#> GSM154429 2 0.4679 0.6415 0.000 0.648 0.000 0.352
#> GSM154430 2 0.4679 0.6415 0.000 0.648 0.000 0.352
#> GSM154434 3 0.1118 0.8208 0.036 0.000 0.964 0.000
#> GSM154436 4 0.4933 0.0323 0.000 0.000 0.432 0.568
#> GSM154437 3 0.4843 0.3074 0.000 0.000 0.604 0.396
#> GSM154438 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154439 3 0.3649 0.6473 0.000 0.000 0.796 0.204
#> GSM154403 2 0.0188 0.8454 0.000 0.996 0.000 0.004
#> GSM154404 2 0.2081 0.8162 0.000 0.916 0.000 0.084
#> GSM154405 2 0.0188 0.8454 0.000 0.996 0.000 0.004
#> GSM154406 2 0.4585 0.6520 0.000 0.668 0.000 0.332
#> GSM154407 2 0.0469 0.8442 0.000 0.988 0.000 0.012
#> GSM154408 4 0.0000 0.9082 0.000 0.000 0.000 1.000
#> GSM154409 4 0.0000 0.9082 0.000 0.000 0.000 1.000
#> GSM154410 4 0.0000 0.9082 0.000 0.000 0.000 1.000
#> GSM154411 4 0.0000 0.9082 0.000 0.000 0.000 1.000
#> GSM154412 4 0.0000 0.9082 0.000 0.000 0.000 1.000
#> GSM154413 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154414 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154415 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154416 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154417 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154418 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154419 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154420 3 0.4955 0.1846 0.000 0.000 0.556 0.444
#> GSM154421 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154422 3 0.0000 0.8444 0.000 0.000 1.000 0.000
#> GSM154203 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154209 2 0.0188 0.8459 0.000 0.996 0.000 0.004
#> GSM154210 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154211 2 0.0817 0.8400 0.000 0.976 0.000 0.024
#> GSM154213 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.8461 0.000 1.000 0.000 0.000
#> GSM154217 3 0.4992 0.0138 0.476 0.000 0.524 0.000
#> GSM154219 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154221 1 0.4454 0.5200 0.692 0.000 0.308 0.000
#> GSM154223 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154229 3 0.4855 0.2519 0.400 0.000 0.600 0.000
#> GSM154231 1 0.0000 0.9608 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9608 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.6433 0.6059 0.000 0.504 0.228 0.268 0.000
#> GSM154424 2 0.4707 0.8157 0.000 0.708 0.228 0.064 0.000
#> GSM154425 4 0.0000 0.9950 0.000 0.000 0.000 1.000 0.000
#> GSM154426 2 0.4707 0.8157 0.000 0.708 0.228 0.064 0.000
#> GSM154427 2 0.4707 0.8157 0.000 0.708 0.228 0.064 0.000
#> GSM154428 2 0.4707 0.8157 0.000 0.708 0.228 0.064 0.000
#> GSM154429 2 0.4707 0.8157 0.000 0.708 0.228 0.064 0.000
#> GSM154430 2 0.4707 0.8157 0.000 0.708 0.228 0.064 0.000
#> GSM154434 3 0.4380 0.8292 0.032 0.000 0.708 0.000 0.260
#> GSM154436 5 0.1544 0.8970 0.000 0.000 0.000 0.068 0.932
#> GSM154437 5 0.0000 0.9733 0.000 0.000 0.000 0.000 1.000
#> GSM154438 5 0.0000 0.9733 0.000 0.000 0.000 0.000 1.000
#> GSM154439 5 0.0000 0.9733 0.000 0.000 0.000 0.000 1.000
#> GSM154403 2 0.3752 0.8164 0.000 0.708 0.292 0.000 0.000
#> GSM154404 2 0.3752 0.8164 0.000 0.708 0.292 0.000 0.000
#> GSM154405 2 0.3752 0.8164 0.000 0.708 0.292 0.000 0.000
#> GSM154406 2 0.4090 0.8182 0.000 0.716 0.268 0.016 0.000
#> GSM154407 2 0.3752 0.8164 0.000 0.708 0.292 0.000 0.000
#> GSM154408 4 0.0000 0.9950 0.000 0.000 0.000 1.000 0.000
#> GSM154409 4 0.0000 0.9950 0.000 0.000 0.000 1.000 0.000
#> GSM154410 4 0.0609 0.9747 0.000 0.000 0.020 0.980 0.000
#> GSM154411 4 0.0000 0.9950 0.000 0.000 0.000 1.000 0.000
#> GSM154412 4 0.0000 0.9950 0.000 0.000 0.000 1.000 0.000
#> GSM154413 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154414 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154415 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154416 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154417 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154418 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154419 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154420 5 0.0000 0.9733 0.000 0.000 0.000 0.000 1.000
#> GSM154421 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154422 3 0.3752 0.8617 0.000 0.000 0.708 0.000 0.292
#> GSM154203 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154206 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154208 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.3143 0.6236 0.000 0.796 0.000 0.204 0.000
#> GSM154210 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154211 2 0.3143 0.6236 0.000 0.796 0.000 0.204 0.000
#> GSM154213 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.8164 0.000 1.000 0.000 0.000 0.000
#> GSM154217 3 0.4300 0.0771 0.476 0.000 0.524 0.000 0.000
#> GSM154219 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.3837 0.4874 0.692 0.000 0.308 0.000 0.000
#> GSM154223 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154229 3 0.4182 0.3011 0.400 0.000 0.600 0.000 0.000
#> GSM154231 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9592 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 6 0.000 0.941 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154424 6 0.000 0.941 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154425 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154426 6 0.133 0.887 0.000 0.064 0.000 0.000 0.000 0.936
#> GSM154427 6 0.000 0.941 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154428 6 0.000 0.941 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154429 6 0.000 0.941 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154430 6 0.000 0.941 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154434 3 0.273 0.710 0.000 0.000 0.808 0.000 0.192 0.000
#> GSM154436 5 0.026 1.000 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM154437 5 0.026 1.000 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM154438 5 0.026 1.000 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM154439 5 0.026 1.000 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM154403 6 0.026 0.940 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM154404 6 0.026 0.940 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM154405 6 0.026 0.940 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM154406 6 0.230 0.830 0.000 0.120 0.000 0.000 0.008 0.872
#> GSM154407 6 0.026 0.940 0.000 0.000 0.000 0.000 0.008 0.992
#> GSM154408 4 0.230 0.828 0.000 0.144 0.000 0.856 0.000 0.000
#> GSM154409 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154410 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154411 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154412 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154413 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154414 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154415 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154416 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154417 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154419 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154420 5 0.026 1.000 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM154421 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154422 3 0.000 0.888 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154203 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154204 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154205 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154206 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.324 0.619 0.000 0.732 0.000 0.000 0.000 0.268
#> GSM154208 2 0.234 0.815 0.000 0.852 0.000 0.000 0.000 0.148
#> GSM154209 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154210 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154211 2 0.000 0.916 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154213 2 0.266 0.778 0.000 0.816 0.000 0.000 0.000 0.184
#> GSM154214 6 0.379 0.179 0.000 0.416 0.000 0.000 0.000 0.584
#> GSM154217 3 0.386 0.124 0.476 0.000 0.524 0.000 0.000 0.000
#> GSM154219 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.345 0.472 0.692 0.000 0.308 0.000 0.000 0.000
#> GSM154223 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154229 3 0.376 0.346 0.400 0.000 0.600 0.000 0.000 0.000
#> GSM154231 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.000 0.958 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> SD:pam 55 2.84e-05 8.91e-13 2
#> SD:pam 53 3.03e-06 3.10e-12 3
#> SD:pam 51 1.09e-11 4.89e-11 4
#> SD:pam 53 6.83e-13 8.52e-11 5
#> SD:pam 52 1.87e-18 5.39e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "mclust"]
# you can also extract it by
# res = res_list["SD:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.987 0.993 0.5071 0.492 0.492
#> 3 3 0.761 0.905 0.936 0.2382 0.882 0.760
#> 4 4 0.749 0.684 0.862 0.1367 0.864 0.657
#> 5 5 0.816 0.870 0.905 0.0939 0.864 0.572
#> 6 6 0.977 0.958 0.979 0.0409 0.977 0.890
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
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
#> GSM154423 2 0.000 1.000 0.000 1.000
#> GSM154424 2 0.000 1.000 0.000 1.000
#> GSM154425 2 0.000 1.000 0.000 1.000
#> GSM154426 2 0.000 1.000 0.000 1.000
#> GSM154427 2 0.000 1.000 0.000 1.000
#> GSM154428 2 0.000 1.000 0.000 1.000
#> GSM154429 2 0.000 1.000 0.000 1.000
#> GSM154430 2 0.000 1.000 0.000 1.000
#> GSM154434 1 0.000 0.984 1.000 0.000
#> GSM154436 1 0.416 0.922 0.916 0.084
#> GSM154437 1 0.416 0.922 0.916 0.084
#> GSM154438 1 0.000 0.984 1.000 0.000
#> GSM154439 1 0.416 0.922 0.916 0.084
#> GSM154403 2 0.000 1.000 0.000 1.000
#> GSM154404 2 0.000 1.000 0.000 1.000
#> GSM154405 2 0.000 1.000 0.000 1.000
#> GSM154406 2 0.000 1.000 0.000 1.000
#> GSM154407 2 0.000 1.000 0.000 1.000
#> GSM154408 2 0.000 1.000 0.000 1.000
#> GSM154409 2 0.000 1.000 0.000 1.000
#> GSM154410 2 0.000 1.000 0.000 1.000
#> GSM154411 2 0.000 1.000 0.000 1.000
#> GSM154412 2 0.000 1.000 0.000 1.000
#> GSM154413 1 0.000 0.984 1.000 0.000
#> GSM154414 1 0.000 0.984 1.000 0.000
#> GSM154415 1 0.000 0.984 1.000 0.000
#> GSM154416 1 0.000 0.984 1.000 0.000
#> GSM154417 1 0.000 0.984 1.000 0.000
#> GSM154418 1 0.388 0.929 0.924 0.076
#> GSM154419 1 0.000 0.984 1.000 0.000
#> GSM154420 1 0.416 0.922 0.916 0.084
#> GSM154421 1 0.000 0.984 1.000 0.000
#> GSM154422 1 0.000 0.984 1.000 0.000
#> GSM154203 2 0.000 1.000 0.000 1.000
#> GSM154204 2 0.000 1.000 0.000 1.000
#> GSM154205 2 0.000 1.000 0.000 1.000
#> GSM154206 2 0.000 1.000 0.000 1.000
#> GSM154207 2 0.000 1.000 0.000 1.000
#> GSM154208 2 0.000 1.000 0.000 1.000
#> GSM154209 2 0.000 1.000 0.000 1.000
#> GSM154210 2 0.000 1.000 0.000 1.000
#> GSM154211 2 0.000 1.000 0.000 1.000
#> GSM154213 2 0.000 1.000 0.000 1.000
#> GSM154214 2 0.000 1.000 0.000 1.000
#> GSM154217 1 0.000 0.984 1.000 0.000
#> GSM154219 1 0.000 0.984 1.000 0.000
#> GSM154220 1 0.000 0.984 1.000 0.000
#> GSM154221 1 0.000 0.984 1.000 0.000
#> GSM154223 1 0.000 0.984 1.000 0.000
#> GSM154224 1 0.000 0.984 1.000 0.000
#> GSM154225 1 0.000 0.984 1.000 0.000
#> GSM154227 1 0.000 0.984 1.000 0.000
#> GSM154228 1 0.000 0.984 1.000 0.000
#> GSM154229 1 0.000 0.984 1.000 0.000
#> GSM154231 1 0.000 0.984 1.000 0.000
#> GSM154232 1 0.000 0.984 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154424 2 0.4654 0.831 0.000 0.792 0.208
#> GSM154425 2 0.4931 0.815 0.000 0.768 0.232
#> GSM154426 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154428 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154434 1 0.4555 0.663 0.800 0.000 0.200
#> GSM154436 3 0.0237 0.932 0.000 0.004 0.996
#> GSM154437 3 0.0237 0.932 0.000 0.004 0.996
#> GSM154438 3 0.4291 0.806 0.180 0.000 0.820
#> GSM154439 3 0.0237 0.932 0.000 0.004 0.996
#> GSM154403 2 0.4702 0.830 0.000 0.788 0.212
#> GSM154404 2 0.4702 0.830 0.000 0.788 0.212
#> GSM154405 2 0.4702 0.830 0.000 0.788 0.212
#> GSM154406 2 0.4702 0.830 0.000 0.788 0.212
#> GSM154407 2 0.4702 0.830 0.000 0.788 0.212
#> GSM154408 2 0.4504 0.837 0.000 0.804 0.196
#> GSM154409 2 0.4750 0.827 0.000 0.784 0.216
#> GSM154410 2 0.4750 0.827 0.000 0.784 0.216
#> GSM154411 2 0.4796 0.824 0.000 0.780 0.220
#> GSM154412 2 0.4605 0.835 0.000 0.796 0.204
#> GSM154413 3 0.2625 0.949 0.084 0.000 0.916
#> GSM154414 3 0.2711 0.947 0.088 0.000 0.912
#> GSM154415 3 0.2625 0.949 0.084 0.000 0.916
#> GSM154416 3 0.2625 0.949 0.084 0.000 0.916
#> GSM154417 3 0.2711 0.947 0.088 0.000 0.912
#> GSM154418 3 0.0592 0.937 0.012 0.000 0.988
#> GSM154419 3 0.2711 0.947 0.088 0.000 0.912
#> GSM154420 3 0.0237 0.932 0.000 0.004 0.996
#> GSM154421 3 0.1753 0.946 0.048 0.000 0.952
#> GSM154422 3 0.2625 0.949 0.084 0.000 0.916
#> GSM154203 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154209 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154210 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154211 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.898 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.978 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.978 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154424 2 0.6188 0.3289 0.000 0.548 0.056 0.396
#> GSM154425 4 0.4564 0.2665 0.000 0.328 0.000 0.672
#> GSM154426 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154427 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154428 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154429 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154434 1 0.3726 0.6603 0.788 0.000 0.000 0.212
#> GSM154436 4 0.0707 0.7102 0.000 0.000 0.020 0.980
#> GSM154437 4 0.0707 0.7102 0.000 0.000 0.020 0.980
#> GSM154438 4 0.5326 0.3336 0.380 0.000 0.016 0.604
#> GSM154439 4 0.0707 0.7102 0.000 0.000 0.020 0.980
#> GSM154403 3 0.7044 0.2530 0.000 0.164 0.560 0.276
#> GSM154404 3 0.6975 0.2452 0.000 0.148 0.560 0.292
#> GSM154405 3 0.7760 0.1195 0.000 0.288 0.436 0.276
#> GSM154406 3 0.7862 0.0765 0.000 0.332 0.388 0.280
#> GSM154407 2 0.7796 0.0438 0.000 0.424 0.284 0.292
#> GSM154408 2 0.4761 0.4523 0.000 0.628 0.000 0.372
#> GSM154409 2 0.5039 0.4014 0.000 0.592 0.004 0.404
#> GSM154410 2 0.5050 0.3942 0.000 0.588 0.004 0.408
#> GSM154411 2 0.5158 0.2561 0.000 0.524 0.004 0.472
#> GSM154412 2 0.4817 0.4336 0.000 0.612 0.000 0.388
#> GSM154413 3 0.1118 0.6692 0.000 0.000 0.964 0.036
#> GSM154414 3 0.1716 0.6689 0.000 0.000 0.936 0.064
#> GSM154415 3 0.2589 0.6584 0.000 0.000 0.884 0.116
#> GSM154416 3 0.2589 0.6584 0.000 0.000 0.884 0.116
#> GSM154417 3 0.0000 0.6624 0.000 0.000 1.000 0.000
#> GSM154418 4 0.4981 -0.0836 0.000 0.000 0.464 0.536
#> GSM154419 3 0.2647 0.6579 0.000 0.000 0.880 0.120
#> GSM154420 4 0.0707 0.7102 0.000 0.000 0.020 0.980
#> GSM154421 3 0.3688 0.5985 0.000 0.000 0.792 0.208
#> GSM154422 3 0.0000 0.6624 0.000 0.000 1.000 0.000
#> GSM154203 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154209 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154210 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154211 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154213 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.8403 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.9780 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9780 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154424 4 0.5416 0.746 0.000 0.248 0.004 0.652 0.096
#> GSM154425 4 0.3401 0.759 0.000 0.064 0.000 0.840 0.096
#> GSM154426 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154427 2 0.0162 0.892 0.000 0.996 0.000 0.000 0.004
#> GSM154428 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154429 2 0.0703 0.895 0.000 0.976 0.000 0.024 0.000
#> GSM154430 2 0.0162 0.892 0.000 0.996 0.000 0.000 0.004
#> GSM154434 1 0.3132 0.761 0.820 0.000 0.008 0.000 0.172
#> GSM154436 5 0.0794 0.985 0.000 0.000 0.028 0.000 0.972
#> GSM154437 5 0.0609 0.986 0.000 0.000 0.020 0.000 0.980
#> GSM154438 5 0.1012 0.972 0.012 0.000 0.020 0.000 0.968
#> GSM154439 5 0.0404 0.982 0.000 0.000 0.012 0.000 0.988
#> GSM154403 4 0.4054 0.740 0.000 0.236 0.012 0.744 0.008
#> GSM154404 4 0.4054 0.740 0.000 0.236 0.012 0.744 0.008
#> GSM154405 4 0.3949 0.683 0.000 0.332 0.000 0.668 0.000
#> GSM154406 4 0.2389 0.768 0.000 0.116 0.000 0.880 0.004
#> GSM154407 4 0.4054 0.740 0.000 0.236 0.012 0.744 0.008
#> GSM154408 4 0.4841 0.732 0.000 0.208 0.000 0.708 0.084
#> GSM154409 4 0.3410 0.761 0.000 0.068 0.000 0.840 0.092
#> GSM154410 4 0.2505 0.745 0.000 0.020 0.000 0.888 0.092
#> GSM154411 4 0.3410 0.761 0.000 0.068 0.000 0.840 0.092
#> GSM154412 4 0.3806 0.755 0.000 0.104 0.000 0.812 0.084
#> GSM154413 3 0.0162 0.885 0.000 0.000 0.996 0.000 0.004
#> GSM154414 3 0.0880 0.891 0.000 0.000 0.968 0.000 0.032
#> GSM154415 3 0.1121 0.891 0.000 0.000 0.956 0.000 0.044
#> GSM154416 3 0.1121 0.891 0.000 0.000 0.956 0.000 0.044
#> GSM154417 3 0.0162 0.882 0.000 0.000 0.996 0.004 0.000
#> GSM154418 3 0.4287 0.250 0.000 0.000 0.540 0.000 0.460
#> GSM154419 3 0.2891 0.796 0.000 0.000 0.824 0.000 0.176
#> GSM154420 5 0.0794 0.985 0.000 0.000 0.028 0.000 0.972
#> GSM154421 3 0.2329 0.848 0.000 0.000 0.876 0.000 0.124
#> GSM154422 3 0.0162 0.882 0.000 0.000 0.996 0.004 0.000
#> GSM154203 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154204 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154206 2 0.0162 0.895 0.000 0.996 0.000 0.004 0.000
#> GSM154207 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000
#> GSM154208 2 0.0000 0.894 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154210 2 0.2605 0.883 0.000 0.852 0.000 0.148 0.000
#> GSM154211 2 0.2773 0.869 0.000 0.836 0.000 0.164 0.000
#> GSM154213 2 0.0162 0.892 0.000 0.996 0.000 0.000 0.004
#> GSM154214 2 0.0162 0.892 0.000 0.996 0.000 0.000 0.004
#> GSM154217 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0162 0.980 0.996 0.000 0.004 0.000 0.000
#> GSM154231 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.983 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154424 6 0.2378 0.837 0.0 0 0.000 0.152 0.000 0.848
#> GSM154425 4 0.0000 0.999 0.0 0 0.000 1.000 0.000 0.000
#> GSM154426 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154427 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154428 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154429 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154430 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154434 1 0.2793 0.730 0.8 0 0.000 0.000 0.200 0.000
#> GSM154436 5 0.0000 1.000 0.0 0 0.000 0.000 1.000 0.000
#> GSM154437 5 0.0000 1.000 0.0 0 0.000 0.000 1.000 0.000
#> GSM154438 5 0.0000 1.000 0.0 0 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0000 1.000 0.0 0 0.000 0.000 1.000 0.000
#> GSM154403 6 0.0000 0.959 0.0 0 0.000 0.000 0.000 1.000
#> GSM154404 6 0.0000 0.959 0.0 0 0.000 0.000 0.000 1.000
#> GSM154405 6 0.0632 0.958 0.0 0 0.000 0.024 0.000 0.976
#> GSM154406 6 0.0632 0.958 0.0 0 0.000 0.024 0.000 0.976
#> GSM154407 6 0.0000 0.959 0.0 0 0.000 0.000 0.000 1.000
#> GSM154408 4 0.0000 0.999 0.0 0 0.000 1.000 0.000 0.000
#> GSM154409 4 0.0000 0.999 0.0 0 0.000 1.000 0.000 0.000
#> GSM154410 4 0.0146 0.996 0.0 0 0.000 0.996 0.000 0.004
#> GSM154411 4 0.0000 0.999 0.0 0 0.000 1.000 0.000 0.000
#> GSM154412 4 0.0000 0.999 0.0 0 0.000 1.000 0.000 0.000
#> GSM154413 3 0.0000 0.895 0.0 0 1.000 0.000 0.000 0.000
#> GSM154414 3 0.0000 0.895 0.0 0 1.000 0.000 0.000 0.000
#> GSM154415 3 0.0000 0.895 0.0 0 1.000 0.000 0.000 0.000
#> GSM154416 3 0.0000 0.895 0.0 0 1.000 0.000 0.000 0.000
#> GSM154417 3 0.0000 0.895 0.0 0 1.000 0.000 0.000 0.000
#> GSM154418 3 0.3592 0.588 0.0 0 0.656 0.000 0.344 0.000
#> GSM154419 3 0.2793 0.789 0.0 0 0.800 0.000 0.200 0.000
#> GSM154420 5 0.0000 1.000 0.0 0 0.000 0.000 1.000 0.000
#> GSM154421 3 0.2793 0.789 0.0 0 0.800 0.000 0.200 0.000
#> GSM154422 3 0.0937 0.884 0.0 0 0.960 0.000 0.040 0.000
#> GSM154203 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154206 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154207 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154208 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154209 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154210 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154211 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154213 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 1.000 0.0 1 0.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.982 1.0 0 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> SD:mclust 56 2.95e-05 5.37e-13 2
#> SD:mclust 56 2.39e-11 6.91e-13 3
#> SD:mclust 42 9.71e-14 4.01e-09 4
#> SD:mclust 55 1.17e-16 3.25e-11 5
#> SD:mclust 56 1.08e-15 8.13e-11 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["SD", "NMF"]
# you can also extract it by
# res = res_list["SD:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 1.000 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.885 0.890 0.953 0.2460 0.865 0.730
#> 4 4 0.772 0.727 0.857 0.1487 0.822 0.565
#> 5 5 0.840 0.774 0.891 0.0776 0.888 0.618
#> 6 6 0.829 0.764 0.809 0.0408 0.938 0.733
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154424 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154425 3 0.5216 0.581 0.000 0.260 0.740
#> GSM154426 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154428 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154434 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154436 3 0.0000 0.895 0.000 0.000 1.000
#> GSM154437 3 0.0000 0.895 0.000 0.000 1.000
#> GSM154438 3 0.2165 0.855 0.064 0.000 0.936
#> GSM154439 3 0.0000 0.895 0.000 0.000 1.000
#> GSM154403 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154406 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154407 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154408 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154409 2 0.5785 0.517 0.000 0.668 0.332
#> GSM154410 2 0.4702 0.728 0.000 0.788 0.212
#> GSM154411 3 0.0747 0.886 0.000 0.016 0.984
#> GSM154412 2 0.6008 0.429 0.000 0.628 0.372
#> GSM154413 1 0.0237 0.941 0.996 0.000 0.004
#> GSM154414 1 0.2878 0.880 0.904 0.000 0.096
#> GSM154415 1 0.4796 0.755 0.780 0.000 0.220
#> GSM154416 1 0.5706 0.594 0.680 0.000 0.320
#> GSM154417 1 0.0592 0.937 0.988 0.000 0.012
#> GSM154418 3 0.0000 0.895 0.000 0.000 1.000
#> GSM154419 1 0.4235 0.809 0.824 0.000 0.176
#> GSM154420 3 0.0000 0.895 0.000 0.000 1.000
#> GSM154421 3 0.5948 0.299 0.360 0.000 0.640
#> GSM154422 1 0.4555 0.784 0.800 0.000 0.200
#> GSM154203 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154209 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154210 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154211 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.963 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.943 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.943 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.3074 0.7797 0.000 0.848 0.000 0.152
#> GSM154424 2 0.0188 0.8908 0.000 0.996 0.000 0.004
#> GSM154425 4 0.4509 0.4292 0.000 0.288 0.004 0.708
#> GSM154426 2 0.0707 0.8869 0.000 0.980 0.000 0.020
#> GSM154427 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154428 2 0.2530 0.8216 0.000 0.888 0.000 0.112
#> GSM154429 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154434 1 0.1452 0.9525 0.956 0.000 0.008 0.036
#> GSM154436 4 0.3907 0.4260 0.000 0.000 0.232 0.768
#> GSM154437 4 0.4250 0.4091 0.000 0.000 0.276 0.724
#> GSM154438 4 0.4535 0.3831 0.004 0.000 0.292 0.704
#> GSM154439 4 0.4250 0.4091 0.000 0.000 0.276 0.724
#> GSM154403 3 0.4844 0.4160 0.000 0.300 0.688 0.012
#> GSM154404 3 0.4844 0.4160 0.000 0.300 0.688 0.012
#> GSM154405 2 0.4511 0.5981 0.000 0.724 0.268 0.008
#> GSM154406 2 0.4420 0.6337 0.000 0.748 0.240 0.012
#> GSM154407 2 0.5407 0.0572 0.000 0.504 0.484 0.012
#> GSM154408 2 0.5631 0.5990 0.000 0.696 0.072 0.232
#> GSM154409 4 0.7205 0.2477 0.000 0.344 0.152 0.504
#> GSM154410 4 0.7429 0.1742 0.000 0.360 0.176 0.464
#> GSM154411 4 0.3142 0.4175 0.000 0.008 0.132 0.860
#> GSM154412 4 0.6206 0.1795 0.000 0.404 0.056 0.540
#> GSM154413 3 0.1109 0.7303 0.028 0.004 0.968 0.000
#> GSM154414 3 0.0817 0.7298 0.024 0.000 0.976 0.000
#> GSM154415 3 0.1284 0.7323 0.024 0.000 0.964 0.012
#> GSM154416 3 0.3479 0.6795 0.012 0.000 0.840 0.148
#> GSM154417 3 0.1975 0.7193 0.048 0.016 0.936 0.000
#> GSM154418 3 0.4746 0.4136 0.000 0.000 0.632 0.368
#> GSM154419 3 0.5056 0.6369 0.076 0.000 0.760 0.164
#> GSM154420 4 0.4250 0.4091 0.000 0.000 0.276 0.724
#> GSM154421 3 0.4356 0.5336 0.000 0.000 0.708 0.292
#> GSM154422 3 0.2954 0.7261 0.028 0.008 0.900 0.064
#> GSM154203 2 0.0592 0.8882 0.000 0.984 0.000 0.016
#> GSM154204 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0592 0.8882 0.000 0.984 0.000 0.016
#> GSM154206 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154209 2 0.1792 0.8566 0.000 0.932 0.000 0.068
#> GSM154210 2 0.0707 0.8869 0.000 0.980 0.000 0.020
#> GSM154211 2 0.2868 0.7976 0.000 0.864 0.000 0.136
#> GSM154213 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.8915 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.9962 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9962 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.4135 0.441 0 0.340 0.004 0.656 0.000
#> GSM154424 2 0.2305 0.852 0 0.896 0.012 0.092 0.000
#> GSM154425 4 0.0992 0.827 0 0.008 0.000 0.968 0.024
#> GSM154426 2 0.3366 0.704 0 0.784 0.004 0.212 0.000
#> GSM154427 2 0.0671 0.913 0 0.980 0.004 0.016 0.000
#> GSM154428 2 0.4238 0.396 0 0.628 0.004 0.368 0.000
#> GSM154429 2 0.0451 0.916 0 0.988 0.004 0.008 0.000
#> GSM154430 2 0.0671 0.913 0 0.980 0.004 0.016 0.000
#> GSM154434 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154436 5 0.1608 0.682 0 0.000 0.000 0.072 0.928
#> GSM154437 5 0.1121 0.695 0 0.000 0.000 0.044 0.956
#> GSM154438 5 0.1408 0.694 0 0.000 0.008 0.044 0.948
#> GSM154439 5 0.1121 0.695 0 0.000 0.000 0.044 0.956
#> GSM154403 3 0.1818 0.680 0 0.044 0.932 0.024 0.000
#> GSM154404 3 0.1211 0.684 0 0.016 0.960 0.024 0.000
#> GSM154405 2 0.4937 0.195 0 0.544 0.428 0.028 0.000
#> GSM154406 3 0.3847 0.584 0 0.180 0.784 0.036 0.000
#> GSM154407 3 0.3970 0.534 0 0.224 0.752 0.024 0.000
#> GSM154408 4 0.3359 0.833 0 0.052 0.108 0.840 0.000
#> GSM154409 4 0.3063 0.843 0 0.020 0.104 0.864 0.012
#> GSM154410 4 0.4048 0.763 0 0.016 0.208 0.764 0.012
#> GSM154411 4 0.1012 0.834 0 0.000 0.012 0.968 0.020
#> GSM154412 4 0.2149 0.851 0 0.028 0.036 0.924 0.012
#> GSM154413 3 0.2280 0.686 0 0.000 0.880 0.000 0.120
#> GSM154414 3 0.2424 0.677 0 0.000 0.868 0.000 0.132
#> GSM154415 3 0.4219 0.071 0 0.000 0.584 0.000 0.416
#> GSM154416 5 0.4227 0.349 0 0.000 0.420 0.000 0.580
#> GSM154417 3 0.2773 0.664 0 0.000 0.836 0.000 0.164
#> GSM154418 5 0.4192 0.396 0 0.000 0.404 0.000 0.596
#> GSM154419 5 0.4278 0.297 0 0.000 0.452 0.000 0.548
#> GSM154420 5 0.1121 0.695 0 0.000 0.000 0.044 0.956
#> GSM154421 5 0.4235 0.364 0 0.000 0.424 0.000 0.576
#> GSM154422 3 0.3508 0.533 0 0.000 0.748 0.000 0.252
#> GSM154203 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154206 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0451 0.915 0 0.988 0.004 0.008 0.000
#> GSM154208 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154209 2 0.0510 0.912 0 0.984 0.000 0.016 0.000
#> GSM154210 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154211 2 0.1043 0.897 0 0.960 0.000 0.040 0.000
#> GSM154213 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.918 0 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.6717 0.3191 0.000 0.384 0.268 0.312 0.000 0.036
#> GSM154424 2 0.5483 0.6450 0.000 0.548 0.352 0.024 0.000 0.076
#> GSM154425 4 0.0858 0.8116 0.000 0.000 0.028 0.968 0.004 0.000
#> GSM154426 2 0.6305 0.6170 0.000 0.528 0.292 0.084 0.000 0.096
#> GSM154427 2 0.4652 0.7066 0.000 0.640 0.288 0.000 0.000 0.072
#> GSM154428 2 0.6131 0.5969 0.000 0.532 0.268 0.168 0.000 0.032
#> GSM154429 2 0.4507 0.7183 0.000 0.664 0.268 0.000 0.000 0.068
#> GSM154430 2 0.4700 0.7044 0.000 0.636 0.288 0.000 0.000 0.076
#> GSM154434 1 0.1082 0.9583 0.956 0.000 0.004 0.000 0.040 0.000
#> GSM154436 5 0.1007 0.7645 0.000 0.000 0.000 0.044 0.956 0.000
#> GSM154437 5 0.0146 0.7957 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM154438 5 0.0000 0.7935 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0146 0.7957 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM154403 6 0.0458 0.7471 0.000 0.016 0.000 0.000 0.000 0.984
#> GSM154404 6 0.0551 0.7379 0.000 0.004 0.008 0.004 0.000 0.984
#> GSM154405 6 0.2821 0.6689 0.000 0.152 0.016 0.000 0.000 0.832
#> GSM154406 6 0.3686 0.7146 0.000 0.108 0.056 0.024 0.000 0.812
#> GSM154407 6 0.1615 0.7465 0.000 0.064 0.004 0.004 0.000 0.928
#> GSM154408 4 0.3329 0.8175 0.000 0.004 0.008 0.768 0.000 0.220
#> GSM154409 4 0.2730 0.8347 0.000 0.000 0.000 0.808 0.000 0.192
#> GSM154410 4 0.3672 0.6296 0.000 0.000 0.000 0.632 0.000 0.368
#> GSM154411 4 0.0937 0.8405 0.000 0.000 0.000 0.960 0.000 0.040
#> GSM154412 4 0.1858 0.8510 0.000 0.000 0.012 0.912 0.000 0.076
#> GSM154413 6 0.4813 0.2149 0.000 0.000 0.248 0.000 0.104 0.648
#> GSM154414 6 0.4663 0.3119 0.000 0.000 0.088 0.000 0.252 0.660
#> GSM154415 5 0.5565 0.0741 0.000 0.000 0.208 0.000 0.552 0.240
#> GSM154416 5 0.5155 0.1171 0.000 0.000 0.280 0.000 0.596 0.124
#> GSM154417 3 0.5271 0.4695 0.000 0.000 0.516 0.000 0.104 0.380
#> GSM154418 3 0.4653 0.8107 0.000 0.000 0.684 0.000 0.196 0.120
#> GSM154419 3 0.5104 0.7083 0.000 0.000 0.588 0.000 0.304 0.108
#> GSM154420 5 0.0146 0.7957 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM154421 3 0.4650 0.8006 0.000 0.000 0.676 0.000 0.220 0.104
#> GSM154422 3 0.4164 0.7779 0.000 0.000 0.744 0.000 0.124 0.132
#> GSM154203 2 0.0000 0.8178 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154204 2 0.0260 0.8151 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM154205 2 0.0146 0.8168 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154206 2 0.0000 0.8178 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.2100 0.7931 0.000 0.884 0.112 0.000 0.000 0.004
#> GSM154208 2 0.0458 0.8110 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM154209 2 0.0000 0.8178 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154210 2 0.0458 0.8110 0.000 0.984 0.000 0.000 0.000 0.016
#> GSM154211 2 0.0291 0.8179 0.000 0.992 0.004 0.004 0.000 0.000
#> GSM154213 2 0.0146 0.8168 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154214 2 0.0146 0.8181 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM154217 1 0.0146 0.9919 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154219 1 0.0260 0.9922 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9928 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0146 0.9919 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154223 1 0.0146 0.9919 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154224 1 0.0260 0.9927 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154225 1 0.0260 0.9927 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154227 1 0.0260 0.9927 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154228 1 0.0146 0.9928 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154229 1 0.0146 0.9928 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154231 1 0.0146 0.9928 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154232 1 0.0260 0.9927 0.992 0.000 0.008 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> SD:NMF 56 2.95e-05 5.37e-13 2
#> SD:NMF 54 3.85e-07 3.79e-11 3
#> SD:NMF 42 8.31e-12 7.58e-10 4
#> SD:NMF 48 1.01e-14 4.45e-08 5
#> SD:NMF 50 6.72e-14 1.39e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "hclust"]
# you can also extract it by
# res = res_list["CV:hclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.805 0.894 0.947 0.5006 0.492 0.492
#> 3 3 0.736 0.849 0.900 0.2716 0.882 0.760
#> 4 4 0.685 0.852 0.892 0.1372 0.910 0.760
#> 5 5 0.824 0.904 0.923 0.0569 0.971 0.897
#> 6 6 0.910 0.861 0.909 0.0631 0.942 0.770
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM154423 2 0.0938 0.894 0.012 0.988
#> GSM154424 2 0.1414 0.899 0.020 0.980
#> GSM154425 2 0.9732 0.438 0.404 0.596
#> GSM154426 2 0.0938 0.894 0.012 0.988
#> GSM154427 2 0.1414 0.899 0.020 0.980
#> GSM154428 2 0.0938 0.894 0.012 0.988
#> GSM154429 2 0.1414 0.899 0.020 0.980
#> GSM154430 2 0.1414 0.899 0.020 0.980
#> GSM154434 1 0.0672 0.990 0.992 0.008
#> GSM154436 1 0.1414 0.981 0.980 0.020
#> GSM154437 1 0.1414 0.981 0.980 0.020
#> GSM154438 1 0.1414 0.981 0.980 0.020
#> GSM154439 1 0.1414 0.981 0.980 0.020
#> GSM154403 2 0.1414 0.899 0.020 0.980
#> GSM154404 2 0.1414 0.899 0.020 0.980
#> GSM154405 2 0.1414 0.899 0.020 0.980
#> GSM154406 2 0.1633 0.898 0.024 0.976
#> GSM154407 2 0.1414 0.899 0.020 0.980
#> GSM154408 2 0.9732 0.438 0.404 0.596
#> GSM154409 2 0.9732 0.438 0.404 0.596
#> GSM154410 2 0.9732 0.438 0.404 0.596
#> GSM154411 2 0.9732 0.438 0.404 0.596
#> GSM154412 2 0.9732 0.438 0.404 0.596
#> GSM154413 1 0.0000 0.995 1.000 0.000
#> GSM154414 1 0.0000 0.995 1.000 0.000
#> GSM154415 1 0.0000 0.995 1.000 0.000
#> GSM154416 1 0.0000 0.995 1.000 0.000
#> GSM154417 1 0.0000 0.995 1.000 0.000
#> GSM154418 1 0.0000 0.995 1.000 0.000
#> GSM154419 1 0.0000 0.995 1.000 0.000
#> GSM154420 1 0.1414 0.981 0.980 0.020
#> GSM154421 1 0.0000 0.995 1.000 0.000
#> GSM154422 1 0.0000 0.995 1.000 0.000
#> GSM154203 2 0.1184 0.895 0.016 0.984
#> GSM154204 2 0.1414 0.899 0.020 0.980
#> GSM154205 2 0.1184 0.895 0.016 0.984
#> GSM154206 2 0.1414 0.899 0.020 0.980
#> GSM154207 2 0.1414 0.899 0.020 0.980
#> GSM154208 2 0.1414 0.899 0.020 0.980
#> GSM154209 2 0.0938 0.894 0.012 0.988
#> GSM154210 2 0.0938 0.894 0.012 0.988
#> GSM154211 2 0.0938 0.894 0.012 0.988
#> GSM154213 2 0.1414 0.899 0.020 0.980
#> GSM154214 2 0.1414 0.899 0.020 0.980
#> GSM154217 1 0.0000 0.995 1.000 0.000
#> GSM154219 1 0.0000 0.995 1.000 0.000
#> GSM154220 1 0.0000 0.995 1.000 0.000
#> GSM154221 1 0.0000 0.995 1.000 0.000
#> GSM154223 1 0.0000 0.995 1.000 0.000
#> GSM154224 1 0.0000 0.995 1.000 0.000
#> GSM154225 1 0.0000 0.995 1.000 0.000
#> GSM154227 1 0.0000 0.995 1.000 0.000
#> GSM154228 1 0.0000 0.995 1.000 0.000
#> GSM154229 1 0.0000 0.995 1.000 0.000
#> GSM154231 1 0.0000 0.995 1.000 0.000
#> GSM154232 1 0.0000 0.995 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.1289 0.895 0.000 0.968 0.032
#> GSM154424 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154425 2 0.6204 0.508 0.000 0.576 0.424
#> GSM154426 2 0.1289 0.895 0.000 0.968 0.032
#> GSM154427 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154428 2 0.1289 0.895 0.000 0.968 0.032
#> GSM154429 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154434 1 0.4291 0.760 0.820 0.000 0.180
#> GSM154436 3 0.0000 0.753 0.000 0.000 1.000
#> GSM154437 3 0.0000 0.753 0.000 0.000 1.000
#> GSM154438 3 0.0000 0.753 0.000 0.000 1.000
#> GSM154439 3 0.0000 0.753 0.000 0.000 1.000
#> GSM154403 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154406 2 0.0237 0.899 0.000 0.996 0.004
#> GSM154407 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154408 2 0.6204 0.508 0.000 0.576 0.424
#> GSM154409 2 0.6204 0.508 0.000 0.576 0.424
#> GSM154410 2 0.6204 0.508 0.000 0.576 0.424
#> GSM154411 2 0.6204 0.508 0.000 0.576 0.424
#> GSM154412 2 0.6204 0.508 0.000 0.576 0.424
#> GSM154413 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154414 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154415 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154416 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154417 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154418 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154419 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154420 3 0.0000 0.753 0.000 0.000 1.000
#> GSM154421 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154422 3 0.5497 0.834 0.292 0.000 0.708
#> GSM154203 2 0.1163 0.896 0.000 0.972 0.028
#> GSM154204 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154205 2 0.1163 0.896 0.000 0.972 0.028
#> GSM154206 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154209 2 0.1289 0.895 0.000 0.968 0.032
#> GSM154210 2 0.1289 0.895 0.000 0.968 0.032
#> GSM154211 2 0.1289 0.895 0.000 0.968 0.032
#> GSM154213 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.900 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.983 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.497 0.623 0.000 0.548 0.000 0.452
#> GSM154424 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154425 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM154426 2 0.497 0.623 0.000 0.548 0.000 0.452
#> GSM154427 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154428 2 0.497 0.623 0.000 0.548 0.000 0.452
#> GSM154429 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154430 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154434 1 0.427 0.790 0.820 0.000 0.108 0.072
#> GSM154436 3 0.336 0.767 0.000 0.000 0.824 0.176
#> GSM154437 3 0.336 0.767 0.000 0.000 0.824 0.176
#> GSM154438 3 0.336 0.767 0.000 0.000 0.824 0.176
#> GSM154439 3 0.336 0.767 0.000 0.000 0.824 0.176
#> GSM154403 2 0.000 0.730 0.000 1.000 0.000 0.000
#> GSM154404 2 0.000 0.730 0.000 1.000 0.000 0.000
#> GSM154405 2 0.000 0.730 0.000 1.000 0.000 0.000
#> GSM154406 2 0.287 0.682 0.000 0.864 0.000 0.136
#> GSM154407 2 0.000 0.730 0.000 1.000 0.000 0.000
#> GSM154408 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM154409 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM154410 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM154411 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM154412 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM154413 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154414 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154415 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154416 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154417 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154418 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154419 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154420 3 0.336 0.767 0.000 0.000 0.824 0.176
#> GSM154421 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154422 3 0.259 0.888 0.116 0.000 0.884 0.000
#> GSM154203 2 0.479 0.711 0.000 0.620 0.000 0.380
#> GSM154204 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154205 2 0.479 0.711 0.000 0.620 0.000 0.380
#> GSM154206 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154207 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154208 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154209 2 0.485 0.692 0.000 0.600 0.000 0.400
#> GSM154210 2 0.483 0.700 0.000 0.608 0.000 0.392
#> GSM154211 2 0.485 0.692 0.000 0.600 0.000 0.400
#> GSM154213 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154214 2 0.322 0.828 0.000 0.836 0.000 0.164
#> GSM154217 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154219 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154220 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154221 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154223 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154224 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154225 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154227 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154228 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154229 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154231 1 0.000 0.985 1.000 0.000 0.000 0.000
#> GSM154232 1 0.000 0.985 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.373 0.701 0.00 0.712 0.000 0.288 0.000
#> GSM154424 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154425 4 0.000 1.000 0.00 0.000 0.000 1.000 0.000
#> GSM154426 2 0.373 0.701 0.00 0.712 0.000 0.288 0.000
#> GSM154427 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154428 2 0.373 0.701 0.00 0.712 0.000 0.288 0.000
#> GSM154429 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154430 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154434 1 0.305 0.784 0.82 0.000 0.004 0.000 0.176
#> GSM154436 5 0.311 1.000 0.00 0.000 0.200 0.000 0.800
#> GSM154437 5 0.311 1.000 0.00 0.000 0.200 0.000 0.800
#> GSM154438 5 0.311 1.000 0.00 0.000 0.200 0.000 0.800
#> GSM154439 5 0.311 1.000 0.00 0.000 0.200 0.000 0.800
#> GSM154403 2 0.311 0.748 0.00 0.800 0.000 0.000 0.200
#> GSM154404 2 0.311 0.748 0.00 0.800 0.000 0.000 0.200
#> GSM154405 2 0.311 0.748 0.00 0.800 0.000 0.000 0.200
#> GSM154406 2 0.538 0.684 0.00 0.664 0.000 0.136 0.200
#> GSM154407 2 0.311 0.748 0.00 0.800 0.000 0.000 0.200
#> GSM154408 4 0.000 1.000 0.00 0.000 0.000 1.000 0.000
#> GSM154409 4 0.000 1.000 0.00 0.000 0.000 1.000 0.000
#> GSM154410 4 0.000 1.000 0.00 0.000 0.000 1.000 0.000
#> GSM154411 4 0.000 1.000 0.00 0.000 0.000 1.000 0.000
#> GSM154412 4 0.000 1.000 0.00 0.000 0.000 1.000 0.000
#> GSM154413 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154414 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154415 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154416 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154417 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154418 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154419 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154420 5 0.311 1.000 0.00 0.000 0.200 0.000 0.800
#> GSM154421 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154422 3 0.000 1.000 0.00 0.000 1.000 0.000 0.000
#> GSM154203 2 0.324 0.765 0.00 0.784 0.000 0.216 0.000
#> GSM154204 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154205 2 0.324 0.765 0.00 0.784 0.000 0.216 0.000
#> GSM154206 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154207 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154208 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154209 2 0.340 0.751 0.00 0.764 0.000 0.236 0.000
#> GSM154210 2 0.334 0.757 0.00 0.772 0.000 0.228 0.000
#> GSM154211 2 0.340 0.751 0.00 0.764 0.000 0.236 0.000
#> GSM154213 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154214 2 0.000 0.848 0.00 1.000 0.000 0.000 0.000
#> GSM154217 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154219 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154220 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154221 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154223 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154224 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154225 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154227 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154228 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154229 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154231 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
#> GSM154232 1 0.000 0.985 1.00 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.1267 0.606 0.000 0.940 0 0.060 0.00 0.000
#> GSM154424 2 0.3823 0.626 0.000 0.564 0 0.000 0.00 0.436
#> GSM154425 4 0.0000 0.946 0.000 0.000 0 1.000 0.00 0.000
#> GSM154426 2 0.1267 0.606 0.000 0.940 0 0.060 0.00 0.000
#> GSM154427 2 0.3823 0.626 0.000 0.564 0 0.000 0.00 0.436
#> GSM154428 2 0.1267 0.606 0.000 0.940 0 0.060 0.00 0.000
#> GSM154429 2 0.3823 0.626 0.000 0.564 0 0.000 0.00 0.436
#> GSM154430 2 0.3823 0.626 0.000 0.564 0 0.000 0.00 0.436
#> GSM154434 1 0.2772 0.777 0.816 0.000 0 0.000 0.18 0.004
#> GSM154436 5 0.0000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> GSM154437 5 0.0000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> GSM154438 5 0.0000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> GSM154439 5 0.0000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> GSM154403 6 0.0146 0.955 0.000 0.004 0 0.000 0.00 0.996
#> GSM154404 6 0.0146 0.955 0.000 0.004 0 0.000 0.00 0.996
#> GSM154405 6 0.0146 0.955 0.000 0.004 0 0.000 0.00 0.996
#> GSM154406 6 0.2794 0.810 0.000 0.080 0 0.060 0.00 0.860
#> GSM154407 6 0.0146 0.955 0.000 0.004 0 0.000 0.00 0.996
#> GSM154408 4 0.1501 0.946 0.000 0.076 0 0.924 0.00 0.000
#> GSM154409 4 0.1501 0.946 0.000 0.076 0 0.924 0.00 0.000
#> GSM154410 4 0.1501 0.946 0.000 0.076 0 0.924 0.00 0.000
#> GSM154411 4 0.0000 0.946 0.000 0.000 0 1.000 0.00 0.000
#> GSM154412 4 0.0000 0.946 0.000 0.000 0 1.000 0.00 0.000
#> GSM154413 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154414 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154415 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154416 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154417 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154418 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154419 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154420 5 0.0000 1.000 0.000 0.000 0 0.000 1.00 0.000
#> GSM154421 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154422 3 0.0000 1.000 0.000 0.000 1 0.000 0.00 0.000
#> GSM154203 2 0.0458 0.644 0.000 0.984 0 0.000 0.00 0.016
#> GSM154204 2 0.3804 0.638 0.000 0.576 0 0.000 0.00 0.424
#> GSM154205 2 0.0458 0.644 0.000 0.984 0 0.000 0.00 0.016
#> GSM154206 2 0.3804 0.638 0.000 0.576 0 0.000 0.00 0.424
#> GSM154207 2 0.3804 0.638 0.000 0.576 0 0.000 0.00 0.424
#> GSM154208 2 0.3804 0.638 0.000 0.576 0 0.000 0.00 0.424
#> GSM154209 2 0.0260 0.638 0.000 0.992 0 0.008 0.00 0.000
#> GSM154210 2 0.0146 0.640 0.000 0.996 0 0.000 0.00 0.004
#> GSM154211 2 0.0260 0.638 0.000 0.992 0 0.008 0.00 0.000
#> GSM154213 2 0.3804 0.638 0.000 0.576 0 0.000 0.00 0.424
#> GSM154214 2 0.3804 0.638 0.000 0.576 0 0.000 0.00 0.424
#> GSM154217 1 0.0146 0.981 0.996 0.000 0 0.000 0.00 0.004
#> GSM154219 1 0.0000 0.982 1.000 0.000 0 0.000 0.00 0.000
#> GSM154220 1 0.0146 0.983 0.996 0.004 0 0.000 0.00 0.000
#> GSM154221 1 0.0146 0.983 0.996 0.004 0 0.000 0.00 0.000
#> GSM154223 1 0.0146 0.983 0.996 0.004 0 0.000 0.00 0.000
#> GSM154224 1 0.0000 0.982 1.000 0.000 0 0.000 0.00 0.000
#> GSM154225 1 0.0000 0.982 1.000 0.000 0 0.000 0.00 0.000
#> GSM154227 1 0.0000 0.982 1.000 0.000 0 0.000 0.00 0.000
#> GSM154228 1 0.0146 0.983 0.996 0.004 0 0.000 0.00 0.000
#> GSM154229 1 0.0146 0.983 0.996 0.004 0 0.000 0.00 0.000
#> GSM154231 1 0.0146 0.983 0.996 0.004 0 0.000 0.00 0.000
#> GSM154232 1 0.0000 0.982 1.000 0.000 0 0.000 0.00 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> CV:hclust 50 1.67e-05 1.15e-11 2
#> CV:hclust 56 2.39e-11 6.91e-13 3
#> CV:hclust 56 5.30e-12 4.20e-12 4
#> CV:hclust 56 1.91e-13 2.01e-11 5
#> CV:hclust 56 4.07e-16 8.13e-11 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "kmeans"]
# you can also extract it by
# res = res_list["CV:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 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.996 0.997 0.5086 0.492 0.492
#> 3 3 0.689 0.787 0.857 0.2531 0.821 0.649
#> 4 4 0.679 0.726 0.821 0.1305 0.864 0.646
#> 5 5 0.692 0.738 0.774 0.0715 0.920 0.730
#> 6 6 0.709 0.700 0.736 0.0508 0.930 0.704
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
#> GSM154423 2 0.0000 0.996 0.000 1.000
#> GSM154424 2 0.0672 0.996 0.008 0.992
#> GSM154425 2 0.0000 0.996 0.000 1.000
#> GSM154426 2 0.0000 0.996 0.000 1.000
#> GSM154427 2 0.0672 0.996 0.008 0.992
#> GSM154428 2 0.0000 0.996 0.000 1.000
#> GSM154429 2 0.0672 0.996 0.008 0.992
#> GSM154430 2 0.0672 0.996 0.008 0.992
#> GSM154434 1 0.0000 0.998 1.000 0.000
#> GSM154436 1 0.0672 0.993 0.992 0.008
#> GSM154437 1 0.0672 0.993 0.992 0.008
#> GSM154438 1 0.0672 0.993 0.992 0.008
#> GSM154439 1 0.0672 0.993 0.992 0.008
#> GSM154403 2 0.0672 0.996 0.008 0.992
#> GSM154404 2 0.0672 0.996 0.008 0.992
#> GSM154405 2 0.0672 0.996 0.008 0.992
#> GSM154406 2 0.0672 0.996 0.008 0.992
#> GSM154407 2 0.0672 0.996 0.008 0.992
#> GSM154408 2 0.0000 0.996 0.000 1.000
#> GSM154409 2 0.0000 0.996 0.000 1.000
#> GSM154410 2 0.0000 0.996 0.000 1.000
#> GSM154411 2 0.0000 0.996 0.000 1.000
#> GSM154412 2 0.0000 0.996 0.000 1.000
#> GSM154413 1 0.0000 0.998 1.000 0.000
#> GSM154414 1 0.0000 0.998 1.000 0.000
#> GSM154415 1 0.0000 0.998 1.000 0.000
#> GSM154416 1 0.0000 0.998 1.000 0.000
#> GSM154417 1 0.0000 0.998 1.000 0.000
#> GSM154418 1 0.0672 0.993 0.992 0.008
#> GSM154419 1 0.0000 0.998 1.000 0.000
#> GSM154420 1 0.0672 0.993 0.992 0.008
#> GSM154421 1 0.0000 0.998 1.000 0.000
#> GSM154422 1 0.0000 0.998 1.000 0.000
#> GSM154203 2 0.0000 0.996 0.000 1.000
#> GSM154204 2 0.0672 0.996 0.008 0.992
#> GSM154205 2 0.0000 0.996 0.000 1.000
#> GSM154206 2 0.0672 0.996 0.008 0.992
#> GSM154207 2 0.0672 0.996 0.008 0.992
#> GSM154208 2 0.0672 0.996 0.008 0.992
#> GSM154209 2 0.0000 0.996 0.000 1.000
#> GSM154210 2 0.0000 0.996 0.000 1.000
#> GSM154211 2 0.0000 0.996 0.000 1.000
#> GSM154213 2 0.0672 0.996 0.008 0.992
#> GSM154214 2 0.0672 0.996 0.008 0.992
#> GSM154217 1 0.0000 0.998 1.000 0.000
#> GSM154219 1 0.0000 0.998 1.000 0.000
#> GSM154220 1 0.0000 0.998 1.000 0.000
#> GSM154221 1 0.0000 0.998 1.000 0.000
#> GSM154223 1 0.0000 0.998 1.000 0.000
#> GSM154224 1 0.0000 0.998 1.000 0.000
#> GSM154225 1 0.0000 0.998 1.000 0.000
#> GSM154227 1 0.0000 0.998 1.000 0.000
#> GSM154228 1 0.0000 0.998 1.000 0.000
#> GSM154229 1 0.0000 0.998 1.000 0.000
#> GSM154231 1 0.0000 0.998 1.000 0.000
#> GSM154232 1 0.0000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.4796 0.791 0.000 0.780 0.220
#> GSM154424 2 0.1411 0.916 0.000 0.964 0.036
#> GSM154425 3 0.4887 0.503 0.000 0.228 0.772
#> GSM154426 2 0.4796 0.791 0.000 0.780 0.220
#> GSM154427 2 0.0747 0.921 0.000 0.984 0.016
#> GSM154428 2 0.4796 0.791 0.000 0.780 0.220
#> GSM154429 2 0.0747 0.921 0.000 0.984 0.016
#> GSM154430 2 0.0747 0.921 0.000 0.984 0.016
#> GSM154434 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154436 3 0.5678 0.491 0.316 0.000 0.684
#> GSM154437 3 0.5733 0.482 0.324 0.000 0.676
#> GSM154438 3 0.5968 0.388 0.364 0.000 0.636
#> GSM154439 3 0.5733 0.482 0.324 0.000 0.676
#> GSM154403 2 0.2711 0.891 0.000 0.912 0.088
#> GSM154404 2 0.2711 0.891 0.000 0.912 0.088
#> GSM154405 2 0.1643 0.914 0.000 0.956 0.044
#> GSM154406 2 0.1753 0.912 0.000 0.952 0.048
#> GSM154407 2 0.2711 0.891 0.000 0.912 0.088
#> GSM154408 2 0.5327 0.738 0.000 0.728 0.272
#> GSM154409 3 0.5291 0.451 0.000 0.268 0.732
#> GSM154410 3 0.5291 0.451 0.000 0.268 0.732
#> GSM154411 3 0.4887 0.503 0.000 0.228 0.772
#> GSM154412 3 0.5291 0.451 0.000 0.268 0.732
#> GSM154413 1 0.5098 0.769 0.752 0.000 0.248
#> GSM154414 1 0.5098 0.769 0.752 0.000 0.248
#> GSM154415 1 0.4796 0.780 0.780 0.000 0.220
#> GSM154416 1 0.4796 0.780 0.780 0.000 0.220
#> GSM154417 1 0.4974 0.779 0.764 0.000 0.236
#> GSM154418 3 0.5706 0.488 0.320 0.000 0.680
#> GSM154419 1 0.4796 0.780 0.780 0.000 0.220
#> GSM154420 3 0.5706 0.488 0.320 0.000 0.680
#> GSM154421 1 0.4974 0.764 0.764 0.000 0.236
#> GSM154422 1 0.5098 0.769 0.752 0.000 0.248
#> GSM154203 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154209 2 0.4346 0.809 0.000 0.816 0.184
#> GSM154210 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154211 2 0.4346 0.809 0.000 0.816 0.184
#> GSM154213 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.922 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154221 1 0.0237 0.881 0.996 0.000 0.004
#> GSM154223 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.883 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.883 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.6130 0.2453 0.000 0.548 0.052 0.400
#> GSM154424 2 0.3239 0.7851 0.000 0.880 0.068 0.052
#> GSM154425 4 0.2843 0.8322 0.000 0.088 0.020 0.892
#> GSM154426 2 0.6130 0.2453 0.000 0.548 0.052 0.400
#> GSM154427 2 0.2797 0.7930 0.000 0.900 0.068 0.032
#> GSM154428 2 0.6130 0.2453 0.000 0.548 0.052 0.400
#> GSM154429 2 0.2797 0.7930 0.000 0.900 0.068 0.032
#> GSM154430 2 0.2797 0.7930 0.000 0.900 0.068 0.032
#> GSM154434 1 0.1305 0.9444 0.960 0.000 0.036 0.004
#> GSM154436 3 0.5933 0.4380 0.040 0.000 0.552 0.408
#> GSM154437 3 0.5999 0.4439 0.044 0.000 0.552 0.404
#> GSM154438 3 0.6355 0.4937 0.076 0.000 0.576 0.348
#> GSM154439 3 0.5999 0.4439 0.044 0.000 0.552 0.404
#> GSM154403 2 0.5010 0.7236 0.000 0.772 0.120 0.108
#> GSM154404 2 0.5010 0.7236 0.000 0.772 0.120 0.108
#> GSM154405 2 0.4374 0.7519 0.000 0.812 0.120 0.068
#> GSM154406 2 0.4411 0.7541 0.000 0.812 0.108 0.080
#> GSM154407 2 0.5010 0.7236 0.000 0.772 0.120 0.108
#> GSM154408 4 0.5917 -0.0142 0.000 0.444 0.036 0.520
#> GSM154409 4 0.2704 0.8627 0.000 0.124 0.000 0.876
#> GSM154410 4 0.2704 0.8627 0.000 0.124 0.000 0.876
#> GSM154411 4 0.2730 0.8324 0.000 0.088 0.016 0.896
#> GSM154412 4 0.2704 0.8627 0.000 0.124 0.000 0.876
#> GSM154413 3 0.5311 0.6464 0.328 0.000 0.648 0.024
#> GSM154414 3 0.5311 0.6464 0.328 0.000 0.648 0.024
#> GSM154415 3 0.4543 0.6561 0.324 0.000 0.676 0.000
#> GSM154416 3 0.4543 0.6561 0.324 0.000 0.676 0.000
#> GSM154417 3 0.5331 0.6418 0.332 0.000 0.644 0.024
#> GSM154418 3 0.3525 0.6027 0.040 0.000 0.860 0.100
#> GSM154419 3 0.4564 0.6532 0.328 0.000 0.672 0.000
#> GSM154420 3 0.5933 0.4380 0.040 0.000 0.552 0.408
#> GSM154421 3 0.4072 0.6680 0.252 0.000 0.748 0.000
#> GSM154422 3 0.5018 0.6474 0.332 0.000 0.656 0.012
#> GSM154203 2 0.0469 0.8048 0.000 0.988 0.000 0.012
#> GSM154204 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154205 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154206 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154207 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154208 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154209 2 0.4917 0.3477 0.000 0.656 0.008 0.336
#> GSM154210 2 0.0469 0.8048 0.000 0.988 0.000 0.012
#> GSM154211 2 0.4973 0.3238 0.000 0.644 0.008 0.348
#> GSM154213 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154214 2 0.0336 0.8058 0.000 0.992 0.000 0.008
#> GSM154217 1 0.0336 0.9898 0.992 0.000 0.000 0.008
#> GSM154219 1 0.0469 0.9893 0.988 0.000 0.000 0.012
#> GSM154220 1 0.0336 0.9898 0.992 0.000 0.000 0.008
#> GSM154221 1 0.0336 0.9898 0.992 0.000 0.000 0.008
#> GSM154223 1 0.0469 0.9888 0.988 0.000 0.000 0.012
#> GSM154224 1 0.0188 0.9895 0.996 0.000 0.000 0.004
#> GSM154225 1 0.0188 0.9895 0.996 0.000 0.000 0.004
#> GSM154227 1 0.0188 0.9895 0.996 0.000 0.000 0.004
#> GSM154228 1 0.0188 0.9887 0.996 0.000 0.000 0.004
#> GSM154229 1 0.0336 0.9898 0.992 0.000 0.000 0.008
#> GSM154231 1 0.0188 0.9887 0.996 0.000 0.000 0.004
#> GSM154232 1 0.0188 0.9895 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.6327 0.3350 0.000 0.368 0.092 0.516 0.024
#> GSM154424 2 0.5729 0.6025 0.000 0.676 0.164 0.136 0.024
#> GSM154425 4 0.4161 0.6774 0.000 0.040 0.000 0.752 0.208
#> GSM154426 4 0.6327 0.3350 0.000 0.368 0.092 0.516 0.024
#> GSM154427 2 0.5295 0.6370 0.000 0.716 0.160 0.100 0.024
#> GSM154428 4 0.6327 0.3350 0.000 0.368 0.092 0.516 0.024
#> GSM154429 2 0.5295 0.6370 0.000 0.716 0.160 0.100 0.024
#> GSM154430 2 0.5295 0.6370 0.000 0.716 0.160 0.100 0.024
#> GSM154434 1 0.2727 0.8818 0.896 0.000 0.024 0.024 0.056
#> GSM154436 5 0.0880 0.9861 0.032 0.000 0.000 0.000 0.968
#> GSM154437 5 0.0880 0.9861 0.032 0.000 0.000 0.000 0.968
#> GSM154438 5 0.1502 0.9424 0.056 0.000 0.004 0.000 0.940
#> GSM154439 5 0.0880 0.9861 0.032 0.000 0.000 0.000 0.968
#> GSM154403 2 0.6372 0.4795 0.000 0.456 0.376 0.168 0.000
#> GSM154404 2 0.6372 0.4795 0.000 0.456 0.376 0.168 0.000
#> GSM154405 2 0.6122 0.5313 0.000 0.512 0.348 0.140 0.000
#> GSM154406 2 0.5987 0.5438 0.000 0.544 0.324 0.132 0.000
#> GSM154407 2 0.6372 0.4795 0.000 0.456 0.376 0.168 0.000
#> GSM154408 4 0.2891 0.6436 0.000 0.176 0.000 0.824 0.000
#> GSM154409 4 0.4234 0.7023 0.000 0.056 0.000 0.760 0.184
#> GSM154410 4 0.4088 0.7045 0.000 0.056 0.000 0.776 0.168
#> GSM154411 4 0.4161 0.6774 0.000 0.040 0.000 0.752 0.208
#> GSM154412 4 0.4234 0.7023 0.000 0.056 0.000 0.760 0.184
#> GSM154413 3 0.6191 0.9140 0.172 0.000 0.536 0.000 0.292
#> GSM154414 3 0.6191 0.9140 0.172 0.000 0.536 0.000 0.292
#> GSM154415 3 0.6290 0.9145 0.168 0.000 0.500 0.000 0.332
#> GSM154416 3 0.6290 0.9145 0.168 0.000 0.500 0.000 0.332
#> GSM154417 3 0.6227 0.9035 0.184 0.000 0.536 0.000 0.280
#> GSM154418 3 0.5302 0.6041 0.032 0.000 0.488 0.008 0.472
#> GSM154419 3 0.6306 0.9147 0.172 0.000 0.500 0.000 0.328
#> GSM154420 5 0.0880 0.9861 0.032 0.000 0.000 0.000 0.968
#> GSM154421 3 0.6380 0.8717 0.136 0.000 0.492 0.008 0.364
#> GSM154422 3 0.6501 0.9060 0.184 0.000 0.524 0.008 0.284
#> GSM154203 2 0.1082 0.6968 0.000 0.964 0.028 0.000 0.008
#> GSM154204 2 0.0000 0.7064 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.1082 0.6968 0.000 0.964 0.028 0.000 0.008
#> GSM154206 2 0.0000 0.7064 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0703 0.6976 0.000 0.976 0.024 0.000 0.000
#> GSM154208 2 0.0000 0.7064 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.4911 0.1374 0.000 0.652 0.032 0.308 0.008
#> GSM154210 2 0.1082 0.6968 0.000 0.964 0.028 0.000 0.008
#> GSM154211 2 0.5161 -0.0574 0.000 0.584 0.032 0.376 0.008
#> GSM154213 2 0.0000 0.7064 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.7064 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.2438 0.9325 0.900 0.000 0.040 0.060 0.000
#> GSM154219 1 0.2139 0.9281 0.916 0.000 0.032 0.052 0.000
#> GSM154220 1 0.2754 0.9285 0.880 0.000 0.040 0.080 0.000
#> GSM154221 1 0.2632 0.9291 0.888 0.000 0.040 0.072 0.000
#> GSM154223 1 0.3269 0.9194 0.848 0.000 0.056 0.096 0.000
#> GSM154224 1 0.0693 0.9306 0.980 0.000 0.012 0.008 0.000
#> GSM154225 1 0.0693 0.9306 0.980 0.000 0.012 0.008 0.000
#> GSM154227 1 0.0693 0.9306 0.980 0.000 0.012 0.008 0.000
#> GSM154228 1 0.2300 0.9265 0.908 0.000 0.040 0.052 0.000
#> GSM154229 1 0.2632 0.9291 0.888 0.000 0.040 0.072 0.000
#> GSM154231 1 0.2300 0.9265 0.908 0.000 0.040 0.052 0.000
#> GSM154232 1 0.0693 0.9304 0.980 0.000 0.012 0.008 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 6 0.6412 0.1382 0.000 0.208 0.016 0.368 0.004 0.404
#> GSM154424 2 0.4746 -0.0032 0.000 0.508 0.000 0.048 0.000 0.444
#> GSM154425 4 0.0964 0.9712 0.000 0.016 0.000 0.968 0.004 0.012
#> GSM154426 6 0.6412 0.1382 0.000 0.208 0.016 0.368 0.004 0.404
#> GSM154427 2 0.4361 0.0737 0.000 0.552 0.000 0.024 0.000 0.424
#> GSM154428 6 0.6412 0.1382 0.000 0.208 0.016 0.368 0.004 0.404
#> GSM154429 2 0.4361 0.0737 0.000 0.552 0.000 0.024 0.000 0.424
#> GSM154430 2 0.4361 0.0737 0.000 0.552 0.000 0.024 0.000 0.424
#> GSM154434 1 0.4574 0.8666 0.740 0.000 0.016 0.008 0.080 0.156
#> GSM154436 5 0.4023 0.9969 0.012 0.000 0.200 0.040 0.748 0.000
#> GSM154437 5 0.4023 0.9969 0.012 0.000 0.200 0.040 0.748 0.000
#> GSM154438 5 0.4125 0.9921 0.012 0.000 0.204 0.036 0.744 0.004
#> GSM154439 5 0.4162 0.9954 0.012 0.000 0.200 0.040 0.744 0.004
#> GSM154403 6 0.7361 0.4763 0.000 0.360 0.124 0.024 0.104 0.388
#> GSM154404 6 0.7361 0.4763 0.000 0.360 0.124 0.024 0.104 0.388
#> GSM154405 6 0.7099 0.4516 0.000 0.384 0.084 0.024 0.108 0.400
#> GSM154406 6 0.7220 0.4548 0.000 0.372 0.088 0.028 0.112 0.400
#> GSM154407 6 0.7361 0.4763 0.000 0.360 0.124 0.024 0.104 0.388
#> GSM154408 4 0.1768 0.9273 0.000 0.044 0.004 0.932 0.008 0.012
#> GSM154409 4 0.0964 0.9770 0.000 0.016 0.004 0.968 0.012 0.000
#> GSM154410 4 0.0748 0.9772 0.000 0.016 0.004 0.976 0.004 0.000
#> GSM154411 4 0.0603 0.9781 0.000 0.016 0.000 0.980 0.004 0.000
#> GSM154412 4 0.0603 0.9781 0.000 0.016 0.000 0.980 0.004 0.000
#> GSM154413 3 0.2092 0.9127 0.124 0.000 0.876 0.000 0.000 0.000
#> GSM154414 3 0.2092 0.9127 0.124 0.000 0.876 0.000 0.000 0.000
#> GSM154415 3 0.2930 0.9148 0.124 0.000 0.840 0.000 0.036 0.000
#> GSM154416 3 0.2930 0.9148 0.124 0.000 0.840 0.000 0.036 0.000
#> GSM154417 3 0.2135 0.9097 0.128 0.000 0.872 0.000 0.000 0.000
#> GSM154418 3 0.4064 0.7123 0.012 0.000 0.768 0.004 0.164 0.052
#> GSM154419 3 0.3072 0.9146 0.124 0.000 0.836 0.000 0.036 0.004
#> GSM154420 5 0.4023 0.9969 0.012 0.000 0.200 0.040 0.748 0.000
#> GSM154421 3 0.4323 0.8209 0.064 0.000 0.772 0.000 0.112 0.052
#> GSM154422 3 0.3675 0.8881 0.128 0.000 0.804 0.000 0.016 0.052
#> GSM154203 2 0.2878 0.6100 0.000 0.860 0.016 0.000 0.024 0.100
#> GSM154204 2 0.0146 0.6293 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM154205 2 0.2878 0.6100 0.000 0.860 0.016 0.000 0.024 0.100
#> GSM154206 2 0.0000 0.6296 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.1714 0.6205 0.000 0.908 0.000 0.000 0.000 0.092
#> GSM154208 2 0.0000 0.6296 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154209 2 0.6263 0.2902 0.000 0.584 0.032 0.232 0.028 0.124
#> GSM154210 2 0.2878 0.6100 0.000 0.860 0.016 0.000 0.024 0.100
#> GSM154211 2 0.6501 0.2125 0.000 0.528 0.032 0.288 0.028 0.124
#> GSM154213 2 0.0000 0.6296 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.6296 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154217 1 0.2633 0.8847 0.864 0.000 0.000 0.000 0.032 0.104
#> GSM154219 1 0.2932 0.8768 0.840 0.000 0.000 0.004 0.024 0.132
#> GSM154220 1 0.1053 0.8793 0.964 0.000 0.000 0.004 0.020 0.012
#> GSM154221 1 0.0767 0.8823 0.976 0.000 0.000 0.008 0.012 0.004
#> GSM154223 1 0.1401 0.8732 0.948 0.000 0.000 0.004 0.028 0.020
#> GSM154224 1 0.3900 0.8784 0.760 0.000 0.000 0.008 0.044 0.188
#> GSM154225 1 0.3900 0.8784 0.760 0.000 0.000 0.008 0.044 0.188
#> GSM154227 1 0.3900 0.8784 0.760 0.000 0.000 0.008 0.044 0.188
#> GSM154228 1 0.2879 0.8835 0.864 0.000 0.000 0.008 0.056 0.072
#> GSM154229 1 0.0767 0.8823 0.976 0.000 0.000 0.008 0.012 0.004
#> GSM154231 1 0.2879 0.8835 0.864 0.000 0.000 0.008 0.056 0.072
#> GSM154232 1 0.3760 0.8792 0.768 0.000 0.000 0.004 0.044 0.184
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> CV:kmeans 56 2.95e-05 5.37e-13 2
#> CV:kmeans 47 2.85e-05 6.22e-11 3
#> CV:kmeans 45 6.15e-10 9.25e-10 4
#> CV:kmeans 48 4.07e-13 9.44e-10 5
#> CV:kmeans 42 4.86e-16 1.67e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "skmeans"]
# you can also extract it by
# res = res_list["CV:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.805 0.904 0.941 0.2603 0.821 0.649
#> 4 4 0.814 0.728 0.825 0.1400 0.804 0.574
#> 5 5 0.837 0.850 0.885 0.0674 0.840 0.572
#> 6 6 0.865 0.848 0.873 0.0500 0.896 0.594
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154424 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154425 3 0.4605 0.7906 0.000 0.204 0.796
#> GSM154426 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154427 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154428 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154429 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154434 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154436 3 0.0592 0.8068 0.012 0.000 0.988
#> GSM154437 3 0.0592 0.8068 0.012 0.000 0.988
#> GSM154438 3 0.6062 0.0842 0.384 0.000 0.616
#> GSM154439 3 0.0592 0.8068 0.012 0.000 0.988
#> GSM154403 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154406 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154407 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154408 2 0.0592 0.9891 0.000 0.988 0.012
#> GSM154409 3 0.4605 0.7906 0.000 0.204 0.796
#> GSM154410 3 0.4605 0.7906 0.000 0.204 0.796
#> GSM154411 3 0.4605 0.7906 0.000 0.204 0.796
#> GSM154412 3 0.4605 0.7906 0.000 0.204 0.796
#> GSM154413 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154414 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154415 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154416 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154417 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154418 3 0.0592 0.8068 0.012 0.000 0.988
#> GSM154419 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154420 3 0.0592 0.8068 0.012 0.000 0.988
#> GSM154421 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154422 1 0.4605 0.8440 0.796 0.000 0.204
#> GSM154203 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154209 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154210 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154211 2 0.0237 0.9964 0.000 0.996 0.004
#> GSM154213 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.9986 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.9122 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.9122 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.0469 0.5989 0.000 0.988 0.000 0.012
#> GSM154424 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154425 2 0.7888 -0.0254 0.000 0.380 0.300 0.320
#> GSM154426 2 0.0000 0.6056 0.000 1.000 0.000 0.000
#> GSM154427 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154428 2 0.0336 0.6012 0.000 0.992 0.000 0.008
#> GSM154429 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154430 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154434 1 0.2345 0.8752 0.900 0.000 0.100 0.000
#> GSM154436 3 0.0188 0.8009 0.000 0.000 0.996 0.004
#> GSM154437 3 0.0188 0.8009 0.000 0.000 0.996 0.004
#> GSM154438 3 0.0000 0.8023 0.000 0.000 1.000 0.000
#> GSM154439 3 0.0188 0.8009 0.000 0.000 0.996 0.004
#> GSM154403 2 0.4866 0.7382 0.000 0.596 0.000 0.404
#> GSM154404 2 0.4866 0.7382 0.000 0.596 0.000 0.404
#> GSM154405 2 0.4790 0.7427 0.000 0.620 0.000 0.380
#> GSM154406 2 0.4866 0.7382 0.000 0.596 0.000 0.404
#> GSM154407 2 0.4866 0.7382 0.000 0.596 0.000 0.404
#> GSM154408 2 0.5453 0.3050 0.000 0.648 0.032 0.320
#> GSM154409 2 0.7893 -0.0269 0.000 0.376 0.300 0.324
#> GSM154410 2 0.7893 -0.0269 0.000 0.376 0.300 0.324
#> GSM154411 2 0.7893 -0.0269 0.000 0.376 0.300 0.324
#> GSM154412 2 0.7893 -0.0269 0.000 0.376 0.300 0.324
#> GSM154413 3 0.4844 0.8523 0.012 0.000 0.688 0.300
#> GSM154414 3 0.4844 0.8523 0.012 0.000 0.688 0.300
#> GSM154415 3 0.4722 0.8527 0.008 0.000 0.692 0.300
#> GSM154416 3 0.4722 0.8527 0.008 0.000 0.692 0.300
#> GSM154417 3 0.7634 0.6378 0.236 0.000 0.464 0.300
#> GSM154418 3 0.3444 0.8435 0.000 0.000 0.816 0.184
#> GSM154419 3 0.4844 0.8523 0.012 0.000 0.688 0.300
#> GSM154420 3 0.0188 0.8009 0.000 0.000 0.996 0.004
#> GSM154421 3 0.4697 0.8529 0.008 0.000 0.696 0.296
#> GSM154422 3 0.6933 0.7587 0.140 0.000 0.560 0.300
#> GSM154203 2 0.4661 0.7502 0.000 0.652 0.000 0.348
#> GSM154204 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154205 2 0.4661 0.7502 0.000 0.652 0.000 0.348
#> GSM154206 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154207 2 0.4661 0.7502 0.000 0.652 0.000 0.348
#> GSM154208 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154209 2 0.0000 0.6056 0.000 1.000 0.000 0.000
#> GSM154210 2 0.4661 0.7502 0.000 0.652 0.000 0.348
#> GSM154211 2 0.0469 0.5989 0.000 0.988 0.000 0.012
#> GSM154213 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154214 2 0.4697 0.7509 0.000 0.644 0.000 0.356
#> GSM154217 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.9905 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9905 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.5386 0.532 0.000 0.372 0.000 0.564 0.064
#> GSM154424 2 0.1410 0.871 0.000 0.940 0.000 0.000 0.060
#> GSM154425 4 0.1410 0.646 0.000 0.000 0.000 0.940 0.060
#> GSM154426 4 0.5461 0.472 0.000 0.408 0.000 0.528 0.064
#> GSM154427 2 0.1410 0.871 0.000 0.940 0.000 0.000 0.060
#> GSM154428 4 0.5432 0.503 0.000 0.392 0.000 0.544 0.064
#> GSM154429 2 0.1410 0.871 0.000 0.940 0.000 0.000 0.060
#> GSM154430 2 0.1410 0.871 0.000 0.940 0.000 0.000 0.060
#> GSM154434 1 0.3381 0.766 0.808 0.000 0.016 0.000 0.176
#> GSM154436 5 0.4509 0.978 0.000 0.000 0.236 0.048 0.716
#> GSM154437 5 0.4509 0.978 0.000 0.000 0.236 0.048 0.716
#> GSM154438 5 0.4509 0.978 0.000 0.000 0.236 0.048 0.716
#> GSM154439 5 0.4509 0.978 0.000 0.000 0.236 0.048 0.716
#> GSM154403 2 0.3636 0.760 0.000 0.728 0.000 0.000 0.272
#> GSM154404 2 0.3636 0.760 0.000 0.728 0.000 0.000 0.272
#> GSM154405 2 0.3636 0.760 0.000 0.728 0.000 0.000 0.272
#> GSM154406 2 0.3766 0.762 0.000 0.728 0.000 0.004 0.268
#> GSM154407 2 0.3636 0.760 0.000 0.728 0.000 0.000 0.272
#> GSM154408 4 0.1282 0.658 0.000 0.044 0.000 0.952 0.004
#> GSM154409 4 0.1410 0.646 0.000 0.000 0.000 0.940 0.060
#> GSM154410 4 0.1410 0.646 0.000 0.000 0.000 0.940 0.060
#> GSM154411 4 0.1410 0.646 0.000 0.000 0.000 0.940 0.060
#> GSM154412 4 0.1410 0.646 0.000 0.000 0.000 0.940 0.060
#> GSM154413 3 0.0162 0.983 0.004 0.000 0.996 0.000 0.000
#> GSM154414 3 0.0000 0.983 0.000 0.000 1.000 0.000 0.000
#> GSM154415 3 0.0000 0.983 0.000 0.000 1.000 0.000 0.000
#> GSM154416 3 0.0000 0.983 0.000 0.000 1.000 0.000 0.000
#> GSM154417 3 0.0880 0.951 0.032 0.000 0.968 0.000 0.000
#> GSM154418 5 0.4503 0.878 0.000 0.000 0.312 0.024 0.664
#> GSM154419 3 0.0162 0.983 0.004 0.000 0.996 0.000 0.000
#> GSM154420 5 0.4509 0.978 0.000 0.000 0.236 0.048 0.716
#> GSM154421 3 0.0162 0.980 0.000 0.000 0.996 0.000 0.004
#> GSM154422 3 0.0703 0.963 0.024 0.000 0.976 0.000 0.000
#> GSM154203 2 0.1697 0.833 0.000 0.932 0.000 0.060 0.008
#> GSM154204 2 0.0000 0.875 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.1697 0.833 0.000 0.932 0.000 0.060 0.008
#> GSM154206 2 0.0000 0.875 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0798 0.864 0.000 0.976 0.000 0.016 0.008
#> GSM154208 2 0.0000 0.875 0.000 1.000 0.000 0.000 0.000
#> GSM154209 4 0.4632 0.487 0.000 0.448 0.000 0.540 0.012
#> GSM154210 2 0.1697 0.833 0.000 0.932 0.000 0.060 0.008
#> GSM154211 4 0.4597 0.524 0.000 0.424 0.000 0.564 0.012
#> GSM154213 2 0.0000 0.875 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.875 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.5806 0.530 0.000 0.632 0.000 0.184 0.088 0.096
#> GSM154424 2 0.5483 0.450 0.000 0.488 0.000 0.012 0.088 0.412
#> GSM154425 4 0.1007 0.981 0.000 0.000 0.000 0.956 0.044 0.000
#> GSM154426 2 0.5763 0.537 0.000 0.640 0.000 0.172 0.088 0.100
#> GSM154427 2 0.5406 0.450 0.000 0.480 0.000 0.008 0.088 0.424
#> GSM154428 2 0.5792 0.534 0.000 0.636 0.000 0.176 0.088 0.100
#> GSM154429 2 0.5406 0.450 0.000 0.480 0.000 0.008 0.088 0.424
#> GSM154430 2 0.5406 0.450 0.000 0.480 0.000 0.008 0.088 0.424
#> GSM154434 1 0.2941 0.718 0.780 0.000 0.000 0.000 0.220 0.000
#> GSM154436 5 0.2112 0.977 0.000 0.000 0.088 0.016 0.896 0.000
#> GSM154437 5 0.2112 0.977 0.000 0.000 0.088 0.016 0.896 0.000
#> GSM154438 5 0.2112 0.977 0.000 0.000 0.088 0.016 0.896 0.000
#> GSM154439 5 0.2112 0.977 0.000 0.000 0.088 0.016 0.896 0.000
#> GSM154403 6 0.1327 0.989 0.000 0.064 0.000 0.000 0.000 0.936
#> GSM154404 6 0.1327 0.989 0.000 0.064 0.000 0.000 0.000 0.936
#> GSM154405 6 0.1501 0.983 0.000 0.076 0.000 0.000 0.000 0.924
#> GSM154406 6 0.1663 0.975 0.000 0.088 0.000 0.000 0.000 0.912
#> GSM154407 6 0.1327 0.989 0.000 0.064 0.000 0.000 0.000 0.936
#> GSM154408 4 0.0458 0.936 0.000 0.016 0.000 0.984 0.000 0.000
#> GSM154409 4 0.0790 0.980 0.000 0.000 0.000 0.968 0.032 0.000
#> GSM154410 4 0.0865 0.982 0.000 0.000 0.000 0.964 0.036 0.000
#> GSM154411 4 0.1007 0.981 0.000 0.000 0.000 0.956 0.044 0.000
#> GSM154412 4 0.0937 0.982 0.000 0.000 0.000 0.960 0.040 0.000
#> GSM154413 3 0.0000 0.984 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154414 3 0.0000 0.984 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154415 3 0.0000 0.984 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154416 3 0.0000 0.984 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154417 3 0.0363 0.973 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM154418 5 0.3176 0.874 0.000 0.000 0.156 0.000 0.812 0.032
#> GSM154419 3 0.0000 0.984 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154420 5 0.2112 0.977 0.000 0.000 0.088 0.016 0.896 0.000
#> GSM154421 3 0.1334 0.958 0.000 0.000 0.948 0.000 0.020 0.032
#> GSM154422 3 0.1390 0.959 0.004 0.000 0.948 0.000 0.016 0.032
#> GSM154203 2 0.0713 0.686 0.000 0.972 0.000 0.000 0.000 0.028
#> GSM154204 2 0.2969 0.654 0.000 0.776 0.000 0.000 0.000 0.224
#> GSM154205 2 0.0865 0.687 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM154206 2 0.3050 0.650 0.000 0.764 0.000 0.000 0.000 0.236
#> GSM154207 2 0.1141 0.689 0.000 0.948 0.000 0.000 0.000 0.052
#> GSM154208 2 0.3076 0.648 0.000 0.760 0.000 0.000 0.000 0.240
#> GSM154209 2 0.1663 0.643 0.000 0.912 0.000 0.088 0.000 0.000
#> GSM154210 2 0.0865 0.687 0.000 0.964 0.000 0.000 0.000 0.036
#> GSM154211 2 0.2092 0.624 0.000 0.876 0.000 0.124 0.000 0.000
#> GSM154213 2 0.3076 0.648 0.000 0.760 0.000 0.000 0.000 0.240
#> GSM154214 2 0.3101 0.646 0.000 0.756 0.000 0.000 0.000 0.244
#> GSM154217 1 0.0000 0.980 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.980 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154221 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154223 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154224 1 0.0000 0.980 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.980 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.980 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154229 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154231 1 0.0146 0.980 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154232 1 0.0000 0.980 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> CV:skmeans 56 2.95e-05 5.37e-13 2
#> CV:skmeans 55 2.96e-07 1.72e-10 3
#> CV:skmeans 50 2.27e-11 1.39e-11 4
#> CV:skmeans 54 2.14e-11 5.26e-11 5
#> CV:skmeans 52 2.53e-15 5.39e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "pam"]
# you can also extract it by
# res = res_list["CV:pam"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.971 0.988 0.5089 0.491 0.491
#> 3 3 0.679 0.760 0.865 0.2495 0.850 0.702
#> 4 4 0.756 0.699 0.881 0.1698 0.805 0.522
#> 5 5 0.817 0.703 0.825 0.0545 0.946 0.798
#> 6 6 0.946 0.896 0.959 0.0627 0.903 0.601
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
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
#> GSM154423 2 0.0000 0.988 0.000 1.000
#> GSM154424 2 0.0000 0.988 0.000 1.000
#> GSM154425 2 0.6247 0.820 0.156 0.844
#> GSM154426 2 0.0000 0.988 0.000 1.000
#> GSM154427 2 0.0000 0.988 0.000 1.000
#> GSM154428 2 0.0000 0.988 0.000 1.000
#> GSM154429 2 0.0000 0.988 0.000 1.000
#> GSM154430 2 0.0000 0.988 0.000 1.000
#> GSM154434 1 0.0000 0.986 1.000 0.000
#> GSM154436 1 0.0000 0.986 1.000 0.000
#> GSM154437 1 0.0000 0.986 1.000 0.000
#> GSM154438 1 0.0000 0.986 1.000 0.000
#> GSM154439 1 0.0000 0.986 1.000 0.000
#> GSM154403 2 0.0000 0.988 0.000 1.000
#> GSM154404 2 0.0000 0.988 0.000 1.000
#> GSM154405 2 0.0000 0.988 0.000 1.000
#> GSM154406 2 0.0000 0.988 0.000 1.000
#> GSM154407 2 0.0000 0.988 0.000 1.000
#> GSM154408 2 0.0000 0.988 0.000 1.000
#> GSM154409 2 0.5737 0.846 0.136 0.864
#> GSM154410 2 0.0376 0.985 0.004 0.996
#> GSM154411 1 0.9393 0.430 0.644 0.356
#> GSM154412 2 0.1414 0.971 0.020 0.980
#> GSM154413 1 0.0000 0.986 1.000 0.000
#> GSM154414 1 0.0000 0.986 1.000 0.000
#> GSM154415 1 0.0000 0.986 1.000 0.000
#> GSM154416 1 0.0000 0.986 1.000 0.000
#> GSM154417 1 0.0000 0.986 1.000 0.000
#> GSM154418 1 0.0000 0.986 1.000 0.000
#> GSM154419 1 0.0000 0.986 1.000 0.000
#> GSM154420 1 0.0000 0.986 1.000 0.000
#> GSM154421 1 0.0000 0.986 1.000 0.000
#> GSM154422 1 0.0000 0.986 1.000 0.000
#> GSM154203 2 0.0000 0.988 0.000 1.000
#> GSM154204 2 0.0000 0.988 0.000 1.000
#> GSM154205 2 0.0000 0.988 0.000 1.000
#> GSM154206 2 0.0000 0.988 0.000 1.000
#> GSM154207 2 0.0000 0.988 0.000 1.000
#> GSM154208 2 0.0000 0.988 0.000 1.000
#> GSM154209 2 0.0000 0.988 0.000 1.000
#> GSM154210 2 0.0000 0.988 0.000 1.000
#> GSM154211 2 0.0000 0.988 0.000 1.000
#> GSM154213 2 0.0000 0.988 0.000 1.000
#> GSM154214 2 0.0000 0.988 0.000 1.000
#> GSM154217 1 0.0000 0.986 1.000 0.000
#> GSM154219 1 0.0000 0.986 1.000 0.000
#> GSM154220 1 0.0000 0.986 1.000 0.000
#> GSM154221 1 0.0000 0.986 1.000 0.000
#> GSM154223 1 0.0000 0.986 1.000 0.000
#> GSM154224 1 0.0000 0.986 1.000 0.000
#> GSM154225 1 0.0000 0.986 1.000 0.000
#> GSM154227 1 0.0000 0.986 1.000 0.000
#> GSM154228 1 0.0000 0.986 1.000 0.000
#> GSM154229 1 0.0000 0.986 1.000 0.000
#> GSM154231 1 0.0000 0.986 1.000 0.000
#> GSM154232 1 0.0000 0.986 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.5706 0.6453 0.000 0.680 0.320
#> GSM154424 2 0.4504 0.7860 0.000 0.804 0.196
#> GSM154425 3 0.4974 0.6125 0.000 0.236 0.764
#> GSM154426 2 0.5706 0.6453 0.000 0.680 0.320
#> GSM154427 2 0.0592 0.8745 0.000 0.988 0.012
#> GSM154428 2 0.5706 0.6453 0.000 0.680 0.320
#> GSM154429 2 0.4504 0.7860 0.000 0.804 0.196
#> GSM154430 2 0.4504 0.7860 0.000 0.804 0.196
#> GSM154434 1 0.2356 0.8513 0.928 0.000 0.072
#> GSM154436 3 0.5706 0.0961 0.320 0.000 0.680
#> GSM154437 3 0.5948 -0.0365 0.360 0.000 0.640
#> GSM154438 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154439 1 0.6280 0.4788 0.540 0.000 0.460
#> GSM154403 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154406 2 0.5706 0.6453 0.000 0.680 0.320
#> GSM154407 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154408 3 0.5016 0.6103 0.000 0.240 0.760
#> GSM154409 3 0.5016 0.6103 0.000 0.240 0.760
#> GSM154410 3 0.5016 0.6103 0.000 0.240 0.760
#> GSM154411 3 0.4452 0.6148 0.000 0.192 0.808
#> GSM154412 3 0.5016 0.6103 0.000 0.240 0.760
#> GSM154413 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154414 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154415 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154416 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154417 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154418 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154419 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154420 3 0.5706 0.0961 0.320 0.000 0.680
#> GSM154421 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154422 1 0.5016 0.8263 0.760 0.000 0.240
#> GSM154203 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154209 2 0.3941 0.8113 0.000 0.844 0.156
#> GSM154210 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154211 2 0.4121 0.8046 0.000 0.832 0.168
#> GSM154213 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.8785 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.8573 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.8573 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 4 0.4948 0.2316 0.000 0.440 0.000 0.560
#> GSM154424 2 0.4941 0.1553 0.000 0.564 0.000 0.436
#> GSM154425 4 0.0000 0.7215 0.000 0.000 0.000 1.000
#> GSM154426 4 0.4948 0.2316 0.000 0.440 0.000 0.560
#> GSM154427 2 0.3873 0.6193 0.000 0.772 0.000 0.228
#> GSM154428 4 0.4948 0.2316 0.000 0.440 0.000 0.560
#> GSM154429 2 0.4941 0.1553 0.000 0.564 0.000 0.436
#> GSM154430 2 0.4941 0.1553 0.000 0.564 0.000 0.436
#> GSM154434 3 0.4585 0.3801 0.332 0.000 0.668 0.000
#> GSM154436 3 0.4948 0.4715 0.000 0.000 0.560 0.440
#> GSM154437 3 0.4855 0.5216 0.000 0.000 0.600 0.400
#> GSM154438 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154439 3 0.3801 0.6995 0.000 0.000 0.780 0.220
#> GSM154403 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154404 2 0.3219 0.7063 0.000 0.836 0.000 0.164
#> GSM154405 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154406 4 0.4992 0.1225 0.000 0.476 0.000 0.524
#> GSM154407 2 0.0188 0.8429 0.000 0.996 0.000 0.004
#> GSM154408 4 0.0000 0.7215 0.000 0.000 0.000 1.000
#> GSM154409 4 0.0000 0.7215 0.000 0.000 0.000 1.000
#> GSM154410 4 0.0000 0.7215 0.000 0.000 0.000 1.000
#> GSM154411 4 0.0000 0.7215 0.000 0.000 0.000 1.000
#> GSM154412 4 0.0000 0.7215 0.000 0.000 0.000 1.000
#> GSM154413 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154414 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154415 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154416 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154417 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154418 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154419 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154420 3 0.4948 0.4715 0.000 0.000 0.560 0.440
#> GSM154421 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154422 3 0.0000 0.8348 0.000 0.000 1.000 0.000
#> GSM154203 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154209 2 0.3172 0.7106 0.000 0.840 0.000 0.160
#> GSM154210 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154211 2 0.3569 0.6662 0.000 0.804 0.000 0.196
#> GSM154213 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.8449 0.000 1.000 0.000 0.000
#> GSM154217 1 0.4697 0.4607 0.644 0.000 0.356 0.000
#> GSM154219 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154221 1 0.3266 0.7792 0.832 0.000 0.168 0.000
#> GSM154223 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154229 3 0.4933 0.0962 0.432 0.000 0.568 0.000
#> GSM154231 1 0.0000 0.9425 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9425 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.2813 0.2877 0.000 0.168 0.000 0.832 0.000
#> GSM154424 2 0.4171 0.6358 0.000 0.604 0.000 0.396 0.000
#> GSM154425 4 0.3949 0.7269 0.000 0.000 0.000 0.668 0.332
#> GSM154426 4 0.4161 -0.3471 0.000 0.392 0.000 0.608 0.000
#> GSM154427 2 0.4150 0.6407 0.000 0.612 0.000 0.388 0.000
#> GSM154428 2 0.4210 0.6249 0.000 0.588 0.000 0.412 0.000
#> GSM154429 2 0.4171 0.6358 0.000 0.604 0.000 0.396 0.000
#> GSM154430 2 0.4171 0.6358 0.000 0.604 0.000 0.396 0.000
#> GSM154434 3 0.4251 0.4602 0.316 0.000 0.672 0.000 0.012
#> GSM154436 5 0.4114 0.9791 0.000 0.000 0.376 0.000 0.624
#> GSM154437 5 0.4150 0.9947 0.000 0.000 0.388 0.000 0.612
#> GSM154438 5 0.4150 0.9947 0.000 0.000 0.388 0.000 0.612
#> GSM154439 5 0.4150 0.9947 0.000 0.000 0.388 0.000 0.612
#> GSM154403 2 0.5268 0.6501 0.000 0.612 0.000 0.320 0.068
#> GSM154404 2 0.5268 0.6501 0.000 0.612 0.000 0.320 0.068
#> GSM154405 2 0.5268 0.6501 0.000 0.612 0.000 0.320 0.068
#> GSM154406 4 0.4649 0.1724 0.000 0.212 0.000 0.720 0.068
#> GSM154407 2 0.5268 0.6501 0.000 0.612 0.000 0.320 0.068
#> GSM154408 4 0.3895 0.7337 0.000 0.000 0.000 0.680 0.320
#> GSM154409 4 0.3895 0.7337 0.000 0.000 0.000 0.680 0.320
#> GSM154410 4 0.3895 0.7337 0.000 0.000 0.000 0.680 0.320
#> GSM154411 4 0.3949 0.7269 0.000 0.000 0.000 0.668 0.332
#> GSM154412 4 0.3895 0.7337 0.000 0.000 0.000 0.680 0.320
#> GSM154413 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154414 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154415 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154416 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154417 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154418 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154419 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154420 5 0.4150 0.9947 0.000 0.000 0.388 0.000 0.612
#> GSM154421 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154422 3 0.0000 0.8523 0.000 0.000 1.000 0.000 0.000
#> GSM154203 2 0.0404 0.6965 0.000 0.988 0.000 0.012 0.000
#> GSM154204 2 0.0000 0.7007 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0404 0.6965 0.000 0.988 0.000 0.012 0.000
#> GSM154206 2 0.0000 0.7007 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0000 0.7007 0.000 1.000 0.000 0.000 0.000
#> GSM154208 2 0.0000 0.7007 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.4262 -0.0954 0.000 0.560 0.000 0.440 0.000
#> GSM154210 2 0.0404 0.6965 0.000 0.988 0.000 0.012 0.000
#> GSM154211 2 0.4262 -0.0954 0.000 0.560 0.000 0.440 0.000
#> GSM154213 2 0.0000 0.7007 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.1544 0.7006 0.000 0.932 0.000 0.068 0.000
#> GSM154217 1 0.4060 0.4138 0.640 0.000 0.360 0.000 0.000
#> GSM154219 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.2813 0.7700 0.832 0.000 0.168 0.000 0.000
#> GSM154223 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154229 3 0.4161 0.2705 0.392 0.000 0.608 0.000 0.000
#> GSM154231 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9402 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 6 0.0000 0.960 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154424 6 0.0000 0.960 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154425 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154426 6 0.0260 0.955 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM154427 6 0.0000 0.960 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154428 6 0.0000 0.960 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154429 6 0.0000 0.960 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154430 6 0.0000 0.960 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154434 3 0.3992 0.420 0.012 0.000 0.624 0.000 0.364 0.000
#> GSM154436 5 0.0458 1.000 0.000 0.000 0.016 0.000 0.984 0.000
#> GSM154437 5 0.0458 1.000 0.000 0.000 0.016 0.000 0.984 0.000
#> GSM154438 5 0.0458 1.000 0.000 0.000 0.016 0.000 0.984 0.000
#> GSM154439 5 0.0458 1.000 0.000 0.000 0.016 0.000 0.984 0.000
#> GSM154403 6 0.0458 0.956 0.000 0.000 0.000 0.000 0.016 0.984
#> GSM154404 6 0.0458 0.956 0.000 0.000 0.000 0.000 0.016 0.984
#> GSM154405 6 0.0363 0.957 0.000 0.000 0.000 0.000 0.012 0.988
#> GSM154406 2 0.4141 0.331 0.000 0.596 0.000 0.000 0.016 0.388
#> GSM154407 6 0.0458 0.956 0.000 0.000 0.000 0.000 0.016 0.984
#> GSM154408 4 0.0146 0.995 0.000 0.004 0.000 0.996 0.000 0.000
#> GSM154409 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154410 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154411 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154412 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154413 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154414 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154415 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154416 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154417 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154419 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154420 5 0.0458 1.000 0.000 0.000 0.016 0.000 0.984 0.000
#> GSM154421 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154422 3 0.0000 0.918 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154203 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154206 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.2092 0.819 0.000 0.876 0.000 0.000 0.000 0.124
#> GSM154208 2 0.0260 0.928 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM154209 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154210 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154211 2 0.0000 0.932 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154213 2 0.0790 0.912 0.000 0.968 0.000 0.000 0.000 0.032
#> GSM154214 6 0.3547 0.464 0.000 0.332 0.000 0.000 0.000 0.668
#> GSM154217 1 0.3647 0.415 0.640 0.000 0.360 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.2527 0.772 0.832 0.000 0.168 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154229 3 0.3647 0.385 0.360 0.000 0.640 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.938 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> CV:pam 55 2.84e-05 8.91e-13 2
#> CV:pam 52 1.87e-06 5.11e-12 3
#> CV:pam 44 3.76e-11 1.51e-09 4
#> CV:pam 48 1.18e-12 9.44e-10 5
#> CV:pam 51 3.12e-19 8.65e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "mclust"]
# you can also extract it by
# res = res_list["CV:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.999 1.000 0.5089 0.492 0.492
#> 3 3 0.685 0.907 0.934 0.2322 0.882 0.760
#> 4 4 0.802 0.704 0.881 0.1535 0.846 0.618
#> 5 5 0.825 0.850 0.897 0.0849 0.875 0.595
#> 6 6 0.997 0.965 0.978 0.0338 0.977 0.890
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2
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
#> GSM154423 2 0.0000 1.000 0.000 1.000
#> GSM154424 2 0.0000 1.000 0.000 1.000
#> GSM154425 2 0.0000 1.000 0.000 1.000
#> GSM154426 2 0.0000 1.000 0.000 1.000
#> GSM154427 2 0.0000 1.000 0.000 1.000
#> GSM154428 2 0.0000 1.000 0.000 1.000
#> GSM154429 2 0.0000 1.000 0.000 1.000
#> GSM154430 2 0.0000 1.000 0.000 1.000
#> GSM154434 1 0.0000 0.999 1.000 0.000
#> GSM154436 1 0.0376 0.997 0.996 0.004
#> GSM154437 1 0.0376 0.997 0.996 0.004
#> GSM154438 1 0.0000 0.999 1.000 0.000
#> GSM154439 1 0.0376 0.997 0.996 0.004
#> GSM154403 2 0.0000 1.000 0.000 1.000
#> GSM154404 2 0.0000 1.000 0.000 1.000
#> GSM154405 2 0.0000 1.000 0.000 1.000
#> GSM154406 2 0.0000 1.000 0.000 1.000
#> GSM154407 2 0.0000 1.000 0.000 1.000
#> GSM154408 2 0.0000 1.000 0.000 1.000
#> GSM154409 2 0.0000 1.000 0.000 1.000
#> GSM154410 2 0.0000 1.000 0.000 1.000
#> GSM154411 2 0.0000 1.000 0.000 1.000
#> GSM154412 2 0.0000 1.000 0.000 1.000
#> GSM154413 1 0.0000 0.999 1.000 0.000
#> GSM154414 1 0.0000 0.999 1.000 0.000
#> GSM154415 1 0.0000 0.999 1.000 0.000
#> GSM154416 1 0.0000 0.999 1.000 0.000
#> GSM154417 1 0.0000 0.999 1.000 0.000
#> GSM154418 1 0.0376 0.997 0.996 0.004
#> GSM154419 1 0.0000 0.999 1.000 0.000
#> GSM154420 1 0.0376 0.997 0.996 0.004
#> GSM154421 1 0.0000 0.999 1.000 0.000
#> GSM154422 1 0.0000 0.999 1.000 0.000
#> GSM154203 2 0.0000 1.000 0.000 1.000
#> GSM154204 2 0.0000 1.000 0.000 1.000
#> GSM154205 2 0.0000 1.000 0.000 1.000
#> GSM154206 2 0.0000 1.000 0.000 1.000
#> GSM154207 2 0.0000 1.000 0.000 1.000
#> GSM154208 2 0.0000 1.000 0.000 1.000
#> GSM154209 2 0.0000 1.000 0.000 1.000
#> GSM154210 2 0.0000 1.000 0.000 1.000
#> GSM154211 2 0.0000 1.000 0.000 1.000
#> GSM154213 2 0.0000 1.000 0.000 1.000
#> GSM154214 2 0.0000 1.000 0.000 1.000
#> GSM154217 1 0.0000 0.999 1.000 0.000
#> GSM154219 1 0.0000 0.999 1.000 0.000
#> GSM154220 1 0.0000 0.999 1.000 0.000
#> GSM154221 1 0.0000 0.999 1.000 0.000
#> GSM154223 1 0.0000 0.999 1.000 0.000
#> GSM154224 1 0.0000 0.999 1.000 0.000
#> GSM154225 1 0.0000 0.999 1.000 0.000
#> GSM154227 1 0.0000 0.999 1.000 0.000
#> GSM154228 1 0.0000 0.999 1.000 0.000
#> GSM154229 1 0.0000 0.999 1.000 0.000
#> GSM154231 1 0.0000 0.999 1.000 0.000
#> GSM154232 1 0.0000 0.999 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154424 2 0.4605 0.836 0.000 0.796 0.204
#> GSM154425 2 0.4654 0.834 0.000 0.792 0.208
#> GSM154426 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154428 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154434 1 0.3941 0.762 0.844 0.000 0.156
#> GSM154436 3 0.0592 0.918 0.012 0.000 0.988
#> GSM154437 3 0.0592 0.918 0.012 0.000 0.988
#> GSM154438 3 0.1031 0.918 0.024 0.000 0.976
#> GSM154439 3 0.0592 0.918 0.012 0.000 0.988
#> GSM154403 2 0.4750 0.827 0.000 0.784 0.216
#> GSM154404 2 0.4750 0.827 0.000 0.784 0.216
#> GSM154405 2 0.4555 0.839 0.000 0.800 0.200
#> GSM154406 2 0.4605 0.836 0.000 0.796 0.204
#> GSM154407 2 0.4702 0.831 0.000 0.788 0.212
#> GSM154408 2 0.4235 0.849 0.000 0.824 0.176
#> GSM154409 2 0.4654 0.834 0.000 0.792 0.208
#> GSM154410 2 0.4605 0.836 0.000 0.796 0.204
#> GSM154411 2 0.4654 0.834 0.000 0.792 0.208
#> GSM154412 2 0.4504 0.842 0.000 0.804 0.196
#> GSM154413 3 0.3752 0.915 0.144 0.000 0.856
#> GSM154414 3 0.3752 0.915 0.144 0.000 0.856
#> GSM154415 3 0.3340 0.925 0.120 0.000 0.880
#> GSM154416 3 0.3551 0.921 0.132 0.000 0.868
#> GSM154417 3 0.3752 0.915 0.144 0.000 0.856
#> GSM154418 3 0.1031 0.923 0.024 0.000 0.976
#> GSM154419 3 0.3192 0.926 0.112 0.000 0.888
#> GSM154420 3 0.0592 0.918 0.012 0.000 0.988
#> GSM154421 3 0.1964 0.928 0.056 0.000 0.944
#> GSM154422 3 0.3752 0.915 0.144 0.000 0.856
#> GSM154203 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154209 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154210 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154211 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.902 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.983 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.983 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.0188 0.8369 0.000 0.996 0.000 0.004
#> GSM154424 2 0.5137 0.1958 0.000 0.544 0.004 0.452
#> GSM154425 4 0.3726 0.6180 0.000 0.212 0.000 0.788
#> GSM154426 2 0.0188 0.8369 0.000 0.996 0.000 0.004
#> GSM154427 2 0.0188 0.8369 0.000 0.996 0.000 0.004
#> GSM154428 2 0.0188 0.8369 0.000 0.996 0.000 0.004
#> GSM154429 2 0.0188 0.8369 0.000 0.996 0.000 0.004
#> GSM154430 2 0.0188 0.8369 0.000 0.996 0.000 0.004
#> GSM154434 1 0.4018 0.6779 0.772 0.000 0.004 0.224
#> GSM154436 4 0.1474 0.7659 0.000 0.000 0.052 0.948
#> GSM154437 4 0.1576 0.7672 0.004 0.000 0.048 0.948
#> GSM154438 4 0.5466 0.5278 0.292 0.000 0.040 0.668
#> GSM154439 4 0.1677 0.7658 0.012 0.000 0.040 0.948
#> GSM154403 3 0.5423 0.4779 0.000 0.028 0.640 0.332
#> GSM154404 3 0.5271 0.4752 0.000 0.020 0.640 0.340
#> GSM154405 3 0.7841 0.0615 0.000 0.272 0.396 0.332
#> GSM154406 3 0.7808 0.0622 0.000 0.256 0.400 0.344
#> GSM154407 2 0.7745 -0.0691 0.000 0.420 0.240 0.340
#> GSM154408 2 0.4933 0.2535 0.000 0.568 0.000 0.432
#> GSM154409 2 0.4981 0.1825 0.000 0.536 0.000 0.464
#> GSM154410 2 0.5161 0.1407 0.000 0.520 0.004 0.476
#> GSM154411 4 0.4543 0.3725 0.000 0.324 0.000 0.676
#> GSM154412 2 0.4992 0.1458 0.000 0.524 0.000 0.476
#> GSM154413 3 0.0000 0.7509 0.000 0.000 1.000 0.000
#> GSM154414 3 0.0000 0.7509 0.000 0.000 1.000 0.000
#> GSM154415 3 0.0000 0.7509 0.000 0.000 1.000 0.000
#> GSM154416 3 0.0000 0.7509 0.000 0.000 1.000 0.000
#> GSM154417 3 0.0000 0.7509 0.000 0.000 1.000 0.000
#> GSM154418 3 0.4916 0.2879 0.000 0.000 0.576 0.424
#> GSM154419 3 0.0188 0.7508 0.000 0.000 0.996 0.004
#> GSM154420 4 0.1474 0.7659 0.000 0.000 0.052 0.948
#> GSM154421 3 0.1637 0.7292 0.000 0.000 0.940 0.060
#> GSM154422 3 0.0592 0.7482 0.000 0.000 0.984 0.016
#> GSM154203 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154209 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154210 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154211 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154213 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.8376 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.9791 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9791 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.3707 0.772 0.000 0.716 0.000 0.284 0.000
#> GSM154424 4 0.4309 0.696 0.000 0.308 0.000 0.676 0.016
#> GSM154425 4 0.2209 0.763 0.000 0.056 0.000 0.912 0.032
#> GSM154426 2 0.3707 0.772 0.000 0.716 0.000 0.284 0.000
#> GSM154427 2 0.0703 0.774 0.000 0.976 0.000 0.024 0.000
#> GSM154428 2 0.3707 0.772 0.000 0.716 0.000 0.284 0.000
#> GSM154429 2 0.2690 0.789 0.000 0.844 0.000 0.156 0.000
#> GSM154430 2 0.0703 0.774 0.000 0.976 0.000 0.024 0.000
#> GSM154434 1 0.2522 0.861 0.880 0.000 0.012 0.000 0.108
#> GSM154436 5 0.1410 0.966 0.000 0.000 0.060 0.000 0.940
#> GSM154437 5 0.0963 0.971 0.000 0.000 0.036 0.000 0.964
#> GSM154438 5 0.1117 0.956 0.016 0.000 0.020 0.000 0.964
#> GSM154439 5 0.0510 0.964 0.000 0.000 0.016 0.000 0.984
#> GSM154403 4 0.4410 0.682 0.000 0.276 0.008 0.700 0.016
#> GSM154404 4 0.4516 0.680 0.000 0.276 0.012 0.696 0.016
#> GSM154405 4 0.4331 0.593 0.000 0.400 0.000 0.596 0.004
#> GSM154406 4 0.1956 0.748 0.000 0.076 0.000 0.916 0.008
#> GSM154407 4 0.4314 0.683 0.000 0.280 0.004 0.700 0.016
#> GSM154408 4 0.3098 0.700 0.000 0.148 0.000 0.836 0.016
#> GSM154409 4 0.1914 0.765 0.000 0.060 0.000 0.924 0.016
#> GSM154410 4 0.1845 0.766 0.000 0.056 0.000 0.928 0.016
#> GSM154411 4 0.2104 0.764 0.000 0.060 0.000 0.916 0.024
#> GSM154412 4 0.2777 0.727 0.000 0.120 0.000 0.864 0.016
#> GSM154413 3 0.0000 0.947 0.000 0.000 1.000 0.000 0.000
#> GSM154414 3 0.0000 0.947 0.000 0.000 1.000 0.000 0.000
#> GSM154415 3 0.0162 0.948 0.000 0.000 0.996 0.000 0.004
#> GSM154416 3 0.0162 0.948 0.000 0.000 0.996 0.000 0.004
#> GSM154417 3 0.0000 0.947 0.000 0.000 1.000 0.000 0.000
#> GSM154418 3 0.3109 0.781 0.000 0.000 0.800 0.000 0.200
#> GSM154419 3 0.2377 0.872 0.000 0.000 0.872 0.000 0.128
#> GSM154420 5 0.1478 0.963 0.000 0.000 0.064 0.000 0.936
#> GSM154421 3 0.1544 0.916 0.000 0.000 0.932 0.000 0.068
#> GSM154422 3 0.0290 0.946 0.000 0.000 0.992 0.000 0.008
#> GSM154203 2 0.3612 0.778 0.000 0.732 0.000 0.268 0.000
#> GSM154204 2 0.0162 0.783 0.000 0.996 0.000 0.004 0.000
#> GSM154205 2 0.3612 0.778 0.000 0.732 0.000 0.268 0.000
#> GSM154206 2 0.0609 0.789 0.000 0.980 0.000 0.020 0.000
#> GSM154207 2 0.0290 0.778 0.000 0.992 0.000 0.008 0.000
#> GSM154208 2 0.0510 0.788 0.000 0.984 0.000 0.016 0.000
#> GSM154209 2 0.3612 0.778 0.000 0.732 0.000 0.268 0.000
#> GSM154210 2 0.3612 0.778 0.000 0.732 0.000 0.268 0.000
#> GSM154211 2 0.3796 0.750 0.000 0.700 0.000 0.300 0.000
#> GSM154213 2 0.0290 0.776 0.000 0.992 0.000 0.008 0.000
#> GSM154214 2 0.0290 0.776 0.000 0.992 0.000 0.008 0.000
#> GSM154217 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.0858 0.978 0.000 0.968 0.000 0.028 0.000 0.004
#> GSM154424 6 0.3076 0.767 0.000 0.000 0.000 0.240 0.000 0.760
#> GSM154425 4 0.0000 0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154426 2 0.0777 0.980 0.000 0.972 0.000 0.024 0.000 0.004
#> GSM154427 2 0.0858 0.979 0.000 0.968 0.000 0.028 0.000 0.004
#> GSM154428 2 0.0858 0.978 0.000 0.968 0.000 0.028 0.000 0.004
#> GSM154429 2 0.0858 0.979 0.000 0.968 0.000 0.028 0.000 0.004
#> GSM154430 2 0.0858 0.979 0.000 0.968 0.000 0.028 0.000 0.004
#> GSM154434 1 0.1765 0.890 0.904 0.000 0.000 0.000 0.096 0.000
#> GSM154436 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154437 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154438 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154403 6 0.0260 0.897 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154404 6 0.0260 0.897 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154405 6 0.2420 0.875 0.000 0.040 0.000 0.076 0.000 0.884
#> GSM154406 6 0.3101 0.845 0.000 0.032 0.000 0.148 0.000 0.820
#> GSM154407 6 0.0260 0.897 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154408 4 0.0865 0.939 0.000 0.036 0.000 0.964 0.000 0.000
#> GSM154409 4 0.0000 0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154410 4 0.0000 0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154411 4 0.0000 0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154412 4 0.0000 0.988 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154413 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154414 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154415 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154416 3 0.0146 0.960 0.000 0.000 0.996 0.000 0.004 0.000
#> GSM154417 3 0.0000 0.960 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 3 0.2631 0.814 0.000 0.000 0.820 0.000 0.180 0.000
#> GSM154419 3 0.1141 0.947 0.000 0.000 0.948 0.000 0.052 0.000
#> GSM154420 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154421 3 0.1075 0.949 0.000 0.000 0.952 0.000 0.048 0.000
#> GSM154422 3 0.0937 0.952 0.000 0.000 0.960 0.000 0.040 0.000
#> GSM154203 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154206 2 0.0146 0.986 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154207 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154208 2 0.0146 0.986 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154209 2 0.0260 0.986 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM154210 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154211 2 0.0260 0.986 0.000 0.992 0.000 0.008 0.000 0.000
#> GSM154213 2 0.0000 0.987 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0146 0.986 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154217 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> CV:mclust 56 2.95e-05 5.37e-13 2
#> CV:mclust 56 2.39e-11 6.91e-13 3
#> CV:mclust 44 3.51e-15 8.14e-09 4
#> CV:mclust 56 4.23e-17 2.01e-11 5
#> CV:mclust 56 1.08e-15 8.13e-11 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["CV", "NMF"]
# you can also extract it by
# res = res_list["CV:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.863 0.856 0.945 0.2519 0.856 0.713
#> 4 4 0.765 0.628 0.830 0.1482 0.851 0.624
#> 5 5 0.851 0.813 0.903 0.0825 0.864 0.554
#> 6 6 0.823 0.706 0.820 0.0407 0.945 0.754
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154424 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154425 3 0.5760 0.401 0.000 0.328 0.672
#> GSM154426 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154428 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154434 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154436 3 0.0237 0.854 0.004 0.000 0.996
#> GSM154437 3 0.0237 0.854 0.004 0.000 0.996
#> GSM154438 3 0.0892 0.846 0.020 0.000 0.980
#> GSM154439 3 0.0237 0.854 0.004 0.000 0.996
#> GSM154403 2 0.0237 0.963 0.000 0.996 0.004
#> GSM154404 2 0.0237 0.963 0.000 0.996 0.004
#> GSM154405 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154406 2 0.0237 0.963 0.000 0.996 0.004
#> GSM154407 2 0.0237 0.963 0.000 0.996 0.004
#> GSM154408 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154409 2 0.5650 0.564 0.000 0.688 0.312
#> GSM154410 2 0.3816 0.817 0.000 0.852 0.148
#> GSM154411 3 0.0237 0.851 0.000 0.004 0.996
#> GSM154412 2 0.6111 0.380 0.000 0.604 0.396
#> GSM154413 1 0.0892 0.919 0.980 0.000 0.020
#> GSM154414 1 0.3116 0.847 0.892 0.000 0.108
#> GSM154415 3 0.6305 -0.101 0.484 0.000 0.516
#> GSM154416 1 0.6299 0.111 0.524 0.000 0.476
#> GSM154417 1 0.1529 0.906 0.960 0.000 0.040
#> GSM154418 3 0.0000 0.852 0.000 0.000 1.000
#> GSM154419 1 0.4931 0.694 0.768 0.000 0.232
#> GSM154420 3 0.0237 0.854 0.004 0.000 0.996
#> GSM154421 3 0.4974 0.589 0.236 0.000 0.764
#> GSM154422 1 0.5327 0.635 0.728 0.000 0.272
#> GSM154203 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154209 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154210 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154211 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.965 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.929 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.929 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.3649 0.7089 0.000 0.796 0.000 0.204
#> GSM154424 2 0.0817 0.8368 0.000 0.976 0.000 0.024
#> GSM154425 3 0.7883 -0.0423 0.000 0.336 0.376 0.288
#> GSM154426 2 0.0817 0.8322 0.000 0.976 0.000 0.024
#> GSM154427 2 0.0592 0.8368 0.000 0.984 0.000 0.016
#> GSM154428 2 0.3444 0.7276 0.000 0.816 0.000 0.184
#> GSM154429 2 0.0336 0.8377 0.000 0.992 0.000 0.008
#> GSM154430 2 0.0592 0.8368 0.000 0.984 0.000 0.016
#> GSM154434 1 0.0469 0.9870 0.988 0.000 0.012 0.000
#> GSM154436 3 0.0707 0.5977 0.000 0.000 0.980 0.020
#> GSM154437 3 0.0000 0.6075 0.000 0.000 1.000 0.000
#> GSM154438 3 0.1411 0.5971 0.020 0.000 0.960 0.020
#> GSM154439 3 0.0000 0.6075 0.000 0.000 1.000 0.000
#> GSM154403 4 0.4500 0.3834 0.000 0.316 0.000 0.684
#> GSM154404 4 0.4454 0.3852 0.000 0.308 0.000 0.692
#> GSM154405 2 0.4661 0.3976 0.000 0.652 0.000 0.348
#> GSM154406 2 0.4406 0.5013 0.000 0.700 0.000 0.300
#> GSM154407 2 0.5000 -0.0327 0.000 0.504 0.000 0.496
#> GSM154408 2 0.4730 0.5406 0.000 0.636 0.000 0.364
#> GSM154409 4 0.7519 -0.2035 0.000 0.392 0.184 0.424
#> GSM154410 4 0.7275 -0.1678 0.000 0.376 0.152 0.472
#> GSM154411 3 0.5769 0.2571 0.000 0.036 0.588 0.376
#> GSM154412 2 0.7715 0.1734 0.000 0.436 0.240 0.324
#> GSM154413 4 0.4804 0.3507 0.016 0.000 0.276 0.708
#> GSM154414 4 0.4831 0.3466 0.016 0.000 0.280 0.704
#> GSM154415 4 0.4920 0.2146 0.004 0.000 0.368 0.628
#> GSM154416 3 0.5273 0.0983 0.008 0.000 0.536 0.456
#> GSM154417 4 0.5022 0.3523 0.028 0.000 0.264 0.708
#> GSM154418 3 0.4500 0.3927 0.000 0.000 0.684 0.316
#> GSM154419 3 0.5671 0.2142 0.028 0.000 0.572 0.400
#> GSM154420 3 0.0188 0.6073 0.000 0.000 0.996 0.004
#> GSM154421 3 0.4889 0.3192 0.004 0.000 0.636 0.360
#> GSM154422 4 0.5526 0.0577 0.020 0.000 0.416 0.564
#> GSM154203 2 0.0592 0.8350 0.000 0.984 0.000 0.016
#> GSM154204 2 0.0469 0.8375 0.000 0.988 0.000 0.012
#> GSM154205 2 0.0592 0.8350 0.000 0.984 0.000 0.016
#> GSM154206 2 0.0592 0.8368 0.000 0.984 0.000 0.016
#> GSM154207 2 0.0000 0.8372 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0592 0.8368 0.000 0.984 0.000 0.016
#> GSM154209 2 0.2530 0.7814 0.000 0.888 0.000 0.112
#> GSM154210 2 0.0592 0.8350 0.000 0.984 0.000 0.016
#> GSM154211 2 0.3528 0.7206 0.000 0.808 0.000 0.192
#> GSM154213 2 0.0592 0.8368 0.000 0.984 0.000 0.016
#> GSM154214 2 0.0592 0.8368 0.000 0.984 0.000 0.016
#> GSM154217 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.9989 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9989 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.2966 0.755 0.000 0.184 0.000 0.816 0.000
#> GSM154424 2 0.3495 0.768 0.000 0.816 0.032 0.152 0.000
#> GSM154425 4 0.0566 0.845 0.000 0.004 0.000 0.984 0.012
#> GSM154426 2 0.4464 0.207 0.000 0.584 0.008 0.408 0.000
#> GSM154427 2 0.0324 0.945 0.000 0.992 0.004 0.004 0.000
#> GSM154428 4 0.3999 0.499 0.000 0.344 0.000 0.656 0.000
#> GSM154429 2 0.0290 0.943 0.000 0.992 0.000 0.008 0.000
#> GSM154430 2 0.0609 0.937 0.000 0.980 0.000 0.020 0.000
#> GSM154434 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154436 5 0.0880 0.740 0.000 0.000 0.000 0.032 0.968
#> GSM154437 5 0.0794 0.742 0.000 0.000 0.000 0.028 0.972
#> GSM154438 5 0.0955 0.741 0.004 0.000 0.000 0.028 0.968
#> GSM154439 5 0.0794 0.742 0.000 0.000 0.000 0.028 0.972
#> GSM154403 3 0.1522 0.712 0.000 0.044 0.944 0.012 0.000
#> GSM154404 3 0.1012 0.709 0.000 0.020 0.968 0.012 0.000
#> GSM154405 3 0.4637 0.164 0.000 0.452 0.536 0.012 0.000
#> GSM154406 3 0.3238 0.676 0.000 0.136 0.836 0.028 0.000
#> GSM154407 3 0.3663 0.624 0.000 0.208 0.776 0.016 0.000
#> GSM154408 4 0.2654 0.841 0.000 0.032 0.084 0.884 0.000
#> GSM154409 4 0.2352 0.837 0.000 0.008 0.092 0.896 0.004
#> GSM154410 4 0.3211 0.782 0.000 0.004 0.164 0.824 0.008
#> GSM154411 4 0.0609 0.843 0.000 0.000 0.000 0.980 0.020
#> GSM154412 4 0.0451 0.849 0.000 0.008 0.000 0.988 0.004
#> GSM154413 3 0.2020 0.676 0.000 0.000 0.900 0.000 0.100
#> GSM154414 3 0.2424 0.648 0.000 0.000 0.868 0.000 0.132
#> GSM154415 5 0.4219 0.524 0.000 0.000 0.416 0.000 0.584
#> GSM154416 5 0.4045 0.629 0.000 0.000 0.356 0.000 0.644
#> GSM154417 3 0.2471 0.650 0.000 0.000 0.864 0.000 0.136
#> GSM154418 5 0.3966 0.654 0.000 0.000 0.336 0.000 0.664
#> GSM154419 5 0.4074 0.627 0.000 0.000 0.364 0.000 0.636
#> GSM154420 5 0.0794 0.742 0.000 0.000 0.000 0.028 0.972
#> GSM154421 5 0.3983 0.652 0.000 0.000 0.340 0.000 0.660
#> GSM154422 3 0.3424 0.464 0.000 0.000 0.760 0.000 0.240
#> GSM154203 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154206 2 0.0162 0.946 0.000 0.996 0.004 0.000 0.000
#> GSM154207 2 0.0162 0.945 0.000 0.996 0.000 0.004 0.000
#> GSM154208 2 0.0162 0.946 0.000 0.996 0.004 0.000 0.000
#> GSM154209 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154210 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM154211 2 0.1608 0.885 0.000 0.928 0.000 0.072 0.000
#> GSM154213 2 0.0162 0.946 0.000 0.996 0.004 0.000 0.000
#> GSM154214 2 0.0162 0.946 0.000 0.996 0.004 0.000 0.000
#> GSM154217 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 1.000 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.4486 -0.2890 0.000 0.512 0.008 0.464 0.000 0.016
#> GSM154424 2 0.3203 0.4425 0.000 0.852 0.056 0.064 0.000 0.028
#> GSM154425 4 0.0508 0.8429 0.000 0.012 0.004 0.984 0.000 0.000
#> GSM154426 2 0.3463 0.3530 0.000 0.800 0.008 0.160 0.000 0.032
#> GSM154427 2 0.0777 0.5567 0.000 0.972 0.004 0.000 0.000 0.024
#> GSM154428 2 0.3738 0.1430 0.000 0.680 0.004 0.312 0.000 0.004
#> GSM154429 2 0.0891 0.5775 0.000 0.968 0.024 0.000 0.000 0.008
#> GSM154430 2 0.0837 0.5524 0.000 0.972 0.004 0.004 0.000 0.020
#> GSM154434 1 0.0692 0.9765 0.976 0.000 0.004 0.000 0.020 0.000
#> GSM154436 5 0.0777 0.7704 0.000 0.000 0.004 0.024 0.972 0.000
#> GSM154437 5 0.0291 0.7845 0.000 0.000 0.004 0.004 0.992 0.000
#> GSM154438 5 0.0000 0.7844 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0146 0.7846 0.000 0.000 0.000 0.004 0.996 0.000
#> GSM154403 6 0.0632 0.7414 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM154404 6 0.0632 0.7414 0.000 0.024 0.000 0.000 0.000 0.976
#> GSM154405 6 0.4356 0.6410 0.000 0.136 0.140 0.000 0.000 0.724
#> GSM154406 6 0.3123 0.7339 0.000 0.032 0.116 0.012 0.000 0.840
#> GSM154407 6 0.3032 0.7329 0.000 0.056 0.104 0.000 0.000 0.840
#> GSM154408 4 0.2740 0.8237 0.000 0.028 0.000 0.852 0.000 0.120
#> GSM154409 4 0.2482 0.8158 0.000 0.000 0.000 0.848 0.004 0.148
#> GSM154410 4 0.3944 0.3900 0.000 0.000 0.000 0.568 0.004 0.428
#> GSM154411 4 0.0405 0.8480 0.000 0.000 0.000 0.988 0.008 0.004
#> GSM154412 4 0.0291 0.8488 0.000 0.000 0.000 0.992 0.004 0.004
#> GSM154413 6 0.4195 0.3312 0.000 0.000 0.200 0.000 0.076 0.724
#> GSM154414 6 0.3893 0.4382 0.000 0.000 0.092 0.000 0.140 0.768
#> GSM154415 5 0.5093 0.0774 0.000 0.000 0.192 0.000 0.632 0.176
#> GSM154416 5 0.5233 -0.3118 0.000 0.000 0.332 0.000 0.556 0.112
#> GSM154417 3 0.5759 0.5639 0.000 0.004 0.440 0.000 0.148 0.408
#> GSM154418 3 0.5923 0.7933 0.000 0.000 0.496 0.008 0.312 0.184
#> GSM154419 3 0.5792 0.7624 0.000 0.000 0.464 0.000 0.348 0.188
#> GSM154420 5 0.0146 0.7844 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM154421 3 0.5601 0.7673 0.000 0.000 0.500 0.000 0.344 0.156
#> GSM154422 3 0.6590 0.7454 0.000 0.068 0.512 0.000 0.204 0.216
#> GSM154203 2 0.3847 0.7390 0.000 0.544 0.456 0.000 0.000 0.000
#> GSM154204 2 0.4083 0.7362 0.000 0.532 0.460 0.000 0.000 0.008
#> GSM154205 2 0.3979 0.7385 0.000 0.540 0.456 0.000 0.000 0.004
#> GSM154206 2 0.3843 0.7392 0.000 0.548 0.452 0.000 0.000 0.000
#> GSM154207 2 0.3620 0.7126 0.000 0.648 0.352 0.000 0.000 0.000
#> GSM154208 2 0.4083 0.7362 0.000 0.532 0.460 0.000 0.000 0.008
#> GSM154209 2 0.3975 0.7390 0.000 0.544 0.452 0.004 0.000 0.000
#> GSM154210 2 0.4083 0.7362 0.000 0.532 0.460 0.000 0.000 0.008
#> GSM154211 2 0.4310 0.7358 0.000 0.540 0.440 0.020 0.000 0.000
#> GSM154213 2 0.4083 0.7362 0.000 0.532 0.460 0.000 0.000 0.008
#> GSM154214 2 0.3982 0.7376 0.000 0.536 0.460 0.000 0.000 0.004
#> GSM154217 1 0.0000 0.9920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0260 0.9919 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0146 0.9909 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154224 1 0.0458 0.9908 0.984 0.000 0.016 0.000 0.000 0.000
#> GSM154225 1 0.0458 0.9908 0.984 0.000 0.016 0.000 0.000 0.000
#> GSM154227 1 0.0458 0.9908 0.984 0.000 0.016 0.000 0.000 0.000
#> GSM154228 1 0.0260 0.9913 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154229 1 0.0260 0.9919 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154231 1 0.0260 0.9913 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154232 1 0.0458 0.9908 0.984 0.000 0.016 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> CV:NMF 56 2.95e-05 5.37e-13 2
#> CV:NMF 52 5.37e-07 2.95e-11 3
#> CV:NMF 38 2.67e-07 5.60e-09 4
#> CV:NMF 52 3.54e-14 3.71e-09 5
#> CV:NMF 47 5.22e-14 5.68e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "hclust"]
# you can also extract it by
# res = res_list["MAD:hclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.805 0.902 0.957 0.4996 0.507 0.507
#> 3 3 0.777 0.916 0.943 0.2678 0.843 0.690
#> 4 4 0.909 0.932 0.962 0.0802 0.981 0.944
#> 5 5 0.849 0.916 0.915 0.0897 0.924 0.770
#> 6 6 0.811 0.864 0.871 0.0823 0.942 0.770
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM154423 2 0.000 1.000 0.0 1.0
#> GSM154424 2 0.000 1.000 0.0 1.0
#> GSM154425 1 0.971 0.438 0.6 0.4
#> GSM154426 2 0.000 1.000 0.0 1.0
#> GSM154427 2 0.000 1.000 0.0 1.0
#> GSM154428 2 0.000 1.000 0.0 1.0
#> GSM154429 2 0.000 1.000 0.0 1.0
#> GSM154430 2 0.000 1.000 0.0 1.0
#> GSM154434 1 0.000 0.921 1.0 0.0
#> GSM154436 1 0.000 0.921 1.0 0.0
#> GSM154437 1 0.000 0.921 1.0 0.0
#> GSM154438 1 0.000 0.921 1.0 0.0
#> GSM154439 1 0.000 0.921 1.0 0.0
#> GSM154403 2 0.000 1.000 0.0 1.0
#> GSM154404 2 0.000 1.000 0.0 1.0
#> GSM154405 2 0.000 1.000 0.0 1.0
#> GSM154406 2 0.000 1.000 0.0 1.0
#> GSM154407 2 0.000 1.000 0.0 1.0
#> GSM154408 1 0.971 0.438 0.6 0.4
#> GSM154409 1 0.971 0.438 0.6 0.4
#> GSM154410 1 0.971 0.438 0.6 0.4
#> GSM154411 1 0.971 0.438 0.6 0.4
#> GSM154412 1 0.971 0.438 0.6 0.4
#> GSM154413 1 0.000 0.921 1.0 0.0
#> GSM154414 1 0.000 0.921 1.0 0.0
#> GSM154415 1 0.000 0.921 1.0 0.0
#> GSM154416 1 0.000 0.921 1.0 0.0
#> GSM154417 1 0.000 0.921 1.0 0.0
#> GSM154418 1 0.000 0.921 1.0 0.0
#> GSM154419 1 0.000 0.921 1.0 0.0
#> GSM154420 1 0.000 0.921 1.0 0.0
#> GSM154421 1 0.000 0.921 1.0 0.0
#> GSM154422 1 0.000 0.921 1.0 0.0
#> GSM154203 2 0.000 1.000 0.0 1.0
#> GSM154204 2 0.000 1.000 0.0 1.0
#> GSM154205 2 0.000 1.000 0.0 1.0
#> GSM154206 2 0.000 1.000 0.0 1.0
#> GSM154207 2 0.000 1.000 0.0 1.0
#> GSM154208 2 0.000 1.000 0.0 1.0
#> GSM154209 2 0.000 1.000 0.0 1.0
#> GSM154210 2 0.000 1.000 0.0 1.0
#> GSM154211 2 0.000 1.000 0.0 1.0
#> GSM154213 2 0.000 1.000 0.0 1.0
#> GSM154214 2 0.000 1.000 0.0 1.0
#> GSM154217 1 0.000 0.921 1.0 0.0
#> GSM154219 1 0.000 0.921 1.0 0.0
#> GSM154220 1 0.000 0.921 1.0 0.0
#> GSM154221 1 0.000 0.921 1.0 0.0
#> GSM154223 1 0.000 0.921 1.0 0.0
#> GSM154224 1 0.000 0.921 1.0 0.0
#> GSM154225 1 0.000 0.921 1.0 0.0
#> GSM154227 1 0.000 0.921 1.0 0.0
#> GSM154228 1 0.000 0.921 1.0 0.0
#> GSM154229 1 0.000 0.921 1.0 0.0
#> GSM154231 1 0.000 0.921 1.0 0.0
#> GSM154232 1 0.000 0.921 1.0 0.0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.000 1.000 0.000 1.00 0.000
#> GSM154424 2 0.000 1.000 0.000 1.00 0.000
#> GSM154425 3 0.369 0.789 0.000 0.14 0.860
#> GSM154426 2 0.000 1.000 0.000 1.00 0.000
#> GSM154427 2 0.000 1.000 0.000 1.00 0.000
#> GSM154428 2 0.000 1.000 0.000 1.00 0.000
#> GSM154429 2 0.000 1.000 0.000 1.00 0.000
#> GSM154430 2 0.000 1.000 0.000 1.00 0.000
#> GSM154434 1 0.319 0.836 0.888 0.00 0.112
#> GSM154436 3 0.522 0.665 0.260 0.00 0.740
#> GSM154437 3 0.522 0.665 0.260 0.00 0.740
#> GSM154438 3 0.522 0.665 0.260 0.00 0.740
#> GSM154439 3 0.522 0.665 0.260 0.00 0.740
#> GSM154403 2 0.000 1.000 0.000 1.00 0.000
#> GSM154404 2 0.000 1.000 0.000 1.00 0.000
#> GSM154405 2 0.000 1.000 0.000 1.00 0.000
#> GSM154406 2 0.000 1.000 0.000 1.00 0.000
#> GSM154407 2 0.000 1.000 0.000 1.00 0.000
#> GSM154408 3 0.369 0.789 0.000 0.14 0.860
#> GSM154409 3 0.369 0.789 0.000 0.14 0.860
#> GSM154410 3 0.369 0.789 0.000 0.14 0.860
#> GSM154411 3 0.369 0.789 0.000 0.14 0.860
#> GSM154412 3 0.369 0.789 0.000 0.14 0.860
#> GSM154413 1 0.216 0.931 0.936 0.00 0.064
#> GSM154414 1 0.216 0.931 0.936 0.00 0.064
#> GSM154415 1 0.216 0.931 0.936 0.00 0.064
#> GSM154416 1 0.216 0.931 0.936 0.00 0.064
#> GSM154417 1 0.216 0.931 0.936 0.00 0.064
#> GSM154418 1 0.475 0.771 0.784 0.00 0.216
#> GSM154419 1 0.216 0.931 0.936 0.00 0.064
#> GSM154420 3 0.522 0.665 0.260 0.00 0.740
#> GSM154421 1 0.475 0.771 0.784 0.00 0.216
#> GSM154422 1 0.288 0.909 0.904 0.00 0.096
#> GSM154203 2 0.000 1.000 0.000 1.00 0.000
#> GSM154204 2 0.000 1.000 0.000 1.00 0.000
#> GSM154205 2 0.000 1.000 0.000 1.00 0.000
#> GSM154206 2 0.000 1.000 0.000 1.00 0.000
#> GSM154207 2 0.000 1.000 0.000 1.00 0.000
#> GSM154208 2 0.000 1.000 0.000 1.00 0.000
#> GSM154209 2 0.000 1.000 0.000 1.00 0.000
#> GSM154210 2 0.000 1.000 0.000 1.00 0.000
#> GSM154211 2 0.000 1.000 0.000 1.00 0.000
#> GSM154213 2 0.000 1.000 0.000 1.00 0.000
#> GSM154214 2 0.000 1.000 0.000 1.00 0.000
#> GSM154217 1 0.000 0.947 1.000 0.00 0.000
#> GSM154219 1 0.000 0.947 1.000 0.00 0.000
#> GSM154220 1 0.000 0.947 1.000 0.00 0.000
#> GSM154221 1 0.000 0.947 1.000 0.00 0.000
#> GSM154223 1 0.000 0.947 1.000 0.00 0.000
#> GSM154224 1 0.000 0.947 1.000 0.00 0.000
#> GSM154225 1 0.000 0.947 1.000 0.00 0.000
#> GSM154227 1 0.000 0.947 1.000 0.00 0.000
#> GSM154228 1 0.000 0.947 1.000 0.00 0.000
#> GSM154229 1 0.000 0.947 1.000 0.00 0.000
#> GSM154231 1 0.000 0.947 1.000 0.00 0.000
#> GSM154232 1 0.000 0.947 1.000 0.00 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.000 1.000 0.000 1 0.000 0
#> GSM154424 2 0.000 1.000 0.000 1 0.000 0
#> GSM154425 4 0.000 1.000 0.000 0 0.000 1
#> GSM154426 2 0.000 1.000 0.000 1 0.000 0
#> GSM154427 2 0.000 1.000 0.000 1 0.000 0
#> GSM154428 2 0.000 1.000 0.000 1 0.000 0
#> GSM154429 2 0.000 1.000 0.000 1 0.000 0
#> GSM154430 2 0.000 1.000 0.000 1 0.000 0
#> GSM154434 1 0.253 0.807 0.888 0 0.112 0
#> GSM154436 3 0.000 1.000 0.000 0 1.000 0
#> GSM154437 3 0.000 1.000 0.000 0 1.000 0
#> GSM154438 3 0.000 1.000 0.000 0 1.000 0
#> GSM154439 3 0.000 1.000 0.000 0 1.000 0
#> GSM154403 2 0.000 1.000 0.000 1 0.000 0
#> GSM154404 2 0.000 1.000 0.000 1 0.000 0
#> GSM154405 2 0.000 1.000 0.000 1 0.000 0
#> GSM154406 2 0.000 1.000 0.000 1 0.000 0
#> GSM154407 2 0.000 1.000 0.000 1 0.000 0
#> GSM154408 4 0.000 1.000 0.000 0 0.000 1
#> GSM154409 4 0.000 1.000 0.000 0 0.000 1
#> GSM154410 4 0.000 1.000 0.000 0 0.000 1
#> GSM154411 4 0.000 1.000 0.000 0 0.000 1
#> GSM154412 4 0.000 1.000 0.000 0 0.000 1
#> GSM154413 1 0.317 0.841 0.840 0 0.160 0
#> GSM154414 1 0.317 0.841 0.840 0 0.160 0
#> GSM154415 1 0.317 0.841 0.840 0 0.160 0
#> GSM154416 1 0.317 0.841 0.840 0 0.160 0
#> GSM154417 1 0.317 0.841 0.840 0 0.160 0
#> GSM154418 1 0.499 0.314 0.524 0 0.476 0
#> GSM154419 1 0.317 0.841 0.840 0 0.160 0
#> GSM154420 3 0.000 1.000 0.000 0 1.000 0
#> GSM154421 1 0.480 0.539 0.616 0 0.384 0
#> GSM154422 1 0.376 0.791 0.784 0 0.216 0
#> GSM154203 2 0.000 1.000 0.000 1 0.000 0
#> GSM154204 2 0.000 1.000 0.000 1 0.000 0
#> GSM154205 2 0.000 1.000 0.000 1 0.000 0
#> GSM154206 2 0.000 1.000 0.000 1 0.000 0
#> GSM154207 2 0.000 1.000 0.000 1 0.000 0
#> GSM154208 2 0.000 1.000 0.000 1 0.000 0
#> GSM154209 2 0.000 1.000 0.000 1 0.000 0
#> GSM154210 2 0.000 1.000 0.000 1 0.000 0
#> GSM154211 2 0.000 1.000 0.000 1 0.000 0
#> GSM154213 2 0.000 1.000 0.000 1 0.000 0
#> GSM154214 2 0.000 1.000 0.000 1 0.000 0
#> GSM154217 1 0.000 0.891 1.000 0 0.000 0
#> GSM154219 1 0.000 0.891 1.000 0 0.000 0
#> GSM154220 1 0.000 0.891 1.000 0 0.000 0
#> GSM154221 1 0.000 0.891 1.000 0 0.000 0
#> GSM154223 1 0.000 0.891 1.000 0 0.000 0
#> GSM154224 1 0.000 0.891 1.000 0 0.000 0
#> GSM154225 1 0.000 0.891 1.000 0 0.000 0
#> GSM154227 1 0.000 0.891 1.000 0 0.000 0
#> GSM154228 1 0.000 0.891 1.000 0 0.000 0
#> GSM154229 1 0.000 0.891 1.000 0 0.000 0
#> GSM154231 1 0.000 0.891 1.000 0 0.000 0
#> GSM154232 1 0.000 0.891 1.000 0 0.000 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154424 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154425 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM154426 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154427 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154428 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154429 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154430 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154434 1 0.218 0.833 0.888 0.000 0.000 0 0.112
#> GSM154436 5 0.148 1.000 0.000 0.000 0.064 0 0.936
#> GSM154437 5 0.148 1.000 0.000 0.000 0.064 0 0.936
#> GSM154438 5 0.148 1.000 0.000 0.000 0.064 0 0.936
#> GSM154439 5 0.148 1.000 0.000 0.000 0.064 0 0.936
#> GSM154403 2 0.421 0.801 0.000 0.768 0.168 0 0.064
#> GSM154404 2 0.421 0.801 0.000 0.768 0.168 0 0.064
#> GSM154405 2 0.418 0.804 0.000 0.772 0.164 0 0.064
#> GSM154406 2 0.418 0.804 0.000 0.772 0.164 0 0.064
#> GSM154407 2 0.421 0.801 0.000 0.768 0.168 0 0.064
#> GSM154408 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM154409 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM154410 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM154411 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM154412 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM154413 3 0.340 0.883 0.236 0.000 0.764 0 0.000
#> GSM154414 3 0.340 0.883 0.236 0.000 0.764 0 0.000
#> GSM154415 3 0.340 0.883 0.236 0.000 0.764 0 0.000
#> GSM154416 3 0.340 0.883 0.236 0.000 0.764 0 0.000
#> GSM154417 3 0.340 0.883 0.236 0.000 0.764 0 0.000
#> GSM154418 3 0.368 0.429 0.000 0.000 0.720 0 0.280
#> GSM154419 3 0.340 0.883 0.236 0.000 0.764 0 0.000
#> GSM154420 5 0.148 1.000 0.000 0.000 0.064 0 0.936
#> GSM154421 3 0.479 0.640 0.092 0.000 0.720 0 0.188
#> GSM154422 3 0.319 0.829 0.148 0.000 0.832 0 0.020
#> GSM154203 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154204 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154205 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154206 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154207 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154208 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154209 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154210 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154211 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154213 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154214 2 0.000 0.951 0.000 1.000 0.000 0 0.000
#> GSM154217 1 0.000 0.937 1.000 0.000 0.000 0 0.000
#> GSM154219 1 0.000 0.937 1.000 0.000 0.000 0 0.000
#> GSM154220 1 0.173 0.922 0.920 0.000 0.080 0 0.000
#> GSM154221 1 0.202 0.908 0.900 0.000 0.100 0 0.000
#> GSM154223 1 0.202 0.908 0.900 0.000 0.100 0 0.000
#> GSM154224 1 0.000 0.937 1.000 0.000 0.000 0 0.000
#> GSM154225 1 0.000 0.937 1.000 0.000 0.000 0 0.000
#> GSM154227 1 0.000 0.937 1.000 0.000 0.000 0 0.000
#> GSM154228 1 0.141 0.931 0.940 0.000 0.060 0 0.000
#> GSM154229 1 0.202 0.908 0.900 0.000 0.100 0 0.000
#> GSM154231 1 0.141 0.931 0.940 0.000 0.060 0 0.000
#> GSM154232 1 0.000 0.937 1.000 0.000 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.000 0.772 0.000 1.000 0.000 0 0.000 0.000
#> GSM154424 2 0.209 0.784 0.000 0.876 0.000 0 0.000 0.124
#> GSM154425 4 0.000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM154426 2 0.000 0.772 0.000 1.000 0.000 0 0.000 0.000
#> GSM154427 2 0.214 0.785 0.000 0.872 0.000 0 0.000 0.128
#> GSM154428 2 0.000 0.772 0.000 1.000 0.000 0 0.000 0.000
#> GSM154429 2 0.214 0.785 0.000 0.872 0.000 0 0.000 0.128
#> GSM154430 2 0.214 0.785 0.000 0.872 0.000 0 0.000 0.128
#> GSM154434 1 0.196 0.823 0.888 0.000 0.000 0 0.112 0.000
#> GSM154436 5 0.000 1.000 0.000 0.000 0.000 0 1.000 0.000
#> GSM154437 5 0.000 1.000 0.000 0.000 0.000 0 1.000 0.000
#> GSM154438 5 0.000 1.000 0.000 0.000 0.000 0 1.000 0.000
#> GSM154439 5 0.000 1.000 0.000 0.000 0.000 0 1.000 0.000
#> GSM154403 6 0.114 0.997 0.000 0.052 0.000 0 0.000 0.948
#> GSM154404 6 0.114 0.997 0.000 0.052 0.000 0 0.000 0.948
#> GSM154405 6 0.120 0.995 0.000 0.056 0.000 0 0.000 0.944
#> GSM154406 6 0.120 0.995 0.000 0.056 0.000 0 0.000 0.944
#> GSM154407 6 0.114 0.997 0.000 0.052 0.000 0 0.000 0.948
#> GSM154408 4 0.000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM154409 4 0.000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM154410 4 0.000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM154411 4 0.000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM154412 4 0.000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> GSM154413 3 0.176 0.911 0.096 0.000 0.904 0 0.000 0.000
#> GSM154414 3 0.176 0.911 0.096 0.000 0.904 0 0.000 0.000
#> GSM154415 3 0.176 0.911 0.096 0.000 0.904 0 0.000 0.000
#> GSM154416 3 0.176 0.911 0.096 0.000 0.904 0 0.000 0.000
#> GSM154417 3 0.176 0.911 0.096 0.000 0.904 0 0.000 0.000
#> GSM154418 3 0.387 0.600 0.000 0.000 0.748 0 0.200 0.052
#> GSM154419 3 0.176 0.911 0.096 0.000 0.904 0 0.000 0.000
#> GSM154420 5 0.000 1.000 0.000 0.000 0.000 0 1.000 0.000
#> GSM154421 3 0.479 0.715 0.060 0.000 0.720 0 0.168 0.052
#> GSM154422 3 0.239 0.865 0.060 0.000 0.888 0 0.000 0.052
#> GSM154203 2 0.327 0.727 0.000 0.728 0.000 0 0.000 0.272
#> GSM154204 2 0.331 0.724 0.000 0.720 0.000 0 0.000 0.280
#> GSM154205 2 0.327 0.727 0.000 0.728 0.000 0 0.000 0.272
#> GSM154206 2 0.365 0.683 0.000 0.640 0.000 0 0.000 0.360
#> GSM154207 2 0.365 0.683 0.000 0.640 0.000 0 0.000 0.360
#> GSM154208 2 0.373 0.650 0.000 0.612 0.000 0 0.000 0.388
#> GSM154209 2 0.000 0.772 0.000 1.000 0.000 0 0.000 0.000
#> GSM154210 2 0.000 0.772 0.000 1.000 0.000 0 0.000 0.000
#> GSM154211 2 0.000 0.772 0.000 1.000 0.000 0 0.000 0.000
#> GSM154213 2 0.373 0.650 0.000 0.612 0.000 0 0.000 0.388
#> GSM154214 2 0.373 0.650 0.000 0.612 0.000 0 0.000 0.388
#> GSM154217 1 0.000 0.907 1.000 0.000 0.000 0 0.000 0.000
#> GSM154219 1 0.000 0.907 1.000 0.000 0.000 0 0.000 0.000
#> GSM154220 1 0.218 0.882 0.868 0.000 0.132 0 0.000 0.000
#> GSM154221 1 0.266 0.846 0.816 0.000 0.184 0 0.000 0.000
#> GSM154223 1 0.266 0.846 0.816 0.000 0.184 0 0.000 0.000
#> GSM154224 1 0.000 0.907 1.000 0.000 0.000 0 0.000 0.000
#> GSM154225 1 0.000 0.907 1.000 0.000 0.000 0 0.000 0.000
#> GSM154227 1 0.000 0.907 1.000 0.000 0.000 0 0.000 0.000
#> GSM154228 1 0.191 0.893 0.892 0.000 0.108 0 0.000 0.000
#> GSM154229 1 0.266 0.846 0.816 0.000 0.184 0 0.000 0.000
#> GSM154231 1 0.191 0.893 0.892 0.000 0.108 0 0.000 0.000
#> GSM154232 1 0.000 0.907 1.000 0.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 disease.state(p) cell.type(p) k
#> MAD:hclust 50 1.67e-05 1.15e-11 2
#> MAD:hclust 56 1.16e-07 1.63e-10 3
#> MAD:hclust 55 7.62e-08 6.87e-12 4
#> MAD:hclust 55 5.43e-13 3.25e-11 5
#> MAD:hclust 56 4.07e-16 8.13e-11 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "kmeans"]
# you can also extract it by
# res = res_list["MAD:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.991 0.993 0.5083 0.492 0.492
#> 3 3 0.686 0.831 0.895 0.2476 0.821 0.649
#> 4 4 0.725 0.767 0.828 0.1146 0.962 0.894
#> 5 5 0.726 0.716 0.753 0.0765 0.882 0.644
#> 6 6 0.706 0.758 0.780 0.0524 0.902 0.623
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
#> GSM154423 2 0.0000 0.990 0.000 1.000
#> GSM154424 2 0.1414 0.989 0.020 0.980
#> GSM154425 2 0.0000 0.990 0.000 1.000
#> GSM154426 2 0.0000 0.990 0.000 1.000
#> GSM154427 2 0.1414 0.989 0.020 0.980
#> GSM154428 2 0.0000 0.990 0.000 1.000
#> GSM154429 2 0.1414 0.989 0.020 0.980
#> GSM154430 2 0.1414 0.989 0.020 0.980
#> GSM154434 1 0.0000 0.995 1.000 0.000
#> GSM154436 1 0.1414 0.984 0.980 0.020
#> GSM154437 1 0.1414 0.984 0.980 0.020
#> GSM154438 1 0.1414 0.984 0.980 0.020
#> GSM154439 1 0.1414 0.984 0.980 0.020
#> GSM154403 2 0.1414 0.989 0.020 0.980
#> GSM154404 2 0.1414 0.989 0.020 0.980
#> GSM154405 2 0.1414 0.989 0.020 0.980
#> GSM154406 2 0.0672 0.990 0.008 0.992
#> GSM154407 2 0.1414 0.989 0.020 0.980
#> GSM154408 2 0.0000 0.990 0.000 1.000
#> GSM154409 2 0.0000 0.990 0.000 1.000
#> GSM154410 2 0.0000 0.990 0.000 1.000
#> GSM154411 2 0.0000 0.990 0.000 1.000
#> GSM154412 2 0.0000 0.990 0.000 1.000
#> GSM154413 1 0.0000 0.995 1.000 0.000
#> GSM154414 1 0.0000 0.995 1.000 0.000
#> GSM154415 1 0.0000 0.995 1.000 0.000
#> GSM154416 1 0.0000 0.995 1.000 0.000
#> GSM154417 1 0.0000 0.995 1.000 0.000
#> GSM154418 1 0.1414 0.984 0.980 0.020
#> GSM154419 1 0.0000 0.995 1.000 0.000
#> GSM154420 1 0.1414 0.984 0.980 0.020
#> GSM154421 1 0.0000 0.995 1.000 0.000
#> GSM154422 1 0.0000 0.995 1.000 0.000
#> GSM154203 2 0.0000 0.990 0.000 1.000
#> GSM154204 2 0.1414 0.989 0.020 0.980
#> GSM154205 2 0.0000 0.990 0.000 1.000
#> GSM154206 2 0.1414 0.989 0.020 0.980
#> GSM154207 2 0.1414 0.989 0.020 0.980
#> GSM154208 2 0.1414 0.989 0.020 0.980
#> GSM154209 2 0.0000 0.990 0.000 1.000
#> GSM154210 2 0.0000 0.990 0.000 1.000
#> GSM154211 2 0.0000 0.990 0.000 1.000
#> GSM154213 2 0.1414 0.989 0.020 0.980
#> GSM154214 2 0.1414 0.989 0.020 0.980
#> GSM154217 1 0.0000 0.995 1.000 0.000
#> GSM154219 1 0.0000 0.995 1.000 0.000
#> GSM154220 1 0.0000 0.995 1.000 0.000
#> GSM154221 1 0.0000 0.995 1.000 0.000
#> GSM154223 1 0.0000 0.995 1.000 0.000
#> GSM154224 1 0.0000 0.995 1.000 0.000
#> GSM154225 1 0.0000 0.995 1.000 0.000
#> GSM154227 1 0.0000 0.995 1.000 0.000
#> GSM154228 1 0.0000 0.995 1.000 0.000
#> GSM154229 1 0.0000 0.995 1.000 0.000
#> GSM154231 1 0.0000 0.995 1.000 0.000
#> GSM154232 1 0.0000 0.995 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.4605 0.796 0.000 0.796 0.204
#> GSM154424 2 0.0237 0.930 0.000 0.996 0.004
#> GSM154425 3 0.4002 0.578 0.000 0.160 0.840
#> GSM154426 2 0.4605 0.796 0.000 0.796 0.204
#> GSM154427 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154428 2 0.4605 0.796 0.000 0.796 0.204
#> GSM154429 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154434 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154436 3 0.5591 0.562 0.304 0.000 0.696
#> GSM154437 3 0.5926 0.527 0.356 0.000 0.644
#> GSM154438 3 0.6235 0.337 0.436 0.000 0.564
#> GSM154439 3 0.5926 0.527 0.356 0.000 0.644
#> GSM154403 2 0.1753 0.911 0.000 0.952 0.048
#> GSM154404 2 0.1753 0.911 0.000 0.952 0.048
#> GSM154405 2 0.0424 0.928 0.000 0.992 0.008
#> GSM154406 2 0.1289 0.919 0.000 0.968 0.032
#> GSM154407 2 0.1753 0.911 0.000 0.952 0.048
#> GSM154408 2 0.5785 0.637 0.000 0.668 0.332
#> GSM154409 3 0.4654 0.535 0.000 0.208 0.792
#> GSM154410 3 0.4654 0.535 0.000 0.208 0.792
#> GSM154411 3 0.4002 0.578 0.000 0.160 0.840
#> GSM154412 3 0.4654 0.535 0.000 0.208 0.792
#> GSM154413 1 0.3340 0.898 0.880 0.000 0.120
#> GSM154414 1 0.3340 0.898 0.880 0.000 0.120
#> GSM154415 1 0.3038 0.903 0.896 0.000 0.104
#> GSM154416 1 0.3038 0.903 0.896 0.000 0.104
#> GSM154417 1 0.3340 0.898 0.880 0.000 0.120
#> GSM154418 3 0.5926 0.527 0.356 0.000 0.644
#> GSM154419 1 0.3038 0.903 0.896 0.000 0.104
#> GSM154420 3 0.5926 0.527 0.356 0.000 0.644
#> GSM154421 1 0.3619 0.873 0.864 0.000 0.136
#> GSM154422 1 0.3267 0.900 0.884 0.000 0.116
#> GSM154203 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154209 2 0.4235 0.818 0.000 0.824 0.176
#> GSM154210 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154211 2 0.4555 0.798 0.000 0.800 0.200
#> GSM154213 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.931 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154221 1 0.0237 0.941 0.996 0.000 0.004
#> GSM154223 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.944 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.944 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.5173 0.531 0.000 0.660 0.020 0.320
#> GSM154424 2 0.1629 0.849 0.000 0.952 0.024 0.024
#> GSM154425 4 0.5799 0.861 0.000 0.068 0.264 0.668
#> GSM154426 2 0.5173 0.531 0.000 0.660 0.020 0.320
#> GSM154427 2 0.1629 0.849 0.000 0.952 0.024 0.024
#> GSM154428 2 0.5173 0.531 0.000 0.660 0.020 0.320
#> GSM154429 2 0.1629 0.849 0.000 0.952 0.024 0.024
#> GSM154430 2 0.1629 0.849 0.000 0.952 0.024 0.024
#> GSM154434 1 0.1211 0.785 0.960 0.000 0.040 0.000
#> GSM154436 3 0.2011 0.940 0.080 0.000 0.920 0.000
#> GSM154437 3 0.2011 0.940 0.080 0.000 0.920 0.000
#> GSM154438 3 0.3182 0.913 0.096 0.000 0.876 0.028
#> GSM154439 3 0.2011 0.940 0.080 0.000 0.920 0.000
#> GSM154403 2 0.4673 0.764 0.000 0.792 0.076 0.132
#> GSM154404 2 0.4673 0.764 0.000 0.792 0.076 0.132
#> GSM154405 2 0.4083 0.791 0.000 0.832 0.068 0.100
#> GSM154406 2 0.4428 0.776 0.000 0.808 0.068 0.124
#> GSM154407 2 0.4673 0.764 0.000 0.792 0.076 0.132
#> GSM154408 4 0.4406 0.550 0.000 0.300 0.000 0.700
#> GSM154409 4 0.5988 0.891 0.000 0.100 0.224 0.676
#> GSM154410 4 0.5988 0.891 0.000 0.100 0.224 0.676
#> GSM154411 4 0.5799 0.861 0.000 0.068 0.264 0.668
#> GSM154412 4 0.5988 0.891 0.000 0.100 0.224 0.676
#> GSM154413 1 0.7036 0.573 0.576 0.000 0.208 0.216
#> GSM154414 1 0.7036 0.573 0.576 0.000 0.208 0.216
#> GSM154415 1 0.6946 0.582 0.588 0.000 0.200 0.212
#> GSM154416 1 0.6946 0.582 0.588 0.000 0.200 0.212
#> GSM154417 1 0.6672 0.611 0.620 0.000 0.168 0.212
#> GSM154418 3 0.5165 0.790 0.080 0.000 0.752 0.168
#> GSM154419 1 0.6946 0.582 0.588 0.000 0.200 0.212
#> GSM154420 3 0.2011 0.940 0.080 0.000 0.920 0.000
#> GSM154421 1 0.7458 0.415 0.500 0.000 0.288 0.212
#> GSM154422 1 0.6634 0.613 0.624 0.000 0.164 0.212
#> GSM154203 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154209 2 0.4277 0.561 0.000 0.720 0.000 0.280
#> GSM154210 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154211 2 0.4477 0.500 0.000 0.688 0.000 0.312
#> GSM154213 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.855 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0336 0.804 0.992 0.000 0.000 0.008
#> GSM154219 1 0.0336 0.804 0.992 0.000 0.000 0.008
#> GSM154220 1 0.0336 0.804 0.992 0.000 0.000 0.008
#> GSM154221 1 0.0336 0.804 0.992 0.000 0.000 0.008
#> GSM154223 1 0.0336 0.804 0.992 0.000 0.000 0.008
#> GSM154224 1 0.0000 0.804 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.804 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.804 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.804 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0336 0.804 0.992 0.000 0.000 0.008
#> GSM154231 1 0.0000 0.804 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.804 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.4306 -0.229 0.000 0.492 0.000 0.508 0.000
#> GSM154424 2 0.3355 0.723 0.000 0.832 0.036 0.132 0.000
#> GSM154425 4 0.6880 0.606 0.000 0.040 0.376 0.464 0.120
#> GSM154426 4 0.4306 -0.229 0.000 0.492 0.000 0.508 0.000
#> GSM154427 2 0.3064 0.732 0.000 0.856 0.036 0.108 0.000
#> GSM154428 4 0.4306 -0.229 0.000 0.492 0.000 0.508 0.000
#> GSM154429 2 0.3064 0.732 0.000 0.856 0.036 0.108 0.000
#> GSM154430 2 0.3064 0.732 0.000 0.856 0.036 0.108 0.000
#> GSM154434 1 0.1644 0.888 0.940 0.000 0.008 0.004 0.048
#> GSM154436 5 0.0794 0.888 0.028 0.000 0.000 0.000 0.972
#> GSM154437 5 0.0794 0.888 0.028 0.000 0.000 0.000 0.972
#> GSM154438 5 0.1662 0.861 0.056 0.000 0.004 0.004 0.936
#> GSM154439 5 0.0955 0.887 0.028 0.000 0.000 0.004 0.968
#> GSM154403 2 0.5820 0.600 0.000 0.640 0.100 0.240 0.020
#> GSM154404 2 0.5820 0.600 0.000 0.640 0.100 0.240 0.020
#> GSM154405 2 0.5469 0.628 0.000 0.672 0.076 0.232 0.020
#> GSM154406 2 0.5676 0.609 0.000 0.652 0.088 0.240 0.020
#> GSM154407 2 0.5820 0.600 0.000 0.640 0.100 0.240 0.020
#> GSM154408 4 0.6265 0.606 0.000 0.132 0.380 0.484 0.004
#> GSM154409 4 0.6916 0.620 0.000 0.052 0.380 0.464 0.104
#> GSM154410 4 0.6916 0.620 0.000 0.052 0.380 0.464 0.104
#> GSM154411 4 0.6885 0.606 0.000 0.040 0.380 0.460 0.120
#> GSM154412 4 0.6953 0.620 0.000 0.052 0.380 0.460 0.108
#> GSM154413 3 0.6234 0.949 0.332 0.000 0.508 0.000 0.160
#> GSM154414 3 0.6234 0.949 0.332 0.000 0.508 0.000 0.160
#> GSM154415 3 0.6300 0.950 0.336 0.000 0.496 0.000 0.168
#> GSM154416 3 0.6300 0.950 0.336 0.000 0.496 0.000 0.168
#> GSM154417 3 0.5976 0.903 0.376 0.000 0.508 0.000 0.116
#> GSM154418 5 0.5201 0.141 0.024 0.000 0.416 0.012 0.548
#> GSM154419 3 0.6300 0.950 0.336 0.000 0.496 0.000 0.168
#> GSM154420 5 0.0794 0.888 0.028 0.000 0.000 0.000 0.972
#> GSM154421 3 0.6754 0.830 0.260 0.000 0.500 0.012 0.228
#> GSM154422 3 0.6334 0.908 0.360 0.000 0.508 0.012 0.120
#> GSM154203 2 0.2516 0.684 0.000 0.860 0.000 0.140 0.000
#> GSM154204 2 0.0000 0.752 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.2516 0.684 0.000 0.860 0.000 0.140 0.000
#> GSM154206 2 0.0000 0.752 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.2773 0.667 0.000 0.836 0.000 0.164 0.000
#> GSM154208 2 0.0000 0.752 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.4060 0.313 0.000 0.640 0.000 0.360 0.000
#> GSM154210 2 0.2516 0.684 0.000 0.860 0.000 0.140 0.000
#> GSM154211 2 0.4192 0.208 0.000 0.596 0.000 0.404 0.000
#> GSM154213 2 0.0000 0.752 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.752 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.1300 0.946 0.956 0.000 0.016 0.028 0.000
#> GSM154219 1 0.1774 0.943 0.932 0.000 0.016 0.052 0.000
#> GSM154220 1 0.1522 0.944 0.944 0.000 0.012 0.044 0.000
#> GSM154221 1 0.1626 0.943 0.940 0.000 0.016 0.044 0.000
#> GSM154223 1 0.1522 0.944 0.944 0.000 0.012 0.044 0.000
#> GSM154224 1 0.1041 0.939 0.964 0.000 0.004 0.032 0.000
#> GSM154225 1 0.1041 0.939 0.964 0.000 0.004 0.032 0.000
#> GSM154227 1 0.1041 0.939 0.964 0.000 0.004 0.032 0.000
#> GSM154228 1 0.0510 0.947 0.984 0.000 0.000 0.016 0.000
#> GSM154229 1 0.1626 0.943 0.940 0.000 0.016 0.044 0.000
#> GSM154231 1 0.0510 0.947 0.984 0.000 0.000 0.016 0.000
#> GSM154232 1 0.1041 0.939 0.964 0.000 0.004 0.032 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.7500 0.364 0.000 0.508 0.140 0.176 0.060 0.116
#> GSM154424 2 0.5931 0.166 0.000 0.528 0.064 0.012 0.040 0.356
#> GSM154425 4 0.1636 0.966 0.000 0.036 0.000 0.936 0.024 0.004
#> GSM154426 2 0.7500 0.364 0.000 0.508 0.140 0.176 0.060 0.116
#> GSM154427 2 0.5688 0.171 0.000 0.560 0.048 0.012 0.040 0.340
#> GSM154428 2 0.7533 0.364 0.000 0.508 0.132 0.176 0.068 0.116
#> GSM154429 2 0.5688 0.171 0.000 0.560 0.048 0.012 0.040 0.340
#> GSM154430 2 0.5688 0.171 0.000 0.560 0.048 0.012 0.040 0.340
#> GSM154434 1 0.1690 0.878 0.940 0.000 0.004 0.020 0.016 0.020
#> GSM154436 5 0.2677 0.994 0.016 0.000 0.084 0.024 0.876 0.000
#> GSM154437 5 0.2677 0.994 0.016 0.000 0.084 0.024 0.876 0.000
#> GSM154438 5 0.2797 0.981 0.016 0.000 0.076 0.036 0.872 0.000
#> GSM154439 5 0.2756 0.993 0.016 0.000 0.084 0.028 0.872 0.000
#> GSM154403 6 0.4053 0.987 0.000 0.300 0.004 0.020 0.000 0.676
#> GSM154404 6 0.4053 0.987 0.000 0.300 0.004 0.020 0.000 0.676
#> GSM154405 6 0.3725 0.966 0.000 0.316 0.000 0.008 0.000 0.676
#> GSM154406 6 0.3952 0.981 0.000 0.308 0.000 0.020 0.000 0.672
#> GSM154407 6 0.4053 0.987 0.000 0.300 0.004 0.020 0.000 0.676
#> GSM154408 4 0.2257 0.940 0.000 0.068 0.008 0.904 0.008 0.012
#> GSM154409 4 0.1929 0.975 0.000 0.048 0.004 0.924 0.016 0.008
#> GSM154410 4 0.1929 0.975 0.000 0.048 0.004 0.924 0.016 0.008
#> GSM154411 4 0.1492 0.966 0.000 0.036 0.000 0.940 0.024 0.000
#> GSM154412 4 0.1477 0.974 0.000 0.048 0.000 0.940 0.008 0.004
#> GSM154413 3 0.2631 0.920 0.180 0.000 0.820 0.000 0.000 0.000
#> GSM154414 3 0.2631 0.920 0.180 0.000 0.820 0.000 0.000 0.000
#> GSM154415 3 0.2772 0.920 0.180 0.000 0.816 0.000 0.004 0.000
#> GSM154416 3 0.2772 0.920 0.180 0.000 0.816 0.000 0.004 0.000
#> GSM154417 3 0.2697 0.915 0.188 0.000 0.812 0.000 0.000 0.000
#> GSM154418 3 0.4983 0.473 0.016 0.000 0.664 0.008 0.252 0.060
#> GSM154419 3 0.3121 0.919 0.180 0.000 0.804 0.000 0.004 0.012
#> GSM154420 5 0.2677 0.994 0.016 0.000 0.084 0.024 0.876 0.000
#> GSM154421 3 0.4074 0.859 0.132 0.000 0.780 0.000 0.028 0.060
#> GSM154422 3 0.3874 0.880 0.156 0.000 0.776 0.000 0.008 0.060
#> GSM154203 2 0.0858 0.583 0.000 0.968 0.028 0.000 0.004 0.000
#> GSM154204 2 0.2260 0.530 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM154205 2 0.0858 0.583 0.000 0.968 0.028 0.000 0.004 0.000
#> GSM154206 2 0.2260 0.530 0.000 0.860 0.000 0.000 0.000 0.140
#> GSM154207 2 0.0547 0.586 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM154208 2 0.2300 0.528 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM154209 2 0.4398 0.501 0.000 0.764 0.076 0.132 0.012 0.016
#> GSM154210 2 0.0858 0.583 0.000 0.968 0.028 0.000 0.004 0.000
#> GSM154211 2 0.4620 0.486 0.000 0.740 0.076 0.156 0.012 0.016
#> GSM154213 2 0.2300 0.528 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM154214 2 0.2300 0.528 0.000 0.856 0.000 0.000 0.000 0.144
#> GSM154217 1 0.2851 0.875 0.868 0.000 0.000 0.036 0.016 0.080
#> GSM154219 1 0.3496 0.869 0.820 0.000 0.000 0.036 0.024 0.120
#> GSM154220 1 0.3534 0.872 0.820 0.000 0.004 0.028 0.024 0.124
#> GSM154221 1 0.3454 0.873 0.824 0.000 0.004 0.028 0.020 0.124
#> GSM154223 1 0.3454 0.873 0.824 0.000 0.004 0.028 0.020 0.124
#> GSM154224 1 0.2039 0.864 0.908 0.000 0.000 0.004 0.016 0.072
#> GSM154225 1 0.2039 0.864 0.908 0.000 0.000 0.004 0.016 0.072
#> GSM154227 1 0.2039 0.864 0.908 0.000 0.000 0.004 0.016 0.072
#> GSM154228 1 0.2058 0.881 0.916 0.000 0.004 0.008 0.016 0.056
#> GSM154229 1 0.3454 0.873 0.824 0.000 0.004 0.028 0.020 0.124
#> GSM154231 1 0.2058 0.881 0.916 0.000 0.004 0.008 0.016 0.056
#> GSM154232 1 0.2039 0.864 0.908 0.000 0.000 0.004 0.016 0.072
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> MAD:kmeans 56 2.95e-05 5.37e-13 2
#> MAD:kmeans 55 2.96e-07 1.72e-10 3
#> MAD:kmeans 55 1.20e-07 6.87e-12 4
#> MAD:kmeans 50 6.36e-12 3.61e-10 5
#> MAD:kmeans 47 3.71e-17 5.68e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "skmeans"]
# you can also extract it by
# res = res_list["MAD:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.909 0.938 0.964 0.2490 0.834 0.674
#> 4 4 0.801 0.836 0.917 0.1374 0.875 0.674
#> 5 5 0.835 0.868 0.880 0.0644 0.952 0.836
#> 6 6 0.896 0.859 0.887 0.0594 0.942 0.769
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154424 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154425 3 0.0892 0.866 0.000 0.020 0.980
#> GSM154426 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154428 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154434 1 0.0237 0.969 0.996 0.000 0.004
#> GSM154436 3 0.4605 0.838 0.204 0.000 0.796
#> GSM154437 3 0.4605 0.838 0.204 0.000 0.796
#> GSM154438 1 0.6192 0.119 0.580 0.000 0.420
#> GSM154439 3 0.4605 0.838 0.204 0.000 0.796
#> GSM154403 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154406 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154407 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154408 2 0.4750 0.748 0.000 0.784 0.216
#> GSM154409 3 0.0892 0.866 0.000 0.020 0.980
#> GSM154410 3 0.0892 0.866 0.000 0.020 0.980
#> GSM154411 3 0.0892 0.866 0.000 0.020 0.980
#> GSM154412 3 0.0892 0.866 0.000 0.020 0.980
#> GSM154413 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154414 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154415 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154416 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154417 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154418 3 0.4605 0.838 0.204 0.000 0.796
#> GSM154419 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154420 3 0.4605 0.838 0.204 0.000 0.796
#> GSM154421 1 0.0892 0.964 0.980 0.000 0.020
#> GSM154422 1 0.0747 0.966 0.984 0.000 0.016
#> GSM154203 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154209 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154210 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154211 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.991 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.970 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.970 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.4222 0.684 0.000 0.728 0.000 0.272
#> GSM154424 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154425 4 0.0188 0.953 0.000 0.000 0.004 0.996
#> GSM154426 2 0.4193 0.689 0.000 0.732 0.000 0.268
#> GSM154427 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154428 2 0.4193 0.689 0.000 0.732 0.000 0.268
#> GSM154429 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154434 1 0.4941 0.141 0.564 0.000 0.436 0.000
#> GSM154436 3 0.3351 0.815 0.008 0.000 0.844 0.148
#> GSM154437 3 0.3351 0.815 0.008 0.000 0.844 0.148
#> GSM154438 3 0.3707 0.816 0.028 0.000 0.840 0.132
#> GSM154439 3 0.3351 0.815 0.008 0.000 0.844 0.148
#> GSM154403 2 0.0336 0.926 0.000 0.992 0.008 0.000
#> GSM154404 2 0.0336 0.926 0.000 0.992 0.008 0.000
#> GSM154405 2 0.0336 0.926 0.000 0.992 0.008 0.000
#> GSM154406 2 0.0336 0.926 0.000 0.992 0.008 0.000
#> GSM154407 2 0.0336 0.926 0.000 0.992 0.008 0.000
#> GSM154408 4 0.2973 0.776 0.000 0.144 0.000 0.856
#> GSM154409 4 0.0188 0.953 0.000 0.000 0.004 0.996
#> GSM154410 4 0.0188 0.953 0.000 0.000 0.004 0.996
#> GSM154411 4 0.0188 0.953 0.000 0.000 0.004 0.996
#> GSM154412 4 0.0188 0.953 0.000 0.000 0.004 0.996
#> GSM154413 3 0.3356 0.777 0.176 0.000 0.824 0.000
#> GSM154414 3 0.3311 0.782 0.172 0.000 0.828 0.000
#> GSM154415 3 0.3311 0.782 0.172 0.000 0.828 0.000
#> GSM154416 3 0.3311 0.782 0.172 0.000 0.828 0.000
#> GSM154417 1 0.4804 0.366 0.616 0.000 0.384 0.000
#> GSM154418 3 0.3249 0.817 0.008 0.000 0.852 0.140
#> GSM154419 3 0.3311 0.782 0.172 0.000 0.828 0.000
#> GSM154420 3 0.3351 0.815 0.008 0.000 0.844 0.148
#> GSM154421 3 0.0469 0.809 0.012 0.000 0.988 0.000
#> GSM154422 1 0.4907 0.278 0.580 0.000 0.420 0.000
#> GSM154203 2 0.0188 0.928 0.000 0.996 0.000 0.004
#> GSM154204 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0188 0.928 0.000 0.996 0.000 0.004
#> GSM154206 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0188 0.928 0.000 0.996 0.000 0.004
#> GSM154208 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154209 2 0.4250 0.678 0.000 0.724 0.000 0.276
#> GSM154210 2 0.0188 0.928 0.000 0.996 0.000 0.004
#> GSM154211 2 0.4304 0.666 0.000 0.716 0.000 0.284
#> GSM154213 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.929 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.899 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.899 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.5256 0.543 0.000 0.608 0.016 0.344 0.032
#> GSM154424 2 0.0566 0.850 0.000 0.984 0.004 0.000 0.012
#> GSM154425 4 0.1270 0.978 0.000 0.000 0.000 0.948 0.052
#> GSM154426 2 0.5196 0.568 0.000 0.624 0.016 0.328 0.032
#> GSM154427 2 0.0566 0.850 0.000 0.984 0.004 0.000 0.012
#> GSM154428 2 0.5227 0.556 0.000 0.616 0.016 0.336 0.032
#> GSM154429 2 0.0566 0.850 0.000 0.984 0.004 0.000 0.012
#> GSM154430 2 0.0566 0.850 0.000 0.984 0.004 0.000 0.012
#> GSM154434 1 0.4902 0.455 0.648 0.000 0.048 0.000 0.304
#> GSM154436 5 0.3454 0.992 0.000 0.000 0.156 0.028 0.816
#> GSM154437 5 0.3454 0.992 0.000 0.000 0.156 0.028 0.816
#> GSM154438 5 0.3573 0.979 0.012 0.000 0.156 0.016 0.816
#> GSM154439 5 0.3454 0.992 0.000 0.000 0.156 0.028 0.816
#> GSM154403 2 0.3615 0.768 0.000 0.808 0.036 0.000 0.156
#> GSM154404 2 0.3615 0.768 0.000 0.808 0.036 0.000 0.156
#> GSM154405 2 0.3615 0.768 0.000 0.808 0.036 0.000 0.156
#> GSM154406 2 0.3615 0.768 0.000 0.808 0.036 0.000 0.156
#> GSM154407 2 0.3615 0.768 0.000 0.808 0.036 0.000 0.156
#> GSM154408 4 0.0794 0.893 0.000 0.028 0.000 0.972 0.000
#> GSM154409 4 0.1270 0.978 0.000 0.000 0.000 0.948 0.052
#> GSM154410 4 0.1270 0.978 0.000 0.000 0.000 0.948 0.052
#> GSM154411 4 0.1270 0.978 0.000 0.000 0.000 0.948 0.052
#> GSM154412 4 0.1270 0.978 0.000 0.000 0.000 0.948 0.052
#> GSM154413 3 0.1197 0.944 0.048 0.000 0.952 0.000 0.000
#> GSM154414 3 0.1197 0.944 0.048 0.000 0.952 0.000 0.000
#> GSM154415 3 0.1282 0.944 0.044 0.000 0.952 0.000 0.004
#> GSM154416 3 0.1282 0.944 0.044 0.000 0.952 0.000 0.004
#> GSM154417 3 0.2020 0.902 0.100 0.000 0.900 0.000 0.000
#> GSM154418 5 0.3527 0.977 0.000 0.000 0.172 0.024 0.804
#> GSM154419 3 0.1282 0.944 0.044 0.000 0.952 0.000 0.004
#> GSM154420 5 0.3454 0.992 0.000 0.000 0.156 0.028 0.816
#> GSM154421 3 0.2690 0.752 0.000 0.000 0.844 0.000 0.156
#> GSM154422 3 0.2020 0.902 0.100 0.000 0.900 0.000 0.000
#> GSM154203 2 0.2270 0.829 0.000 0.916 0.012 0.052 0.020
#> GSM154204 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.2270 0.829 0.000 0.916 0.012 0.052 0.020
#> GSM154206 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.1106 0.845 0.000 0.964 0.012 0.000 0.024
#> GSM154208 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000
#> GSM154209 2 0.4925 0.549 0.000 0.624 0.012 0.344 0.020
#> GSM154210 2 0.2270 0.829 0.000 0.916 0.012 0.052 0.020
#> GSM154211 2 0.4981 0.521 0.000 0.608 0.012 0.360 0.020
#> GSM154213 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.850 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.969 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.5949 0.685 0.000 0.544 0.036 0.076 0.012 0.332
#> GSM154424 2 0.2545 0.645 0.000 0.892 0.032 0.004 0.012 0.060
#> GSM154425 4 0.0458 0.987 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM154426 2 0.5904 0.688 0.000 0.548 0.036 0.072 0.012 0.332
#> GSM154427 2 0.2290 0.634 0.000 0.908 0.032 0.004 0.012 0.044
#> GSM154428 2 0.5904 0.688 0.000 0.548 0.036 0.072 0.012 0.332
#> GSM154429 2 0.2001 0.653 0.000 0.924 0.032 0.004 0.012 0.028
#> GSM154430 2 0.2222 0.640 0.000 0.912 0.032 0.004 0.012 0.040
#> GSM154434 1 0.3547 0.508 0.668 0.000 0.000 0.000 0.332 0.000
#> GSM154436 5 0.1245 0.987 0.000 0.000 0.016 0.032 0.952 0.000
#> GSM154437 5 0.1245 0.987 0.000 0.000 0.016 0.032 0.952 0.000
#> GSM154438 5 0.1168 0.984 0.000 0.000 0.016 0.028 0.956 0.000
#> GSM154439 5 0.1245 0.987 0.000 0.000 0.016 0.032 0.952 0.000
#> GSM154403 6 0.3727 0.996 0.000 0.388 0.000 0.000 0.000 0.612
#> GSM154404 6 0.3727 0.996 0.000 0.388 0.000 0.000 0.000 0.612
#> GSM154405 6 0.3727 0.996 0.000 0.388 0.000 0.000 0.000 0.612
#> GSM154406 6 0.3717 0.985 0.000 0.384 0.000 0.000 0.000 0.616
#> GSM154407 6 0.3727 0.996 0.000 0.388 0.000 0.000 0.000 0.612
#> GSM154408 4 0.0790 0.940 0.000 0.000 0.000 0.968 0.000 0.032
#> GSM154409 4 0.0458 0.987 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM154410 4 0.0458 0.987 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM154411 4 0.0547 0.984 0.000 0.000 0.000 0.980 0.020 0.000
#> GSM154412 4 0.0458 0.987 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM154413 3 0.0972 0.937 0.028 0.000 0.964 0.000 0.008 0.000
#> GSM154414 3 0.0972 0.937 0.028 0.000 0.964 0.000 0.008 0.000
#> GSM154415 3 0.0993 0.936 0.024 0.000 0.964 0.000 0.012 0.000
#> GSM154416 3 0.0993 0.936 0.024 0.000 0.964 0.000 0.012 0.000
#> GSM154417 3 0.1010 0.932 0.036 0.000 0.960 0.000 0.000 0.004
#> GSM154418 5 0.1562 0.937 0.000 0.000 0.024 0.004 0.940 0.032
#> GSM154419 3 0.1218 0.937 0.028 0.000 0.956 0.000 0.012 0.004
#> GSM154420 5 0.1245 0.987 0.000 0.000 0.016 0.032 0.952 0.000
#> GSM154421 3 0.4278 0.491 0.000 0.000 0.632 0.000 0.336 0.032
#> GSM154422 3 0.2351 0.907 0.036 0.000 0.904 0.000 0.028 0.032
#> GSM154203 2 0.3565 0.727 0.000 0.692 0.000 0.004 0.000 0.304
#> GSM154204 2 0.0547 0.685 0.000 0.980 0.000 0.000 0.000 0.020
#> GSM154205 2 0.3547 0.729 0.000 0.696 0.000 0.004 0.000 0.300
#> GSM154206 2 0.0146 0.677 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154207 2 0.3175 0.732 0.000 0.744 0.000 0.000 0.000 0.256
#> GSM154208 2 0.0000 0.675 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154209 2 0.4751 0.699 0.000 0.620 0.004 0.060 0.000 0.316
#> GSM154210 2 0.3547 0.729 0.000 0.696 0.000 0.004 0.000 0.300
#> GSM154211 2 0.4901 0.694 0.000 0.608 0.004 0.072 0.000 0.316
#> GSM154213 2 0.0000 0.675 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.675 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154217 1 0.0405 0.960 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM154219 1 0.0405 0.960 0.988 0.000 0.000 0.000 0.008 0.004
#> GSM154220 1 0.0603 0.961 0.980 0.000 0.000 0.000 0.004 0.016
#> GSM154221 1 0.0858 0.958 0.968 0.000 0.000 0.000 0.004 0.028
#> GSM154223 1 0.0713 0.959 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM154224 1 0.0146 0.960 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154225 1 0.0146 0.960 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154227 1 0.0146 0.960 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154228 1 0.0547 0.960 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM154229 1 0.0858 0.958 0.968 0.000 0.000 0.000 0.004 0.028
#> GSM154231 1 0.0547 0.960 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM154232 1 0.0000 0.961 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> MAD:skmeans 56 2.95e-05 5.37e-13 2
#> MAD:skmeans 55 2.96e-07 1.72e-10 3
#> MAD:skmeans 53 4.79e-12 1.83e-11 4
#> MAD:skmeans 55 1.62e-13 3.25e-11 5
#> MAD:skmeans 55 5.59e-15 1.31e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "pam"]
# you can also extract it by
# res = res_list["MAD:pam"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.976 0.991 0.5092 0.491 0.491
#> 3 3 0.747 0.846 0.894 0.2369 0.885 0.769
#> 4 4 0.904 0.857 0.940 0.1418 0.901 0.745
#> 5 5 0.811 0.883 0.926 0.0537 0.960 0.862
#> 6 6 0.882 0.864 0.931 0.0905 0.922 0.694
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM154423 2 0.000 0.995 0.000 1.000
#> GSM154424 2 0.000 0.995 0.000 1.000
#> GSM154425 2 0.358 0.928 0.068 0.932
#> GSM154426 2 0.000 0.995 0.000 1.000
#> GSM154427 2 0.000 0.995 0.000 1.000
#> GSM154428 2 0.000 0.995 0.000 1.000
#> GSM154429 2 0.000 0.995 0.000 1.000
#> GSM154430 2 0.000 0.995 0.000 1.000
#> GSM154434 1 0.000 0.985 1.000 0.000
#> GSM154436 1 0.000 0.985 1.000 0.000
#> GSM154437 1 0.000 0.985 1.000 0.000
#> GSM154438 1 0.000 0.985 1.000 0.000
#> GSM154439 1 0.000 0.985 1.000 0.000
#> GSM154403 2 0.000 0.995 0.000 1.000
#> GSM154404 2 0.000 0.995 0.000 1.000
#> GSM154405 2 0.000 0.995 0.000 1.000
#> GSM154406 2 0.000 0.995 0.000 1.000
#> GSM154407 2 0.000 0.995 0.000 1.000
#> GSM154408 2 0.000 0.995 0.000 1.000
#> GSM154409 2 0.343 0.933 0.064 0.936
#> GSM154410 2 0.000 0.995 0.000 1.000
#> GSM154411 1 0.969 0.335 0.604 0.396
#> GSM154412 2 0.000 0.995 0.000 1.000
#> GSM154413 1 0.000 0.985 1.000 0.000
#> GSM154414 1 0.000 0.985 1.000 0.000
#> GSM154415 1 0.000 0.985 1.000 0.000
#> GSM154416 1 0.000 0.985 1.000 0.000
#> GSM154417 1 0.000 0.985 1.000 0.000
#> GSM154418 1 0.000 0.985 1.000 0.000
#> GSM154419 1 0.000 0.985 1.000 0.000
#> GSM154420 1 0.000 0.985 1.000 0.000
#> GSM154421 1 0.000 0.985 1.000 0.000
#> GSM154422 1 0.000 0.985 1.000 0.000
#> GSM154203 2 0.000 0.995 0.000 1.000
#> GSM154204 2 0.000 0.995 0.000 1.000
#> GSM154205 2 0.000 0.995 0.000 1.000
#> GSM154206 2 0.000 0.995 0.000 1.000
#> GSM154207 2 0.000 0.995 0.000 1.000
#> GSM154208 2 0.000 0.995 0.000 1.000
#> GSM154209 2 0.000 0.995 0.000 1.000
#> GSM154210 2 0.000 0.995 0.000 1.000
#> GSM154211 2 0.000 0.995 0.000 1.000
#> GSM154213 2 0.000 0.995 0.000 1.000
#> GSM154214 2 0.000 0.995 0.000 1.000
#> GSM154217 1 0.000 0.985 1.000 0.000
#> GSM154219 1 0.000 0.985 1.000 0.000
#> GSM154220 1 0.000 0.985 1.000 0.000
#> GSM154221 1 0.000 0.985 1.000 0.000
#> GSM154223 1 0.000 0.985 1.000 0.000
#> GSM154224 1 0.000 0.985 1.000 0.000
#> GSM154225 1 0.000 0.985 1.000 0.000
#> GSM154227 1 0.000 0.985 1.000 0.000
#> GSM154228 1 0.000 0.985 1.000 0.000
#> GSM154229 1 0.000 0.985 1.000 0.000
#> GSM154231 1 0.000 0.985 1.000 0.000
#> GSM154232 1 0.000 0.985 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.4235 0.823 0.000 0.824 0.176
#> GSM154424 2 0.2625 0.909 0.000 0.916 0.084
#> GSM154425 3 0.4555 0.897 0.000 0.200 0.800
#> GSM154426 2 0.4235 0.823 0.000 0.824 0.176
#> GSM154427 2 0.1163 0.930 0.000 0.972 0.028
#> GSM154428 2 0.4235 0.823 0.000 0.824 0.176
#> GSM154429 2 0.2625 0.909 0.000 0.916 0.084
#> GSM154430 2 0.2625 0.909 0.000 0.916 0.084
#> GSM154434 1 0.4178 0.867 0.828 0.000 0.172
#> GSM154436 3 0.5948 0.368 0.360 0.000 0.640
#> GSM154437 1 0.6180 0.194 0.584 0.000 0.416
#> GSM154438 1 0.3192 0.861 0.888 0.000 0.112
#> GSM154439 1 0.4504 0.656 0.804 0.000 0.196
#> GSM154403 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154406 2 0.4178 0.827 0.000 0.828 0.172
#> GSM154407 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154408 3 0.4605 0.893 0.000 0.204 0.796
#> GSM154409 3 0.4555 0.897 0.000 0.200 0.800
#> GSM154410 3 0.4555 0.897 0.000 0.200 0.800
#> GSM154411 3 0.4692 0.873 0.012 0.168 0.820
#> GSM154412 3 0.4555 0.897 0.000 0.200 0.800
#> GSM154413 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154414 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154415 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154416 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154417 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154418 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154419 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154420 1 0.6215 0.157 0.572 0.000 0.428
#> GSM154421 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154422 1 0.0892 0.839 0.980 0.000 0.020
#> GSM154203 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154209 2 0.2625 0.909 0.000 0.916 0.084
#> GSM154210 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154211 2 0.2625 0.909 0.000 0.916 0.084
#> GSM154213 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.938 0.000 1.000 0.000
#> GSM154217 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154219 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154220 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154221 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154223 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154224 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154225 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154227 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154228 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154229 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154231 1 0.4291 0.867 0.820 0.000 0.180
#> GSM154232 1 0.4291 0.867 0.820 0.000 0.180
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.2281 0.910 0.000 0.904 0.000 0.096
#> GSM154424 2 0.0188 0.980 0.000 0.996 0.000 0.004
#> GSM154425 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> GSM154426 2 0.2281 0.910 0.000 0.904 0.000 0.096
#> GSM154427 2 0.0188 0.980 0.000 0.996 0.000 0.004
#> GSM154428 2 0.2281 0.910 0.000 0.904 0.000 0.096
#> GSM154429 2 0.0188 0.980 0.000 0.996 0.000 0.004
#> GSM154430 2 0.0188 0.980 0.000 0.996 0.000 0.004
#> GSM154434 3 0.4103 0.640 0.256 0.000 0.744 0.000
#> GSM154436 4 0.4431 0.540 0.000 0.000 0.304 0.696
#> GSM154437 3 0.4855 0.242 0.000 0.000 0.600 0.400
#> GSM154438 3 0.2868 0.757 0.136 0.000 0.864 0.000
#> GSM154439 3 0.3356 0.666 0.000 0.000 0.824 0.176
#> GSM154403 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154404 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154405 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154406 2 0.2216 0.914 0.000 0.908 0.000 0.092
#> GSM154407 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154408 4 0.2081 0.845 0.000 0.084 0.000 0.916
#> GSM154409 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> GSM154410 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> GSM154411 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> GSM154412 4 0.0000 0.924 0.000 0.000 0.000 1.000
#> GSM154413 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154414 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154415 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154416 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154417 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154418 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154419 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154420 3 0.4916 0.173 0.000 0.000 0.576 0.424
#> GSM154421 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154422 3 0.0000 0.824 0.000 0.000 1.000 0.000
#> GSM154203 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154204 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154209 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154210 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154211 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154213 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.982 0.000 1.000 0.000 0.000
#> GSM154217 3 0.4996 0.108 0.484 0.000 0.516 0.000
#> GSM154219 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154221 3 0.4008 0.655 0.244 0.000 0.756 0.000
#> GSM154223 1 0.3801 0.671 0.780 0.000 0.220 0.000
#> GSM154224 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154229 3 0.4008 0.655 0.244 0.000 0.756 0.000
#> GSM154231 1 0.0000 0.967 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.967 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.424 0.744 0.000 0.752 0.000 0.200 0.048
#> GSM154424 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154425 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000
#> GSM154426 2 0.371 0.811 0.000 0.808 0.000 0.144 0.048
#> GSM154427 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154428 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154429 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154430 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154434 3 0.458 0.683 0.236 0.000 0.712 0.000 0.052
#> GSM154436 5 0.223 0.972 0.000 0.000 0.116 0.000 0.884
#> GSM154437 5 0.223 0.972 0.000 0.000 0.116 0.000 0.884
#> GSM154438 5 0.271 0.884 0.072 0.000 0.044 0.000 0.884
#> GSM154439 5 0.223 0.972 0.000 0.000 0.116 0.000 0.884
#> GSM154403 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154404 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154405 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154406 2 0.000 0.918 0.000 1.000 0.000 0.000 0.000
#> GSM154407 2 0.120 0.917 0.000 0.952 0.000 0.000 0.048
#> GSM154408 4 0.279 0.832 0.000 0.088 0.000 0.876 0.036
#> GSM154409 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000
#> GSM154410 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000
#> GSM154411 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000
#> GSM154412 4 0.000 0.967 0.000 0.000 0.000 1.000 0.000
#> GSM154413 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154414 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154415 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154416 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154417 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154418 3 0.179 0.816 0.000 0.000 0.916 0.000 0.084
#> GSM154419 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154420 5 0.223 0.972 0.000 0.000 0.116 0.000 0.884
#> GSM154421 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154422 3 0.000 0.873 0.000 0.000 1.000 0.000 0.000
#> GSM154203 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154204 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154205 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154206 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154207 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154208 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154209 2 0.455 0.738 0.000 0.732 0.000 0.200 0.068
#> GSM154210 2 0.154 0.910 0.000 0.932 0.000 0.000 0.068
#> GSM154211 2 0.424 0.783 0.000 0.768 0.000 0.164 0.068
#> GSM154213 2 0.148 0.911 0.000 0.936 0.000 0.000 0.064
#> GSM154214 2 0.000 0.918 0.000 1.000 0.000 0.000 0.000
#> GSM154217 3 0.430 0.168 0.484 0.000 0.516 0.000 0.000
#> GSM154219 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154221 3 0.307 0.760 0.196 0.000 0.804 0.000 0.000
#> GSM154223 1 0.327 0.658 0.780 0.000 0.220 0.000 0.000
#> GSM154224 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154229 3 0.311 0.756 0.200 0.000 0.800 0.000 0.000
#> GSM154231 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.000 0.965 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 6 0.0260 0.877 0.000 0.008 0.000 0.000 0.000 0.992
#> GSM154424 6 0.0000 0.878 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154425 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154426 6 0.1444 0.839 0.000 0.072 0.000 0.000 0.000 0.928
#> GSM154427 6 0.0000 0.878 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154428 6 0.0146 0.878 0.000 0.004 0.000 0.000 0.000 0.996
#> GSM154429 6 0.0000 0.878 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154430 6 0.0000 0.878 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154434 3 0.4254 0.698 0.216 0.000 0.712 0.000 0.072 0.000
#> GSM154436 5 0.1444 0.979 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM154437 5 0.1444 0.979 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM154438 5 0.1682 0.915 0.052 0.000 0.020 0.000 0.928 0.000
#> GSM154439 5 0.1444 0.979 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM154403 6 0.1444 0.871 0.000 0.000 0.000 0.000 0.072 0.928
#> GSM154404 6 0.1444 0.871 0.000 0.000 0.000 0.000 0.072 0.928
#> GSM154405 6 0.1444 0.871 0.000 0.000 0.000 0.000 0.072 0.928
#> GSM154406 6 0.3641 0.792 0.000 0.140 0.000 0.000 0.072 0.788
#> GSM154407 6 0.1444 0.871 0.000 0.000 0.000 0.000 0.072 0.928
#> GSM154408 4 0.3821 0.746 0.000 0.080 0.000 0.772 0.000 0.148
#> GSM154409 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154410 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154411 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154412 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154413 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154414 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154415 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154416 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154417 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 3 0.2135 0.790 0.000 0.000 0.872 0.000 0.128 0.000
#> GSM154419 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154420 5 0.1444 0.979 0.000 0.000 0.072 0.000 0.928 0.000
#> GSM154421 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154422 3 0.0000 0.877 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154203 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154204 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154205 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154206 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 6 0.3828 0.328 0.000 0.440 0.000 0.000 0.000 0.560
#> GSM154208 2 0.1863 0.861 0.000 0.896 0.000 0.000 0.000 0.104
#> GSM154209 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154210 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154211 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154213 6 0.3847 0.280 0.000 0.456 0.000 0.000 0.000 0.544
#> GSM154214 6 0.2730 0.752 0.000 0.192 0.000 0.000 0.000 0.808
#> GSM154217 3 0.3866 0.173 0.484 0.000 0.516 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 3 0.2730 0.769 0.192 0.000 0.808 0.000 0.000 0.000
#> GSM154223 1 0.2941 0.657 0.780 0.000 0.220 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154229 3 0.2793 0.761 0.200 0.000 0.800 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.965 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> MAD:pam 55 2.84e-05 8.91e-13 2
#> MAD:pam 53 3.03e-06 3.10e-12 3
#> MAD:pam 53 8.62e-10 1.00e-10 4
#> MAD:pam 55 3.46e-11 3.25e-11 5
#> MAD:pam 53 2.80e-15 3.36e-10 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "mclust"]
# you can also extract it by
# res = res_list["MAD:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.834 0.984 0.991 0.5067 0.492 0.492
#> 3 3 0.653 0.853 0.900 0.2239 0.882 0.760
#> 4 4 0.718 0.779 0.876 0.1878 0.799 0.513
#> 5 5 0.712 0.690 0.816 0.0454 0.875 0.595
#> 6 6 1.000 0.962 0.974 0.0559 0.938 0.746
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM154423 2 0.000 1.000 0.0 1.0
#> GSM154424 2 0.000 1.000 0.0 1.0
#> GSM154425 2 0.000 1.000 0.0 1.0
#> GSM154426 2 0.000 1.000 0.0 1.0
#> GSM154427 2 0.000 1.000 0.0 1.0
#> GSM154428 2 0.000 1.000 0.0 1.0
#> GSM154429 2 0.000 1.000 0.0 1.0
#> GSM154430 2 0.000 1.000 0.0 1.0
#> GSM154434 1 0.000 0.980 1.0 0.0
#> GSM154436 1 0.469 0.906 0.9 0.1
#> GSM154437 1 0.469 0.906 0.9 0.1
#> GSM154438 1 0.000 0.980 1.0 0.0
#> GSM154439 1 0.469 0.906 0.9 0.1
#> GSM154403 2 0.000 1.000 0.0 1.0
#> GSM154404 2 0.000 1.000 0.0 1.0
#> GSM154405 2 0.000 1.000 0.0 1.0
#> GSM154406 2 0.000 1.000 0.0 1.0
#> GSM154407 2 0.000 1.000 0.0 1.0
#> GSM154408 2 0.000 1.000 0.0 1.0
#> GSM154409 2 0.000 1.000 0.0 1.0
#> GSM154410 2 0.000 1.000 0.0 1.0
#> GSM154411 2 0.000 1.000 0.0 1.0
#> GSM154412 2 0.000 1.000 0.0 1.0
#> GSM154413 1 0.000 0.980 1.0 0.0
#> GSM154414 1 0.000 0.980 1.0 0.0
#> GSM154415 1 0.000 0.980 1.0 0.0
#> GSM154416 1 0.000 0.980 1.0 0.0
#> GSM154417 1 0.000 0.980 1.0 0.0
#> GSM154418 1 0.469 0.906 0.9 0.1
#> GSM154419 1 0.000 0.980 1.0 0.0
#> GSM154420 1 0.469 0.906 0.9 0.1
#> GSM154421 1 0.000 0.980 1.0 0.0
#> GSM154422 1 0.000 0.980 1.0 0.0
#> GSM154203 2 0.000 1.000 0.0 1.0
#> GSM154204 2 0.000 1.000 0.0 1.0
#> GSM154205 2 0.000 1.000 0.0 1.0
#> GSM154206 2 0.000 1.000 0.0 1.0
#> GSM154207 2 0.000 1.000 0.0 1.0
#> GSM154208 2 0.000 1.000 0.0 1.0
#> GSM154209 2 0.000 1.000 0.0 1.0
#> GSM154210 2 0.000 1.000 0.0 1.0
#> GSM154211 2 0.000 1.000 0.0 1.0
#> GSM154213 2 0.000 1.000 0.0 1.0
#> GSM154214 2 0.000 1.000 0.0 1.0
#> GSM154217 1 0.000 0.980 1.0 0.0
#> GSM154219 1 0.000 0.980 1.0 0.0
#> GSM154220 1 0.000 0.980 1.0 0.0
#> GSM154221 1 0.000 0.980 1.0 0.0
#> GSM154223 1 0.000 0.980 1.0 0.0
#> GSM154224 1 0.000 0.980 1.0 0.0
#> GSM154225 1 0.000 0.980 1.0 0.0
#> GSM154227 1 0.000 0.980 1.0 0.0
#> GSM154228 1 0.000 0.980 1.0 0.0
#> GSM154229 1 0.000 0.980 1.0 0.0
#> GSM154231 1 0.000 0.980 1.0 0.0
#> GSM154232 1 0.000 0.980 1.0 0.0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.000 0.897 0.000 1.000 0.000
#> GSM154424 2 0.455 0.835 0.000 0.800 0.200
#> GSM154425 2 0.594 0.803 0.036 0.760 0.204
#> GSM154426 2 0.000 0.897 0.000 1.000 0.000
#> GSM154427 2 0.000 0.897 0.000 1.000 0.000
#> GSM154428 2 0.000 0.897 0.000 1.000 0.000
#> GSM154429 2 0.000 0.897 0.000 1.000 0.000
#> GSM154430 2 0.000 0.897 0.000 1.000 0.000
#> GSM154434 1 0.627 0.794 0.544 0.000 0.456
#> GSM154436 3 0.606 0.741 0.384 0.000 0.616
#> GSM154437 3 0.606 0.741 0.384 0.000 0.616
#> GSM154438 3 0.624 0.683 0.440 0.000 0.560
#> GSM154439 3 0.606 0.741 0.384 0.000 0.616
#> GSM154403 2 0.501 0.828 0.008 0.788 0.204
#> GSM154404 2 0.501 0.828 0.008 0.788 0.204
#> GSM154405 2 0.460 0.833 0.000 0.796 0.204
#> GSM154406 2 0.460 0.833 0.000 0.796 0.204
#> GSM154407 2 0.460 0.833 0.000 0.796 0.204
#> GSM154408 2 0.460 0.833 0.000 0.796 0.204
#> GSM154409 2 0.460 0.833 0.000 0.796 0.204
#> GSM154410 2 0.460 0.833 0.000 0.796 0.204
#> GSM154411 2 0.483 0.831 0.004 0.792 0.204
#> GSM154412 2 0.460 0.833 0.000 0.796 0.204
#> GSM154413 3 0.000 0.690 0.000 0.000 1.000
#> GSM154414 3 0.000 0.690 0.000 0.000 1.000
#> GSM154415 3 0.000 0.690 0.000 0.000 1.000
#> GSM154416 3 0.000 0.690 0.000 0.000 1.000
#> GSM154417 3 0.000 0.690 0.000 0.000 1.000
#> GSM154418 3 0.606 0.741 0.384 0.000 0.616
#> GSM154419 3 0.000 0.690 0.000 0.000 1.000
#> GSM154420 3 0.606 0.741 0.384 0.000 0.616
#> GSM154421 3 0.543 0.747 0.284 0.000 0.716
#> GSM154422 3 0.116 0.689 0.028 0.000 0.972
#> GSM154203 2 0.000 0.897 0.000 1.000 0.000
#> GSM154204 2 0.000 0.897 0.000 1.000 0.000
#> GSM154205 2 0.000 0.897 0.000 1.000 0.000
#> GSM154206 2 0.000 0.897 0.000 1.000 0.000
#> GSM154207 2 0.000 0.897 0.000 1.000 0.000
#> GSM154208 2 0.000 0.897 0.000 1.000 0.000
#> GSM154209 2 0.000 0.897 0.000 1.000 0.000
#> GSM154210 2 0.000 0.897 0.000 1.000 0.000
#> GSM154211 2 0.000 0.897 0.000 1.000 0.000
#> GSM154213 2 0.000 0.897 0.000 1.000 0.000
#> GSM154214 2 0.000 0.897 0.000 1.000 0.000
#> GSM154217 1 0.606 0.985 0.616 0.000 0.384
#> GSM154219 1 0.606 0.985 0.616 0.000 0.384
#> GSM154220 1 0.606 0.985 0.616 0.000 0.384
#> GSM154221 1 0.606 0.985 0.616 0.000 0.384
#> GSM154223 1 0.606 0.985 0.616 0.000 0.384
#> GSM154224 1 0.606 0.985 0.616 0.000 0.384
#> GSM154225 1 0.606 0.985 0.616 0.000 0.384
#> GSM154227 1 0.606 0.985 0.616 0.000 0.384
#> GSM154228 1 0.606 0.985 0.616 0.000 0.384
#> GSM154229 1 0.606 0.985 0.616 0.000 0.384
#> GSM154231 1 0.606 0.985 0.616 0.000 0.384
#> GSM154232 1 0.606 0.985 0.616 0.000 0.384
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154424 4 0.5090 0.55483 0.000 0.324 0.016 0.660
#> GSM154425 4 0.4697 0.51567 0.000 0.356 0.000 0.644
#> GSM154426 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154427 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154428 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154429 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154434 1 0.1929 0.93575 0.940 0.000 0.024 0.036
#> GSM154436 4 0.4977 -0.00363 0.000 0.000 0.460 0.540
#> GSM154437 4 0.4977 -0.00363 0.000 0.000 0.460 0.540
#> GSM154438 3 0.7777 0.13211 0.268 0.000 0.428 0.304
#> GSM154439 4 0.4977 -0.00363 0.000 0.000 0.460 0.540
#> GSM154403 4 0.6194 0.54407 0.000 0.132 0.200 0.668
#> GSM154404 4 0.6098 0.54284 0.000 0.124 0.200 0.676
#> GSM154405 4 0.6823 0.52792 0.000 0.196 0.200 0.604
#> GSM154406 4 0.6683 0.59009 0.000 0.204 0.176 0.620
#> GSM154407 4 0.6112 0.54698 0.000 0.128 0.196 0.676
#> GSM154408 4 0.4164 0.63126 0.000 0.264 0.000 0.736
#> GSM154409 4 0.3726 0.63967 0.000 0.212 0.000 0.788
#> GSM154410 4 0.3688 0.63892 0.000 0.208 0.000 0.792
#> GSM154411 4 0.3726 0.63967 0.000 0.212 0.000 0.788
#> GSM154412 4 0.3873 0.63851 0.000 0.228 0.000 0.772
#> GSM154413 3 0.0000 0.88536 0.000 0.000 1.000 0.000
#> GSM154414 3 0.0000 0.88536 0.000 0.000 1.000 0.000
#> GSM154415 3 0.0000 0.88536 0.000 0.000 1.000 0.000
#> GSM154416 3 0.0000 0.88536 0.000 0.000 1.000 0.000
#> GSM154417 3 0.1716 0.83878 0.000 0.000 0.936 0.064
#> GSM154418 4 0.5000 -0.06001 0.000 0.000 0.496 0.504
#> GSM154419 3 0.0000 0.88536 0.000 0.000 1.000 0.000
#> GSM154420 4 0.4977 -0.00363 0.000 0.000 0.460 0.540
#> GSM154421 3 0.0188 0.88211 0.000 0.000 0.996 0.004
#> GSM154422 3 0.3402 0.74354 0.004 0.000 0.832 0.164
#> GSM154203 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154204 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154206 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154209 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154210 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154211 2 0.0469 0.99138 0.000 0.988 0.000 0.012
#> GSM154213 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.99234 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0817 0.97043 0.976 0.000 0.024 0.000
#> GSM154231 1 0.0000 0.99243 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.99243 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.6077 0.3773 0.000 0.480 0.000 0.396 0.124
#> GSM154424 2 0.4058 0.4374 0.000 0.740 0.024 0.236 0.000
#> GSM154425 4 0.1106 0.7842 0.000 0.024 0.000 0.964 0.012
#> GSM154426 2 0.6081 0.3717 0.000 0.476 0.000 0.400 0.124
#> GSM154427 2 0.0404 0.6067 0.000 0.988 0.000 0.012 0.000
#> GSM154428 2 0.6081 0.3717 0.000 0.476 0.000 0.400 0.124
#> GSM154429 2 0.2690 0.6099 0.000 0.844 0.000 0.156 0.000
#> GSM154430 2 0.1410 0.6210 0.000 0.940 0.000 0.060 0.000
#> GSM154434 1 0.2437 0.8818 0.904 0.000 0.032 0.060 0.004
#> GSM154436 5 0.3241 0.8597 0.000 0.000 0.024 0.144 0.832
#> GSM154437 5 0.3151 0.8615 0.000 0.000 0.020 0.144 0.836
#> GSM154438 5 0.6721 0.6375 0.180 0.000 0.072 0.144 0.604
#> GSM154439 5 0.3151 0.8615 0.000 0.000 0.020 0.144 0.836
#> GSM154403 2 0.6234 0.3839 0.000 0.624 0.112 0.224 0.040
#> GSM154404 2 0.6292 0.3825 0.000 0.620 0.120 0.220 0.040
#> GSM154405 2 0.5506 0.4127 0.000 0.636 0.032 0.292 0.040
#> GSM154406 4 0.4800 0.0967 0.000 0.368 0.000 0.604 0.028
#> GSM154407 2 0.6208 0.3859 0.000 0.628 0.112 0.220 0.040
#> GSM154408 4 0.3684 0.3394 0.000 0.280 0.000 0.720 0.000
#> GSM154409 4 0.0162 0.7977 0.000 0.004 0.000 0.996 0.000
#> GSM154410 4 0.1197 0.7465 0.000 0.048 0.000 0.952 0.000
#> GSM154411 4 0.0162 0.7977 0.000 0.004 0.000 0.996 0.000
#> GSM154412 4 0.0162 0.7977 0.000 0.004 0.000 0.996 0.000
#> GSM154413 3 0.1121 0.8612 0.000 0.000 0.956 0.000 0.044
#> GSM154414 3 0.1544 0.8698 0.000 0.000 0.932 0.000 0.068
#> GSM154415 3 0.2471 0.8662 0.000 0.000 0.864 0.000 0.136
#> GSM154416 3 0.2471 0.8662 0.000 0.000 0.864 0.000 0.136
#> GSM154417 3 0.0290 0.8340 0.000 0.000 0.992 0.000 0.008
#> GSM154418 5 0.5990 0.4427 0.000 0.000 0.296 0.144 0.560
#> GSM154419 3 0.3897 0.8131 0.000 0.000 0.768 0.028 0.204
#> GSM154420 5 0.3151 0.8615 0.000 0.000 0.020 0.144 0.836
#> GSM154421 3 0.4329 0.7533 0.000 0.000 0.716 0.032 0.252
#> GSM154422 3 0.2632 0.8073 0.000 0.000 0.888 0.040 0.072
#> GSM154203 2 0.6004 0.3837 0.000 0.508 0.000 0.372 0.120
#> GSM154204 2 0.2230 0.6226 0.000 0.884 0.000 0.116 0.000
#> GSM154205 2 0.6002 0.3865 0.000 0.492 0.000 0.392 0.116
#> GSM154206 2 0.2020 0.6238 0.000 0.900 0.000 0.100 0.000
#> GSM154207 2 0.3301 0.6189 0.000 0.848 0.000 0.072 0.080
#> GSM154208 2 0.1792 0.6232 0.000 0.916 0.000 0.084 0.000
#> GSM154209 2 0.6077 0.3773 0.000 0.480 0.000 0.396 0.124
#> GSM154210 2 0.6004 0.3837 0.000 0.508 0.000 0.372 0.120
#> GSM154211 2 0.6077 0.3773 0.000 0.480 0.000 0.396 0.124
#> GSM154213 2 0.0162 0.5995 0.000 0.996 0.000 0.004 0.000
#> GSM154214 2 0.0162 0.5995 0.000 0.996 0.000 0.004 0.000
#> GSM154217 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.2074 0.8753 0.896 0.000 0.104 0.000 0.000
#> GSM154231 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9813 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.0146 0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM154424 6 0.4125 0.716 0.000 0.128 0.000 0.124 0.000 0.748
#> GSM154425 4 0.0000 0.977 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154426 2 0.0146 0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM154427 2 0.1610 0.953 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM154428 2 0.0146 0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM154429 2 0.1610 0.953 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM154430 2 0.1610 0.953 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM154434 1 0.0405 0.987 0.988 0.000 0.004 0.000 0.008 0.000
#> GSM154436 5 0.0146 0.963 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM154437 5 0.0146 0.963 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM154438 5 0.2302 0.835 0.120 0.000 0.008 0.000 0.872 0.000
#> GSM154439 5 0.0146 0.963 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM154403 6 0.0458 0.933 0.000 0.000 0.000 0.016 0.000 0.984
#> GSM154404 6 0.0458 0.933 0.000 0.000 0.000 0.016 0.000 0.984
#> GSM154405 6 0.0777 0.930 0.000 0.004 0.000 0.024 0.000 0.972
#> GSM154406 6 0.1700 0.888 0.000 0.048 0.000 0.024 0.000 0.928
#> GSM154407 6 0.0458 0.933 0.000 0.000 0.000 0.016 0.000 0.984
#> GSM154408 4 0.1765 0.879 0.000 0.096 0.000 0.904 0.000 0.000
#> GSM154409 4 0.0000 0.977 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154410 4 0.0000 0.977 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154411 4 0.0000 0.977 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154412 4 0.0000 0.977 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154413 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154414 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154415 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154416 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154417 3 0.0000 0.996 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 5 0.0713 0.946 0.000 0.000 0.028 0.000 0.972 0.000
#> GSM154419 3 0.0260 0.994 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM154420 5 0.0146 0.963 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM154421 3 0.0363 0.991 0.000 0.000 0.988 0.000 0.012 0.000
#> GSM154422 3 0.0260 0.994 0.000 0.000 0.992 0.000 0.008 0.000
#> GSM154203 2 0.0291 0.951 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM154204 2 0.1556 0.954 0.000 0.920 0.000 0.000 0.000 0.080
#> GSM154205 2 0.0291 0.951 0.000 0.992 0.000 0.000 0.004 0.004
#> GSM154206 2 0.1501 0.954 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM154207 2 0.1387 0.954 0.000 0.932 0.000 0.000 0.000 0.068
#> GSM154208 2 0.1501 0.954 0.000 0.924 0.000 0.000 0.000 0.076
#> GSM154209 2 0.0146 0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM154210 2 0.0146 0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM154211 2 0.0146 0.951 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM154213 2 0.1610 0.953 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM154214 2 0.1610 0.953 0.000 0.916 0.000 0.000 0.000 0.084
#> GSM154217 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.999 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> MAD:mclust 56 2.95e-05 5.37e-13 2
#> MAD:mclust 56 2.39e-11 6.91e-13 3
#> MAD:mclust 50 4.25e-15 7.99e-11 4
#> MAD:mclust 40 7.75e-12 4.33e-08 5
#> MAD:mclust 56 5.68e-15 8.13e-11 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["MAD", "NMF"]
# you can also extract it by
# res = res_list["MAD:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5089 0.492 0.492
#> 3 3 0.957 0.916 0.963 0.2498 0.821 0.649
#> 4 4 0.729 0.711 0.849 0.1478 0.883 0.682
#> 5 5 0.831 0.787 0.884 0.0721 0.903 0.673
#> 6 6 0.810 0.727 0.834 0.0432 0.945 0.768
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
#> GSM154423 2 0 1 0 1
#> GSM154424 2 0 1 0 1
#> GSM154425 2 0 1 0 1
#> GSM154426 2 0 1 0 1
#> GSM154427 2 0 1 0 1
#> GSM154428 2 0 1 0 1
#> GSM154429 2 0 1 0 1
#> GSM154430 2 0 1 0 1
#> GSM154434 1 0 1 1 0
#> GSM154436 1 0 1 1 0
#> GSM154437 1 0 1 1 0
#> GSM154438 1 0 1 1 0
#> GSM154439 1 0 1 1 0
#> GSM154403 2 0 1 0 1
#> GSM154404 2 0 1 0 1
#> GSM154405 2 0 1 0 1
#> GSM154406 2 0 1 0 1
#> GSM154407 2 0 1 0 1
#> GSM154408 2 0 1 0 1
#> GSM154409 2 0 1 0 1
#> GSM154410 2 0 1 0 1
#> GSM154411 2 0 1 0 1
#> GSM154412 2 0 1 0 1
#> GSM154413 1 0 1 1 0
#> GSM154414 1 0 1 1 0
#> GSM154415 1 0 1 1 0
#> GSM154416 1 0 1 1 0
#> GSM154417 1 0 1 1 0
#> GSM154418 1 0 1 1 0
#> GSM154419 1 0 1 1 0
#> GSM154420 1 0 1 1 0
#> GSM154421 1 0 1 1 0
#> GSM154422 1 0 1 1 0
#> GSM154203 2 0 1 0 1
#> GSM154204 2 0 1 0 1
#> GSM154205 2 0 1 0 1
#> GSM154206 2 0 1 0 1
#> GSM154207 2 0 1 0 1
#> GSM154208 2 0 1 0 1
#> GSM154209 2 0 1 0 1
#> GSM154210 2 0 1 0 1
#> GSM154211 2 0 1 0 1
#> GSM154213 2 0 1 0 1
#> GSM154214 2 0 1 0 1
#> GSM154217 1 0 1 1 0
#> GSM154219 1 0 1 1 0
#> GSM154220 1 0 1 1 0
#> GSM154221 1 0 1 1 0
#> GSM154223 1 0 1 1 0
#> GSM154224 1 0 1 1 0
#> GSM154225 1 0 1 1 0
#> GSM154227 1 0 1 1 0
#> GSM154228 1 0 1 1 0
#> GSM154229 1 0 1 1 0
#> GSM154231 1 0 1 1 0
#> GSM154232 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154424 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154425 3 0.1753 0.810 0.000 0.048 0.952
#> GSM154426 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154428 2 0.0424 0.993 0.000 0.992 0.008
#> GSM154429 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154434 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154436 3 0.0424 0.821 0.008 0.000 0.992
#> GSM154437 3 0.0892 0.817 0.020 0.000 0.980
#> GSM154438 3 0.5016 0.591 0.240 0.000 0.760
#> GSM154439 3 0.0892 0.817 0.020 0.000 0.980
#> GSM154403 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154406 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154407 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154408 2 0.0424 0.993 0.000 0.992 0.008
#> GSM154409 3 0.5948 0.505 0.000 0.360 0.640
#> GSM154410 3 0.6307 0.197 0.000 0.488 0.512
#> GSM154411 3 0.0000 0.819 0.000 0.000 1.000
#> GSM154412 3 0.6267 0.314 0.000 0.452 0.548
#> GSM154413 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154414 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154415 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154416 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154417 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154418 3 0.0424 0.821 0.008 0.000 0.992
#> GSM154419 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154420 3 0.0424 0.821 0.008 0.000 0.992
#> GSM154421 1 0.6079 0.392 0.612 0.000 0.388
#> GSM154422 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154203 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154209 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154210 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154211 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154213 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.999 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.980 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.980 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.3219 0.7876 0.000 0.836 0.164 0.000
#> GSM154424 2 0.0592 0.8964 0.000 0.984 0.016 0.000
#> GSM154425 4 0.6037 0.5251 0.000 0.068 0.304 0.628
#> GSM154426 2 0.0469 0.8979 0.000 0.988 0.012 0.000
#> GSM154427 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154428 2 0.2973 0.8081 0.000 0.856 0.144 0.000
#> GSM154429 2 0.0000 0.9007 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154434 1 0.1211 0.9590 0.960 0.000 0.000 0.040
#> GSM154436 4 0.0336 0.5197 0.000 0.000 0.008 0.992
#> GSM154437 4 0.2402 0.4897 0.012 0.000 0.076 0.912
#> GSM154438 4 0.5624 0.3093 0.148 0.000 0.128 0.724
#> GSM154439 4 0.3015 0.4695 0.024 0.000 0.092 0.884
#> GSM154403 3 0.5097 0.1810 0.004 0.428 0.568 0.000
#> GSM154404 3 0.5417 0.2205 0.016 0.412 0.572 0.000
#> GSM154405 2 0.4134 0.6257 0.000 0.740 0.260 0.000
#> GSM154406 2 0.4193 0.6212 0.000 0.732 0.268 0.000
#> GSM154407 2 0.4889 0.4092 0.004 0.636 0.360 0.000
#> GSM154408 2 0.6170 0.4388 0.000 0.600 0.332 0.068
#> GSM154409 4 0.7698 0.4310 0.000 0.224 0.356 0.420
#> GSM154410 4 0.7068 0.4783 0.000 0.128 0.380 0.492
#> GSM154411 4 0.4936 0.5266 0.000 0.012 0.316 0.672
#> GSM154412 4 0.7879 0.3448 0.000 0.288 0.332 0.380
#> GSM154413 3 0.5716 0.6612 0.060 0.000 0.668 0.272
#> GSM154414 3 0.5672 0.6599 0.056 0.000 0.668 0.276
#> GSM154415 3 0.5678 0.6376 0.044 0.000 0.640 0.316
#> GSM154416 3 0.5812 0.6225 0.048 0.000 0.624 0.328
#> GSM154417 3 0.6288 0.6375 0.128 0.004 0.672 0.196
#> GSM154418 4 0.4817 0.0275 0.000 0.000 0.388 0.612
#> GSM154419 3 0.7731 0.4038 0.248 0.000 0.436 0.316
#> GSM154420 4 0.2011 0.4894 0.000 0.000 0.080 0.920
#> GSM154421 4 0.6134 -0.3278 0.048 0.000 0.444 0.508
#> GSM154422 3 0.6680 0.6526 0.120 0.012 0.644 0.224
#> GSM154203 2 0.0188 0.9001 0.000 0.996 0.004 0.000
#> GSM154204 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154205 2 0.0000 0.9007 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154207 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154208 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154209 2 0.1867 0.8646 0.000 0.928 0.072 0.000
#> GSM154210 2 0.0336 0.8991 0.000 0.992 0.008 0.000
#> GSM154211 2 0.2704 0.8263 0.000 0.876 0.124 0.000
#> GSM154213 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154214 2 0.0188 0.9008 0.000 0.996 0.004 0.000
#> GSM154217 1 0.0469 0.9867 0.988 0.000 0.000 0.012
#> GSM154219 1 0.0469 0.9867 0.988 0.000 0.000 0.012
#> GSM154220 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154225 1 0.0336 0.9892 0.992 0.000 0.000 0.008
#> GSM154227 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.9934 1.000 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.9934 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.4562 0.157 0.000 0.500 0.008 0.492 0.000
#> GSM154424 2 0.2843 0.819 0.000 0.848 0.008 0.144 0.000
#> GSM154425 4 0.1644 0.891 0.000 0.008 0.004 0.940 0.048
#> GSM154426 2 0.2843 0.814 0.000 0.848 0.008 0.144 0.000
#> GSM154427 2 0.0404 0.896 0.000 0.988 0.000 0.012 0.000
#> GSM154428 2 0.4276 0.468 0.000 0.616 0.004 0.380 0.000
#> GSM154429 2 0.0703 0.894 0.000 0.976 0.000 0.024 0.000
#> GSM154430 2 0.0963 0.889 0.000 0.964 0.000 0.036 0.000
#> GSM154434 1 0.0162 0.995 0.996 0.000 0.000 0.000 0.004
#> GSM154436 5 0.1478 0.929 0.000 0.000 0.000 0.064 0.936
#> GSM154437 5 0.0451 0.975 0.004 0.000 0.000 0.008 0.988
#> GSM154438 5 0.0566 0.971 0.012 0.000 0.000 0.004 0.984
#> GSM154439 5 0.0451 0.974 0.008 0.000 0.000 0.004 0.988
#> GSM154403 3 0.3242 0.579 0.000 0.116 0.844 0.040 0.000
#> GSM154404 3 0.2569 0.599 0.000 0.068 0.892 0.040 0.000
#> GSM154405 2 0.4522 0.567 0.000 0.708 0.248 0.044 0.000
#> GSM154406 3 0.4644 0.417 0.000 0.280 0.680 0.040 0.000
#> GSM154407 3 0.5142 0.198 0.000 0.392 0.564 0.044 0.000
#> GSM154408 4 0.2588 0.875 0.000 0.048 0.060 0.892 0.000
#> GSM154409 4 0.3718 0.872 0.000 0.008 0.120 0.824 0.048
#> GSM154410 4 0.4488 0.810 0.000 0.004 0.188 0.748 0.060
#> GSM154411 4 0.1671 0.880 0.000 0.000 0.000 0.924 0.076
#> GSM154412 4 0.1300 0.889 0.000 0.028 0.000 0.956 0.016
#> GSM154413 3 0.2554 0.628 0.020 0.000 0.896 0.008 0.076
#> GSM154414 3 0.2470 0.627 0.000 0.000 0.884 0.012 0.104
#> GSM154415 3 0.4268 0.353 0.000 0.000 0.556 0.000 0.444
#> GSM154416 3 0.4307 0.247 0.000 0.000 0.500 0.000 0.500
#> GSM154417 3 0.0960 0.623 0.008 0.004 0.972 0.000 0.016
#> GSM154418 3 0.5068 0.386 0.000 0.000 0.572 0.040 0.388
#> GSM154419 3 0.4562 0.238 0.008 0.000 0.500 0.000 0.492
#> GSM154420 5 0.0510 0.971 0.000 0.000 0.000 0.016 0.984
#> GSM154421 3 0.4562 0.328 0.004 0.000 0.548 0.004 0.444
#> GSM154422 3 0.3170 0.606 0.008 0.004 0.828 0.000 0.160
#> GSM154203 2 0.0000 0.896 0.000 1.000 0.000 0.000 0.000
#> GSM154204 2 0.0609 0.892 0.000 0.980 0.000 0.020 0.000
#> GSM154205 2 0.0162 0.896 0.000 0.996 0.000 0.004 0.000
#> GSM154206 2 0.0162 0.896 0.000 0.996 0.000 0.004 0.000
#> GSM154207 2 0.0510 0.895 0.000 0.984 0.000 0.016 0.000
#> GSM154208 2 0.0609 0.892 0.000 0.980 0.000 0.020 0.000
#> GSM154209 2 0.1430 0.884 0.000 0.944 0.004 0.052 0.000
#> GSM154210 2 0.0671 0.894 0.000 0.980 0.004 0.016 0.000
#> GSM154211 2 0.2338 0.848 0.000 0.884 0.004 0.112 0.000
#> GSM154213 2 0.0290 0.896 0.000 0.992 0.000 0.008 0.000
#> GSM154214 2 0.0404 0.895 0.000 0.988 0.000 0.012 0.000
#> GSM154217 1 0.0162 0.995 0.996 0.000 0.000 0.000 0.004
#> GSM154219 1 0.0162 0.995 0.996 0.000 0.000 0.000 0.004
#> GSM154220 1 0.0162 0.996 0.996 0.000 0.000 0.000 0.004
#> GSM154221 1 0.0290 0.994 0.992 0.000 0.000 0.000 0.008
#> GSM154223 1 0.0290 0.994 0.992 0.000 0.000 0.000 0.008
#> GSM154224 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0162 0.995 0.996 0.000 0.000 0.000 0.004
#> GSM154227 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0162 0.996 0.996 0.000 0.000 0.000 0.004
#> GSM154229 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000
#> GSM154231 1 0.0162 0.996 0.996 0.000 0.000 0.000 0.004
#> GSM154232 1 0.0000 0.997 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.6714 0.477 0.000 0.436 0.036 0.236 0.004 0.288
#> GSM154424 2 0.6192 0.621 0.000 0.540 0.104 0.068 0.000 0.288
#> GSM154425 4 0.1719 0.849 0.000 0.000 0.008 0.928 0.008 0.056
#> GSM154426 2 0.6073 0.633 0.000 0.552 0.084 0.060 0.004 0.300
#> GSM154427 2 0.4809 0.701 0.000 0.664 0.072 0.012 0.000 0.252
#> GSM154428 2 0.6316 0.592 0.000 0.516 0.032 0.172 0.004 0.276
#> GSM154429 2 0.4159 0.727 0.000 0.732 0.036 0.016 0.000 0.216
#> GSM154430 2 0.4940 0.691 0.000 0.644 0.076 0.012 0.000 0.268
#> GSM154434 1 0.1267 0.938 0.940 0.000 0.000 0.000 0.060 0.000
#> GSM154436 5 0.1908 0.733 0.000 0.000 0.004 0.096 0.900 0.000
#> GSM154437 5 0.0458 0.797 0.000 0.000 0.000 0.016 0.984 0.000
#> GSM154438 5 0.0291 0.794 0.004 0.000 0.004 0.000 0.992 0.000
#> GSM154439 5 0.0363 0.798 0.000 0.000 0.000 0.012 0.988 0.000
#> GSM154403 6 0.5080 0.647 0.000 0.108 0.148 0.044 0.000 0.700
#> GSM154404 6 0.5074 0.582 0.000 0.068 0.208 0.044 0.000 0.680
#> GSM154405 6 0.4770 0.547 0.000 0.368 0.012 0.036 0.000 0.584
#> GSM154406 6 0.5345 0.673 0.000 0.232 0.060 0.060 0.000 0.648
#> GSM154407 6 0.4858 0.685 0.000 0.208 0.048 0.048 0.000 0.696
#> GSM154408 4 0.2551 0.867 0.000 0.012 0.004 0.872 0.004 0.108
#> GSM154409 4 0.2734 0.848 0.000 0.000 0.004 0.840 0.008 0.148
#> GSM154410 4 0.2979 0.814 0.000 0.000 0.004 0.804 0.004 0.188
#> GSM154411 4 0.0725 0.883 0.000 0.000 0.012 0.976 0.012 0.000
#> GSM154412 4 0.0291 0.885 0.000 0.000 0.000 0.992 0.004 0.004
#> GSM154413 3 0.5484 0.250 0.000 0.000 0.480 0.000 0.128 0.392
#> GSM154414 6 0.5922 -0.312 0.000 0.000 0.368 0.000 0.212 0.420
#> GSM154415 5 0.5061 0.275 0.000 0.000 0.252 0.000 0.620 0.128
#> GSM154416 5 0.4798 0.232 0.000 0.000 0.312 0.000 0.612 0.076
#> GSM154417 3 0.3993 0.423 0.000 0.000 0.676 0.000 0.024 0.300
#> GSM154418 3 0.2794 0.665 0.000 0.000 0.840 0.012 0.144 0.004
#> GSM154419 3 0.4284 0.222 0.004 0.000 0.544 0.000 0.440 0.012
#> GSM154420 5 0.0622 0.797 0.000 0.000 0.008 0.012 0.980 0.000
#> GSM154421 3 0.2854 0.631 0.000 0.000 0.792 0.000 0.208 0.000
#> GSM154422 3 0.2006 0.667 0.000 0.000 0.904 0.000 0.080 0.016
#> GSM154203 2 0.0692 0.761 0.000 0.976 0.000 0.004 0.000 0.020
#> GSM154204 2 0.1728 0.728 0.000 0.924 0.008 0.004 0.000 0.064
#> GSM154205 2 0.1155 0.750 0.000 0.956 0.004 0.004 0.000 0.036
#> GSM154206 2 0.0937 0.765 0.000 0.960 0.000 0.000 0.000 0.040
#> GSM154207 2 0.3192 0.738 0.000 0.776 0.004 0.004 0.000 0.216
#> GSM154208 2 0.1700 0.720 0.000 0.916 0.000 0.004 0.000 0.080
#> GSM154209 2 0.1074 0.760 0.000 0.960 0.000 0.012 0.000 0.028
#> GSM154210 2 0.1900 0.724 0.000 0.916 0.008 0.008 0.000 0.068
#> GSM154211 2 0.1779 0.764 0.000 0.920 0.000 0.016 0.000 0.064
#> GSM154213 2 0.1410 0.742 0.000 0.944 0.004 0.008 0.000 0.044
#> GSM154214 2 0.0935 0.752 0.000 0.964 0.000 0.004 0.000 0.032
#> GSM154217 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154219 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 1 0.0291 0.990 0.992 0.000 0.000 0.000 0.004 0.004
#> GSM154221 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154223 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0146 0.991 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154229 1 0.0363 0.986 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM154231 1 0.0146 0.991 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154232 1 0.0146 0.991 0.996 0.000 0.004 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> MAD:NMF 56 2.95e-05 5.37e-13 2
#> MAD:NMF 53 3.17e-07 1.69e-10 3
#> MAD:NMF 42 7.13e-11 1.48e-08 4
#> MAD:NMF 47 3.67e-13 1.98e-08 5
#> MAD:NMF 49 1.82e-13 2.22e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "hclust"]
# you can also extract it by
# res = res_list["ATC:hclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.671 0.867 0.933 0.3438 0.725 0.725
#> 3 3 0.616 0.746 0.886 0.8676 0.637 0.504
#> 4 4 0.660 0.761 0.857 0.1026 0.905 0.747
#> 5 5 0.739 0.709 0.832 0.0953 0.873 0.602
#> 6 6 0.809 0.756 0.878 0.0474 0.964 0.844
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
#> GSM154423 2 0.0672 0.916 0.008 0.992
#> GSM154424 2 0.0000 0.916 0.000 1.000
#> GSM154425 1 0.0000 0.999 1.000 0.000
#> GSM154426 2 0.0672 0.916 0.008 0.992
#> GSM154427 2 0.0000 0.916 0.000 1.000
#> GSM154428 2 0.0672 0.916 0.008 0.992
#> GSM154429 2 0.0000 0.916 0.000 1.000
#> GSM154430 2 0.0000 0.916 0.000 1.000
#> GSM154434 2 0.9732 0.466 0.404 0.596
#> GSM154436 1 0.0000 0.999 1.000 0.000
#> GSM154437 1 0.0000 0.999 1.000 0.000
#> GSM154438 1 0.0000 0.999 1.000 0.000
#> GSM154439 1 0.0000 0.999 1.000 0.000
#> GSM154403 2 0.0000 0.916 0.000 1.000
#> GSM154404 2 0.0000 0.916 0.000 1.000
#> GSM154405 2 0.0000 0.916 0.000 1.000
#> GSM154406 2 0.0000 0.916 0.000 1.000
#> GSM154407 2 0.0000 0.916 0.000 1.000
#> GSM154408 2 0.9815 0.420 0.420 0.580
#> GSM154409 1 0.0376 0.995 0.996 0.004
#> GSM154410 2 0.9922 0.362 0.448 0.552
#> GSM154411 1 0.0000 0.999 1.000 0.000
#> GSM154412 1 0.0000 0.999 1.000 0.000
#> GSM154413 2 0.0672 0.916 0.008 0.992
#> GSM154414 2 0.0672 0.916 0.008 0.992
#> GSM154415 2 0.4431 0.865 0.092 0.908
#> GSM154416 2 0.1184 0.913 0.016 0.984
#> GSM154417 2 0.0672 0.916 0.008 0.992
#> GSM154418 2 0.9732 0.466 0.404 0.596
#> GSM154419 2 0.6048 0.822 0.148 0.852
#> GSM154420 1 0.0000 0.999 1.000 0.000
#> GSM154421 2 0.6048 0.822 0.148 0.852
#> GSM154422 2 0.0672 0.916 0.008 0.992
#> GSM154203 2 0.0000 0.916 0.000 1.000
#> GSM154204 2 0.0000 0.916 0.000 1.000
#> GSM154205 2 0.0000 0.916 0.000 1.000
#> GSM154206 2 0.0000 0.916 0.000 1.000
#> GSM154207 2 0.0000 0.916 0.000 1.000
#> GSM154208 2 0.0000 0.916 0.000 1.000
#> GSM154209 2 0.0672 0.916 0.008 0.992
#> GSM154210 2 0.0000 0.916 0.000 1.000
#> GSM154211 2 0.7139 0.740 0.196 0.804
#> GSM154213 2 0.0000 0.916 0.000 1.000
#> GSM154214 2 0.0000 0.916 0.000 1.000
#> GSM154217 2 0.8443 0.693 0.272 0.728
#> GSM154219 2 0.8443 0.693 0.272 0.728
#> GSM154220 2 0.0672 0.916 0.008 0.992
#> GSM154221 2 0.0672 0.916 0.008 0.992
#> GSM154223 2 0.0672 0.916 0.008 0.992
#> GSM154224 2 0.8443 0.693 0.272 0.728
#> GSM154225 2 0.8443 0.693 0.272 0.728
#> GSM154227 2 0.8443 0.693 0.272 0.728
#> GSM154228 2 0.0672 0.916 0.008 0.992
#> GSM154229 2 0.0672 0.916 0.008 0.992
#> GSM154231 2 0.0672 0.916 0.008 0.992
#> GSM154232 2 0.0672 0.916 0.008 0.992
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 1 0.6045 0.335 0.620 0.380 0.000
#> GSM154424 2 0.0424 0.943 0.008 0.992 0.000
#> GSM154425 3 0.0000 0.925 0.000 0.000 1.000
#> GSM154426 1 0.6045 0.335 0.620 0.380 0.000
#> GSM154427 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154428 1 0.6045 0.335 0.620 0.380 0.000
#> GSM154429 2 0.0424 0.943 0.008 0.992 0.000
#> GSM154430 2 0.0424 0.943 0.008 0.992 0.000
#> GSM154434 1 0.6111 0.403 0.604 0.000 0.396
#> GSM154436 3 0.0000 0.925 0.000 0.000 1.000
#> GSM154437 3 0.0000 0.925 0.000 0.000 1.000
#> GSM154438 3 0.0000 0.925 0.000 0.000 1.000
#> GSM154439 3 0.0000 0.925 0.000 0.000 1.000
#> GSM154403 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154406 2 0.4504 0.792 0.196 0.804 0.000
#> GSM154407 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154408 1 0.9105 0.177 0.448 0.140 0.412
#> GSM154409 3 0.0592 0.918 0.012 0.000 0.988
#> GSM154410 3 0.9110 -0.230 0.420 0.140 0.440
#> GSM154411 3 0.0424 0.921 0.008 0.000 0.992
#> GSM154412 3 0.0424 0.921 0.008 0.000 0.992
#> GSM154413 1 0.0424 0.771 0.992 0.008 0.000
#> GSM154414 1 0.0424 0.771 0.992 0.008 0.000
#> GSM154415 1 0.3043 0.748 0.908 0.008 0.084
#> GSM154416 1 0.0848 0.772 0.984 0.008 0.008
#> GSM154417 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154418 1 0.6111 0.403 0.604 0.000 0.396
#> GSM154419 1 0.3686 0.719 0.860 0.000 0.140
#> GSM154420 3 0.0000 0.925 0.000 0.000 1.000
#> GSM154421 1 0.3686 0.719 0.860 0.000 0.140
#> GSM154422 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154203 2 0.4504 0.792 0.196 0.804 0.000
#> GSM154204 2 0.0424 0.943 0.008 0.992 0.000
#> GSM154205 2 0.4504 0.792 0.196 0.804 0.000
#> GSM154206 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154207 2 0.0424 0.943 0.008 0.992 0.000
#> GSM154208 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154209 1 0.6045 0.335 0.620 0.380 0.000
#> GSM154210 2 0.4504 0.792 0.196 0.804 0.000
#> GSM154211 1 0.8442 0.453 0.620 0.192 0.188
#> GSM154213 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.944 0.000 1.000 0.000
#> GSM154217 1 0.5254 0.617 0.736 0.000 0.264
#> GSM154219 1 0.5254 0.617 0.736 0.000 0.264
#> GSM154220 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154224 1 0.5254 0.617 0.736 0.000 0.264
#> GSM154225 1 0.5254 0.617 0.736 0.000 0.264
#> GSM154227 1 0.5254 0.617 0.736 0.000 0.264
#> GSM154228 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.774 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.774 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 4 0.3569 0.718 0.000 0.196 0.000 0.804
#> GSM154424 2 0.0469 0.918 0.000 0.988 0.000 0.012
#> GSM154425 3 0.3444 0.750 0.000 0.000 0.816 0.184
#> GSM154426 4 0.3569 0.718 0.000 0.196 0.000 0.804
#> GSM154427 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154428 4 0.3569 0.718 0.000 0.196 0.000 0.804
#> GSM154429 2 0.0469 0.918 0.000 0.988 0.000 0.012
#> GSM154430 2 0.0469 0.918 0.000 0.988 0.000 0.012
#> GSM154434 1 0.3390 0.537 0.852 0.000 0.132 0.016
#> GSM154436 3 0.0000 0.806 0.000 0.000 1.000 0.000
#> GSM154437 3 0.0000 0.806 0.000 0.000 1.000 0.000
#> GSM154438 3 0.0000 0.806 0.000 0.000 1.000 0.000
#> GSM154439 3 0.0000 0.806 0.000 0.000 1.000 0.000
#> GSM154403 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154404 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154405 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154406 2 0.3907 0.673 0.000 0.768 0.000 0.232
#> GSM154407 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154408 4 0.5143 0.282 0.456 0.000 0.004 0.540
#> GSM154409 3 0.7262 0.621 0.252 0.000 0.540 0.208
#> GSM154410 4 0.5165 0.263 0.484 0.000 0.004 0.512
#> GSM154411 3 0.7234 0.625 0.252 0.000 0.544 0.204
#> GSM154412 3 0.7234 0.625 0.252 0.000 0.544 0.204
#> GSM154413 1 0.4382 0.785 0.704 0.000 0.000 0.296
#> GSM154414 1 0.4382 0.785 0.704 0.000 0.000 0.296
#> GSM154415 1 0.3649 0.778 0.796 0.000 0.000 0.204
#> GSM154416 1 0.4277 0.789 0.720 0.000 0.000 0.280
#> GSM154417 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154418 1 0.3390 0.537 0.852 0.000 0.132 0.016
#> GSM154419 1 0.2589 0.766 0.884 0.000 0.000 0.116
#> GSM154420 3 0.0000 0.806 0.000 0.000 1.000 0.000
#> GSM154421 1 0.2589 0.766 0.884 0.000 0.000 0.116
#> GSM154422 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154203 2 0.3907 0.673 0.000 0.768 0.000 0.232
#> GSM154204 2 0.0469 0.918 0.000 0.988 0.000 0.012
#> GSM154205 2 0.3907 0.673 0.000 0.768 0.000 0.232
#> GSM154206 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0469 0.918 0.000 0.988 0.000 0.012
#> GSM154208 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154209 4 0.3569 0.718 0.000 0.196 0.000 0.804
#> GSM154210 2 0.3907 0.673 0.000 0.768 0.000 0.232
#> GSM154211 4 0.0336 0.594 0.000 0.008 0.000 0.992
#> GSM154213 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.920 0.000 1.000 0.000 0.000
#> GSM154217 1 0.0336 0.696 0.992 0.000 0.000 0.008
#> GSM154219 1 0.0336 0.696 0.992 0.000 0.000 0.008
#> GSM154220 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154221 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154223 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154224 1 0.0336 0.696 0.992 0.000 0.000 0.008
#> GSM154225 1 0.0336 0.696 0.992 0.000 0.000 0.008
#> GSM154227 1 0.0336 0.696 0.992 0.000 0.000 0.008
#> GSM154228 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154229 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154231 1 0.4304 0.800 0.716 0.000 0.000 0.284
#> GSM154232 1 0.4304 0.800 0.716 0.000 0.000 0.284
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.0703 0.939 0.000 0.024 0.000 0.976 0.000
#> GSM154424 2 0.2891 0.809 0.000 0.824 0.000 0.176 0.000
#> GSM154425 5 0.3409 0.794 0.160 0.000 0.000 0.024 0.816
#> GSM154426 4 0.0703 0.939 0.000 0.024 0.000 0.976 0.000
#> GSM154427 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154428 4 0.0703 0.939 0.000 0.024 0.000 0.976 0.000
#> GSM154429 2 0.2852 0.811 0.000 0.828 0.000 0.172 0.000
#> GSM154430 2 0.2852 0.811 0.000 0.828 0.000 0.172 0.000
#> GSM154434 1 0.2970 0.576 0.828 0.000 0.168 0.000 0.004
#> GSM154436 5 0.0000 0.962 0.000 0.000 0.000 0.000 1.000
#> GSM154437 5 0.0000 0.962 0.000 0.000 0.000 0.000 1.000
#> GSM154438 5 0.0000 0.962 0.000 0.000 0.000 0.000 1.000
#> GSM154439 5 0.0000 0.962 0.000 0.000 0.000 0.000 1.000
#> GSM154403 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154404 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154405 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154406 2 0.4192 0.573 0.000 0.596 0.000 0.404 0.000
#> GSM154407 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154408 1 0.6680 0.118 0.412 0.000 0.240 0.348 0.000
#> GSM154409 1 0.4902 -0.166 0.564 0.000 0.000 0.028 0.408
#> GSM154410 1 0.6638 0.176 0.440 0.000 0.240 0.320 0.000
#> GSM154411 1 0.4833 -0.170 0.564 0.000 0.000 0.024 0.412
#> GSM154412 1 0.4833 -0.170 0.564 0.000 0.000 0.024 0.412
#> GSM154413 3 0.1211 0.916 0.016 0.000 0.960 0.024 0.000
#> GSM154414 3 0.1211 0.916 0.016 0.000 0.960 0.024 0.000
#> GSM154415 3 0.4731 0.238 0.328 0.000 0.640 0.032 0.000
#> GSM154416 3 0.1818 0.888 0.044 0.000 0.932 0.024 0.000
#> GSM154417 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154418 1 0.2970 0.576 0.828 0.000 0.168 0.000 0.004
#> GSM154419 1 0.4305 0.239 0.512 0.000 0.488 0.000 0.000
#> GSM154420 5 0.0000 0.962 0.000 0.000 0.000 0.000 1.000
#> GSM154421 1 0.4305 0.239 0.512 0.000 0.488 0.000 0.000
#> GSM154422 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154203 2 0.4192 0.573 0.000 0.596 0.000 0.404 0.000
#> GSM154204 2 0.2852 0.811 0.000 0.828 0.000 0.172 0.000
#> GSM154205 2 0.4192 0.573 0.000 0.596 0.000 0.404 0.000
#> GSM154206 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.2891 0.809 0.000 0.824 0.000 0.176 0.000
#> GSM154208 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154209 4 0.0703 0.939 0.000 0.024 0.000 0.976 0.000
#> GSM154210 2 0.4192 0.573 0.000 0.596 0.000 0.404 0.000
#> GSM154211 4 0.2773 0.732 0.164 0.000 0.000 0.836 0.000
#> GSM154213 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.839 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.3816 0.568 0.696 0.000 0.304 0.000 0.000
#> GSM154219 1 0.3816 0.568 0.696 0.000 0.304 0.000 0.000
#> GSM154220 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154221 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154223 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154224 1 0.3816 0.568 0.696 0.000 0.304 0.000 0.000
#> GSM154225 1 0.3816 0.568 0.696 0.000 0.304 0.000 0.000
#> GSM154227 1 0.3816 0.568 0.696 0.000 0.304 0.000 0.000
#> GSM154228 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154229 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154231 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
#> GSM154232 3 0.0000 0.943 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 6 0.0000 0.92000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154424 2 0.2730 0.79659 0.000 0.808 0.000 0.000 0.000 0.192
#> GSM154425 4 0.3866 -0.00733 0.000 0.000 0.000 0.516 0.484 0.000
#> GSM154426 6 0.0000 0.92000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154427 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154428 6 0.0000 0.92000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154429 2 0.2697 0.79849 0.000 0.812 0.000 0.000 0.000 0.188
#> GSM154430 2 0.2697 0.79849 0.000 0.812 0.000 0.000 0.000 0.188
#> GSM154434 1 0.2491 0.70537 0.836 0.000 0.000 0.164 0.000 0.000
#> GSM154436 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154437 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154438 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154403 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154404 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154405 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154406 2 0.3810 0.55033 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM154407 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154408 4 0.6705 0.30865 0.132 0.000 0.092 0.476 0.000 0.300
#> GSM154409 4 0.1788 0.65527 0.004 0.000 0.000 0.916 0.076 0.004
#> GSM154410 4 0.6621 0.34393 0.132 0.000 0.092 0.504 0.000 0.272
#> GSM154411 4 0.1644 0.65511 0.004 0.000 0.000 0.920 0.076 0.000
#> GSM154412 4 0.1644 0.65511 0.004 0.000 0.000 0.920 0.076 0.000
#> GSM154413 3 0.3469 0.78810 0.120 0.000 0.812 0.064 0.000 0.004
#> GSM154414 3 0.3469 0.78810 0.120 0.000 0.812 0.064 0.000 0.004
#> GSM154415 3 0.5217 0.02656 0.452 0.000 0.472 0.068 0.000 0.008
#> GSM154416 3 0.3785 0.75431 0.152 0.000 0.780 0.064 0.000 0.004
#> GSM154417 3 0.0000 0.89118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 1 0.2491 0.70537 0.836 0.000 0.000 0.164 0.000 0.000
#> GSM154419 1 0.4134 0.44603 0.656 0.000 0.316 0.028 0.000 0.000
#> GSM154420 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154421 1 0.4134 0.44603 0.656 0.000 0.316 0.028 0.000 0.000
#> GSM154422 3 0.0000 0.89118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154203 2 0.3810 0.55033 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM154204 2 0.2697 0.79849 0.000 0.812 0.000 0.000 0.000 0.188
#> GSM154205 2 0.3810 0.55033 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM154206 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.2730 0.79659 0.000 0.808 0.000 0.000 0.000 0.192
#> GSM154208 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154209 6 0.0000 0.92000 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154210 2 0.3810 0.55033 0.000 0.572 0.000 0.000 0.000 0.428
#> GSM154211 6 0.2883 0.59107 0.000 0.000 0.000 0.212 0.000 0.788
#> GSM154213 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.82977 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.82438 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.82438 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 3 0.0000 0.89118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154221 3 0.0000 0.89118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154223 3 0.0000 0.89118 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.82438 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.82438 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.82438 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 3 0.0146 0.89146 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM154229 3 0.0458 0.88867 0.016 0.000 0.984 0.000 0.000 0.000
#> GSM154231 3 0.0146 0.89146 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM154232 3 0.0713 0.88413 0.028 0.000 0.972 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> ATC:hclust 52 1.66e-02 8.99e-01 2
#> ATC:hclust 47 2.36e-07 5.40e-09 3
#> ATC:hclust 54 9.57e-07 8.76e-10 4
#> ATC:hclust 48 5.23e-06 4.66e-09 5
#> ATC:hclust 50 2.80e-06 1.39e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "kmeans"]
# you can also extract it by
# res = res_list["ATC:kmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.734 0.890 0.951 0.4963 0.501 0.501
#> 3 3 0.890 0.902 0.952 0.3157 0.794 0.611
#> 4 4 0.862 0.869 0.926 0.1267 0.895 0.711
#> 5 5 0.818 0.748 0.824 0.0713 0.917 0.704
#> 6 6 0.776 0.670 0.802 0.0415 0.927 0.687
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
#> GSM154423 2 0.000 0.964 0.000 1.000
#> GSM154424 2 0.000 0.964 0.000 1.000
#> GSM154425 1 0.000 0.931 1.000 0.000
#> GSM154426 2 0.000 0.964 0.000 1.000
#> GSM154427 2 0.000 0.964 0.000 1.000
#> GSM154428 2 0.000 0.964 0.000 1.000
#> GSM154429 2 0.000 0.964 0.000 1.000
#> GSM154430 2 0.000 0.964 0.000 1.000
#> GSM154434 1 0.000 0.931 1.000 0.000
#> GSM154436 1 0.000 0.931 1.000 0.000
#> GSM154437 1 0.000 0.931 1.000 0.000
#> GSM154438 1 0.000 0.931 1.000 0.000
#> GSM154439 1 0.000 0.931 1.000 0.000
#> GSM154403 2 0.000 0.964 0.000 1.000
#> GSM154404 2 0.000 0.964 0.000 1.000
#> GSM154405 2 0.000 0.964 0.000 1.000
#> GSM154406 2 0.000 0.964 0.000 1.000
#> GSM154407 2 0.000 0.964 0.000 1.000
#> GSM154408 1 0.494 0.860 0.892 0.108
#> GSM154409 1 0.000 0.931 1.000 0.000
#> GSM154410 1 0.000 0.931 1.000 0.000
#> GSM154411 1 0.000 0.931 1.000 0.000
#> GSM154412 1 0.000 0.931 1.000 0.000
#> GSM154413 1 0.904 0.600 0.680 0.320
#> GSM154414 1 0.904 0.600 0.680 0.320
#> GSM154415 1 0.000 0.931 1.000 0.000
#> GSM154416 1 0.000 0.931 1.000 0.000
#> GSM154417 2 0.966 0.266 0.392 0.608
#> GSM154418 1 0.000 0.931 1.000 0.000
#> GSM154419 1 0.000 0.931 1.000 0.000
#> GSM154420 1 0.000 0.931 1.000 0.000
#> GSM154421 1 0.000 0.931 1.000 0.000
#> GSM154422 1 0.904 0.600 0.680 0.320
#> GSM154203 2 0.000 0.964 0.000 1.000
#> GSM154204 2 0.000 0.964 0.000 1.000
#> GSM154205 2 0.000 0.964 0.000 1.000
#> GSM154206 2 0.000 0.964 0.000 1.000
#> GSM154207 2 0.000 0.964 0.000 1.000
#> GSM154208 2 0.000 0.964 0.000 1.000
#> GSM154209 2 0.000 0.964 0.000 1.000
#> GSM154210 2 0.000 0.964 0.000 1.000
#> GSM154211 1 0.494 0.860 0.892 0.108
#> GSM154213 2 0.000 0.964 0.000 1.000
#> GSM154214 2 0.000 0.964 0.000 1.000
#> GSM154217 1 0.000 0.931 1.000 0.000
#> GSM154219 1 0.000 0.931 1.000 0.000
#> GSM154220 1 0.402 0.879 0.920 0.080
#> GSM154221 2 0.929 0.405 0.344 0.656
#> GSM154223 1 0.808 0.712 0.752 0.248
#> GSM154224 1 0.000 0.931 1.000 0.000
#> GSM154225 1 0.000 0.931 1.000 0.000
#> GSM154227 1 0.000 0.931 1.000 0.000
#> GSM154228 1 0.802 0.717 0.756 0.244
#> GSM154229 1 0.000 0.931 1.000 0.000
#> GSM154231 1 0.802 0.717 0.756 0.244
#> GSM154232 1 0.000 0.931 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.5536 0.752 0.200 0.776 0.024
#> GSM154424 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154425 3 0.0892 0.997 0.020 0.000 0.980
#> GSM154426 2 0.6066 0.688 0.248 0.728 0.024
#> GSM154427 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154428 2 0.6066 0.688 0.248 0.728 0.024
#> GSM154429 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154434 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154436 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154437 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154438 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154439 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154403 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154406 2 0.0892 0.934 0.000 0.980 0.020
#> GSM154407 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154408 1 0.7476 0.336 0.556 0.040 0.404
#> GSM154409 3 0.0892 0.997 0.020 0.000 0.980
#> GSM154410 1 0.6111 0.380 0.604 0.000 0.396
#> GSM154411 3 0.0892 0.997 0.020 0.000 0.980
#> GSM154412 3 0.0892 0.997 0.020 0.000 0.980
#> GSM154413 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154414 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154415 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154416 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154417 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154418 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154419 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154420 3 0.1031 0.998 0.024 0.000 0.976
#> GSM154421 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154422 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154203 2 0.0892 0.934 0.000 0.980 0.020
#> GSM154204 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154205 2 0.0892 0.934 0.000 0.980 0.020
#> GSM154206 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154209 2 0.6066 0.688 0.248 0.728 0.024
#> GSM154210 2 0.0892 0.934 0.000 0.980 0.020
#> GSM154211 1 0.7831 0.309 0.540 0.056 0.404
#> GSM154213 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.941 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154221 1 0.0237 0.936 0.996 0.004 0.000
#> GSM154223 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.940 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.940 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 4 0.2466 0.8552 0.004 0.096 0.000 0.900
#> GSM154424 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154425 3 0.0188 0.9640 0.000 0.000 0.996 0.004
#> GSM154426 4 0.2466 0.8552 0.004 0.096 0.000 0.900
#> GSM154427 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154428 4 0.2466 0.8552 0.004 0.096 0.000 0.900
#> GSM154429 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154434 3 0.3612 0.8522 0.044 0.000 0.856 0.100
#> GSM154436 3 0.0000 0.9647 0.000 0.000 1.000 0.000
#> GSM154437 3 0.0000 0.9647 0.000 0.000 1.000 0.000
#> GSM154438 3 0.0000 0.9647 0.000 0.000 1.000 0.000
#> GSM154439 3 0.0000 0.9647 0.000 0.000 1.000 0.000
#> GSM154403 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154404 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154405 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154406 2 0.4713 0.5072 0.000 0.640 0.000 0.360
#> GSM154407 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154408 4 0.1958 0.8444 0.008 0.020 0.028 0.944
#> GSM154409 4 0.6038 0.0934 0.044 0.000 0.424 0.532
#> GSM154410 4 0.3707 0.7419 0.132 0.000 0.028 0.840
#> GSM154411 3 0.0188 0.9640 0.000 0.000 0.996 0.004
#> GSM154412 3 0.0895 0.9531 0.004 0.000 0.976 0.020
#> GSM154413 1 0.1389 0.9372 0.952 0.000 0.000 0.048
#> GSM154414 1 0.1389 0.9372 0.952 0.000 0.000 0.048
#> GSM154415 1 0.2081 0.9172 0.916 0.000 0.000 0.084
#> GSM154416 1 0.1302 0.9383 0.956 0.000 0.000 0.044
#> GSM154417 1 0.1389 0.9372 0.952 0.000 0.000 0.048
#> GSM154418 3 0.3144 0.8770 0.044 0.000 0.884 0.072
#> GSM154419 1 0.2281 0.9139 0.904 0.000 0.000 0.096
#> GSM154420 3 0.0000 0.9647 0.000 0.000 1.000 0.000
#> GSM154421 1 0.2281 0.9139 0.904 0.000 0.000 0.096
#> GSM154422 1 0.1389 0.9372 0.952 0.000 0.000 0.048
#> GSM154203 2 0.4697 0.5151 0.000 0.644 0.000 0.356
#> GSM154204 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154205 2 0.4697 0.5151 0.000 0.644 0.000 0.356
#> GSM154206 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154209 4 0.2466 0.8552 0.004 0.096 0.000 0.900
#> GSM154210 2 0.4697 0.5151 0.000 0.644 0.000 0.356
#> GSM154211 4 0.1958 0.8444 0.008 0.020 0.028 0.944
#> GSM154213 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.9032 0.000 1.000 0.000 0.000
#> GSM154217 1 0.2281 0.9139 0.904 0.000 0.000 0.096
#> GSM154219 1 0.2281 0.9139 0.904 0.000 0.000 0.096
#> GSM154220 1 0.1302 0.9383 0.956 0.000 0.000 0.044
#> GSM154221 1 0.1389 0.9372 0.952 0.000 0.000 0.048
#> GSM154223 1 0.1302 0.9383 0.956 0.000 0.000 0.044
#> GSM154224 1 0.2281 0.9139 0.904 0.000 0.000 0.096
#> GSM154225 1 0.2281 0.9139 0.904 0.000 0.000 0.096
#> GSM154227 1 0.2011 0.9189 0.920 0.000 0.000 0.080
#> GSM154228 1 0.1302 0.9383 0.956 0.000 0.000 0.044
#> GSM154229 1 0.1302 0.9383 0.956 0.000 0.000 0.044
#> GSM154231 1 0.1302 0.9383 0.956 0.000 0.000 0.044
#> GSM154232 1 0.1022 0.9275 0.968 0.000 0.000 0.032
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.0404 0.901 0.000 0.000 0.012 0.988 0.000
#> GSM154424 2 0.3305 0.755 0.224 0.776 0.000 0.000 0.000
#> GSM154425 5 0.2516 0.891 0.140 0.000 0.000 0.000 0.860
#> GSM154426 4 0.0404 0.901 0.000 0.000 0.012 0.988 0.000
#> GSM154427 2 0.0000 0.817 0.000 1.000 0.000 0.000 0.000
#> GSM154428 4 0.0404 0.901 0.000 0.000 0.012 0.988 0.000
#> GSM154429 2 0.2929 0.773 0.180 0.820 0.000 0.000 0.000
#> GSM154430 2 0.0000 0.817 0.000 1.000 0.000 0.000 0.000
#> GSM154434 1 0.4442 0.243 0.688 0.000 0.028 0.000 0.284
#> GSM154436 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000
#> GSM154437 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000
#> GSM154438 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000
#> GSM154439 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000
#> GSM154403 2 0.0510 0.815 0.016 0.984 0.000 0.000 0.000
#> GSM154404 2 0.0510 0.815 0.016 0.984 0.000 0.000 0.000
#> GSM154405 2 0.0510 0.815 0.016 0.984 0.000 0.000 0.000
#> GSM154406 2 0.6811 0.314 0.232 0.388 0.004 0.376 0.000
#> GSM154407 2 0.0510 0.815 0.016 0.984 0.000 0.000 0.000
#> GSM154408 4 0.0451 0.898 0.008 0.000 0.004 0.988 0.000
#> GSM154409 4 0.5872 0.473 0.232 0.000 0.000 0.600 0.168
#> GSM154410 4 0.3424 0.721 0.240 0.000 0.000 0.760 0.000
#> GSM154411 5 0.3081 0.876 0.156 0.000 0.000 0.012 0.832
#> GSM154412 5 0.3391 0.853 0.188 0.000 0.000 0.012 0.800
#> GSM154413 3 0.1282 0.867 0.044 0.000 0.952 0.004 0.000
#> GSM154414 3 0.1282 0.867 0.044 0.000 0.952 0.004 0.000
#> GSM154415 1 0.4249 0.720 0.568 0.000 0.432 0.000 0.000
#> GSM154416 3 0.1197 0.868 0.048 0.000 0.952 0.000 0.000
#> GSM154417 3 0.0162 0.898 0.000 0.000 0.996 0.004 0.000
#> GSM154418 1 0.4130 0.138 0.696 0.000 0.000 0.012 0.292
#> GSM154419 1 0.4262 0.739 0.560 0.000 0.440 0.000 0.000
#> GSM154420 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000
#> GSM154421 1 0.4242 0.737 0.572 0.000 0.428 0.000 0.000
#> GSM154422 3 0.0162 0.898 0.000 0.000 0.996 0.004 0.000
#> GSM154203 2 0.6672 0.322 0.232 0.392 0.000 0.376 0.000
#> GSM154204 2 0.3074 0.767 0.196 0.804 0.000 0.000 0.000
#> GSM154205 2 0.6671 0.329 0.232 0.396 0.000 0.372 0.000
#> GSM154206 2 0.0000 0.817 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.3305 0.755 0.224 0.776 0.000 0.000 0.000
#> GSM154208 2 0.0000 0.817 0.000 1.000 0.000 0.000 0.000
#> GSM154209 4 0.0404 0.901 0.000 0.000 0.012 0.988 0.000
#> GSM154210 2 0.6671 0.329 0.232 0.396 0.000 0.372 0.000
#> GSM154211 4 0.0579 0.899 0.008 0.000 0.008 0.984 0.000
#> GSM154213 2 0.0000 0.817 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.817 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.4283 0.749 0.544 0.000 0.456 0.000 0.000
#> GSM154219 1 0.4283 0.749 0.544 0.000 0.456 0.000 0.000
#> GSM154220 3 0.0510 0.895 0.016 0.000 0.984 0.000 0.000
#> GSM154221 3 0.0566 0.897 0.012 0.000 0.984 0.004 0.000
#> GSM154223 3 0.0404 0.898 0.012 0.000 0.988 0.000 0.000
#> GSM154224 1 0.4283 0.749 0.544 0.000 0.456 0.000 0.000
#> GSM154225 1 0.4283 0.749 0.544 0.000 0.456 0.000 0.000
#> GSM154227 1 0.4283 0.749 0.544 0.000 0.456 0.000 0.000
#> GSM154228 3 0.0404 0.898 0.012 0.000 0.988 0.000 0.000
#> GSM154229 3 0.0162 0.897 0.004 0.000 0.996 0.000 0.000
#> GSM154231 3 0.0404 0.898 0.012 0.000 0.988 0.000 0.000
#> GSM154232 3 0.4287 -0.604 0.460 0.000 0.540 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.0146 0.464 0.004 0.996 0.000 0.000 0.000 0.000
#> GSM154424 6 0.3695 0.629 0.000 0.000 0.000 0.376 0.000 0.624
#> GSM154425 5 0.5056 0.444 0.100 0.000 0.000 0.312 0.588 0.000
#> GSM154426 2 0.0000 0.464 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154427 6 0.0000 0.858 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154428 2 0.0000 0.464 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154429 6 0.3371 0.698 0.000 0.000 0.000 0.292 0.000 0.708
#> GSM154430 6 0.0713 0.855 0.000 0.000 0.000 0.028 0.000 0.972
#> GSM154434 1 0.3463 0.624 0.828 0.000 0.040 0.028 0.104 0.000
#> GSM154436 5 0.0260 0.757 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM154437 5 0.0260 0.757 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM154438 5 0.0000 0.758 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0000 0.758 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154403 6 0.1863 0.843 0.036 0.000 0.000 0.044 0.000 0.920
#> GSM154404 6 0.1934 0.843 0.040 0.000 0.000 0.044 0.000 0.916
#> GSM154405 6 0.1863 0.843 0.036 0.000 0.000 0.044 0.000 0.920
#> GSM154406 2 0.6416 0.389 0.024 0.408 0.000 0.360 0.000 0.208
#> GSM154407 6 0.2258 0.842 0.060 0.000 0.000 0.044 0.000 0.896
#> GSM154408 2 0.1265 0.402 0.008 0.948 0.000 0.044 0.000 0.000
#> GSM154409 4 0.6717 0.000 0.152 0.384 0.000 0.396 0.068 0.000
#> GSM154410 2 0.5490 -0.760 0.140 0.516 0.000 0.344 0.000 0.000
#> GSM154411 5 0.5432 0.297 0.124 0.000 0.000 0.376 0.500 0.000
#> GSM154412 5 0.5545 0.227 0.136 0.000 0.000 0.396 0.468 0.000
#> GSM154413 3 0.2950 0.843 0.024 0.000 0.828 0.148 0.000 0.000
#> GSM154414 3 0.2950 0.843 0.024 0.000 0.828 0.148 0.000 0.000
#> GSM154415 1 0.5298 0.719 0.592 0.000 0.248 0.160 0.000 0.000
#> GSM154416 3 0.3062 0.832 0.024 0.000 0.816 0.160 0.000 0.000
#> GSM154417 3 0.0260 0.934 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154418 1 0.4968 0.133 0.632 0.000 0.000 0.248 0.120 0.000
#> GSM154419 1 0.3670 0.840 0.736 0.000 0.240 0.024 0.000 0.000
#> GSM154420 5 0.0000 0.758 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154421 1 0.3483 0.833 0.764 0.000 0.212 0.024 0.000 0.000
#> GSM154422 3 0.0260 0.934 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154203 2 0.6351 0.409 0.024 0.424 0.000 0.360 0.000 0.192
#> GSM154204 6 0.3563 0.669 0.000 0.000 0.000 0.336 0.000 0.664
#> GSM154205 2 0.6416 0.389 0.024 0.408 0.000 0.360 0.000 0.208
#> GSM154206 6 0.0000 0.858 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154207 6 0.3695 0.629 0.000 0.000 0.000 0.376 0.000 0.624
#> GSM154208 6 0.1176 0.855 0.024 0.000 0.000 0.020 0.000 0.956
#> GSM154209 2 0.0000 0.464 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154210 2 0.6416 0.389 0.024 0.408 0.000 0.360 0.000 0.208
#> GSM154211 2 0.1074 0.428 0.012 0.960 0.000 0.028 0.000 0.000
#> GSM154213 6 0.0632 0.857 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM154214 6 0.0632 0.857 0.024 0.000 0.000 0.000 0.000 0.976
#> GSM154217 1 0.3151 0.855 0.748 0.000 0.252 0.000 0.000 0.000
#> GSM154219 1 0.3151 0.855 0.748 0.000 0.252 0.000 0.000 0.000
#> GSM154220 3 0.0260 0.935 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154221 3 0.0260 0.935 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154223 3 0.0260 0.935 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154224 1 0.3151 0.855 0.748 0.000 0.252 0.000 0.000 0.000
#> GSM154225 1 0.3151 0.855 0.748 0.000 0.252 0.000 0.000 0.000
#> GSM154227 1 0.3151 0.855 0.748 0.000 0.252 0.000 0.000 0.000
#> GSM154228 3 0.0260 0.935 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154229 3 0.0458 0.932 0.000 0.000 0.984 0.016 0.000 0.000
#> GSM154231 3 0.0260 0.935 0.008 0.000 0.992 0.000 0.000 0.000
#> GSM154232 1 0.3684 0.722 0.628 0.000 0.372 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> ATC:kmeans 54 7.93e-05 7.47e-08 2
#> ATC:kmeans 53 5.19e-08 5.05e-10 3
#> ATC:kmeans 55 3.37e-07 4.23e-10 4
#> ATC:kmeans 48 1.22e-04 3.41e-08 5
#> ATC:kmeans 40 1.01e-04 1.07e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "skmeans"]
# you can also extract it by
# res = res_list["ATC:skmeans"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.795 0.858 0.947 0.5048 0.494 0.494
#> 3 3 0.877 0.956 0.972 0.3235 0.756 0.541
#> 4 4 0.883 0.890 0.936 0.0909 0.930 0.789
#> 5 5 0.949 0.964 0.969 0.0781 0.920 0.714
#> 6 6 0.934 0.906 0.941 0.0261 0.977 0.891
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM154423 2 0.000 0.929 0.000 1.000
#> GSM154424 2 0.000 0.929 0.000 1.000
#> GSM154425 1 0.000 0.946 1.000 0.000
#> GSM154426 2 0.000 0.929 0.000 1.000
#> GSM154427 2 0.000 0.929 0.000 1.000
#> GSM154428 2 0.000 0.929 0.000 1.000
#> GSM154429 2 0.000 0.929 0.000 1.000
#> GSM154430 2 0.000 0.929 0.000 1.000
#> GSM154434 1 0.000 0.946 1.000 0.000
#> GSM154436 1 0.000 0.946 1.000 0.000
#> GSM154437 1 0.000 0.946 1.000 0.000
#> GSM154438 1 0.000 0.946 1.000 0.000
#> GSM154439 1 0.000 0.946 1.000 0.000
#> GSM154403 2 0.000 0.929 0.000 1.000
#> GSM154404 2 0.000 0.929 0.000 1.000
#> GSM154405 2 0.000 0.929 0.000 1.000
#> GSM154406 2 0.000 0.929 0.000 1.000
#> GSM154407 2 0.000 0.929 0.000 1.000
#> GSM154408 2 0.971 0.342 0.400 0.600
#> GSM154409 1 0.000 0.946 1.000 0.000
#> GSM154410 1 0.000 0.946 1.000 0.000
#> GSM154411 1 0.000 0.946 1.000 0.000
#> GSM154412 1 0.000 0.946 1.000 0.000
#> GSM154413 1 0.971 0.334 0.600 0.400
#> GSM154414 1 0.971 0.334 0.600 0.400
#> GSM154415 1 0.000 0.946 1.000 0.000
#> GSM154416 1 0.000 0.946 1.000 0.000
#> GSM154417 2 0.969 0.301 0.396 0.604
#> GSM154418 1 0.000 0.946 1.000 0.000
#> GSM154419 1 0.000 0.946 1.000 0.000
#> GSM154420 1 0.000 0.946 1.000 0.000
#> GSM154421 1 0.000 0.946 1.000 0.000
#> GSM154422 1 0.971 0.334 0.600 0.400
#> GSM154203 2 0.000 0.929 0.000 1.000
#> GSM154204 2 0.000 0.929 0.000 1.000
#> GSM154205 2 0.000 0.929 0.000 1.000
#> GSM154206 2 0.000 0.929 0.000 1.000
#> GSM154207 2 0.000 0.929 0.000 1.000
#> GSM154208 2 0.000 0.929 0.000 1.000
#> GSM154209 2 0.000 0.929 0.000 1.000
#> GSM154210 2 0.000 0.929 0.000 1.000
#> GSM154211 2 0.969 0.351 0.396 0.604
#> GSM154213 2 0.000 0.929 0.000 1.000
#> GSM154214 2 0.000 0.929 0.000 1.000
#> GSM154217 1 0.000 0.946 1.000 0.000
#> GSM154219 1 0.000 0.946 1.000 0.000
#> GSM154220 1 0.000 0.946 1.000 0.000
#> GSM154221 2 0.966 0.312 0.392 0.608
#> GSM154223 1 0.706 0.729 0.808 0.192
#> GSM154224 1 0.000 0.946 1.000 0.000
#> GSM154225 1 0.000 0.946 1.000 0.000
#> GSM154227 1 0.000 0.946 1.000 0.000
#> GSM154228 1 0.000 0.946 1.000 0.000
#> GSM154229 1 0.000 0.946 1.000 0.000
#> GSM154231 1 0.000 0.946 1.000 0.000
#> GSM154232 1 0.000 0.946 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.000 1.000 0.000 1 0.000
#> GSM154424 2 0.000 1.000 0.000 1 0.000
#> GSM154425 3 0.000 0.991 0.000 0 1.000
#> GSM154426 2 0.000 1.000 0.000 1 0.000
#> GSM154427 2 0.000 1.000 0.000 1 0.000
#> GSM154428 2 0.000 1.000 0.000 1 0.000
#> GSM154429 2 0.000 1.000 0.000 1 0.000
#> GSM154430 2 0.000 1.000 0.000 1 0.000
#> GSM154434 3 0.000 0.991 0.000 0 1.000
#> GSM154436 3 0.000 0.991 0.000 0 1.000
#> GSM154437 3 0.000 0.991 0.000 0 1.000
#> GSM154438 3 0.000 0.991 0.000 0 1.000
#> GSM154439 3 0.000 0.991 0.000 0 1.000
#> GSM154403 2 0.000 1.000 0.000 1 0.000
#> GSM154404 2 0.000 1.000 0.000 1 0.000
#> GSM154405 2 0.000 1.000 0.000 1 0.000
#> GSM154406 2 0.000 1.000 0.000 1 0.000
#> GSM154407 2 0.000 1.000 0.000 1 0.000
#> GSM154408 3 0.000 0.991 0.000 0 1.000
#> GSM154409 3 0.000 0.991 0.000 0 1.000
#> GSM154410 3 0.000 0.991 0.000 0 1.000
#> GSM154411 3 0.000 0.991 0.000 0 1.000
#> GSM154412 3 0.000 0.991 0.000 0 1.000
#> GSM154413 1 0.000 0.908 1.000 0 0.000
#> GSM154414 1 0.000 0.908 1.000 0 0.000
#> GSM154415 3 0.207 0.931 0.060 0 0.940
#> GSM154416 1 0.455 0.833 0.800 0 0.200
#> GSM154417 1 0.000 0.908 1.000 0 0.000
#> GSM154418 3 0.000 0.991 0.000 0 1.000
#> GSM154419 1 0.465 0.826 0.792 0 0.208
#> GSM154420 3 0.000 0.991 0.000 0 1.000
#> GSM154421 3 0.216 0.927 0.064 0 0.936
#> GSM154422 1 0.000 0.908 1.000 0 0.000
#> GSM154203 2 0.000 1.000 0.000 1 0.000
#> GSM154204 2 0.000 1.000 0.000 1 0.000
#> GSM154205 2 0.000 1.000 0.000 1 0.000
#> GSM154206 2 0.000 1.000 0.000 1 0.000
#> GSM154207 2 0.000 1.000 0.000 1 0.000
#> GSM154208 2 0.000 1.000 0.000 1 0.000
#> GSM154209 2 0.000 1.000 0.000 1 0.000
#> GSM154210 2 0.000 1.000 0.000 1 0.000
#> GSM154211 3 0.000 0.991 0.000 0 1.000
#> GSM154213 2 0.000 1.000 0.000 1 0.000
#> GSM154214 2 0.000 1.000 0.000 1 0.000
#> GSM154217 1 0.465 0.826 0.792 0 0.208
#> GSM154219 1 0.455 0.833 0.800 0 0.200
#> GSM154220 1 0.000 0.908 1.000 0 0.000
#> GSM154221 1 0.000 0.908 1.000 0 0.000
#> GSM154223 1 0.000 0.908 1.000 0 0.000
#> GSM154224 1 0.465 0.826 0.792 0 0.208
#> GSM154225 1 0.465 0.826 0.792 0 0.208
#> GSM154227 1 0.455 0.833 0.800 0 0.200
#> GSM154228 1 0.000 0.908 1.000 0 0.000
#> GSM154229 1 0.000 0.908 1.000 0 0.000
#> GSM154231 1 0.000 0.908 1.000 0 0.000
#> GSM154232 1 0.000 0.908 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 4 0.1211 0.978 0.000 0.040 0.000 0.960
#> GSM154424 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154425 3 0.0707 0.977 0.000 0.000 0.980 0.020
#> GSM154426 4 0.1211 0.978 0.000 0.040 0.000 0.960
#> GSM154427 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154428 4 0.1211 0.978 0.000 0.040 0.000 0.960
#> GSM154429 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154434 3 0.0921 0.964 0.000 0.000 0.972 0.028
#> GSM154436 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM154437 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM154438 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM154439 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM154403 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154404 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154405 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154406 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154407 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154408 4 0.1211 0.956 0.000 0.000 0.040 0.960
#> GSM154409 3 0.0707 0.977 0.000 0.000 0.980 0.020
#> GSM154410 3 0.0707 0.977 0.000 0.000 0.980 0.020
#> GSM154411 3 0.0707 0.977 0.000 0.000 0.980 0.020
#> GSM154412 3 0.0707 0.977 0.000 0.000 0.980 0.020
#> GSM154413 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154414 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154415 3 0.1211 0.955 0.000 0.000 0.960 0.040
#> GSM154416 1 0.5466 0.638 0.668 0.000 0.292 0.040
#> GSM154417 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154418 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM154419 1 0.5942 0.504 0.548 0.000 0.412 0.040
#> GSM154420 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM154421 3 0.1211 0.955 0.000 0.000 0.960 0.040
#> GSM154422 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154203 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM154204 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154206 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154209 4 0.1211 0.978 0.000 0.040 0.000 0.960
#> GSM154210 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM154211 4 0.1211 0.956 0.000 0.000 0.040 0.960
#> GSM154213 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM154217 1 0.5942 0.504 0.548 0.000 0.412 0.040
#> GSM154219 1 0.5933 0.510 0.552 0.000 0.408 0.040
#> GSM154220 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154221 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154223 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154224 1 0.5942 0.504 0.548 0.000 0.412 0.040
#> GSM154225 1 0.5942 0.504 0.548 0.000 0.412 0.040
#> GSM154227 1 0.5619 0.612 0.640 0.000 0.320 0.040
#> GSM154228 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154229 1 0.1211 0.779 0.960 0.000 0.000 0.040
#> GSM154231 1 0.0000 0.786 1.000 0.000 0.000 0.000
#> GSM154232 1 0.1211 0.779 0.960 0.000 0.000 0.040
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM154424 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154425 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154426 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154428 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154430 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154434 5 0.0404 0.989 0.012 0.000 0.000 0.000 0.988
#> GSM154436 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154437 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154438 5 0.0162 0.996 0.004 0.000 0.000 0.000 0.996
#> GSM154439 5 0.0162 0.996 0.004 0.000 0.000 0.000 0.996
#> GSM154403 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154404 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154405 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154406 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154407 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154408 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM154409 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154410 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154411 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154412 5 0.0000 0.997 0.000 0.000 0.000 0.000 1.000
#> GSM154413 3 0.0404 0.856 0.012 0.000 0.988 0.000 0.000
#> GSM154414 3 0.0404 0.856 0.012 0.000 0.988 0.000 0.000
#> GSM154415 1 0.3767 0.812 0.812 0.000 0.120 0.000 0.068
#> GSM154416 1 0.2329 0.844 0.876 0.000 0.124 0.000 0.000
#> GSM154417 3 0.2280 0.948 0.120 0.000 0.880 0.000 0.000
#> GSM154418 5 0.0162 0.996 0.004 0.000 0.000 0.000 0.996
#> GSM154419 1 0.0404 0.927 0.988 0.000 0.000 0.000 0.012
#> GSM154420 5 0.0162 0.996 0.004 0.000 0.000 0.000 0.996
#> GSM154421 1 0.3508 0.685 0.748 0.000 0.000 0.000 0.252
#> GSM154422 3 0.2280 0.948 0.120 0.000 0.880 0.000 0.000
#> GSM154203 2 0.0290 0.993 0.000 0.992 0.000 0.008 0.000
#> GSM154204 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0162 0.996 0.000 0.996 0.000 0.004 0.000
#> GSM154206 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154208 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154209 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM154210 2 0.0162 0.996 0.000 0.996 0.000 0.004 0.000
#> GSM154211 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0404 0.927 0.988 0.000 0.000 0.000 0.012
#> GSM154219 1 0.0404 0.927 0.988 0.000 0.000 0.000 0.012
#> GSM154220 3 0.2648 0.941 0.152 0.000 0.848 0.000 0.000
#> GSM154221 3 0.2280 0.948 0.120 0.000 0.880 0.000 0.000
#> GSM154223 3 0.2516 0.947 0.140 0.000 0.860 0.000 0.000
#> GSM154224 1 0.0404 0.927 0.988 0.000 0.000 0.000 0.012
#> GSM154225 1 0.0404 0.927 0.988 0.000 0.000 0.000 0.012
#> GSM154227 1 0.0451 0.923 0.988 0.000 0.008 0.000 0.004
#> GSM154228 3 0.2605 0.944 0.148 0.000 0.852 0.000 0.000
#> GSM154229 1 0.1121 0.896 0.956 0.000 0.044 0.000 0.000
#> GSM154231 3 0.2605 0.944 0.148 0.000 0.852 0.000 0.000
#> GSM154232 1 0.0510 0.918 0.984 0.000 0.016 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 4 0.0000 0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154424 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154425 5 0.2311 0.912 0.000 0.000 0.104 0.000 0.880 0.016
#> GSM154426 4 0.0000 0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154427 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154428 4 0.0363 0.959 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM154429 2 0.0146 0.981 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154430 2 0.0146 0.981 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154434 5 0.0865 0.912 0.036 0.000 0.000 0.000 0.964 0.000
#> GSM154436 5 0.0000 0.933 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154437 5 0.0000 0.933 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154438 5 0.0260 0.933 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM154439 5 0.0260 0.933 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM154403 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154404 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154405 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154406 2 0.0603 0.974 0.000 0.980 0.016 0.000 0.000 0.004
#> GSM154407 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154408 4 0.2748 0.837 0.000 0.000 0.120 0.856 0.008 0.016
#> GSM154409 5 0.2494 0.904 0.000 0.000 0.120 0.000 0.864 0.016
#> GSM154410 5 0.2494 0.904 0.000 0.000 0.120 0.000 0.864 0.016
#> GSM154411 5 0.2311 0.912 0.000 0.000 0.104 0.000 0.880 0.016
#> GSM154412 5 0.2311 0.912 0.000 0.000 0.104 0.000 0.880 0.016
#> GSM154413 3 0.2527 0.655 0.000 0.000 0.832 0.000 0.000 0.168
#> GSM154414 3 0.2562 0.652 0.000 0.000 0.828 0.000 0.000 0.172
#> GSM154415 3 0.5304 0.539 0.292 0.000 0.572 0.000 0.136 0.000
#> GSM154416 3 0.4417 0.476 0.384 0.000 0.588 0.000 0.004 0.024
#> GSM154417 6 0.0891 0.954 0.024 0.000 0.008 0.000 0.000 0.968
#> GSM154418 5 0.0260 0.933 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM154419 1 0.0146 0.912 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154420 5 0.0260 0.933 0.008 0.000 0.000 0.000 0.992 0.000
#> GSM154421 1 0.3390 0.466 0.704 0.000 0.000 0.000 0.296 0.000
#> GSM154422 6 0.0891 0.954 0.024 0.000 0.008 0.000 0.000 0.968
#> GSM154203 2 0.2808 0.881 0.004 0.868 0.028 0.092 0.000 0.008
#> GSM154204 2 0.0520 0.976 0.000 0.984 0.008 0.000 0.000 0.008
#> GSM154205 2 0.2044 0.933 0.004 0.920 0.028 0.040 0.000 0.008
#> GSM154206 2 0.0146 0.981 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM154207 2 0.0520 0.976 0.000 0.984 0.008 0.000 0.000 0.008
#> GSM154208 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154209 4 0.0000 0.962 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM154210 2 0.2044 0.933 0.004 0.920 0.028 0.040 0.000 0.008
#> GSM154211 4 0.0806 0.954 0.000 0.000 0.020 0.972 0.008 0.000
#> GSM154213 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.981 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154217 1 0.0146 0.912 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154219 1 0.0146 0.912 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154220 6 0.1663 0.940 0.088 0.000 0.000 0.000 0.000 0.912
#> GSM154221 6 0.0777 0.955 0.024 0.000 0.004 0.000 0.000 0.972
#> GSM154223 6 0.1285 0.961 0.052 0.000 0.004 0.000 0.000 0.944
#> GSM154224 1 0.0146 0.912 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154225 1 0.0146 0.912 0.996 0.000 0.000 0.000 0.004 0.000
#> GSM154227 1 0.0146 0.909 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM154228 6 0.1643 0.957 0.068 0.000 0.008 0.000 0.000 0.924
#> GSM154229 1 0.2219 0.760 0.864 0.000 0.000 0.000 0.000 0.136
#> GSM154231 6 0.1643 0.957 0.068 0.000 0.008 0.000 0.000 0.924
#> GSM154232 1 0.0790 0.887 0.968 0.000 0.000 0.000 0.000 0.032
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> ATC:skmeans 49 5.21e-05 6.13e-08 2
#> ATC:skmeans 56 1.84e-08 1.84e-09 3
#> ATC:skmeans 56 5.02e-08 2.31e-09 4
#> ATC:skmeans 56 2.03e-06 5.51e-09 5
#> ATC:skmeans 54 1.08e-07 5.20e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "pam"]
# you can also extract it by
# res = res_list["ATC:pam"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.954 0.984 0.4926 0.514 0.514
#> 3 3 0.705 0.870 0.920 0.2587 0.865 0.737
#> 4 4 0.732 0.800 0.887 0.1674 0.876 0.686
#> 5 5 0.851 0.774 0.888 0.1040 0.852 0.530
#> 6 6 0.805 0.673 0.840 0.0411 0.872 0.479
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
#> GSM154423 2 0.0000 0.9994 0.000 1.000
#> GSM154424 2 0.0000 0.9994 0.000 1.000
#> GSM154425 1 0.0000 0.9720 1.000 0.000
#> GSM154426 2 0.0672 0.9919 0.008 0.992
#> GSM154427 2 0.0000 0.9994 0.000 1.000
#> GSM154428 2 0.0000 0.9994 0.000 1.000
#> GSM154429 2 0.0000 0.9994 0.000 1.000
#> GSM154430 2 0.0000 0.9994 0.000 1.000
#> GSM154434 1 0.0000 0.9720 1.000 0.000
#> GSM154436 1 0.0000 0.9720 1.000 0.000
#> GSM154437 1 0.0000 0.9720 1.000 0.000
#> GSM154438 1 0.0000 0.9720 1.000 0.000
#> GSM154439 1 0.0000 0.9720 1.000 0.000
#> GSM154403 2 0.0000 0.9994 0.000 1.000
#> GSM154404 2 0.0000 0.9994 0.000 1.000
#> GSM154405 2 0.0000 0.9994 0.000 1.000
#> GSM154406 2 0.0000 0.9994 0.000 1.000
#> GSM154407 2 0.0000 0.9994 0.000 1.000
#> GSM154408 1 0.0000 0.9720 1.000 0.000
#> GSM154409 1 0.0000 0.9720 1.000 0.000
#> GSM154410 1 0.0000 0.9720 1.000 0.000
#> GSM154411 1 0.0000 0.9720 1.000 0.000
#> GSM154412 1 0.0000 0.9720 1.000 0.000
#> GSM154413 1 0.0000 0.9720 1.000 0.000
#> GSM154414 1 0.0000 0.9720 1.000 0.000
#> GSM154415 1 0.0000 0.9720 1.000 0.000
#> GSM154416 1 0.0000 0.9720 1.000 0.000
#> GSM154417 1 0.0000 0.9720 1.000 0.000
#> GSM154418 1 0.0000 0.9720 1.000 0.000
#> GSM154419 1 0.0000 0.9720 1.000 0.000
#> GSM154420 1 0.0000 0.9720 1.000 0.000
#> GSM154421 1 0.0000 0.9720 1.000 0.000
#> GSM154422 1 0.0000 0.9720 1.000 0.000
#> GSM154203 2 0.0000 0.9994 0.000 1.000
#> GSM154204 2 0.0000 0.9994 0.000 1.000
#> GSM154205 2 0.0000 0.9994 0.000 1.000
#> GSM154206 2 0.0000 0.9994 0.000 1.000
#> GSM154207 2 0.0000 0.9994 0.000 1.000
#> GSM154208 2 0.0000 0.9994 0.000 1.000
#> GSM154209 2 0.0376 0.9958 0.004 0.996
#> GSM154210 2 0.0000 0.9994 0.000 1.000
#> GSM154211 1 0.9775 0.3067 0.588 0.412
#> GSM154213 2 0.0000 0.9994 0.000 1.000
#> GSM154214 2 0.0000 0.9994 0.000 1.000
#> GSM154217 1 0.0000 0.9720 1.000 0.000
#> GSM154219 1 0.0000 0.9720 1.000 0.000
#> GSM154220 1 0.0000 0.9720 1.000 0.000
#> GSM154221 1 1.0000 0.0282 0.504 0.496
#> GSM154223 1 0.0000 0.9720 1.000 0.000
#> GSM154224 1 0.0000 0.9720 1.000 0.000
#> GSM154225 1 0.0000 0.9720 1.000 0.000
#> GSM154227 1 0.0000 0.9720 1.000 0.000
#> GSM154228 1 0.0000 0.9720 1.000 0.000
#> GSM154229 1 0.0000 0.9720 1.000 0.000
#> GSM154231 1 0.0000 0.9720 1.000 0.000
#> GSM154232 1 0.0000 0.9720 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.8148 0.640 0.200 0.644 0.156
#> GSM154424 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154425 3 0.0000 0.780 0.000 0.000 1.000
#> GSM154426 2 0.8231 0.630 0.208 0.636 0.156
#> GSM154427 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154428 2 0.9193 0.318 0.364 0.480 0.156
#> GSM154429 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154434 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154436 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154437 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154438 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154439 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154403 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154406 2 0.3941 0.823 0.000 0.844 0.156
#> GSM154407 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154408 1 0.3941 0.802 0.844 0.000 0.156
#> GSM154409 1 0.4121 0.801 0.832 0.000 0.168
#> GSM154410 1 0.4062 0.803 0.836 0.000 0.164
#> GSM154411 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154412 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154413 1 0.3941 0.802 0.844 0.000 0.156
#> GSM154414 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154415 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154416 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154417 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154418 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154419 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154420 3 0.3941 0.970 0.156 0.000 0.844
#> GSM154421 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154422 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154203 2 0.3941 0.823 0.000 0.844 0.156
#> GSM154204 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154205 2 0.3941 0.823 0.000 0.844 0.156
#> GSM154206 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154209 2 0.8190 0.635 0.204 0.640 0.156
#> GSM154210 2 0.3941 0.823 0.000 0.844 0.156
#> GSM154211 1 0.8918 0.266 0.548 0.296 0.156
#> GSM154213 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.888 0.000 1.000 0.000
#> GSM154217 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154219 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154220 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154224 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154225 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154227 1 0.0424 0.940 0.992 0.000 0.008
#> GSM154228 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.941 1.000 0.000 0.000
#> GSM154232 1 0.0424 0.940 0.992 0.000 0.008
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 4 0.265 0.772 0.000 0.120 0.000 0.880
#> GSM154424 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154425 3 0.000 0.990 0.000 0.000 1.000 0.000
#> GSM154426 4 0.265 0.772 0.000 0.120 0.000 0.880
#> GSM154427 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154428 4 0.265 0.772 0.000 0.120 0.000 0.880
#> GSM154429 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154430 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154434 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154436 3 0.000 0.990 0.000 0.000 1.000 0.000
#> GSM154437 3 0.000 0.990 0.000 0.000 1.000 0.000
#> GSM154438 3 0.000 0.990 0.000 0.000 1.000 0.000
#> GSM154439 3 0.000 0.990 0.000 0.000 1.000 0.000
#> GSM154403 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154404 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154405 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154406 2 0.500 0.160 0.000 0.516 0.000 0.484
#> GSM154407 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154408 4 0.287 0.772 0.136 0.000 0.000 0.864
#> GSM154409 4 0.464 0.663 0.344 0.000 0.000 0.656
#> GSM154410 4 0.445 0.688 0.308 0.000 0.000 0.692
#> GSM154411 3 0.177 0.938 0.012 0.000 0.944 0.044
#> GSM154412 4 0.782 0.180 0.256 0.000 0.368 0.376
#> GSM154413 1 0.433 0.809 0.712 0.000 0.000 0.288
#> GSM154414 1 0.413 0.834 0.740 0.000 0.000 0.260
#> GSM154415 1 0.147 0.847 0.948 0.000 0.000 0.052
#> GSM154416 1 0.287 0.838 0.864 0.000 0.000 0.136
#> GSM154417 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154418 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154419 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154420 3 0.000 0.990 0.000 0.000 1.000 0.000
#> GSM154421 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154422 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154203 2 0.494 0.297 0.000 0.564 0.000 0.436
#> GSM154204 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154205 2 0.494 0.297 0.000 0.564 0.000 0.436
#> GSM154206 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154207 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154208 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154209 4 0.265 0.772 0.000 0.120 0.000 0.880
#> GSM154210 2 0.494 0.297 0.000 0.564 0.000 0.436
#> GSM154211 4 0.293 0.778 0.108 0.012 0.000 0.880
#> GSM154213 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154214 2 0.000 0.877 0.000 1.000 0.000 0.000
#> GSM154217 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154219 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154220 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154221 1 0.430 0.813 0.716 0.000 0.000 0.284
#> GSM154223 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154224 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154225 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154227 1 0.000 0.846 1.000 0.000 0.000 0.000
#> GSM154228 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154229 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154231 1 0.410 0.836 0.744 0.000 0.000 0.256
#> GSM154232 1 0.000 0.846 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.0000 0.776 0.000 0.000 0.000 1.000 0.000
#> GSM154424 2 0.0510 0.983 0.000 0.984 0.000 0.016 0.000
#> GSM154425 5 0.0000 0.986 0.000 0.000 0.000 0.000 1.000
#> GSM154426 4 0.0000 0.776 0.000 0.000 0.000 1.000 0.000
#> GSM154427 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154428 4 0.0000 0.776 0.000 0.000 0.000 1.000 0.000
#> GSM154429 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154430 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154434 1 0.3305 0.647 0.776 0.000 0.224 0.000 0.000
#> GSM154436 5 0.0000 0.986 0.000 0.000 0.000 0.000 1.000
#> GSM154437 5 0.0000 0.986 0.000 0.000 0.000 0.000 1.000
#> GSM154438 5 0.0000 0.986 0.000 0.000 0.000 0.000 1.000
#> GSM154439 5 0.0000 0.986 0.000 0.000 0.000 0.000 1.000
#> GSM154403 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154404 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154405 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154406 4 0.3774 0.632 0.000 0.296 0.000 0.704 0.000
#> GSM154407 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154408 4 0.0000 0.776 0.000 0.000 0.000 1.000 0.000
#> GSM154409 4 0.4225 0.263 0.364 0.000 0.004 0.632 0.000
#> GSM154410 4 0.4015 0.310 0.348 0.000 0.000 0.652 0.000
#> GSM154411 5 0.2153 0.912 0.040 0.000 0.000 0.044 0.916
#> GSM154412 1 0.6494 0.331 0.492 0.000 0.000 0.252 0.256
#> GSM154413 3 0.0000 0.809 0.000 0.000 1.000 0.000 0.000
#> GSM154414 3 0.0000 0.809 0.000 0.000 1.000 0.000 0.000
#> GSM154415 1 0.4278 0.530 0.548 0.000 0.452 0.000 0.000
#> GSM154416 1 0.4278 0.530 0.548 0.000 0.452 0.000 0.000
#> GSM154417 3 0.0000 0.809 0.000 0.000 1.000 0.000 0.000
#> GSM154418 1 0.4171 0.568 0.604 0.000 0.396 0.000 0.000
#> GSM154419 1 0.4278 0.530 0.548 0.000 0.452 0.000 0.000
#> GSM154420 5 0.0000 0.986 0.000 0.000 0.000 0.000 1.000
#> GSM154421 1 0.4278 0.530 0.548 0.000 0.452 0.000 0.000
#> GSM154422 3 0.0000 0.809 0.000 0.000 1.000 0.000 0.000
#> GSM154203 4 0.3774 0.632 0.000 0.296 0.000 0.704 0.000
#> GSM154204 2 0.0609 0.980 0.000 0.980 0.000 0.020 0.000
#> GSM154205 4 0.3774 0.632 0.000 0.296 0.000 0.704 0.000
#> GSM154206 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0609 0.980 0.000 0.980 0.000 0.020 0.000
#> GSM154208 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154209 4 0.0000 0.776 0.000 0.000 0.000 1.000 0.000
#> GSM154210 4 0.3774 0.632 0.000 0.296 0.000 0.704 0.000
#> GSM154211 4 0.0000 0.776 0.000 0.000 0.000 1.000 0.000
#> GSM154213 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0000 0.995 0.000 1.000 0.000 0.000 0.000
#> GSM154217 1 0.0000 0.685 1.000 0.000 0.000 0.000 0.000
#> GSM154219 1 0.0000 0.685 1.000 0.000 0.000 0.000 0.000
#> GSM154220 3 0.4161 0.505 0.392 0.000 0.608 0.000 0.000
#> GSM154221 3 0.0000 0.809 0.000 0.000 1.000 0.000 0.000
#> GSM154223 3 0.0404 0.805 0.012 0.000 0.988 0.000 0.000
#> GSM154224 1 0.0000 0.685 1.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.685 1.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.685 1.000 0.000 0.000 0.000 0.000
#> GSM154228 3 0.4150 0.510 0.388 0.000 0.612 0.000 0.000
#> GSM154229 3 0.1341 0.750 0.056 0.000 0.944 0.000 0.000
#> GSM154231 3 0.4060 0.540 0.360 0.000 0.640 0.000 0.000
#> GSM154232 1 0.1544 0.629 0.932 0.000 0.068 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.2048 0.79250 0.000 0.880 0.000 0.120 0.000 0.000
#> GSM154424 6 0.3428 0.53774 0.000 0.304 0.000 0.000 0.000 0.696
#> GSM154425 4 0.3774 0.27875 0.000 0.000 0.000 0.592 0.408 0.000
#> GSM154426 2 0.2491 0.77264 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM154427 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154428 2 0.2048 0.79250 0.000 0.880 0.000 0.120 0.000 0.000
#> GSM154429 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154430 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154434 1 0.5486 0.23646 0.568 0.000 0.224 0.208 0.000 0.000
#> GSM154436 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154437 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154438 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154439 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154403 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154404 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154405 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154406 2 0.1204 0.81045 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM154407 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154408 4 0.3309 0.42420 0.000 0.280 0.000 0.720 0.000 0.000
#> GSM154409 4 0.4760 0.61339 0.120 0.212 0.000 0.668 0.000 0.000
#> GSM154410 4 0.4968 0.58949 0.120 0.248 0.000 0.632 0.000 0.000
#> GSM154411 4 0.3756 0.29469 0.000 0.000 0.000 0.600 0.400 0.000
#> GSM154412 4 0.4066 0.53768 0.120 0.020 0.000 0.780 0.080 0.000
#> GSM154413 3 0.0865 0.64435 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM154414 3 0.0865 0.64435 0.000 0.000 0.964 0.036 0.000 0.000
#> GSM154415 3 0.5858 0.34931 0.272 0.000 0.484 0.244 0.000 0.000
#> GSM154416 3 0.5858 0.34931 0.272 0.000 0.484 0.244 0.000 0.000
#> GSM154417 3 0.0000 0.64467 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154418 4 0.5910 -0.06139 0.308 0.000 0.232 0.460 0.000 0.000
#> GSM154419 3 0.5858 0.34931 0.272 0.000 0.484 0.244 0.000 0.000
#> GSM154420 5 0.0000 1.00000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM154421 3 0.5847 0.33544 0.284 0.000 0.484 0.232 0.000 0.000
#> GSM154422 3 0.0000 0.64467 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154203 2 0.1204 0.81045 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM154204 2 0.3409 0.56303 0.000 0.700 0.000 0.000 0.000 0.300
#> GSM154205 2 0.1204 0.81045 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM154206 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154207 2 0.3409 0.56303 0.000 0.700 0.000 0.000 0.000 0.300
#> GSM154208 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154209 2 0.2491 0.77264 0.000 0.836 0.000 0.164 0.000 0.000
#> GSM154210 2 0.1204 0.81045 0.000 0.944 0.000 0.000 0.000 0.056
#> GSM154211 2 0.2562 0.76574 0.000 0.828 0.000 0.172 0.000 0.000
#> GSM154213 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154214 6 0.0000 0.96984 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154217 1 0.2854 0.63245 0.792 0.000 0.000 0.208 0.000 0.000
#> GSM154219 1 0.0000 0.79104 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154220 3 0.3804 0.00456 0.424 0.000 0.576 0.000 0.000 0.000
#> GSM154221 3 0.0000 0.64467 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM154223 3 0.0363 0.63855 0.012 0.000 0.988 0.000 0.000 0.000
#> GSM154224 1 0.0000 0.79104 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154225 1 0.0000 0.79104 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154227 1 0.0000 0.79104 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM154228 1 0.3862 0.00362 0.524 0.000 0.476 0.000 0.000 0.000
#> GSM154229 3 0.4146 0.46696 0.288 0.000 0.676 0.036 0.000 0.000
#> GSM154231 3 0.3828 0.01034 0.440 0.000 0.560 0.000 0.000 0.000
#> GSM154232 1 0.0000 0.79104 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> ATC:pam 54 1.48e-05 2.22e-08 2
#> ATC:pam 54 2.42e-07 1.57e-08 3
#> ATC:pam 51 1.77e-05 8.12e-10 4
#> ATC:pam 53 3.48e-05 1.33e-09 5
#> ATC:pam 43 2.07e-07 3.70e-08 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "mclust"]
# you can also extract it by
# res = res_list["ATC:mclust"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 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.556 0.945 0.944 0.4785 0.492 0.492
#> 3 3 0.724 0.829 0.920 0.3064 0.910 0.818
#> 4 4 0.773 0.821 0.898 0.1126 0.918 0.796
#> 5 5 0.792 0.783 0.891 0.1034 0.873 0.629
#> 6 6 0.772 0.808 0.839 0.0683 0.832 0.419
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
#> GSM154423 2 0.634 0.913 0.160 0.840
#> GSM154424 2 0.634 0.913 0.160 0.840
#> GSM154425 2 0.722 0.888 0.200 0.800
#> GSM154426 2 0.634 0.913 0.160 0.840
#> GSM154427 2 0.000 0.880 0.000 1.000
#> GSM154428 2 0.634 0.913 0.160 0.840
#> GSM154429 2 0.000 0.880 0.000 1.000
#> GSM154430 2 0.000 0.880 0.000 1.000
#> GSM154434 1 0.000 1.000 1.000 0.000
#> GSM154436 1 0.000 1.000 1.000 0.000
#> GSM154437 1 0.000 1.000 1.000 0.000
#> GSM154438 1 0.000 1.000 1.000 0.000
#> GSM154439 1 0.000 1.000 1.000 0.000
#> GSM154403 2 0.000 0.880 0.000 1.000
#> GSM154404 2 0.000 0.880 0.000 1.000
#> GSM154405 2 0.000 0.880 0.000 1.000
#> GSM154406 2 0.615 0.912 0.152 0.848
#> GSM154407 2 0.634 0.913 0.160 0.840
#> GSM154408 2 0.697 0.896 0.188 0.812
#> GSM154409 2 0.722 0.888 0.200 0.800
#> GSM154410 2 0.722 0.888 0.200 0.800
#> GSM154411 2 0.722 0.888 0.200 0.800
#> GSM154412 2 0.722 0.888 0.200 0.800
#> GSM154413 1 0.000 1.000 1.000 0.000
#> GSM154414 1 0.000 1.000 1.000 0.000
#> GSM154415 1 0.000 1.000 1.000 0.000
#> GSM154416 1 0.000 1.000 1.000 0.000
#> GSM154417 1 0.000 1.000 1.000 0.000
#> GSM154418 1 0.000 1.000 1.000 0.000
#> GSM154419 1 0.000 1.000 1.000 0.000
#> GSM154420 1 0.000 1.000 1.000 0.000
#> GSM154421 1 0.000 1.000 1.000 0.000
#> GSM154422 1 0.000 1.000 1.000 0.000
#> GSM154203 2 0.634 0.913 0.160 0.840
#> GSM154204 2 0.000 0.880 0.000 1.000
#> GSM154205 2 0.625 0.912 0.156 0.844
#> GSM154206 2 0.000 0.880 0.000 1.000
#> GSM154207 2 0.000 0.880 0.000 1.000
#> GSM154208 2 0.634 0.913 0.160 0.840
#> GSM154209 2 0.634 0.913 0.160 0.840
#> GSM154210 2 0.634 0.913 0.160 0.840
#> GSM154211 2 0.722 0.888 0.200 0.800
#> GSM154213 2 0.000 0.880 0.000 1.000
#> GSM154214 2 0.000 0.880 0.000 1.000
#> GSM154217 1 0.000 1.000 1.000 0.000
#> GSM154219 1 0.000 1.000 1.000 0.000
#> GSM154220 1 0.000 1.000 1.000 0.000
#> GSM154221 1 0.000 1.000 1.000 0.000
#> GSM154223 1 0.000 1.000 1.000 0.000
#> GSM154224 1 0.000 1.000 1.000 0.000
#> GSM154225 1 0.000 1.000 1.000 0.000
#> GSM154227 1 0.000 1.000 1.000 0.000
#> GSM154228 1 0.000 1.000 1.000 0.000
#> GSM154229 1 0.000 1.000 1.000 0.000
#> GSM154231 1 0.000 1.000 1.000 0.000
#> GSM154232 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.5016 0.6643 0.000 0.760 0.240
#> GSM154424 2 0.0592 0.9109 0.000 0.988 0.012
#> GSM154425 3 0.3715 0.8596 0.004 0.128 0.868
#> GSM154426 2 0.5016 0.6643 0.000 0.760 0.240
#> GSM154427 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154428 2 0.5016 0.6643 0.000 0.760 0.240
#> GSM154429 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154434 1 0.4178 0.7766 0.828 0.000 0.172
#> GSM154436 1 0.5968 0.5936 0.636 0.000 0.364
#> GSM154437 1 0.5968 0.5936 0.636 0.000 0.364
#> GSM154438 1 0.5968 0.5936 0.636 0.000 0.364
#> GSM154439 1 0.5968 0.5936 0.636 0.000 0.364
#> GSM154403 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154406 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154407 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154408 3 0.3412 0.8636 0.000 0.124 0.876
#> GSM154409 3 0.0592 0.9363 0.000 0.012 0.988
#> GSM154410 3 0.0592 0.9363 0.000 0.012 0.988
#> GSM154411 3 0.0000 0.9308 0.000 0.000 1.000
#> GSM154412 3 0.0000 0.9308 0.000 0.000 1.000
#> GSM154413 1 0.4121 0.7781 0.832 0.000 0.168
#> GSM154414 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154415 1 0.5016 0.7121 0.760 0.000 0.240
#> GSM154416 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154417 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154418 1 0.5968 0.5936 0.636 0.000 0.364
#> GSM154419 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154420 1 0.5968 0.5936 0.636 0.000 0.364
#> GSM154421 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154422 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154203 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154204 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154205 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154206 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154209 2 0.5016 0.6643 0.000 0.760 0.240
#> GSM154210 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154211 2 0.6307 0.0656 0.000 0.512 0.488
#> GSM154213 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.9199 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154221 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154223 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154224 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.8813 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.8813 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 2 0.3763 0.8331 0.000 0.832 0.024 0.144
#> GSM154424 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154425 4 0.2197 0.9143 0.000 0.004 0.080 0.916
#> GSM154426 2 0.3958 0.8186 0.000 0.816 0.024 0.160
#> GSM154427 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154428 2 0.3763 0.8331 0.000 0.832 0.024 0.144
#> GSM154429 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154430 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154434 1 0.6677 0.3721 0.552 0.000 0.348 0.100
#> GSM154436 3 0.2530 0.8522 0.000 0.000 0.888 0.112
#> GSM154437 3 0.2530 0.8522 0.000 0.000 0.888 0.112
#> GSM154438 3 0.6938 -0.0126 0.400 0.000 0.488 0.112
#> GSM154439 3 0.2530 0.8522 0.000 0.000 0.888 0.112
#> GSM154403 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154404 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154405 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154406 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154407 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154408 4 0.0000 0.9697 0.000 0.000 0.000 1.000
#> GSM154409 4 0.0336 0.9760 0.000 0.000 0.008 0.992
#> GSM154410 4 0.0336 0.9760 0.000 0.000 0.008 0.992
#> GSM154411 4 0.0336 0.9760 0.000 0.000 0.008 0.992
#> GSM154412 4 0.0921 0.9661 0.000 0.000 0.028 0.972
#> GSM154413 1 0.2542 0.7545 0.904 0.000 0.012 0.084
#> GSM154414 1 0.0000 0.8081 1.000 0.000 0.000 0.000
#> GSM154415 1 0.2542 0.7545 0.904 0.000 0.012 0.084
#> GSM154416 1 0.0000 0.8081 1.000 0.000 0.000 0.000
#> GSM154417 1 0.0707 0.8083 0.980 0.000 0.020 0.000
#> GSM154418 3 0.3441 0.8304 0.024 0.000 0.856 0.120
#> GSM154419 1 0.3649 0.7465 0.796 0.000 0.204 0.000
#> GSM154420 3 0.2530 0.8522 0.000 0.000 0.888 0.112
#> GSM154421 1 0.5444 0.4649 0.560 0.000 0.424 0.016
#> GSM154422 1 0.0707 0.8083 0.980 0.000 0.020 0.000
#> GSM154203 2 0.1059 0.9425 0.000 0.972 0.012 0.016
#> GSM154204 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154205 2 0.0804 0.9463 0.000 0.980 0.012 0.008
#> GSM154206 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154208 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154209 2 0.3969 0.8069 0.000 0.804 0.016 0.180
#> GSM154210 2 0.0804 0.9463 0.000 0.980 0.012 0.008
#> GSM154211 2 0.4482 0.7974 0.000 0.804 0.068 0.128
#> GSM154213 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.9542 0.000 1.000 0.000 0.000
#> GSM154217 1 0.4977 0.4478 0.540 0.000 0.460 0.000
#> GSM154219 1 0.4977 0.4478 0.540 0.000 0.460 0.000
#> GSM154220 1 0.2408 0.7933 0.896 0.000 0.104 0.000
#> GSM154221 1 0.0592 0.8084 0.984 0.000 0.016 0.000
#> GSM154223 1 0.0000 0.8081 1.000 0.000 0.000 0.000
#> GSM154224 1 0.4661 0.5822 0.652 0.000 0.348 0.000
#> GSM154225 1 0.4916 0.4906 0.576 0.000 0.424 0.000
#> GSM154227 1 0.2281 0.7928 0.904 0.000 0.096 0.000
#> GSM154228 1 0.0000 0.8081 1.000 0.000 0.000 0.000
#> GSM154229 1 0.0000 0.8081 1.000 0.000 0.000 0.000
#> GSM154231 1 0.0000 0.8081 1.000 0.000 0.000 0.000
#> GSM154232 1 0.2281 0.7928 0.904 0.000 0.096 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 2 0.2654 0.838 0.000 0.900 0.016 0.040 0.044
#> GSM154424 2 0.1121 0.868 0.000 0.956 0.000 0.000 0.044
#> GSM154425 5 0.0000 0.632 0.000 0.000 0.000 0.000 1.000
#> GSM154426 2 0.3940 0.756 0.000 0.808 0.012 0.136 0.044
#> GSM154427 2 0.0162 0.883 0.000 0.996 0.000 0.004 0.000
#> GSM154428 2 0.2499 0.841 0.000 0.908 0.016 0.040 0.036
#> GSM154429 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> GSM154430 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> GSM154434 1 0.2149 0.895 0.916 0.000 0.036 0.000 0.048
#> GSM154436 5 0.3331 0.656 0.024 0.000 0.068 0.044 0.864
#> GSM154437 5 0.4415 0.605 0.008 0.000 0.160 0.064 0.768
#> GSM154438 1 0.4182 0.352 0.600 0.000 0.000 0.000 0.400
#> GSM154439 5 0.4101 0.244 0.372 0.000 0.000 0.000 0.628
#> GSM154403 2 0.0162 0.883 0.000 0.996 0.000 0.004 0.000
#> GSM154404 2 0.0324 0.883 0.000 0.992 0.000 0.004 0.004
#> GSM154405 2 0.0162 0.883 0.000 0.996 0.000 0.004 0.000
#> GSM154406 2 0.0451 0.881 0.000 0.988 0.000 0.008 0.004
#> GSM154407 2 0.4341 0.431 0.000 0.592 0.000 0.404 0.004
#> GSM154408 4 0.0290 0.942 0.000 0.000 0.000 0.992 0.008
#> GSM154409 4 0.0510 0.944 0.000 0.000 0.000 0.984 0.016
#> GSM154410 4 0.0404 0.944 0.000 0.000 0.000 0.988 0.012
#> GSM154411 4 0.0794 0.940 0.000 0.000 0.000 0.972 0.028
#> GSM154412 4 0.2233 0.871 0.000 0.000 0.004 0.892 0.104
#> GSM154413 1 0.1774 0.894 0.932 0.000 0.016 0.000 0.052
#> GSM154414 1 0.3141 0.798 0.832 0.000 0.152 0.000 0.016
#> GSM154415 1 0.1845 0.891 0.928 0.000 0.016 0.000 0.056
#> GSM154416 1 0.1469 0.908 0.948 0.000 0.036 0.000 0.016
#> GSM154417 3 0.1544 0.857 0.068 0.000 0.932 0.000 0.000
#> GSM154418 3 0.5556 0.326 0.008 0.000 0.616 0.076 0.300
#> GSM154419 3 0.1121 0.861 0.044 0.000 0.956 0.000 0.000
#> GSM154420 5 0.5432 0.240 0.000 0.000 0.392 0.064 0.544
#> GSM154421 3 0.0955 0.857 0.028 0.000 0.968 0.000 0.004
#> GSM154422 3 0.1341 0.860 0.056 0.000 0.944 0.000 0.000
#> GSM154203 2 0.1018 0.874 0.000 0.968 0.016 0.016 0.000
#> GSM154204 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> GSM154205 2 0.0693 0.878 0.000 0.980 0.012 0.008 0.000
#> GSM154206 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> GSM154207 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> GSM154208 2 0.4341 0.431 0.000 0.592 0.000 0.404 0.004
#> GSM154209 4 0.2476 0.854 0.000 0.064 0.012 0.904 0.020
#> GSM154210 2 0.4260 0.612 0.000 0.680 0.008 0.308 0.004
#> GSM154211 5 0.4896 0.388 0.008 0.248 0.020 0.020 0.704
#> GSM154213 2 0.3561 0.679 0.000 0.740 0.000 0.260 0.000
#> GSM154214 2 0.3452 0.698 0.000 0.756 0.000 0.244 0.000
#> GSM154217 3 0.0880 0.859 0.032 0.000 0.968 0.000 0.000
#> GSM154219 3 0.0880 0.859 0.032 0.000 0.968 0.000 0.000
#> GSM154220 3 0.3534 0.679 0.256 0.000 0.744 0.000 0.000
#> GSM154221 3 0.3143 0.746 0.204 0.000 0.796 0.000 0.000
#> GSM154223 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000
#> GSM154224 1 0.1478 0.897 0.936 0.000 0.064 0.000 0.000
#> GSM154225 1 0.2377 0.846 0.872 0.000 0.128 0.000 0.000
#> GSM154227 1 0.0290 0.915 0.992 0.000 0.008 0.000 0.000
#> GSM154228 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000
#> GSM154229 1 0.0609 0.913 0.980 0.000 0.020 0.000 0.000
#> GSM154231 1 0.0162 0.914 0.996 0.000 0.000 0.000 0.004
#> GSM154232 1 0.0162 0.914 0.996 0.000 0.004 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 2 0.2854 0.841 0.000 0.792 0.000 0.000 0.000 0.208
#> GSM154424 6 0.2544 0.840 0.000 0.004 0.012 0.000 0.120 0.864
#> GSM154425 5 0.0405 0.767 0.000 0.008 0.000 0.004 0.988 0.000
#> GSM154426 2 0.3110 0.835 0.000 0.792 0.000 0.012 0.000 0.196
#> GSM154427 6 0.0000 0.913 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154428 2 0.2854 0.841 0.000 0.792 0.000 0.000 0.000 0.208
#> GSM154429 6 0.0260 0.912 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154430 6 0.0260 0.912 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154434 3 0.3023 0.750 0.212 0.000 0.784 0.000 0.004 0.000
#> GSM154436 5 0.3062 0.862 0.032 0.000 0.144 0.000 0.824 0.000
#> GSM154437 5 0.2597 0.848 0.000 0.000 0.176 0.000 0.824 0.000
#> GSM154438 5 0.3078 0.743 0.192 0.012 0.000 0.000 0.796 0.000
#> GSM154439 5 0.3721 0.841 0.100 0.012 0.084 0.000 0.804 0.000
#> GSM154403 6 0.0000 0.913 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154404 6 0.0000 0.913 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154405 6 0.0000 0.913 0.000 0.000 0.000 0.000 0.000 1.000
#> GSM154406 2 0.3864 0.446 0.000 0.520 0.000 0.000 0.000 0.480
#> GSM154407 6 0.2730 0.817 0.000 0.192 0.000 0.000 0.000 0.808
#> GSM154408 4 0.3371 0.562 0.000 0.292 0.000 0.708 0.000 0.000
#> GSM154409 4 0.0363 0.905 0.000 0.012 0.000 0.988 0.000 0.000
#> GSM154410 4 0.0363 0.905 0.000 0.012 0.000 0.988 0.000 0.000
#> GSM154411 4 0.0405 0.903 0.000 0.004 0.000 0.988 0.008 0.000
#> GSM154412 4 0.0632 0.892 0.000 0.000 0.000 0.976 0.024 0.000
#> GSM154413 1 0.0713 0.866 0.972 0.000 0.028 0.000 0.000 0.000
#> GSM154414 1 0.0865 0.868 0.964 0.000 0.036 0.000 0.000 0.000
#> GSM154415 3 0.3989 0.361 0.468 0.000 0.528 0.000 0.004 0.000
#> GSM154416 1 0.1141 0.863 0.948 0.000 0.052 0.000 0.000 0.000
#> GSM154417 1 0.2969 0.766 0.776 0.000 0.224 0.000 0.000 0.000
#> GSM154418 3 0.2723 0.676 0.004 0.000 0.852 0.128 0.016 0.000
#> GSM154419 3 0.0458 0.780 0.016 0.000 0.984 0.000 0.000 0.000
#> GSM154420 5 0.2730 0.839 0.000 0.000 0.192 0.000 0.808 0.000
#> GSM154421 3 0.0146 0.777 0.004 0.000 0.996 0.000 0.000 0.000
#> GSM154422 1 0.2969 0.766 0.776 0.000 0.224 0.000 0.000 0.000
#> GSM154203 2 0.2854 0.841 0.000 0.792 0.000 0.000 0.000 0.208
#> GSM154204 6 0.0260 0.912 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154205 2 0.3151 0.817 0.000 0.748 0.000 0.000 0.000 0.252
#> GSM154206 6 0.0146 0.913 0.000 0.000 0.000 0.004 0.000 0.996
#> GSM154207 6 0.0260 0.912 0.000 0.000 0.000 0.008 0.000 0.992
#> GSM154208 6 0.2762 0.817 0.000 0.196 0.000 0.000 0.000 0.804
#> GSM154209 2 0.0935 0.699 0.000 0.964 0.000 0.032 0.000 0.004
#> GSM154210 2 0.1387 0.734 0.000 0.932 0.000 0.000 0.000 0.068
#> GSM154211 2 0.2933 0.677 0.000 0.796 0.000 0.004 0.200 0.000
#> GSM154213 6 0.2664 0.823 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM154214 6 0.2664 0.823 0.000 0.184 0.000 0.000 0.000 0.816
#> GSM154217 3 0.0632 0.780 0.024 0.000 0.976 0.000 0.000 0.000
#> GSM154219 3 0.0632 0.780 0.024 0.000 0.976 0.000 0.000 0.000
#> GSM154220 1 0.2793 0.785 0.800 0.000 0.200 0.000 0.000 0.000
#> GSM154221 1 0.2969 0.766 0.776 0.000 0.224 0.000 0.000 0.000
#> GSM154223 1 0.0363 0.873 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM154224 3 0.2996 0.757 0.228 0.000 0.772 0.000 0.000 0.000
#> GSM154225 3 0.2378 0.785 0.152 0.000 0.848 0.000 0.000 0.000
#> GSM154227 3 0.3409 0.707 0.300 0.000 0.700 0.000 0.000 0.000
#> GSM154228 1 0.0260 0.872 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154229 1 0.0458 0.873 0.984 0.000 0.016 0.000 0.000 0.000
#> GSM154231 1 0.0260 0.872 0.992 0.000 0.008 0.000 0.000 0.000
#> GSM154232 1 0.1910 0.783 0.892 0.000 0.108 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> ATC:mclust 56 2.95e-05 5.37e-13 2
#> ATC:mclust 55 9.35e-06 1.14e-12 3
#> ATC:mclust 50 1.07e-06 7.99e-11 4
#> ATC:mclust 49 3.88e-06 2.11e-09 5
#> ATC:mclust 54 2.32e-07 1.01e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
The object with results only for a single top-value method and a single partition method can be extracted as:
res = res_list["ATC", "NMF"]
# you can also extract it by
# res = res_list["ATC:NMF"]
A summary of res
and all the functions that can be applied to it:
res
#> A 'ConsensusPartition' object with k = 2, 3, 4, 5, 6.
#> On a matrix with 21168 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.856 0.935 0.971 0.5071 0.492 0.492
#> 3 3 0.978 0.960 0.980 0.3200 0.747 0.528
#> 4 4 0.777 0.801 0.887 0.0818 0.916 0.760
#> 5 5 0.761 0.662 0.837 0.0663 0.892 0.662
#> 6 6 0.791 0.707 0.847 0.0379 0.932 0.732
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
#> GSM154423 2 0.0000 0.985 0.000 1.000
#> GSM154424 2 0.0000 0.985 0.000 1.000
#> GSM154425 1 0.0000 0.953 1.000 0.000
#> GSM154426 2 0.0000 0.985 0.000 1.000
#> GSM154427 2 0.0000 0.985 0.000 1.000
#> GSM154428 2 0.0000 0.985 0.000 1.000
#> GSM154429 2 0.0000 0.985 0.000 1.000
#> GSM154430 2 0.0000 0.985 0.000 1.000
#> GSM154434 1 0.0000 0.953 1.000 0.000
#> GSM154436 1 0.0000 0.953 1.000 0.000
#> GSM154437 1 0.0000 0.953 1.000 0.000
#> GSM154438 1 0.0000 0.953 1.000 0.000
#> GSM154439 1 0.0000 0.953 1.000 0.000
#> GSM154403 2 0.0000 0.985 0.000 1.000
#> GSM154404 2 0.0000 0.985 0.000 1.000
#> GSM154405 2 0.0000 0.985 0.000 1.000
#> GSM154406 2 0.0000 0.985 0.000 1.000
#> GSM154407 2 0.0000 0.985 0.000 1.000
#> GSM154408 1 0.7815 0.716 0.768 0.232
#> GSM154409 1 0.0000 0.953 1.000 0.000
#> GSM154410 1 0.0000 0.953 1.000 0.000
#> GSM154411 1 0.0000 0.953 1.000 0.000
#> GSM154412 1 0.0000 0.953 1.000 0.000
#> GSM154413 2 0.5842 0.834 0.140 0.860
#> GSM154414 2 0.6048 0.822 0.148 0.852
#> GSM154415 1 0.0000 0.953 1.000 0.000
#> GSM154416 1 0.0000 0.953 1.000 0.000
#> GSM154417 2 0.0000 0.985 0.000 1.000
#> GSM154418 1 0.0000 0.953 1.000 0.000
#> GSM154419 1 0.0000 0.953 1.000 0.000
#> GSM154420 1 0.0000 0.953 1.000 0.000
#> GSM154421 1 0.0000 0.953 1.000 0.000
#> GSM154422 2 0.3431 0.924 0.064 0.936
#> GSM154203 2 0.0000 0.985 0.000 1.000
#> GSM154204 2 0.0000 0.985 0.000 1.000
#> GSM154205 2 0.0000 0.985 0.000 1.000
#> GSM154206 2 0.0000 0.985 0.000 1.000
#> GSM154207 2 0.0000 0.985 0.000 1.000
#> GSM154208 2 0.0000 0.985 0.000 1.000
#> GSM154209 2 0.0000 0.985 0.000 1.000
#> GSM154210 2 0.0000 0.985 0.000 1.000
#> GSM154211 1 0.7602 0.733 0.780 0.220
#> GSM154213 2 0.0000 0.985 0.000 1.000
#> GSM154214 2 0.0000 0.985 0.000 1.000
#> GSM154217 1 0.0000 0.953 1.000 0.000
#> GSM154219 1 0.0000 0.953 1.000 0.000
#> GSM154220 1 0.0672 0.947 0.992 0.008
#> GSM154221 2 0.0000 0.985 0.000 1.000
#> GSM154223 1 0.9775 0.336 0.588 0.412
#> GSM154224 1 0.0000 0.953 1.000 0.000
#> GSM154225 1 0.0000 0.953 1.000 0.000
#> GSM154227 1 0.0000 0.953 1.000 0.000
#> GSM154228 1 0.5294 0.850 0.880 0.120
#> GSM154229 1 0.0000 0.953 1.000 0.000
#> GSM154231 1 0.8713 0.615 0.708 0.292
#> GSM154232 1 0.0000 0.953 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM154423 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154424 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154425 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154426 2 0.1163 0.974 0.000 0.972 0.028
#> GSM154427 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154428 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154429 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154430 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154434 3 0.4121 0.802 0.168 0.000 0.832
#> GSM154436 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154437 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154438 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154439 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154403 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154404 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154405 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154406 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154407 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154408 3 0.1163 0.942 0.000 0.028 0.972
#> GSM154409 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154410 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154411 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154412 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154413 1 0.5435 0.744 0.784 0.192 0.024
#> GSM154414 1 0.0747 0.957 0.984 0.016 0.000
#> GSM154415 3 0.5058 0.686 0.244 0.000 0.756
#> GSM154416 1 0.2066 0.917 0.940 0.000 0.060
#> GSM154417 1 0.0237 0.966 0.996 0.004 0.000
#> GSM154418 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154419 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154420 3 0.0237 0.966 0.004 0.000 0.996
#> GSM154421 1 0.4974 0.682 0.764 0.000 0.236
#> GSM154422 1 0.0237 0.966 0.996 0.004 0.000
#> GSM154203 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154204 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154205 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154206 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154207 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154208 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154209 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154210 2 0.0237 0.996 0.000 0.996 0.004
#> GSM154211 3 0.0592 0.955 0.000 0.012 0.988
#> GSM154213 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154214 2 0.0000 0.998 0.000 1.000 0.000
#> GSM154217 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154219 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154220 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154221 1 0.0237 0.966 0.996 0.004 0.000
#> GSM154223 1 0.0237 0.966 0.996 0.004 0.000
#> GSM154224 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154225 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154227 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154228 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154229 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154231 1 0.0000 0.968 1.000 0.000 0.000
#> GSM154232 1 0.0000 0.968 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM154423 4 0.4855 0.4188 0.000 0.352 0.004 0.644
#> GSM154424 2 0.0817 0.9527 0.000 0.976 0.000 0.024
#> GSM154425 4 0.4406 0.5360 0.000 0.000 0.300 0.700
#> GSM154426 4 0.5724 0.6565 0.000 0.144 0.140 0.716
#> GSM154427 2 0.0000 0.9601 0.000 1.000 0.000 0.000
#> GSM154428 2 0.4843 0.2377 0.000 0.604 0.000 0.396
#> GSM154429 2 0.0188 0.9599 0.000 0.996 0.000 0.004
#> GSM154430 2 0.0188 0.9599 0.000 0.996 0.000 0.004
#> GSM154434 3 0.4820 0.5932 0.168 0.000 0.772 0.060
#> GSM154436 3 0.2469 0.7687 0.000 0.000 0.892 0.108
#> GSM154437 3 0.1637 0.7844 0.000 0.000 0.940 0.060
#> GSM154438 3 0.1716 0.7844 0.000 0.000 0.936 0.064
#> GSM154439 3 0.0921 0.7857 0.000 0.000 0.972 0.028
#> GSM154403 2 0.0188 0.9591 0.000 0.996 0.000 0.004
#> GSM154404 2 0.0188 0.9591 0.000 0.996 0.000 0.004
#> GSM154405 2 0.0188 0.9591 0.000 0.996 0.000 0.004
#> GSM154406 2 0.0817 0.9519 0.000 0.976 0.000 0.024
#> GSM154407 2 0.0188 0.9583 0.004 0.996 0.000 0.000
#> GSM154408 3 0.6042 0.4380 0.000 0.224 0.672 0.104
#> GSM154409 3 0.3311 0.7509 0.000 0.000 0.828 0.172
#> GSM154410 3 0.3808 0.7513 0.000 0.012 0.812 0.176
#> GSM154411 3 0.3024 0.7635 0.000 0.000 0.852 0.148
#> GSM154412 3 0.3400 0.7445 0.000 0.000 0.820 0.180
#> GSM154413 1 0.5954 0.6999 0.724 0.028 0.068 0.180
#> GSM154414 1 0.4351 0.8117 0.844 0.044 0.060 0.052
#> GSM154415 1 0.7766 0.0487 0.412 0.000 0.244 0.344
#> GSM154416 1 0.3421 0.8276 0.868 0.000 0.088 0.044
#> GSM154417 1 0.0817 0.8795 0.976 0.000 0.000 0.024
#> GSM154418 3 0.2589 0.7825 0.000 0.000 0.884 0.116
#> GSM154419 1 0.5432 0.7524 0.740 0.000 0.124 0.136
#> GSM154420 3 0.2921 0.7249 0.000 0.000 0.860 0.140
#> GSM154421 3 0.6118 0.5565 0.120 0.000 0.672 0.208
#> GSM154422 1 0.3278 0.8367 0.864 0.000 0.020 0.116
#> GSM154203 2 0.1389 0.9312 0.000 0.952 0.000 0.048
#> GSM154204 2 0.0188 0.9599 0.000 0.996 0.000 0.004
#> GSM154205 2 0.0817 0.9509 0.000 0.976 0.000 0.024
#> GSM154206 2 0.0000 0.9601 0.000 1.000 0.000 0.000
#> GSM154207 2 0.0592 0.9553 0.000 0.984 0.000 0.016
#> GSM154208 2 0.0000 0.9601 0.000 1.000 0.000 0.000
#> GSM154209 2 0.2654 0.8484 0.000 0.888 0.004 0.108
#> GSM154210 2 0.0188 0.9599 0.000 0.996 0.000 0.004
#> GSM154211 4 0.4252 0.6054 0.000 0.004 0.252 0.744
#> GSM154213 2 0.0000 0.9601 0.000 1.000 0.000 0.000
#> GSM154214 2 0.0000 0.9601 0.000 1.000 0.000 0.000
#> GSM154217 1 0.5836 0.6962 0.700 0.000 0.112 0.188
#> GSM154219 1 0.4685 0.7770 0.784 0.000 0.060 0.156
#> GSM154220 1 0.0188 0.8823 0.996 0.000 0.000 0.004
#> GSM154221 1 0.0188 0.8823 0.996 0.000 0.000 0.004
#> GSM154223 1 0.0000 0.8823 1.000 0.000 0.000 0.000
#> GSM154224 1 0.0469 0.8817 0.988 0.000 0.000 0.012
#> GSM154225 1 0.2271 0.8610 0.916 0.000 0.008 0.076
#> GSM154227 1 0.0000 0.8823 1.000 0.000 0.000 0.000
#> GSM154228 1 0.0336 0.8814 0.992 0.000 0.000 0.008
#> GSM154229 1 0.1545 0.8728 0.952 0.000 0.008 0.040
#> GSM154231 1 0.1118 0.8756 0.964 0.000 0.000 0.036
#> GSM154232 1 0.0000 0.8823 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM154423 4 0.1894 0.6325 0.000 0.072 0.008 0.920 0.000
#> GSM154424 2 0.0451 0.9606 0.000 0.988 0.008 0.004 0.000
#> GSM154425 4 0.3995 0.4873 0.000 0.000 0.044 0.776 0.180
#> GSM154426 4 0.1281 0.6347 0.000 0.032 0.012 0.956 0.000
#> GSM154427 2 0.0290 0.9601 0.000 0.992 0.008 0.000 0.000
#> GSM154428 4 0.3912 0.5293 0.000 0.228 0.020 0.752 0.000
#> GSM154429 2 0.0162 0.9602 0.000 0.996 0.000 0.004 0.000
#> GSM154430 2 0.0000 0.9610 0.000 1.000 0.000 0.000 0.000
#> GSM154434 5 0.3154 0.5725 0.104 0.000 0.012 0.024 0.860
#> GSM154436 5 0.1764 0.6214 0.000 0.000 0.008 0.064 0.928
#> GSM154437 5 0.1626 0.6289 0.000 0.000 0.016 0.044 0.940
#> GSM154438 5 0.1549 0.6380 0.000 0.000 0.016 0.040 0.944
#> GSM154439 5 0.1211 0.6333 0.000 0.000 0.024 0.016 0.960
#> GSM154403 2 0.1282 0.9338 0.000 0.952 0.044 0.000 0.004
#> GSM154404 2 0.1043 0.9404 0.000 0.960 0.040 0.000 0.000
#> GSM154405 2 0.0290 0.9601 0.000 0.992 0.008 0.000 0.000
#> GSM154406 2 0.3449 0.8311 0.000 0.844 0.088 0.064 0.004
#> GSM154407 2 0.0162 0.9610 0.000 0.996 0.004 0.000 0.000
#> GSM154408 4 0.5962 0.5457 0.000 0.080 0.080 0.680 0.160
#> GSM154409 4 0.4850 0.4633 0.000 0.000 0.072 0.696 0.232
#> GSM154410 3 0.6729 0.0175 0.000 0.000 0.408 0.328 0.264
#> GSM154411 4 0.6024 0.2048 0.000 0.000 0.148 0.556 0.296
#> GSM154412 4 0.4493 0.5579 0.000 0.000 0.108 0.756 0.136
#> GSM154413 1 0.7713 0.1076 0.428 0.016 0.264 0.032 0.260
#> GSM154414 1 0.7765 0.0328 0.396 0.064 0.264 0.000 0.276
#> GSM154415 5 0.6425 0.3476 0.088 0.000 0.272 0.052 0.588
#> GSM154416 5 0.6703 0.0351 0.360 0.000 0.244 0.000 0.396
#> GSM154417 1 0.2563 0.7792 0.872 0.000 0.120 0.000 0.008
#> GSM154418 5 0.4862 0.1944 0.004 0.000 0.220 0.068 0.708
#> GSM154419 1 0.5832 0.5332 0.600 0.000 0.248 0.000 0.152
#> GSM154420 5 0.2127 0.5472 0.000 0.000 0.108 0.000 0.892
#> GSM154421 3 0.5735 0.0287 0.072 0.000 0.492 0.004 0.432
#> GSM154422 1 0.3741 0.6966 0.732 0.000 0.264 0.000 0.004
#> GSM154203 2 0.3635 0.6273 0.000 0.748 0.004 0.248 0.000
#> GSM154204 2 0.0162 0.9602 0.000 0.996 0.000 0.004 0.000
#> GSM154205 2 0.1341 0.9203 0.000 0.944 0.000 0.056 0.000
#> GSM154206 2 0.0290 0.9601 0.000 0.992 0.008 0.000 0.000
#> GSM154207 2 0.0510 0.9541 0.000 0.984 0.000 0.016 0.000
#> GSM154208 2 0.0000 0.9610 0.000 1.000 0.000 0.000 0.000
#> GSM154209 4 0.4793 0.4910 0.000 0.260 0.056 0.684 0.000
#> GSM154210 2 0.0290 0.9587 0.000 0.992 0.000 0.008 0.000
#> GSM154211 4 0.3184 0.5724 0.000 0.000 0.048 0.852 0.100
#> GSM154213 2 0.0000 0.9610 0.000 1.000 0.000 0.000 0.000
#> GSM154214 2 0.0162 0.9610 0.000 0.996 0.004 0.000 0.000
#> GSM154217 1 0.5858 0.2040 0.456 0.000 0.448 0.000 0.096
#> GSM154219 1 0.4269 0.6599 0.732 0.000 0.232 0.000 0.036
#> GSM154220 1 0.0880 0.8001 0.968 0.000 0.032 0.000 0.000
#> GSM154221 1 0.1124 0.8011 0.960 0.004 0.036 0.000 0.000
#> GSM154223 1 0.0510 0.8021 0.984 0.000 0.016 0.000 0.000
#> GSM154224 1 0.1753 0.7943 0.936 0.000 0.032 0.000 0.032
#> GSM154225 1 0.2378 0.7820 0.904 0.000 0.048 0.000 0.048
#> GSM154227 1 0.0162 0.8025 0.996 0.000 0.004 0.000 0.000
#> GSM154228 1 0.0963 0.7983 0.964 0.000 0.036 0.000 0.000
#> GSM154229 1 0.1502 0.7926 0.940 0.000 0.056 0.000 0.004
#> GSM154231 1 0.1410 0.7915 0.940 0.000 0.060 0.000 0.000
#> GSM154232 1 0.0404 0.8024 0.988 0.000 0.012 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM154423 4 0.1950 0.62596 0.000 0.044 0.008 0.924 0.004 0.020
#> GSM154424 2 0.0146 0.97066 0.000 0.996 0.000 0.004 0.000 0.000
#> GSM154425 4 0.4766 0.51293 0.000 0.000 0.044 0.732 0.128 0.096
#> GSM154426 4 0.2596 0.62490 0.000 0.016 0.032 0.896 0.012 0.044
#> GSM154427 2 0.0000 0.97062 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154428 4 0.3694 0.53474 0.000 0.124 0.056 0.804 0.000 0.016
#> GSM154429 2 0.0291 0.97033 0.000 0.992 0.004 0.004 0.000 0.000
#> GSM154430 2 0.0291 0.97033 0.000 0.992 0.004 0.004 0.000 0.000
#> GSM154434 5 0.2565 0.80644 0.072 0.000 0.004 0.012 0.888 0.024
#> GSM154436 5 0.1851 0.84540 0.000 0.000 0.012 0.036 0.928 0.024
#> GSM154437 5 0.1624 0.85161 0.000 0.000 0.004 0.020 0.936 0.040
#> GSM154438 5 0.0405 0.85499 0.000 0.000 0.008 0.000 0.988 0.004
#> GSM154439 5 0.0622 0.85537 0.000 0.000 0.008 0.000 0.980 0.012
#> GSM154403 2 0.1714 0.89843 0.000 0.908 0.092 0.000 0.000 0.000
#> GSM154404 2 0.1556 0.91177 0.000 0.920 0.080 0.000 0.000 0.000
#> GSM154405 2 0.0547 0.96148 0.000 0.980 0.020 0.000 0.000 0.000
#> GSM154406 3 0.4913 0.18965 0.000 0.408 0.540 0.040 0.000 0.012
#> GSM154407 2 0.0458 0.96364 0.000 0.984 0.016 0.000 0.000 0.000
#> GSM154408 4 0.4527 0.51304 0.000 0.016 0.024 0.728 0.028 0.204
#> GSM154409 4 0.5033 0.44743 0.000 0.000 0.032 0.672 0.072 0.224
#> GSM154410 6 0.4354 0.00000 0.000 0.000 0.008 0.236 0.052 0.704
#> GSM154411 4 0.5687 0.00223 0.000 0.000 0.016 0.520 0.112 0.352
#> GSM154412 4 0.4214 0.56912 0.000 0.000 0.052 0.776 0.048 0.124
#> GSM154413 3 0.4730 0.64167 0.168 0.020 0.736 0.004 0.060 0.012
#> GSM154414 3 0.3925 0.63859 0.220 0.004 0.744 0.000 0.024 0.008
#> GSM154415 3 0.4915 0.20089 0.016 0.000 0.540 0.008 0.416 0.020
#> GSM154416 3 0.4348 0.63207 0.152 0.000 0.724 0.000 0.124 0.000
#> GSM154417 1 0.4221 0.18645 0.588 0.008 0.396 0.000 0.000 0.008
#> GSM154418 5 0.6055 0.37920 0.000 0.000 0.140 0.040 0.552 0.268
#> GSM154419 3 0.4617 0.57151 0.304 0.000 0.644 0.000 0.040 0.012
#> GSM154420 5 0.2520 0.81811 0.000 0.000 0.012 0.008 0.872 0.108
#> GSM154421 3 0.6561 0.03947 0.040 0.000 0.416 0.000 0.188 0.356
#> GSM154422 3 0.4272 0.52840 0.288 0.000 0.668 0.000 0.000 0.044
#> GSM154203 2 0.2692 0.80945 0.000 0.840 0.012 0.148 0.000 0.000
#> GSM154204 2 0.0291 0.97033 0.000 0.992 0.004 0.004 0.000 0.000
#> GSM154205 2 0.0777 0.95800 0.000 0.972 0.004 0.024 0.000 0.000
#> GSM154206 2 0.0000 0.97062 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154207 2 0.0405 0.96855 0.000 0.988 0.004 0.008 0.000 0.000
#> GSM154208 2 0.0000 0.97062 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154209 4 0.4395 0.50599 0.000 0.140 0.004 0.740 0.004 0.112
#> GSM154210 2 0.0291 0.97033 0.000 0.992 0.004 0.004 0.000 0.000
#> GSM154211 4 0.4838 0.50927 0.000 0.008 0.080 0.748 0.092 0.072
#> GSM154213 2 0.0000 0.97062 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM154214 2 0.0146 0.96930 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM154217 1 0.6107 0.22144 0.468 0.000 0.076 0.000 0.064 0.392
#> GSM154219 1 0.3065 0.78265 0.848 0.000 0.048 0.000 0.008 0.096
#> GSM154220 1 0.0717 0.86130 0.976 0.000 0.016 0.000 0.000 0.008
#> GSM154221 1 0.0777 0.86090 0.972 0.000 0.024 0.000 0.000 0.004
#> GSM154223 1 0.0713 0.86171 0.972 0.000 0.028 0.000 0.000 0.000
#> GSM154224 1 0.0862 0.85870 0.972 0.000 0.004 0.000 0.016 0.008
#> GSM154225 1 0.1605 0.84484 0.940 0.000 0.012 0.000 0.032 0.016
#> GSM154227 1 0.0748 0.86326 0.976 0.000 0.016 0.004 0.000 0.004
#> GSM154228 1 0.1036 0.85852 0.964 0.000 0.024 0.004 0.000 0.008
#> GSM154229 1 0.2070 0.81262 0.892 0.000 0.100 0.000 0.000 0.008
#> GSM154231 1 0.1606 0.84307 0.932 0.000 0.056 0.004 0.000 0.008
#> GSM154232 1 0.0653 0.86335 0.980 0.000 0.012 0.004 0.000 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n disease.state(p) cell.type(p) k
#> ATC:NMF 55 1.82e-03 8.70e-05 2
#> ATC:NMF 56 4.41e-08 1.22e-09 3
#> ATC:NMF 52 8.20e-08 5.56e-09 4
#> ATC:NMF 44 4.65e-07 1.51e-09 5
#> ATC:NMF 47 5.50e-11 1.52e-09 6
If matrix rows can be associated to genes, consider to use functional_enrichment(res,
...)
to perform function enrichment for the signature genes. See this vignette for more detailed explanations.
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