Date: 2019-12-25 21:59:11 CET, cola version: 1.3.2
Document is loading...
All available functions which can be applied to this res_list
object:
res_list
#> A 'ConsensusPartitionList' object with 24 methods.
#> On a matrix with 46323 rows and 60 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] 46323 60
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_list),
col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:hclust | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:hclust | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:hclust | 6 | 1.000 | 0.998 | 0.999 | ** | 2,5 |
ATC:pam | 6 | 0.999 | 0.964 | 0.985 | ** | 3,5 |
ATC:mclust | 6 | 0.977 | 0.931 | 0.953 | ** | 2,4,5 |
CV:pam | 6 | 0.971 | 0.932 | 0.969 | ** | 3,4 |
MAD:pam | 6 | 0.967 | 0.923 | 0.966 | ** | 2,3,4,5 |
SD:pam | 6 | 0.943 | 0.952 | 0.977 | * | 3,4 |
MAD:mclust | 5 | 0.919 | 0.950 | 0.948 | * | 4 |
MAD:skmeans | 6 | 0.914 | 0.855 | 0.897 | * | 2 |
ATC:kmeans | 3 | 0.911 | 0.907 | 0.956 | * | |
SD:skmeans | 3 | 0.911 | 0.906 | 0.963 | * | 2 |
ATC:NMF | 5 | 0.910 | 0.870 | 0.921 | * | 2,4 |
CV:skmeans | 3 | 0.910 | 0.871 | 0.950 | * | 2 |
ATC:hclust | 5 | 0.910 | 0.927 | 0.956 | * | |
MAD:NMF | 4 | 0.906 | 0.917 | 0.949 | * | 2,3 |
ATC:skmeans | 6 | 0.903 | 0.824 | 0.849 | * | 2,3,4,5 |
SD:NMF | 3 | 0.861 | 0.920 | 0.967 | ||
CV:NMF | 3 | 0.856 | 0.894 | 0.959 | ||
CV:mclust | 3 | 0.769 | 0.858 | 0.915 | ||
SD:kmeans | 4 | 0.738 | 0.796 | 0.874 | ||
SD:mclust | 3 | 0.732 | 0.909 | 0.945 | ||
MAD:kmeans | 3 | 0.607 | 0.768 | 0.877 | ||
CV:kmeans | 2 | 0.286 | 0.875 | 0.882 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 0.635 0.8611 0.936 0.358 0.636 0.636
#> CV:NMF 2 0.633 0.8560 0.937 0.364 0.636 0.636
#> MAD:NMF 2 1.000 0.9692 0.989 0.508 0.492 0.492
#> ATC:NMF 2 0.930 0.9293 0.971 0.449 0.548 0.548
#> SD:skmeans 2 1.000 0.9841 0.994 0.509 0.492 0.492
#> CV:skmeans 2 1.000 0.9920 0.996 0.509 0.492 0.492
#> MAD:skmeans 2 1.000 0.9822 0.993 0.509 0.492 0.492
#> ATC:skmeans 2 1.000 0.9818 0.993 0.509 0.492 0.492
#> SD:mclust 2 0.350 0.8234 0.855 0.457 0.492 0.492
#> CV:mclust 2 0.429 0.3070 0.605 0.457 0.655 0.655
#> MAD:mclust 2 0.655 0.9593 0.969 0.495 0.492 0.492
#> ATC:mclust 2 1.000 1.0000 1.000 0.509 0.492 0.492
#> SD:kmeans 2 0.451 0.8338 0.848 0.429 0.492 0.492
#> CV:kmeans 2 0.286 0.8754 0.882 0.451 0.492 0.492
#> MAD:kmeans 2 0.538 0.0459 0.582 0.466 0.741 0.741
#> ATC:kmeans 2 0.491 0.8889 0.917 0.459 0.492 0.492
#> SD:pam 2 0.497 0.8807 0.852 0.409 0.497 0.497
#> CV:pam 2 0.464 0.7016 0.807 0.321 0.817 0.817
#> MAD:pam 2 1.000 0.9726 0.987 0.489 0.506 0.506
#> ATC:pam 2 0.493 0.7245 0.832 0.317 0.817 0.817
#> SD:hclust 2 1.000 1.0000 1.000 0.184 0.817 0.817
#> CV:hclust 2 1.000 1.0000 1.000 0.184 0.817 0.817
#> MAD:hclust 2 1.000 1.0000 1.000 0.184 0.817 0.817
#> ATC:hclust 2 0.512 0.9348 0.949 0.225 0.817 0.817
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.861 0.920 0.967 0.697 0.627 0.464
#> CV:NMF 3 0.856 0.894 0.959 0.672 0.627 0.464
#> MAD:NMF 3 0.977 0.949 0.977 0.293 0.666 0.424
#> ATC:NMF 3 0.866 0.925 0.968 0.372 0.593 0.390
#> SD:skmeans 3 0.911 0.906 0.963 0.329 0.719 0.487
#> CV:skmeans 3 0.910 0.871 0.950 0.329 0.695 0.456
#> MAD:skmeans 3 0.857 0.947 0.973 0.328 0.720 0.490
#> ATC:skmeans 3 1.000 0.941 0.964 0.258 0.841 0.686
#> SD:mclust 3 0.732 0.909 0.945 0.253 0.618 0.427
#> CV:mclust 3 0.769 0.858 0.915 0.285 0.454 0.343
#> MAD:mclust 3 0.698 0.888 0.911 0.266 0.750 0.533
#> ATC:mclust 3 0.658 0.934 0.917 0.241 0.750 0.533
#> SD:kmeans 3 0.814 0.905 0.944 0.273 0.631 0.442
#> CV:kmeans 3 0.794 0.897 0.945 0.241 0.618 0.427
#> MAD:kmeans 3 0.607 0.768 0.877 0.348 0.531 0.396
#> ATC:kmeans 3 0.911 0.907 0.956 0.231 0.637 0.440
#> SD:pam 3 1.000 0.978 0.992 0.379 0.701 0.516
#> CV:pam 3 1.000 0.987 0.994 0.753 0.624 0.540
#> MAD:pam 3 1.000 0.996 0.998 0.372 0.749 0.538
#> ATC:pam 3 1.000 0.960 0.986 0.777 0.616 0.530
#> SD:hclust 3 0.723 0.807 0.923 2.048 0.645 0.565
#> CV:hclust 3 0.766 0.828 0.929 2.004 0.645 0.565
#> MAD:hclust 3 0.771 0.931 0.964 2.162 0.589 0.497
#> ATC:hclust 3 0.697 0.920 0.960 1.599 0.588 0.496
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.716 0.816 0.877 0.1931 0.810 0.551
#> CV:NMF 4 0.710 0.815 0.873 0.1930 0.801 0.534
#> MAD:NMF 4 0.906 0.917 0.949 0.1267 0.855 0.606
#> ATC:NMF 4 0.960 0.921 0.965 0.1734 0.841 0.612
#> SD:skmeans 4 0.780 0.674 0.850 0.1175 0.845 0.569
#> CV:skmeans 4 0.751 0.699 0.813 0.1165 0.862 0.610
#> MAD:skmeans 4 0.797 0.691 0.844 0.1172 0.871 0.630
#> ATC:skmeans 4 0.948 0.924 0.969 0.1517 0.892 0.703
#> SD:mclust 4 0.779 0.887 0.919 0.2318 0.824 0.618
#> CV:mclust 4 0.782 0.850 0.908 0.1967 0.824 0.618
#> MAD:mclust 4 1.000 0.985 0.992 0.1429 0.956 0.866
#> ATC:mclust 4 1.000 1.000 1.000 0.1318 0.956 0.866
#> SD:kmeans 4 0.738 0.796 0.874 0.2931 0.814 0.596
#> CV:kmeans 4 0.698 0.785 0.859 0.2462 0.814 0.596
#> MAD:kmeans 4 0.669 0.602 0.774 0.1331 0.861 0.631
#> ATC:kmeans 4 0.722 0.834 0.896 0.2581 0.834 0.630
#> SD:pam 4 0.978 0.961 0.980 0.2968 0.827 0.608
#> CV:pam 4 1.000 0.966 0.987 0.3021 0.827 0.608
#> MAD:pam 4 0.970 0.949 0.970 0.0855 0.939 0.815
#> ATC:pam 4 0.793 0.870 0.913 0.2729 0.840 0.636
#> SD:hclust 4 0.711 0.867 0.891 0.2100 0.858 0.692
#> CV:hclust 4 0.735 0.835 0.844 0.1953 0.858 0.692
#> MAD:hclust 4 0.895 0.954 0.975 0.1894 0.914 0.787
#> ATC:hclust 4 0.780 0.833 0.914 0.1898 0.853 0.649
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.788 0.714 0.856 0.0558 0.964 0.871
#> CV:NMF 5 0.711 0.669 0.830 0.0590 0.953 0.834
#> MAD:NMF 5 0.857 0.794 0.892 0.0451 0.958 0.841
#> ATC:NMF 5 0.910 0.870 0.921 0.0301 0.973 0.908
#> SD:skmeans 5 0.844 0.856 0.906 0.0535 0.905 0.644
#> CV:skmeans 5 0.827 0.840 0.898 0.0528 0.876 0.561
#> MAD:skmeans 5 0.868 0.844 0.886 0.0554 0.937 0.752
#> ATC:skmeans 5 0.920 0.910 0.947 0.0738 0.907 0.668
#> SD:mclust 5 0.823 0.849 0.888 0.0953 0.939 0.786
#> CV:mclust 5 0.823 0.693 0.816 0.0976 0.895 0.656
#> MAD:mclust 5 0.919 0.950 0.948 0.0840 0.939 0.786
#> ATC:mclust 5 0.987 0.957 0.980 0.0933 0.939 0.786
#> SD:kmeans 5 0.713 0.683 0.791 0.0840 1.000 1.000
#> CV:kmeans 5 0.700 0.704 0.799 0.0960 1.000 1.000
#> MAD:kmeans 5 0.666 0.534 0.723 0.0773 0.904 0.694
#> ATC:kmeans 5 0.807 0.826 0.835 0.0879 0.899 0.665
#> SD:pam 5 0.847 0.820 0.907 0.0684 0.956 0.838
#> CV:pam 5 0.862 0.575 0.797 0.0666 0.915 0.701
#> MAD:pam 5 0.925 0.834 0.941 0.0766 0.900 0.654
#> ATC:pam 5 0.974 0.932 0.972 0.0996 0.875 0.596
#> SD:hclust 5 0.777 0.866 0.901 0.1291 0.925 0.766
#> CV:hclust 5 0.777 0.825 0.879 0.1546 0.917 0.740
#> MAD:hclust 5 0.917 0.924 0.950 0.1223 0.890 0.655
#> ATC:hclust 5 0.910 0.927 0.956 0.1207 0.893 0.648
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.692 0.636 0.752 0.0472 0.959 0.834
#> CV:NMF 6 0.696 0.593 0.744 0.0441 0.931 0.745
#> MAD:NMF 6 0.741 0.677 0.804 0.0356 0.987 0.945
#> ATC:NMF 6 0.815 0.805 0.860 0.0450 0.980 0.927
#> SD:skmeans 6 0.856 0.783 0.843 0.0334 0.968 0.841
#> CV:skmeans 6 0.835 0.768 0.829 0.0341 0.968 0.841
#> MAD:skmeans 6 0.914 0.855 0.897 0.0328 0.962 0.817
#> ATC:skmeans 6 0.903 0.824 0.849 0.0268 0.975 0.885
#> SD:mclust 6 0.841 0.857 0.875 0.0538 0.959 0.819
#> CV:mclust 6 0.788 0.789 0.860 0.0554 0.912 0.638
#> MAD:mclust 6 0.878 0.933 0.891 0.0514 0.959 0.819
#> ATC:mclust 6 0.977 0.931 0.953 0.0251 0.975 0.887
#> SD:kmeans 6 0.711 0.637 0.709 0.0539 0.892 0.623
#> CV:kmeans 6 0.709 0.651 0.735 0.0537 0.932 0.754
#> MAD:kmeans 6 0.747 0.711 0.733 0.0485 0.873 0.574
#> ATC:kmeans 6 0.838 0.645 0.802 0.0527 0.960 0.818
#> SD:pam 6 0.943 0.952 0.977 0.0429 0.939 0.740
#> CV:pam 6 0.971 0.932 0.969 0.0411 0.936 0.724
#> MAD:pam 6 0.967 0.923 0.966 0.0390 0.951 0.776
#> ATC:pam 6 0.999 0.964 0.985 0.0397 0.952 0.780
#> SD:hclust 6 0.835 0.909 0.895 0.0531 0.941 0.758
#> CV:hclust 6 0.803 0.834 0.836 0.0529 0.915 0.661
#> MAD:hclust 6 1.000 0.998 0.999 0.0499 0.976 0.886
#> ATC:hclust 6 0.892 0.817 0.878 0.0434 0.985 0.928
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 agent(p) individual(p) k
#> SD:NMF 56 0.8831 6.05e-05 2
#> CV:NMF 55 0.9402 8.40e-05 2
#> MAD:NMF 59 0.6944 3.71e-05 2
#> ATC:NMF 58 0.5758 7.98e-06 2
#> SD:skmeans 59 0.6944 3.71e-05 2
#> CV:skmeans 60 0.7963 2.61e-05 2
#> MAD:skmeans 59 0.6944 3.71e-05 2
#> ATC:skmeans 59 0.8981 3.71e-05 2
#> SD:mclust 60 1.0000 3.87e-06 2
#> CV:mclust 13 NA NA 2
#> MAD:mclust 60 1.0000 3.87e-06 2
#> ATC:mclust 60 1.0000 3.87e-06 2
#> SD:kmeans 59 0.6944 3.71e-05 2
#> CV:kmeans 60 0.7963 2.61e-05 2
#> MAD:kmeans 9 NA NA 2
#> ATC:kmeans 55 1.0000 4.73e-05 2
#> SD:pam 59 1.0000 9.51e-05 2
#> CV:pam 60 0.0314 3.87e-06 2
#> MAD:pam 60 0.6005 7.16e-05 2
#> ATC:pam 60 0.0314 3.87e-06 2
#> SD:hclust 60 0.0314 3.87e-06 2
#> CV:hclust 60 0.0314 3.87e-06 2
#> MAD:hclust 60 0.0314 3.87e-06 2
#> ATC:hclust 60 0.0314 3.87e-06 2
test_to_known_factors(res_list, k = 3)
#> n agent(p) individual(p) k
#> SD:NMF 59 0.08997 3.54e-08 3
#> CV:NMF 57 0.07741 1.31e-07 3
#> MAD:NMF 58 0.08450 4.69e-08 3
#> ATC:NMF 60 0.06622 5.50e-09 3
#> SD:skmeans 57 0.79555 2.54e-08 3
#> CV:skmeans 53 0.36159 4.19e-08 3
#> MAD:skmeans 59 0.79731 2.67e-08 3
#> ATC:skmeans 59 0.76349 3.52e-07 3
#> SD:mclust 60 0.01279 7.01e-09 3
#> CV:mclust 60 0.01279 7.01e-09 3
#> MAD:mclust 60 0.28606 1.98e-08 3
#> ATC:mclust 60 0.28606 1.98e-08 3
#> SD:kmeans 60 0.01279 7.01e-09 3
#> CV:kmeans 60 0.01279 7.01e-09 3
#> MAD:kmeans 57 0.35990 3.43e-08 3
#> ATC:kmeans 55 0.01363 1.47e-07 3
#> SD:pam 59 0.01544 8.51e-09 3
#> CV:pam 60 0.01235 5.80e-09 3
#> MAD:pam 60 0.34803 1.25e-08 3
#> ATC:pam 59 0.00909 3.30e-08 3
#> SD:hclust 51 0.02165 9.11e-08 3
#> CV:hclust 49 0.02554 1.30e-07 3
#> MAD:hclust 60 0.02618 4.35e-09 3
#> ATC:hclust 60 0.03076 1.18e-08 3
test_to_known_factors(res_list, k = 4)
#> n agent(p) individual(p) k
#> SD:NMF 55 0.06355 2.15e-10 4
#> CV:NMF 57 0.03440 2.61e-11 4
#> MAD:NMF 60 0.41174 1.21e-11 4
#> ATC:NMF 58 0.04835 5.85e-11 4
#> SD:skmeans 48 0.07145 3.22e-10 4
#> CV:skmeans 48 0.07145 3.22e-10 4
#> MAD:skmeans 54 0.11157 2.97e-11 4
#> ATC:skmeans 58 0.56279 1.73e-10 4
#> SD:mclust 60 0.03323 2.98e-12 4
#> CV:mclust 60 0.03323 2.98e-12 4
#> MAD:mclust 60 0.03323 2.98e-12 4
#> ATC:mclust 60 0.03323 2.98e-12 4
#> SD:kmeans 54 0.02465 8.09e-11 4
#> CV:kmeans 51 0.00871 3.38e-10 4
#> MAD:kmeans 45 0.04484 1.00e-09 4
#> ATC:kmeans 53 0.01575 1.59e-11 4
#> SD:pam 60 0.03159 1.02e-12 4
#> CV:pam 59 0.03742 1.97e-12 4
#> MAD:pam 60 0.03159 1.02e-12 4
#> ATC:pam 59 0.03399 5.06e-11 4
#> SD:hclust 60 0.03185 5.63e-13 4
#> CV:hclust 59 0.02521 4.28e-13 4
#> MAD:hclust 60 0.03185 5.63e-13 4
#> ATC:hclust 55 0.06400 6.68e-12 4
test_to_known_factors(res_list, k = 5)
#> n agent(p) individual(p) k
#> SD:NMF 51 0.1233 6.44e-12 5
#> CV:NMF 47 0.1239 1.48e-09 5
#> MAD:NMF 57 0.6637 6.15e-14 5
#> ATC:NMF 57 0.0588 5.68e-11 5
#> SD:skmeans 60 0.3391 4.18e-15 5
#> CV:skmeans 60 0.3391 4.18e-15 5
#> MAD:skmeans 57 0.6666 2.42e-15 5
#> ATC:skmeans 58 0.6728 5.79e-14 5
#> SD:mclust 57 0.1038 8.52e-16 5
#> CV:mclust 45 0.0963 4.96e-10 5
#> MAD:mclust 60 0.0558 1.80e-16 5
#> ATC:mclust 60 0.0558 1.80e-16 5
#> SD:kmeans 48 0.0098 3.22e-10 5
#> CV:kmeans 48 0.0098 3.22e-10 5
#> MAD:kmeans 33 0.0578 9.44e-06 5
#> ATC:kmeans 57 0.0993 2.35e-14 5
#> SD:pam 59 0.0463 2.67e-14 5
#> CV:pam 41 0.0033 1.49e-08 5
#> MAD:pam 54 0.0499 4.85e-14 5
#> ATC:pam 58 0.0337 4.22e-13 5
#> SD:hclust 59 0.0313 1.12e-15 5
#> CV:hclust 59 0.0313 1.12e-15 5
#> MAD:hclust 60 0.0657 1.80e-16 5
#> ATC:hclust 60 0.0860 1.31e-15 5
test_to_known_factors(res_list, k = 6)
#> n agent(p) individual(p) k
#> SD:NMF 51 0.07354 7.00e-18 6
#> CV:NMF 43 0.10773 6.57e-10 6
#> MAD:NMF 50 0.52423 3.95e-10 6
#> ATC:NMF 56 0.04722 3.79e-15 6
#> SD:skmeans 53 0.02056 5.73e-18 6
#> CV:skmeans 50 0.02729 4.13e-17 6
#> MAD:skmeans 60 0.37593 3.00e-19 6
#> ATC:skmeans 57 0.70242 2.29e-14 6
#> SD:mclust 58 0.02780 4.56e-19 6
#> CV:mclust 54 0.02918 8.14e-19 6
#> MAD:mclust 60 0.02139 1.12e-20 6
#> ATC:mclust 57 0.07268 8.30e-20 6
#> SD:kmeans 49 0.08332 1.99e-17 6
#> CV:kmeans 48 0.05175 4.13e-13 6
#> MAD:kmeans 51 0.07855 6.18e-14 6
#> ATC:kmeans 52 0.13822 2.85e-15 6
#> SD:pam 60 0.00309 1.11e-17 6
#> CV:pam 60 0.00309 1.11e-17 6
#> MAD:pam 57 0.01338 1.15e-18 6
#> ATC:pam 59 0.00811 1.25e-18 6
#> SD:hclust 60 0.05260 3.00e-19 6
#> CV:hclust 58 0.06418 5.70e-19 6
#> MAD:hclust 60 0.05260 3.00e-19 6
#> ATC:hclust 56 0.02970 3.49e-17 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.1839 0.817 0.817
#> 3 3 0.723 0.807 0.923 2.0484 0.645 0.565
#> 4 4 0.711 0.867 0.891 0.2100 0.858 0.692
#> 5 5 0.777 0.866 0.901 0.1291 0.925 0.766
#> 6 6 0.835 0.909 0.895 0.0531 0.941 0.758
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
#> GSM1324896 1 0 1 1 0
#> GSM1324897 1 0 1 1 0
#> GSM1324898 1 0 1 1 0
#> GSM1324902 1 0 1 1 0
#> GSM1324903 1 0 1 1 0
#> GSM1324904 1 0 1 1 0
#> GSM1324908 1 0 1 1 0
#> GSM1324909 1 0 1 1 0
#> GSM1324910 1 0 1 1 0
#> GSM1324914 1 0 1 1 0
#> GSM1324915 1 0 1 1 0
#> GSM1324916 1 0 1 1 0
#> GSM1324920 1 0 1 1 0
#> GSM1324921 1 0 1 1 0
#> GSM1324922 1 0 1 1 0
#> GSM1324926 2 0 1 0 1
#> GSM1324927 2 0 1 0 1
#> GSM1324928 2 0 1 0 1
#> GSM1324938 1 0 1 1 0
#> GSM1324939 1 0 1 1 0
#> GSM1324940 1 0 1 1 0
#> GSM1324944 1 0 1 1 0
#> GSM1324945 1 0 1 1 0
#> GSM1324946 1 0 1 1 0
#> GSM1324950 1 0 1 1 0
#> GSM1324951 1 0 1 1 0
#> GSM1324952 1 0 1 1 0
#> GSM1324932 2 0 1 0 1
#> GSM1324933 2 0 1 0 1
#> GSM1324934 2 0 1 0 1
#> GSM1324893 1 0 1 1 0
#> GSM1324894 1 0 1 1 0
#> GSM1324895 1 0 1 1 0
#> GSM1324899 1 0 1 1 0
#> GSM1324900 1 0 1 1 0
#> GSM1324901 1 0 1 1 0
#> GSM1324905 1 0 1 1 0
#> GSM1324906 1 0 1 1 0
#> GSM1324907 1 0 1 1 0
#> GSM1324911 1 0 1 1 0
#> GSM1324912 1 0 1 1 0
#> GSM1324913 1 0 1 1 0
#> GSM1324917 1 0 1 1 0
#> GSM1324918 1 0 1 1 0
#> GSM1324919 1 0 1 1 0
#> GSM1324923 1 0 1 1 0
#> GSM1324924 1 0 1 1 0
#> GSM1324925 1 0 1 1 0
#> GSM1324929 1 0 1 1 0
#> GSM1324930 1 0 1 1 0
#> GSM1324931 1 0 1 1 0
#> GSM1324935 1 0 1 1 0
#> GSM1324936 1 0 1 1 0
#> GSM1324937 1 0 1 1 0
#> GSM1324941 1 0 1 1 0
#> GSM1324942 1 0 1 1 0
#> GSM1324943 1 0 1 1 0
#> GSM1324947 1 0 1 1 0
#> GSM1324948 1 0 1 1 0
#> GSM1324949 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.964 1.000 0.000 0
#> GSM1324897 1 0.0000 0.964 1.000 0.000 0
#> GSM1324898 1 0.0000 0.964 1.000 0.000 0
#> GSM1324902 1 0.0000 0.964 1.000 0.000 0
#> GSM1324903 1 0.0000 0.964 1.000 0.000 0
#> GSM1324904 1 0.0000 0.964 1.000 0.000 0
#> GSM1324908 2 0.1643 0.820 0.044 0.956 0
#> GSM1324909 1 0.0000 0.964 1.000 0.000 0
#> GSM1324910 1 0.0000 0.964 1.000 0.000 0
#> GSM1324914 2 0.0892 0.844 0.020 0.980 0
#> GSM1324915 1 0.4504 0.714 0.804 0.196 0
#> GSM1324916 1 0.4504 0.714 0.804 0.196 0
#> GSM1324920 2 0.0000 0.857 0.000 1.000 0
#> GSM1324921 2 0.0000 0.857 0.000 1.000 0
#> GSM1324922 2 0.0000 0.857 0.000 1.000 0
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1
#> GSM1324938 2 0.0000 0.857 0.000 1.000 0
#> GSM1324939 2 0.0000 0.857 0.000 1.000 0
#> GSM1324940 2 0.0000 0.857 0.000 1.000 0
#> GSM1324944 2 0.0000 0.857 0.000 1.000 0
#> GSM1324945 2 0.0000 0.857 0.000 1.000 0
#> GSM1324946 2 0.0000 0.857 0.000 1.000 0
#> GSM1324950 2 0.6286 0.287 0.464 0.536 0
#> GSM1324951 2 0.6286 0.287 0.464 0.536 0
#> GSM1324952 2 0.6286 0.287 0.464 0.536 0
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1
#> GSM1324893 1 0.0000 0.964 1.000 0.000 0
#> GSM1324894 1 0.0000 0.964 1.000 0.000 0
#> GSM1324895 1 0.0000 0.964 1.000 0.000 0
#> GSM1324899 1 0.0000 0.964 1.000 0.000 0
#> GSM1324900 1 0.0000 0.964 1.000 0.000 0
#> GSM1324901 1 0.0000 0.964 1.000 0.000 0
#> GSM1324905 2 0.0000 0.857 0.000 1.000 0
#> GSM1324906 2 0.0000 0.857 0.000 1.000 0
#> GSM1324907 1 0.0000 0.964 1.000 0.000 0
#> GSM1324911 2 0.0000 0.857 0.000 1.000 0
#> GSM1324912 2 0.0000 0.857 0.000 1.000 0
#> GSM1324913 2 0.0000 0.857 0.000 1.000 0
#> GSM1324917 2 0.0000 0.857 0.000 1.000 0
#> GSM1324918 2 0.0000 0.857 0.000 1.000 0
#> GSM1324919 2 0.0000 0.857 0.000 1.000 0
#> GSM1324923 2 0.0000 0.857 0.000 1.000 0
#> GSM1324924 2 0.0000 0.857 0.000 1.000 0
#> GSM1324925 2 0.0000 0.857 0.000 1.000 0
#> GSM1324929 2 0.0000 0.857 0.000 1.000 0
#> GSM1324930 2 0.0000 0.857 0.000 1.000 0
#> GSM1324931 2 0.0000 0.857 0.000 1.000 0
#> GSM1324935 2 0.0000 0.857 0.000 1.000 0
#> GSM1324936 2 0.0000 0.857 0.000 1.000 0
#> GSM1324937 2 0.0000 0.857 0.000 1.000 0
#> GSM1324941 2 0.6286 0.287 0.464 0.536 0
#> GSM1324942 2 0.6286 0.287 0.464 0.536 0
#> GSM1324943 2 0.6286 0.287 0.464 0.536 0
#> GSM1324947 2 0.6286 0.287 0.464 0.536 0
#> GSM1324948 2 0.6286 0.287 0.464 0.536 0
#> GSM1324949 2 0.6286 0.287 0.464 0.536 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324908 4 0.4274 0.592 0.044 0.148 0 0.808
#> GSM1324909 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324914 4 0.4866 0.559 0.000 0.404 0 0.596
#> GSM1324915 1 0.3764 0.791 0.784 0.216 0 0.000
#> GSM1324916 1 0.3764 0.791 0.784 0.216 0 0.000
#> GSM1324920 4 0.3569 0.790 0.000 0.196 0 0.804
#> GSM1324921 4 0.3569 0.790 0.000 0.196 0 0.804
#> GSM1324922 4 0.3569 0.790 0.000 0.196 0 0.804
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 4 0.0469 0.779 0.000 0.012 0 0.988
#> GSM1324939 4 0.0469 0.779 0.000 0.012 0 0.988
#> GSM1324940 4 0.0469 0.779 0.000 0.012 0 0.988
#> GSM1324944 4 0.1118 0.763 0.000 0.036 0 0.964
#> GSM1324945 4 0.1118 0.763 0.000 0.036 0 0.964
#> GSM1324946 4 0.1118 0.763 0.000 0.036 0 0.964
#> GSM1324950 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324951 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324952 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324905 4 0.3024 0.633 0.000 0.148 0 0.852
#> GSM1324906 4 0.3024 0.633 0.000 0.148 0 0.852
#> GSM1324907 1 0.0000 0.975 1.000 0.000 0 0.000
#> GSM1324911 4 0.3024 0.633 0.000 0.148 0 0.852
#> GSM1324912 4 0.3024 0.633 0.000 0.148 0 0.852
#> GSM1324913 4 0.3024 0.633 0.000 0.148 0 0.852
#> GSM1324917 4 0.3486 0.795 0.000 0.188 0 0.812
#> GSM1324918 4 0.3486 0.795 0.000 0.188 0 0.812
#> GSM1324919 4 0.3486 0.795 0.000 0.188 0 0.812
#> GSM1324923 4 0.3400 0.796 0.000 0.180 0 0.820
#> GSM1324924 4 0.3400 0.796 0.000 0.180 0 0.820
#> GSM1324925 4 0.3400 0.796 0.000 0.180 0 0.820
#> GSM1324929 4 0.3400 0.796 0.000 0.180 0 0.820
#> GSM1324930 4 0.3400 0.796 0.000 0.180 0 0.820
#> GSM1324931 4 0.3400 0.796 0.000 0.180 0 0.820
#> GSM1324935 4 0.0469 0.779 0.000 0.012 0 0.988
#> GSM1324936 4 0.0469 0.779 0.000 0.012 0 0.988
#> GSM1324937 4 0.0469 0.779 0.000 0.012 0 0.988
#> GSM1324941 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324942 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324943 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324947 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324948 2 0.4697 1.000 0.000 0.644 0 0.356
#> GSM1324949 2 0.4697 1.000 0.000 0.644 0 0.356
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324908 4 0.485 0.925 0.044 0.048 0 0.756 0.152
#> GSM1324909 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324914 2 0.427 0.383 0.000 0.552 0 0.448 0.000
#> GSM1324915 1 0.345 0.763 0.756 0.000 0 0.244 0.000
#> GSM1324916 1 0.345 0.763 0.756 0.000 0 0.244 0.000
#> GSM1324920 2 0.342 0.632 0.000 0.760 0 0.240 0.000
#> GSM1324921 2 0.342 0.632 0.000 0.760 0 0.240 0.000
#> GSM1324922 2 0.342 0.632 0.000 0.760 0 0.240 0.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.304 0.737 0.000 0.808 0 0.000 0.192
#> GSM1324939 2 0.304 0.737 0.000 0.808 0 0.000 0.192
#> GSM1324940 2 0.304 0.737 0.000 0.808 0 0.000 0.192
#> GSM1324944 2 0.389 0.605 0.000 0.680 0 0.000 0.320
#> GSM1324945 2 0.389 0.605 0.000 0.680 0 0.000 0.320
#> GSM1324946 2 0.389 0.605 0.000 0.680 0 0.000 0.320
#> GSM1324950 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324951 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324952 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324932 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324905 4 0.420 0.985 0.000 0.048 0 0.756 0.196
#> GSM1324906 4 0.420 0.985 0.000 0.048 0 0.756 0.196
#> GSM1324907 1 0.000 0.973 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.420 0.985 0.000 0.048 0 0.756 0.196
#> GSM1324912 4 0.420 0.985 0.000 0.048 0 0.756 0.196
#> GSM1324913 4 0.420 0.985 0.000 0.048 0 0.756 0.196
#> GSM1324917 2 0.337 0.637 0.000 0.768 0 0.232 0.000
#> GSM1324918 2 0.337 0.637 0.000 0.768 0 0.232 0.000
#> GSM1324919 2 0.337 0.637 0.000 0.768 0 0.232 0.000
#> GSM1324923 2 0.000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324924 2 0.000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324925 2 0.000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324929 2 0.000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324930 2 0.000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324931 2 0.000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324935 2 0.304 0.737 0.000 0.808 0 0.000 0.192
#> GSM1324936 2 0.304 0.737 0.000 0.808 0 0.000 0.192
#> GSM1324937 2 0.304 0.737 0.000 0.808 0 0.000 0.192
#> GSM1324941 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324942 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324943 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324947 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324948 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324949 5 0.000 1.000 0.000 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324908 6 0.3692 0.924 0.044 0.000 0 0.012 0.152 0.792
#> GSM1324909 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.2562 0.798 0.000 0.000 0 0.828 0.000 0.172
#> GSM1324915 1 0.6012 0.537 0.572 0.184 0 0.036 0.000 0.208
#> GSM1324916 1 0.6012 0.537 0.572 0.184 0 0.036 0.000 0.208
#> GSM1324920 4 0.0865 0.948 0.000 0.036 0 0.964 0.000 0.000
#> GSM1324921 4 0.0865 0.948 0.000 0.036 0 0.964 0.000 0.000
#> GSM1324922 4 0.0865 0.948 0.000 0.036 0 0.964 0.000 0.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.2664 0.845 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324939 2 0.2664 0.845 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324940 2 0.2664 0.845 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324944 2 0.3464 0.722 0.000 0.688 0 0.000 0.312 0.000
#> GSM1324945 2 0.3464 0.722 0.000 0.688 0 0.000 0.312 0.000
#> GSM1324946 2 0.3464 0.722 0.000 0.688 0 0.000 0.312 0.000
#> GSM1324950 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324905 6 0.3110 0.984 0.000 0.000 0 0.012 0.196 0.792
#> GSM1324906 6 0.3110 0.984 0.000 0.000 0 0.012 0.196 0.792
#> GSM1324907 1 0.0000 0.952 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324911 6 0.3110 0.984 0.000 0.000 0 0.012 0.196 0.792
#> GSM1324912 6 0.3110 0.984 0.000 0.000 0 0.012 0.196 0.792
#> GSM1324913 6 0.3110 0.984 0.000 0.000 0 0.012 0.196 0.792
#> GSM1324917 4 0.1444 0.946 0.000 0.072 0 0.928 0.000 0.000
#> GSM1324918 4 0.1444 0.946 0.000 0.072 0 0.928 0.000 0.000
#> GSM1324919 4 0.1444 0.946 0.000 0.072 0 0.928 0.000 0.000
#> GSM1324923 2 0.2730 0.774 0.000 0.808 0 0.192 0.000 0.000
#> GSM1324924 2 0.2730 0.774 0.000 0.808 0 0.192 0.000 0.000
#> GSM1324925 2 0.2730 0.774 0.000 0.808 0 0.192 0.000 0.000
#> GSM1324929 2 0.2730 0.774 0.000 0.808 0 0.192 0.000 0.000
#> GSM1324930 2 0.2730 0.774 0.000 0.808 0 0.192 0.000 0.000
#> GSM1324931 2 0.2730 0.774 0.000 0.808 0 0.192 0.000 0.000
#> GSM1324935 2 0.2664 0.845 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324936 2 0.2664 0.845 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324937 2 0.2664 0.845 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324941 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324942 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324943 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324947 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 1.000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> SD:hclust 60 0.0314 3.87e-06 2
#> SD:hclust 51 0.0217 9.11e-08 3
#> SD:hclust 60 0.0319 5.63e-13 4
#> SD:hclust 59 0.0313 1.12e-15 5
#> SD:hclust 60 0.0526 3.00e-19 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 46323 rows and 60 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 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.451 0.834 0.848 0.4286 0.492 0.492
#> 3 3 0.814 0.905 0.944 0.2727 0.631 0.442
#> 4 4 0.738 0.796 0.874 0.2931 0.814 0.596
#> 5 5 0.713 0.683 0.791 0.0840 1.000 1.000
#> 6 6 0.711 0.637 0.709 0.0539 0.892 0.623
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
#> GSM1324896 1 0.730 0.947 0.796 0.204
#> GSM1324897 1 0.730 0.947 0.796 0.204
#> GSM1324898 1 0.730 0.947 0.796 0.204
#> GSM1324902 1 0.722 0.947 0.800 0.200
#> GSM1324903 1 0.722 0.947 0.800 0.200
#> GSM1324904 1 0.722 0.947 0.800 0.200
#> GSM1324908 2 1.000 -0.326 0.492 0.508
#> GSM1324909 1 0.722 0.947 0.800 0.200
#> GSM1324910 1 0.722 0.947 0.800 0.200
#> GSM1324914 2 0.443 0.821 0.092 0.908
#> GSM1324915 1 0.722 0.947 0.800 0.200
#> GSM1324916 1 0.722 0.947 0.800 0.200
#> GSM1324920 2 0.443 0.821 0.092 0.908
#> GSM1324921 2 0.443 0.821 0.092 0.908
#> GSM1324922 2 0.605 0.794 0.148 0.852
#> GSM1324926 2 0.861 0.667 0.284 0.716
#> GSM1324927 2 0.861 0.667 0.284 0.716
#> GSM1324928 2 0.861 0.667 0.284 0.716
#> GSM1324938 2 0.343 0.823 0.064 0.936
#> GSM1324939 2 0.343 0.823 0.064 0.936
#> GSM1324940 2 0.343 0.823 0.064 0.936
#> GSM1324944 2 0.615 0.756 0.152 0.848
#> GSM1324945 2 0.615 0.756 0.152 0.848
#> GSM1324946 2 0.595 0.765 0.144 0.856
#> GSM1324950 1 0.861 0.925 0.716 0.284
#> GSM1324951 1 0.861 0.925 0.716 0.284
#> GSM1324952 1 0.861 0.925 0.716 0.284
#> GSM1324932 2 0.861 0.667 0.284 0.716
#> GSM1324933 2 0.861 0.667 0.284 0.716
#> GSM1324934 2 0.861 0.667 0.284 0.716
#> GSM1324893 1 0.722 0.947 0.800 0.200
#> GSM1324894 1 0.722 0.947 0.800 0.200
#> GSM1324895 1 0.722 0.947 0.800 0.200
#> GSM1324899 1 0.722 0.947 0.800 0.200
#> GSM1324900 1 0.722 0.947 0.800 0.200
#> GSM1324901 1 0.722 0.947 0.800 0.200
#> GSM1324905 1 0.861 0.925 0.716 0.284
#> GSM1324906 1 0.861 0.925 0.716 0.284
#> GSM1324907 1 0.738 0.946 0.792 0.208
#> GSM1324911 2 0.584 0.770 0.140 0.860
#> GSM1324912 1 0.861 0.925 0.716 0.284
#> GSM1324913 2 0.506 0.794 0.112 0.888
#> GSM1324917 2 0.242 0.811 0.040 0.960
#> GSM1324918 2 0.141 0.817 0.020 0.980
#> GSM1324919 2 0.242 0.811 0.040 0.960
#> GSM1324923 2 0.327 0.824 0.060 0.940
#> GSM1324924 2 0.327 0.824 0.060 0.940
#> GSM1324925 2 0.295 0.825 0.052 0.948
#> GSM1324929 2 0.000 0.818 0.000 1.000
#> GSM1324930 2 0.000 0.818 0.000 1.000
#> GSM1324931 2 0.000 0.818 0.000 1.000
#> GSM1324935 2 0.615 0.756 0.152 0.848
#> GSM1324936 2 0.615 0.756 0.152 0.848
#> GSM1324937 2 0.697 0.697 0.188 0.812
#> GSM1324941 1 0.861 0.925 0.716 0.284
#> GSM1324942 1 0.861 0.925 0.716 0.284
#> GSM1324943 1 0.861 0.925 0.716 0.284
#> GSM1324947 1 0.861 0.925 0.716 0.284
#> GSM1324948 1 0.861 0.925 0.716 0.284
#> GSM1324949 1 0.861 0.925 0.716 0.284
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324897 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324898 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324902 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324903 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324904 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324908 2 0.1411 0.900 0.036 0.964 0.000
#> GSM1324909 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324910 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324914 2 0.0237 0.914 0.000 0.996 0.004
#> GSM1324915 1 0.1525 0.996 0.964 0.032 0.004
#> GSM1324916 1 0.1525 0.996 0.964 0.032 0.004
#> GSM1324920 2 0.0000 0.915 0.000 1.000 0.000
#> GSM1324921 2 0.0000 0.915 0.000 1.000 0.000
#> GSM1324922 2 0.0000 0.915 0.000 1.000 0.000
#> GSM1324926 3 0.0237 0.990 0.000 0.004 0.996
#> GSM1324927 3 0.0237 0.990 0.000 0.004 0.996
#> GSM1324928 3 0.0237 0.990 0.000 0.004 0.996
#> GSM1324938 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324939 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324940 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324944 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324945 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324946 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324950 2 0.5810 0.576 0.336 0.664 0.000
#> GSM1324951 2 0.5810 0.576 0.336 0.664 0.000
#> GSM1324952 2 0.5810 0.576 0.336 0.664 0.000
#> GSM1324932 3 0.1525 0.990 0.032 0.004 0.964
#> GSM1324933 3 0.1525 0.990 0.032 0.004 0.964
#> GSM1324934 3 0.1525 0.990 0.032 0.004 0.964
#> GSM1324893 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324894 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324895 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324899 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324900 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324901 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324905 2 0.1411 0.900 0.036 0.964 0.000
#> GSM1324906 2 0.1411 0.900 0.036 0.964 0.000
#> GSM1324907 1 0.1289 0.999 0.968 0.032 0.000
#> GSM1324911 2 0.0000 0.915 0.000 1.000 0.000
#> GSM1324912 2 0.5810 0.576 0.336 0.664 0.000
#> GSM1324913 2 0.0000 0.915 0.000 1.000 0.000
#> GSM1324917 2 0.0237 0.914 0.000 0.996 0.004
#> GSM1324918 2 0.0237 0.914 0.000 0.996 0.004
#> GSM1324919 2 0.0237 0.914 0.000 0.996 0.004
#> GSM1324923 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324924 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324925 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324929 2 0.0424 0.914 0.000 0.992 0.008
#> GSM1324930 2 0.0424 0.914 0.000 0.992 0.008
#> GSM1324931 2 0.0424 0.914 0.000 0.992 0.008
#> GSM1324935 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324936 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324937 2 0.0237 0.915 0.000 0.996 0.004
#> GSM1324941 2 0.1529 0.899 0.040 0.960 0.000
#> GSM1324942 2 0.1529 0.899 0.040 0.960 0.000
#> GSM1324943 2 0.1529 0.899 0.040 0.960 0.000
#> GSM1324947 2 0.5810 0.576 0.336 0.664 0.000
#> GSM1324948 2 0.5810 0.576 0.336 0.664 0.000
#> GSM1324949 2 0.5810 0.576 0.336 0.664 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324897 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324898 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324902 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324903 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324904 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324908 4 0.4228 0.568 0.008 0.232 0.000 0.760
#> GSM1324909 1 0.0469 0.962 0.988 0.012 0.000 0.000
#> GSM1324910 1 0.0469 0.962 0.988 0.012 0.000 0.000
#> GSM1324914 4 0.0817 0.768 0.000 0.024 0.000 0.976
#> GSM1324915 1 0.1474 0.954 0.948 0.052 0.000 0.000
#> GSM1324916 1 0.1474 0.954 0.948 0.052 0.000 0.000
#> GSM1324920 4 0.0592 0.773 0.000 0.016 0.000 0.984
#> GSM1324921 4 0.0592 0.773 0.000 0.016 0.000 0.984
#> GSM1324922 4 0.0592 0.773 0.000 0.016 0.000 0.984
#> GSM1324926 3 0.0817 0.992 0.000 0.024 0.976 0.000
#> GSM1324927 3 0.0817 0.992 0.000 0.024 0.976 0.000
#> GSM1324928 3 0.0817 0.992 0.000 0.024 0.976 0.000
#> GSM1324938 4 0.4746 0.448 0.000 0.368 0.000 0.632
#> GSM1324939 4 0.4746 0.448 0.000 0.368 0.000 0.632
#> GSM1324940 4 0.4746 0.448 0.000 0.368 0.000 0.632
#> GSM1324944 2 0.4643 0.520 0.000 0.656 0.000 0.344
#> GSM1324945 2 0.4643 0.520 0.000 0.656 0.000 0.344
#> GSM1324946 2 0.4643 0.520 0.000 0.656 0.000 0.344
#> GSM1324950 2 0.3354 0.848 0.044 0.872 0.000 0.084
#> GSM1324951 2 0.3354 0.848 0.044 0.872 0.000 0.084
#> GSM1324952 2 0.3354 0.848 0.044 0.872 0.000 0.084
#> GSM1324932 3 0.0000 0.992 0.000 0.000 1.000 0.000
#> GSM1324933 3 0.0000 0.992 0.000 0.000 1.000 0.000
#> GSM1324934 3 0.0000 0.992 0.000 0.000 1.000 0.000
#> GSM1324893 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324894 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324895 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324899 1 0.1389 0.958 0.952 0.048 0.000 0.000
#> GSM1324900 1 0.1389 0.958 0.952 0.048 0.000 0.000
#> GSM1324901 1 0.1389 0.958 0.952 0.048 0.000 0.000
#> GSM1324905 2 0.4360 0.750 0.008 0.744 0.000 0.248
#> GSM1324906 2 0.4360 0.750 0.008 0.744 0.000 0.248
#> GSM1324907 1 0.1302 0.959 0.956 0.044 0.000 0.000
#> GSM1324911 4 0.3942 0.573 0.000 0.236 0.000 0.764
#> GSM1324912 2 0.5330 0.734 0.120 0.748 0.000 0.132
#> GSM1324913 4 0.3942 0.573 0.000 0.236 0.000 0.764
#> GSM1324917 4 0.0188 0.775 0.000 0.004 0.000 0.996
#> GSM1324918 4 0.0188 0.775 0.000 0.004 0.000 0.996
#> GSM1324919 4 0.0188 0.775 0.000 0.004 0.000 0.996
#> GSM1324923 4 0.1637 0.782 0.000 0.060 0.000 0.940
#> GSM1324924 4 0.1637 0.782 0.000 0.060 0.000 0.940
#> GSM1324925 4 0.1637 0.782 0.000 0.060 0.000 0.940
#> GSM1324929 4 0.1637 0.782 0.000 0.060 0.000 0.940
#> GSM1324930 4 0.1637 0.782 0.000 0.060 0.000 0.940
#> GSM1324931 4 0.1637 0.782 0.000 0.060 0.000 0.940
#> GSM1324935 4 0.4898 0.327 0.000 0.416 0.000 0.584
#> GSM1324936 4 0.4898 0.327 0.000 0.416 0.000 0.584
#> GSM1324937 4 0.4898 0.327 0.000 0.416 0.000 0.584
#> GSM1324941 2 0.3088 0.838 0.008 0.864 0.000 0.128
#> GSM1324942 2 0.3088 0.838 0.008 0.864 0.000 0.128
#> GSM1324943 2 0.3088 0.838 0.008 0.864 0.000 0.128
#> GSM1324947 2 0.3354 0.848 0.044 0.872 0.000 0.084
#> GSM1324948 2 0.3354 0.848 0.044 0.872 0.000 0.084
#> GSM1324949 2 0.3354 0.848 0.044 0.872 0.000 0.084
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.2612 0.793 0.868 0.000 0.000 NA 0.008
#> GSM1324897 1 0.2612 0.793 0.868 0.000 0.000 NA 0.008
#> GSM1324898 1 0.2612 0.793 0.868 0.000 0.000 NA 0.008
#> GSM1324902 1 0.3521 0.858 0.764 0.004 0.000 NA 0.000
#> GSM1324903 1 0.3521 0.858 0.764 0.004 0.000 NA 0.000
#> GSM1324904 1 0.3521 0.858 0.764 0.004 0.000 NA 0.000
#> GSM1324908 2 0.6362 0.468 0.000 0.464 0.000 NA 0.168
#> GSM1324909 1 0.2329 0.863 0.876 0.000 0.000 NA 0.000
#> GSM1324910 1 0.2329 0.863 0.876 0.000 0.000 NA 0.000
#> GSM1324914 2 0.4575 0.617 0.000 0.648 0.000 NA 0.024
#> GSM1324915 1 0.4046 0.832 0.696 0.008 0.000 NA 0.000
#> GSM1324916 1 0.4046 0.832 0.696 0.008 0.000 NA 0.000
#> GSM1324920 2 0.4526 0.628 0.000 0.672 0.000 NA 0.028
#> GSM1324921 2 0.4526 0.628 0.000 0.672 0.000 NA 0.028
#> GSM1324922 2 0.4526 0.628 0.000 0.672 0.000 NA 0.028
#> GSM1324926 3 0.0000 0.973 0.000 0.000 1.000 NA 0.000
#> GSM1324927 3 0.0000 0.973 0.000 0.000 1.000 NA 0.000
#> GSM1324928 3 0.0000 0.973 0.000 0.000 1.000 NA 0.000
#> GSM1324938 2 0.6066 0.268 0.000 0.504 0.000 NA 0.368
#> GSM1324939 2 0.6066 0.268 0.000 0.504 0.000 NA 0.368
#> GSM1324940 2 0.6066 0.268 0.000 0.504 0.000 NA 0.368
#> GSM1324944 5 0.5961 0.295 0.000 0.316 0.000 NA 0.552
#> GSM1324945 5 0.5961 0.295 0.000 0.316 0.000 NA 0.552
#> GSM1324946 5 0.5961 0.295 0.000 0.316 0.000 NA 0.552
#> GSM1324950 5 0.0290 0.803 0.008 0.000 0.000 NA 0.992
#> GSM1324951 5 0.0290 0.803 0.008 0.000 0.000 NA 0.992
#> GSM1324952 5 0.0290 0.803 0.008 0.000 0.000 NA 0.992
#> GSM1324932 3 0.1830 0.973 0.000 0.008 0.924 NA 0.000
#> GSM1324933 3 0.1830 0.973 0.000 0.008 0.924 NA 0.000
#> GSM1324934 3 0.1830 0.973 0.000 0.008 0.924 NA 0.000
#> GSM1324893 1 0.3690 0.859 0.764 0.012 0.000 NA 0.000
#> GSM1324894 1 0.3690 0.859 0.764 0.012 0.000 NA 0.000
#> GSM1324895 1 0.3690 0.859 0.764 0.012 0.000 NA 0.000
#> GSM1324899 1 0.0566 0.841 0.984 0.004 0.000 NA 0.000
#> GSM1324900 1 0.0566 0.841 0.984 0.004 0.000 NA 0.000
#> GSM1324901 1 0.0566 0.841 0.984 0.004 0.000 NA 0.000
#> GSM1324905 5 0.4946 0.604 0.000 0.120 0.000 NA 0.712
#> GSM1324906 5 0.4946 0.604 0.000 0.120 0.000 NA 0.712
#> GSM1324907 1 0.2612 0.793 0.868 0.000 0.000 NA 0.008
#> GSM1324911 2 0.6406 0.453 0.000 0.484 0.000 NA 0.188
#> GSM1324912 5 0.5734 0.596 0.068 0.044 0.000 NA 0.668
#> GSM1324913 2 0.6406 0.453 0.000 0.484 0.000 NA 0.188
#> GSM1324917 2 0.4141 0.636 0.000 0.728 0.000 NA 0.024
#> GSM1324918 2 0.4223 0.637 0.000 0.724 0.000 NA 0.028
#> GSM1324919 2 0.4141 0.636 0.000 0.728 0.000 NA 0.024
#> GSM1324923 2 0.2130 0.637 0.000 0.908 0.000 NA 0.080
#> GSM1324924 2 0.2130 0.637 0.000 0.908 0.000 NA 0.080
#> GSM1324925 2 0.2130 0.637 0.000 0.908 0.000 NA 0.080
#> GSM1324929 2 0.1831 0.640 0.000 0.920 0.000 NA 0.076
#> GSM1324930 2 0.1831 0.640 0.000 0.920 0.000 NA 0.076
#> GSM1324931 2 0.1831 0.640 0.000 0.920 0.000 NA 0.076
#> GSM1324935 2 0.6180 0.190 0.000 0.460 0.000 NA 0.404
#> GSM1324936 2 0.6180 0.190 0.000 0.460 0.000 NA 0.404
#> GSM1324937 2 0.6180 0.190 0.000 0.460 0.000 NA 0.404
#> GSM1324941 5 0.0703 0.800 0.000 0.000 0.000 NA 0.976
#> GSM1324942 5 0.0703 0.800 0.000 0.000 0.000 NA 0.976
#> GSM1324943 5 0.0703 0.800 0.000 0.000 0.000 NA 0.976
#> GSM1324947 5 0.0451 0.803 0.008 0.000 0.000 NA 0.988
#> GSM1324948 5 0.0451 0.803 0.008 0.000 0.000 NA 0.988
#> GSM1324949 5 0.0451 0.803 0.008 0.000 0.000 NA 0.988
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.5714 0.7058 0.496 0.100 0.000 0.000 0.020 0.384
#> GSM1324897 1 0.5714 0.7058 0.496 0.100 0.000 0.000 0.020 0.384
#> GSM1324898 1 0.5714 0.7058 0.496 0.100 0.000 0.000 0.020 0.384
#> GSM1324902 1 0.0000 0.7953 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.7953 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.7953 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324908 4 0.5799 -0.6670 0.000 0.016 0.000 0.460 0.116 0.408
#> GSM1324909 1 0.3695 0.8029 0.776 0.060 0.000 0.000 0.000 0.164
#> GSM1324910 1 0.3695 0.8029 0.776 0.060 0.000 0.000 0.000 0.164
#> GSM1324914 4 0.2390 0.4846 0.000 0.056 0.000 0.888 0.000 0.056
#> GSM1324915 1 0.3214 0.7607 0.840 0.084 0.000 0.008 0.000 0.068
#> GSM1324916 1 0.3214 0.7607 0.840 0.084 0.000 0.008 0.000 0.068
#> GSM1324920 4 0.1196 0.5420 0.000 0.008 0.000 0.952 0.000 0.040
#> GSM1324921 4 0.1196 0.5420 0.000 0.008 0.000 0.952 0.000 0.040
#> GSM1324922 4 0.1196 0.5420 0.000 0.008 0.000 0.952 0.000 0.040
#> GSM1324926 3 0.0260 0.9533 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM1324927 3 0.0260 0.9536 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM1324928 3 0.0260 0.9536 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM1324938 2 0.5722 0.7292 0.000 0.560 0.000 0.212 0.220 0.008
#> GSM1324939 2 0.5722 0.7292 0.000 0.560 0.000 0.212 0.220 0.008
#> GSM1324940 2 0.5722 0.7292 0.000 0.560 0.000 0.212 0.220 0.008
#> GSM1324944 2 0.7147 0.5733 0.000 0.380 0.000 0.104 0.332 0.184
#> GSM1324945 2 0.7147 0.5733 0.000 0.380 0.000 0.104 0.332 0.184
#> GSM1324946 2 0.7147 0.5733 0.000 0.380 0.000 0.104 0.332 0.184
#> GSM1324950 5 0.0405 0.8234 0.004 0.008 0.000 0.000 0.988 0.000
#> GSM1324951 5 0.0405 0.8234 0.004 0.008 0.000 0.000 0.988 0.000
#> GSM1324952 5 0.0405 0.8234 0.004 0.008 0.000 0.000 0.988 0.000
#> GSM1324932 3 0.2249 0.9533 0.000 0.064 0.900 0.000 0.004 0.032
#> GSM1324933 3 0.2164 0.9536 0.000 0.068 0.900 0.000 0.000 0.032
#> GSM1324934 3 0.2164 0.9536 0.000 0.068 0.900 0.000 0.000 0.032
#> GSM1324893 1 0.0790 0.7946 0.968 0.032 0.000 0.000 0.000 0.000
#> GSM1324894 1 0.0790 0.7946 0.968 0.032 0.000 0.000 0.000 0.000
#> GSM1324895 1 0.0790 0.7946 0.968 0.032 0.000 0.000 0.000 0.000
#> GSM1324899 1 0.4931 0.7732 0.648 0.136 0.000 0.000 0.000 0.216
#> GSM1324900 1 0.4931 0.7732 0.648 0.136 0.000 0.000 0.000 0.216
#> GSM1324901 1 0.4931 0.7732 0.648 0.136 0.000 0.000 0.000 0.216
#> GSM1324905 5 0.5703 -0.2760 0.004 0.008 0.000 0.108 0.468 0.412
#> GSM1324906 5 0.5703 -0.2760 0.004 0.008 0.000 0.108 0.468 0.412
#> GSM1324907 1 0.5714 0.7058 0.496 0.100 0.000 0.000 0.020 0.384
#> GSM1324911 6 0.6118 0.5894 0.000 0.036 0.000 0.404 0.116 0.444
#> GSM1324912 6 0.5393 -0.0605 0.008 0.008 0.000 0.064 0.436 0.484
#> GSM1324913 6 0.6164 0.5794 0.000 0.044 0.000 0.404 0.108 0.444
#> GSM1324917 4 0.1333 0.5705 0.000 0.048 0.000 0.944 0.000 0.008
#> GSM1324918 4 0.1333 0.5705 0.000 0.048 0.000 0.944 0.000 0.008
#> GSM1324919 4 0.1333 0.5705 0.000 0.048 0.000 0.944 0.000 0.008
#> GSM1324923 4 0.5184 0.3435 0.000 0.420 0.000 0.500 0.004 0.076
#> GSM1324924 4 0.5184 0.3435 0.000 0.420 0.000 0.500 0.004 0.076
#> GSM1324925 4 0.5184 0.3435 0.000 0.420 0.000 0.500 0.004 0.076
#> GSM1324929 4 0.5089 0.4024 0.000 0.384 0.000 0.540 0.004 0.072
#> GSM1324930 4 0.5089 0.4024 0.000 0.384 0.000 0.540 0.004 0.072
#> GSM1324931 4 0.5089 0.4024 0.000 0.384 0.000 0.540 0.004 0.072
#> GSM1324935 2 0.5885 0.7672 0.000 0.536 0.000 0.192 0.260 0.012
#> GSM1324936 2 0.5885 0.7672 0.000 0.536 0.000 0.192 0.260 0.012
#> GSM1324937 2 0.5885 0.7672 0.000 0.536 0.000 0.192 0.260 0.012
#> GSM1324941 5 0.2069 0.7930 0.004 0.020 0.000 0.000 0.908 0.068
#> GSM1324942 5 0.2069 0.7930 0.004 0.020 0.000 0.000 0.908 0.068
#> GSM1324943 5 0.2069 0.7930 0.004 0.020 0.000 0.000 0.908 0.068
#> GSM1324947 5 0.0146 0.8238 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM1324948 5 0.0146 0.8238 0.004 0.000 0.000 0.000 0.996 0.000
#> GSM1324949 5 0.0146 0.8238 0.004 0.000 0.000 0.000 0.996 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 agent(p) individual(p) k
#> SD:kmeans 59 0.6944 3.71e-05 2
#> SD:kmeans 60 0.0128 7.01e-09 3
#> SD:kmeans 54 0.0246 8.09e-11 4
#> SD:kmeans 48 0.0098 3.22e-10 5
#> SD:kmeans 49 0.0833 1.99e-17 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.984 0.994 0.5088 0.492 0.492
#> 3 3 0.911 0.906 0.963 0.3293 0.719 0.487
#> 4 4 0.780 0.674 0.850 0.1175 0.845 0.569
#> 5 5 0.844 0.856 0.906 0.0535 0.905 0.644
#> 6 6 0.856 0.783 0.843 0.0334 0.968 0.841
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
#> GSM1324896 1 0.000 0.987 1.000 0.000
#> GSM1324897 1 0.000 0.987 1.000 0.000
#> GSM1324898 1 0.000 0.987 1.000 0.000
#> GSM1324902 1 0.000 0.987 1.000 0.000
#> GSM1324903 1 0.000 0.987 1.000 0.000
#> GSM1324904 1 0.000 0.987 1.000 0.000
#> GSM1324908 1 0.949 0.418 0.632 0.368
#> GSM1324909 1 0.000 0.987 1.000 0.000
#> GSM1324910 1 0.000 0.987 1.000 0.000
#> GSM1324914 2 0.000 1.000 0.000 1.000
#> GSM1324915 1 0.000 0.987 1.000 0.000
#> GSM1324916 1 0.000 0.987 1.000 0.000
#> GSM1324920 2 0.000 1.000 0.000 1.000
#> GSM1324921 2 0.000 1.000 0.000 1.000
#> GSM1324922 2 0.000 1.000 0.000 1.000
#> GSM1324926 2 0.000 1.000 0.000 1.000
#> GSM1324927 2 0.000 1.000 0.000 1.000
#> GSM1324928 2 0.000 1.000 0.000 1.000
#> GSM1324938 2 0.000 1.000 0.000 1.000
#> GSM1324939 2 0.000 1.000 0.000 1.000
#> GSM1324940 2 0.000 1.000 0.000 1.000
#> GSM1324944 2 0.000 1.000 0.000 1.000
#> GSM1324945 2 0.000 1.000 0.000 1.000
#> GSM1324946 2 0.000 1.000 0.000 1.000
#> GSM1324950 1 0.000 0.987 1.000 0.000
#> GSM1324951 1 0.000 0.987 1.000 0.000
#> GSM1324952 1 0.000 0.987 1.000 0.000
#> GSM1324932 2 0.000 1.000 0.000 1.000
#> GSM1324933 2 0.000 1.000 0.000 1.000
#> GSM1324934 2 0.000 1.000 0.000 1.000
#> GSM1324893 1 0.000 0.987 1.000 0.000
#> GSM1324894 1 0.000 0.987 1.000 0.000
#> GSM1324895 1 0.000 0.987 1.000 0.000
#> GSM1324899 1 0.000 0.987 1.000 0.000
#> GSM1324900 1 0.000 0.987 1.000 0.000
#> GSM1324901 1 0.000 0.987 1.000 0.000
#> GSM1324905 1 0.000 0.987 1.000 0.000
#> GSM1324906 1 0.000 0.987 1.000 0.000
#> GSM1324907 1 0.000 0.987 1.000 0.000
#> GSM1324911 2 0.000 1.000 0.000 1.000
#> GSM1324912 1 0.000 0.987 1.000 0.000
#> GSM1324913 2 0.000 1.000 0.000 1.000
#> GSM1324917 2 0.000 1.000 0.000 1.000
#> GSM1324918 2 0.000 1.000 0.000 1.000
#> GSM1324919 2 0.000 1.000 0.000 1.000
#> GSM1324923 2 0.000 1.000 0.000 1.000
#> GSM1324924 2 0.000 1.000 0.000 1.000
#> GSM1324925 2 0.000 1.000 0.000 1.000
#> GSM1324929 2 0.000 1.000 0.000 1.000
#> GSM1324930 2 0.000 1.000 0.000 1.000
#> GSM1324931 2 0.000 1.000 0.000 1.000
#> GSM1324935 2 0.000 1.000 0.000 1.000
#> GSM1324936 2 0.000 1.000 0.000 1.000
#> GSM1324937 2 0.000 1.000 0.000 1.000
#> GSM1324941 1 0.000 0.987 1.000 0.000
#> GSM1324942 1 0.000 0.987 1.000 0.000
#> GSM1324943 1 0.000 0.987 1.000 0.000
#> GSM1324947 1 0.000 0.987 1.000 0.000
#> GSM1324948 1 0.000 0.987 1.000 0.000
#> GSM1324949 1 0.000 0.987 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324897 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324898 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324902 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324903 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324904 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324908 1 0.625 0.177 0.556 0.000 0.444
#> GSM1324909 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324910 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324914 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324915 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324916 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324920 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324921 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324922 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324926 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324927 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324928 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324938 2 0.475 0.735 0.000 0.784 0.216
#> GSM1324939 2 0.475 0.735 0.000 0.784 0.216
#> GSM1324940 2 0.475 0.735 0.000 0.784 0.216
#> GSM1324944 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324945 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324946 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324950 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324951 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324952 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324932 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324933 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324934 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324893 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324894 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324895 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324899 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324900 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324901 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324905 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324906 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324907 1 0.000 0.960 1.000 0.000 0.000
#> GSM1324911 3 0.624 0.257 0.000 0.440 0.560
#> GSM1324912 1 0.502 0.670 0.760 0.240 0.000
#> GSM1324913 3 0.624 0.257 0.000 0.440 0.560
#> GSM1324917 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324918 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324919 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324923 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324924 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324925 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324929 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324930 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324931 3 0.000 0.954 0.000 0.000 1.000
#> GSM1324935 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324936 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324937 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324941 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324942 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324943 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324947 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324948 2 0.000 0.962 0.000 1.000 0.000
#> GSM1324949 2 0.000 0.962 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324908 3 0.6600 0.111 0.408 0.048 0.528 0.016
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324914 3 0.0469 0.660 0.000 0.000 0.988 0.012
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324920 3 0.0921 0.656 0.000 0.000 0.972 0.028
#> GSM1324921 3 0.0921 0.656 0.000 0.000 0.972 0.028
#> GSM1324922 3 0.0921 0.656 0.000 0.000 0.972 0.028
#> GSM1324926 3 0.4585 0.563 0.000 0.000 0.668 0.332
#> GSM1324927 3 0.4585 0.563 0.000 0.000 0.668 0.332
#> GSM1324928 3 0.4585 0.563 0.000 0.000 0.668 0.332
#> GSM1324938 4 0.1743 0.695 0.000 0.056 0.004 0.940
#> GSM1324939 4 0.1743 0.695 0.000 0.056 0.004 0.940
#> GSM1324940 4 0.1743 0.695 0.000 0.056 0.004 0.940
#> GSM1324944 2 0.4941 0.195 0.000 0.564 0.000 0.436
#> GSM1324945 2 0.4941 0.195 0.000 0.564 0.000 0.436
#> GSM1324946 2 0.4941 0.195 0.000 0.564 0.000 0.436
#> GSM1324950 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324951 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324952 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324932 3 0.4585 0.563 0.000 0.000 0.668 0.332
#> GSM1324933 3 0.4585 0.563 0.000 0.000 0.668 0.332
#> GSM1324934 3 0.4585 0.563 0.000 0.000 0.668 0.332
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324905 2 0.4262 0.609 0.000 0.756 0.236 0.008
#> GSM1324906 2 0.4262 0.609 0.000 0.756 0.236 0.008
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324911 3 0.7745 -0.142 0.000 0.352 0.412 0.236
#> GSM1324912 2 0.5569 0.502 0.280 0.676 0.040 0.004
#> GSM1324913 3 0.7766 -0.134 0.000 0.344 0.412 0.244
#> GSM1324917 3 0.1211 0.668 0.000 0.000 0.960 0.040
#> GSM1324918 3 0.1211 0.668 0.000 0.000 0.960 0.040
#> GSM1324919 3 0.1211 0.668 0.000 0.000 0.960 0.040
#> GSM1324923 4 0.2149 0.676 0.000 0.000 0.088 0.912
#> GSM1324924 4 0.2149 0.676 0.000 0.000 0.088 0.912
#> GSM1324925 4 0.2149 0.676 0.000 0.000 0.088 0.912
#> GSM1324929 4 0.4661 0.245 0.000 0.000 0.348 0.652
#> GSM1324930 4 0.4661 0.245 0.000 0.000 0.348 0.652
#> GSM1324931 4 0.4661 0.245 0.000 0.000 0.348 0.652
#> GSM1324935 4 0.4800 0.392 0.000 0.340 0.004 0.656
#> GSM1324936 4 0.4800 0.392 0.000 0.340 0.004 0.656
#> GSM1324937 4 0.4800 0.392 0.000 0.340 0.004 0.656
#> GSM1324941 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324942 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324943 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324947 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324948 2 0.0000 0.806 0.000 1.000 0.000 0.000
#> GSM1324949 2 0.0000 0.806 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324897 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324898 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324902 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324903 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324904 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324908 4 0.460 0.595 0.176 0.032 0.016 0.764 0.012
#> GSM1324909 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.281 0.777 0.000 0.000 0.168 0.832 0.000
#> GSM1324915 1 0.088 0.970 0.968 0.000 0.000 0.032 0.000
#> GSM1324916 1 0.088 0.970 0.968 0.000 0.000 0.032 0.000
#> GSM1324920 4 0.293 0.778 0.000 0.004 0.164 0.832 0.000
#> GSM1324921 4 0.293 0.778 0.000 0.004 0.164 0.832 0.000
#> GSM1324922 4 0.293 0.778 0.000 0.004 0.164 0.832 0.000
#> GSM1324926 3 0.000 0.842 0.000 0.000 1.000 0.000 0.000
#> GSM1324927 3 0.000 0.842 0.000 0.000 1.000 0.000 0.000
#> GSM1324928 3 0.000 0.842 0.000 0.000 1.000 0.000 0.000
#> GSM1324938 2 0.104 0.852 0.000 0.964 0.032 0.000 0.004
#> GSM1324939 2 0.104 0.852 0.000 0.964 0.032 0.000 0.004
#> GSM1324940 2 0.104 0.852 0.000 0.964 0.032 0.000 0.004
#> GSM1324944 2 0.417 0.753 0.000 0.760 0.000 0.048 0.192
#> GSM1324945 2 0.417 0.753 0.000 0.760 0.000 0.048 0.192
#> GSM1324946 2 0.417 0.753 0.000 0.760 0.000 0.048 0.192
#> GSM1324950 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324951 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324952 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324932 3 0.000 0.842 0.000 0.000 1.000 0.000 0.000
#> GSM1324933 3 0.000 0.842 0.000 0.000 1.000 0.000 0.000
#> GSM1324934 3 0.000 0.842 0.000 0.000 1.000 0.000 0.000
#> GSM1324893 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324894 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324895 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324899 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324905 5 0.395 0.788 0.000 0.036 0.000 0.192 0.772
#> GSM1324906 5 0.395 0.788 0.000 0.036 0.000 0.192 0.772
#> GSM1324907 1 0.000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1324911 4 0.371 0.614 0.000 0.048 0.000 0.808 0.144
#> GSM1324912 5 0.460 0.778 0.028 0.036 0.000 0.180 0.756
#> GSM1324913 4 0.371 0.614 0.000 0.048 0.000 0.808 0.144
#> GSM1324917 4 0.400 0.656 0.000 0.000 0.344 0.656 0.000
#> GSM1324918 4 0.400 0.656 0.000 0.000 0.344 0.656 0.000
#> GSM1324919 4 0.400 0.656 0.000 0.000 0.344 0.656 0.000
#> GSM1324923 2 0.376 0.776 0.000 0.784 0.028 0.188 0.000
#> GSM1324924 2 0.376 0.776 0.000 0.784 0.028 0.188 0.000
#> GSM1324925 2 0.376 0.776 0.000 0.784 0.028 0.188 0.000
#> GSM1324929 3 0.525 0.672 0.000 0.224 0.668 0.108 0.000
#> GSM1324930 3 0.525 0.672 0.000 0.224 0.668 0.108 0.000
#> GSM1324931 3 0.525 0.672 0.000 0.224 0.668 0.108 0.000
#> GSM1324935 2 0.104 0.858 0.000 0.960 0.000 0.000 0.040
#> GSM1324936 2 0.104 0.858 0.000 0.960 0.000 0.000 0.040
#> GSM1324937 2 0.104 0.858 0.000 0.960 0.000 0.000 0.040
#> GSM1324941 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324942 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324943 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324947 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324948 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
#> GSM1324949 5 0.000 0.939 0.000 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324897 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324898 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324902 1 0.1398 0.962 0.940 0.000 0.008 0.000 0.000 0.052
#> GSM1324903 1 0.1398 0.962 0.940 0.000 0.008 0.000 0.000 0.052
#> GSM1324904 1 0.1398 0.962 0.940 0.000 0.008 0.000 0.000 0.052
#> GSM1324908 6 0.5501 0.398 0.120 0.000 0.000 0.360 0.004 0.516
#> GSM1324909 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.1003 0.857 0.000 0.000 0.020 0.964 0.000 0.016
#> GSM1324915 1 0.2285 0.938 0.900 0.000 0.008 0.028 0.000 0.064
#> GSM1324916 1 0.2285 0.938 0.900 0.000 0.008 0.028 0.000 0.064
#> GSM1324920 4 0.0363 0.864 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM1324921 4 0.0363 0.864 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM1324922 4 0.0363 0.864 0.000 0.000 0.012 0.988 0.000 0.000
#> GSM1324926 3 0.1267 0.720 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM1324927 3 0.1267 0.720 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM1324928 3 0.1267 0.720 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM1324938 2 0.0935 0.722 0.000 0.964 0.004 0.000 0.000 0.032
#> GSM1324939 2 0.0935 0.722 0.000 0.964 0.004 0.000 0.000 0.032
#> GSM1324940 2 0.0935 0.722 0.000 0.964 0.004 0.000 0.000 0.032
#> GSM1324944 2 0.5623 0.557 0.000 0.612 0.012 0.016 0.108 0.252
#> GSM1324945 2 0.5623 0.557 0.000 0.612 0.012 0.016 0.108 0.252
#> GSM1324946 2 0.5623 0.557 0.000 0.612 0.012 0.016 0.108 0.252
#> GSM1324950 5 0.0146 0.993 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM1324951 5 0.0146 0.993 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM1324952 5 0.0146 0.993 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM1324932 3 0.1267 0.720 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM1324933 3 0.1267 0.720 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM1324934 3 0.1267 0.720 0.000 0.000 0.940 0.060 0.000 0.000
#> GSM1324893 1 0.1398 0.962 0.940 0.000 0.008 0.000 0.000 0.052
#> GSM1324894 1 0.1398 0.962 0.940 0.000 0.008 0.000 0.000 0.052
#> GSM1324895 1 0.1398 0.962 0.940 0.000 0.008 0.000 0.000 0.052
#> GSM1324899 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324900 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324901 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324905 6 0.4709 0.559 0.000 0.000 0.000 0.048 0.412 0.540
#> GSM1324906 6 0.4709 0.559 0.000 0.000 0.000 0.048 0.412 0.540
#> GSM1324907 1 0.0146 0.967 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1324911 6 0.4664 0.585 0.000 0.012 0.000 0.264 0.056 0.668
#> GSM1324912 6 0.5595 0.599 0.044 0.000 0.004 0.048 0.356 0.548
#> GSM1324913 6 0.4607 0.582 0.000 0.012 0.000 0.264 0.052 0.672
#> GSM1324917 4 0.3221 0.818 0.000 0.000 0.188 0.792 0.000 0.020
#> GSM1324918 4 0.3221 0.818 0.000 0.000 0.188 0.792 0.000 0.020
#> GSM1324919 4 0.3221 0.818 0.000 0.000 0.188 0.792 0.000 0.020
#> GSM1324923 2 0.6713 0.403 0.000 0.408 0.064 0.160 0.000 0.368
#> GSM1324924 2 0.6671 0.409 0.000 0.412 0.060 0.160 0.000 0.368
#> GSM1324925 2 0.6713 0.403 0.000 0.408 0.064 0.160 0.000 0.368
#> GSM1324929 3 0.7090 0.322 0.000 0.168 0.420 0.112 0.000 0.300
#> GSM1324930 3 0.7090 0.322 0.000 0.168 0.420 0.112 0.000 0.300
#> GSM1324931 3 0.7090 0.322 0.000 0.168 0.420 0.112 0.000 0.300
#> GSM1324935 2 0.0363 0.723 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM1324936 2 0.0363 0.723 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM1324937 2 0.0363 0.723 0.000 0.988 0.000 0.000 0.012 0.000
#> GSM1324941 5 0.0405 0.985 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM1324942 5 0.0405 0.985 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM1324943 5 0.0405 0.985 0.000 0.000 0.000 0.004 0.988 0.008
#> GSM1324947 5 0.0146 0.993 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM1324948 5 0.0146 0.993 0.000 0.004 0.000 0.000 0.996 0.000
#> GSM1324949 5 0.0146 0.993 0.000 0.004 0.000 0.000 0.996 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 agent(p) individual(p) k
#> SD:skmeans 59 0.6944 3.71e-05 2
#> SD:skmeans 57 0.7955 2.54e-08 3
#> SD:skmeans 48 0.0715 3.22e-10 4
#> SD:skmeans 60 0.3391 4.18e-15 5
#> SD:skmeans 53 0.0206 5.73e-18 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 46323 rows and 60 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 0.497 0.881 0.852 0.4086 0.497 0.497
#> 3 3 1.000 0.978 0.992 0.3786 0.701 0.516
#> 4 4 0.978 0.961 0.980 0.2968 0.827 0.608
#> 5 5 0.847 0.820 0.907 0.0684 0.956 0.838
#> 6 6 0.943 0.952 0.977 0.0429 0.939 0.740
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] 3 4
There is also optional best \(k\) = 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.881 0.989 0.700 0.300
#> GSM1324897 1 0.881 0.989 0.700 0.300
#> GSM1324898 1 0.881 0.989 0.700 0.300
#> GSM1324902 1 0.881 0.989 0.700 0.300
#> GSM1324903 1 0.881 0.989 0.700 0.300
#> GSM1324904 1 0.881 0.989 0.700 0.300
#> GSM1324908 1 0.881 0.989 0.700 0.300
#> GSM1324909 1 0.881 0.989 0.700 0.300
#> GSM1324910 1 0.881 0.989 0.700 0.300
#> GSM1324914 2 0.000 0.892 0.000 1.000
#> GSM1324915 1 0.881 0.989 0.700 0.300
#> GSM1324916 1 0.881 0.989 0.700 0.300
#> GSM1324920 2 0.000 0.892 0.000 1.000
#> GSM1324921 2 0.000 0.892 0.000 1.000
#> GSM1324922 2 0.000 0.892 0.000 1.000
#> GSM1324926 2 0.881 0.661 0.300 0.700
#> GSM1324927 2 0.881 0.661 0.300 0.700
#> GSM1324928 2 0.881 0.661 0.300 0.700
#> GSM1324938 2 0.000 0.892 0.000 1.000
#> GSM1324939 2 0.000 0.892 0.000 1.000
#> GSM1324940 2 0.000 0.892 0.000 1.000
#> GSM1324944 2 0.000 0.892 0.000 1.000
#> GSM1324945 2 0.000 0.892 0.000 1.000
#> GSM1324946 2 0.000 0.892 0.000 1.000
#> GSM1324950 1 0.881 0.989 0.700 0.300
#> GSM1324951 1 0.881 0.989 0.700 0.300
#> GSM1324952 1 0.881 0.989 0.700 0.300
#> GSM1324932 2 0.881 0.661 0.300 0.700
#> GSM1324933 2 0.881 0.661 0.300 0.700
#> GSM1324934 2 0.881 0.661 0.300 0.700
#> GSM1324893 1 0.881 0.989 0.700 0.300
#> GSM1324894 1 0.881 0.989 0.700 0.300
#> GSM1324895 1 0.881 0.989 0.700 0.300
#> GSM1324899 1 0.881 0.989 0.700 0.300
#> GSM1324900 1 0.881 0.989 0.700 0.300
#> GSM1324901 1 0.881 0.989 0.700 0.300
#> GSM1324905 2 0.388 0.785 0.076 0.924
#> GSM1324906 2 0.118 0.873 0.016 0.984
#> GSM1324907 1 0.881 0.989 0.700 0.300
#> GSM1324911 2 0.000 0.892 0.000 1.000
#> GSM1324912 1 0.881 0.989 0.700 0.300
#> GSM1324913 2 0.000 0.892 0.000 1.000
#> GSM1324917 2 0.000 0.892 0.000 1.000
#> GSM1324918 2 0.000 0.892 0.000 1.000
#> GSM1324919 2 0.000 0.892 0.000 1.000
#> GSM1324923 2 0.000 0.892 0.000 1.000
#> GSM1324924 2 0.000 0.892 0.000 1.000
#> GSM1324925 2 0.000 0.892 0.000 1.000
#> GSM1324929 2 0.000 0.892 0.000 1.000
#> GSM1324930 2 0.000 0.892 0.000 1.000
#> GSM1324931 2 0.000 0.892 0.000 1.000
#> GSM1324935 2 0.000 0.892 0.000 1.000
#> GSM1324936 2 0.000 0.892 0.000 1.000
#> GSM1324937 2 0.000 0.892 0.000 1.000
#> GSM1324941 1 1.000 0.613 0.504 0.496
#> GSM1324942 1 0.891 0.978 0.692 0.308
#> GSM1324943 2 0.994 -0.504 0.456 0.544
#> GSM1324947 1 0.881 0.989 0.700 0.300
#> GSM1324948 1 0.881 0.989 0.700 0.300
#> GSM1324949 1 0.881 0.989 0.700 0.300
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 1.000 1.000 0.000 0
#> GSM1324897 1 0.000 1.000 1.000 0.000 0
#> GSM1324898 1 0.000 1.000 1.000 0.000 0
#> GSM1324902 1 0.000 1.000 1.000 0.000 0
#> GSM1324903 1 0.000 1.000 1.000 0.000 0
#> GSM1324904 1 0.000 1.000 1.000 0.000 0
#> GSM1324908 1 0.000 1.000 1.000 0.000 0
#> GSM1324909 1 0.000 1.000 1.000 0.000 0
#> GSM1324910 1 0.000 1.000 1.000 0.000 0
#> GSM1324914 2 0.000 0.983 0.000 1.000 0
#> GSM1324915 1 0.000 1.000 1.000 0.000 0
#> GSM1324916 1 0.000 1.000 1.000 0.000 0
#> GSM1324920 2 0.000 0.983 0.000 1.000 0
#> GSM1324921 2 0.000 0.983 0.000 1.000 0
#> GSM1324922 2 0.000 0.983 0.000 1.000 0
#> GSM1324926 3 0.000 1.000 0.000 0.000 1
#> GSM1324927 3 0.000 1.000 0.000 0.000 1
#> GSM1324928 3 0.000 1.000 0.000 0.000 1
#> GSM1324938 2 0.000 0.983 0.000 1.000 0
#> GSM1324939 2 0.000 0.983 0.000 1.000 0
#> GSM1324940 2 0.000 0.983 0.000 1.000 0
#> GSM1324944 2 0.000 0.983 0.000 1.000 0
#> GSM1324945 2 0.000 0.983 0.000 1.000 0
#> GSM1324946 2 0.000 0.983 0.000 1.000 0
#> GSM1324950 2 0.000 0.983 0.000 1.000 0
#> GSM1324951 2 0.000 0.983 0.000 1.000 0
#> GSM1324952 2 0.000 0.983 0.000 1.000 0
#> GSM1324932 3 0.000 1.000 0.000 0.000 1
#> GSM1324933 3 0.000 1.000 0.000 0.000 1
#> GSM1324934 3 0.000 1.000 0.000 0.000 1
#> GSM1324893 1 0.000 1.000 1.000 0.000 0
#> GSM1324894 1 0.000 1.000 1.000 0.000 0
#> GSM1324895 1 0.000 1.000 1.000 0.000 0
#> GSM1324899 1 0.000 1.000 1.000 0.000 0
#> GSM1324900 1 0.000 1.000 1.000 0.000 0
#> GSM1324901 1 0.000 1.000 1.000 0.000 0
#> GSM1324905 2 0.613 0.342 0.400 0.600 0
#> GSM1324906 2 0.280 0.878 0.092 0.908 0
#> GSM1324907 1 0.000 1.000 1.000 0.000 0
#> GSM1324911 2 0.000 0.983 0.000 1.000 0
#> GSM1324912 1 0.000 1.000 1.000 0.000 0
#> GSM1324913 2 0.000 0.983 0.000 1.000 0
#> GSM1324917 2 0.000 0.983 0.000 1.000 0
#> GSM1324918 2 0.000 0.983 0.000 1.000 0
#> GSM1324919 2 0.000 0.983 0.000 1.000 0
#> GSM1324923 2 0.000 0.983 0.000 1.000 0
#> GSM1324924 2 0.000 0.983 0.000 1.000 0
#> GSM1324925 2 0.000 0.983 0.000 1.000 0
#> GSM1324929 2 0.000 0.983 0.000 1.000 0
#> GSM1324930 2 0.000 0.983 0.000 1.000 0
#> GSM1324931 2 0.000 0.983 0.000 1.000 0
#> GSM1324935 2 0.000 0.983 0.000 1.000 0
#> GSM1324936 2 0.000 0.983 0.000 1.000 0
#> GSM1324937 2 0.000 0.983 0.000 1.000 0
#> GSM1324941 2 0.000 0.983 0.000 1.000 0
#> GSM1324942 2 0.000 0.983 0.000 1.000 0
#> GSM1324943 2 0.000 0.983 0.000 1.000 0
#> GSM1324947 2 0.000 0.983 0.000 1.000 0
#> GSM1324948 2 0.000 0.983 0.000 1.000 0
#> GSM1324949 2 0.000 0.983 0.000 1.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324908 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324909 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324914 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324915 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324916 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324920 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324921 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324922 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 4 0.1557 0.942 0.000 0.056 0 0.944
#> GSM1324939 4 0.1118 0.956 0.000 0.036 0 0.964
#> GSM1324940 4 0.2149 0.909 0.000 0.088 0 0.912
#> GSM1324944 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324945 2 0.1557 0.931 0.000 0.944 0 0.056
#> GSM1324946 2 0.1867 0.917 0.000 0.928 0 0.072
#> GSM1324950 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324951 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324952 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324905 2 0.0895 0.947 0.020 0.976 0 0.004
#> GSM1324906 2 0.0336 0.961 0.008 0.992 0 0.000
#> GSM1324907 1 0.0000 0.992 1.000 0.000 0 0.000
#> GSM1324911 4 0.4134 0.642 0.000 0.260 0 0.740
#> GSM1324912 1 0.2814 0.834 0.868 0.132 0 0.000
#> GSM1324913 4 0.0336 0.959 0.000 0.008 0 0.992
#> GSM1324917 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324918 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324919 4 0.0000 0.959 0.000 0.000 0 1.000
#> GSM1324923 4 0.1022 0.958 0.000 0.032 0 0.968
#> GSM1324924 4 0.1022 0.958 0.000 0.032 0 0.968
#> GSM1324925 4 0.1022 0.958 0.000 0.032 0 0.968
#> GSM1324929 4 0.0817 0.960 0.000 0.024 0 0.976
#> GSM1324930 4 0.0817 0.960 0.000 0.024 0 0.976
#> GSM1324931 4 0.0817 0.960 0.000 0.024 0 0.976
#> GSM1324935 2 0.2704 0.866 0.000 0.876 0 0.124
#> GSM1324936 2 0.2760 0.862 0.000 0.872 0 0.128
#> GSM1324937 2 0.0592 0.959 0.000 0.984 0 0.016
#> GSM1324941 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324942 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324943 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324947 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324948 2 0.0000 0.968 0.000 1.000 0 0.000
#> GSM1324949 2 0.0000 0.968 0.000 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324908 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324909 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.2179 0.816 0.000 0.112 0 0.888 0.000
#> GSM1324915 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324916 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324920 4 0.0000 0.829 0.000 0.000 0 1.000 0.000
#> GSM1324921 4 0.0162 0.827 0.000 0.004 0 0.996 0.000
#> GSM1324922 4 0.0162 0.827 0.000 0.004 0 0.996 0.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.2338 0.646 0.000 0.884 0 0.112 0.004
#> GSM1324939 2 0.2338 0.646 0.000 0.884 0 0.112 0.004
#> GSM1324940 2 0.2462 0.644 0.000 0.880 0 0.112 0.008
#> GSM1324944 5 0.5659 0.606 0.000 0.320 0 0.100 0.580
#> GSM1324945 5 0.5688 0.600 0.000 0.328 0 0.100 0.572
#> GSM1324946 5 0.5701 0.596 0.000 0.332 0 0.100 0.568
#> GSM1324950 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324951 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324952 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324905 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324906 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324907 1 0.0000 0.992 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.4810 0.638 0.000 0.084 0 0.712 0.204
#> GSM1324912 1 0.2424 0.837 0.868 0.000 0 0.000 0.132
#> GSM1324913 2 0.4604 0.272 0.000 0.560 0 0.428 0.012
#> GSM1324917 4 0.3336 0.690 0.000 0.228 0 0.772 0.000
#> GSM1324918 2 0.3949 0.511 0.000 0.668 0 0.332 0.000
#> GSM1324919 4 0.2179 0.816 0.000 0.112 0 0.888 0.000
#> GSM1324923 2 0.0162 0.693 0.000 0.996 0 0.004 0.000
#> GSM1324924 2 0.0162 0.693 0.000 0.996 0 0.004 0.000
#> GSM1324925 2 0.0510 0.693 0.000 0.984 0 0.016 0.000
#> GSM1324929 2 0.3857 0.543 0.000 0.688 0 0.312 0.000
#> GSM1324930 2 0.3857 0.543 0.000 0.688 0 0.312 0.000
#> GSM1324931 2 0.3857 0.543 0.000 0.688 0 0.312 0.000
#> GSM1324935 5 0.5813 0.588 0.000 0.328 0 0.112 0.560
#> GSM1324936 5 0.5826 0.584 0.000 0.332 0 0.112 0.556
#> GSM1324937 5 0.5785 0.596 0.000 0.320 0 0.112 0.568
#> GSM1324941 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324942 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324943 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324947 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324948 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
#> GSM1324949 5 0.0000 0.823 0.000 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324908 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324909 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.000 0.931 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324916 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324920 4 0.000 0.931 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324921 4 0.000 0.931 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324922 4 0.000 0.931 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.000 0.920 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324939 2 0.000 0.920 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324940 2 0.000 0.920 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324944 2 0.260 0.832 0.000 0.824 0 0.000 0.176 0.000
#> GSM1324945 2 0.260 0.832 0.000 0.824 0 0.000 0.176 0.000
#> GSM1324946 2 0.270 0.833 0.000 0.824 0 0.000 0.172 0.004
#> GSM1324950 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324905 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324906 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324907 1 0.000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324911 4 0.309 0.742 0.000 0.008 0 0.800 0.188 0.004
#> GSM1324912 1 0.242 0.809 0.844 0.000 0 0.000 0.156 0.000
#> GSM1324913 6 0.333 0.716 0.000 0.008 0 0.220 0.004 0.768
#> GSM1324917 4 0.242 0.789 0.000 0.000 0 0.844 0.000 0.156
#> GSM1324918 6 0.191 0.867 0.000 0.000 0 0.108 0.000 0.892
#> GSM1324919 4 0.000 0.931 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324923 6 0.000 0.949 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324924 6 0.000 0.949 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324925 6 0.000 0.949 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324929 6 0.000 0.949 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324930 6 0.000 0.949 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324931 6 0.000 0.949 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324935 2 0.000 0.920 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324936 2 0.000 0.920 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324937 2 0.000 0.920 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324941 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324942 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324943 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324947 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.000 1.000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> SD:pam 59 1.00000 9.51e-05 2
#> SD:pam 59 0.01544 8.51e-09 3
#> SD:pam 60 0.03159 1.02e-12 4
#> SD:pam 59 0.04631 2.67e-14 5
#> SD:pam 60 0.00309 1.11e-17 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.350 0.823 0.855 0.4575 0.492 0.492
#> 3 3 0.732 0.909 0.945 0.2529 0.618 0.427
#> 4 4 0.779 0.887 0.919 0.2318 0.824 0.618
#> 5 5 0.823 0.849 0.888 0.0953 0.939 0.786
#> 6 6 0.841 0.857 0.875 0.0538 0.959 0.819
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
#> GSM1324896 1 0.5178 0.797 0.884 0.116
#> GSM1324897 1 0.5178 0.797 0.884 0.116
#> GSM1324898 1 0.5178 0.797 0.884 0.116
#> GSM1324902 1 0.4690 0.800 0.900 0.100
#> GSM1324903 1 0.4690 0.800 0.900 0.100
#> GSM1324904 1 0.4690 0.800 0.900 0.100
#> GSM1324908 1 0.9922 0.600 0.552 0.448
#> GSM1324909 1 0.4690 0.800 0.900 0.100
#> GSM1324910 1 0.4690 0.800 0.900 0.100
#> GSM1324914 1 0.9795 0.601 0.584 0.416
#> GSM1324915 1 0.4690 0.800 0.900 0.100
#> GSM1324916 1 0.4690 0.800 0.900 0.100
#> GSM1324920 1 0.9393 0.586 0.644 0.356
#> GSM1324921 1 0.9393 0.586 0.644 0.356
#> GSM1324922 1 0.9393 0.586 0.644 0.356
#> GSM1324926 2 0.5842 0.853 0.140 0.860
#> GSM1324927 2 0.5842 0.853 0.140 0.860
#> GSM1324928 2 0.5842 0.853 0.140 0.860
#> GSM1324938 2 0.0376 0.963 0.004 0.996
#> GSM1324939 2 0.0376 0.963 0.004 0.996
#> GSM1324940 2 0.0376 0.963 0.004 0.996
#> GSM1324944 2 0.0376 0.963 0.004 0.996
#> GSM1324945 2 0.0376 0.963 0.004 0.996
#> GSM1324946 2 0.0376 0.963 0.004 0.996
#> GSM1324950 2 0.0376 0.963 0.004 0.996
#> GSM1324951 2 0.0376 0.963 0.004 0.996
#> GSM1324952 2 0.0376 0.963 0.004 0.996
#> GSM1324932 2 0.5842 0.853 0.140 0.860
#> GSM1324933 2 0.5842 0.853 0.140 0.860
#> GSM1324934 2 0.5842 0.853 0.140 0.860
#> GSM1324893 1 0.4690 0.800 0.900 0.100
#> GSM1324894 1 0.4690 0.800 0.900 0.100
#> GSM1324895 1 0.4690 0.800 0.900 0.100
#> GSM1324899 1 0.4690 0.800 0.900 0.100
#> GSM1324900 1 0.4690 0.800 0.900 0.100
#> GSM1324901 1 0.4690 0.800 0.900 0.100
#> GSM1324905 1 0.9977 0.563 0.528 0.472
#> GSM1324906 1 0.9977 0.563 0.528 0.472
#> GSM1324907 1 0.5178 0.797 0.884 0.116
#> GSM1324911 1 0.9944 0.589 0.544 0.456
#> GSM1324912 1 0.9922 0.600 0.552 0.448
#> GSM1324913 1 0.9977 0.563 0.528 0.472
#> GSM1324917 1 0.9393 0.586 0.644 0.356
#> GSM1324918 1 0.9909 0.601 0.556 0.444
#> GSM1324919 1 0.9393 0.586 0.644 0.356
#> GSM1324923 2 0.0376 0.963 0.004 0.996
#> GSM1324924 2 0.0000 0.961 0.000 1.000
#> GSM1324925 2 0.0000 0.961 0.000 1.000
#> GSM1324929 2 0.0000 0.961 0.000 1.000
#> GSM1324930 2 0.0000 0.961 0.000 1.000
#> GSM1324931 2 0.0000 0.961 0.000 1.000
#> GSM1324935 2 0.0376 0.963 0.004 0.996
#> GSM1324936 2 0.0376 0.963 0.004 0.996
#> GSM1324937 2 0.0376 0.963 0.004 0.996
#> GSM1324941 2 0.0376 0.963 0.004 0.996
#> GSM1324942 2 0.0376 0.963 0.004 0.996
#> GSM1324943 2 0.0376 0.963 0.004 0.996
#> GSM1324947 2 0.0376 0.963 0.004 0.996
#> GSM1324948 2 0.0376 0.963 0.004 0.996
#> GSM1324949 2 0.0376 0.963 0.004 0.996
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324908 2 0.7082 0.737 0.120 0.724 0.156
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324914 2 0.5896 0.711 0.008 0.700 0.292
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324920 2 0.5896 0.711 0.008 0.700 0.292
#> GSM1324921 2 0.5896 0.711 0.008 0.700 0.292
#> GSM1324922 2 0.5896 0.711 0.008 0.700 0.292
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324938 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324950 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324951 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324952 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324905 2 0.3686 0.842 0.000 0.860 0.140
#> GSM1324906 2 0.3686 0.842 0.000 0.860 0.140
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324911 2 0.4099 0.841 0.008 0.852 0.140
#> GSM1324912 2 0.7016 0.741 0.116 0.728 0.156
#> GSM1324913 2 0.4099 0.841 0.008 0.852 0.140
#> GSM1324917 2 0.5896 0.711 0.008 0.700 0.292
#> GSM1324918 2 0.5692 0.736 0.008 0.724 0.268
#> GSM1324919 2 0.5896 0.711 0.008 0.700 0.292
#> GSM1324923 2 0.0661 0.904 0.008 0.988 0.004
#> GSM1324924 2 0.0661 0.904 0.008 0.988 0.004
#> GSM1324925 2 0.0661 0.904 0.008 0.988 0.004
#> GSM1324929 2 0.0661 0.904 0.008 0.988 0.004
#> GSM1324930 2 0.0661 0.904 0.008 0.988 0.004
#> GSM1324931 2 0.0661 0.904 0.008 0.988 0.004
#> GSM1324935 2 0.0424 0.904 0.008 0.992 0.000
#> GSM1324936 2 0.0424 0.904 0.008 0.992 0.000
#> GSM1324937 2 0.0424 0.904 0.008 0.992 0.000
#> GSM1324941 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324947 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324948 2 0.0000 0.905 0.000 1.000 0.000
#> GSM1324949 2 0.0000 0.905 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324908 4 0.5369 0.766 0.096 0.164 0 0.740
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324914 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324920 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324921 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324922 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 2 0.2216 0.866 0.000 0.908 0 0.092
#> GSM1324939 2 0.2216 0.866 0.000 0.908 0 0.092
#> GSM1324940 2 0.2216 0.866 0.000 0.908 0 0.092
#> GSM1324944 2 0.2469 0.864 0.000 0.892 0 0.108
#> GSM1324945 2 0.2469 0.864 0.000 0.892 0 0.108
#> GSM1324946 2 0.2469 0.864 0.000 0.892 0 0.108
#> GSM1324950 2 0.0000 0.846 0.000 1.000 0 0.000
#> GSM1324951 2 0.0000 0.846 0.000 1.000 0 0.000
#> GSM1324952 2 0.0000 0.846 0.000 1.000 0 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324905 4 0.4661 0.634 0.000 0.348 0 0.652
#> GSM1324906 4 0.4661 0.634 0.000 0.348 0 0.652
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0 0.000
#> GSM1324911 4 0.3444 0.754 0.000 0.184 0 0.816
#> GSM1324912 4 0.5369 0.766 0.096 0.164 0 0.740
#> GSM1324913 4 0.3444 0.754 0.000 0.184 0 0.816
#> GSM1324917 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324918 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324919 4 0.0000 0.846 0.000 0.000 0 1.000
#> GSM1324923 2 0.4193 0.790 0.000 0.732 0 0.268
#> GSM1324924 2 0.4193 0.790 0.000 0.732 0 0.268
#> GSM1324925 2 0.4193 0.790 0.000 0.732 0 0.268
#> GSM1324929 2 0.4304 0.777 0.000 0.716 0 0.284
#> GSM1324930 2 0.4304 0.777 0.000 0.716 0 0.284
#> GSM1324931 2 0.4304 0.777 0.000 0.716 0 0.284
#> GSM1324935 2 0.3942 0.815 0.000 0.764 0 0.236
#> GSM1324936 2 0.3942 0.815 0.000 0.764 0 0.236
#> GSM1324937 2 0.3942 0.815 0.000 0.764 0 0.236
#> GSM1324941 2 0.0707 0.853 0.000 0.980 0 0.020
#> GSM1324942 2 0.0707 0.853 0.000 0.980 0 0.020
#> GSM1324943 2 0.0707 0.853 0.000 0.980 0 0.020
#> GSM1324947 2 0.0000 0.846 0.000 1.000 0 0.000
#> GSM1324948 2 0.0000 0.846 0.000 1.000 0 0.000
#> GSM1324949 2 0.0000 0.846 0.000 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324908 4 0.5892 0.704 0.096 0.168 0 0.680 0.056
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.0000 0.780 0.000 0.000 0 1.000 0.000
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324920 4 0.0000 0.780 0.000 0.000 0 1.000 0.000
#> GSM1324921 4 0.0000 0.780 0.000 0.000 0 1.000 0.000
#> GSM1324922 4 0.0000 0.780 0.000 0.000 0 1.000 0.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.0290 0.759 0.000 0.992 0 0.000 0.008
#> GSM1324939 2 0.0290 0.759 0.000 0.992 0 0.000 0.008
#> GSM1324940 2 0.0290 0.759 0.000 0.992 0 0.000 0.008
#> GSM1324944 2 0.0000 0.762 0.000 1.000 0 0.000 0.000
#> GSM1324945 2 0.0162 0.763 0.000 0.996 0 0.004 0.000
#> GSM1324946 2 0.0404 0.761 0.000 0.988 0 0.012 0.000
#> GSM1324950 5 0.3636 1.000 0.000 0.272 0 0.000 0.728
#> GSM1324951 5 0.3636 1.000 0.000 0.272 0 0.000 0.728
#> GSM1324952 5 0.3636 1.000 0.000 0.272 0 0.000 0.728
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324905 4 0.5675 0.562 0.000 0.352 0 0.556 0.092
#> GSM1324906 4 0.5675 0.562 0.000 0.352 0 0.556 0.092
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.5899 0.562 0.000 0.248 0 0.592 0.160
#> GSM1324912 4 0.6401 0.689 0.096 0.176 0 0.640 0.088
#> GSM1324913 4 0.5941 0.553 0.000 0.256 0 0.584 0.160
#> GSM1324917 4 0.0162 0.780 0.000 0.004 0 0.996 0.000
#> GSM1324918 4 0.1341 0.776 0.000 0.056 0 0.944 0.000
#> GSM1324919 4 0.0000 0.780 0.000 0.000 0 1.000 0.000
#> GSM1324923 2 0.4599 0.734 0.000 0.688 0 0.040 0.272
#> GSM1324924 2 0.4452 0.740 0.000 0.696 0 0.032 0.272
#> GSM1324925 2 0.4452 0.740 0.000 0.696 0 0.032 0.272
#> GSM1324929 2 0.4452 0.740 0.000 0.696 0 0.032 0.272
#> GSM1324930 2 0.4452 0.740 0.000 0.696 0 0.032 0.272
#> GSM1324931 2 0.4452 0.740 0.000 0.696 0 0.032 0.272
#> GSM1324935 2 0.2818 0.782 0.000 0.856 0 0.012 0.132
#> GSM1324936 2 0.2583 0.782 0.000 0.864 0 0.004 0.132
#> GSM1324937 2 0.2818 0.781 0.000 0.856 0 0.012 0.132
#> GSM1324941 2 0.3109 0.495 0.000 0.800 0 0.000 0.200
#> GSM1324942 2 0.3109 0.495 0.000 0.800 0 0.000 0.200
#> GSM1324943 2 0.3109 0.495 0.000 0.800 0 0.000 0.200
#> GSM1324947 5 0.3636 1.000 0.000 0.272 0 0.000 0.728
#> GSM1324948 5 0.3636 1.000 0.000 0.272 0 0.000 0.728
#> GSM1324949 5 0.3636 1.000 0.000 0.272 0 0.000 0.728
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.3231 0.881 0.784 0.016 0 0.000 0.000 0.200
#> GSM1324897 1 0.3231 0.881 0.784 0.016 0 0.000 0.000 0.200
#> GSM1324898 1 0.3231 0.881 0.784 0.016 0 0.000 0.000 0.200
#> GSM1324902 1 0.0458 0.933 0.984 0.000 0 0.000 0.000 0.016
#> GSM1324903 1 0.0458 0.933 0.984 0.000 0 0.000 0.000 0.016
#> GSM1324904 1 0.0458 0.933 0.984 0.000 0 0.000 0.000 0.016
#> GSM1324908 4 0.5653 0.564 0.000 0.184 0 0.616 0.028 0.172
#> GSM1324909 1 0.2053 0.926 0.888 0.004 0 0.000 0.000 0.108
#> GSM1324910 1 0.2053 0.926 0.888 0.004 0 0.000 0.000 0.108
#> GSM1324914 4 0.0000 0.775 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.0146 0.931 0.996 0.000 0 0.000 0.000 0.004
#> GSM1324916 1 0.0000 0.932 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324920 4 0.0000 0.775 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324921 4 0.0000 0.775 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324922 4 0.0000 0.775 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.1866 0.850 0.000 0.908 0 0.000 0.084 0.008
#> GSM1324939 2 0.1866 0.850 0.000 0.908 0 0.000 0.084 0.008
#> GSM1324940 2 0.1866 0.850 0.000 0.908 0 0.000 0.084 0.008
#> GSM1324944 2 0.1501 0.850 0.000 0.924 0 0.000 0.076 0.000
#> GSM1324945 2 0.1501 0.850 0.000 0.924 0 0.000 0.076 0.000
#> GSM1324946 2 0.1501 0.850 0.000 0.924 0 0.000 0.076 0.000
#> GSM1324950 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 0.932 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.932 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.932 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.1556 0.932 0.920 0.000 0 0.000 0.000 0.080
#> GSM1324900 1 0.1556 0.932 0.920 0.000 0 0.000 0.000 0.080
#> GSM1324901 1 0.1556 0.932 0.920 0.000 0 0.000 0.000 0.080
#> GSM1324905 4 0.6390 0.554 0.000 0.208 0 0.540 0.192 0.060
#> GSM1324906 4 0.6390 0.554 0.000 0.208 0 0.540 0.192 0.060
#> GSM1324907 1 0.3348 0.870 0.768 0.016 0 0.000 0.000 0.216
#> GSM1324911 4 0.5628 0.479 0.000 0.240 0 0.540 0.000 0.220
#> GSM1324912 4 0.6087 0.608 0.000 0.104 0 0.608 0.116 0.172
#> GSM1324913 4 0.5628 0.482 0.000 0.240 0 0.540 0.000 0.220
#> GSM1324917 4 0.0000 0.775 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324918 4 0.1657 0.759 0.000 0.016 0 0.928 0.000 0.056
#> GSM1324919 4 0.0000 0.775 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324923 6 0.3428 0.970 0.000 0.304 0 0.000 0.000 0.696
#> GSM1324924 6 0.3371 0.979 0.000 0.292 0 0.000 0.000 0.708
#> GSM1324925 6 0.3371 0.979 0.000 0.292 0 0.000 0.000 0.708
#> GSM1324929 6 0.3390 0.980 0.000 0.296 0 0.000 0.000 0.704
#> GSM1324930 6 0.3390 0.980 0.000 0.296 0 0.000 0.000 0.704
#> GSM1324931 6 0.3390 0.980 0.000 0.296 0 0.000 0.000 0.704
#> GSM1324935 2 0.0000 0.784 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324936 2 0.0146 0.783 0.000 0.996 0 0.000 0.000 0.004
#> GSM1324937 2 0.0000 0.784 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324941 2 0.3620 0.608 0.000 0.648 0 0.000 0.352 0.000
#> GSM1324942 2 0.3620 0.608 0.000 0.648 0 0.000 0.352 0.000
#> GSM1324943 2 0.3620 0.608 0.000 0.648 0 0.000 0.352 0.000
#> GSM1324947 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 1.000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> SD:mclust 60 1.0000 3.87e-06 2
#> SD:mclust 60 0.0128 7.01e-09 3
#> SD:mclust 60 0.0332 2.98e-12 4
#> SD:mclust 57 0.1038 8.52e-16 5
#> SD:mclust 58 0.0278 4.56e-19 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 46323 rows and 60 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 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.635 0.861 0.936 0.3581 0.636 0.636
#> 3 3 0.861 0.920 0.967 0.6972 0.627 0.464
#> 4 4 0.716 0.816 0.877 0.1931 0.810 0.551
#> 5 5 0.788 0.714 0.856 0.0558 0.964 0.871
#> 6 6 0.692 0.636 0.752 0.0472 0.959 0.834
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
#> GSM1324896 1 0.0000 0.9439 1.000 0.000
#> GSM1324897 1 0.0000 0.9439 1.000 0.000
#> GSM1324898 1 0.0000 0.9439 1.000 0.000
#> GSM1324902 1 0.0000 0.9439 1.000 0.000
#> GSM1324903 1 0.0000 0.9439 1.000 0.000
#> GSM1324904 1 0.0000 0.9439 1.000 0.000
#> GSM1324908 1 0.0000 0.9439 1.000 0.000
#> GSM1324909 1 0.0000 0.9439 1.000 0.000
#> GSM1324910 1 0.0000 0.9439 1.000 0.000
#> GSM1324914 2 0.8016 0.7606 0.244 0.756
#> GSM1324915 1 0.0000 0.9439 1.000 0.000
#> GSM1324916 1 0.0000 0.9439 1.000 0.000
#> GSM1324920 1 0.9963 -0.0274 0.536 0.464
#> GSM1324921 1 0.9460 0.3530 0.636 0.364
#> GSM1324922 1 0.0938 0.9343 0.988 0.012
#> GSM1324926 2 0.0000 0.8518 0.000 1.000
#> GSM1324927 2 0.0000 0.8518 0.000 1.000
#> GSM1324928 2 0.0000 0.8518 0.000 1.000
#> GSM1324938 1 0.7299 0.7064 0.796 0.204
#> GSM1324939 1 0.9393 0.3770 0.644 0.356
#> GSM1324940 1 0.6623 0.7552 0.828 0.172
#> GSM1324944 1 0.0000 0.9439 1.000 0.000
#> GSM1324945 1 0.0000 0.9439 1.000 0.000
#> GSM1324946 1 0.0376 0.9410 0.996 0.004
#> GSM1324950 1 0.0000 0.9439 1.000 0.000
#> GSM1324951 1 0.0000 0.9439 1.000 0.000
#> GSM1324952 1 0.0000 0.9439 1.000 0.000
#> GSM1324932 2 0.0000 0.8518 0.000 1.000
#> GSM1324933 2 0.0000 0.8518 0.000 1.000
#> GSM1324934 2 0.0000 0.8518 0.000 1.000
#> GSM1324893 1 0.0000 0.9439 1.000 0.000
#> GSM1324894 1 0.0000 0.9439 1.000 0.000
#> GSM1324895 1 0.0000 0.9439 1.000 0.000
#> GSM1324899 1 0.0000 0.9439 1.000 0.000
#> GSM1324900 1 0.0000 0.9439 1.000 0.000
#> GSM1324901 1 0.0000 0.9439 1.000 0.000
#> GSM1324905 1 0.0000 0.9439 1.000 0.000
#> GSM1324906 1 0.0000 0.9439 1.000 0.000
#> GSM1324907 1 0.0000 0.9439 1.000 0.000
#> GSM1324911 1 0.0376 0.9410 0.996 0.004
#> GSM1324912 1 0.0000 0.9439 1.000 0.000
#> GSM1324913 1 0.4161 0.8636 0.916 0.084
#> GSM1324917 2 0.6148 0.8546 0.152 0.848
#> GSM1324918 2 0.6712 0.8498 0.176 0.824
#> GSM1324919 2 0.7219 0.8330 0.200 0.800
#> GSM1324923 1 0.6623 0.7554 0.828 0.172
#> GSM1324924 1 0.8386 0.5897 0.732 0.268
#> GSM1324925 2 0.9608 0.4985 0.384 0.616
#> GSM1324929 2 0.6973 0.8448 0.188 0.812
#> GSM1324930 2 0.6973 0.8448 0.188 0.812
#> GSM1324931 2 0.6973 0.8448 0.188 0.812
#> GSM1324935 1 0.0000 0.9439 1.000 0.000
#> GSM1324936 1 0.0000 0.9439 1.000 0.000
#> GSM1324937 1 0.0000 0.9439 1.000 0.000
#> GSM1324941 1 0.0000 0.9439 1.000 0.000
#> GSM1324942 1 0.0000 0.9439 1.000 0.000
#> GSM1324943 1 0.0000 0.9439 1.000 0.000
#> GSM1324947 1 0.0000 0.9439 1.000 0.000
#> GSM1324948 1 0.0000 0.9439 1.000 0.000
#> GSM1324949 1 0.0000 0.9439 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324897 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324898 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324902 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324903 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324904 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324908 1 0.5098 0.610 0.752 0.248 0.000
#> GSM1324909 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324910 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324914 3 0.3551 0.829 0.000 0.132 0.868
#> GSM1324915 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324916 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324920 2 0.4291 0.751 0.000 0.820 0.180
#> GSM1324921 2 0.3267 0.845 0.000 0.884 0.116
#> GSM1324922 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324926 3 0.0000 0.878 0.000 0.000 1.000
#> GSM1324927 3 0.0000 0.878 0.000 0.000 1.000
#> GSM1324928 3 0.0000 0.878 0.000 0.000 1.000
#> GSM1324938 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324950 2 0.0424 0.961 0.008 0.992 0.000
#> GSM1324951 2 0.2448 0.891 0.076 0.924 0.000
#> GSM1324952 2 0.5497 0.574 0.292 0.708 0.000
#> GSM1324932 3 0.0000 0.878 0.000 0.000 1.000
#> GSM1324933 3 0.0000 0.878 0.000 0.000 1.000
#> GSM1324934 3 0.0000 0.878 0.000 0.000 1.000
#> GSM1324893 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324894 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324895 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324899 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324900 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324901 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324905 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324906 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324907 1 0.0000 0.981 1.000 0.000 0.000
#> GSM1324911 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324912 1 0.0237 0.976 0.996 0.004 0.000
#> GSM1324913 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324917 3 0.4002 0.817 0.000 0.160 0.840
#> GSM1324918 3 0.6299 0.180 0.000 0.476 0.524
#> GSM1324919 3 0.4002 0.817 0.000 0.160 0.840
#> GSM1324923 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324924 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324925 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324929 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324930 2 0.0237 0.964 0.000 0.996 0.004
#> GSM1324931 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324935 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324941 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.967 0.000 1.000 0.000
#> GSM1324947 2 0.3192 0.848 0.112 0.888 0.000
#> GSM1324948 2 0.0592 0.958 0.012 0.988 0.000
#> GSM1324949 2 0.0592 0.958 0.012 0.988 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.2216 0.9115 0.908 0.000 0.000 0.092
#> GSM1324897 1 0.2216 0.9115 0.908 0.000 0.000 0.092
#> GSM1324898 1 0.2401 0.9087 0.904 0.004 0.000 0.092
#> GSM1324902 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324903 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324904 1 0.0336 0.9624 0.992 0.000 0.000 0.008
#> GSM1324908 4 0.5184 0.6756 0.212 0.056 0.000 0.732
#> GSM1324909 1 0.0592 0.9578 0.984 0.000 0.000 0.016
#> GSM1324910 1 0.0592 0.9578 0.984 0.000 0.000 0.016
#> GSM1324914 4 0.4399 0.6348 0.000 0.016 0.224 0.760
#> GSM1324915 1 0.0921 0.9590 0.972 0.000 0.000 0.028
#> GSM1324916 1 0.0707 0.9583 0.980 0.000 0.000 0.020
#> GSM1324920 4 0.3947 0.7740 0.076 0.072 0.004 0.848
#> GSM1324921 4 0.3928 0.7695 0.088 0.060 0.004 0.848
#> GSM1324922 4 0.3679 0.7317 0.140 0.016 0.004 0.840
#> GSM1324926 3 0.0707 0.9852 0.000 0.000 0.980 0.020
#> GSM1324927 3 0.0817 0.9866 0.000 0.000 0.976 0.024
#> GSM1324928 3 0.0817 0.9866 0.000 0.000 0.976 0.024
#> GSM1324938 2 0.0336 0.8585 0.000 0.992 0.000 0.008
#> GSM1324939 2 0.0592 0.8578 0.000 0.984 0.000 0.016
#> GSM1324940 2 0.0336 0.8589 0.000 0.992 0.000 0.008
#> GSM1324944 2 0.0592 0.8573 0.000 0.984 0.000 0.016
#> GSM1324945 2 0.0707 0.8560 0.000 0.980 0.000 0.020
#> GSM1324946 2 0.0921 0.8518 0.000 0.972 0.000 0.028
#> GSM1324950 2 0.3606 0.7904 0.020 0.840 0.000 0.140
#> GSM1324951 2 0.3907 0.7818 0.032 0.828 0.000 0.140
#> GSM1324952 2 0.4257 0.7659 0.048 0.812 0.000 0.140
#> GSM1324932 3 0.0469 0.9871 0.000 0.000 0.988 0.012
#> GSM1324933 3 0.0469 0.9871 0.000 0.000 0.988 0.012
#> GSM1324934 3 0.0469 0.9871 0.000 0.000 0.988 0.012
#> GSM1324893 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324894 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324895 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324899 1 0.0188 0.9628 0.996 0.000 0.000 0.004
#> GSM1324900 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324901 1 0.0469 0.9629 0.988 0.000 0.000 0.012
#> GSM1324905 4 0.3764 0.7187 0.000 0.216 0.000 0.784
#> GSM1324906 4 0.3837 0.7191 0.000 0.224 0.000 0.776
#> GSM1324907 1 0.3324 0.8592 0.852 0.012 0.000 0.136
#> GSM1324911 4 0.4040 0.7566 0.000 0.248 0.000 0.752
#> GSM1324912 4 0.5085 0.4809 0.304 0.020 0.000 0.676
#> GSM1324913 4 0.4040 0.7566 0.000 0.248 0.000 0.752
#> GSM1324917 4 0.4492 0.7667 0.040 0.068 0.056 0.836
#> GSM1324918 4 0.3900 0.7732 0.000 0.164 0.020 0.816
#> GSM1324919 4 0.4476 0.7606 0.076 0.044 0.044 0.836
#> GSM1324923 2 0.4477 0.4374 0.000 0.688 0.000 0.312
#> GSM1324924 2 0.4406 0.4621 0.000 0.700 0.000 0.300
#> GSM1324925 4 0.4564 0.6389 0.000 0.328 0.000 0.672
#> GSM1324929 4 0.6716 0.5779 0.000 0.320 0.112 0.568
#> GSM1324930 4 0.7504 0.4406 0.000 0.344 0.192 0.464
#> GSM1324931 2 0.7203 0.0868 0.000 0.524 0.164 0.312
#> GSM1324935 2 0.1474 0.8377 0.000 0.948 0.000 0.052
#> GSM1324936 2 0.0921 0.8537 0.000 0.972 0.000 0.028
#> GSM1324937 2 0.0817 0.8554 0.000 0.976 0.000 0.024
#> GSM1324941 2 0.0592 0.8580 0.000 0.984 0.000 0.016
#> GSM1324942 2 0.0469 0.8576 0.000 0.988 0.000 0.012
#> GSM1324943 2 0.0336 0.8580 0.000 0.992 0.000 0.008
#> GSM1324947 2 0.3999 0.7785 0.036 0.824 0.000 0.140
#> GSM1324948 2 0.3335 0.8006 0.016 0.856 0.000 0.128
#> GSM1324949 2 0.3441 0.8011 0.024 0.856 0.000 0.120
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 5 0.4262 0.7511 0.440 0.000 0.000 0.000 0.560
#> GSM1324897 5 0.4307 0.6490 0.496 0.000 0.000 0.000 0.504
#> GSM1324898 1 0.4305 -0.7363 0.512 0.000 0.000 0.000 0.488
#> GSM1324902 1 0.0290 0.7935 0.992 0.000 0.000 0.000 0.008
#> GSM1324903 1 0.0703 0.7902 0.976 0.000 0.000 0.000 0.024
#> GSM1324904 1 0.0290 0.7946 0.992 0.000 0.000 0.000 0.008
#> GSM1324908 4 0.2838 0.7659 0.072 0.008 0.000 0.884 0.036
#> GSM1324909 1 0.3274 0.4600 0.780 0.000 0.000 0.000 0.220
#> GSM1324910 1 0.3395 0.4177 0.764 0.000 0.000 0.000 0.236
#> GSM1324914 4 0.4068 0.6571 0.000 0.004 0.144 0.792 0.060
#> GSM1324915 1 0.4216 0.4498 0.720 0.008 0.000 0.012 0.260
#> GSM1324916 1 0.2295 0.7459 0.900 0.008 0.000 0.004 0.088
#> GSM1324920 4 0.1200 0.7840 0.012 0.008 0.000 0.964 0.016
#> GSM1324921 4 0.1200 0.7840 0.012 0.008 0.000 0.964 0.016
#> GSM1324922 4 0.4312 0.6747 0.156 0.008 0.000 0.776 0.060
#> GSM1324926 3 0.2293 0.8396 0.000 0.000 0.900 0.016 0.084
#> GSM1324927 3 0.2046 0.8454 0.000 0.000 0.916 0.016 0.068
#> GSM1324928 3 0.2046 0.8454 0.000 0.000 0.916 0.016 0.068
#> GSM1324938 2 0.0324 0.9045 0.000 0.992 0.000 0.004 0.004
#> GSM1324939 2 0.0324 0.9045 0.000 0.992 0.000 0.004 0.004
#> GSM1324940 2 0.0451 0.9041 0.000 0.988 0.000 0.004 0.008
#> GSM1324944 2 0.1041 0.9001 0.000 0.964 0.000 0.032 0.004
#> GSM1324945 2 0.1571 0.8858 0.000 0.936 0.000 0.060 0.004
#> GSM1324946 2 0.1124 0.8989 0.000 0.960 0.000 0.036 0.004
#> GSM1324950 2 0.1410 0.8942 0.000 0.940 0.000 0.000 0.060
#> GSM1324951 2 0.1965 0.8776 0.000 0.904 0.000 0.000 0.096
#> GSM1324952 2 0.3689 0.7186 0.004 0.740 0.000 0.000 0.256
#> GSM1324932 3 0.0162 0.8474 0.000 0.000 0.996 0.000 0.004
#> GSM1324933 3 0.0000 0.8478 0.000 0.000 1.000 0.000 0.000
#> GSM1324934 3 0.0162 0.8474 0.000 0.000 0.996 0.000 0.004
#> GSM1324893 1 0.1121 0.7806 0.956 0.000 0.000 0.000 0.044
#> GSM1324894 1 0.1121 0.7806 0.956 0.000 0.000 0.000 0.044
#> GSM1324895 1 0.1043 0.7834 0.960 0.000 0.000 0.000 0.040
#> GSM1324899 1 0.1270 0.7741 0.948 0.000 0.000 0.000 0.052
#> GSM1324900 1 0.0794 0.7930 0.972 0.000 0.000 0.000 0.028
#> GSM1324901 1 0.0609 0.7915 0.980 0.000 0.000 0.000 0.020
#> GSM1324905 4 0.5104 0.6362 0.000 0.068 0.000 0.648 0.284
#> GSM1324906 4 0.5062 0.6431 0.000 0.068 0.000 0.656 0.276
#> GSM1324907 5 0.3949 0.6648 0.300 0.004 0.000 0.000 0.696
#> GSM1324911 4 0.1915 0.7840 0.000 0.040 0.000 0.928 0.032
#> GSM1324912 4 0.6097 0.2727 0.096 0.008 0.000 0.476 0.420
#> GSM1324913 4 0.1907 0.7835 0.000 0.044 0.000 0.928 0.028
#> GSM1324917 4 0.0854 0.7838 0.004 0.008 0.012 0.976 0.000
#> GSM1324918 4 0.0609 0.7823 0.000 0.020 0.000 0.980 0.000
#> GSM1324919 4 0.0865 0.7849 0.024 0.004 0.000 0.972 0.000
#> GSM1324923 2 0.3730 0.6320 0.000 0.712 0.000 0.288 0.000
#> GSM1324924 2 0.3662 0.6849 0.000 0.744 0.000 0.252 0.004
#> GSM1324925 4 0.4047 0.4517 0.000 0.320 0.000 0.676 0.004
#> GSM1324929 4 0.6002 0.0760 0.000 0.116 0.392 0.492 0.000
#> GSM1324930 3 0.6756 -0.0411 0.000 0.264 0.372 0.364 0.000
#> GSM1324931 2 0.6330 0.3191 0.000 0.528 0.236 0.236 0.000
#> GSM1324935 2 0.0865 0.9017 0.000 0.972 0.000 0.004 0.024
#> GSM1324936 2 0.0771 0.9026 0.000 0.976 0.000 0.004 0.020
#> GSM1324937 2 0.0955 0.9005 0.000 0.968 0.000 0.004 0.028
#> GSM1324941 2 0.1638 0.8954 0.000 0.932 0.000 0.004 0.064
#> GSM1324942 2 0.1205 0.9025 0.000 0.956 0.000 0.004 0.040
#> GSM1324943 2 0.1124 0.9031 0.000 0.960 0.000 0.004 0.036
#> GSM1324947 2 0.1197 0.8989 0.000 0.952 0.000 0.000 0.048
#> GSM1324948 2 0.1043 0.9022 0.000 0.960 0.000 0.000 0.040
#> GSM1324949 2 0.0963 0.9016 0.000 0.964 0.000 0.000 0.036
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 5 0.3717 0.6521 0.384 0.000 0.000 0.000 0.616 0.000
#> GSM1324897 5 0.3810 0.6247 0.428 0.000 0.000 0.000 0.572 0.000
#> GSM1324898 5 0.3833 0.5989 0.444 0.000 0.000 0.000 0.556 0.000
#> GSM1324902 1 0.0790 0.7872 0.968 0.000 0.000 0.000 0.032 0.000
#> GSM1324903 1 0.0547 0.7889 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM1324904 1 0.1007 0.7858 0.956 0.000 0.000 0.000 0.044 0.000
#> GSM1324908 4 0.2881 0.5934 0.084 0.004 0.000 0.868 0.012 0.032
#> GSM1324909 1 0.2762 0.6000 0.804 0.000 0.000 0.000 0.196 0.000
#> GSM1324910 1 0.2793 0.5948 0.800 0.000 0.000 0.000 0.200 0.000
#> GSM1324914 4 0.6946 0.1506 0.000 0.000 0.356 0.360 0.064 0.220
#> GSM1324915 5 0.7530 0.2338 0.256 0.000 0.264 0.000 0.332 0.148
#> GSM1324916 1 0.7072 -0.2026 0.436 0.000 0.192 0.000 0.268 0.104
#> GSM1324920 4 0.3618 0.5884 0.000 0.000 0.000 0.768 0.040 0.192
#> GSM1324921 4 0.3490 0.5960 0.000 0.000 0.000 0.784 0.040 0.176
#> GSM1324922 4 0.5535 0.5099 0.048 0.000 0.004 0.648 0.088 0.212
#> GSM1324926 3 0.1845 0.6827 0.000 0.000 0.920 0.000 0.028 0.052
#> GSM1324927 3 0.0000 0.7433 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1324928 3 0.0363 0.7475 0.000 0.000 0.988 0.000 0.000 0.012
#> GSM1324938 2 0.1349 0.8094 0.000 0.940 0.000 0.000 0.004 0.056
#> GSM1324939 2 0.1493 0.8081 0.000 0.936 0.000 0.004 0.004 0.056
#> GSM1324940 2 0.1542 0.8093 0.000 0.936 0.004 0.000 0.008 0.052
#> GSM1324944 2 0.2705 0.7921 0.000 0.872 0.000 0.072 0.004 0.052
#> GSM1324945 2 0.2978 0.7840 0.000 0.856 0.000 0.084 0.008 0.052
#> GSM1324946 2 0.2760 0.7898 0.000 0.868 0.000 0.076 0.004 0.052
#> GSM1324950 2 0.2553 0.7928 0.000 0.848 0.000 0.000 0.144 0.008
#> GSM1324951 2 0.2969 0.7432 0.000 0.776 0.000 0.000 0.224 0.000
#> GSM1324952 2 0.3756 0.6029 0.004 0.644 0.000 0.000 0.352 0.000
#> GSM1324932 3 0.3650 0.7241 0.000 0.000 0.708 0.000 0.012 0.280
#> GSM1324933 3 0.3650 0.7241 0.000 0.000 0.708 0.000 0.012 0.280
#> GSM1324934 3 0.3650 0.7241 0.000 0.000 0.708 0.000 0.012 0.280
#> GSM1324893 1 0.1265 0.7656 0.948 0.000 0.000 0.000 0.044 0.008
#> GSM1324894 1 0.1124 0.7714 0.956 0.000 0.000 0.000 0.036 0.008
#> GSM1324895 1 0.1196 0.7708 0.952 0.000 0.000 0.000 0.040 0.008
#> GSM1324899 1 0.2053 0.7502 0.888 0.000 0.000 0.000 0.108 0.004
#> GSM1324900 1 0.1970 0.7618 0.900 0.000 0.000 0.000 0.092 0.008
#> GSM1324901 1 0.2006 0.7482 0.892 0.000 0.000 0.000 0.104 0.004
#> GSM1324905 4 0.5196 0.4530 0.000 0.068 0.000 0.600 0.312 0.020
#> GSM1324906 4 0.5297 0.4411 0.000 0.068 0.000 0.588 0.320 0.024
#> GSM1324907 5 0.3543 0.5910 0.272 0.004 0.000 0.000 0.720 0.004
#> GSM1324911 4 0.2051 0.6074 0.000 0.040 0.000 0.916 0.008 0.036
#> GSM1324912 4 0.6142 0.3780 0.052 0.028 0.000 0.516 0.360 0.044
#> GSM1324913 4 0.1980 0.6086 0.000 0.036 0.000 0.920 0.008 0.036
#> GSM1324917 4 0.2313 0.6019 0.004 0.000 0.000 0.884 0.012 0.100
#> GSM1324918 4 0.1753 0.6059 0.000 0.000 0.000 0.912 0.004 0.084
#> GSM1324919 4 0.2781 0.6011 0.008 0.000 0.000 0.860 0.024 0.108
#> GSM1324923 2 0.6030 0.0393 0.000 0.508 0.000 0.220 0.012 0.260
#> GSM1324924 2 0.5785 0.1371 0.000 0.544 0.000 0.196 0.008 0.252
#> GSM1324925 4 0.6067 -0.1694 0.000 0.276 0.000 0.480 0.008 0.236
#> GSM1324929 6 0.6615 0.7760 0.000 0.044 0.232 0.264 0.000 0.460
#> GSM1324930 6 0.6764 0.8104 0.000 0.072 0.228 0.220 0.000 0.480
#> GSM1324931 6 0.7193 0.7086 0.000 0.204 0.172 0.172 0.000 0.452
#> GSM1324935 2 0.2373 0.7925 0.000 0.888 0.000 0.004 0.024 0.084
#> GSM1324936 2 0.2002 0.7991 0.000 0.908 0.000 0.004 0.012 0.076
#> GSM1324937 2 0.2095 0.7973 0.000 0.904 0.000 0.004 0.016 0.076
#> GSM1324941 2 0.3083 0.8038 0.000 0.860 0.000 0.052 0.060 0.028
#> GSM1324942 2 0.1700 0.8187 0.000 0.936 0.000 0.012 0.028 0.024
#> GSM1324943 2 0.1620 0.8186 0.000 0.940 0.000 0.012 0.024 0.024
#> GSM1324947 2 0.2664 0.7795 0.000 0.816 0.000 0.000 0.184 0.000
#> GSM1324948 2 0.2378 0.7946 0.000 0.848 0.000 0.000 0.152 0.000
#> GSM1324949 2 0.1958 0.8111 0.000 0.896 0.000 0.000 0.100 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 agent(p) individual(p) k
#> SD:NMF 56 0.8831 6.05e-05 2
#> SD:NMF 59 0.0900 3.54e-08 3
#> SD:NMF 55 0.0635 2.15e-10 4
#> SD:NMF 51 0.1233 6.44e-12 5
#> SD:NMF 51 0.0735 7.00e-18 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.1839 0.817 0.817
#> 3 3 0.766 0.828 0.929 2.0039 0.645 0.565
#> 4 4 0.735 0.835 0.844 0.1953 0.858 0.692
#> 5 5 0.777 0.825 0.879 0.1546 0.917 0.740
#> 6 6 0.803 0.834 0.836 0.0529 0.915 0.661
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
#> GSM1324896 1 0 1 1 0
#> GSM1324897 1 0 1 1 0
#> GSM1324898 1 0 1 1 0
#> GSM1324902 1 0 1 1 0
#> GSM1324903 1 0 1 1 0
#> GSM1324904 1 0 1 1 0
#> GSM1324908 1 0 1 1 0
#> GSM1324909 1 0 1 1 0
#> GSM1324910 1 0 1 1 0
#> GSM1324914 1 0 1 1 0
#> GSM1324915 1 0 1 1 0
#> GSM1324916 1 0 1 1 0
#> GSM1324920 1 0 1 1 0
#> GSM1324921 1 0 1 1 0
#> GSM1324922 1 0 1 1 0
#> GSM1324926 2 0 1 0 1
#> GSM1324927 2 0 1 0 1
#> GSM1324928 2 0 1 0 1
#> GSM1324938 1 0 1 1 0
#> GSM1324939 1 0 1 1 0
#> GSM1324940 1 0 1 1 0
#> GSM1324944 1 0 1 1 0
#> GSM1324945 1 0 1 1 0
#> GSM1324946 1 0 1 1 0
#> GSM1324950 1 0 1 1 0
#> GSM1324951 1 0 1 1 0
#> GSM1324952 1 0 1 1 0
#> GSM1324932 2 0 1 0 1
#> GSM1324933 2 0 1 0 1
#> GSM1324934 2 0 1 0 1
#> GSM1324893 1 0 1 1 0
#> GSM1324894 1 0 1 1 0
#> GSM1324895 1 0 1 1 0
#> GSM1324899 1 0 1 1 0
#> GSM1324900 1 0 1 1 0
#> GSM1324901 1 0 1 1 0
#> GSM1324905 1 0 1 1 0
#> GSM1324906 1 0 1 1 0
#> GSM1324907 1 0 1 1 0
#> GSM1324911 1 0 1 1 0
#> GSM1324912 1 0 1 1 0
#> GSM1324913 1 0 1 1 0
#> GSM1324917 1 0 1 1 0
#> GSM1324918 1 0 1 1 0
#> GSM1324919 1 0 1 1 0
#> GSM1324923 1 0 1 1 0
#> GSM1324924 1 0 1 1 0
#> GSM1324925 1 0 1 1 0
#> GSM1324929 1 0 1 1 0
#> GSM1324930 1 0 1 1 0
#> GSM1324931 1 0 1 1 0
#> GSM1324935 1 0 1 1 0
#> GSM1324936 1 0 1 1 0
#> GSM1324937 1 0 1 1 0
#> GSM1324941 1 0 1 1 0
#> GSM1324942 1 0 1 1 0
#> GSM1324943 1 0 1 1 0
#> GSM1324947 1 0 1 1 0
#> GSM1324948 1 0 1 1 0
#> GSM1324949 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.935 1.000 0.000 0
#> GSM1324897 1 0.0000 0.935 1.000 0.000 0
#> GSM1324898 1 0.0000 0.935 1.000 0.000 0
#> GSM1324902 1 0.0000 0.935 1.000 0.000 0
#> GSM1324903 1 0.0000 0.935 1.000 0.000 0
#> GSM1324904 1 0.0000 0.935 1.000 0.000 0
#> GSM1324908 2 0.0592 0.872 0.012 0.988 0
#> GSM1324909 1 0.0000 0.935 1.000 0.000 0
#> GSM1324910 1 0.0000 0.935 1.000 0.000 0
#> GSM1324914 2 0.2165 0.841 0.064 0.936 0
#> GSM1324915 1 0.5835 0.388 0.660 0.340 0
#> GSM1324916 1 0.5835 0.388 0.660 0.340 0
#> GSM1324920 2 0.0000 0.882 0.000 1.000 0
#> GSM1324921 2 0.0000 0.882 0.000 1.000 0
#> GSM1324922 2 0.0000 0.882 0.000 1.000 0
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1
#> GSM1324938 2 0.0000 0.882 0.000 1.000 0
#> GSM1324939 2 0.0000 0.882 0.000 1.000 0
#> GSM1324940 2 0.0000 0.882 0.000 1.000 0
#> GSM1324944 2 0.0000 0.882 0.000 1.000 0
#> GSM1324945 2 0.0000 0.882 0.000 1.000 0
#> GSM1324946 2 0.0000 0.882 0.000 1.000 0
#> GSM1324950 2 0.6079 0.468 0.388 0.612 0
#> GSM1324951 2 0.6079 0.468 0.388 0.612 0
#> GSM1324952 2 0.6079 0.468 0.388 0.612 0
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1
#> GSM1324893 1 0.0000 0.935 1.000 0.000 0
#> GSM1324894 1 0.0000 0.935 1.000 0.000 0
#> GSM1324895 1 0.0000 0.935 1.000 0.000 0
#> GSM1324899 1 0.0000 0.935 1.000 0.000 0
#> GSM1324900 1 0.0000 0.935 1.000 0.000 0
#> GSM1324901 1 0.0000 0.935 1.000 0.000 0
#> GSM1324905 2 0.0000 0.882 0.000 1.000 0
#> GSM1324906 2 0.0000 0.882 0.000 1.000 0
#> GSM1324907 1 0.0000 0.935 1.000 0.000 0
#> GSM1324911 2 0.0000 0.882 0.000 1.000 0
#> GSM1324912 2 0.0000 0.882 0.000 1.000 0
#> GSM1324913 2 0.0000 0.882 0.000 1.000 0
#> GSM1324917 2 0.0000 0.882 0.000 1.000 0
#> GSM1324918 2 0.0000 0.882 0.000 1.000 0
#> GSM1324919 2 0.0000 0.882 0.000 1.000 0
#> GSM1324923 2 0.0000 0.882 0.000 1.000 0
#> GSM1324924 2 0.0000 0.882 0.000 1.000 0
#> GSM1324925 2 0.0000 0.882 0.000 1.000 0
#> GSM1324929 2 0.0000 0.882 0.000 1.000 0
#> GSM1324930 2 0.0000 0.882 0.000 1.000 0
#> GSM1324931 2 0.0000 0.882 0.000 1.000 0
#> GSM1324935 2 0.0000 0.882 0.000 1.000 0
#> GSM1324936 2 0.0000 0.882 0.000 1.000 0
#> GSM1324937 2 0.0000 0.882 0.000 1.000 0
#> GSM1324941 2 0.6079 0.468 0.388 0.612 0
#> GSM1324942 2 0.6079 0.468 0.388 0.612 0
#> GSM1324943 2 0.6079 0.468 0.388 0.612 0
#> GSM1324947 2 0.6079 0.468 0.388 0.612 0
#> GSM1324948 2 0.6079 0.468 0.388 0.612 0
#> GSM1324949 2 0.6079 0.468 0.388 0.612 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324897 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324898 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324902 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324903 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324904 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324908 4 0.421 0.710 0.012 0.216 0 0.772
#> GSM1324909 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324910 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324914 4 0.487 0.163 0.000 0.404 0 0.596
#> GSM1324915 1 0.487 0.558 0.596 0.404 0 0.000
#> GSM1324916 1 0.487 0.558 0.596 0.404 0 0.000
#> GSM1324920 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324921 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324922 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1 0.000
#> GSM1324938 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324939 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324940 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324944 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324945 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324946 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324950 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324951 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324952 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324932 3 0.000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324894 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324895 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324899 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324900 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324901 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324905 4 0.376 0.717 0.000 0.216 0 0.784
#> GSM1324906 4 0.376 0.717 0.000 0.216 0 0.784
#> GSM1324907 1 0.000 0.953 1.000 0.000 0 0.000
#> GSM1324911 4 0.376 0.717 0.000 0.216 0 0.784
#> GSM1324912 4 0.376 0.717 0.000 0.216 0 0.784
#> GSM1324913 4 0.376 0.717 0.000 0.216 0 0.784
#> GSM1324917 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324918 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324919 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324923 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324924 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324925 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324929 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324930 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324931 4 0.000 0.748 0.000 0.000 0 1.000
#> GSM1324935 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324936 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324937 4 0.404 0.692 0.000 0.248 0 0.752
#> GSM1324941 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324942 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324943 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324947 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324948 2 0.445 1.000 0.000 0.692 0 0.308
#> GSM1324949 2 0.445 1.000 0.000 0.692 0 0.308
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324908 4 0.588 0.821 0.012 0.096 0 0.596 0.296
#> GSM1324909 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.424 -0.112 0.000 0.428 0 0.572 0.000
#> GSM1324915 1 0.419 0.563 0.596 0.000 0 0.404 0.000
#> GSM1324916 1 0.419 0.563 0.596 0.000 0 0.404 0.000
#> GSM1324920 2 0.281 0.647 0.000 0.832 0 0.168 0.000
#> GSM1324921 2 0.281 0.647 0.000 0.832 0 0.168 0.000
#> GSM1324922 2 0.281 0.647 0.000 0.832 0 0.168 0.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.348 0.701 0.000 0.752 0 0.000 0.248
#> GSM1324939 2 0.348 0.701 0.000 0.752 0 0.000 0.248
#> GSM1324940 2 0.348 0.701 0.000 0.752 0 0.000 0.248
#> GSM1324944 2 0.410 0.554 0.000 0.628 0 0.000 0.372
#> GSM1324945 2 0.410 0.554 0.000 0.628 0 0.000 0.372
#> GSM1324946 2 0.410 0.554 0.000 0.628 0 0.000 0.372
#> GSM1324950 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324951 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324952 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324932 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324905 4 0.557 0.835 0.000 0.096 0 0.596 0.308
#> GSM1324906 4 0.557 0.835 0.000 0.096 0 0.596 0.308
#> GSM1324907 1 0.000 0.954 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.557 0.835 0.000 0.096 0 0.596 0.308
#> GSM1324912 4 0.557 0.835 0.000 0.096 0 0.596 0.308
#> GSM1324913 4 0.557 0.835 0.000 0.096 0 0.596 0.308
#> GSM1324917 2 0.281 0.647 0.000 0.832 0 0.168 0.000
#> GSM1324918 2 0.281 0.647 0.000 0.832 0 0.168 0.000
#> GSM1324919 2 0.281 0.647 0.000 0.832 0 0.168 0.000
#> GSM1324923 2 0.000 0.742 0.000 1.000 0 0.000 0.000
#> GSM1324924 2 0.000 0.742 0.000 1.000 0 0.000 0.000
#> GSM1324925 2 0.000 0.742 0.000 1.000 0 0.000 0.000
#> GSM1324929 2 0.000 0.742 0.000 1.000 0 0.000 0.000
#> GSM1324930 2 0.000 0.742 0.000 1.000 0 0.000 0.000
#> GSM1324931 2 0.000 0.742 0.000 1.000 0 0.000 0.000
#> GSM1324935 2 0.348 0.701 0.000 0.752 0 0.000 0.248
#> GSM1324936 2 0.348 0.701 0.000 0.752 0 0.000 0.248
#> GSM1324937 2 0.348 0.701 0.000 0.752 0 0.000 0.248
#> GSM1324941 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324942 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324943 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324947 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324948 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324949 5 0.000 1.000 0.000 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.0363 0.993 0.988 0.000 0 0.000 0.012 0.000
#> GSM1324903 1 0.0363 0.993 0.988 0.000 0 0.000 0.012 0.000
#> GSM1324904 1 0.0363 0.993 0.988 0.000 0 0.000 0.012 0.000
#> GSM1324908 6 0.0363 0.978 0.012 0.000 0 0.000 0.000 0.988
#> GSM1324909 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.2964 0.563 0.000 0.004 0 0.792 0.204 0.000
#> GSM1324915 5 0.5900 -0.255 0.384 0.000 0 0.204 0.412 0.000
#> GSM1324916 5 0.5900 -0.255 0.384 0.000 0 0.204 0.412 0.000
#> GSM1324920 4 0.3354 0.925 0.000 0.168 0 0.796 0.000 0.036
#> GSM1324921 4 0.3354 0.925 0.000 0.168 0 0.796 0.000 0.036
#> GSM1324922 4 0.3354 0.925 0.000 0.168 0 0.796 0.000 0.036
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.0000 0.790 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324939 2 0.0000 0.790 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324940 2 0.0000 0.790 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324944 2 0.2092 0.695 0.000 0.876 0 0.000 0.000 0.124
#> GSM1324945 2 0.2092 0.695 0.000 0.876 0 0.000 0.000 0.124
#> GSM1324946 2 0.2092 0.695 0.000 0.876 0 0.000 0.000 0.124
#> GSM1324950 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324951 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324952 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0363 0.993 0.988 0.000 0 0.000 0.012 0.000
#> GSM1324894 1 0.0363 0.993 0.988 0.000 0 0.000 0.012 0.000
#> GSM1324895 1 0.0363 0.993 0.988 0.000 0 0.000 0.012 0.000
#> GSM1324899 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324905 6 0.0000 0.996 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324906 6 0.0000 0.996 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324907 1 0.0000 0.995 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324911 6 0.0000 0.996 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324912 6 0.0000 0.996 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324913 6 0.0000 0.996 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324917 4 0.3354 0.925 0.000 0.168 0 0.796 0.000 0.036
#> GSM1324918 4 0.3354 0.925 0.000 0.168 0 0.796 0.000 0.036
#> GSM1324919 4 0.3354 0.925 0.000 0.168 0 0.796 0.000 0.036
#> GSM1324923 2 0.3126 0.654 0.000 0.752 0 0.248 0.000 0.000
#> GSM1324924 2 0.3126 0.654 0.000 0.752 0 0.248 0.000 0.000
#> GSM1324925 2 0.3126 0.654 0.000 0.752 0 0.248 0.000 0.000
#> GSM1324929 2 0.3126 0.654 0.000 0.752 0 0.248 0.000 0.000
#> GSM1324930 2 0.3126 0.654 0.000 0.752 0 0.248 0.000 0.000
#> GSM1324931 2 0.3126 0.654 0.000 0.752 0 0.248 0.000 0.000
#> GSM1324935 2 0.0000 0.790 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324936 2 0.0000 0.790 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324937 2 0.0000 0.790 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324941 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324942 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324943 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324947 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324948 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
#> GSM1324949 5 0.5375 0.760 0.000 0.208 0 0.000 0.588 0.204
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 agent(p) individual(p) k
#> CV:hclust 60 0.0314 3.87e-06 2
#> CV:hclust 49 0.0255 1.30e-07 3
#> CV:hclust 59 0.0252 4.28e-13 4
#> CV:hclust 59 0.0313 1.12e-15 5
#> CV:hclust 58 0.0642 5.70e-19 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 46323 rows and 60 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 0.286 0.875 0.882 0.4506 0.492 0.492
#> 3 3 0.794 0.897 0.945 0.2407 0.618 0.427
#> 4 4 0.698 0.785 0.859 0.2462 0.814 0.596
#> 5 5 0.700 0.704 0.799 0.0960 1.000 1.000
#> 6 6 0.709 0.651 0.735 0.0537 0.932 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
#> GSM1324896 1 0.000 0.933 1.000 0.000
#> GSM1324897 1 0.000 0.933 1.000 0.000
#> GSM1324898 1 0.000 0.933 1.000 0.000
#> GSM1324902 1 0.000 0.933 1.000 0.000
#> GSM1324903 1 0.000 0.933 1.000 0.000
#> GSM1324904 1 0.000 0.933 1.000 0.000
#> GSM1324908 1 0.775 0.682 0.772 0.228
#> GSM1324909 1 0.000 0.933 1.000 0.000
#> GSM1324910 1 0.000 0.933 1.000 0.000
#> GSM1324914 2 0.730 0.878 0.204 0.796
#> GSM1324915 1 0.000 0.933 1.000 0.000
#> GSM1324916 1 0.000 0.933 1.000 0.000
#> GSM1324920 2 0.730 0.878 0.204 0.796
#> GSM1324921 2 0.730 0.878 0.204 0.796
#> GSM1324922 2 0.802 0.863 0.244 0.756
#> GSM1324926 2 0.482 0.740 0.104 0.896
#> GSM1324927 2 0.482 0.740 0.104 0.896
#> GSM1324928 2 0.482 0.740 0.104 0.896
#> GSM1324938 2 0.706 0.877 0.192 0.808
#> GSM1324939 2 0.706 0.877 0.192 0.808
#> GSM1324940 2 0.706 0.877 0.192 0.808
#> GSM1324944 2 0.839 0.827 0.268 0.732
#> GSM1324945 2 0.839 0.827 0.268 0.732
#> GSM1324946 2 0.827 0.835 0.260 0.740
#> GSM1324950 1 0.482 0.908 0.896 0.104
#> GSM1324951 1 0.482 0.908 0.896 0.104
#> GSM1324952 1 0.482 0.908 0.896 0.104
#> GSM1324932 2 0.482 0.740 0.104 0.896
#> GSM1324933 2 0.482 0.740 0.104 0.896
#> GSM1324934 2 0.482 0.740 0.104 0.896
#> GSM1324893 1 0.000 0.933 1.000 0.000
#> GSM1324894 1 0.000 0.933 1.000 0.000
#> GSM1324895 1 0.000 0.933 1.000 0.000
#> GSM1324899 1 0.000 0.933 1.000 0.000
#> GSM1324900 1 0.000 0.933 1.000 0.000
#> GSM1324901 1 0.000 0.933 1.000 0.000
#> GSM1324905 1 0.482 0.908 0.896 0.104
#> GSM1324906 1 0.482 0.908 0.896 0.104
#> GSM1324907 1 0.000 0.933 1.000 0.000
#> GSM1324911 2 0.827 0.835 0.260 0.740
#> GSM1324912 1 0.482 0.908 0.896 0.104
#> GSM1324913 2 0.821 0.839 0.256 0.744
#> GSM1324917 2 0.634 0.869 0.160 0.840
#> GSM1324918 2 0.584 0.872 0.140 0.860
#> GSM1324919 2 0.634 0.869 0.160 0.840
#> GSM1324923 2 0.680 0.880 0.180 0.820
#> GSM1324924 2 0.680 0.880 0.180 0.820
#> GSM1324925 2 0.680 0.880 0.180 0.820
#> GSM1324929 2 0.574 0.872 0.136 0.864
#> GSM1324930 2 0.574 0.872 0.136 0.864
#> GSM1324931 2 0.574 0.872 0.136 0.864
#> GSM1324935 2 0.839 0.827 0.268 0.732
#> GSM1324936 2 0.839 0.827 0.268 0.732
#> GSM1324937 2 0.839 0.827 0.268 0.732
#> GSM1324941 1 0.482 0.908 0.896 0.104
#> GSM1324942 1 0.482 0.908 0.896 0.104
#> GSM1324943 1 0.482 0.908 0.896 0.104
#> GSM1324947 1 0.482 0.908 0.896 0.104
#> GSM1324948 1 0.482 0.908 0.896 0.104
#> GSM1324949 1 0.482 0.908 0.896 0.104
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324897 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324898 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324902 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324903 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324904 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324908 2 0.1753 0.885 0.048 0.952 0.000
#> GSM1324909 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324910 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324914 2 0.0237 0.898 0.004 0.996 0.000
#> GSM1324915 1 0.0424 0.994 0.992 0.008 0.000
#> GSM1324916 1 0.0424 0.994 0.992 0.008 0.000
#> GSM1324920 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324921 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324922 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324926 3 0.0424 0.998 0.008 0.000 0.992
#> GSM1324927 3 0.0424 0.998 0.008 0.000 0.992
#> GSM1324928 3 0.0424 0.998 0.008 0.000 0.992
#> GSM1324938 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324950 2 0.5760 0.604 0.328 0.672 0.000
#> GSM1324951 2 0.5760 0.604 0.328 0.672 0.000
#> GSM1324952 2 0.5760 0.604 0.328 0.672 0.000
#> GSM1324932 3 0.0000 0.998 0.000 0.000 1.000
#> GSM1324933 3 0.0000 0.998 0.000 0.000 1.000
#> GSM1324934 3 0.0000 0.998 0.000 0.000 1.000
#> GSM1324893 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324894 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324895 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324899 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324900 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324901 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324905 2 0.1753 0.885 0.048 0.952 0.000
#> GSM1324906 2 0.1753 0.885 0.048 0.952 0.000
#> GSM1324907 1 0.0592 0.999 0.988 0.012 0.000
#> GSM1324911 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324912 2 0.5760 0.604 0.328 0.672 0.000
#> GSM1324913 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324917 2 0.2625 0.853 0.000 0.916 0.084
#> GSM1324918 2 0.2625 0.853 0.000 0.916 0.084
#> GSM1324919 2 0.2625 0.853 0.000 0.916 0.084
#> GSM1324923 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324924 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324925 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324929 2 0.2625 0.853 0.000 0.916 0.084
#> GSM1324930 2 0.2625 0.853 0.000 0.916 0.084
#> GSM1324931 2 0.2625 0.853 0.000 0.916 0.084
#> GSM1324935 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.900 0.000 1.000 0.000
#> GSM1324941 2 0.1753 0.885 0.048 0.952 0.000
#> GSM1324942 2 0.1753 0.885 0.048 0.952 0.000
#> GSM1324943 2 0.1753 0.885 0.048 0.952 0.000
#> GSM1324947 2 0.5760 0.604 0.328 0.672 0.000
#> GSM1324948 2 0.5760 0.604 0.328 0.672 0.000
#> GSM1324949 2 0.5760 0.604 0.328 0.672 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.2704 0.938 0.876 0.124 0.000 0.000
#> GSM1324897 1 0.2704 0.938 0.876 0.124 0.000 0.000
#> GSM1324898 1 0.2704 0.938 0.876 0.124 0.000 0.000
#> GSM1324902 1 0.0188 0.949 0.996 0.004 0.000 0.000
#> GSM1324903 1 0.0188 0.949 0.996 0.004 0.000 0.000
#> GSM1324904 1 0.0188 0.949 0.996 0.004 0.000 0.000
#> GSM1324908 4 0.4576 0.509 0.012 0.260 0.000 0.728
#> GSM1324909 1 0.1716 0.950 0.936 0.064 0.000 0.000
#> GSM1324910 1 0.1716 0.950 0.936 0.064 0.000 0.000
#> GSM1324914 4 0.0336 0.766 0.000 0.008 0.000 0.992
#> GSM1324915 1 0.0469 0.946 0.988 0.012 0.000 0.000
#> GSM1324916 1 0.0469 0.946 0.988 0.012 0.000 0.000
#> GSM1324920 4 0.0000 0.769 0.000 0.000 0.000 1.000
#> GSM1324921 4 0.0000 0.769 0.000 0.000 0.000 1.000
#> GSM1324922 4 0.0000 0.769 0.000 0.000 0.000 1.000
#> GSM1324926 3 0.1211 0.987 0.000 0.040 0.960 0.000
#> GSM1324927 3 0.1211 0.987 0.000 0.040 0.960 0.000
#> GSM1324928 3 0.1211 0.987 0.000 0.040 0.960 0.000
#> GSM1324938 4 0.4661 0.475 0.000 0.348 0.000 0.652
#> GSM1324939 4 0.4661 0.475 0.000 0.348 0.000 0.652
#> GSM1324940 4 0.4661 0.475 0.000 0.348 0.000 0.652
#> GSM1324944 2 0.4898 0.368 0.000 0.584 0.000 0.416
#> GSM1324945 2 0.4898 0.368 0.000 0.584 0.000 0.416
#> GSM1324946 2 0.4898 0.368 0.000 0.584 0.000 0.416
#> GSM1324950 2 0.4462 0.837 0.064 0.804 0.000 0.132
#> GSM1324951 2 0.4462 0.837 0.064 0.804 0.000 0.132
#> GSM1324952 2 0.4462 0.837 0.064 0.804 0.000 0.132
#> GSM1324932 3 0.0000 0.987 0.000 0.000 1.000 0.000
#> GSM1324933 3 0.0000 0.987 0.000 0.000 1.000 0.000
#> GSM1324934 3 0.0000 0.987 0.000 0.000 1.000 0.000
#> GSM1324893 1 0.0188 0.949 0.996 0.004 0.000 0.000
#> GSM1324894 1 0.0188 0.949 0.996 0.004 0.000 0.000
#> GSM1324895 1 0.0188 0.949 0.996 0.004 0.000 0.000
#> GSM1324899 1 0.2408 0.945 0.896 0.104 0.000 0.000
#> GSM1324900 1 0.2408 0.945 0.896 0.104 0.000 0.000
#> GSM1324901 1 0.2408 0.945 0.896 0.104 0.000 0.000
#> GSM1324905 2 0.4516 0.782 0.012 0.736 0.000 0.252
#> GSM1324906 2 0.4516 0.782 0.012 0.736 0.000 0.252
#> GSM1324907 1 0.2704 0.938 0.876 0.124 0.000 0.000
#> GSM1324911 4 0.4193 0.535 0.000 0.268 0.000 0.732
#> GSM1324912 2 0.5352 0.789 0.092 0.740 0.000 0.168
#> GSM1324913 4 0.4193 0.535 0.000 0.268 0.000 0.732
#> GSM1324917 4 0.0817 0.758 0.000 0.000 0.024 0.976
#> GSM1324918 4 0.0817 0.758 0.000 0.000 0.024 0.976
#> GSM1324919 4 0.0817 0.758 0.000 0.000 0.024 0.976
#> GSM1324923 4 0.1867 0.773 0.000 0.072 0.000 0.928
#> GSM1324924 4 0.1867 0.773 0.000 0.072 0.000 0.928
#> GSM1324925 4 0.1867 0.773 0.000 0.072 0.000 0.928
#> GSM1324929 4 0.2670 0.772 0.000 0.072 0.024 0.904
#> GSM1324930 4 0.2670 0.772 0.000 0.072 0.024 0.904
#> GSM1324931 4 0.2670 0.772 0.000 0.072 0.024 0.904
#> GSM1324935 4 0.4790 0.397 0.000 0.380 0.000 0.620
#> GSM1324936 4 0.4790 0.397 0.000 0.380 0.000 0.620
#> GSM1324937 4 0.4790 0.397 0.000 0.380 0.000 0.620
#> GSM1324941 2 0.3808 0.820 0.012 0.812 0.000 0.176
#> GSM1324942 2 0.3808 0.820 0.012 0.812 0.000 0.176
#> GSM1324943 2 0.3808 0.820 0.012 0.812 0.000 0.176
#> GSM1324947 2 0.4462 0.837 0.064 0.804 0.000 0.132
#> GSM1324948 2 0.4462 0.837 0.064 0.804 0.000 0.132
#> GSM1324949 2 0.4462 0.837 0.064 0.804 0.000 0.132
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.2189 0.822 0.904 0.000 0.000 NA 0.012
#> GSM1324897 1 0.2189 0.822 0.904 0.000 0.000 NA 0.012
#> GSM1324898 1 0.2189 0.822 0.904 0.000 0.000 NA 0.012
#> GSM1324902 1 0.3612 0.865 0.764 0.000 0.000 NA 0.008
#> GSM1324903 1 0.3612 0.865 0.764 0.000 0.000 NA 0.008
#> GSM1324904 1 0.3612 0.865 0.764 0.000 0.000 NA 0.008
#> GSM1324908 2 0.6000 0.308 0.000 0.572 0.000 NA 0.268
#> GSM1324909 1 0.2286 0.870 0.888 0.000 0.000 NA 0.004
#> GSM1324910 1 0.2286 0.870 0.888 0.000 0.000 NA 0.004
#> GSM1324914 2 0.1638 0.646 0.000 0.932 0.000 NA 0.004
#> GSM1324915 1 0.4275 0.839 0.696 0.020 0.000 NA 0.000
#> GSM1324916 1 0.4275 0.839 0.696 0.020 0.000 NA 0.000
#> GSM1324920 2 0.1399 0.663 0.000 0.952 0.000 NA 0.020
#> GSM1324921 2 0.1399 0.663 0.000 0.952 0.000 NA 0.020
#> GSM1324922 2 0.1399 0.663 0.000 0.952 0.000 NA 0.020
#> GSM1324926 3 0.1851 0.968 0.000 0.000 0.912 NA 0.000
#> GSM1324927 3 0.1851 0.968 0.000 0.000 0.912 NA 0.000
#> GSM1324928 3 0.1851 0.968 0.000 0.000 0.912 NA 0.000
#> GSM1324938 2 0.6767 0.401 0.000 0.388 0.000 NA 0.276
#> GSM1324939 2 0.6767 0.401 0.000 0.388 0.000 NA 0.276
#> GSM1324940 2 0.6767 0.401 0.000 0.388 0.000 NA 0.276
#> GSM1324944 5 0.6158 0.309 0.000 0.184 0.000 NA 0.552
#> GSM1324945 5 0.6158 0.309 0.000 0.184 0.000 NA 0.552
#> GSM1324946 5 0.6158 0.309 0.000 0.184 0.000 NA 0.552
#> GSM1324950 5 0.1153 0.807 0.004 0.008 0.000 NA 0.964
#> GSM1324951 5 0.1153 0.807 0.004 0.008 0.000 NA 0.964
#> GSM1324952 5 0.1153 0.807 0.004 0.008 0.000 NA 0.964
#> GSM1324932 3 0.0000 0.968 0.000 0.000 1.000 NA 0.000
#> GSM1324933 3 0.0000 0.968 0.000 0.000 1.000 NA 0.000
#> GSM1324934 3 0.0000 0.968 0.000 0.000 1.000 NA 0.000
#> GSM1324893 1 0.3612 0.865 0.764 0.000 0.000 NA 0.008
#> GSM1324894 1 0.3612 0.865 0.764 0.000 0.000 NA 0.008
#> GSM1324895 1 0.3612 0.865 0.764 0.000 0.000 NA 0.008
#> GSM1324899 1 0.0771 0.849 0.976 0.004 0.000 NA 0.000
#> GSM1324900 1 0.0771 0.849 0.976 0.004 0.000 NA 0.000
#> GSM1324901 1 0.0771 0.849 0.976 0.004 0.000 NA 0.000
#> GSM1324905 5 0.4926 0.645 0.000 0.132 0.000 NA 0.716
#> GSM1324906 5 0.4926 0.645 0.000 0.132 0.000 NA 0.716
#> GSM1324907 1 0.2189 0.822 0.904 0.000 0.000 NA 0.012
#> GSM1324911 2 0.6174 0.327 0.000 0.552 0.000 NA 0.256
#> GSM1324912 5 0.5195 0.659 0.024 0.092 0.000 NA 0.724
#> GSM1324913 2 0.6181 0.333 0.000 0.552 0.000 NA 0.252
#> GSM1324917 2 0.1471 0.667 0.000 0.952 0.004 NA 0.020
#> GSM1324918 2 0.1471 0.667 0.000 0.952 0.004 NA 0.020
#> GSM1324919 2 0.1471 0.667 0.000 0.952 0.004 NA 0.020
#> GSM1324923 2 0.4496 0.678 0.000 0.728 0.000 NA 0.056
#> GSM1324924 2 0.4496 0.678 0.000 0.728 0.000 NA 0.056
#> GSM1324925 2 0.4496 0.678 0.000 0.728 0.000 NA 0.056
#> GSM1324929 2 0.4524 0.682 0.000 0.736 0.004 NA 0.052
#> GSM1324930 2 0.4524 0.682 0.000 0.736 0.004 NA 0.052
#> GSM1324931 2 0.4524 0.682 0.000 0.736 0.004 NA 0.052
#> GSM1324935 2 0.6821 0.323 0.000 0.352 0.000 NA 0.328
#> GSM1324936 2 0.6821 0.323 0.000 0.352 0.000 NA 0.328
#> GSM1324937 2 0.6821 0.323 0.000 0.352 0.000 NA 0.328
#> GSM1324941 5 0.0807 0.804 0.000 0.012 0.000 NA 0.976
#> GSM1324942 5 0.0807 0.804 0.000 0.012 0.000 NA 0.976
#> GSM1324943 5 0.0807 0.804 0.000 0.012 0.000 NA 0.976
#> GSM1324947 5 0.1329 0.806 0.004 0.008 0.000 NA 0.956
#> GSM1324948 5 0.1329 0.806 0.004 0.008 0.000 NA 0.956
#> GSM1324949 5 0.1329 0.806 0.004 0.008 0.000 NA 0.956
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.4172 0.720 0.528 0.000 0.000 0.000 0.012 NA
#> GSM1324897 1 0.4172 0.720 0.528 0.000 0.000 0.000 0.012 NA
#> GSM1324898 1 0.4172 0.720 0.528 0.000 0.000 0.000 0.012 NA
#> GSM1324902 1 0.0146 0.798 0.996 0.004 0.000 0.000 0.000 NA
#> GSM1324903 1 0.0146 0.798 0.996 0.004 0.000 0.000 0.000 NA
#> GSM1324904 1 0.0146 0.798 0.996 0.004 0.000 0.000 0.000 NA
#> GSM1324908 4 0.6849 0.388 0.000 0.128 0.000 0.504 0.212 NA
#> GSM1324909 1 0.3572 0.807 0.792 0.016 0.000 0.024 0.000 NA
#> GSM1324910 1 0.3572 0.807 0.792 0.016 0.000 0.024 0.000 NA
#> GSM1324914 4 0.4468 0.547 0.000 0.212 0.000 0.696 0.000 NA
#> GSM1324915 1 0.4276 0.713 0.772 0.052 0.000 0.052 0.000 NA
#> GSM1324916 1 0.4276 0.713 0.772 0.052 0.000 0.052 0.000 NA
#> GSM1324920 4 0.3374 0.626 0.000 0.208 0.000 0.772 0.000 NA
#> GSM1324921 4 0.3374 0.626 0.000 0.208 0.000 0.772 0.000 NA
#> GSM1324922 4 0.3374 0.626 0.000 0.208 0.000 0.772 0.000 NA
#> GSM1324926 3 0.2730 0.944 0.000 0.004 0.864 0.020 0.004 NA
#> GSM1324927 3 0.2592 0.944 0.000 0.004 0.864 0.016 0.000 NA
#> GSM1324928 3 0.2592 0.944 0.000 0.004 0.864 0.016 0.000 NA
#> GSM1324938 2 0.2905 0.600 0.000 0.836 0.000 0.012 0.144 NA
#> GSM1324939 2 0.2905 0.600 0.000 0.836 0.000 0.012 0.144 NA
#> GSM1324940 2 0.2905 0.600 0.000 0.836 0.000 0.012 0.144 NA
#> GSM1324944 5 0.6643 0.169 0.000 0.384 0.000 0.084 0.416 NA
#> GSM1324945 5 0.6643 0.169 0.000 0.384 0.000 0.084 0.416 NA
#> GSM1324946 5 0.6643 0.169 0.000 0.384 0.000 0.084 0.416 NA
#> GSM1324950 5 0.1148 0.767 0.004 0.016 0.000 0.000 0.960 NA
#> GSM1324951 5 0.1148 0.767 0.004 0.016 0.000 0.000 0.960 NA
#> GSM1324952 5 0.1148 0.767 0.004 0.016 0.000 0.000 0.960 NA
#> GSM1324932 3 0.0000 0.945 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324933 3 0.0000 0.945 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324934 3 0.0000 0.945 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324893 1 0.0767 0.798 0.976 0.008 0.000 0.012 0.000 NA
#> GSM1324894 1 0.0767 0.798 0.976 0.008 0.000 0.012 0.000 NA
#> GSM1324895 1 0.0767 0.798 0.976 0.008 0.000 0.012 0.000 NA
#> GSM1324899 1 0.4793 0.781 0.664 0.024 0.000 0.048 0.000 NA
#> GSM1324900 1 0.4793 0.781 0.664 0.024 0.000 0.048 0.000 NA
#> GSM1324901 1 0.4793 0.781 0.664 0.024 0.000 0.048 0.000 NA
#> GSM1324905 5 0.5598 0.546 0.000 0.036 0.000 0.188 0.632 NA
#> GSM1324906 5 0.5598 0.546 0.000 0.036 0.000 0.188 0.632 NA
#> GSM1324907 1 0.4172 0.720 0.528 0.000 0.000 0.000 0.012 NA
#> GSM1324911 4 0.7106 0.382 0.000 0.160 0.000 0.468 0.200 NA
#> GSM1324912 5 0.5494 0.566 0.004 0.020 0.000 0.156 0.640 NA
#> GSM1324913 4 0.7110 0.380 0.000 0.164 0.000 0.468 0.196 NA
#> GSM1324917 4 0.3978 0.572 0.000 0.268 0.000 0.700 0.000 NA
#> GSM1324918 4 0.3978 0.572 0.000 0.268 0.000 0.700 0.000 NA
#> GSM1324919 4 0.3978 0.572 0.000 0.268 0.000 0.700 0.000 NA
#> GSM1324923 2 0.5297 0.420 0.000 0.536 0.000 0.364 0.004 NA
#> GSM1324924 2 0.5297 0.420 0.000 0.536 0.000 0.364 0.004 NA
#> GSM1324925 2 0.5297 0.420 0.000 0.536 0.000 0.364 0.004 NA
#> GSM1324929 2 0.5260 0.386 0.000 0.552 0.000 0.348 0.004 NA
#> GSM1324930 2 0.5260 0.386 0.000 0.552 0.000 0.348 0.004 NA
#> GSM1324931 2 0.5260 0.386 0.000 0.552 0.000 0.348 0.004 NA
#> GSM1324935 2 0.3351 0.586 0.000 0.800 0.000 0.028 0.168 NA
#> GSM1324936 2 0.3351 0.586 0.000 0.800 0.000 0.028 0.168 NA
#> GSM1324937 2 0.3351 0.586 0.000 0.800 0.000 0.028 0.168 NA
#> GSM1324941 5 0.1719 0.763 0.000 0.032 0.000 0.004 0.932 NA
#> GSM1324942 5 0.1719 0.763 0.000 0.032 0.000 0.004 0.932 NA
#> GSM1324943 5 0.1719 0.763 0.000 0.032 0.000 0.004 0.932 NA
#> GSM1324947 5 0.1377 0.767 0.004 0.016 0.000 0.004 0.952 NA
#> GSM1324948 5 0.1377 0.767 0.004 0.016 0.000 0.004 0.952 NA
#> GSM1324949 5 0.1377 0.767 0.004 0.016 0.000 0.004 0.952 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n agent(p) individual(p) k
#> CV:kmeans 60 0.79625 2.61e-05 2
#> CV:kmeans 60 0.01279 7.01e-09 3
#> CV:kmeans 51 0.00871 3.38e-10 4
#> CV:kmeans 48 0.00980 3.22e-10 5
#> CV:kmeans 48 0.05175 4.13e-13 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.992 0.996 0.5088 0.492 0.492
#> 3 3 0.910 0.871 0.950 0.3290 0.695 0.456
#> 4 4 0.751 0.699 0.813 0.1165 0.862 0.610
#> 5 5 0.827 0.840 0.898 0.0528 0.876 0.561
#> 6 6 0.835 0.768 0.829 0.0341 0.968 0.841
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
#> GSM1324896 1 0.000 0.993 1.000 0.000
#> GSM1324897 1 0.000 0.993 1.000 0.000
#> GSM1324898 1 0.000 0.993 1.000 0.000
#> GSM1324902 1 0.000 0.993 1.000 0.000
#> GSM1324903 1 0.000 0.993 1.000 0.000
#> GSM1324904 1 0.000 0.993 1.000 0.000
#> GSM1324908 1 0.745 0.731 0.788 0.212
#> GSM1324909 1 0.000 0.993 1.000 0.000
#> GSM1324910 1 0.000 0.993 1.000 0.000
#> GSM1324914 2 0.000 1.000 0.000 1.000
#> GSM1324915 1 0.000 0.993 1.000 0.000
#> GSM1324916 1 0.000 0.993 1.000 0.000
#> GSM1324920 2 0.000 1.000 0.000 1.000
#> GSM1324921 2 0.000 1.000 0.000 1.000
#> GSM1324922 2 0.000 1.000 0.000 1.000
#> GSM1324926 2 0.000 1.000 0.000 1.000
#> GSM1324927 2 0.000 1.000 0.000 1.000
#> GSM1324928 2 0.000 1.000 0.000 1.000
#> GSM1324938 2 0.000 1.000 0.000 1.000
#> GSM1324939 2 0.000 1.000 0.000 1.000
#> GSM1324940 2 0.000 1.000 0.000 1.000
#> GSM1324944 2 0.000 1.000 0.000 1.000
#> GSM1324945 2 0.000 1.000 0.000 1.000
#> GSM1324946 2 0.000 1.000 0.000 1.000
#> GSM1324950 1 0.000 0.993 1.000 0.000
#> GSM1324951 1 0.000 0.993 1.000 0.000
#> GSM1324952 1 0.000 0.993 1.000 0.000
#> GSM1324932 2 0.000 1.000 0.000 1.000
#> GSM1324933 2 0.000 1.000 0.000 1.000
#> GSM1324934 2 0.000 1.000 0.000 1.000
#> GSM1324893 1 0.000 0.993 1.000 0.000
#> GSM1324894 1 0.000 0.993 1.000 0.000
#> GSM1324895 1 0.000 0.993 1.000 0.000
#> GSM1324899 1 0.000 0.993 1.000 0.000
#> GSM1324900 1 0.000 0.993 1.000 0.000
#> GSM1324901 1 0.000 0.993 1.000 0.000
#> GSM1324905 1 0.000 0.993 1.000 0.000
#> GSM1324906 1 0.000 0.993 1.000 0.000
#> GSM1324907 1 0.000 0.993 1.000 0.000
#> GSM1324911 2 0.000 1.000 0.000 1.000
#> GSM1324912 1 0.000 0.993 1.000 0.000
#> GSM1324913 2 0.000 1.000 0.000 1.000
#> GSM1324917 2 0.000 1.000 0.000 1.000
#> GSM1324918 2 0.000 1.000 0.000 1.000
#> GSM1324919 2 0.000 1.000 0.000 1.000
#> GSM1324923 2 0.000 1.000 0.000 1.000
#> GSM1324924 2 0.000 1.000 0.000 1.000
#> GSM1324925 2 0.000 1.000 0.000 1.000
#> GSM1324929 2 0.000 1.000 0.000 1.000
#> GSM1324930 2 0.000 1.000 0.000 1.000
#> GSM1324931 2 0.000 1.000 0.000 1.000
#> GSM1324935 2 0.000 1.000 0.000 1.000
#> GSM1324936 2 0.000 1.000 0.000 1.000
#> GSM1324937 2 0.000 1.000 0.000 1.000
#> GSM1324941 1 0.000 0.993 1.000 0.000
#> GSM1324942 1 0.000 0.993 1.000 0.000
#> GSM1324943 1 0.000 0.993 1.000 0.000
#> GSM1324947 1 0.000 0.993 1.000 0.000
#> GSM1324948 1 0.000 0.993 1.000 0.000
#> GSM1324949 1 0.000 0.993 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324897 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324898 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324902 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324903 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324904 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324908 1 0.579 0.485 0.668 0.000 0.332
#> GSM1324909 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324910 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324914 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324915 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324916 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324920 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324921 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324922 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324938 2 0.624 0.293 0.000 0.560 0.440
#> GSM1324939 2 0.624 0.293 0.000 0.560 0.440
#> GSM1324940 2 0.624 0.293 0.000 0.560 0.440
#> GSM1324944 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324945 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324946 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324950 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324951 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324952 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324932 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324893 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324894 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324895 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324899 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324900 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324901 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324905 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324906 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324907 1 0.000 0.953 1.000 0.000 0.000
#> GSM1324911 2 0.626 0.244 0.000 0.552 0.448
#> GSM1324912 1 0.627 0.170 0.544 0.456 0.000
#> GSM1324913 2 0.626 0.244 0.000 0.552 0.448
#> GSM1324917 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324918 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324919 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324923 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324924 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324925 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324929 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324930 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324931 3 0.000 1.000 0.000 0.000 1.000
#> GSM1324935 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324936 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324937 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324941 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324942 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324943 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324947 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324948 2 0.000 0.883 0.000 1.000 0.000
#> GSM1324949 2 0.000 0.883 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324902 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324908 1 0.7125 0.2798 0.516 0.072 0.388 0.024
#> GSM1324909 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324914 3 0.0336 0.7869 0.000 0.000 0.992 0.008
#> GSM1324915 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324920 3 0.0921 0.7847 0.000 0.000 0.972 0.028
#> GSM1324921 3 0.0921 0.7847 0.000 0.000 0.972 0.028
#> GSM1324922 3 0.0921 0.7847 0.000 0.000 0.972 0.028
#> GSM1324926 3 0.4277 0.7804 0.000 0.000 0.720 0.280
#> GSM1324927 3 0.4277 0.7804 0.000 0.000 0.720 0.280
#> GSM1324928 3 0.4277 0.7804 0.000 0.000 0.720 0.280
#> GSM1324938 4 0.2675 0.6746 0.000 0.100 0.008 0.892
#> GSM1324939 4 0.2675 0.6746 0.000 0.100 0.008 0.892
#> GSM1324940 4 0.2675 0.6746 0.000 0.100 0.008 0.892
#> GSM1324944 2 0.4981 0.1665 0.000 0.536 0.000 0.464
#> GSM1324945 2 0.4981 0.1665 0.000 0.536 0.000 0.464
#> GSM1324946 2 0.4981 0.1665 0.000 0.536 0.000 0.464
#> GSM1324950 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324951 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324952 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324932 3 0.4277 0.7804 0.000 0.000 0.720 0.280
#> GSM1324933 3 0.4277 0.7804 0.000 0.000 0.720 0.280
#> GSM1324934 3 0.4277 0.7804 0.000 0.000 0.720 0.280
#> GSM1324893 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324905 2 0.4434 0.6183 0.000 0.756 0.228 0.016
#> GSM1324906 2 0.4434 0.6183 0.000 0.756 0.228 0.016
#> GSM1324907 1 0.0000 0.9723 1.000 0.000 0.000 0.000
#> GSM1324911 2 0.7916 0.2074 0.000 0.352 0.336 0.312
#> GSM1324912 2 0.5774 0.5602 0.200 0.720 0.064 0.016
#> GSM1324913 2 0.7919 0.1995 0.000 0.348 0.336 0.316
#> GSM1324917 3 0.1792 0.8155 0.000 0.000 0.932 0.068
#> GSM1324918 3 0.1792 0.8155 0.000 0.000 0.932 0.068
#> GSM1324919 3 0.1792 0.8155 0.000 0.000 0.932 0.068
#> GSM1324923 4 0.2011 0.6690 0.000 0.000 0.080 0.920
#> GSM1324924 4 0.2011 0.6690 0.000 0.000 0.080 0.920
#> GSM1324925 4 0.2011 0.6690 0.000 0.000 0.080 0.920
#> GSM1324929 4 0.4898 -0.0128 0.000 0.000 0.416 0.584
#> GSM1324930 4 0.4898 -0.0128 0.000 0.000 0.416 0.584
#> GSM1324931 4 0.4898 -0.0128 0.000 0.000 0.416 0.584
#> GSM1324935 4 0.4535 0.4641 0.000 0.292 0.004 0.704
#> GSM1324936 4 0.4535 0.4641 0.000 0.292 0.004 0.704
#> GSM1324937 4 0.4535 0.4641 0.000 0.292 0.004 0.704
#> GSM1324941 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324942 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324943 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324947 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324948 2 0.0000 0.7534 0.000 1.000 0.000 0.000
#> GSM1324949 2 0.0000 0.7534 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324902 1 0.0162 0.991 0.996 0.004 0.000 0.000 0.000
#> GSM1324903 1 0.0162 0.991 0.996 0.004 0.000 0.000 0.000
#> GSM1324904 1 0.0162 0.991 0.996 0.004 0.000 0.000 0.000
#> GSM1324908 4 0.4450 0.540 0.196 0.004 0.012 0.756 0.032
#> GSM1324909 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.3305 0.728 0.000 0.000 0.224 0.776 0.000
#> GSM1324915 1 0.1502 0.946 0.940 0.004 0.000 0.056 0.000
#> GSM1324916 1 0.1502 0.946 0.940 0.004 0.000 0.056 0.000
#> GSM1324920 4 0.3210 0.733 0.000 0.000 0.212 0.788 0.000
#> GSM1324921 4 0.3210 0.733 0.000 0.000 0.212 0.788 0.000
#> GSM1324922 4 0.3210 0.733 0.000 0.000 0.212 0.788 0.000
#> GSM1324926 3 0.0000 0.855 0.000 0.000 1.000 0.000 0.000
#> GSM1324927 3 0.0000 0.855 0.000 0.000 1.000 0.000 0.000
#> GSM1324928 3 0.0000 0.855 0.000 0.000 1.000 0.000 0.000
#> GSM1324938 2 0.0609 0.839 0.000 0.980 0.020 0.000 0.000
#> GSM1324939 2 0.0609 0.839 0.000 0.980 0.020 0.000 0.000
#> GSM1324940 2 0.0609 0.839 0.000 0.980 0.020 0.000 0.000
#> GSM1324944 2 0.4670 0.724 0.000 0.724 0.000 0.076 0.200
#> GSM1324945 2 0.4670 0.724 0.000 0.724 0.000 0.076 0.200
#> GSM1324946 2 0.4637 0.728 0.000 0.728 0.000 0.076 0.196
#> GSM1324950 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324951 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324952 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324932 3 0.0000 0.855 0.000 0.000 1.000 0.000 0.000
#> GSM1324933 3 0.0000 0.855 0.000 0.000 1.000 0.000 0.000
#> GSM1324934 3 0.0000 0.855 0.000 0.000 1.000 0.000 0.000
#> GSM1324893 1 0.0162 0.991 0.996 0.004 0.000 0.000 0.000
#> GSM1324894 1 0.0162 0.991 0.996 0.004 0.000 0.000 0.000
#> GSM1324895 1 0.0162 0.991 0.996 0.004 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324905 5 0.3582 0.778 0.000 0.008 0.000 0.224 0.768
#> GSM1324906 5 0.3582 0.778 0.000 0.008 0.000 0.224 0.768
#> GSM1324907 1 0.0000 0.992 1.000 0.000 0.000 0.000 0.000
#> GSM1324911 4 0.3612 0.530 0.000 0.028 0.000 0.800 0.172
#> GSM1324912 5 0.4285 0.769 0.032 0.008 0.000 0.208 0.752
#> GSM1324913 4 0.3574 0.536 0.000 0.028 0.000 0.804 0.168
#> GSM1324917 4 0.4171 0.584 0.000 0.000 0.396 0.604 0.000
#> GSM1324918 4 0.4171 0.584 0.000 0.000 0.396 0.604 0.000
#> GSM1324919 4 0.4171 0.584 0.000 0.000 0.396 0.604 0.000
#> GSM1324923 2 0.4712 0.723 0.000 0.732 0.100 0.168 0.000
#> GSM1324924 2 0.4712 0.723 0.000 0.732 0.100 0.168 0.000
#> GSM1324925 2 0.4712 0.723 0.000 0.732 0.100 0.168 0.000
#> GSM1324929 3 0.4971 0.697 0.000 0.176 0.708 0.116 0.000
#> GSM1324930 3 0.4971 0.697 0.000 0.176 0.708 0.116 0.000
#> GSM1324931 3 0.4971 0.697 0.000 0.176 0.708 0.116 0.000
#> GSM1324935 2 0.0510 0.841 0.000 0.984 0.000 0.000 0.016
#> GSM1324936 2 0.0510 0.841 0.000 0.984 0.000 0.000 0.016
#> GSM1324937 2 0.0510 0.841 0.000 0.984 0.000 0.000 0.016
#> GSM1324941 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324942 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324943 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324947 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324948 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
#> GSM1324949 5 0.0162 0.936 0.000 0.004 0.000 0.000 0.996
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0146 0.971 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324897 1 0.0146 0.971 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324898 1 0.0146 0.971 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324902 1 0.1074 0.967 0.960 0.000 0.012 0.000 0.000 0.028
#> GSM1324903 1 0.1074 0.967 0.960 0.000 0.012 0.000 0.000 0.028
#> GSM1324904 1 0.1074 0.967 0.960 0.000 0.012 0.000 0.000 0.028
#> GSM1324908 6 0.5534 0.489 0.132 0.000 0.000 0.276 0.012 0.580
#> GSM1324909 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.1649 0.843 0.000 0.000 0.036 0.932 0.000 0.032
#> GSM1324915 1 0.2853 0.899 0.868 0.000 0.012 0.072 0.000 0.048
#> GSM1324916 1 0.2853 0.899 0.868 0.000 0.012 0.072 0.000 0.048
#> GSM1324920 4 0.0260 0.874 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM1324921 4 0.0260 0.874 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM1324922 4 0.0260 0.874 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM1324926 3 0.1910 0.689 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM1324927 3 0.1910 0.689 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM1324928 3 0.1910 0.689 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM1324938 2 0.0603 0.680 0.000 0.980 0.004 0.000 0.000 0.016
#> GSM1324939 2 0.0603 0.680 0.000 0.980 0.004 0.000 0.000 0.016
#> GSM1324940 2 0.0603 0.680 0.000 0.980 0.004 0.000 0.000 0.016
#> GSM1324944 2 0.5874 0.386 0.000 0.508 0.020 0.000 0.128 0.344
#> GSM1324945 2 0.5874 0.386 0.000 0.508 0.020 0.000 0.128 0.344
#> GSM1324946 2 0.5874 0.386 0.000 0.508 0.020 0.000 0.128 0.344
#> GSM1324950 5 0.0000 0.996 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324951 5 0.0000 0.996 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324952 5 0.0000 0.996 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324932 3 0.1910 0.689 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM1324933 3 0.1910 0.689 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM1324934 3 0.1910 0.689 0.000 0.000 0.892 0.108 0.000 0.000
#> GSM1324893 1 0.1074 0.967 0.960 0.000 0.012 0.000 0.000 0.028
#> GSM1324894 1 0.1074 0.967 0.960 0.000 0.012 0.000 0.000 0.028
#> GSM1324895 1 0.1074 0.967 0.960 0.000 0.012 0.000 0.000 0.028
#> GSM1324899 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324905 6 0.4199 0.633 0.000 0.000 0.000 0.020 0.380 0.600
#> GSM1324906 6 0.4199 0.633 0.000 0.000 0.000 0.020 0.380 0.600
#> GSM1324907 1 0.0146 0.971 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324911 6 0.3796 0.657 0.000 0.000 0.000 0.176 0.060 0.764
#> GSM1324912 6 0.4575 0.662 0.020 0.000 0.000 0.020 0.340 0.620
#> GSM1324913 6 0.3739 0.653 0.000 0.000 0.000 0.176 0.056 0.768
#> GSM1324917 4 0.3027 0.826 0.000 0.000 0.148 0.824 0.000 0.028
#> GSM1324918 4 0.3027 0.826 0.000 0.000 0.148 0.824 0.000 0.028
#> GSM1324919 4 0.3027 0.826 0.000 0.000 0.148 0.824 0.000 0.028
#> GSM1324923 2 0.7318 0.311 0.000 0.368 0.128 0.192 0.000 0.312
#> GSM1324924 2 0.7318 0.311 0.000 0.368 0.128 0.192 0.000 0.312
#> GSM1324925 2 0.7318 0.311 0.000 0.368 0.128 0.192 0.000 0.312
#> GSM1324929 3 0.7380 0.258 0.000 0.172 0.400 0.176 0.000 0.252
#> GSM1324930 3 0.7380 0.258 0.000 0.172 0.400 0.176 0.000 0.252
#> GSM1324931 3 0.7380 0.258 0.000 0.172 0.400 0.176 0.000 0.252
#> GSM1324935 2 0.0146 0.682 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM1324936 2 0.0146 0.682 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM1324937 2 0.0146 0.682 0.000 0.996 0.000 0.000 0.000 0.004
#> GSM1324941 5 0.0260 0.992 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM1324942 5 0.0260 0.992 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM1324943 5 0.0260 0.992 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM1324947 5 0.0000 0.996 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324948 5 0.0000 0.996 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324949 5 0.0000 0.996 0.000 0.000 0.000 0.000 1.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 agent(p) individual(p) k
#> CV:skmeans 60 0.7963 2.61e-05 2
#> CV:skmeans 53 0.3616 4.19e-08 3
#> CV:skmeans 48 0.0715 3.22e-10 4
#> CV:skmeans 60 0.3391 4.18e-15 5
#> CV:skmeans 50 0.0273 4.13e-17 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 46323 rows and 60 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 0.464 0.702 0.807 0.3205 0.817 0.817
#> 3 3 1.000 0.987 0.994 0.7529 0.624 0.540
#> 4 4 1.000 0.966 0.987 0.3021 0.827 0.608
#> 5 5 0.862 0.575 0.797 0.0666 0.915 0.701
#> 6 6 0.971 0.932 0.969 0.0411 0.936 0.724
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] 3 4
There is also optional best \(k\) = 3 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.000 0.712 1.000 0.000
#> GSM1324897 1 0.000 0.712 1.000 0.000
#> GSM1324898 1 0.000 0.712 1.000 0.000
#> GSM1324902 1 0.000 0.712 1.000 0.000
#> GSM1324903 1 0.000 0.712 1.000 0.000
#> GSM1324904 1 0.000 0.712 1.000 0.000
#> GSM1324908 1 0.000 0.712 1.000 0.000
#> GSM1324909 1 0.000 0.712 1.000 0.000
#> GSM1324910 1 0.000 0.712 1.000 0.000
#> GSM1324914 1 0.985 0.625 0.572 0.428
#> GSM1324915 1 0.000 0.712 1.000 0.000
#> GSM1324916 1 0.000 0.712 1.000 0.000
#> GSM1324920 1 0.985 0.625 0.572 0.428
#> GSM1324921 1 0.985 0.625 0.572 0.428
#> GSM1324922 1 0.985 0.625 0.572 0.428
#> GSM1324926 2 0.000 1.000 0.000 1.000
#> GSM1324927 2 0.000 1.000 0.000 1.000
#> GSM1324928 2 0.000 1.000 0.000 1.000
#> GSM1324938 1 0.985 0.625 0.572 0.428
#> GSM1324939 1 0.985 0.625 0.572 0.428
#> GSM1324940 1 0.985 0.625 0.572 0.428
#> GSM1324944 1 0.985 0.625 0.572 0.428
#> GSM1324945 1 0.985 0.625 0.572 0.428
#> GSM1324946 1 0.985 0.625 0.572 0.428
#> GSM1324950 1 0.000 0.712 1.000 0.000
#> GSM1324951 1 0.000 0.712 1.000 0.000
#> GSM1324952 1 0.000 0.712 1.000 0.000
#> GSM1324932 2 0.000 1.000 0.000 1.000
#> GSM1324933 2 0.000 1.000 0.000 1.000
#> GSM1324934 2 0.000 1.000 0.000 1.000
#> GSM1324893 1 0.000 0.712 1.000 0.000
#> GSM1324894 1 0.000 0.712 1.000 0.000
#> GSM1324895 1 0.000 0.712 1.000 0.000
#> GSM1324899 1 0.000 0.712 1.000 0.000
#> GSM1324900 1 0.000 0.712 1.000 0.000
#> GSM1324901 1 0.000 0.712 1.000 0.000
#> GSM1324905 1 0.981 0.627 0.580 0.420
#> GSM1324906 1 0.983 0.626 0.576 0.424
#> GSM1324907 1 0.000 0.712 1.000 0.000
#> GSM1324911 1 0.985 0.625 0.572 0.428
#> GSM1324912 1 0.000 0.712 1.000 0.000
#> GSM1324913 1 0.985 0.625 0.572 0.428
#> GSM1324917 1 0.985 0.625 0.572 0.428
#> GSM1324918 1 0.985 0.625 0.572 0.428
#> GSM1324919 1 0.985 0.625 0.572 0.428
#> GSM1324923 1 0.985 0.625 0.572 0.428
#> GSM1324924 1 0.985 0.625 0.572 0.428
#> GSM1324925 1 0.985 0.625 0.572 0.428
#> GSM1324929 1 0.985 0.625 0.572 0.428
#> GSM1324930 1 0.985 0.625 0.572 0.428
#> GSM1324931 1 0.985 0.625 0.572 0.428
#> GSM1324935 1 0.985 0.625 0.572 0.428
#> GSM1324936 1 0.985 0.625 0.572 0.428
#> GSM1324937 1 0.985 0.625 0.572 0.428
#> GSM1324941 1 0.689 0.676 0.816 0.184
#> GSM1324942 1 0.000 0.712 1.000 0.000
#> GSM1324943 1 0.827 0.660 0.740 0.260
#> GSM1324947 1 0.000 0.712 1.000 0.000
#> GSM1324948 1 0.000 0.712 1.000 0.000
#> GSM1324949 1 0.000 0.712 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0
#> GSM1324908 1 0.0000 1.000 1.000 0.000 0
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0
#> GSM1324914 2 0.0000 0.988 0.000 1.000 0
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0
#> GSM1324920 2 0.0000 0.988 0.000 1.000 0
#> GSM1324921 2 0.0000 0.988 0.000 1.000 0
#> GSM1324922 2 0.0000 0.988 0.000 1.000 0
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1
#> GSM1324938 2 0.0000 0.988 0.000 1.000 0
#> GSM1324939 2 0.0000 0.988 0.000 1.000 0
#> GSM1324940 2 0.0000 0.988 0.000 1.000 0
#> GSM1324944 2 0.0000 0.988 0.000 1.000 0
#> GSM1324945 2 0.0000 0.988 0.000 1.000 0
#> GSM1324946 2 0.0000 0.988 0.000 1.000 0
#> GSM1324950 2 0.0592 0.980 0.012 0.988 0
#> GSM1324951 2 0.0592 0.980 0.012 0.988 0
#> GSM1324952 2 0.1860 0.938 0.052 0.948 0
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0
#> GSM1324905 2 0.4750 0.708 0.216 0.784 0
#> GSM1324906 2 0.0747 0.975 0.016 0.984 0
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0
#> GSM1324911 2 0.0000 0.988 0.000 1.000 0
#> GSM1324912 1 0.0237 0.994 0.996 0.004 0
#> GSM1324913 2 0.0000 0.988 0.000 1.000 0
#> GSM1324917 2 0.0000 0.988 0.000 1.000 0
#> GSM1324918 2 0.0000 0.988 0.000 1.000 0
#> GSM1324919 2 0.0000 0.988 0.000 1.000 0
#> GSM1324923 2 0.0000 0.988 0.000 1.000 0
#> GSM1324924 2 0.0000 0.988 0.000 1.000 0
#> GSM1324925 2 0.0000 0.988 0.000 1.000 0
#> GSM1324929 2 0.0000 0.988 0.000 1.000 0
#> GSM1324930 2 0.0000 0.988 0.000 1.000 0
#> GSM1324931 2 0.0000 0.988 0.000 1.000 0
#> GSM1324935 2 0.0000 0.988 0.000 1.000 0
#> GSM1324936 2 0.0000 0.988 0.000 1.000 0
#> GSM1324937 2 0.0000 0.988 0.000 1.000 0
#> GSM1324941 2 0.0000 0.988 0.000 1.000 0
#> GSM1324942 2 0.0000 0.988 0.000 1.000 0
#> GSM1324943 2 0.0000 0.988 0.000 1.000 0
#> GSM1324947 2 0.0592 0.980 0.012 0.988 0
#> GSM1324948 2 0.0592 0.980 0.012 0.988 0
#> GSM1324949 2 0.0592 0.980 0.012 0.988 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324908 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324909 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324914 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324915 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324916 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324920 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324921 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324922 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 4 0.0188 0.968 0.000 0.004 0 0.996
#> GSM1324939 4 0.0188 0.968 0.000 0.004 0 0.996
#> GSM1324940 4 0.0188 0.968 0.000 0.004 0 0.996
#> GSM1324944 2 0.0188 0.991 0.000 0.996 0 0.004
#> GSM1324945 2 0.0188 0.991 0.000 0.996 0 0.004
#> GSM1324946 2 0.0188 0.991 0.000 0.996 0 0.004
#> GSM1324950 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324951 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324952 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324905 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324906 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324907 1 0.0000 0.983 1.000 0.000 0 0.000
#> GSM1324911 4 0.4817 0.359 0.000 0.388 0 0.612
#> GSM1324912 1 0.4040 0.648 0.752 0.248 0 0.000
#> GSM1324913 4 0.0707 0.952 0.000 0.020 0 0.980
#> GSM1324917 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324918 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324919 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324923 4 0.0188 0.968 0.000 0.004 0 0.996
#> GSM1324924 4 0.0188 0.968 0.000 0.004 0 0.996
#> GSM1324925 4 0.0188 0.968 0.000 0.004 0 0.996
#> GSM1324929 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324930 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324931 4 0.0000 0.969 0.000 0.000 0 1.000
#> GSM1324935 2 0.0921 0.971 0.000 0.972 0 0.028
#> GSM1324936 2 0.0921 0.971 0.000 0.972 0 0.028
#> GSM1324937 2 0.0921 0.971 0.000 0.972 0 0.028
#> GSM1324941 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324942 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324943 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324947 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324948 2 0.0000 0.993 0.000 1.000 0 0.000
#> GSM1324949 2 0.0000 0.993 0.000 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324902 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324908 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324909 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.4306 0.200 0.000 0.000 0.492 0.508 0.000
#> GSM1324915 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324920 3 0.5548 -0.271 0.000 0.068 0.492 0.440 0.000
#> GSM1324921 3 0.5548 -0.271 0.000 0.068 0.492 0.440 0.000
#> GSM1324922 3 0.5548 -0.271 0.000 0.068 0.492 0.440 0.000
#> GSM1324926 3 0.4306 0.640 0.000 0.492 0.508 0.000 0.000
#> GSM1324927 3 0.4306 0.640 0.000 0.492 0.508 0.000 0.000
#> GSM1324928 3 0.4306 0.640 0.000 0.492 0.508 0.000 0.000
#> GSM1324938 2 0.4306 0.256 0.000 0.508 0.000 0.492 0.000
#> GSM1324939 2 0.4306 0.256 0.000 0.508 0.000 0.492 0.000
#> GSM1324940 2 0.4306 0.256 0.000 0.508 0.000 0.492 0.000
#> GSM1324944 5 0.4287 -0.180 0.000 0.460 0.000 0.000 0.540
#> GSM1324945 5 0.4287 -0.180 0.000 0.460 0.000 0.000 0.540
#> GSM1324946 5 0.4291 -0.195 0.000 0.464 0.000 0.000 0.536
#> GSM1324950 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324951 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324952 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324932 3 0.4306 0.640 0.000 0.492 0.508 0.000 0.000
#> GSM1324933 3 0.4306 0.640 0.000 0.492 0.508 0.000 0.000
#> GSM1324934 3 0.4306 0.640 0.000 0.492 0.508 0.000 0.000
#> GSM1324893 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324905 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324906 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324907 1 0.0000 0.984 1.000 0.000 0.000 0.000 0.000
#> GSM1324911 4 0.6628 0.193 0.000 0.004 0.196 0.456 0.344
#> GSM1324912 1 0.3508 0.650 0.748 0.000 0.000 0.000 0.252
#> GSM1324913 4 0.0955 0.564 0.000 0.004 0.000 0.968 0.028
#> GSM1324917 4 0.4045 0.347 0.000 0.000 0.356 0.644 0.000
#> GSM1324918 4 0.0000 0.580 0.000 0.000 0.000 1.000 0.000
#> GSM1324919 4 0.4306 0.200 0.000 0.000 0.492 0.508 0.000
#> GSM1324923 4 0.4262 -0.267 0.000 0.440 0.000 0.560 0.000
#> GSM1324924 4 0.4262 -0.267 0.000 0.440 0.000 0.560 0.000
#> GSM1324925 4 0.4201 -0.198 0.000 0.408 0.000 0.592 0.000
#> GSM1324929 4 0.0162 0.580 0.000 0.004 0.000 0.996 0.000
#> GSM1324930 4 0.0162 0.580 0.000 0.004 0.000 0.996 0.000
#> GSM1324931 4 0.0162 0.580 0.000 0.004 0.000 0.996 0.000
#> GSM1324935 2 0.4306 0.162 0.000 0.508 0.000 0.000 0.492
#> GSM1324936 2 0.4306 0.162 0.000 0.508 0.000 0.000 0.492
#> GSM1324937 2 0.4307 0.150 0.000 0.504 0.000 0.000 0.496
#> GSM1324941 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324942 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324943 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324947 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324948 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
#> GSM1324949 5 0.0000 0.848 0.000 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324908 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324909 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.0000 0.906 0.00 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324916 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324920 4 0.0000 0.906 0.00 0.000 0 1.000 0.000 0.000
#> GSM1324921 4 0.0000 0.906 0.00 0.000 0 1.000 0.000 0.000
#> GSM1324922 4 0.0000 0.906 0.00 0.000 0 1.000 0.000 0.000
#> GSM1324926 3 0.0000 1.000 0.00 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.00 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.00 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.0000 0.841 0.00 1.000 0 0.000 0.000 0.000
#> GSM1324939 2 0.0000 0.841 0.00 1.000 0 0.000 0.000 0.000
#> GSM1324940 2 0.0000 0.841 0.00 1.000 0 0.000 0.000 0.000
#> GSM1324944 2 0.3699 0.609 0.00 0.660 0 0.000 0.336 0.004
#> GSM1324945 2 0.3684 0.616 0.00 0.664 0 0.000 0.332 0.004
#> GSM1324946 2 0.3684 0.616 0.00 0.664 0 0.000 0.332 0.004
#> GSM1324950 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.00 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.00 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.00 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324905 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324906 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324907 1 0.0000 0.982 1.00 0.000 0 0.000 0.000 0.000
#> GSM1324911 4 0.4101 0.514 0.00 0.000 0 0.664 0.308 0.028
#> GSM1324912 1 0.3309 0.605 0.72 0.000 0 0.000 0.280 0.000
#> GSM1324913 6 0.0891 0.970 0.00 0.000 0 0.024 0.008 0.968
#> GSM1324917 4 0.2340 0.786 0.00 0.000 0 0.852 0.000 0.148
#> GSM1324918 6 0.0547 0.982 0.00 0.000 0 0.020 0.000 0.980
#> GSM1324919 4 0.0000 0.906 0.00 0.000 0 1.000 0.000 0.000
#> GSM1324923 6 0.0146 0.990 0.00 0.004 0 0.000 0.000 0.996
#> GSM1324924 6 0.0000 0.990 0.00 0.000 0 0.000 0.000 1.000
#> GSM1324925 6 0.0000 0.990 0.00 0.000 0 0.000 0.000 1.000
#> GSM1324929 6 0.0146 0.991 0.00 0.000 0 0.004 0.000 0.996
#> GSM1324930 6 0.0146 0.991 0.00 0.000 0 0.004 0.000 0.996
#> GSM1324931 6 0.0146 0.991 0.00 0.000 0 0.004 0.000 0.996
#> GSM1324935 2 0.0000 0.841 0.00 1.000 0 0.000 0.000 0.000
#> GSM1324936 2 0.0000 0.841 0.00 1.000 0 0.000 0.000 0.000
#> GSM1324937 2 0.0000 0.841 0.00 1.000 0 0.000 0.000 0.000
#> GSM1324941 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324942 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324943 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324947 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 1.000 0.00 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 1.000 0.00 0.000 0 0.000 1.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 agent(p) individual(p) k
#> CV:pam 60 0.03142 3.87e-06 2
#> CV:pam 60 0.01235 5.80e-09 3
#> CV:pam 59 0.03742 1.97e-12 4
#> CV:pam 41 0.00330 1.49e-08 5
#> CV:pam 60 0.00309 1.11e-17 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.429 0.307 0.605 0.4571 0.655 0.655
#> 3 3 0.769 0.858 0.915 0.2854 0.454 0.343
#> 4 4 0.782 0.850 0.908 0.1967 0.824 0.618
#> 5 5 0.823 0.693 0.816 0.0976 0.895 0.656
#> 6 6 0.788 0.789 0.860 0.0554 0.912 0.638
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
#> GSM1324896 1 0.999 -0.154 0.520 0.480
#> GSM1324897 1 0.999 -0.154 0.520 0.480
#> GSM1324898 1 0.999 -0.154 0.520 0.480
#> GSM1324902 1 0.999 -0.154 0.520 0.480
#> GSM1324903 1 0.999 -0.154 0.520 0.480
#> GSM1324904 1 0.999 -0.154 0.520 0.480
#> GSM1324908 2 0.430 0.903 0.088 0.912
#> GSM1324909 1 0.999 -0.154 0.520 0.480
#> GSM1324910 1 0.999 -0.154 0.520 0.480
#> GSM1324914 2 0.163 0.908 0.024 0.976
#> GSM1324915 1 0.999 -0.154 0.520 0.480
#> GSM1324916 1 0.999 -0.154 0.520 0.480
#> GSM1324920 2 0.000 0.897 0.000 1.000
#> GSM1324921 2 0.000 0.897 0.000 1.000
#> GSM1324922 2 0.000 0.897 0.000 1.000
#> GSM1324926 1 0.990 0.254 0.560 0.440
#> GSM1324927 1 0.990 0.254 0.560 0.440
#> GSM1324928 1 0.990 0.254 0.560 0.440
#> GSM1324938 1 0.987 0.329 0.568 0.432
#> GSM1324939 1 0.987 0.329 0.568 0.432
#> GSM1324940 1 0.987 0.329 0.568 0.432
#> GSM1324944 1 0.993 0.327 0.548 0.452
#> GSM1324945 1 0.993 0.327 0.548 0.452
#> GSM1324946 1 0.993 0.327 0.548 0.452
#> GSM1324950 1 0.993 0.327 0.548 0.452
#> GSM1324951 1 0.993 0.327 0.548 0.452
#> GSM1324952 1 0.993 0.327 0.548 0.452
#> GSM1324932 1 0.990 0.254 0.560 0.440
#> GSM1324933 1 0.990 0.254 0.560 0.440
#> GSM1324934 1 0.990 0.254 0.560 0.440
#> GSM1324893 1 0.999 -0.154 0.520 0.480
#> GSM1324894 1 0.999 -0.154 0.520 0.480
#> GSM1324895 1 0.999 -0.154 0.520 0.480
#> GSM1324899 1 0.999 -0.154 0.520 0.480
#> GSM1324900 1 0.999 -0.154 0.520 0.480
#> GSM1324901 1 0.999 -0.154 0.520 0.480
#> GSM1324905 2 0.430 0.903 0.088 0.912
#> GSM1324906 2 0.430 0.903 0.088 0.912
#> GSM1324907 1 0.999 -0.154 0.520 0.480
#> GSM1324911 2 0.416 0.906 0.084 0.916
#> GSM1324912 2 0.430 0.903 0.088 0.912
#> GSM1324913 2 0.416 0.906 0.084 0.916
#> GSM1324917 2 0.000 0.897 0.000 1.000
#> GSM1324918 2 0.260 0.910 0.044 0.956
#> GSM1324919 2 0.000 0.897 0.000 1.000
#> GSM1324923 1 0.998 0.320 0.524 0.476
#> GSM1324924 1 0.999 0.318 0.520 0.480
#> GSM1324925 1 1.000 0.313 0.512 0.488
#> GSM1324929 1 0.997 0.314 0.532 0.468
#> GSM1324930 1 0.997 0.314 0.532 0.468
#> GSM1324931 1 0.997 0.314 0.532 0.468
#> GSM1324935 1 0.993 0.327 0.548 0.452
#> GSM1324936 1 0.993 0.327 0.548 0.452
#> GSM1324937 1 0.993 0.327 0.548 0.452
#> GSM1324941 1 0.993 0.327 0.548 0.452
#> GSM1324942 1 0.993 0.327 0.548 0.452
#> GSM1324943 1 0.993 0.327 0.548 0.452
#> GSM1324947 1 0.993 0.327 0.548 0.452
#> GSM1324948 1 0.993 0.327 0.548 0.452
#> GSM1324949 1 0.993 0.327 0.548 0.452
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324908 2 0.7504 0.636 0.060 0.628 0.312
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324914 2 0.6247 0.618 0.004 0.620 0.376
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324920 2 0.6330 0.591 0.004 0.600 0.396
#> GSM1324921 2 0.6330 0.591 0.004 0.600 0.396
#> GSM1324922 2 0.6298 0.602 0.004 0.608 0.388
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324938 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324950 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324951 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324952 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324905 2 0.5497 0.706 0.000 0.708 0.292
#> GSM1324906 2 0.5497 0.706 0.000 0.708 0.292
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324911 2 0.5722 0.705 0.004 0.704 0.292
#> GSM1324912 2 0.7391 0.645 0.056 0.636 0.308
#> GSM1324913 2 0.5722 0.705 0.004 0.704 0.292
#> GSM1324917 2 0.6330 0.591 0.004 0.600 0.396
#> GSM1324918 2 0.6247 0.618 0.004 0.620 0.376
#> GSM1324919 2 0.6330 0.591 0.004 0.600 0.396
#> GSM1324923 2 0.2496 0.833 0.004 0.928 0.068
#> GSM1324924 2 0.2496 0.833 0.004 0.928 0.068
#> GSM1324925 2 0.2496 0.833 0.004 0.928 0.068
#> GSM1324929 2 0.2496 0.833 0.004 0.928 0.068
#> GSM1324930 2 0.2496 0.833 0.004 0.928 0.068
#> GSM1324931 2 0.2496 0.833 0.004 0.928 0.068
#> GSM1324935 2 0.0237 0.843 0.004 0.996 0.000
#> GSM1324936 2 0.0237 0.843 0.004 0.996 0.000
#> GSM1324937 2 0.0237 0.843 0.004 0.996 0.000
#> GSM1324941 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324947 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324948 2 0.0000 0.844 0.000 1.000 0.000
#> GSM1324949 2 0.0000 0.844 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324897 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324898 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324902 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324903 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324904 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324908 4 0.4706 0.726 0.02 0.248 0 0.732
#> GSM1324909 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324910 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324914 4 0.0000 0.827 0.00 0.000 0 1.000
#> GSM1324915 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324916 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324920 4 0.0000 0.827 0.00 0.000 0 1.000
#> GSM1324921 4 0.0000 0.827 0.00 0.000 0 1.000
#> GSM1324922 4 0.0000 0.827 0.00 0.000 0 1.000
#> GSM1324926 3 0.0000 1.000 0.00 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.00 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.00 0.000 1 0.000
#> GSM1324938 2 0.2281 0.816 0.00 0.904 0 0.096
#> GSM1324939 2 0.2281 0.816 0.00 0.904 0 0.096
#> GSM1324940 2 0.2281 0.816 0.00 0.904 0 0.096
#> GSM1324944 2 0.3123 0.804 0.00 0.844 0 0.156
#> GSM1324945 2 0.3266 0.799 0.00 0.832 0 0.168
#> GSM1324946 2 0.3172 0.804 0.00 0.840 0 0.160
#> GSM1324950 2 0.0000 0.796 0.00 1.000 0 0.000
#> GSM1324951 2 0.0000 0.796 0.00 1.000 0 0.000
#> GSM1324952 2 0.0000 0.796 0.00 1.000 0 0.000
#> GSM1324932 3 0.0000 1.000 0.00 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.00 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.00 0.000 1 0.000
#> GSM1324893 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324894 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324895 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324899 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324900 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324901 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324905 4 0.4356 0.684 0.00 0.292 0 0.708
#> GSM1324906 4 0.4382 0.679 0.00 0.296 0 0.704
#> GSM1324907 1 0.0000 1.000 1.00 0.000 0 0.000
#> GSM1324911 4 0.4008 0.716 0.00 0.244 0 0.756
#> GSM1324912 4 0.4737 0.722 0.02 0.252 0 0.728
#> GSM1324913 4 0.3975 0.717 0.00 0.240 0 0.760
#> GSM1324917 4 0.0000 0.827 0.00 0.000 0 1.000
#> GSM1324918 4 0.0188 0.827 0.00 0.004 0 0.996
#> GSM1324919 4 0.0000 0.827 0.00 0.000 0 1.000
#> GSM1324923 2 0.4605 0.656 0.00 0.664 0 0.336
#> GSM1324924 2 0.4605 0.656 0.00 0.664 0 0.336
#> GSM1324925 2 0.4605 0.656 0.00 0.664 0 0.336
#> GSM1324929 2 0.4898 0.549 0.00 0.584 0 0.416
#> GSM1324930 2 0.4898 0.549 0.00 0.584 0 0.416
#> GSM1324931 2 0.4898 0.549 0.00 0.584 0 0.416
#> GSM1324935 2 0.4103 0.750 0.00 0.744 0 0.256
#> GSM1324936 2 0.3907 0.770 0.00 0.768 0 0.232
#> GSM1324937 2 0.4008 0.760 0.00 0.756 0 0.244
#> GSM1324941 2 0.1022 0.807 0.00 0.968 0 0.032
#> GSM1324942 2 0.1022 0.807 0.00 0.968 0 0.032
#> GSM1324943 2 0.1022 0.807 0.00 0.968 0 0.032
#> GSM1324947 2 0.0000 0.796 0.00 1.000 0 0.000
#> GSM1324948 2 0.0000 0.796 0.00 1.000 0 0.000
#> GSM1324949 2 0.0000 0.796 0.00 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324908 5 0.5156 0.0219 0.020 0.220 0 0.060 0.700
#> GSM1324909 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.4242 0.9814 0.000 0.000 0 0.572 0.428
#> GSM1324915 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324916 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324920 4 0.4235 0.9840 0.000 0.000 0 0.576 0.424
#> GSM1324921 4 0.4235 0.9840 0.000 0.000 0 0.576 0.424
#> GSM1324922 4 0.4235 0.9840 0.000 0.000 0 0.576 0.424
#> GSM1324926 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.2516 0.5945 0.000 0.860 0 0.000 0.140
#> GSM1324939 2 0.2516 0.5945 0.000 0.860 0 0.000 0.140
#> GSM1324940 2 0.2516 0.5945 0.000 0.860 0 0.000 0.140
#> GSM1324944 2 0.2471 0.5942 0.000 0.864 0 0.000 0.136
#> GSM1324945 2 0.2471 0.5942 0.000 0.864 0 0.000 0.136
#> GSM1324946 2 0.2471 0.5942 0.000 0.864 0 0.000 0.136
#> GSM1324950 5 0.6590 0.3417 0.000 0.320 0 0.228 0.452
#> GSM1324951 5 0.6590 0.3417 0.000 0.320 0 0.228 0.452
#> GSM1324952 5 0.6590 0.3417 0.000 0.320 0 0.228 0.452
#> GSM1324932 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.0000 1.0000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.0000 0.9997 1.000 0.000 0 0.000 0.000
#> GSM1324905 5 0.3707 0.2035 0.000 0.284 0 0.000 0.716
#> GSM1324906 5 0.3707 0.2035 0.000 0.284 0 0.000 0.716
#> GSM1324907 1 0.0162 0.9951 0.996 0.000 0 0.000 0.004
#> GSM1324911 5 0.4268 0.0443 0.000 0.444 0 0.000 0.556
#> GSM1324912 5 0.4434 0.1281 0.020 0.248 0 0.012 0.720
#> GSM1324913 5 0.4268 0.0443 0.000 0.444 0 0.000 0.556
#> GSM1324917 4 0.4235 0.9840 0.000 0.000 0 0.576 0.424
#> GSM1324918 4 0.5435 0.9038 0.000 0.060 0 0.512 0.428
#> GSM1324919 4 0.4235 0.9840 0.000 0.000 0 0.576 0.424
#> GSM1324923 2 0.5045 0.5066 0.000 0.696 0 0.196 0.108
#> GSM1324924 2 0.5045 0.5066 0.000 0.696 0 0.196 0.108
#> GSM1324925 2 0.5045 0.5066 0.000 0.696 0 0.196 0.108
#> GSM1324929 2 0.5091 0.5068 0.000 0.692 0 0.196 0.112
#> GSM1324930 2 0.5091 0.5068 0.000 0.692 0 0.196 0.112
#> GSM1324931 2 0.5091 0.5068 0.000 0.692 0 0.196 0.112
#> GSM1324935 2 0.0609 0.6063 0.000 0.980 0 0.000 0.020
#> GSM1324936 2 0.0000 0.6078 0.000 1.000 0 0.000 0.000
#> GSM1324937 2 0.0880 0.6044 0.000 0.968 0 0.000 0.032
#> GSM1324941 2 0.4161 0.2136 0.000 0.608 0 0.000 0.392
#> GSM1324942 2 0.4161 0.2136 0.000 0.608 0 0.000 0.392
#> GSM1324943 2 0.4161 0.2136 0.000 0.608 0 0.000 0.392
#> GSM1324947 5 0.6590 0.3417 0.000 0.320 0 0.228 0.452
#> GSM1324948 5 0.6590 0.3417 0.000 0.320 0 0.228 0.452
#> GSM1324949 5 0.6590 0.3417 0.000 0.320 0 0.228 0.452
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.1921 0.902 0.916 0.032 0 0.000 0.000 0.052
#> GSM1324897 1 0.1921 0.902 0.916 0.032 0 0.000 0.000 0.052
#> GSM1324898 1 0.1921 0.902 0.916 0.032 0 0.000 0.000 0.052
#> GSM1324902 1 0.0777 0.925 0.972 0.004 0 0.000 0.000 0.024
#> GSM1324903 1 0.0777 0.925 0.972 0.004 0 0.000 0.000 0.024
#> GSM1324904 1 0.0777 0.925 0.972 0.004 0 0.000 0.000 0.024
#> GSM1324908 4 0.5253 0.110 0.000 0.080 0 0.540 0.008 0.372
#> GSM1324909 1 0.0806 0.920 0.972 0.020 0 0.000 0.000 0.008
#> GSM1324910 1 0.0806 0.920 0.972 0.020 0 0.000 0.000 0.008
#> GSM1324914 4 0.0260 0.745 0.000 0.000 0 0.992 0.000 0.008
#> GSM1324915 1 0.2911 0.897 0.832 0.144 0 0.000 0.000 0.024
#> GSM1324916 1 0.2911 0.897 0.832 0.144 0 0.000 0.000 0.024
#> GSM1324920 4 0.0146 0.747 0.000 0.000 0 0.996 0.000 0.004
#> GSM1324921 4 0.0146 0.747 0.000 0.000 0 0.996 0.000 0.004
#> GSM1324922 4 0.0146 0.747 0.000 0.000 0 0.996 0.000 0.004
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.3202 0.855 0.000 0.800 0 0.000 0.176 0.024
#> GSM1324939 2 0.3202 0.855 0.000 0.800 0 0.000 0.176 0.024
#> GSM1324940 2 0.3202 0.855 0.000 0.800 0 0.000 0.176 0.024
#> GSM1324944 2 0.2664 0.854 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324945 2 0.2664 0.854 0.000 0.816 0 0.000 0.184 0.000
#> GSM1324946 2 0.3189 0.853 0.000 0.796 0 0.000 0.184 0.020
#> GSM1324950 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.1492 0.925 0.940 0.036 0 0.000 0.000 0.024
#> GSM1324894 1 0.2333 0.915 0.884 0.092 0 0.000 0.000 0.024
#> GSM1324895 1 0.1829 0.923 0.920 0.056 0 0.000 0.000 0.024
#> GSM1324899 1 0.2300 0.901 0.856 0.144 0 0.000 0.000 0.000
#> GSM1324900 1 0.2300 0.901 0.856 0.144 0 0.000 0.000 0.000
#> GSM1324901 1 0.2300 0.901 0.856 0.144 0 0.000 0.000 0.000
#> GSM1324905 4 0.7315 0.324 0.000 0.192 0 0.428 0.200 0.180
#> GSM1324906 4 0.7315 0.324 0.000 0.192 0 0.428 0.200 0.180
#> GSM1324907 1 0.1921 0.902 0.916 0.032 0 0.000 0.000 0.052
#> GSM1324911 6 0.5204 -0.129 0.000 0.068 0 0.428 0.008 0.496
#> GSM1324912 4 0.5916 0.228 0.000 0.120 0 0.540 0.032 0.308
#> GSM1324913 6 0.5204 -0.129 0.000 0.068 0 0.428 0.008 0.496
#> GSM1324917 4 0.0000 0.747 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324918 4 0.1957 0.698 0.000 0.000 0 0.888 0.000 0.112
#> GSM1324919 4 0.0000 0.747 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324923 6 0.2871 0.776 0.000 0.192 0 0.000 0.004 0.804
#> GSM1324924 6 0.2871 0.776 0.000 0.192 0 0.000 0.004 0.804
#> GSM1324925 6 0.2871 0.776 0.000 0.192 0 0.000 0.004 0.804
#> GSM1324929 6 0.2941 0.771 0.000 0.220 0 0.000 0.000 0.780
#> GSM1324930 6 0.2941 0.771 0.000 0.220 0 0.000 0.000 0.780
#> GSM1324931 6 0.2941 0.771 0.000 0.220 0 0.000 0.000 0.780
#> GSM1324935 2 0.2871 0.657 0.000 0.804 0 0.000 0.004 0.192
#> GSM1324936 2 0.2738 0.666 0.000 0.820 0 0.000 0.004 0.176
#> GSM1324937 2 0.2871 0.662 0.000 0.804 0 0.000 0.004 0.192
#> GSM1324941 2 0.3515 0.740 0.000 0.676 0 0.000 0.324 0.000
#> GSM1324942 2 0.3515 0.740 0.000 0.676 0 0.000 0.324 0.000
#> GSM1324943 2 0.3515 0.740 0.000 0.676 0 0.000 0.324 0.000
#> GSM1324947 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 1.000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> CV:mclust 13 NA NA 2
#> CV:mclust 60 0.0128 7.01e-09 3
#> CV:mclust 60 0.0332 2.98e-12 4
#> CV:mclust 45 0.0963 4.96e-10 5
#> CV:mclust 54 0.0292 8.14e-19 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.633 0.856 0.937 0.3645 0.636 0.636
#> 3 3 0.856 0.894 0.959 0.6721 0.627 0.464
#> 4 4 0.710 0.815 0.873 0.1930 0.801 0.534
#> 5 5 0.711 0.669 0.830 0.0590 0.953 0.834
#> 6 6 0.696 0.593 0.744 0.0441 0.931 0.745
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
#> GSM1324896 1 0.0000 0.9411 1.000 0.000
#> GSM1324897 1 0.0000 0.9411 1.000 0.000
#> GSM1324898 1 0.0000 0.9411 1.000 0.000
#> GSM1324902 1 0.0000 0.9411 1.000 0.000
#> GSM1324903 1 0.0000 0.9411 1.000 0.000
#> GSM1324904 1 0.0000 0.9411 1.000 0.000
#> GSM1324908 1 0.0000 0.9411 1.000 0.000
#> GSM1324909 1 0.0000 0.9411 1.000 0.000
#> GSM1324910 1 0.0000 0.9411 1.000 0.000
#> GSM1324914 2 0.6148 0.8385 0.152 0.848
#> GSM1324915 1 0.0000 0.9411 1.000 0.000
#> GSM1324916 1 0.0000 0.9411 1.000 0.000
#> GSM1324920 1 0.9993 -0.0859 0.516 0.484
#> GSM1324921 1 0.9710 0.2511 0.600 0.400
#> GSM1324922 1 0.1414 0.9254 0.980 0.020
#> GSM1324926 2 0.0000 0.8668 0.000 1.000
#> GSM1324927 2 0.0000 0.8668 0.000 1.000
#> GSM1324928 2 0.0000 0.8668 0.000 1.000
#> GSM1324938 1 0.6531 0.7593 0.832 0.168
#> GSM1324939 1 0.9710 0.2515 0.600 0.400
#> GSM1324940 1 0.5178 0.8270 0.884 0.116
#> GSM1324944 1 0.0000 0.9411 1.000 0.000
#> GSM1324945 1 0.0000 0.9411 1.000 0.000
#> GSM1324946 1 0.0938 0.9321 0.988 0.012
#> GSM1324950 1 0.0000 0.9411 1.000 0.000
#> GSM1324951 1 0.0000 0.9411 1.000 0.000
#> GSM1324952 1 0.0000 0.9411 1.000 0.000
#> GSM1324932 2 0.0000 0.8668 0.000 1.000
#> GSM1324933 2 0.0000 0.8668 0.000 1.000
#> GSM1324934 2 0.0000 0.8668 0.000 1.000
#> GSM1324893 1 0.0000 0.9411 1.000 0.000
#> GSM1324894 1 0.0000 0.9411 1.000 0.000
#> GSM1324895 1 0.0000 0.9411 1.000 0.000
#> GSM1324899 1 0.0000 0.9411 1.000 0.000
#> GSM1324900 1 0.0000 0.9411 1.000 0.000
#> GSM1324901 1 0.0000 0.9411 1.000 0.000
#> GSM1324905 1 0.0000 0.9411 1.000 0.000
#> GSM1324906 1 0.0000 0.9411 1.000 0.000
#> GSM1324907 1 0.0000 0.9411 1.000 0.000
#> GSM1324911 1 0.0672 0.9352 0.992 0.008
#> GSM1324912 1 0.0000 0.9411 1.000 0.000
#> GSM1324913 1 0.4022 0.8675 0.920 0.080
#> GSM1324917 2 0.5842 0.8673 0.140 0.860
#> GSM1324918 2 0.6531 0.8591 0.168 0.832
#> GSM1324919 2 0.7219 0.8253 0.200 0.800
#> GSM1324923 1 0.7299 0.7047 0.796 0.204
#> GSM1324924 1 0.9358 0.3941 0.648 0.352
#> GSM1324925 2 0.9552 0.4949 0.376 0.624
#> GSM1324929 2 0.6531 0.8593 0.168 0.832
#> GSM1324930 2 0.6531 0.8593 0.168 0.832
#> GSM1324931 2 0.6623 0.8559 0.172 0.828
#> GSM1324935 1 0.0000 0.9411 1.000 0.000
#> GSM1324936 1 0.0000 0.9411 1.000 0.000
#> GSM1324937 1 0.0000 0.9411 1.000 0.000
#> GSM1324941 1 0.0000 0.9411 1.000 0.000
#> GSM1324942 1 0.0000 0.9411 1.000 0.000
#> GSM1324943 1 0.0000 0.9411 1.000 0.000
#> GSM1324947 1 0.0000 0.9411 1.000 0.000
#> GSM1324948 1 0.0000 0.9411 1.000 0.000
#> GSM1324949 1 0.0000 0.9411 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324897 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324898 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324902 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324903 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324904 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324908 1 0.5785 0.4691 0.668 0.332 0.000
#> GSM1324909 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324910 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324914 3 0.2356 0.8535 0.000 0.072 0.928
#> GSM1324915 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324916 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324920 2 0.4702 0.6873 0.000 0.788 0.212
#> GSM1324921 2 0.3551 0.8105 0.000 0.868 0.132
#> GSM1324922 2 0.0237 0.9490 0.000 0.996 0.004
#> GSM1324926 3 0.0000 0.8789 0.000 0.000 1.000
#> GSM1324927 3 0.0000 0.8789 0.000 0.000 1.000
#> GSM1324928 3 0.0000 0.8789 0.000 0.000 1.000
#> GSM1324938 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324950 2 0.0237 0.9489 0.004 0.996 0.000
#> GSM1324951 2 0.2959 0.8508 0.100 0.900 0.000
#> GSM1324952 2 0.6280 0.1535 0.460 0.540 0.000
#> GSM1324932 3 0.0000 0.8789 0.000 0.000 1.000
#> GSM1324933 3 0.0000 0.8789 0.000 0.000 1.000
#> GSM1324934 3 0.0000 0.8789 0.000 0.000 1.000
#> GSM1324893 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324894 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324895 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324899 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324900 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324901 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324905 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324906 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324907 1 0.0000 0.9730 1.000 0.000 0.000
#> GSM1324911 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324912 1 0.1163 0.9400 0.972 0.028 0.000
#> GSM1324913 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324917 3 0.4178 0.7933 0.000 0.172 0.828
#> GSM1324918 3 0.6309 0.0784 0.000 0.500 0.500
#> GSM1324919 3 0.4235 0.7895 0.000 0.176 0.824
#> GSM1324923 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324924 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324925 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324929 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324930 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324931 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324935 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324941 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.9517 0.000 1.000 0.000
#> GSM1324947 2 0.4702 0.7006 0.212 0.788 0.000
#> GSM1324948 2 0.0747 0.9389 0.016 0.984 0.000
#> GSM1324949 2 0.1529 0.9166 0.040 0.960 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.2011 0.920 0.920 0.080 0.000 0.000
#> GSM1324897 1 0.1792 0.930 0.932 0.068 0.000 0.000
#> GSM1324898 1 0.1867 0.927 0.928 0.072 0.000 0.000
#> GSM1324902 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> GSM1324903 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> GSM1324904 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM1324908 4 0.4880 0.686 0.188 0.052 0.000 0.760
#> GSM1324909 1 0.0469 0.962 0.988 0.012 0.000 0.000
#> GSM1324910 1 0.0469 0.962 0.988 0.012 0.000 0.000
#> GSM1324914 4 0.4516 0.590 0.000 0.012 0.252 0.736
#> GSM1324915 1 0.1509 0.948 0.960 0.008 0.012 0.020
#> GSM1324916 1 0.0657 0.961 0.984 0.004 0.000 0.012
#> GSM1324920 4 0.2528 0.764 0.080 0.008 0.004 0.908
#> GSM1324921 4 0.2859 0.749 0.112 0.008 0.000 0.880
#> GSM1324922 4 0.3819 0.696 0.172 0.004 0.008 0.816
#> GSM1324926 3 0.0817 0.981 0.000 0.000 0.976 0.024
#> GSM1324927 3 0.0921 0.983 0.000 0.000 0.972 0.028
#> GSM1324928 3 0.0921 0.983 0.000 0.000 0.972 0.028
#> GSM1324938 2 0.3486 0.840 0.000 0.812 0.000 0.188
#> GSM1324939 2 0.3486 0.840 0.000 0.812 0.000 0.188
#> GSM1324940 2 0.3356 0.842 0.000 0.824 0.000 0.176
#> GSM1324944 2 0.3649 0.835 0.000 0.796 0.000 0.204
#> GSM1324945 2 0.3764 0.829 0.000 0.784 0.000 0.216
#> GSM1324946 2 0.3801 0.826 0.000 0.780 0.000 0.220
#> GSM1324950 2 0.0895 0.788 0.020 0.976 0.000 0.004
#> GSM1324951 2 0.1004 0.785 0.024 0.972 0.000 0.004
#> GSM1324952 2 0.1661 0.758 0.052 0.944 0.000 0.004
#> GSM1324932 3 0.0469 0.983 0.000 0.000 0.988 0.012
#> GSM1324933 3 0.0469 0.983 0.000 0.000 0.988 0.012
#> GSM1324934 3 0.0469 0.983 0.000 0.000 0.988 0.012
#> GSM1324893 1 0.0469 0.961 0.988 0.000 0.000 0.012
#> GSM1324894 1 0.0592 0.959 0.984 0.000 0.000 0.016
#> GSM1324895 1 0.0336 0.964 0.992 0.000 0.000 0.008
#> GSM1324899 1 0.0000 0.965 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> GSM1324901 1 0.0188 0.965 0.996 0.000 0.000 0.004
#> GSM1324905 4 0.4500 0.671 0.000 0.316 0.000 0.684
#> GSM1324906 4 0.4431 0.675 0.000 0.304 0.000 0.696
#> GSM1324907 1 0.3486 0.802 0.812 0.188 0.000 0.000
#> GSM1324911 4 0.2281 0.756 0.000 0.096 0.000 0.904
#> GSM1324912 4 0.7010 0.529 0.240 0.184 0.000 0.576
#> GSM1324913 4 0.2281 0.756 0.000 0.096 0.000 0.904
#> GSM1324917 4 0.2586 0.761 0.012 0.008 0.068 0.912
#> GSM1324918 4 0.1398 0.768 0.000 0.040 0.004 0.956
#> GSM1324919 4 0.3544 0.757 0.076 0.008 0.044 0.872
#> GSM1324923 2 0.4994 0.376 0.000 0.520 0.000 0.480
#> GSM1324924 2 0.4994 0.376 0.000 0.520 0.000 0.480
#> GSM1324925 4 0.2868 0.706 0.000 0.136 0.000 0.864
#> GSM1324929 4 0.4285 0.714 0.000 0.104 0.076 0.820
#> GSM1324930 4 0.5863 0.621 0.000 0.120 0.180 0.700
#> GSM1324931 4 0.7297 0.293 0.000 0.244 0.220 0.536
#> GSM1324935 2 0.3873 0.818 0.000 0.772 0.000 0.228
#> GSM1324936 2 0.3688 0.832 0.000 0.792 0.000 0.208
#> GSM1324937 2 0.3649 0.834 0.000 0.796 0.000 0.204
#> GSM1324941 2 0.2408 0.837 0.000 0.896 0.000 0.104
#> GSM1324942 2 0.2345 0.836 0.000 0.900 0.000 0.100
#> GSM1324943 2 0.2469 0.838 0.000 0.892 0.000 0.108
#> GSM1324947 2 0.1211 0.770 0.040 0.960 0.000 0.000
#> GSM1324948 2 0.0927 0.792 0.016 0.976 0.000 0.008
#> GSM1324949 2 0.1004 0.785 0.024 0.972 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 5 0.4287 0.0462 0.460 0.000 0.000 0.000 0.540
#> GSM1324897 1 0.4300 -0.1476 0.524 0.000 0.000 0.000 0.476
#> GSM1324898 1 0.4283 -0.0570 0.544 0.000 0.000 0.000 0.456
#> GSM1324902 1 0.0794 0.7970 0.972 0.000 0.000 0.000 0.028
#> GSM1324903 1 0.0794 0.7953 0.972 0.000 0.000 0.000 0.028
#> GSM1324904 1 0.0703 0.7976 0.976 0.000 0.000 0.000 0.024
#> GSM1324908 4 0.3929 0.6289 0.116 0.028 0.000 0.820 0.036
#> GSM1324909 1 0.3003 0.6762 0.812 0.000 0.000 0.000 0.188
#> GSM1324910 1 0.3003 0.6762 0.812 0.000 0.000 0.000 0.188
#> GSM1324914 4 0.4069 0.6023 0.000 0.000 0.136 0.788 0.076
#> GSM1324915 1 0.4350 0.5892 0.704 0.000 0.000 0.028 0.268
#> GSM1324916 1 0.3060 0.7346 0.848 0.000 0.000 0.024 0.128
#> GSM1324920 4 0.0960 0.7280 0.016 0.004 0.000 0.972 0.008
#> GSM1324921 4 0.1179 0.7269 0.016 0.004 0.000 0.964 0.016
#> GSM1324922 4 0.3712 0.6386 0.124 0.004 0.000 0.820 0.052
#> GSM1324926 3 0.2423 0.9458 0.000 0.000 0.896 0.024 0.080
#> GSM1324927 3 0.2300 0.9489 0.000 0.000 0.904 0.024 0.072
#> GSM1324928 3 0.2300 0.9489 0.000 0.000 0.904 0.024 0.072
#> GSM1324938 2 0.1282 0.8583 0.000 0.952 0.000 0.004 0.044
#> GSM1324939 2 0.1282 0.8583 0.000 0.952 0.000 0.004 0.044
#> GSM1324940 2 0.1502 0.8567 0.000 0.940 0.000 0.004 0.056
#> GSM1324944 2 0.0693 0.8620 0.000 0.980 0.000 0.012 0.008
#> GSM1324945 2 0.0992 0.8592 0.000 0.968 0.000 0.024 0.008
#> GSM1324946 2 0.0912 0.8618 0.000 0.972 0.000 0.016 0.012
#> GSM1324950 2 0.1908 0.8469 0.000 0.908 0.000 0.000 0.092
#> GSM1324951 2 0.2690 0.7993 0.000 0.844 0.000 0.000 0.156
#> GSM1324952 2 0.4171 0.4652 0.000 0.604 0.000 0.000 0.396
#> GSM1324932 3 0.0000 0.9501 0.000 0.000 1.000 0.000 0.000
#> GSM1324933 3 0.0000 0.9501 0.000 0.000 1.000 0.000 0.000
#> GSM1324934 3 0.0000 0.9501 0.000 0.000 1.000 0.000 0.000
#> GSM1324893 1 0.1410 0.7775 0.940 0.000 0.000 0.000 0.060
#> GSM1324894 1 0.1410 0.7775 0.940 0.000 0.000 0.000 0.060
#> GSM1324895 1 0.1410 0.7775 0.940 0.000 0.000 0.000 0.060
#> GSM1324899 1 0.1043 0.7968 0.960 0.000 0.000 0.000 0.040
#> GSM1324900 1 0.1121 0.7946 0.956 0.000 0.000 0.000 0.044
#> GSM1324901 1 0.0609 0.7986 0.980 0.000 0.000 0.000 0.020
#> GSM1324905 4 0.5964 0.2775 0.000 0.124 0.000 0.536 0.340
#> GSM1324906 4 0.5941 0.2909 0.000 0.124 0.000 0.544 0.332
#> GSM1324907 5 0.3876 0.3744 0.316 0.000 0.000 0.000 0.684
#> GSM1324911 4 0.2505 0.7162 0.000 0.092 0.000 0.888 0.020
#> GSM1324912 5 0.6668 -0.0866 0.088 0.044 0.000 0.400 0.468
#> GSM1324913 4 0.2505 0.7167 0.000 0.092 0.000 0.888 0.020
#> GSM1324917 4 0.1121 0.7326 0.008 0.016 0.004 0.968 0.004
#> GSM1324918 4 0.0794 0.7311 0.000 0.028 0.000 0.972 0.000
#> GSM1324919 4 0.1179 0.7322 0.016 0.016 0.000 0.964 0.004
#> GSM1324923 2 0.4402 0.4525 0.000 0.636 0.000 0.352 0.012
#> GSM1324924 2 0.4323 0.4867 0.000 0.656 0.000 0.332 0.012
#> GSM1324925 4 0.4444 0.3410 0.000 0.364 0.000 0.624 0.012
#> GSM1324929 4 0.5632 0.5003 0.000 0.088 0.264 0.636 0.012
#> GSM1324930 4 0.6861 0.2478 0.000 0.208 0.328 0.452 0.012
#> GSM1324931 2 0.6941 0.0204 0.000 0.424 0.220 0.344 0.012
#> GSM1324935 2 0.2236 0.8434 0.000 0.908 0.000 0.024 0.068
#> GSM1324936 2 0.1943 0.8489 0.000 0.924 0.000 0.020 0.056
#> GSM1324937 2 0.2110 0.8467 0.000 0.912 0.000 0.016 0.072
#> GSM1324941 2 0.1341 0.8599 0.000 0.944 0.000 0.000 0.056
#> GSM1324942 2 0.1121 0.8617 0.000 0.956 0.000 0.000 0.044
#> GSM1324943 2 0.1121 0.8617 0.000 0.956 0.000 0.000 0.044
#> GSM1324947 2 0.1478 0.8573 0.000 0.936 0.000 0.000 0.064
#> GSM1324948 2 0.1478 0.8561 0.000 0.936 0.000 0.000 0.064
#> GSM1324949 2 0.1270 0.8600 0.000 0.948 0.000 0.000 0.052
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 6 0.3872 0.4762 0.392 0.000 0.000 0.000 NA 0.604
#> GSM1324897 6 0.3991 0.3612 0.472 0.000 0.000 0.000 NA 0.524
#> GSM1324898 6 0.3868 0.2925 0.496 0.000 0.000 0.000 NA 0.504
#> GSM1324902 1 0.1141 0.8759 0.948 0.000 0.000 0.000 NA 0.052
#> GSM1324903 1 0.0547 0.8868 0.980 0.000 0.000 0.000 NA 0.020
#> GSM1324904 1 0.1075 0.8780 0.952 0.000 0.000 0.000 NA 0.048
#> GSM1324908 4 0.4693 0.5616 0.088 0.008 0.000 0.752 NA 0.040
#> GSM1324909 1 0.2902 0.6933 0.800 0.000 0.000 0.000 NA 0.196
#> GSM1324910 1 0.3081 0.6479 0.776 0.000 0.000 0.000 NA 0.220
#> GSM1324914 3 0.6132 0.2043 0.000 0.000 0.484 0.304 NA 0.016
#> GSM1324915 3 0.7205 0.1556 0.116 0.000 0.420 0.000 NA 0.248
#> GSM1324916 3 0.7363 -0.0664 0.324 0.000 0.356 0.000 NA 0.160
#> GSM1324920 4 0.2213 0.6348 0.000 0.000 0.004 0.888 NA 0.008
#> GSM1324921 4 0.2404 0.6323 0.004 0.000 0.004 0.880 NA 0.008
#> GSM1324922 4 0.3927 0.5923 0.052 0.000 0.008 0.800 NA 0.020
#> GSM1324926 3 0.1863 0.5872 0.000 0.000 0.896 0.000 NA 0.000
#> GSM1324927 3 0.0000 0.6154 0.000 0.000 1.000 0.000 NA 0.000
#> GSM1324928 3 0.0458 0.6164 0.000 0.000 0.984 0.000 NA 0.000
#> GSM1324938 2 0.2051 0.8007 0.000 0.916 0.000 0.008 NA 0.040
#> GSM1324939 2 0.2051 0.8012 0.000 0.916 0.000 0.008 NA 0.036
#> GSM1324940 2 0.2186 0.7988 0.000 0.908 0.000 0.008 NA 0.048
#> GSM1324944 2 0.3031 0.7870 0.000 0.852 0.000 0.032 NA 0.016
#> GSM1324945 2 0.3633 0.7619 0.000 0.808 0.000 0.052 NA 0.016
#> GSM1324946 2 0.3076 0.7784 0.000 0.840 0.000 0.044 NA 0.004
#> GSM1324950 2 0.2933 0.7457 0.000 0.796 0.000 0.000 NA 0.200
#> GSM1324951 2 0.3756 0.6323 0.004 0.676 0.000 0.000 NA 0.316
#> GSM1324952 2 0.4306 0.3965 0.004 0.520 0.000 0.000 NA 0.464
#> GSM1324932 3 0.3774 0.5465 0.000 0.000 0.592 0.000 NA 0.000
#> GSM1324933 3 0.3774 0.5465 0.000 0.000 0.592 0.000 NA 0.000
#> GSM1324934 3 0.3774 0.5465 0.000 0.000 0.592 0.000 NA 0.000
#> GSM1324893 1 0.0146 0.8851 0.996 0.000 0.000 0.000 NA 0.004
#> GSM1324894 1 0.0146 0.8851 0.996 0.000 0.000 0.000 NA 0.004
#> GSM1324895 1 0.0146 0.8851 0.996 0.000 0.000 0.000 NA 0.004
#> GSM1324899 1 0.1686 0.8696 0.924 0.000 0.000 0.000 NA 0.064
#> GSM1324900 1 0.1802 0.8573 0.916 0.000 0.000 0.000 NA 0.072
#> GSM1324901 1 0.1838 0.8574 0.916 0.000 0.000 0.000 NA 0.068
#> GSM1324905 4 0.6691 0.1812 0.000 0.100 0.000 0.404 NA 0.392
#> GSM1324906 4 0.6659 0.1875 0.000 0.100 0.000 0.412 NA 0.388
#> GSM1324907 6 0.3133 0.4967 0.212 0.008 0.000 0.000 NA 0.780
#> GSM1324911 4 0.3533 0.6286 0.000 0.052 0.000 0.824 NA 0.024
#> GSM1324912 6 0.7290 -0.1832 0.064 0.048 0.000 0.340 NA 0.428
#> GSM1324913 4 0.3533 0.6286 0.000 0.052 0.000 0.824 NA 0.024
#> GSM1324917 4 0.0405 0.6585 0.004 0.000 0.000 0.988 NA 0.000
#> GSM1324918 4 0.0508 0.6591 0.000 0.000 0.000 0.984 NA 0.004
#> GSM1324919 4 0.0622 0.6585 0.012 0.000 0.000 0.980 NA 0.000
#> GSM1324923 2 0.5572 0.1347 0.000 0.464 0.000 0.396 NA 0.000
#> GSM1324924 2 0.5509 0.2166 0.000 0.496 0.000 0.368 NA 0.000
#> GSM1324925 4 0.5100 0.3824 0.000 0.260 0.000 0.612 NA 0.000
#> GSM1324929 4 0.6275 0.2733 0.000 0.020 0.164 0.448 NA 0.004
#> GSM1324930 4 0.6523 0.2646 0.000 0.036 0.164 0.432 NA 0.004
#> GSM1324931 4 0.7235 0.2275 0.000 0.132 0.136 0.372 NA 0.004
#> GSM1324935 2 0.2620 0.7913 0.000 0.888 0.000 0.028 NA 0.052
#> GSM1324936 2 0.2556 0.7926 0.000 0.892 0.000 0.028 NA 0.048
#> GSM1324937 2 0.2541 0.7932 0.000 0.892 0.000 0.024 NA 0.052
#> GSM1324941 2 0.3118 0.7895 0.000 0.836 0.000 0.000 NA 0.092
#> GSM1324942 2 0.2277 0.8053 0.000 0.892 0.000 0.000 NA 0.076
#> GSM1324943 2 0.2179 0.8066 0.000 0.900 0.000 0.000 NA 0.064
#> GSM1324947 2 0.2482 0.7842 0.000 0.848 0.000 0.000 NA 0.148
#> GSM1324948 2 0.2389 0.7932 0.000 0.864 0.000 0.000 NA 0.128
#> GSM1324949 2 0.1471 0.8098 0.000 0.932 0.000 0.000 NA 0.064
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 agent(p) individual(p) k
#> CV:NMF 55 0.9402 8.40e-05 2
#> CV:NMF 57 0.0774 1.31e-07 3
#> CV:NMF 57 0.0344 2.61e-11 4
#> CV:NMF 47 0.1239 1.48e-09 5
#> CV:NMF 43 0.1077 6.57e-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", "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 46323 rows and 60 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 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 1.000 1.000 0.1839 0.817 0.817
#> 3 3 0.771 0.931 0.964 2.1619 0.589 0.497
#> 4 4 0.895 0.954 0.975 0.1894 0.914 0.787
#> 5 5 0.917 0.924 0.950 0.1223 0.890 0.655
#> 6 6 1.000 0.998 0.999 0.0499 0.976 0.886
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 5
There is also optional best \(k\) = 2 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
#> GSM1324896 1 0 1 1 0
#> GSM1324897 1 0 1 1 0
#> GSM1324898 1 0 1 1 0
#> GSM1324902 1 0 1 1 0
#> GSM1324903 1 0 1 1 0
#> GSM1324904 1 0 1 1 0
#> GSM1324908 1 0 1 1 0
#> GSM1324909 1 0 1 1 0
#> GSM1324910 1 0 1 1 0
#> GSM1324914 1 0 1 1 0
#> GSM1324915 1 0 1 1 0
#> GSM1324916 1 0 1 1 0
#> GSM1324920 1 0 1 1 0
#> GSM1324921 1 0 1 1 0
#> GSM1324922 1 0 1 1 0
#> GSM1324926 2 0 1 0 1
#> GSM1324927 2 0 1 0 1
#> GSM1324928 2 0 1 0 1
#> GSM1324938 1 0 1 1 0
#> GSM1324939 1 0 1 1 0
#> GSM1324940 1 0 1 1 0
#> GSM1324944 1 0 1 1 0
#> GSM1324945 1 0 1 1 0
#> GSM1324946 1 0 1 1 0
#> GSM1324950 1 0 1 1 0
#> GSM1324951 1 0 1 1 0
#> GSM1324952 1 0 1 1 0
#> GSM1324932 2 0 1 0 1
#> GSM1324933 2 0 1 0 1
#> GSM1324934 2 0 1 0 1
#> GSM1324893 1 0 1 1 0
#> GSM1324894 1 0 1 1 0
#> GSM1324895 1 0 1 1 0
#> GSM1324899 1 0 1 1 0
#> GSM1324900 1 0 1 1 0
#> GSM1324901 1 0 1 1 0
#> GSM1324905 1 0 1 1 0
#> GSM1324906 1 0 1 1 0
#> GSM1324907 1 0 1 1 0
#> GSM1324911 1 0 1 1 0
#> GSM1324912 1 0 1 1 0
#> GSM1324913 1 0 1 1 0
#> GSM1324917 1 0 1 1 0
#> GSM1324918 1 0 1 1 0
#> GSM1324919 1 0 1 1 0
#> GSM1324923 1 0 1 1 0
#> GSM1324924 1 0 1 1 0
#> GSM1324925 1 0 1 1 0
#> GSM1324929 1 0 1 1 0
#> GSM1324930 1 0 1 1 0
#> GSM1324931 1 0 1 1 0
#> GSM1324935 1 0 1 1 0
#> GSM1324936 1 0 1 1 0
#> GSM1324937 1 0 1 1 0
#> GSM1324941 1 0 1 1 0
#> GSM1324942 1 0 1 1 0
#> GSM1324943 1 0 1 1 0
#> GSM1324947 1 0 1 1 0
#> GSM1324948 1 0 1 1 0
#> GSM1324949 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 0.880 1.00 0.00 0
#> GSM1324897 1 0.000 0.880 1.00 0.00 0
#> GSM1324898 1 0.000 0.880 1.00 0.00 0
#> GSM1324902 1 0.000 0.880 1.00 0.00 0
#> GSM1324903 1 0.000 0.880 1.00 0.00 0
#> GSM1324904 1 0.000 0.880 1.00 0.00 0
#> GSM1324908 2 0.000 1.000 0.00 1.00 0
#> GSM1324909 1 0.000 0.880 1.00 0.00 0
#> GSM1324910 1 0.000 0.880 1.00 0.00 0
#> GSM1324914 2 0.000 1.000 0.00 1.00 0
#> GSM1324915 1 0.000 0.880 1.00 0.00 0
#> GSM1324916 1 0.000 0.880 1.00 0.00 0
#> GSM1324920 2 0.000 1.000 0.00 1.00 0
#> GSM1324921 2 0.000 1.000 0.00 1.00 0
#> GSM1324922 2 0.000 1.000 0.00 1.00 0
#> GSM1324926 3 0.000 1.000 0.00 0.00 1
#> GSM1324927 3 0.000 1.000 0.00 0.00 1
#> GSM1324928 3 0.000 1.000 0.00 0.00 1
#> GSM1324938 2 0.000 1.000 0.00 1.00 0
#> GSM1324939 2 0.000 1.000 0.00 1.00 0
#> GSM1324940 2 0.000 1.000 0.00 1.00 0
#> GSM1324944 2 0.000 1.000 0.00 1.00 0
#> GSM1324945 2 0.000 1.000 0.00 1.00 0
#> GSM1324946 2 0.000 1.000 0.00 1.00 0
#> GSM1324950 1 0.502 0.767 0.76 0.24 0
#> GSM1324951 1 0.502 0.767 0.76 0.24 0
#> GSM1324952 1 0.502 0.767 0.76 0.24 0
#> GSM1324932 3 0.000 1.000 0.00 0.00 1
#> GSM1324933 3 0.000 1.000 0.00 0.00 1
#> GSM1324934 3 0.000 1.000 0.00 0.00 1
#> GSM1324893 1 0.000 0.880 1.00 0.00 0
#> GSM1324894 1 0.000 0.880 1.00 0.00 0
#> GSM1324895 1 0.000 0.880 1.00 0.00 0
#> GSM1324899 1 0.000 0.880 1.00 0.00 0
#> GSM1324900 1 0.000 0.880 1.00 0.00 0
#> GSM1324901 1 0.000 0.880 1.00 0.00 0
#> GSM1324905 2 0.000 1.000 0.00 1.00 0
#> GSM1324906 2 0.000 1.000 0.00 1.00 0
#> GSM1324907 1 0.000 0.880 1.00 0.00 0
#> GSM1324911 2 0.000 1.000 0.00 1.00 0
#> GSM1324912 2 0.000 1.000 0.00 1.00 0
#> GSM1324913 2 0.000 1.000 0.00 1.00 0
#> GSM1324917 2 0.000 1.000 0.00 1.00 0
#> GSM1324918 2 0.000 1.000 0.00 1.00 0
#> GSM1324919 2 0.000 1.000 0.00 1.00 0
#> GSM1324923 2 0.000 1.000 0.00 1.00 0
#> GSM1324924 2 0.000 1.000 0.00 1.00 0
#> GSM1324925 2 0.000 1.000 0.00 1.00 0
#> GSM1324929 2 0.000 1.000 0.00 1.00 0
#> GSM1324930 2 0.000 1.000 0.00 1.00 0
#> GSM1324931 2 0.000 1.000 0.00 1.00 0
#> GSM1324935 2 0.000 1.000 0.00 1.00 0
#> GSM1324936 2 0.000 1.000 0.00 1.00 0
#> GSM1324937 2 0.000 1.000 0.00 1.00 0
#> GSM1324941 1 0.502 0.767 0.76 0.24 0
#> GSM1324942 1 0.502 0.767 0.76 0.24 0
#> GSM1324943 1 0.502 0.767 0.76 0.24 0
#> GSM1324947 1 0.502 0.767 0.76 0.24 0
#> GSM1324948 1 0.502 0.767 0.76 0.24 0
#> GSM1324949 1 0.502 0.767 0.76 0.24 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324897 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324898 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324902 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324903 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324904 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324908 4 0.3726 0.772 0 0.212 0 0.788
#> GSM1324909 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324910 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324914 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324915 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324916 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324920 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324921 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324922 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324926 3 0.0000 1.000 0 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0 0.000 1 0.000
#> GSM1324938 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324939 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324940 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324944 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324945 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324946 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324950 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324951 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324952 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324932 3 0.0000 1.000 0 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0 0.000 1 0.000
#> GSM1324893 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324894 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324895 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324899 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324900 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324901 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324905 4 0.3907 0.751 0 0.232 0 0.768
#> GSM1324906 4 0.3907 0.751 0 0.232 0 0.768
#> GSM1324907 1 0.0000 1.000 1 0.000 0 0.000
#> GSM1324911 4 0.3907 0.751 0 0.232 0 0.768
#> GSM1324912 4 0.3907 0.751 0 0.232 0 0.768
#> GSM1324913 4 0.3907 0.751 0 0.232 0 0.768
#> GSM1324917 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324918 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324919 4 0.0000 0.940 0 0.000 0 1.000
#> GSM1324923 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324924 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324925 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324929 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324930 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324931 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324935 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324936 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324937 4 0.0336 0.942 0 0.008 0 0.992
#> GSM1324941 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324942 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324943 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324947 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324948 2 0.0000 1.000 0 1.000 0 0.000
#> GSM1324949 2 0.0000 1.000 0 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324908 4 0.0609 0.660 0 0.02 0 0.980 0.000
#> GSM1324909 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324914 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324915 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324920 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324921 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324922 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324926 3 0.0000 1.000 0 0.00 1 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0 0.00 1 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0 0.00 1 0.000 0.000
#> GSM1324938 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324939 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324940 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324944 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324945 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324946 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324950 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324951 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324952 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324932 3 0.0000 1.000 0 0.00 1 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0 0.00 1 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0 0.00 1 0.000 0.000
#> GSM1324893 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324905 4 0.0162 0.654 0 0.00 0 0.996 0.004
#> GSM1324906 4 0.0162 0.654 0 0.00 0 0.996 0.004
#> GSM1324907 1 0.0000 1.000 1 0.00 0 0.000 0.000
#> GSM1324911 4 0.0162 0.654 0 0.00 0 0.996 0.004
#> GSM1324912 4 0.0162 0.654 0 0.00 0 0.996 0.004
#> GSM1324913 4 0.0162 0.654 0 0.00 0 0.996 0.004
#> GSM1324917 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324918 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324919 4 0.4227 0.640 0 0.42 0 0.580 0.000
#> GSM1324923 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324924 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324925 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324929 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324930 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324931 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324935 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324936 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324937 2 0.0000 1.000 0 1.00 0 0.000 0.000
#> GSM1324941 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324942 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324943 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324947 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324948 5 0.0000 1.000 0 0.00 0 0.000 1.000
#> GSM1324949 5 0.0000 1.000 0 0.00 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324897 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324898 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324902 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324903 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324904 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324908 6 0.101 0.953 0 0 0 0.044 0 0.956
#> GSM1324909 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324910 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324914 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324915 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324916 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324920 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324921 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324922 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324926 3 0.000 1.000 0 0 1 0.000 0 0.000
#> GSM1324927 3 0.000 1.000 0 0 1 0.000 0 0.000
#> GSM1324928 3 0.000 1.000 0 0 1 0.000 0 0.000
#> GSM1324938 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324939 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324940 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324944 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324945 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324946 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324950 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324951 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324952 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324932 3 0.000 1.000 0 0 1 0.000 0 0.000
#> GSM1324933 3 0.000 1.000 0 0 1 0.000 0 0.000
#> GSM1324934 3 0.000 1.000 0 0 1 0.000 0 0.000
#> GSM1324893 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324894 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324895 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324899 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324900 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324901 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324905 6 0.000 0.991 0 0 0 0.000 0 1.000
#> GSM1324906 6 0.000 0.991 0 0 0 0.000 0 1.000
#> GSM1324907 1 0.000 1.000 1 0 0 0.000 0 0.000
#> GSM1324911 6 0.000 0.991 0 0 0 0.000 0 1.000
#> GSM1324912 6 0.000 0.991 0 0 0 0.000 0 1.000
#> GSM1324913 6 0.000 0.991 0 0 0 0.000 0 1.000
#> GSM1324917 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324918 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324919 4 0.000 1.000 0 0 0 1.000 0 0.000
#> GSM1324923 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324924 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324925 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324929 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324930 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324931 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324935 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324936 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324937 2 0.000 1.000 0 1 0 0.000 0 0.000
#> GSM1324941 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324942 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324943 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324947 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324948 5 0.000 1.000 0 0 0 0.000 1 0.000
#> GSM1324949 5 0.000 1.000 0 0 0 0.000 1 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 agent(p) individual(p) k
#> MAD:hclust 60 0.0314 3.87e-06 2
#> MAD:hclust 60 0.0262 4.35e-09 3
#> MAD:hclust 60 0.0319 5.63e-13 4
#> MAD:hclust 60 0.0657 1.80e-16 5
#> MAD:hclust 60 0.0526 3.00e-19 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.538 0.0459 0.582 0.4663 0.741 0.741
#> 3 3 0.607 0.7679 0.877 0.3475 0.531 0.396
#> 4 4 0.669 0.6024 0.774 0.1331 0.861 0.631
#> 5 5 0.666 0.5344 0.723 0.0773 0.904 0.694
#> 6 6 0.747 0.7110 0.733 0.0485 0.873 0.574
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
#> GSM1324896 1 0.993 0.4905 0.548 0.452
#> GSM1324897 1 0.993 0.4905 0.548 0.452
#> GSM1324898 1 0.993 0.4905 0.548 0.452
#> GSM1324902 1 0.994 0.4908 0.544 0.456
#> GSM1324903 1 0.994 0.4908 0.544 0.456
#> GSM1324904 1 0.994 0.4908 0.544 0.456
#> GSM1324908 1 0.876 -0.3772 0.704 0.296
#> GSM1324909 1 0.994 0.4908 0.544 0.456
#> GSM1324910 1 0.994 0.4908 0.544 0.456
#> GSM1324914 1 1.000 -0.8665 0.500 0.500
#> GSM1324915 1 0.994 0.4908 0.544 0.456
#> GSM1324916 1 0.994 0.4908 0.544 0.456
#> GSM1324920 1 1.000 -0.8665 0.500 0.500
#> GSM1324921 2 1.000 0.8468 0.500 0.500
#> GSM1324922 1 1.000 -0.8665 0.500 0.500
#> GSM1324926 2 0.978 0.9293 0.412 0.588
#> GSM1324927 2 0.978 0.9293 0.412 0.588
#> GSM1324928 2 0.978 0.9293 0.412 0.588
#> GSM1324938 1 0.994 -0.8067 0.544 0.456
#> GSM1324939 1 0.994 -0.8067 0.544 0.456
#> GSM1324940 1 0.994 -0.8067 0.544 0.456
#> GSM1324944 1 0.994 -0.8067 0.544 0.456
#> GSM1324945 1 0.994 -0.8067 0.544 0.456
#> GSM1324946 1 0.994 -0.8067 0.544 0.456
#> GSM1324950 1 0.891 0.4552 0.692 0.308
#> GSM1324951 1 0.891 0.4552 0.692 0.308
#> GSM1324952 1 0.961 0.4766 0.616 0.384
#> GSM1324932 2 0.978 0.9293 0.412 0.588
#> GSM1324933 2 0.978 0.9293 0.412 0.588
#> GSM1324934 2 0.978 0.9293 0.412 0.588
#> GSM1324893 1 0.994 0.4908 0.544 0.456
#> GSM1324894 1 0.994 0.4908 0.544 0.456
#> GSM1324895 1 0.994 0.4908 0.544 0.456
#> GSM1324899 1 0.994 0.4908 0.544 0.456
#> GSM1324900 1 0.994 0.4908 0.544 0.456
#> GSM1324901 1 0.994 0.4908 0.544 0.456
#> GSM1324905 1 0.343 0.0394 0.936 0.064
#> GSM1324906 1 0.343 0.0394 0.936 0.064
#> GSM1324907 1 0.993 0.4905 0.548 0.452
#> GSM1324911 1 0.994 -0.8067 0.544 0.456
#> GSM1324912 1 0.990 0.4880 0.560 0.440
#> GSM1324913 1 0.994 -0.8067 0.544 0.456
#> GSM1324917 2 1.000 0.8468 0.500 0.500
#> GSM1324918 1 0.995 -0.8120 0.540 0.460
#> GSM1324919 2 1.000 0.8468 0.500 0.500
#> GSM1324923 1 0.994 -0.8067 0.544 0.456
#> GSM1324924 1 0.994 -0.8067 0.544 0.456
#> GSM1324925 1 0.994 -0.8067 0.544 0.456
#> GSM1324929 1 0.995 -0.8120 0.540 0.460
#> GSM1324930 1 0.995 -0.8120 0.540 0.460
#> GSM1324931 1 0.995 -0.8120 0.540 0.460
#> GSM1324935 1 0.994 -0.8067 0.544 0.456
#> GSM1324936 1 0.994 -0.8067 0.544 0.456
#> GSM1324937 1 0.994 -0.8067 0.544 0.456
#> GSM1324941 1 0.000 0.1654 1.000 0.000
#> GSM1324942 1 0.000 0.1654 1.000 0.000
#> GSM1324943 1 0.000 0.1654 1.000 0.000
#> GSM1324947 1 0.891 0.4552 0.692 0.308
#> GSM1324948 1 0.891 0.4552 0.692 0.308
#> GSM1324949 1 0.891 0.4552 0.692 0.308
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0424 0.9967 0.992 0.008 0.000
#> GSM1324897 1 0.0424 0.9967 0.992 0.008 0.000
#> GSM1324898 1 0.0424 0.9967 0.992 0.008 0.000
#> GSM1324902 1 0.0592 0.9967 0.988 0.012 0.000
#> GSM1324903 1 0.0592 0.9967 0.988 0.012 0.000
#> GSM1324904 1 0.0592 0.9967 0.988 0.012 0.000
#> GSM1324908 2 0.4062 0.6721 0.000 0.836 0.164
#> GSM1324909 1 0.0424 0.9967 0.992 0.008 0.000
#> GSM1324910 1 0.0424 0.9967 0.992 0.008 0.000
#> GSM1324914 3 0.6168 0.6186 0.000 0.412 0.588
#> GSM1324915 1 0.0829 0.9948 0.984 0.012 0.004
#> GSM1324916 1 0.0829 0.9948 0.984 0.012 0.004
#> GSM1324920 3 0.6168 0.6186 0.000 0.412 0.588
#> GSM1324921 3 0.6168 0.6186 0.000 0.412 0.588
#> GSM1324922 3 0.6215 0.5826 0.000 0.428 0.572
#> GSM1324926 3 0.1411 0.7075 0.000 0.036 0.964
#> GSM1324927 3 0.1411 0.7075 0.000 0.036 0.964
#> GSM1324928 3 0.1411 0.7075 0.000 0.036 0.964
#> GSM1324938 2 0.1289 0.7951 0.000 0.968 0.032
#> GSM1324939 2 0.1289 0.7951 0.000 0.968 0.032
#> GSM1324940 2 0.1289 0.7951 0.000 0.968 0.032
#> GSM1324944 2 0.0000 0.8101 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.8101 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.8101 0.000 1.000 0.000
#> GSM1324950 2 0.4346 0.7138 0.184 0.816 0.000
#> GSM1324951 2 0.4346 0.7138 0.184 0.816 0.000
#> GSM1324952 2 0.4346 0.7138 0.184 0.816 0.000
#> GSM1324932 3 0.1832 0.7075 0.008 0.036 0.956
#> GSM1324933 3 0.1832 0.7075 0.008 0.036 0.956
#> GSM1324934 3 0.1832 0.7075 0.008 0.036 0.956
#> GSM1324893 1 0.0592 0.9967 0.988 0.012 0.000
#> GSM1324894 1 0.0592 0.9967 0.988 0.012 0.000
#> GSM1324895 1 0.0592 0.9967 0.988 0.012 0.000
#> GSM1324899 1 0.0661 0.9957 0.988 0.008 0.004
#> GSM1324900 1 0.0661 0.9957 0.988 0.008 0.004
#> GSM1324901 1 0.0661 0.9957 0.988 0.008 0.004
#> GSM1324905 2 0.1399 0.8025 0.004 0.968 0.028
#> GSM1324906 2 0.1399 0.8025 0.004 0.968 0.028
#> GSM1324907 1 0.0424 0.9967 0.992 0.008 0.000
#> GSM1324911 2 0.4062 0.6721 0.000 0.836 0.164
#> GSM1324912 2 0.6082 0.5910 0.296 0.692 0.012
#> GSM1324913 2 0.4062 0.6721 0.000 0.836 0.164
#> GSM1324917 3 0.5529 0.7406 0.000 0.296 0.704
#> GSM1324918 3 0.5529 0.7406 0.000 0.296 0.704
#> GSM1324919 3 0.5529 0.7406 0.000 0.296 0.704
#> GSM1324923 2 0.6045 -0.0212 0.000 0.620 0.380
#> GSM1324924 2 0.6045 -0.0212 0.000 0.620 0.380
#> GSM1324925 2 0.6095 -0.0736 0.000 0.608 0.392
#> GSM1324929 3 0.5905 0.7248 0.000 0.352 0.648
#> GSM1324930 3 0.5905 0.7248 0.000 0.352 0.648
#> GSM1324931 3 0.5905 0.7248 0.000 0.352 0.648
#> GSM1324935 2 0.0000 0.8101 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.8101 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.8101 0.000 1.000 0.000
#> GSM1324941 2 0.0747 0.8102 0.016 0.984 0.000
#> GSM1324942 2 0.0747 0.8102 0.016 0.984 0.000
#> GSM1324943 2 0.0747 0.8102 0.016 0.984 0.000
#> GSM1324947 2 0.4346 0.7138 0.184 0.816 0.000
#> GSM1324948 2 0.4346 0.7138 0.184 0.816 0.000
#> GSM1324949 2 0.4346 0.7138 0.184 0.816 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.2174 0.935 0.928 0.000 0.052 0.020
#> GSM1324897 1 0.2174 0.935 0.928 0.000 0.052 0.020
#> GSM1324898 1 0.2174 0.935 0.928 0.000 0.052 0.020
#> GSM1324902 1 0.1798 0.954 0.944 0.000 0.040 0.016
#> GSM1324903 1 0.1798 0.954 0.944 0.000 0.040 0.016
#> GSM1324904 1 0.1798 0.954 0.944 0.000 0.040 0.016
#> GSM1324908 4 0.5781 0.523 0.000 0.480 0.028 0.492
#> GSM1324909 1 0.0000 0.955 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.955 1.000 0.000 0.000 0.000
#> GSM1324914 4 0.6819 0.651 0.000 0.348 0.112 0.540
#> GSM1324915 1 0.2197 0.949 0.928 0.000 0.048 0.024
#> GSM1324916 1 0.2197 0.949 0.928 0.000 0.048 0.024
#> GSM1324920 4 0.6876 0.652 0.000 0.352 0.116 0.532
#> GSM1324921 4 0.6876 0.652 0.000 0.352 0.116 0.532
#> GSM1324922 4 0.6876 0.652 0.000 0.352 0.116 0.532
#> GSM1324926 3 0.3074 0.977 0.000 0.000 0.848 0.152
#> GSM1324927 3 0.3074 0.977 0.000 0.000 0.848 0.152
#> GSM1324928 3 0.3074 0.977 0.000 0.000 0.848 0.152
#> GSM1324938 2 0.2944 0.395 0.000 0.868 0.004 0.128
#> GSM1324939 2 0.2944 0.395 0.000 0.868 0.004 0.128
#> GSM1324940 2 0.2944 0.395 0.000 0.868 0.004 0.128
#> GSM1324944 2 0.0817 0.477 0.000 0.976 0.000 0.024
#> GSM1324945 2 0.0817 0.477 0.000 0.976 0.000 0.024
#> GSM1324946 2 0.0817 0.477 0.000 0.976 0.000 0.024
#> GSM1324950 2 0.5578 0.539 0.040 0.648 0.000 0.312
#> GSM1324951 2 0.5578 0.539 0.040 0.648 0.000 0.312
#> GSM1324952 2 0.5578 0.539 0.040 0.648 0.000 0.312
#> GSM1324932 3 0.2408 0.977 0.000 0.000 0.896 0.104
#> GSM1324933 3 0.2408 0.977 0.000 0.000 0.896 0.104
#> GSM1324934 3 0.2408 0.977 0.000 0.000 0.896 0.104
#> GSM1324893 1 0.1913 0.953 0.940 0.000 0.040 0.020
#> GSM1324894 1 0.1913 0.953 0.940 0.000 0.040 0.020
#> GSM1324895 1 0.1913 0.953 0.940 0.000 0.040 0.020
#> GSM1324899 1 0.1004 0.951 0.972 0.000 0.024 0.004
#> GSM1324900 1 0.1004 0.951 0.972 0.000 0.024 0.004
#> GSM1324901 1 0.1004 0.951 0.972 0.000 0.024 0.004
#> GSM1324905 4 0.4998 -0.302 0.000 0.488 0.000 0.512
#> GSM1324906 4 0.4998 -0.302 0.000 0.488 0.000 0.512
#> GSM1324907 1 0.2174 0.935 0.928 0.000 0.052 0.020
#> GSM1324911 4 0.5781 0.525 0.000 0.484 0.028 0.488
#> GSM1324912 4 0.8158 -0.252 0.208 0.328 0.020 0.444
#> GSM1324913 4 0.5781 0.529 0.000 0.484 0.028 0.488
#> GSM1324917 4 0.7300 0.636 0.000 0.276 0.196 0.528
#> GSM1324918 4 0.7300 0.636 0.000 0.276 0.196 0.528
#> GSM1324919 4 0.7300 0.636 0.000 0.276 0.196 0.528
#> GSM1324923 2 0.5917 -0.494 0.000 0.520 0.036 0.444
#> GSM1324924 2 0.5917 -0.494 0.000 0.520 0.036 0.444
#> GSM1324925 2 0.5917 -0.494 0.000 0.520 0.036 0.444
#> GSM1324929 4 0.7391 0.568 0.000 0.396 0.164 0.440
#> GSM1324930 4 0.7391 0.568 0.000 0.396 0.164 0.440
#> GSM1324931 4 0.7391 0.568 0.000 0.396 0.164 0.440
#> GSM1324935 2 0.2647 0.411 0.000 0.880 0.000 0.120
#> GSM1324936 2 0.2647 0.411 0.000 0.880 0.000 0.120
#> GSM1324937 2 0.2647 0.411 0.000 0.880 0.000 0.120
#> GSM1324941 2 0.4500 0.540 0.000 0.684 0.000 0.316
#> GSM1324942 2 0.4500 0.540 0.000 0.684 0.000 0.316
#> GSM1324943 2 0.4500 0.540 0.000 0.684 0.000 0.316
#> GSM1324947 2 0.5578 0.539 0.040 0.648 0.000 0.312
#> GSM1324948 2 0.5578 0.539 0.040 0.648 0.000 0.312
#> GSM1324949 2 0.5578 0.539 0.040 0.648 0.000 0.312
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.4392 0.748 0.612 0.000 0.008 0.000 0.380
#> GSM1324897 1 0.4392 0.748 0.612 0.000 0.008 0.000 0.380
#> GSM1324898 1 0.4392 0.748 0.612 0.000 0.008 0.000 0.380
#> GSM1324902 1 0.0290 0.847 0.992 0.000 0.008 0.000 0.000
#> GSM1324903 1 0.0290 0.847 0.992 0.000 0.008 0.000 0.000
#> GSM1324904 1 0.0290 0.847 0.992 0.000 0.008 0.000 0.000
#> GSM1324908 4 0.4606 0.434 0.000 0.112 0.012 0.768 0.108
#> GSM1324909 1 0.2583 0.847 0.864 0.000 0.004 0.000 0.132
#> GSM1324910 1 0.2583 0.847 0.864 0.000 0.004 0.000 0.132
#> GSM1324914 4 0.1836 0.662 0.000 0.016 0.040 0.936 0.008
#> GSM1324915 1 0.1547 0.836 0.948 0.000 0.016 0.004 0.032
#> GSM1324916 1 0.1547 0.836 0.948 0.000 0.016 0.004 0.032
#> GSM1324920 4 0.1854 0.665 0.000 0.020 0.036 0.936 0.008
#> GSM1324921 4 0.1854 0.665 0.000 0.020 0.036 0.936 0.008
#> GSM1324922 4 0.1854 0.665 0.000 0.020 0.036 0.936 0.008
#> GSM1324926 3 0.2719 0.974 0.000 0.000 0.884 0.068 0.048
#> GSM1324927 3 0.2645 0.974 0.000 0.000 0.888 0.068 0.044
#> GSM1324928 3 0.2645 0.974 0.000 0.000 0.888 0.068 0.044
#> GSM1324938 2 0.4637 0.267 0.000 0.672 0.000 0.292 0.036
#> GSM1324939 2 0.4637 0.267 0.000 0.672 0.000 0.292 0.036
#> GSM1324940 2 0.4637 0.267 0.000 0.672 0.000 0.292 0.036
#> GSM1324944 2 0.4747 0.365 0.000 0.732 0.004 0.184 0.080
#> GSM1324945 2 0.4747 0.365 0.000 0.732 0.004 0.184 0.080
#> GSM1324946 2 0.4747 0.365 0.000 0.732 0.004 0.184 0.080
#> GSM1324950 2 0.4118 0.211 0.004 0.660 0.000 0.000 0.336
#> GSM1324951 2 0.4118 0.211 0.004 0.660 0.000 0.000 0.336
#> GSM1324952 2 0.4118 0.211 0.004 0.660 0.000 0.000 0.336
#> GSM1324932 3 0.1768 0.974 0.000 0.004 0.924 0.072 0.000
#> GSM1324933 3 0.1768 0.974 0.000 0.000 0.924 0.072 0.004
#> GSM1324934 3 0.1768 0.974 0.000 0.004 0.924 0.072 0.000
#> GSM1324893 1 0.0451 0.849 0.988 0.000 0.008 0.004 0.000
#> GSM1324894 1 0.0451 0.849 0.988 0.000 0.008 0.004 0.000
#> GSM1324895 1 0.0451 0.849 0.988 0.000 0.008 0.004 0.000
#> GSM1324899 1 0.4221 0.818 0.732 0.000 0.032 0.000 0.236
#> GSM1324900 1 0.4221 0.818 0.732 0.000 0.032 0.000 0.236
#> GSM1324901 1 0.4221 0.818 0.732 0.000 0.032 0.000 0.236
#> GSM1324905 2 0.7045 -0.654 0.000 0.364 0.008 0.308 0.320
#> GSM1324906 2 0.7045 -0.654 0.000 0.364 0.008 0.308 0.320
#> GSM1324907 1 0.4392 0.748 0.612 0.000 0.008 0.000 0.380
#> GSM1324911 4 0.4905 0.425 0.000 0.116 0.008 0.736 0.140
#> GSM1324912 5 0.7464 0.000 0.028 0.296 0.012 0.212 0.452
#> GSM1324913 4 0.4858 0.432 0.000 0.112 0.008 0.740 0.140
#> GSM1324917 4 0.2243 0.657 0.000 0.016 0.056 0.916 0.012
#> GSM1324918 4 0.2243 0.657 0.000 0.016 0.056 0.916 0.012
#> GSM1324919 4 0.2243 0.657 0.000 0.016 0.056 0.916 0.012
#> GSM1324923 4 0.5396 0.479 0.000 0.376 0.000 0.560 0.064
#> GSM1324924 4 0.5396 0.479 0.000 0.376 0.000 0.560 0.064
#> GSM1324925 4 0.5396 0.479 0.000 0.376 0.000 0.560 0.064
#> GSM1324929 4 0.6432 0.540 0.000 0.320 0.056 0.556 0.068
#> GSM1324930 4 0.6432 0.540 0.000 0.320 0.056 0.556 0.068
#> GSM1324931 4 0.6432 0.540 0.000 0.320 0.056 0.556 0.068
#> GSM1324935 2 0.4360 0.301 0.000 0.692 0.000 0.284 0.024
#> GSM1324936 2 0.4360 0.301 0.000 0.692 0.000 0.284 0.024
#> GSM1324937 2 0.4360 0.301 0.000 0.692 0.000 0.284 0.024
#> GSM1324941 2 0.4147 0.195 0.000 0.676 0.000 0.008 0.316
#> GSM1324942 2 0.4147 0.195 0.000 0.676 0.000 0.008 0.316
#> GSM1324943 2 0.4147 0.195 0.000 0.676 0.000 0.008 0.316
#> GSM1324947 2 0.4118 0.211 0.004 0.660 0.000 0.000 0.336
#> GSM1324948 2 0.4118 0.211 0.004 0.660 0.000 0.000 0.336
#> GSM1324949 2 0.4118 0.211 0.004 0.660 0.000 0.000 0.336
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.4020 0.715 0.776 0.096 0.004 0.000 0.004 0.120
#> GSM1324897 1 0.4020 0.715 0.776 0.096 0.004 0.000 0.004 0.120
#> GSM1324898 1 0.4020 0.715 0.776 0.096 0.004 0.000 0.004 0.120
#> GSM1324902 1 0.3575 0.813 0.708 0.008 0.000 0.000 0.000 0.284
#> GSM1324903 1 0.3575 0.813 0.708 0.008 0.000 0.000 0.000 0.284
#> GSM1324904 1 0.3575 0.813 0.708 0.008 0.000 0.000 0.000 0.284
#> GSM1324908 4 0.4659 0.638 0.000 0.036 0.000 0.676 0.028 0.260
#> GSM1324909 1 0.2636 0.820 0.860 0.016 0.004 0.000 0.000 0.120
#> GSM1324910 1 0.2636 0.820 0.860 0.016 0.004 0.000 0.000 0.120
#> GSM1324914 4 0.1340 0.814 0.000 0.040 0.008 0.948 0.004 0.000
#> GSM1324915 1 0.4579 0.776 0.644 0.052 0.004 0.000 0.000 0.300
#> GSM1324916 1 0.4579 0.776 0.644 0.052 0.004 0.000 0.000 0.300
#> GSM1324920 4 0.1340 0.814 0.000 0.040 0.008 0.948 0.004 0.000
#> GSM1324921 4 0.1340 0.814 0.000 0.040 0.008 0.948 0.004 0.000
#> GSM1324922 4 0.1453 0.811 0.000 0.040 0.008 0.944 0.008 0.000
#> GSM1324926 3 0.1049 0.954 0.000 0.008 0.960 0.032 0.000 0.000
#> GSM1324927 3 0.0935 0.955 0.000 0.000 0.964 0.032 0.000 0.004
#> GSM1324928 3 0.0935 0.955 0.000 0.000 0.964 0.032 0.000 0.004
#> GSM1324938 2 0.5936 0.686 0.000 0.572 0.004 0.124 0.268 0.032
#> GSM1324939 2 0.5936 0.686 0.000 0.572 0.004 0.124 0.268 0.032
#> GSM1324940 2 0.5936 0.686 0.000 0.572 0.004 0.124 0.268 0.032
#> GSM1324944 2 0.6181 0.489 0.000 0.480 0.000 0.044 0.360 0.116
#> GSM1324945 2 0.6181 0.489 0.000 0.480 0.000 0.044 0.360 0.116
#> GSM1324946 2 0.6181 0.489 0.000 0.480 0.000 0.044 0.360 0.116
#> GSM1324950 5 0.0000 0.783 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324951 5 0.0000 0.783 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324952 5 0.0000 0.783 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324932 3 0.2831 0.956 0.000 0.044 0.876 0.028 0.000 0.052
#> GSM1324933 3 0.2831 0.956 0.000 0.044 0.876 0.028 0.000 0.052
#> GSM1324934 3 0.2831 0.956 0.000 0.044 0.876 0.028 0.000 0.052
#> GSM1324893 1 0.4001 0.813 0.708 0.028 0.004 0.000 0.000 0.260
#> GSM1324894 1 0.4001 0.813 0.708 0.028 0.004 0.000 0.000 0.260
#> GSM1324895 1 0.4001 0.813 0.708 0.028 0.004 0.000 0.000 0.260
#> GSM1324899 1 0.1332 0.792 0.952 0.028 0.012 0.000 0.000 0.008
#> GSM1324900 1 0.1332 0.792 0.952 0.028 0.012 0.000 0.000 0.008
#> GSM1324901 1 0.1332 0.792 0.952 0.028 0.012 0.000 0.000 0.008
#> GSM1324905 5 0.6705 0.201 0.000 0.036 0.000 0.288 0.396 0.280
#> GSM1324906 5 0.6705 0.201 0.000 0.036 0.000 0.288 0.396 0.280
#> GSM1324907 1 0.4020 0.715 0.776 0.096 0.004 0.000 0.004 0.120
#> GSM1324911 4 0.5249 0.615 0.000 0.060 0.000 0.632 0.040 0.268
#> GSM1324912 5 0.7499 0.195 0.028 0.060 0.000 0.252 0.368 0.292
#> GSM1324913 4 0.5186 0.619 0.000 0.060 0.000 0.636 0.036 0.268
#> GSM1324917 4 0.2383 0.794 0.000 0.052 0.028 0.900 0.000 0.020
#> GSM1324918 4 0.2383 0.794 0.000 0.052 0.028 0.900 0.000 0.020
#> GSM1324919 4 0.2383 0.794 0.000 0.052 0.028 0.900 0.000 0.020
#> GSM1324923 2 0.5616 0.533 0.000 0.572 0.008 0.328 0.040 0.052
#> GSM1324924 2 0.5616 0.533 0.000 0.572 0.008 0.328 0.040 0.052
#> GSM1324925 2 0.5616 0.533 0.000 0.572 0.008 0.328 0.040 0.052
#> GSM1324929 2 0.5876 0.463 0.000 0.528 0.024 0.364 0.024 0.060
#> GSM1324930 2 0.5876 0.463 0.000 0.528 0.024 0.364 0.024 0.060
#> GSM1324931 2 0.5876 0.463 0.000 0.528 0.024 0.364 0.024 0.060
#> GSM1324935 2 0.6076 0.669 0.000 0.540 0.000 0.116 0.296 0.048
#> GSM1324936 2 0.6076 0.669 0.000 0.540 0.000 0.116 0.296 0.048
#> GSM1324937 2 0.6076 0.669 0.000 0.540 0.000 0.116 0.296 0.048
#> GSM1324941 5 0.1549 0.767 0.000 0.020 0.000 0.000 0.936 0.044
#> GSM1324942 5 0.1549 0.767 0.000 0.020 0.000 0.000 0.936 0.044
#> GSM1324943 5 0.1549 0.767 0.000 0.020 0.000 0.000 0.936 0.044
#> GSM1324947 5 0.0260 0.782 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM1324948 5 0.0260 0.782 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM1324949 5 0.0260 0.782 0.000 0.000 0.000 0.000 0.992 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n agent(p) individual(p) k
#> MAD:kmeans 9 NA NA 2
#> MAD:kmeans 57 0.3599 3.43e-08 3
#> MAD:kmeans 45 0.0448 1.00e-09 4
#> MAD:kmeans 33 0.0578 9.44e-06 5
#> MAD:kmeans 51 0.0785 6.18e-14 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 46323 rows and 60 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 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.982 0.993 0.5086 0.492 0.492
#> 3 3 0.857 0.947 0.973 0.3278 0.720 0.490
#> 4 4 0.797 0.691 0.844 0.1172 0.871 0.630
#> 5 5 0.868 0.844 0.886 0.0554 0.937 0.752
#> 6 6 0.914 0.855 0.897 0.0328 0.962 0.817
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
#> GSM1324896 1 0.000 1.000 1.0 0.0
#> GSM1324897 1 0.000 1.000 1.0 0.0
#> GSM1324898 1 0.000 1.000 1.0 0.0
#> GSM1324902 1 0.000 1.000 1.0 0.0
#> GSM1324903 1 0.000 1.000 1.0 0.0
#> GSM1324904 1 0.000 1.000 1.0 0.0
#> GSM1324908 2 0.971 0.333 0.4 0.6
#> GSM1324909 1 0.000 1.000 1.0 0.0
#> GSM1324910 1 0.000 1.000 1.0 0.0
#> GSM1324914 2 0.000 0.987 0.0 1.0
#> GSM1324915 1 0.000 1.000 1.0 0.0
#> GSM1324916 1 0.000 1.000 1.0 0.0
#> GSM1324920 2 0.000 0.987 0.0 1.0
#> GSM1324921 2 0.000 0.987 0.0 1.0
#> GSM1324922 2 0.000 0.987 0.0 1.0
#> GSM1324926 2 0.000 0.987 0.0 1.0
#> GSM1324927 2 0.000 0.987 0.0 1.0
#> GSM1324928 2 0.000 0.987 0.0 1.0
#> GSM1324938 2 0.000 0.987 0.0 1.0
#> GSM1324939 2 0.000 0.987 0.0 1.0
#> GSM1324940 2 0.000 0.987 0.0 1.0
#> GSM1324944 2 0.000 0.987 0.0 1.0
#> GSM1324945 2 0.000 0.987 0.0 1.0
#> GSM1324946 2 0.000 0.987 0.0 1.0
#> GSM1324950 1 0.000 1.000 1.0 0.0
#> GSM1324951 1 0.000 1.000 1.0 0.0
#> GSM1324952 1 0.000 1.000 1.0 0.0
#> GSM1324932 2 0.000 0.987 0.0 1.0
#> GSM1324933 2 0.000 0.987 0.0 1.0
#> GSM1324934 2 0.000 0.987 0.0 1.0
#> GSM1324893 1 0.000 1.000 1.0 0.0
#> GSM1324894 1 0.000 1.000 1.0 0.0
#> GSM1324895 1 0.000 1.000 1.0 0.0
#> GSM1324899 1 0.000 1.000 1.0 0.0
#> GSM1324900 1 0.000 1.000 1.0 0.0
#> GSM1324901 1 0.000 1.000 1.0 0.0
#> GSM1324905 1 0.000 1.000 1.0 0.0
#> GSM1324906 1 0.000 1.000 1.0 0.0
#> GSM1324907 1 0.000 1.000 1.0 0.0
#> GSM1324911 2 0.000 0.987 0.0 1.0
#> GSM1324912 1 0.000 1.000 1.0 0.0
#> GSM1324913 2 0.000 0.987 0.0 1.0
#> GSM1324917 2 0.000 0.987 0.0 1.0
#> GSM1324918 2 0.000 0.987 0.0 1.0
#> GSM1324919 2 0.000 0.987 0.0 1.0
#> GSM1324923 2 0.000 0.987 0.0 1.0
#> GSM1324924 2 0.000 0.987 0.0 1.0
#> GSM1324925 2 0.000 0.987 0.0 1.0
#> GSM1324929 2 0.000 0.987 0.0 1.0
#> GSM1324930 2 0.000 0.987 0.0 1.0
#> GSM1324931 2 0.000 0.987 0.0 1.0
#> GSM1324935 2 0.000 0.987 0.0 1.0
#> GSM1324936 2 0.000 0.987 0.0 1.0
#> GSM1324937 2 0.000 0.987 0.0 1.0
#> GSM1324941 1 0.000 1.000 1.0 0.0
#> GSM1324942 1 0.000 1.000 1.0 0.0
#> GSM1324943 1 0.000 1.000 1.0 0.0
#> GSM1324947 1 0.000 1.000 1.0 0.0
#> GSM1324948 1 0.000 1.000 1.0 0.0
#> GSM1324949 1 0.000 1.000 1.0 0.0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324897 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324898 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324902 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324903 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324904 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324908 3 0.611 0.359 0.396 0.000 0.604
#> GSM1324909 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324910 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324914 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324915 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324916 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324920 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324921 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324922 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324926 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324927 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324928 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324938 2 0.362 0.881 0.000 0.864 0.136
#> GSM1324939 2 0.362 0.881 0.000 0.864 0.136
#> GSM1324940 2 0.362 0.881 0.000 0.864 0.136
#> GSM1324944 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324945 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324946 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324950 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324951 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324952 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324932 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324933 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324934 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324893 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324894 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324895 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324899 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324900 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324901 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324905 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324906 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324907 1 0.000 0.993 1.000 0.000 0.000
#> GSM1324911 3 0.388 0.821 0.000 0.152 0.848
#> GSM1324912 1 0.319 0.878 0.888 0.112 0.000
#> GSM1324913 3 0.388 0.821 0.000 0.152 0.848
#> GSM1324917 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324918 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324919 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324923 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324924 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324925 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324929 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324930 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324931 3 0.000 0.965 0.000 0.000 1.000
#> GSM1324935 2 0.341 0.891 0.000 0.876 0.124
#> GSM1324936 2 0.341 0.891 0.000 0.876 0.124
#> GSM1324937 2 0.341 0.891 0.000 0.876 0.124
#> GSM1324941 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324942 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324943 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324947 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324948 2 0.000 0.956 0.000 1.000 0.000
#> GSM1324949 2 0.000 0.956 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324897 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324898 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324902 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324903 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324904 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324908 4 0.780 0.410 0.248 0.372 0.000 0.380
#> GSM1324909 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324914 4 0.466 0.650 0.000 0.348 0.000 0.652
#> GSM1324915 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324916 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324920 4 0.466 0.650 0.000 0.348 0.000 0.652
#> GSM1324921 4 0.466 0.650 0.000 0.348 0.000 0.652
#> GSM1324922 4 0.466 0.650 0.000 0.348 0.000 0.652
#> GSM1324926 4 0.000 0.622 0.000 0.000 0.000 1.000
#> GSM1324927 4 0.000 0.622 0.000 0.000 0.000 1.000
#> GSM1324928 4 0.000 0.622 0.000 0.000 0.000 1.000
#> GSM1324938 2 0.604 0.616 0.000 0.628 0.068 0.304
#> GSM1324939 2 0.604 0.616 0.000 0.628 0.068 0.304
#> GSM1324940 2 0.604 0.616 0.000 0.628 0.068 0.304
#> GSM1324944 2 0.482 0.554 0.000 0.612 0.388 0.000
#> GSM1324945 2 0.482 0.554 0.000 0.612 0.388 0.000
#> GSM1324946 2 0.480 0.559 0.000 0.616 0.384 0.000
#> GSM1324950 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324951 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324952 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324932 4 0.000 0.622 0.000 0.000 0.000 1.000
#> GSM1324933 4 0.000 0.622 0.000 0.000 0.000 1.000
#> GSM1324934 4 0.000 0.622 0.000 0.000 0.000 1.000
#> GSM1324893 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324894 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324895 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324899 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324905 3 0.464 0.560 0.000 0.344 0.656 0.000
#> GSM1324906 3 0.464 0.560 0.000 0.344 0.656 0.000
#> GSM1324907 1 0.000 0.990 1.000 0.000 0.000 0.000
#> GSM1324911 2 0.513 -0.284 0.000 0.668 0.020 0.312
#> GSM1324912 1 0.400 0.798 0.824 0.036 0.140 0.000
#> GSM1324913 2 0.513 -0.284 0.000 0.668 0.020 0.312
#> GSM1324917 4 0.460 0.654 0.000 0.336 0.000 0.664
#> GSM1324918 4 0.460 0.654 0.000 0.336 0.000 0.664
#> GSM1324919 4 0.460 0.654 0.000 0.336 0.000 0.664
#> GSM1324923 2 0.475 0.555 0.000 0.632 0.000 0.368
#> GSM1324924 2 0.475 0.555 0.000 0.632 0.000 0.368
#> GSM1324925 2 0.475 0.555 0.000 0.632 0.000 0.368
#> GSM1324929 4 0.487 -0.161 0.000 0.404 0.000 0.596
#> GSM1324930 4 0.487 -0.161 0.000 0.404 0.000 0.596
#> GSM1324931 4 0.487 -0.161 0.000 0.404 0.000 0.596
#> GSM1324935 2 0.514 0.585 0.000 0.628 0.360 0.012
#> GSM1324936 2 0.514 0.585 0.000 0.628 0.360 0.012
#> GSM1324937 2 0.514 0.585 0.000 0.628 0.360 0.012
#> GSM1324941 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324942 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324943 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324947 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324948 3 0.000 0.905 0.000 0.000 1.000 0.000
#> GSM1324949 3 0.000 0.905 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0290 0.969 0.992 0.000 0.008 0.000 0.000
#> GSM1324897 1 0.0290 0.969 0.992 0.000 0.008 0.000 0.000
#> GSM1324898 1 0.0290 0.969 0.992 0.000 0.008 0.000 0.000
#> GSM1324902 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324908 4 0.4531 0.667 0.028 0.004 0.248 0.716 0.004
#> GSM1324909 1 0.0162 0.970 0.996 0.000 0.004 0.000 0.000
#> GSM1324910 1 0.0162 0.970 0.996 0.000 0.004 0.000 0.000
#> GSM1324914 4 0.0000 0.781 0.000 0.000 0.000 1.000 0.000
#> GSM1324915 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324920 4 0.0000 0.781 0.000 0.000 0.000 1.000 0.000
#> GSM1324921 4 0.0000 0.781 0.000 0.000 0.000 1.000 0.000
#> GSM1324922 4 0.0000 0.781 0.000 0.000 0.000 1.000 0.000
#> GSM1324926 3 0.4040 0.868 0.000 0.016 0.724 0.260 0.000
#> GSM1324927 3 0.4040 0.868 0.000 0.016 0.724 0.260 0.000
#> GSM1324928 3 0.4040 0.868 0.000 0.016 0.724 0.260 0.000
#> GSM1324938 2 0.0162 0.928 0.000 0.996 0.004 0.000 0.000
#> GSM1324939 2 0.0162 0.928 0.000 0.996 0.004 0.000 0.000
#> GSM1324940 2 0.0162 0.928 0.000 0.996 0.004 0.000 0.000
#> GSM1324944 2 0.2797 0.895 0.000 0.880 0.060 0.000 0.060
#> GSM1324945 2 0.2797 0.895 0.000 0.880 0.060 0.000 0.060
#> GSM1324946 2 0.2659 0.899 0.000 0.888 0.060 0.000 0.052
#> GSM1324950 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324951 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324952 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324932 3 0.4040 0.868 0.000 0.016 0.724 0.260 0.000
#> GSM1324933 3 0.4040 0.868 0.000 0.016 0.724 0.260 0.000
#> GSM1324934 3 0.4040 0.868 0.000 0.016 0.724 0.260 0.000
#> GSM1324893 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.971 1.000 0.000 0.000 0.000 0.000
#> GSM1324899 1 0.0162 0.970 0.996 0.000 0.004 0.000 0.000
#> GSM1324900 1 0.0162 0.970 0.996 0.000 0.004 0.000 0.000
#> GSM1324901 1 0.0162 0.970 0.996 0.000 0.004 0.000 0.000
#> GSM1324905 5 0.6724 0.247 0.000 0.004 0.252 0.280 0.464
#> GSM1324906 5 0.6724 0.247 0.000 0.004 0.252 0.280 0.464
#> GSM1324907 1 0.0290 0.969 0.992 0.000 0.008 0.000 0.000
#> GSM1324911 4 0.4039 0.673 0.000 0.008 0.268 0.720 0.004
#> GSM1324912 1 0.7400 0.301 0.516 0.004 0.260 0.140 0.080
#> GSM1324913 4 0.4039 0.673 0.000 0.008 0.268 0.720 0.004
#> GSM1324917 4 0.2852 0.622 0.000 0.000 0.172 0.828 0.000
#> GSM1324918 4 0.2852 0.622 0.000 0.000 0.172 0.828 0.000
#> GSM1324919 4 0.2852 0.622 0.000 0.000 0.172 0.828 0.000
#> GSM1324923 2 0.2914 0.866 0.000 0.872 0.076 0.052 0.000
#> GSM1324924 2 0.2914 0.866 0.000 0.872 0.076 0.052 0.000
#> GSM1324925 2 0.2914 0.866 0.000 0.872 0.076 0.052 0.000
#> GSM1324929 3 0.5707 0.745 0.000 0.216 0.624 0.160 0.000
#> GSM1324930 3 0.5707 0.745 0.000 0.216 0.624 0.160 0.000
#> GSM1324931 3 0.5707 0.745 0.000 0.216 0.624 0.160 0.000
#> GSM1324935 2 0.0609 0.928 0.000 0.980 0.000 0.000 0.020
#> GSM1324936 2 0.0609 0.928 0.000 0.980 0.000 0.000 0.020
#> GSM1324937 2 0.0609 0.928 0.000 0.980 0.000 0.000 0.020
#> GSM1324941 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324942 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324943 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324947 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324948 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
#> GSM1324949 5 0.0162 0.895 0.000 0.004 0.000 0.000 0.996
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0260 0.988 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM1324897 1 0.0260 0.988 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM1324898 1 0.0260 0.988 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM1324902 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324903 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324904 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324908 6 0.4076 0.527 0.012 0.000 0.000 0.396 0.000 0.592
#> GSM1324909 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1324915 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324916 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324920 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1324921 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1324922 4 0.0000 0.953 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1324926 3 0.1501 0.804 0.000 0.000 0.924 0.076 0.000 0.000
#> GSM1324927 3 0.1501 0.804 0.000 0.000 0.924 0.076 0.000 0.000
#> GSM1324928 3 0.1501 0.804 0.000 0.000 0.924 0.076 0.000 0.000
#> GSM1324938 2 0.0363 0.805 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM1324939 2 0.0363 0.805 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM1324940 2 0.0363 0.805 0.000 0.988 0.000 0.000 0.000 0.012
#> GSM1324944 2 0.4195 0.749 0.000 0.748 0.032 0.000 0.032 0.188
#> GSM1324945 2 0.4195 0.749 0.000 0.748 0.032 0.000 0.032 0.188
#> GSM1324946 2 0.4195 0.749 0.000 0.748 0.032 0.000 0.032 0.188
#> GSM1324950 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324951 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324952 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324932 3 0.1501 0.804 0.000 0.000 0.924 0.076 0.000 0.000
#> GSM1324933 3 0.1501 0.804 0.000 0.000 0.924 0.076 0.000 0.000
#> GSM1324934 3 0.1501 0.804 0.000 0.000 0.924 0.076 0.000 0.000
#> GSM1324893 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324894 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324895 1 0.0458 0.989 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1324899 1 0.0146 0.989 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324900 1 0.0146 0.989 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324901 1 0.0146 0.989 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1324905 6 0.4550 0.687 0.000 0.000 0.000 0.084 0.240 0.676
#> GSM1324906 6 0.4550 0.687 0.000 0.000 0.000 0.084 0.240 0.676
#> GSM1324907 1 0.0260 0.988 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM1324911 6 0.3023 0.703 0.000 0.000 0.000 0.232 0.000 0.768
#> GSM1324912 6 0.4574 0.569 0.260 0.000 0.000 0.020 0.040 0.680
#> GSM1324913 6 0.3023 0.703 0.000 0.000 0.000 0.232 0.000 0.768
#> GSM1324917 4 0.1471 0.938 0.000 0.000 0.064 0.932 0.000 0.004
#> GSM1324918 4 0.1471 0.938 0.000 0.000 0.064 0.932 0.000 0.004
#> GSM1324919 4 0.1471 0.938 0.000 0.000 0.064 0.932 0.000 0.004
#> GSM1324923 2 0.6236 0.539 0.000 0.508 0.160 0.036 0.000 0.296
#> GSM1324924 2 0.6236 0.539 0.000 0.508 0.160 0.036 0.000 0.296
#> GSM1324925 2 0.6236 0.539 0.000 0.508 0.160 0.036 0.000 0.296
#> GSM1324929 3 0.5956 0.519 0.000 0.136 0.580 0.044 0.000 0.240
#> GSM1324930 3 0.5956 0.519 0.000 0.136 0.580 0.044 0.000 0.240
#> GSM1324931 3 0.5956 0.519 0.000 0.136 0.580 0.044 0.000 0.240
#> GSM1324935 2 0.0000 0.805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1324936 2 0.0000 0.805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1324937 2 0.0000 0.805 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1324941 5 0.0508 0.987 0.000 0.000 0.004 0.000 0.984 0.012
#> GSM1324942 5 0.0508 0.987 0.000 0.000 0.004 0.000 0.984 0.012
#> GSM1324943 5 0.0508 0.987 0.000 0.000 0.004 0.000 0.984 0.012
#> GSM1324947 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324948 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1324949 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.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 agent(p) individual(p) k
#> MAD:skmeans 59 0.694 3.71e-05 2
#> MAD:skmeans 59 0.797 2.67e-08 3
#> MAD:skmeans 54 0.112 2.97e-11 4
#> MAD:skmeans 57 0.667 2.42e-15 5
#> MAD:skmeans 60 0.376 3.00e-19 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 46323 rows and 60 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 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.973 0.987 0.4892 0.506 0.506
#> 3 3 1.000 0.996 0.998 0.3720 0.749 0.538
#> 4 4 0.970 0.949 0.970 0.0855 0.939 0.815
#> 5 5 0.925 0.834 0.941 0.0766 0.900 0.654
#> 6 6 0.967 0.923 0.966 0.0390 0.951 0.776
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 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
#> GSM1324896 1 0.000 0.968 1.000 0.000
#> GSM1324897 1 0.000 0.968 1.000 0.000
#> GSM1324898 1 0.000 0.968 1.000 0.000
#> GSM1324902 1 0.000 0.968 1.000 0.000
#> GSM1324903 1 0.000 0.968 1.000 0.000
#> GSM1324904 1 0.000 0.968 1.000 0.000
#> GSM1324908 1 0.000 0.968 1.000 0.000
#> GSM1324909 1 0.000 0.968 1.000 0.000
#> GSM1324910 1 0.000 0.968 1.000 0.000
#> GSM1324914 2 0.000 1.000 0.000 1.000
#> GSM1324915 1 0.000 0.968 1.000 0.000
#> GSM1324916 1 0.000 0.968 1.000 0.000
#> GSM1324920 2 0.000 1.000 0.000 1.000
#> GSM1324921 2 0.000 1.000 0.000 1.000
#> GSM1324922 2 0.000 1.000 0.000 1.000
#> GSM1324926 2 0.000 1.000 0.000 1.000
#> GSM1324927 2 0.000 1.000 0.000 1.000
#> GSM1324928 2 0.000 1.000 0.000 1.000
#> GSM1324938 2 0.000 1.000 0.000 1.000
#> GSM1324939 2 0.000 1.000 0.000 1.000
#> GSM1324940 2 0.000 1.000 0.000 1.000
#> GSM1324944 2 0.000 1.000 0.000 1.000
#> GSM1324945 2 0.000 1.000 0.000 1.000
#> GSM1324946 2 0.000 1.000 0.000 1.000
#> GSM1324950 1 0.714 0.771 0.804 0.196
#> GSM1324951 1 0.000 0.968 1.000 0.000
#> GSM1324952 1 0.000 0.968 1.000 0.000
#> GSM1324932 2 0.000 1.000 0.000 1.000
#> GSM1324933 2 0.000 1.000 0.000 1.000
#> GSM1324934 2 0.000 1.000 0.000 1.000
#> GSM1324893 1 0.000 0.968 1.000 0.000
#> GSM1324894 1 0.000 0.968 1.000 0.000
#> GSM1324895 1 0.000 0.968 1.000 0.000
#> GSM1324899 1 0.000 0.968 1.000 0.000
#> GSM1324900 1 0.000 0.968 1.000 0.000
#> GSM1324901 1 0.000 0.968 1.000 0.000
#> GSM1324905 2 0.000 1.000 0.000 1.000
#> GSM1324906 2 0.000 1.000 0.000 1.000
#> GSM1324907 1 0.000 0.968 1.000 0.000
#> GSM1324911 2 0.000 1.000 0.000 1.000
#> GSM1324912 1 0.000 0.968 1.000 0.000
#> GSM1324913 2 0.000 1.000 0.000 1.000
#> GSM1324917 2 0.000 1.000 0.000 1.000
#> GSM1324918 2 0.000 1.000 0.000 1.000
#> GSM1324919 2 0.000 1.000 0.000 1.000
#> GSM1324923 2 0.000 1.000 0.000 1.000
#> GSM1324924 2 0.000 1.000 0.000 1.000
#> GSM1324925 2 0.000 1.000 0.000 1.000
#> GSM1324929 2 0.000 1.000 0.000 1.000
#> GSM1324930 2 0.000 1.000 0.000 1.000
#> GSM1324931 2 0.000 1.000 0.000 1.000
#> GSM1324935 2 0.000 1.000 0.000 1.000
#> GSM1324936 2 0.000 1.000 0.000 1.000
#> GSM1324937 2 0.000 1.000 0.000 1.000
#> GSM1324941 2 0.000 1.000 0.000 1.000
#> GSM1324942 2 0.000 1.000 0.000 1.000
#> GSM1324943 2 0.000 1.000 0.000 1.000
#> GSM1324947 1 0.242 0.936 0.960 0.040
#> GSM1324948 1 0.855 0.644 0.720 0.280
#> GSM1324949 1 0.821 0.685 0.744 0.256
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324897 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324898 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324902 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324903 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324904 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324908 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324909 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324910 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324914 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324915 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324916 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324920 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324921 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324922 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324926 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324927 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324928 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324938 3 0.0424 0.990 0.000 0.008 0.992
#> GSM1324939 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324940 3 0.0592 0.987 0.000 0.012 0.988
#> GSM1324944 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324950 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324951 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324952 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324932 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324933 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324934 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324893 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324894 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324895 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324899 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324900 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324901 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324905 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324906 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324907 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1324911 3 0.2165 0.933 0.000 0.064 0.936
#> GSM1324912 1 0.0747 0.984 0.984 0.016 0.000
#> GSM1324913 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324917 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324918 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324919 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324923 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324924 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324925 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324929 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324930 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324931 3 0.0000 0.996 0.000 0.000 1.000
#> GSM1324935 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324936 2 0.0424 0.991 0.000 0.992 0.008
#> GSM1324937 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324941 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324947 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324948 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324949 2 0.0000 0.999 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324908 1 0.2216 0.893 0.908 0.000 0 0.092
#> GSM1324909 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324914 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324915 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324916 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324920 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324921 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324922 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324939 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324940 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324944 2 0.1118 0.927 0.000 0.964 0 0.036
#> GSM1324945 2 0.1302 0.923 0.000 0.956 0 0.044
#> GSM1324946 2 0.1302 0.923 0.000 0.956 0 0.044
#> GSM1324950 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324951 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324952 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324905 2 0.2216 0.861 0.000 0.908 0 0.092
#> GSM1324906 2 0.2216 0.861 0.000 0.908 0 0.092
#> GSM1324907 1 0.0000 0.993 1.000 0.000 0 0.000
#> GSM1324911 4 0.1940 0.879 0.000 0.076 0 0.924
#> GSM1324912 1 0.0921 0.965 0.972 0.028 0 0.000
#> GSM1324913 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324917 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324918 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324919 4 0.0000 0.933 0.000 0.000 0 1.000
#> GSM1324923 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324924 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324925 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324929 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324930 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324931 4 0.2216 0.937 0.000 0.092 0 0.908
#> GSM1324935 2 0.3219 0.823 0.000 0.836 0 0.164
#> GSM1324936 2 0.3219 0.823 0.000 0.836 0 0.164
#> GSM1324937 2 0.3219 0.823 0.000 0.836 0 0.164
#> GSM1324941 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324942 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324943 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324947 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324948 2 0.0000 0.938 0.000 1.000 0 0.000
#> GSM1324949 2 0.0000 0.938 0.000 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324908 4 0.3932 0.52432 0.328 0.000 0 0.672 0.000
#> GSM1324909 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.0000 0.90598 0.000 0.000 0 1.000 0.000
#> GSM1324915 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324916 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324920 4 0.0000 0.90598 0.000 0.000 0 1.000 0.000
#> GSM1324921 4 0.0000 0.90598 0.000 0.000 0 1.000 0.000
#> GSM1324922 4 0.0000 0.90598 0.000 0.000 0 1.000 0.000
#> GSM1324926 3 0.0000 1.00000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.0000 1.00000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.0000 1.00000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.0000 0.81711 0.000 1.000 0 0.000 0.000
#> GSM1324939 2 0.0000 0.81711 0.000 1.000 0 0.000 0.000
#> GSM1324940 2 0.0000 0.81711 0.000 1.000 0 0.000 0.000
#> GSM1324944 5 0.4192 0.26187 0.000 0.404 0 0.000 0.596
#> GSM1324945 5 0.4201 0.25090 0.000 0.408 0 0.000 0.592
#> GSM1324946 5 0.4210 0.23898 0.000 0.412 0 0.000 0.588
#> GSM1324950 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324951 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324952 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324932 3 0.0000 1.00000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.0000 1.00000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.0000 1.00000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324905 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324906 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324907 1 0.0000 0.99785 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.0566 0.89777 0.000 0.004 0 0.984 0.012
#> GSM1324912 1 0.0880 0.96269 0.968 0.000 0 0.000 0.032
#> GSM1324913 4 0.3452 0.68642 0.000 0.244 0 0.756 0.000
#> GSM1324917 4 0.0000 0.90598 0.000 0.000 0 1.000 0.000
#> GSM1324918 4 0.2179 0.83412 0.000 0.112 0 0.888 0.000
#> GSM1324919 4 0.0000 0.90598 0.000 0.000 0 1.000 0.000
#> GSM1324923 2 0.0000 0.81711 0.000 1.000 0 0.000 0.000
#> GSM1324924 2 0.0000 0.81711 0.000 1.000 0 0.000 0.000
#> GSM1324925 2 0.0000 0.81711 0.000 1.000 0 0.000 0.000
#> GSM1324929 2 0.1043 0.79932 0.000 0.960 0 0.040 0.000
#> GSM1324930 2 0.1043 0.79932 0.000 0.960 0 0.040 0.000
#> GSM1324931 2 0.1043 0.79932 0.000 0.960 0 0.040 0.000
#> GSM1324935 2 0.4305 0.00959 0.000 0.512 0 0.000 0.488
#> GSM1324936 2 0.4305 0.00959 0.000 0.512 0 0.000 0.488
#> GSM1324937 2 0.4306 -0.00583 0.000 0.508 0 0.000 0.492
#> GSM1324941 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324942 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324943 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324947 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324948 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
#> GSM1324949 5 0.0000 0.88026 0.000 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324908 4 0.3390 0.578 0.296 0.000 0 0.704 0.000 0.000
#> GSM1324909 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.0000 0.911 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324916 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324920 4 0.0000 0.911 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324921 4 0.0000 0.911 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324922 4 0.0000 0.911 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.0000 0.793 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324939 2 0.0000 0.793 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324940 2 0.0000 0.793 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324944 2 0.3833 0.401 0.000 0.556 0 0.000 0.444 0.000
#> GSM1324945 2 0.3833 0.401 0.000 0.556 0 0.000 0.444 0.000
#> GSM1324946 2 0.3833 0.401 0.000 0.556 0 0.000 0.444 0.000
#> GSM1324950 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324905 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324906 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324907 1 0.0000 0.998 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324911 4 0.0458 0.901 0.000 0.000 0 0.984 0.016 0.000
#> GSM1324912 1 0.0632 0.972 0.976 0.000 0 0.000 0.024 0.000
#> GSM1324913 4 0.3023 0.741 0.000 0.000 0 0.784 0.004 0.212
#> GSM1324917 4 0.0000 0.911 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324918 4 0.2491 0.796 0.000 0.000 0 0.836 0.000 0.164
#> GSM1324919 4 0.0000 0.911 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324923 6 0.0000 1.000 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324924 6 0.0000 1.000 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324925 6 0.0000 1.000 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324929 6 0.0000 1.000 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324930 6 0.0000 1.000 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324931 6 0.0000 1.000 0.000 0.000 0 0.000 0.000 1.000
#> GSM1324935 2 0.0000 0.793 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324936 2 0.0000 0.793 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324937 2 0.0000 0.793 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324941 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324942 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324943 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324947 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 1.000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> MAD:pam 60 0.6005 7.16e-05 2
#> MAD:pam 60 0.3480 1.25e-08 3
#> MAD:pam 60 0.0316 1.02e-12 4
#> MAD:pam 54 0.0499 4.85e-14 5
#> MAD:pam 57 0.0134 1.15e-18 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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.655 0.959 0.969 0.4953 0.492 0.492
#> 3 3 0.698 0.888 0.911 0.2655 0.750 0.533
#> 4 4 1.000 0.985 0.992 0.1429 0.956 0.866
#> 5 5 0.919 0.950 0.948 0.0840 0.939 0.786
#> 6 6 0.878 0.933 0.891 0.0514 0.959 0.819
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 4
There is also optional best \(k\) = 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.000 0.932 1.000 0.000
#> GSM1324897 1 0.000 0.932 1.000 0.000
#> GSM1324898 1 0.000 0.932 1.000 0.000
#> GSM1324902 1 0.000 0.932 1.000 0.000
#> GSM1324903 1 0.000 0.932 1.000 0.000
#> GSM1324904 1 0.000 0.932 1.000 0.000
#> GSM1324908 1 0.595 0.901 0.856 0.144
#> GSM1324909 1 0.000 0.932 1.000 0.000
#> GSM1324910 1 0.000 0.932 1.000 0.000
#> GSM1324914 1 0.595 0.901 0.856 0.144
#> GSM1324915 1 0.000 0.932 1.000 0.000
#> GSM1324916 1 0.000 0.932 1.000 0.000
#> GSM1324920 1 0.595 0.901 0.856 0.144
#> GSM1324921 1 0.595 0.901 0.856 0.144
#> GSM1324922 1 0.595 0.901 0.856 0.144
#> GSM1324926 2 0.000 1.000 0.000 1.000
#> GSM1324927 2 0.000 1.000 0.000 1.000
#> GSM1324928 2 0.000 1.000 0.000 1.000
#> GSM1324938 2 0.000 1.000 0.000 1.000
#> GSM1324939 2 0.000 1.000 0.000 1.000
#> GSM1324940 2 0.000 1.000 0.000 1.000
#> GSM1324944 2 0.000 1.000 0.000 1.000
#> GSM1324945 2 0.000 1.000 0.000 1.000
#> GSM1324946 2 0.000 1.000 0.000 1.000
#> GSM1324950 2 0.000 1.000 0.000 1.000
#> GSM1324951 2 0.000 1.000 0.000 1.000
#> GSM1324952 2 0.000 1.000 0.000 1.000
#> GSM1324932 2 0.000 1.000 0.000 1.000
#> GSM1324933 2 0.000 1.000 0.000 1.000
#> GSM1324934 2 0.000 1.000 0.000 1.000
#> GSM1324893 1 0.000 0.932 1.000 0.000
#> GSM1324894 1 0.000 0.932 1.000 0.000
#> GSM1324895 1 0.000 0.932 1.000 0.000
#> GSM1324899 1 0.000 0.932 1.000 0.000
#> GSM1324900 1 0.000 0.932 1.000 0.000
#> GSM1324901 1 0.000 0.932 1.000 0.000
#> GSM1324905 1 0.595 0.901 0.856 0.144
#> GSM1324906 1 0.595 0.901 0.856 0.144
#> GSM1324907 1 0.000 0.932 1.000 0.000
#> GSM1324911 1 0.595 0.901 0.856 0.144
#> GSM1324912 1 0.595 0.901 0.856 0.144
#> GSM1324913 1 0.595 0.901 0.856 0.144
#> GSM1324917 1 0.595 0.901 0.856 0.144
#> GSM1324918 1 0.595 0.901 0.856 0.144
#> GSM1324919 1 0.595 0.901 0.856 0.144
#> GSM1324923 2 0.000 1.000 0.000 1.000
#> GSM1324924 2 0.000 1.000 0.000 1.000
#> GSM1324925 2 0.000 1.000 0.000 1.000
#> GSM1324929 2 0.000 1.000 0.000 1.000
#> GSM1324930 2 0.000 1.000 0.000 1.000
#> GSM1324931 2 0.000 1.000 0.000 1.000
#> GSM1324935 2 0.000 1.000 0.000 1.000
#> GSM1324936 2 0.000 1.000 0.000 1.000
#> GSM1324937 2 0.000 1.000 0.000 1.000
#> GSM1324941 2 0.000 1.000 0.000 1.000
#> GSM1324942 2 0.000 1.000 0.000 1.000
#> GSM1324943 2 0.000 1.000 0.000 1.000
#> GSM1324947 2 0.000 1.000 0.000 1.000
#> GSM1324948 2 0.000 1.000 0.000 1.000
#> GSM1324949 2 0.000 1.000 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324908 3 0.5982 0.816 0.004 0.328 0.668
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324914 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324920 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324921 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324922 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324926 3 0.0424 0.696 0.000 0.008 0.992
#> GSM1324927 3 0.0424 0.696 0.000 0.008 0.992
#> GSM1324928 3 0.0424 0.696 0.000 0.008 0.992
#> GSM1324938 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324950 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324951 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324952 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324932 3 0.0424 0.696 0.000 0.008 0.992
#> GSM1324933 3 0.0424 0.696 0.000 0.008 0.992
#> GSM1324934 3 0.0424 0.696 0.000 0.008 0.992
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324905 3 0.5982 0.816 0.004 0.328 0.668
#> GSM1324906 3 0.5982 0.816 0.004 0.328 0.668
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0.000
#> GSM1324911 3 0.5982 0.816 0.004 0.328 0.668
#> GSM1324912 3 0.5982 0.816 0.004 0.328 0.668
#> GSM1324913 3 0.5982 0.816 0.004 0.328 0.668
#> GSM1324917 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324918 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324919 3 0.5760 0.817 0.000 0.328 0.672
#> GSM1324923 2 0.4062 0.773 0.000 0.836 0.164
#> GSM1324924 2 0.4062 0.773 0.000 0.836 0.164
#> GSM1324925 2 0.4062 0.773 0.000 0.836 0.164
#> GSM1324929 2 0.4062 0.773 0.000 0.836 0.164
#> GSM1324930 2 0.4062 0.773 0.000 0.836 0.164
#> GSM1324931 2 0.4062 0.773 0.000 0.836 0.164
#> GSM1324935 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324941 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324947 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324948 2 0.0000 0.938 0.000 1.000 0.000
#> GSM1324949 2 0.0000 0.938 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324897 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324898 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324902 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324903 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324904 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324908 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324909 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324910 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324914 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324915 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324916 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324920 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324921 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324922 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324926 3 0.000 1.000 0 0.000 1 0.000
#> GSM1324927 3 0.000 1.000 0 0.000 1 0.000
#> GSM1324928 3 0.000 1.000 0 0.000 1 0.000
#> GSM1324938 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324939 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324940 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324944 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324945 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324946 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324950 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324951 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324952 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324932 3 0.000 1.000 0 0.000 1 0.000
#> GSM1324933 3 0.000 1.000 0 0.000 1 0.000
#> GSM1324934 3 0.000 1.000 0 0.000 1 0.000
#> GSM1324893 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324894 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324895 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324899 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324900 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324901 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324905 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324906 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324907 1 0.000 1.000 1 0.000 0 0.000
#> GSM1324911 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324912 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324913 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324917 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324918 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324919 4 0.000 1.000 0 0.000 0 1.000
#> GSM1324923 2 0.208 0.923 0 0.916 0 0.084
#> GSM1324924 2 0.208 0.923 0 0.916 0 0.084
#> GSM1324925 2 0.208 0.923 0 0.916 0 0.084
#> GSM1324929 2 0.208 0.923 0 0.916 0 0.084
#> GSM1324930 2 0.208 0.923 0 0.916 0 0.084
#> GSM1324931 2 0.208 0.923 0 0.916 0 0.084
#> GSM1324935 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324936 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324937 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324941 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324942 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324943 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324947 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324948 2 0.000 0.975 0 1.000 0 0.000
#> GSM1324949 2 0.000 0.975 0 1.000 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324897 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324898 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324902 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324903 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324904 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324908 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324909 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324910 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324914 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324915 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324916 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324920 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324921 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324922 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324926 3 0.000 1.000 0 0.000 1 0 0.000
#> GSM1324927 3 0.000 1.000 0 0.000 1 0 0.000
#> GSM1324928 3 0.000 1.000 0 0.000 1 0 0.000
#> GSM1324938 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324939 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324940 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324944 2 0.000 0.863 0 1.000 0 0 0.000
#> GSM1324945 2 0.000 0.863 0 1.000 0 0 0.000
#> GSM1324946 2 0.000 0.863 0 1.000 0 0 0.000
#> GSM1324950 5 0.331 1.000 0 0.224 0 0 0.776
#> GSM1324951 5 0.331 1.000 0 0.224 0 0 0.776
#> GSM1324952 5 0.331 1.000 0 0.224 0 0 0.776
#> GSM1324932 3 0.000 1.000 0 0.000 1 0 0.000
#> GSM1324933 3 0.000 1.000 0 0.000 1 0 0.000
#> GSM1324934 3 0.000 1.000 0 0.000 1 0 0.000
#> GSM1324893 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324894 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324895 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324899 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324900 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324901 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324905 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324906 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324907 1 0.000 1.000 1 0.000 0 0 0.000
#> GSM1324911 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324912 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324913 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324917 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324918 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324919 4 0.000 1.000 0 0.000 0 1 0.000
#> GSM1324923 2 0.331 0.776 0 0.776 0 0 0.224
#> GSM1324924 2 0.331 0.776 0 0.776 0 0 0.224
#> GSM1324925 2 0.331 0.776 0 0.776 0 0 0.224
#> GSM1324929 2 0.331 0.776 0 0.776 0 0 0.224
#> GSM1324930 2 0.331 0.776 0 0.776 0 0 0.224
#> GSM1324931 2 0.331 0.776 0 0.776 0 0 0.224
#> GSM1324935 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324936 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324937 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324941 2 0.104 0.865 0 0.960 0 0 0.040
#> GSM1324942 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324943 2 0.112 0.865 0 0.956 0 0 0.044
#> GSM1324947 5 0.331 1.000 0 0.224 0 0 0.776
#> GSM1324948 5 0.331 1.000 0 0.224 0 0 0.776
#> GSM1324949 5 0.331 1.000 0 0.224 0 0 0.776
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.5352 0.793 0.592 0.000 0 0.000 0.204 0.204
#> GSM1324897 1 0.5352 0.793 0.592 0.000 0 0.000 0.204 0.204
#> GSM1324898 1 0.5352 0.793 0.592 0.000 0 0.000 0.204 0.204
#> GSM1324902 1 0.0000 0.801 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.801 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.0363 0.795 0.988 0.000 0 0.000 0.000 0.012
#> GSM1324908 4 0.0547 0.989 0.000 0.000 0 0.980 0.000 0.020
#> GSM1324909 1 0.4863 0.817 0.660 0.000 0 0.000 0.140 0.200
#> GSM1324910 1 0.4863 0.817 0.660 0.000 0 0.000 0.140 0.200
#> GSM1324914 4 0.0000 0.993 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.0458 0.797 0.984 0.000 0 0.000 0.000 0.016
#> GSM1324916 1 0.0363 0.795 0.988 0.000 0 0.000 0.000 0.012
#> GSM1324920 4 0.0260 0.993 0.000 0.000 0 0.992 0.000 0.008
#> GSM1324921 4 0.0260 0.993 0.000 0.000 0 0.992 0.000 0.008
#> GSM1324922 4 0.0260 0.993 0.000 0.000 0 0.992 0.000 0.008
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.0363 0.966 0.000 0.988 0 0.000 0.012 0.000
#> GSM1324939 2 0.0363 0.966 0.000 0.988 0 0.000 0.012 0.000
#> GSM1324940 2 0.0363 0.966 0.000 0.988 0 0.000 0.012 0.000
#> GSM1324944 2 0.0547 0.955 0.000 0.980 0 0.000 0.000 0.020
#> GSM1324945 2 0.0713 0.949 0.000 0.972 0 0.000 0.000 0.028
#> GSM1324946 2 0.0547 0.955 0.000 0.980 0 0.000 0.000 0.020
#> GSM1324950 5 0.2823 1.000 0.000 0.204 0 0.000 0.796 0.000
#> GSM1324951 5 0.2823 1.000 0.000 0.204 0 0.000 0.796 0.000
#> GSM1324952 5 0.2823 1.000 0.000 0.204 0 0.000 0.796 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 0.801 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.801 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.801 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.4863 0.817 0.660 0.000 0 0.000 0.140 0.200
#> GSM1324900 1 0.4898 0.816 0.656 0.000 0 0.000 0.144 0.200
#> GSM1324901 1 0.4898 0.816 0.656 0.000 0 0.000 0.144 0.200
#> GSM1324905 4 0.0146 0.992 0.000 0.000 0 0.996 0.004 0.000
#> GSM1324906 4 0.0146 0.992 0.000 0.000 0 0.996 0.004 0.000
#> GSM1324907 1 0.5352 0.793 0.592 0.000 0 0.000 0.204 0.204
#> GSM1324911 4 0.0508 0.987 0.000 0.000 0 0.984 0.004 0.012
#> GSM1324912 4 0.0000 0.993 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324913 4 0.0508 0.987 0.000 0.000 0 0.984 0.004 0.012
#> GSM1324917 4 0.0260 0.993 0.000 0.000 0 0.992 0.000 0.008
#> GSM1324918 4 0.0000 0.993 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324919 4 0.0260 0.993 0.000 0.000 0 0.992 0.000 0.008
#> GSM1324923 6 0.2969 1.000 0.000 0.224 0 0.000 0.000 0.776
#> GSM1324924 6 0.2969 1.000 0.000 0.224 0 0.000 0.000 0.776
#> GSM1324925 6 0.2969 1.000 0.000 0.224 0 0.000 0.000 0.776
#> GSM1324929 6 0.2969 1.000 0.000 0.224 0 0.000 0.000 0.776
#> GSM1324930 6 0.2969 1.000 0.000 0.224 0 0.000 0.000 0.776
#> GSM1324931 6 0.2969 1.000 0.000 0.224 0 0.000 0.000 0.776
#> GSM1324935 2 0.0632 0.967 0.000 0.976 0 0.000 0.024 0.000
#> GSM1324936 2 0.0632 0.967 0.000 0.976 0 0.000 0.024 0.000
#> GSM1324937 2 0.0632 0.967 0.000 0.976 0 0.000 0.024 0.000
#> GSM1324941 2 0.1204 0.938 0.000 0.944 0 0.000 0.056 0.000
#> GSM1324942 2 0.1204 0.938 0.000 0.944 0 0.000 0.056 0.000
#> GSM1324943 2 0.1204 0.938 0.000 0.944 0 0.000 0.056 0.000
#> GSM1324947 5 0.2823 1.000 0.000 0.204 0 0.000 0.796 0.000
#> GSM1324948 5 0.2823 1.000 0.000 0.204 0 0.000 0.796 0.000
#> GSM1324949 5 0.2823 1.000 0.000 0.204 0 0.000 0.796 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 agent(p) individual(p) k
#> MAD:mclust 60 1.0000 3.87e-06 2
#> MAD:mclust 60 0.2861 1.98e-08 3
#> MAD:mclust 60 0.0332 2.98e-12 4
#> MAD:mclust 60 0.0558 1.80e-16 5
#> MAD:mclust 60 0.0214 1.12e-20 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 46323 rows and 60 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 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.969 0.989 0.5084 0.492 0.492
#> 3 3 0.977 0.949 0.977 0.2933 0.666 0.424
#> 4 4 0.906 0.917 0.949 0.1267 0.855 0.606
#> 5 5 0.857 0.794 0.892 0.0451 0.958 0.841
#> 6 6 0.741 0.677 0.804 0.0356 0.987 0.945
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.0000 0.9824 1.000 0.000
#> GSM1324897 1 0.0000 0.9824 1.000 0.000
#> GSM1324898 1 0.0000 0.9824 1.000 0.000
#> GSM1324902 1 0.0000 0.9824 1.000 0.000
#> GSM1324903 1 0.0000 0.9824 1.000 0.000
#> GSM1324904 1 0.0000 0.9824 1.000 0.000
#> GSM1324908 1 0.1843 0.9554 0.972 0.028
#> GSM1324909 1 0.0000 0.9824 1.000 0.000
#> GSM1324910 1 0.0000 0.9824 1.000 0.000
#> GSM1324914 2 0.0000 0.9945 0.000 1.000
#> GSM1324915 1 0.0000 0.9824 1.000 0.000
#> GSM1324916 1 0.0000 0.9824 1.000 0.000
#> GSM1324920 2 0.0000 0.9945 0.000 1.000
#> GSM1324921 2 0.0000 0.9945 0.000 1.000
#> GSM1324922 2 0.0000 0.9945 0.000 1.000
#> GSM1324926 2 0.0000 0.9945 0.000 1.000
#> GSM1324927 2 0.0000 0.9945 0.000 1.000
#> GSM1324928 2 0.0000 0.9945 0.000 1.000
#> GSM1324938 2 0.0000 0.9945 0.000 1.000
#> GSM1324939 2 0.0000 0.9945 0.000 1.000
#> GSM1324940 2 0.0000 0.9945 0.000 1.000
#> GSM1324944 2 0.4690 0.8893 0.100 0.900
#> GSM1324945 2 0.2043 0.9655 0.032 0.968
#> GSM1324946 2 0.0000 0.9945 0.000 1.000
#> GSM1324950 1 0.0000 0.9824 1.000 0.000
#> GSM1324951 1 0.0000 0.9824 1.000 0.000
#> GSM1324952 1 0.0000 0.9824 1.000 0.000
#> GSM1324932 2 0.0000 0.9945 0.000 1.000
#> GSM1324933 2 0.0000 0.9945 0.000 1.000
#> GSM1324934 2 0.0000 0.9945 0.000 1.000
#> GSM1324893 1 0.0000 0.9824 1.000 0.000
#> GSM1324894 1 0.0000 0.9824 1.000 0.000
#> GSM1324895 1 0.0000 0.9824 1.000 0.000
#> GSM1324899 1 0.0000 0.9824 1.000 0.000
#> GSM1324900 1 0.0000 0.9824 1.000 0.000
#> GSM1324901 1 0.0000 0.9824 1.000 0.000
#> GSM1324905 1 0.0000 0.9824 1.000 0.000
#> GSM1324906 1 0.0000 0.9824 1.000 0.000
#> GSM1324907 1 0.0000 0.9824 1.000 0.000
#> GSM1324911 2 0.0672 0.9881 0.008 0.992
#> GSM1324912 1 0.0000 0.9824 1.000 0.000
#> GSM1324913 2 0.0000 0.9945 0.000 1.000
#> GSM1324917 2 0.0000 0.9945 0.000 1.000
#> GSM1324918 2 0.0000 0.9945 0.000 1.000
#> GSM1324919 2 0.0000 0.9945 0.000 1.000
#> GSM1324923 2 0.0000 0.9945 0.000 1.000
#> GSM1324924 2 0.0000 0.9945 0.000 1.000
#> GSM1324925 2 0.0000 0.9945 0.000 1.000
#> GSM1324929 2 0.0000 0.9945 0.000 1.000
#> GSM1324930 2 0.0000 0.9945 0.000 1.000
#> GSM1324931 2 0.0000 0.9945 0.000 1.000
#> GSM1324935 2 0.0938 0.9846 0.012 0.988
#> GSM1324936 2 0.0000 0.9945 0.000 1.000
#> GSM1324937 1 0.9998 0.0178 0.508 0.492
#> GSM1324941 1 0.0000 0.9824 1.000 0.000
#> GSM1324942 1 0.0000 0.9824 1.000 0.000
#> GSM1324943 1 0.0000 0.9824 1.000 0.000
#> GSM1324947 1 0.0000 0.9824 1.000 0.000
#> GSM1324948 1 0.0000 0.9824 1.000 0.000
#> GSM1324949 1 0.0000 0.9824 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324897 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324898 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324902 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324903 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324904 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324908 1 0.2846 0.915 0.924 0.056 0.020
#> GSM1324909 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324910 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324914 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324915 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324916 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324920 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324921 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324922 3 0.3816 0.804 0.000 0.148 0.852
#> GSM1324926 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324927 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324928 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324938 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324950 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324951 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324952 2 0.1031 0.971 0.024 0.976 0.000
#> GSM1324932 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324933 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324934 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324893 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324894 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324895 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324899 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324900 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324901 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324905 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324906 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324907 1 0.0000 0.995 1.000 0.000 0.000
#> GSM1324911 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324912 1 0.0237 0.991 0.996 0.004 0.000
#> GSM1324913 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324917 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324918 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324919 3 0.0000 0.907 0.000 0.000 1.000
#> GSM1324923 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324924 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324925 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324929 3 0.6180 0.398 0.000 0.416 0.584
#> GSM1324930 3 0.5733 0.585 0.000 0.324 0.676
#> GSM1324931 3 0.6026 0.490 0.000 0.376 0.624
#> GSM1324935 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324941 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324947 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324948 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1324949 2 0.0000 0.999 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.1488 0.961 0.956 0.012 0.000 0.032
#> GSM1324897 1 0.1488 0.961 0.956 0.012 0.000 0.032
#> GSM1324898 1 0.1388 0.964 0.960 0.012 0.000 0.028
#> GSM1324902 1 0.0188 0.985 0.996 0.000 0.000 0.004
#> GSM1324903 1 0.0188 0.985 0.996 0.000 0.000 0.004
#> GSM1324904 1 0.0000 0.985 1.000 0.000 0.000 0.000
#> GSM1324908 4 0.2704 0.837 0.124 0.000 0.000 0.876
#> GSM1324909 1 0.0188 0.984 0.996 0.000 0.000 0.004
#> GSM1324910 1 0.0188 0.984 0.996 0.000 0.000 0.004
#> GSM1324914 4 0.1388 0.902 0.000 0.012 0.028 0.960
#> GSM1324915 1 0.0188 0.985 0.996 0.000 0.000 0.004
#> GSM1324916 1 0.0188 0.985 0.996 0.000 0.000 0.004
#> GSM1324920 4 0.1209 0.904 0.032 0.000 0.004 0.964
#> GSM1324921 4 0.1305 0.904 0.036 0.000 0.004 0.960
#> GSM1324922 4 0.1474 0.898 0.052 0.000 0.000 0.948
#> GSM1324926 3 0.0000 0.910 0.000 0.000 1.000 0.000
#> GSM1324927 3 0.0000 0.910 0.000 0.000 1.000 0.000
#> GSM1324928 3 0.0000 0.910 0.000 0.000 1.000 0.000
#> GSM1324938 2 0.0657 0.949 0.000 0.984 0.012 0.004
#> GSM1324939 2 0.1004 0.945 0.000 0.972 0.024 0.004
#> GSM1324940 2 0.0188 0.951 0.000 0.996 0.000 0.004
#> GSM1324944 2 0.1389 0.935 0.000 0.952 0.000 0.048
#> GSM1324945 2 0.1637 0.928 0.000 0.940 0.000 0.060
#> GSM1324946 2 0.1792 0.922 0.000 0.932 0.000 0.068
#> GSM1324950 2 0.1209 0.942 0.004 0.964 0.000 0.032
#> GSM1324951 2 0.1356 0.940 0.008 0.960 0.000 0.032
#> GSM1324952 2 0.1488 0.938 0.012 0.956 0.000 0.032
#> GSM1324932 3 0.0592 0.913 0.000 0.000 0.984 0.016
#> GSM1324933 3 0.0592 0.913 0.000 0.000 0.984 0.016
#> GSM1324934 3 0.0592 0.913 0.000 0.000 0.984 0.016
#> GSM1324893 1 0.0336 0.983 0.992 0.000 0.000 0.008
#> GSM1324894 1 0.0336 0.983 0.992 0.000 0.000 0.008
#> GSM1324895 1 0.0336 0.983 0.992 0.000 0.000 0.008
#> GSM1324899 1 0.0000 0.985 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.985 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.985 1.000 0.000 0.000 0.000
#> GSM1324905 4 0.1557 0.891 0.000 0.056 0.000 0.944
#> GSM1324906 4 0.1637 0.890 0.000 0.060 0.000 0.940
#> GSM1324907 1 0.1610 0.958 0.952 0.016 0.000 0.032
#> GSM1324911 4 0.1557 0.895 0.000 0.056 0.000 0.944
#> GSM1324912 4 0.3907 0.681 0.232 0.000 0.000 0.768
#> GSM1324913 4 0.1637 0.894 0.000 0.060 0.000 0.940
#> GSM1324917 4 0.1890 0.892 0.008 0.000 0.056 0.936
#> GSM1324918 4 0.1675 0.898 0.004 0.004 0.044 0.948
#> GSM1324919 4 0.2197 0.893 0.024 0.000 0.048 0.928
#> GSM1324923 2 0.3311 0.809 0.000 0.828 0.000 0.172
#> GSM1324924 2 0.3907 0.721 0.000 0.768 0.000 0.232
#> GSM1324925 4 0.3569 0.739 0.000 0.196 0.000 0.804
#> GSM1324929 3 0.4831 0.677 0.000 0.016 0.704 0.280
#> GSM1324930 3 0.4054 0.804 0.000 0.016 0.796 0.188
#> GSM1324931 3 0.4010 0.828 0.000 0.028 0.816 0.156
#> GSM1324935 2 0.0188 0.951 0.000 0.996 0.000 0.004
#> GSM1324936 2 0.0921 0.945 0.000 0.972 0.000 0.028
#> GSM1324937 2 0.0188 0.951 0.000 0.996 0.000 0.004
#> GSM1324941 2 0.0336 0.951 0.000 0.992 0.000 0.008
#> GSM1324942 2 0.0188 0.951 0.000 0.996 0.000 0.004
#> GSM1324943 2 0.0336 0.951 0.000 0.992 0.000 0.008
#> GSM1324947 2 0.1356 0.940 0.008 0.960 0.000 0.032
#> GSM1324948 2 0.1256 0.942 0.008 0.964 0.000 0.028
#> GSM1324949 2 0.1256 0.942 0.008 0.964 0.000 0.028
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 5 0.4283 0.798 0.456 0.000 0.000 0.000 0.544
#> GSM1324897 5 0.4305 0.740 0.488 0.000 0.000 0.000 0.512
#> GSM1324898 1 0.4300 -0.721 0.524 0.000 0.000 0.000 0.476
#> GSM1324902 1 0.0290 0.717 0.992 0.000 0.000 0.000 0.008
#> GSM1324903 1 0.1341 0.698 0.944 0.000 0.000 0.000 0.056
#> GSM1324904 1 0.0510 0.718 0.984 0.000 0.000 0.000 0.016
#> GSM1324908 4 0.1300 0.886 0.028 0.000 0.000 0.956 0.016
#> GSM1324909 1 0.3612 0.303 0.732 0.000 0.000 0.000 0.268
#> GSM1324910 1 0.3661 0.272 0.724 0.000 0.000 0.000 0.276
#> GSM1324914 4 0.0324 0.896 0.000 0.000 0.004 0.992 0.004
#> GSM1324915 1 0.2929 0.606 0.820 0.000 0.000 0.000 0.180
#> GSM1324916 1 0.1965 0.692 0.904 0.000 0.000 0.000 0.096
#> GSM1324920 4 0.0566 0.895 0.004 0.000 0.000 0.984 0.012
#> GSM1324921 4 0.0566 0.895 0.004 0.000 0.000 0.984 0.012
#> GSM1324922 4 0.4610 0.681 0.168 0.000 0.000 0.740 0.092
#> GSM1324926 3 0.0963 0.947 0.000 0.000 0.964 0.000 0.036
#> GSM1324927 3 0.0880 0.949 0.000 0.000 0.968 0.000 0.032
#> GSM1324928 3 0.0880 0.949 0.000 0.000 0.968 0.000 0.032
#> GSM1324938 2 0.0162 0.942 0.000 0.996 0.000 0.000 0.004
#> GSM1324939 2 0.0162 0.942 0.000 0.996 0.000 0.000 0.004
#> GSM1324940 2 0.0162 0.942 0.000 0.996 0.000 0.000 0.004
#> GSM1324944 2 0.0566 0.942 0.000 0.984 0.000 0.004 0.012
#> GSM1324945 2 0.0566 0.942 0.000 0.984 0.000 0.004 0.012
#> GSM1324946 2 0.0566 0.942 0.000 0.984 0.000 0.004 0.012
#> GSM1324950 2 0.1851 0.912 0.000 0.912 0.000 0.000 0.088
#> GSM1324951 2 0.2074 0.898 0.000 0.896 0.000 0.000 0.104
#> GSM1324952 2 0.4147 0.643 0.008 0.676 0.000 0.000 0.316
#> GSM1324932 3 0.0000 0.952 0.000 0.000 1.000 0.000 0.000
#> GSM1324933 3 0.0000 0.952 0.000 0.000 1.000 0.000 0.000
#> GSM1324934 3 0.0000 0.952 0.000 0.000 1.000 0.000 0.000
#> GSM1324893 1 0.2377 0.652 0.872 0.000 0.000 0.000 0.128
#> GSM1324894 1 0.2377 0.652 0.872 0.000 0.000 0.000 0.128
#> GSM1324895 1 0.2377 0.652 0.872 0.000 0.000 0.000 0.128
#> GSM1324899 1 0.2648 0.591 0.848 0.000 0.000 0.000 0.152
#> GSM1324900 1 0.1197 0.714 0.952 0.000 0.000 0.000 0.048
#> GSM1324901 1 0.1908 0.677 0.908 0.000 0.000 0.000 0.092
#> GSM1324905 4 0.3878 0.765 0.000 0.016 0.000 0.748 0.236
#> GSM1324906 4 0.4089 0.756 0.004 0.016 0.000 0.736 0.244
#> GSM1324907 5 0.3999 0.707 0.344 0.000 0.000 0.000 0.656
#> GSM1324911 4 0.1043 0.891 0.000 0.000 0.000 0.960 0.040
#> GSM1324912 4 0.5498 0.513 0.080 0.000 0.000 0.580 0.340
#> GSM1324913 4 0.1041 0.892 0.000 0.004 0.000 0.964 0.032
#> GSM1324917 4 0.0404 0.895 0.000 0.000 0.012 0.988 0.000
#> GSM1324918 4 0.0162 0.896 0.000 0.000 0.004 0.996 0.000
#> GSM1324919 4 0.0613 0.896 0.004 0.000 0.008 0.984 0.004
#> GSM1324923 2 0.1571 0.916 0.000 0.936 0.000 0.060 0.004
#> GSM1324924 2 0.1704 0.910 0.000 0.928 0.000 0.068 0.004
#> GSM1324925 2 0.3928 0.614 0.000 0.700 0.000 0.296 0.004
#> GSM1324929 3 0.2166 0.914 0.000 0.012 0.912 0.072 0.004
#> GSM1324930 3 0.2437 0.914 0.000 0.032 0.904 0.060 0.004
#> GSM1324931 3 0.2835 0.879 0.000 0.080 0.880 0.036 0.004
#> GSM1324935 2 0.0290 0.941 0.000 0.992 0.000 0.000 0.008
#> GSM1324936 2 0.0162 0.942 0.000 0.996 0.000 0.000 0.004
#> GSM1324937 2 0.0290 0.941 0.000 0.992 0.000 0.000 0.008
#> GSM1324941 2 0.1544 0.929 0.000 0.932 0.000 0.000 0.068
#> GSM1324942 2 0.1043 0.939 0.000 0.960 0.000 0.000 0.040
#> GSM1324943 2 0.1043 0.939 0.000 0.960 0.000 0.000 0.040
#> GSM1324947 2 0.0963 0.937 0.000 0.964 0.000 0.000 0.036
#> GSM1324948 2 0.1341 0.930 0.000 0.944 0.000 0.000 0.056
#> GSM1324949 2 0.0510 0.941 0.000 0.984 0.000 0.000 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 5 0.3782 0.384 0.412 0.000 0.000 0.000 0.588 NA
#> GSM1324897 5 0.3864 0.204 0.480 0.000 0.000 0.000 0.520 NA
#> GSM1324898 1 0.3868 -0.347 0.508 0.000 0.000 0.000 0.492 NA
#> GSM1324902 1 0.0260 0.807 0.992 0.000 0.000 0.000 0.008 NA
#> GSM1324903 1 0.0260 0.806 0.992 0.000 0.000 0.000 0.008 NA
#> GSM1324904 1 0.0935 0.804 0.964 0.000 0.000 0.000 0.032 NA
#> GSM1324908 4 0.3127 0.781 0.012 0.000 0.000 0.844 0.040 NA
#> GSM1324909 1 0.2527 0.730 0.832 0.000 0.000 0.000 0.168 NA
#> GSM1324910 1 0.2631 0.718 0.820 0.000 0.000 0.000 0.180 NA
#> GSM1324914 4 0.1738 0.793 0.004 0.000 0.000 0.928 0.016 NA
#> GSM1324915 1 0.4720 0.349 0.560 0.000 0.000 0.000 0.052 NA
#> GSM1324916 1 0.2560 0.758 0.872 0.000 0.000 0.000 0.036 NA
#> GSM1324920 4 0.2288 0.777 0.016 0.000 0.000 0.900 0.068 NA
#> GSM1324921 4 0.2094 0.779 0.008 0.000 0.000 0.908 0.068 NA
#> GSM1324922 4 0.3732 0.719 0.068 0.000 0.000 0.808 0.104 NA
#> GSM1324926 3 0.3950 0.660 0.000 0.000 0.564 0.004 0.000 NA
#> GSM1324927 3 0.3426 0.760 0.000 0.000 0.720 0.004 0.000 NA
#> GSM1324928 3 0.3360 0.765 0.000 0.000 0.732 0.004 0.000 NA
#> GSM1324938 2 0.0891 0.812 0.000 0.968 0.000 0.000 0.008 NA
#> GSM1324939 2 0.1049 0.811 0.000 0.960 0.000 0.000 0.008 NA
#> GSM1324940 2 0.1194 0.811 0.000 0.956 0.004 0.000 0.008 NA
#> GSM1324944 2 0.2255 0.802 0.000 0.892 0.000 0.000 0.028 NA
#> GSM1324945 2 0.2860 0.787 0.000 0.852 0.000 0.000 0.048 NA
#> GSM1324946 2 0.2384 0.800 0.000 0.884 0.000 0.000 0.032 NA
#> GSM1324950 2 0.4026 0.508 0.000 0.612 0.000 0.000 0.376 NA
#> GSM1324951 2 0.4072 0.351 0.000 0.544 0.000 0.000 0.448 NA
#> GSM1324952 5 0.4051 -0.302 0.000 0.432 0.000 0.000 0.560 NA
#> GSM1324932 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324933 3 0.0146 0.833 0.000 0.000 0.996 0.000 0.004 NA
#> GSM1324934 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324893 1 0.1349 0.789 0.940 0.000 0.000 0.000 0.056 NA
#> GSM1324894 1 0.1349 0.789 0.940 0.000 0.000 0.000 0.056 NA
#> GSM1324895 1 0.1349 0.789 0.940 0.000 0.000 0.000 0.056 NA
#> GSM1324899 1 0.1814 0.783 0.900 0.000 0.000 0.000 0.100 NA
#> GSM1324900 1 0.1863 0.794 0.896 0.000 0.000 0.000 0.104 NA
#> GSM1324901 1 0.2165 0.787 0.884 0.000 0.000 0.000 0.108 NA
#> GSM1324905 4 0.5537 0.493 0.000 0.008 0.000 0.480 0.408 NA
#> GSM1324906 4 0.5509 0.485 0.000 0.008 0.000 0.476 0.416 NA
#> GSM1324907 5 0.3565 0.456 0.304 0.000 0.000 0.000 0.692 NA
#> GSM1324911 4 0.3078 0.778 0.000 0.000 0.000 0.836 0.056 NA
#> GSM1324912 4 0.6575 0.387 0.068 0.000 0.000 0.416 0.388 NA
#> GSM1324913 4 0.3092 0.778 0.000 0.000 0.000 0.836 0.060 NA
#> GSM1324917 4 0.1218 0.792 0.000 0.000 0.004 0.956 0.028 NA
#> GSM1324918 4 0.0291 0.796 0.000 0.000 0.004 0.992 0.000 NA
#> GSM1324919 4 0.1862 0.788 0.008 0.000 0.004 0.928 0.044 NA
#> GSM1324923 2 0.4320 0.705 0.000 0.764 0.000 0.120 0.028 NA
#> GSM1324924 2 0.4080 0.719 0.000 0.780 0.000 0.112 0.020 NA
#> GSM1324925 2 0.5217 0.565 0.000 0.640 0.000 0.248 0.024 NA
#> GSM1324929 3 0.3803 0.786 0.000 0.004 0.808 0.076 0.016 NA
#> GSM1324930 3 0.4053 0.784 0.000 0.016 0.800 0.076 0.016 NA
#> GSM1324931 3 0.4148 0.786 0.000 0.032 0.800 0.060 0.016 NA
#> GSM1324935 2 0.1636 0.806 0.000 0.936 0.000 0.004 0.024 NA
#> GSM1324936 2 0.1036 0.812 0.000 0.964 0.000 0.004 0.008 NA
#> GSM1324937 2 0.1245 0.809 0.000 0.952 0.000 0.000 0.016 NA
#> GSM1324941 2 0.3123 0.782 0.000 0.832 0.000 0.000 0.112 NA
#> GSM1324942 2 0.1367 0.811 0.000 0.944 0.000 0.000 0.044 NA
#> GSM1324943 2 0.1334 0.811 0.000 0.948 0.000 0.000 0.032 NA
#> GSM1324947 2 0.4062 0.544 0.004 0.640 0.000 0.000 0.344 NA
#> GSM1324948 2 0.3653 0.613 0.000 0.692 0.000 0.000 0.300 NA
#> GSM1324949 2 0.3190 0.698 0.000 0.772 0.000 0.000 0.220 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n agent(p) individual(p) k
#> MAD:NMF 59 0.6944 3.71e-05 2
#> MAD:NMF 58 0.0845 4.69e-08 3
#> MAD:NMF 60 0.4117 1.21e-11 4
#> MAD:NMF 57 0.6637 6.15e-14 5
#> MAD:NMF 50 0.5242 3.95e-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["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 46323 rows and 60 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.512 0.935 0.949 0.2252 0.817 0.817
#> 3 3 0.697 0.920 0.960 1.5986 0.588 0.496
#> 4 4 0.780 0.833 0.914 0.1898 0.853 0.649
#> 5 5 0.910 0.927 0.956 0.1207 0.893 0.648
#> 6 6 0.892 0.817 0.878 0.0434 0.985 0.928
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.0000 0.936 1.000 0.000
#> GSM1324897 1 0.0000 0.936 1.000 0.000
#> GSM1324898 1 0.0000 0.936 1.000 0.000
#> GSM1324902 1 0.0000 0.936 1.000 0.000
#> GSM1324903 1 0.0000 0.936 1.000 0.000
#> GSM1324904 1 0.0000 0.936 1.000 0.000
#> GSM1324908 1 0.0376 0.936 0.996 0.004
#> GSM1324909 1 0.0000 0.936 1.000 0.000
#> GSM1324910 1 0.0000 0.936 1.000 0.000
#> GSM1324914 1 0.5519 0.917 0.872 0.128
#> GSM1324915 1 0.0000 0.936 1.000 0.000
#> GSM1324916 1 0.0000 0.936 1.000 0.000
#> GSM1324920 1 0.5519 0.917 0.872 0.128
#> GSM1324921 1 0.5519 0.917 0.872 0.128
#> GSM1324922 1 0.5519 0.917 0.872 0.128
#> GSM1324926 2 0.0000 1.000 0.000 1.000
#> GSM1324927 2 0.0000 1.000 0.000 1.000
#> GSM1324928 2 0.0000 1.000 0.000 1.000
#> GSM1324938 1 0.5519 0.917 0.872 0.128
#> GSM1324939 1 0.5519 0.917 0.872 0.128
#> GSM1324940 1 0.5519 0.917 0.872 0.128
#> GSM1324944 1 0.5519 0.917 0.872 0.128
#> GSM1324945 1 0.5519 0.917 0.872 0.128
#> GSM1324946 1 0.5519 0.917 0.872 0.128
#> GSM1324950 1 0.0000 0.936 1.000 0.000
#> GSM1324951 1 0.0000 0.936 1.000 0.000
#> GSM1324952 1 0.0000 0.936 1.000 0.000
#> GSM1324932 2 0.0000 1.000 0.000 1.000
#> GSM1324933 2 0.0000 1.000 0.000 1.000
#> GSM1324934 2 0.0000 1.000 0.000 1.000
#> GSM1324893 1 0.0000 0.936 1.000 0.000
#> GSM1324894 1 0.0000 0.936 1.000 0.000
#> GSM1324895 1 0.0000 0.936 1.000 0.000
#> GSM1324899 1 0.0000 0.936 1.000 0.000
#> GSM1324900 1 0.0000 0.936 1.000 0.000
#> GSM1324901 1 0.0000 0.936 1.000 0.000
#> GSM1324905 1 0.0000 0.936 1.000 0.000
#> GSM1324906 1 0.0000 0.936 1.000 0.000
#> GSM1324907 1 0.0000 0.936 1.000 0.000
#> GSM1324911 1 0.5519 0.917 0.872 0.128
#> GSM1324912 1 0.0000 0.936 1.000 0.000
#> GSM1324913 1 0.5519 0.917 0.872 0.128
#> GSM1324917 1 0.5519 0.917 0.872 0.128
#> GSM1324918 1 0.5519 0.917 0.872 0.128
#> GSM1324919 1 0.5519 0.917 0.872 0.128
#> GSM1324923 1 0.5519 0.917 0.872 0.128
#> GSM1324924 1 0.5519 0.917 0.872 0.128
#> GSM1324925 1 0.5519 0.917 0.872 0.128
#> GSM1324929 1 0.5519 0.917 0.872 0.128
#> GSM1324930 1 0.5519 0.917 0.872 0.128
#> GSM1324931 1 0.5519 0.917 0.872 0.128
#> GSM1324935 1 0.5519 0.917 0.872 0.128
#> GSM1324936 1 0.5519 0.917 0.872 0.128
#> GSM1324937 1 0.5519 0.917 0.872 0.128
#> GSM1324941 1 0.0000 0.936 1.000 0.000
#> GSM1324942 1 0.0000 0.936 1.000 0.000
#> GSM1324943 1 0.0000 0.936 1.000 0.000
#> GSM1324947 1 0.0000 0.936 1.000 0.000
#> GSM1324948 1 0.0000 0.936 1.000 0.000
#> GSM1324949 1 0.0000 0.936 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 0.894 1.000 0.000 0
#> GSM1324897 1 0.000 0.894 1.000 0.000 0
#> GSM1324898 1 0.000 0.894 1.000 0.000 0
#> GSM1324902 1 0.000 0.894 1.000 0.000 0
#> GSM1324903 1 0.000 0.894 1.000 0.000 0
#> GSM1324904 1 0.000 0.894 1.000 0.000 0
#> GSM1324908 2 0.341 0.843 0.124 0.876 0
#> GSM1324909 1 0.000 0.894 1.000 0.000 0
#> GSM1324910 1 0.000 0.894 1.000 0.000 0
#> GSM1324914 2 0.000 0.981 0.000 1.000 0
#> GSM1324915 1 0.000 0.894 1.000 0.000 0
#> GSM1324916 1 0.000 0.894 1.000 0.000 0
#> GSM1324920 2 0.000 0.981 0.000 1.000 0
#> GSM1324921 2 0.000 0.981 0.000 1.000 0
#> GSM1324922 2 0.000 0.981 0.000 1.000 0
#> GSM1324926 3 0.000 1.000 0.000 0.000 1
#> GSM1324927 3 0.000 1.000 0.000 0.000 1
#> GSM1324928 3 0.000 1.000 0.000 0.000 1
#> GSM1324938 2 0.000 0.981 0.000 1.000 0
#> GSM1324939 2 0.000 0.981 0.000 1.000 0
#> GSM1324940 2 0.000 0.981 0.000 1.000 0
#> GSM1324944 2 0.000 0.981 0.000 1.000 0
#> GSM1324945 2 0.000 0.981 0.000 1.000 0
#> GSM1324946 2 0.000 0.981 0.000 1.000 0
#> GSM1324950 1 0.460 0.804 0.796 0.204 0
#> GSM1324951 1 0.460 0.804 0.796 0.204 0
#> GSM1324952 1 0.460 0.804 0.796 0.204 0
#> GSM1324932 3 0.000 1.000 0.000 0.000 1
#> GSM1324933 3 0.000 1.000 0.000 0.000 1
#> GSM1324934 3 0.000 1.000 0.000 0.000 1
#> GSM1324893 1 0.000 0.894 1.000 0.000 0
#> GSM1324894 1 0.000 0.894 1.000 0.000 0
#> GSM1324895 1 0.000 0.894 1.000 0.000 0
#> GSM1324899 1 0.000 0.894 1.000 0.000 0
#> GSM1324900 1 0.000 0.894 1.000 0.000 0
#> GSM1324901 1 0.000 0.894 1.000 0.000 0
#> GSM1324905 2 0.348 0.838 0.128 0.872 0
#> GSM1324906 2 0.348 0.838 0.128 0.872 0
#> GSM1324907 1 0.000 0.894 1.000 0.000 0
#> GSM1324911 2 0.000 0.981 0.000 1.000 0
#> GSM1324912 1 0.445 0.714 0.808 0.192 0
#> GSM1324913 2 0.000 0.981 0.000 1.000 0
#> GSM1324917 2 0.000 0.981 0.000 1.000 0
#> GSM1324918 2 0.000 0.981 0.000 1.000 0
#> GSM1324919 2 0.000 0.981 0.000 1.000 0
#> GSM1324923 2 0.000 0.981 0.000 1.000 0
#> GSM1324924 2 0.000 0.981 0.000 1.000 0
#> GSM1324925 2 0.000 0.981 0.000 1.000 0
#> GSM1324929 2 0.000 0.981 0.000 1.000 0
#> GSM1324930 2 0.000 0.981 0.000 1.000 0
#> GSM1324931 2 0.000 0.981 0.000 1.000 0
#> GSM1324935 2 0.000 0.981 0.000 1.000 0
#> GSM1324936 2 0.000 0.981 0.000 1.000 0
#> GSM1324937 2 0.000 0.981 0.000 1.000 0
#> GSM1324941 1 0.460 0.804 0.796 0.204 0
#> GSM1324942 1 0.460 0.804 0.796 0.204 0
#> GSM1324943 1 0.460 0.804 0.796 0.204 0
#> GSM1324947 1 0.460 0.804 0.796 0.204 0
#> GSM1324948 1 0.460 0.804 0.796 0.204 0
#> GSM1324949 1 0.460 0.804 0.796 0.204 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324908 2 0.4992 -0.182 0.000 0.524 0 0.476
#> GSM1324909 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324914 4 0.3688 0.728 0.000 0.208 0 0.792
#> GSM1324915 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324916 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324920 4 0.3688 0.728 0.000 0.208 0 0.792
#> GSM1324921 4 0.3688 0.728 0.000 0.208 0 0.792
#> GSM1324922 4 0.3688 0.728 0.000 0.208 0 0.792
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324939 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324940 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324944 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324945 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324946 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324950 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324951 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324952 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324905 2 0.4989 -0.170 0.000 0.528 0 0.472
#> GSM1324906 2 0.4989 -0.170 0.000 0.528 0 0.472
#> GSM1324907 1 0.0000 0.981 1.000 0.000 0 0.000
#> GSM1324911 4 0.4855 0.458 0.000 0.400 0 0.600
#> GSM1324912 1 0.4477 0.595 0.688 0.312 0 0.000
#> GSM1324913 4 0.4855 0.458 0.000 0.400 0 0.600
#> GSM1324917 4 0.0188 0.915 0.000 0.004 0 0.996
#> GSM1324918 4 0.0188 0.915 0.000 0.004 0 0.996
#> GSM1324919 4 0.0188 0.915 0.000 0.004 0 0.996
#> GSM1324923 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324924 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324925 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324929 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324930 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324931 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324935 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324936 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324937 4 0.0000 0.917 0.000 0.000 0 1.000
#> GSM1324941 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324942 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324943 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324947 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324948 2 0.3569 0.767 0.196 0.804 0 0.000
#> GSM1324949 2 0.3569 0.767 0.196 0.804 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324908 4 0.233 0.680 0.000 0.000 0 0.876 0.124
#> GSM1324909 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.304 0.784 0.000 0.192 0 0.808 0.000
#> GSM1324915 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324916 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324920 4 0.304 0.784 0.000 0.192 0 0.808 0.000
#> GSM1324921 4 0.304 0.784 0.000 0.192 0 0.808 0.000
#> GSM1324922 4 0.304 0.784 0.000 0.192 0 0.808 0.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324939 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324940 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324944 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324945 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324946 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324950 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324951 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324952 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324932 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324905 4 0.238 0.677 0.000 0.000 0 0.872 0.128
#> GSM1324906 4 0.238 0.677 0.000 0.000 0 0.872 0.128
#> GSM1324907 1 0.000 0.982 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.000 0.719 0.000 0.000 0 1.000 0.000
#> GSM1324912 1 0.515 0.620 0.688 0.000 0 0.192 0.120
#> GSM1324913 4 0.000 0.719 0.000 0.000 0 1.000 0.000
#> GSM1324917 4 0.417 0.575 0.000 0.396 0 0.604 0.000
#> GSM1324918 4 0.417 0.575 0.000 0.396 0 0.604 0.000
#> GSM1324919 4 0.417 0.575 0.000 0.396 0 0.604 0.000
#> GSM1324923 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324924 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324925 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324929 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324930 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324931 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324935 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324936 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324937 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> GSM1324941 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324942 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324943 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324947 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324948 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324949 5 0.000 1.000 0.000 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324908 4 0.209 0.5457 0.000 0.000 0 0.876 0.124 0.000
#> GSM1324909 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.386 -0.0071 0.000 0.000 0 0.528 0.000 0.472
#> GSM1324915 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324916 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324920 4 0.386 -0.0071 0.000 0.000 0 0.528 0.000 0.472
#> GSM1324921 4 0.386 -0.0071 0.000 0.000 0 0.528 0.000 0.472
#> GSM1324922 4 0.386 -0.0071 0.000 0.000 0 0.528 0.000 0.472
#> GSM1324926 3 0.000 1.0000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.000 1.0000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.000 1.0000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324939 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324940 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324944 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324945 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324946 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324950 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.000 1.0000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.000 1.0000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.000 1.0000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324905 4 0.214 0.5442 0.000 0.000 0 0.872 0.128 0.000
#> GSM1324906 4 0.214 0.5442 0.000 0.000 0 0.872 0.128 0.000
#> GSM1324907 1 0.000 0.9816 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324911 4 0.000 0.5384 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324912 1 0.462 0.5877 0.688 0.000 0 0.192 0.120 0.000
#> GSM1324913 4 0.000 0.5384 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324917 6 0.310 1.0000 0.000 0.000 0 0.244 0.000 0.756
#> GSM1324918 6 0.310 1.0000 0.000 0.000 0 0.244 0.000 0.756
#> GSM1324919 6 0.310 1.0000 0.000 0.000 0 0.244 0.000 0.756
#> GSM1324923 2 0.000 0.6754 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324924 2 0.000 0.6754 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324925 2 0.000 0.6754 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324929 2 0.000 0.6754 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324930 2 0.000 0.6754 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324931 2 0.000 0.6754 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324935 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324936 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324937 2 0.384 0.7776 0.000 0.552 0 0.000 0.000 0.448
#> GSM1324941 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324942 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324943 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324947 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.000 1.0000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.000 1.0000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> ATC:hclust 60 0.0314 3.87e-06 2
#> ATC:hclust 60 0.0308 1.18e-08 3
#> ATC:hclust 55 0.0640 6.68e-12 4
#> ATC:hclust 60 0.0860 1.31e-15 5
#> ATC:hclust 56 0.0297 3.49e-17 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 46323 rows and 60 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.491 0.889 0.917 0.4591 0.492 0.492
#> 3 3 0.911 0.907 0.956 0.2310 0.637 0.440
#> 4 4 0.722 0.834 0.896 0.2581 0.834 0.630
#> 5 5 0.807 0.826 0.835 0.0879 0.899 0.665
#> 6 6 0.838 0.645 0.802 0.0527 0.960 0.818
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
#> GSM1324896 1 0.000 0.992 1.000 0.000
#> GSM1324897 1 0.000 0.992 1.000 0.000
#> GSM1324898 1 0.000 0.992 1.000 0.000
#> GSM1324902 1 0.000 0.992 1.000 0.000
#> GSM1324903 1 0.000 0.992 1.000 0.000
#> GSM1324904 1 0.000 0.992 1.000 0.000
#> GSM1324908 1 0.000 0.992 1.000 0.000
#> GSM1324909 1 0.000 0.992 1.000 0.000
#> GSM1324910 1 0.000 0.992 1.000 0.000
#> GSM1324914 2 0.997 0.413 0.468 0.532
#> GSM1324915 1 0.000 0.992 1.000 0.000
#> GSM1324916 1 0.000 0.992 1.000 0.000
#> GSM1324920 2 1.000 0.362 0.488 0.512
#> GSM1324921 2 1.000 0.362 0.488 0.512
#> GSM1324922 1 0.697 0.691 0.812 0.188
#> GSM1324926 2 0.000 0.818 0.000 1.000
#> GSM1324927 2 0.000 0.818 0.000 1.000
#> GSM1324928 2 0.000 0.818 0.000 1.000
#> GSM1324938 2 0.563 0.891 0.132 0.868
#> GSM1324939 2 0.563 0.891 0.132 0.868
#> GSM1324940 2 0.563 0.891 0.132 0.868
#> GSM1324944 2 0.563 0.891 0.132 0.868
#> GSM1324945 2 0.563 0.891 0.132 0.868
#> GSM1324946 2 0.563 0.891 0.132 0.868
#> GSM1324950 1 0.000 0.992 1.000 0.000
#> GSM1324951 1 0.000 0.992 1.000 0.000
#> GSM1324952 1 0.000 0.992 1.000 0.000
#> GSM1324932 2 0.000 0.818 0.000 1.000
#> GSM1324933 2 0.000 0.818 0.000 1.000
#> GSM1324934 2 0.000 0.818 0.000 1.000
#> GSM1324893 1 0.000 0.992 1.000 0.000
#> GSM1324894 1 0.000 0.992 1.000 0.000
#> GSM1324895 1 0.000 0.992 1.000 0.000
#> GSM1324899 1 0.000 0.992 1.000 0.000
#> GSM1324900 1 0.000 0.992 1.000 0.000
#> GSM1324901 1 0.000 0.992 1.000 0.000
#> GSM1324905 1 0.000 0.992 1.000 0.000
#> GSM1324906 1 0.000 0.992 1.000 0.000
#> GSM1324907 1 0.000 0.992 1.000 0.000
#> GSM1324911 2 1.000 0.362 0.488 0.512
#> GSM1324912 1 0.000 0.992 1.000 0.000
#> GSM1324913 2 0.574 0.888 0.136 0.864
#> GSM1324917 2 0.563 0.891 0.132 0.868
#> GSM1324918 2 0.563 0.891 0.132 0.868
#> GSM1324919 2 0.563 0.891 0.132 0.868
#> GSM1324923 2 0.563 0.891 0.132 0.868
#> GSM1324924 2 0.563 0.891 0.132 0.868
#> GSM1324925 2 0.563 0.891 0.132 0.868
#> GSM1324929 2 0.563 0.891 0.132 0.868
#> GSM1324930 2 0.563 0.891 0.132 0.868
#> GSM1324931 2 0.563 0.891 0.132 0.868
#> GSM1324935 2 0.563 0.891 0.132 0.868
#> GSM1324936 2 0.563 0.891 0.132 0.868
#> GSM1324937 2 0.993 0.450 0.452 0.548
#> GSM1324941 1 0.000 0.992 1.000 0.000
#> GSM1324942 1 0.000 0.992 1.000 0.000
#> GSM1324943 1 0.000 0.992 1.000 0.000
#> GSM1324947 1 0.000 0.992 1.000 0.000
#> GSM1324948 1 0.000 0.992 1.000 0.000
#> GSM1324949 1 0.000 0.992 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324897 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324898 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324902 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324903 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324904 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324908 2 0.1031 0.911 0.024 0.976 0.00
#> GSM1324909 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324910 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324914 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324915 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324916 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324920 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324921 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324922 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324926 3 0.0000 0.994 0.000 0.000 1.00
#> GSM1324927 3 0.0000 0.994 0.000 0.000 1.00
#> GSM1324928 3 0.0000 0.994 0.000 0.000 1.00
#> GSM1324938 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324939 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324940 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324944 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324945 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324946 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324950 2 0.6008 0.456 0.372 0.628 0.00
#> GSM1324951 2 0.6291 0.205 0.468 0.532 0.00
#> GSM1324952 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324932 3 0.0892 0.994 0.020 0.000 0.98
#> GSM1324933 3 0.0892 0.994 0.020 0.000 0.98
#> GSM1324934 3 0.0892 0.994 0.020 0.000 0.98
#> GSM1324893 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324894 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324895 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324899 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324900 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324901 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324905 2 0.1031 0.911 0.024 0.976 0.00
#> GSM1324906 2 0.1031 0.911 0.024 0.976 0.00
#> GSM1324907 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324911 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324912 1 0.0892 1.000 0.980 0.020 0.00
#> GSM1324913 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324917 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324918 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324919 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324923 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324924 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324925 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324929 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324930 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324931 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324935 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324936 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324937 2 0.0000 0.925 0.000 1.000 0.00
#> GSM1324941 2 0.0592 0.918 0.012 0.988 0.00
#> GSM1324942 2 0.1031 0.911 0.024 0.976 0.00
#> GSM1324943 2 0.0592 0.918 0.012 0.988 0.00
#> GSM1324947 2 0.6291 0.205 0.468 0.532 0.00
#> GSM1324948 2 0.6008 0.456 0.372 0.628 0.00
#> GSM1324949 2 0.6008 0.456 0.372 0.628 0.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324902 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324903 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324904 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324908 2 0.4594 0.394 0.008 0.712 0.000 0.280
#> GSM1324909 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324914 4 0.4961 0.457 0.000 0.448 0.000 0.552
#> GSM1324915 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324916 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324920 4 0.4961 0.457 0.000 0.448 0.000 0.552
#> GSM1324921 4 0.4961 0.457 0.000 0.448 0.000 0.552
#> GSM1324922 4 0.4961 0.457 0.000 0.448 0.000 0.552
#> GSM1324926 3 0.1302 0.984 0.000 0.044 0.956 0.000
#> GSM1324927 3 0.1211 0.985 0.000 0.040 0.960 0.000
#> GSM1324928 3 0.1211 0.985 0.000 0.040 0.960 0.000
#> GSM1324938 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324939 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324940 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324944 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324945 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324946 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324950 2 0.4756 0.839 0.144 0.784 0.000 0.072
#> GSM1324951 2 0.4756 0.839 0.144 0.784 0.000 0.072
#> GSM1324952 2 0.4365 0.790 0.188 0.784 0.000 0.028
#> GSM1324932 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> GSM1324933 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> GSM1324934 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> GSM1324893 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324894 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324895 1 0.0336 0.993 0.992 0.008 0.000 0.000
#> GSM1324899 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324905 2 0.2198 0.750 0.008 0.920 0.000 0.072
#> GSM1324906 2 0.2198 0.750 0.008 0.920 0.000 0.072
#> GSM1324907 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> GSM1324911 4 0.4961 0.457 0.000 0.448 0.000 0.552
#> GSM1324912 1 0.1389 0.938 0.952 0.048 0.000 0.000
#> GSM1324913 4 0.4948 0.470 0.000 0.440 0.000 0.560
#> GSM1324917 4 0.3219 0.745 0.000 0.164 0.000 0.836
#> GSM1324918 4 0.3123 0.749 0.000 0.156 0.000 0.844
#> GSM1324919 4 0.3219 0.745 0.000 0.164 0.000 0.836
#> GSM1324923 4 0.0000 0.817 0.000 0.000 0.000 1.000
#> GSM1324924 4 0.0000 0.817 0.000 0.000 0.000 1.000
#> GSM1324925 4 0.0000 0.817 0.000 0.000 0.000 1.000
#> GSM1324929 4 0.0000 0.817 0.000 0.000 0.000 1.000
#> GSM1324930 4 0.0000 0.817 0.000 0.000 0.000 1.000
#> GSM1324931 4 0.0000 0.817 0.000 0.000 0.000 1.000
#> GSM1324935 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324936 4 0.0921 0.814 0.000 0.028 0.000 0.972
#> GSM1324937 4 0.3726 0.664 0.000 0.212 0.000 0.788
#> GSM1324941 2 0.3610 0.779 0.000 0.800 0.000 0.200
#> GSM1324942 2 0.3852 0.787 0.008 0.800 0.000 0.192
#> GSM1324943 2 0.3610 0.779 0.000 0.800 0.000 0.200
#> GSM1324947 2 0.4756 0.839 0.144 0.784 0.000 0.072
#> GSM1324948 2 0.4756 0.839 0.144 0.784 0.000 0.072
#> GSM1324949 2 0.4756 0.839 0.144 0.784 0.000 0.072
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324902 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324903 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324904 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324908 4 0.2280 0.6351 0.000 0.120 0.000 0.880 0.000
#> GSM1324909 1 0.0794 0.8219 0.972 0.000 0.000 0.000 0.028
#> GSM1324910 1 0.0794 0.8219 0.972 0.000 0.000 0.000 0.028
#> GSM1324914 4 0.3661 0.7929 0.000 0.276 0.000 0.724 0.000
#> GSM1324915 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324916 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324920 4 0.3661 0.7929 0.000 0.276 0.000 0.724 0.000
#> GSM1324921 4 0.3661 0.7929 0.000 0.276 0.000 0.724 0.000
#> GSM1324922 4 0.3661 0.7929 0.000 0.276 0.000 0.724 0.000
#> GSM1324926 3 0.0703 0.9698 0.000 0.000 0.976 0.000 0.024
#> GSM1324927 3 0.0000 0.9775 0.000 0.000 1.000 0.000 0.000
#> GSM1324928 3 0.0000 0.9775 0.000 0.000 1.000 0.000 0.000
#> GSM1324938 2 0.0162 0.9254 0.000 0.996 0.000 0.004 0.000
#> GSM1324939 2 0.0162 0.9254 0.000 0.996 0.000 0.004 0.000
#> GSM1324940 2 0.0162 0.9254 0.000 0.996 0.000 0.004 0.000
#> GSM1324944 2 0.0324 0.9250 0.000 0.992 0.000 0.004 0.004
#> GSM1324945 2 0.0324 0.9250 0.000 0.992 0.000 0.004 0.004
#> GSM1324946 2 0.0324 0.9250 0.000 0.992 0.000 0.004 0.004
#> GSM1324950 5 0.4936 0.9920 0.008 0.016 0.000 0.416 0.560
#> GSM1324951 5 0.4936 0.9920 0.008 0.016 0.000 0.416 0.560
#> GSM1324952 5 0.4944 0.9862 0.012 0.012 0.000 0.416 0.560
#> GSM1324932 3 0.1270 0.9790 0.000 0.000 0.948 0.000 0.052
#> GSM1324933 3 0.1270 0.9790 0.000 0.000 0.948 0.000 0.052
#> GSM1324934 3 0.1270 0.9790 0.000 0.000 0.948 0.000 0.052
#> GSM1324893 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324894 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324895 1 0.4015 0.8230 0.652 0.000 0.000 0.000 0.348
#> GSM1324899 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324905 4 0.2280 0.0944 0.000 0.000 0.000 0.880 0.120
#> GSM1324906 4 0.2280 0.0944 0.000 0.000 0.000 0.880 0.120
#> GSM1324907 1 0.0000 0.8182 1.000 0.000 0.000 0.000 0.000
#> GSM1324911 4 0.3661 0.7929 0.000 0.276 0.000 0.724 0.000
#> GSM1324912 1 0.4491 0.8155 0.652 0.000 0.000 0.020 0.328
#> GSM1324913 4 0.3730 0.7822 0.000 0.288 0.000 0.712 0.000
#> GSM1324917 4 0.4367 0.5633 0.000 0.416 0.000 0.580 0.004
#> GSM1324918 2 0.4450 -0.4107 0.000 0.508 0.000 0.488 0.004
#> GSM1324919 4 0.4359 0.5713 0.000 0.412 0.000 0.584 0.004
#> GSM1324923 2 0.1117 0.9197 0.000 0.964 0.000 0.020 0.016
#> GSM1324924 2 0.1117 0.9197 0.000 0.964 0.000 0.020 0.016
#> GSM1324925 2 0.1117 0.9197 0.000 0.964 0.000 0.020 0.016
#> GSM1324929 2 0.1117 0.9197 0.000 0.964 0.000 0.020 0.016
#> GSM1324930 2 0.1117 0.9197 0.000 0.964 0.000 0.020 0.016
#> GSM1324931 2 0.1117 0.9197 0.000 0.964 0.000 0.020 0.016
#> GSM1324935 2 0.0324 0.9250 0.000 0.992 0.000 0.004 0.004
#> GSM1324936 2 0.0324 0.9250 0.000 0.992 0.000 0.004 0.004
#> GSM1324937 2 0.2077 0.8093 0.000 0.908 0.000 0.084 0.008
#> GSM1324941 5 0.4848 0.9850 0.000 0.024 0.000 0.420 0.556
#> GSM1324942 5 0.4848 0.9850 0.000 0.024 0.000 0.420 0.556
#> GSM1324943 5 0.4848 0.9850 0.000 0.024 0.000 0.420 0.556
#> GSM1324947 5 0.4936 0.9920 0.008 0.016 0.000 0.416 0.560
#> GSM1324948 5 0.4936 0.9920 0.008 0.016 0.000 0.416 0.560
#> GSM1324949 5 0.4936 0.9920 0.008 0.016 0.000 0.416 0.560
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.1707 0.526 0.928 0.004 0.000 0.056 0.000 0.012
#> GSM1324897 1 0.1707 0.526 0.928 0.004 0.000 0.056 0.000 0.012
#> GSM1324898 1 0.1707 0.526 0.928 0.004 0.000 0.056 0.000 0.012
#> GSM1324902 6 0.4315 0.768 0.492 0.000 0.000 0.004 0.012 0.492
#> GSM1324903 6 0.4315 0.768 0.492 0.000 0.000 0.004 0.012 0.492
#> GSM1324904 1 0.4315 -0.855 0.492 0.000 0.000 0.004 0.012 0.492
#> GSM1324908 4 0.4368 0.802 0.000 0.028 0.000 0.756 0.140 0.076
#> GSM1324909 1 0.1075 0.499 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM1324910 1 0.1075 0.499 0.952 0.000 0.000 0.000 0.000 0.048
#> GSM1324914 4 0.3375 0.851 0.000 0.076 0.000 0.828 0.088 0.008
#> GSM1324915 1 0.5016 -0.784 0.488 0.000 0.000 0.044 0.012 0.456
#> GSM1324916 1 0.5016 -0.784 0.488 0.000 0.000 0.044 0.012 0.456
#> GSM1324920 4 0.3375 0.851 0.000 0.076 0.000 0.828 0.088 0.008
#> GSM1324921 4 0.3375 0.851 0.000 0.076 0.000 0.828 0.088 0.008
#> GSM1324922 4 0.3123 0.851 0.000 0.076 0.000 0.836 0.088 0.000
#> GSM1324926 3 0.0458 0.965 0.000 0.000 0.984 0.000 0.000 0.016
#> GSM1324927 3 0.0146 0.969 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM1324928 3 0.0146 0.969 0.000 0.000 0.996 0.004 0.000 0.000
#> GSM1324938 2 0.1296 0.888 0.000 0.952 0.000 0.012 0.004 0.032
#> GSM1324939 2 0.1296 0.888 0.000 0.952 0.000 0.012 0.004 0.032
#> GSM1324940 2 0.1296 0.888 0.000 0.952 0.000 0.012 0.004 0.032
#> GSM1324944 2 0.1901 0.882 0.000 0.912 0.000 0.008 0.004 0.076
#> GSM1324945 2 0.1901 0.882 0.000 0.912 0.000 0.008 0.004 0.076
#> GSM1324946 2 0.1644 0.884 0.000 0.920 0.000 0.000 0.004 0.076
#> GSM1324950 5 0.0363 0.979 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM1324951 5 0.0363 0.979 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM1324952 5 0.0363 0.979 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM1324932 3 0.1682 0.970 0.000 0.000 0.928 0.020 0.000 0.052
#> GSM1324933 3 0.1682 0.970 0.000 0.000 0.928 0.020 0.000 0.052
#> GSM1324934 3 0.1682 0.970 0.000 0.000 0.928 0.020 0.000 0.052
#> GSM1324893 1 0.4500 -0.824 0.496 0.000 0.000 0.012 0.012 0.480
#> GSM1324894 1 0.4500 -0.824 0.496 0.000 0.000 0.012 0.012 0.480
#> GSM1324895 1 0.4500 -0.824 0.496 0.000 0.000 0.012 0.012 0.480
#> GSM1324899 1 0.0000 0.529 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.529 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.529 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1324905 4 0.5094 0.539 0.000 0.000 0.000 0.568 0.336 0.096
#> GSM1324906 4 0.5094 0.539 0.000 0.000 0.000 0.568 0.336 0.096
#> GSM1324907 1 0.1707 0.526 0.928 0.004 0.000 0.056 0.000 0.012
#> GSM1324911 4 0.4590 0.839 0.000 0.080 0.000 0.756 0.092 0.072
#> GSM1324912 6 0.5482 0.596 0.420 0.000 0.000 0.060 0.028 0.492
#> GSM1324913 4 0.4592 0.840 0.000 0.088 0.000 0.756 0.084 0.072
#> GSM1324917 4 0.3645 0.774 0.000 0.152 0.000 0.784 0.000 0.064
#> GSM1324918 4 0.4456 0.630 0.000 0.268 0.000 0.668 0.000 0.064
#> GSM1324919 4 0.3645 0.774 0.000 0.152 0.000 0.784 0.000 0.064
#> GSM1324923 2 0.2868 0.864 0.000 0.840 0.000 0.028 0.000 0.132
#> GSM1324924 2 0.2868 0.864 0.000 0.840 0.000 0.028 0.000 0.132
#> GSM1324925 2 0.2868 0.864 0.000 0.840 0.000 0.028 0.000 0.132
#> GSM1324929 2 0.3123 0.859 0.000 0.824 0.000 0.040 0.000 0.136
#> GSM1324930 2 0.3123 0.859 0.000 0.824 0.000 0.040 0.000 0.136
#> GSM1324931 2 0.3123 0.859 0.000 0.824 0.000 0.040 0.000 0.136
#> GSM1324935 2 0.2313 0.874 0.000 0.884 0.000 0.012 0.004 0.100
#> GSM1324936 2 0.2313 0.874 0.000 0.884 0.000 0.012 0.004 0.100
#> GSM1324937 2 0.2986 0.851 0.000 0.852 0.000 0.012 0.032 0.104
#> GSM1324941 5 0.1268 0.962 0.000 0.008 0.000 0.004 0.952 0.036
#> GSM1324942 5 0.1268 0.962 0.000 0.008 0.000 0.004 0.952 0.036
#> GSM1324943 5 0.1268 0.962 0.000 0.008 0.000 0.004 0.952 0.036
#> GSM1324947 5 0.0146 0.979 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM1324948 5 0.0146 0.979 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM1324949 5 0.0146 0.979 0.000 0.000 0.000 0.000 0.996 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 agent(p) individual(p) k
#> ATC:kmeans 55 1.0000 4.73e-05 2
#> ATC:kmeans 55 0.0136 1.47e-07 3
#> ATC:kmeans 53 0.0158 1.59e-11 4
#> ATC:kmeans 57 0.0993 2.35e-14 5
#> ATC:kmeans 52 0.1382 2.85e-15 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 46323 rows and 60 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 1.000 0.982 0.993 0.5087 0.492 0.492
#> 3 3 1.000 0.941 0.964 0.2579 0.841 0.686
#> 4 4 0.948 0.924 0.969 0.1517 0.892 0.703
#> 5 5 0.920 0.910 0.947 0.0738 0.907 0.668
#> 6 6 0.903 0.824 0.849 0.0268 0.975 0.885
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 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
#> GSM1324896 1 0.0000 1.000 1.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000
#> GSM1324908 1 0.0000 1.000 1.000 0.000
#> GSM1324909 1 0.0000 1.000 1.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000
#> GSM1324914 2 0.0000 0.986 0.000 1.000
#> GSM1324915 1 0.0000 1.000 1.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000
#> GSM1324920 2 0.0000 0.986 0.000 1.000
#> GSM1324921 2 0.0376 0.982 0.004 0.996
#> GSM1324922 2 0.9732 0.323 0.404 0.596
#> GSM1324926 2 0.0000 0.986 0.000 1.000
#> GSM1324927 2 0.0000 0.986 0.000 1.000
#> GSM1324928 2 0.0000 0.986 0.000 1.000
#> GSM1324938 2 0.0000 0.986 0.000 1.000
#> GSM1324939 2 0.0000 0.986 0.000 1.000
#> GSM1324940 2 0.0000 0.986 0.000 1.000
#> GSM1324944 2 0.0000 0.986 0.000 1.000
#> GSM1324945 2 0.0000 0.986 0.000 1.000
#> GSM1324946 2 0.0000 0.986 0.000 1.000
#> GSM1324950 1 0.0000 1.000 1.000 0.000
#> GSM1324951 1 0.0000 1.000 1.000 0.000
#> GSM1324952 1 0.0000 1.000 1.000 0.000
#> GSM1324932 2 0.0000 0.986 0.000 1.000
#> GSM1324933 2 0.0000 0.986 0.000 1.000
#> GSM1324934 2 0.0000 0.986 0.000 1.000
#> GSM1324893 1 0.0000 1.000 1.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000
#> GSM1324905 1 0.0000 1.000 1.000 0.000
#> GSM1324906 1 0.0000 1.000 1.000 0.000
#> GSM1324907 1 0.0000 1.000 1.000 0.000
#> GSM1324911 2 0.0000 0.986 0.000 1.000
#> GSM1324912 1 0.0000 1.000 1.000 0.000
#> GSM1324913 2 0.0000 0.986 0.000 1.000
#> GSM1324917 2 0.0000 0.986 0.000 1.000
#> GSM1324918 2 0.0000 0.986 0.000 1.000
#> GSM1324919 2 0.0000 0.986 0.000 1.000
#> GSM1324923 2 0.0000 0.986 0.000 1.000
#> GSM1324924 2 0.0000 0.986 0.000 1.000
#> GSM1324925 2 0.0000 0.986 0.000 1.000
#> GSM1324929 2 0.0000 0.986 0.000 1.000
#> GSM1324930 2 0.0000 0.986 0.000 1.000
#> GSM1324931 2 0.0000 0.986 0.000 1.000
#> GSM1324935 2 0.0000 0.986 0.000 1.000
#> GSM1324936 2 0.0000 0.986 0.000 1.000
#> GSM1324937 2 0.0000 0.986 0.000 1.000
#> GSM1324941 1 0.0000 1.000 1.000 0.000
#> GSM1324942 1 0.0000 1.000 1.000 0.000
#> GSM1324943 1 0.0000 1.000 1.000 0.000
#> GSM1324947 1 0.0000 1.000 1.000 0.000
#> GSM1324948 1 0.0000 1.000 1.000 0.000
#> GSM1324949 1 0.0000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324897 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324898 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324902 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324903 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324904 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324908 3 0.2356 0.882 0.072 0.000 0.928
#> GSM1324909 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324910 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324914 3 0.2356 0.925 0.000 0.072 0.928
#> GSM1324915 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324916 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324920 3 0.2356 0.925 0.000 0.072 0.928
#> GSM1324921 3 0.2496 0.925 0.004 0.068 0.928
#> GSM1324922 3 0.2793 0.915 0.028 0.044 0.928
#> GSM1324926 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324927 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324928 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324938 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324950 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324951 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324952 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324932 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324933 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324934 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324893 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324894 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324895 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324899 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324900 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324901 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324905 3 0.0424 0.893 0.008 0.000 0.992
#> GSM1324906 3 0.0424 0.893 0.008 0.000 0.992
#> GSM1324907 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324911 3 0.2356 0.925 0.000 0.072 0.928
#> GSM1324912 1 0.0000 0.977 1.000 0.000 0.000
#> GSM1324913 3 0.2356 0.925 0.000 0.072 0.928
#> GSM1324917 3 0.5254 0.731 0.000 0.264 0.736
#> GSM1324918 2 0.6026 0.275 0.000 0.624 0.376
#> GSM1324919 3 0.5254 0.731 0.000 0.264 0.736
#> GSM1324923 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324924 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324925 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324929 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324930 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324931 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324935 2 0.1411 0.940 0.000 0.964 0.036
#> GSM1324936 2 0.1163 0.948 0.000 0.972 0.028
#> GSM1324937 2 0.1643 0.931 0.000 0.956 0.044
#> GSM1324941 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324942 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324943 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324947 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324948 1 0.2356 0.953 0.928 0.000 0.072
#> GSM1324949 1 0.2356 0.953 0.928 0.000 0.072
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324908 4 0.0188 0.946 0.004 0.000 0.000 0.996
#> GSM1324909 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324914 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> GSM1324915 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324920 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> GSM1324921 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> GSM1324922 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> GSM1324926 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324927 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324928 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324938 3 0.0336 0.950 0.000 0.008 0.992 0.000
#> GSM1324939 3 0.0336 0.950 0.000 0.008 0.992 0.000
#> GSM1324940 3 0.0336 0.950 0.000 0.008 0.992 0.000
#> GSM1324944 3 0.0336 0.950 0.000 0.008 0.992 0.000
#> GSM1324945 3 0.0336 0.950 0.000 0.008 0.992 0.000
#> GSM1324946 3 0.0336 0.950 0.000 0.008 0.992 0.000
#> GSM1324950 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324951 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324952 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324932 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324933 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324934 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324893 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324905 4 0.0592 0.940 0.000 0.016 0.000 0.984
#> GSM1324906 4 0.0592 0.940 0.000 0.016 0.000 0.984
#> GSM1324907 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324911 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> GSM1324912 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1324913 4 0.0000 0.948 0.000 0.000 0.000 1.000
#> GSM1324917 4 0.3528 0.765 0.000 0.000 0.192 0.808
#> GSM1324918 3 0.4817 0.340 0.000 0.000 0.612 0.388
#> GSM1324919 4 0.3486 0.770 0.000 0.000 0.188 0.812
#> GSM1324923 3 0.0188 0.951 0.000 0.004 0.996 0.000
#> GSM1324924 3 0.0188 0.951 0.000 0.004 0.996 0.000
#> GSM1324925 3 0.0188 0.951 0.000 0.004 0.996 0.000
#> GSM1324929 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324930 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324931 3 0.0000 0.951 0.000 0.000 1.000 0.000
#> GSM1324935 3 0.4008 0.679 0.000 0.244 0.756 0.000
#> GSM1324936 3 0.3942 0.692 0.000 0.236 0.764 0.000
#> GSM1324937 2 0.4925 0.153 0.000 0.572 0.428 0.000
#> GSM1324941 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324942 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324943 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324947 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324948 2 0.0336 0.939 0.008 0.992 0.000 0.000
#> GSM1324949 2 0.0336 0.939 0.008 0.992 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324908 4 0.0290 0.978 0 0.008 0.000 0.992 0.000
#> GSM1324909 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324914 4 0.0794 0.977 0 0.028 0.000 0.972 0.000
#> GSM1324915 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324920 4 0.1121 0.973 0 0.044 0.000 0.956 0.000
#> GSM1324921 4 0.1121 0.973 0 0.044 0.000 0.956 0.000
#> GSM1324922 4 0.1121 0.973 0 0.044 0.000 0.956 0.000
#> GSM1324926 3 0.0000 0.837 0 0.000 1.000 0.000 0.000
#> GSM1324927 3 0.0000 0.837 0 0.000 1.000 0.000 0.000
#> GSM1324928 3 0.0000 0.837 0 0.000 1.000 0.000 0.000
#> GSM1324938 2 0.3395 0.806 0 0.764 0.236 0.000 0.000
#> GSM1324939 2 0.3424 0.801 0 0.760 0.240 0.000 0.000
#> GSM1324940 2 0.3424 0.801 0 0.760 0.240 0.000 0.000
#> GSM1324944 2 0.1671 0.904 0 0.924 0.076 0.000 0.000
#> GSM1324945 2 0.1671 0.904 0 0.924 0.076 0.000 0.000
#> GSM1324946 2 0.1671 0.904 0 0.924 0.076 0.000 0.000
#> GSM1324950 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324951 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324952 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324932 3 0.0000 0.837 0 0.000 1.000 0.000 0.000
#> GSM1324933 3 0.0000 0.837 0 0.000 1.000 0.000 0.000
#> GSM1324934 3 0.0000 0.837 0 0.000 1.000 0.000 0.000
#> GSM1324893 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324905 4 0.0771 0.968 0 0.004 0.000 0.976 0.020
#> GSM1324906 4 0.0771 0.968 0 0.004 0.000 0.976 0.020
#> GSM1324907 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324911 4 0.0000 0.978 0 0.000 0.000 1.000 0.000
#> GSM1324912 1 0.0000 1.000 1 0.000 0.000 0.000 0.000
#> GSM1324913 4 0.0000 0.978 0 0.000 0.000 1.000 0.000
#> GSM1324917 3 0.4891 0.483 0 0.044 0.640 0.316 0.000
#> GSM1324918 3 0.3944 0.675 0 0.032 0.768 0.200 0.000
#> GSM1324919 3 0.4957 0.450 0 0.044 0.624 0.332 0.000
#> GSM1324923 3 0.3452 0.640 0 0.244 0.756 0.000 0.000
#> GSM1324924 3 0.3452 0.640 0 0.244 0.756 0.000 0.000
#> GSM1324925 3 0.3452 0.640 0 0.244 0.756 0.000 0.000
#> GSM1324929 3 0.1197 0.825 0 0.048 0.952 0.000 0.000
#> GSM1324930 3 0.1197 0.825 0 0.048 0.952 0.000 0.000
#> GSM1324931 3 0.1197 0.825 0 0.048 0.952 0.000 0.000
#> GSM1324935 2 0.1364 0.892 0 0.952 0.036 0.000 0.012
#> GSM1324936 2 0.1364 0.892 0 0.952 0.036 0.000 0.012
#> GSM1324937 2 0.1386 0.889 0 0.952 0.032 0.000 0.016
#> GSM1324941 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324942 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324943 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324947 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324948 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
#> GSM1324949 5 0.0000 1.000 0 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324897 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324898 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324902 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324903 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324904 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324908 4 0.3915 0.5987 0.004 0.000 0.000 0.584 0.000 NA
#> GSM1324909 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324910 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324914 4 0.0000 0.6297 0.000 0.000 0.000 1.000 0.000 NA
#> GSM1324915 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324916 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324920 4 0.3409 0.5993 0.000 0.000 0.000 0.700 0.000 NA
#> GSM1324921 4 0.3409 0.5993 0.000 0.000 0.000 0.700 0.000 NA
#> GSM1324922 4 0.3371 0.6012 0.000 0.000 0.000 0.708 0.000 NA
#> GSM1324926 3 0.0000 0.8294 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324927 3 0.0000 0.8294 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324928 3 0.0000 0.8294 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324938 2 0.3834 0.6797 0.000 0.708 0.268 0.000 0.000 NA
#> GSM1324939 2 0.3834 0.6797 0.000 0.708 0.268 0.000 0.000 NA
#> GSM1324940 2 0.3834 0.6797 0.000 0.708 0.268 0.000 0.000 NA
#> GSM1324944 2 0.2776 0.8201 0.000 0.860 0.052 0.000 0.000 NA
#> GSM1324945 2 0.2776 0.8201 0.000 0.860 0.052 0.000 0.000 NA
#> GSM1324946 2 0.2776 0.8201 0.000 0.860 0.052 0.000 0.000 NA
#> GSM1324950 5 0.0000 0.9899 0.000 0.000 0.000 0.000 1.000 NA
#> GSM1324951 5 0.0000 0.9899 0.000 0.000 0.000 0.000 1.000 NA
#> GSM1324952 5 0.0000 0.9899 0.000 0.000 0.000 0.000 1.000 NA
#> GSM1324932 3 0.0000 0.8294 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324933 3 0.0000 0.8294 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324934 3 0.0000 0.8294 0.000 0.000 1.000 0.000 0.000 NA
#> GSM1324893 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324894 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324895 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324899 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324900 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324901 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324905 4 0.3966 0.5809 0.000 0.000 0.000 0.552 0.004 NA
#> GSM1324906 4 0.3966 0.5809 0.000 0.000 0.000 0.552 0.004 NA
#> GSM1324907 1 0.0000 0.9995 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1324911 4 0.3515 0.6197 0.000 0.000 0.000 0.676 0.000 NA
#> GSM1324912 1 0.0260 0.9922 0.992 0.000 0.000 0.000 0.000 NA
#> GSM1324913 4 0.3499 0.6205 0.000 0.000 0.000 0.680 0.000 NA
#> GSM1324917 4 0.6128 0.3297 0.000 0.004 0.296 0.432 0.000 NA
#> GSM1324918 3 0.5491 0.0218 0.000 0.004 0.508 0.372 0.000 NA
#> GSM1324919 4 0.6076 0.3800 0.000 0.004 0.260 0.452 0.000 NA
#> GSM1324923 3 0.4585 0.7070 0.000 0.116 0.692 0.000 0.000 NA
#> GSM1324924 3 0.4585 0.7070 0.000 0.116 0.692 0.000 0.000 NA
#> GSM1324925 3 0.4585 0.7070 0.000 0.116 0.692 0.000 0.000 NA
#> GSM1324929 3 0.2730 0.8074 0.000 0.012 0.836 0.000 0.000 NA
#> GSM1324930 3 0.2730 0.8074 0.000 0.012 0.836 0.000 0.000 NA
#> GSM1324931 3 0.2730 0.8074 0.000 0.012 0.836 0.000 0.000 NA
#> GSM1324935 2 0.0858 0.8070 0.000 0.968 0.004 0.000 0.000 NA
#> GSM1324936 2 0.0858 0.8070 0.000 0.968 0.004 0.000 0.000 NA
#> GSM1324937 2 0.0858 0.8070 0.000 0.968 0.004 0.000 0.000 NA
#> GSM1324941 5 0.0790 0.9796 0.000 0.000 0.000 0.000 0.968 NA
#> GSM1324942 5 0.0790 0.9796 0.000 0.000 0.000 0.000 0.968 NA
#> GSM1324943 5 0.0790 0.9796 0.000 0.000 0.000 0.000 0.968 NA
#> GSM1324947 5 0.0000 0.9899 0.000 0.000 0.000 0.000 1.000 NA
#> GSM1324948 5 0.0000 0.9899 0.000 0.000 0.000 0.000 1.000 NA
#> GSM1324949 5 0.0000 0.9899 0.000 0.000 0.000 0.000 1.000 NA
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n agent(p) individual(p) k
#> ATC:skmeans 59 0.898 3.71e-05 2
#> ATC:skmeans 59 0.763 3.52e-07 3
#> ATC:skmeans 58 0.563 1.73e-10 4
#> ATC:skmeans 58 0.673 5.79e-14 5
#> ATC:skmeans 57 0.702 2.29e-14 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 46323 rows and 60 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 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.493 0.724 0.832 0.3175 0.817 0.817
#> 3 3 1.000 0.960 0.986 0.7768 0.616 0.530
#> 4 4 0.793 0.870 0.913 0.2729 0.840 0.636
#> 5 5 0.974 0.932 0.972 0.0996 0.875 0.596
#> 6 6 0.999 0.964 0.985 0.0397 0.952 0.780
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] 3 5
There is also optional best \(k\) = 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.978 0.759 0.588 0.412
#> GSM1324897 1 0.978 0.759 0.588 0.412
#> GSM1324898 1 0.978 0.759 0.588 0.412
#> GSM1324902 1 0.978 0.759 0.588 0.412
#> GSM1324903 1 0.978 0.759 0.588 0.412
#> GSM1324904 1 0.978 0.759 0.588 0.412
#> GSM1324908 1 0.978 0.759 0.588 0.412
#> GSM1324909 1 0.978 0.759 0.588 0.412
#> GSM1324910 1 0.978 0.759 0.588 0.412
#> GSM1324914 1 0.000 0.614 1.000 0.000
#> GSM1324915 1 0.978 0.759 0.588 0.412
#> GSM1324916 1 0.978 0.759 0.588 0.412
#> GSM1324920 1 0.000 0.614 1.000 0.000
#> GSM1324921 1 0.118 0.621 0.984 0.016
#> GSM1324922 1 0.141 0.623 0.980 0.020
#> GSM1324926 2 0.978 1.000 0.412 0.588
#> GSM1324927 2 0.978 1.000 0.412 0.588
#> GSM1324928 2 0.978 1.000 0.412 0.588
#> GSM1324938 1 0.000 0.614 1.000 0.000
#> GSM1324939 1 0.000 0.614 1.000 0.000
#> GSM1324940 1 0.000 0.614 1.000 0.000
#> GSM1324944 1 0.000 0.614 1.000 0.000
#> GSM1324945 1 0.000 0.614 1.000 0.000
#> GSM1324946 1 0.000 0.614 1.000 0.000
#> GSM1324950 1 0.978 0.759 0.588 0.412
#> GSM1324951 1 0.978 0.759 0.588 0.412
#> GSM1324952 1 0.978 0.759 0.588 0.412
#> GSM1324932 2 0.978 1.000 0.412 0.588
#> GSM1324933 2 0.978 1.000 0.412 0.588
#> GSM1324934 2 0.978 1.000 0.412 0.588
#> GSM1324893 1 0.978 0.759 0.588 0.412
#> GSM1324894 1 0.978 0.759 0.588 0.412
#> GSM1324895 1 0.978 0.759 0.588 0.412
#> GSM1324899 1 0.978 0.759 0.588 0.412
#> GSM1324900 1 0.978 0.759 0.588 0.412
#> GSM1324901 1 0.978 0.759 0.588 0.412
#> GSM1324905 1 0.978 0.759 0.588 0.412
#> GSM1324906 1 0.978 0.759 0.588 0.412
#> GSM1324907 1 0.978 0.759 0.588 0.412
#> GSM1324911 1 0.000 0.614 1.000 0.000
#> GSM1324912 1 0.978 0.759 0.588 0.412
#> GSM1324913 1 0.000 0.614 1.000 0.000
#> GSM1324917 1 0.000 0.614 1.000 0.000
#> GSM1324918 1 0.000 0.614 1.000 0.000
#> GSM1324919 1 0.000 0.614 1.000 0.000
#> GSM1324923 1 0.000 0.614 1.000 0.000
#> GSM1324924 1 0.000 0.614 1.000 0.000
#> GSM1324925 1 0.000 0.614 1.000 0.000
#> GSM1324929 1 0.000 0.614 1.000 0.000
#> GSM1324930 1 0.000 0.614 1.000 0.000
#> GSM1324931 1 0.000 0.614 1.000 0.000
#> GSM1324935 1 0.000 0.614 1.000 0.000
#> GSM1324936 1 0.000 0.614 1.000 0.000
#> GSM1324937 1 0.000 0.614 1.000 0.000
#> GSM1324941 1 0.855 0.720 0.720 0.280
#> GSM1324942 1 0.978 0.759 0.588 0.412
#> GSM1324943 1 0.925 0.740 0.660 0.340
#> GSM1324947 1 0.978 0.759 0.588 0.412
#> GSM1324948 1 0.978 0.759 0.588 0.412
#> GSM1324949 1 0.978 0.759 0.588 0.412
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 0.953 1.000 0.000 0
#> GSM1324897 1 0.000 0.953 1.000 0.000 0
#> GSM1324898 1 0.000 0.953 1.000 0.000 0
#> GSM1324902 1 0.000 0.953 1.000 0.000 0
#> GSM1324903 1 0.000 0.953 1.000 0.000 0
#> GSM1324904 1 0.000 0.953 1.000 0.000 0
#> GSM1324908 1 0.571 0.491 0.680 0.320 0
#> GSM1324909 1 0.000 0.953 1.000 0.000 0
#> GSM1324910 1 0.000 0.953 1.000 0.000 0
#> GSM1324914 2 0.000 0.992 0.000 1.000 0
#> GSM1324915 1 0.000 0.953 1.000 0.000 0
#> GSM1324916 1 0.000 0.953 1.000 0.000 0
#> GSM1324920 2 0.000 0.992 0.000 1.000 0
#> GSM1324921 2 0.000 0.992 0.000 1.000 0
#> GSM1324922 2 0.000 0.992 0.000 1.000 0
#> GSM1324926 3 0.000 1.000 0.000 0.000 1
#> GSM1324927 3 0.000 1.000 0.000 0.000 1
#> GSM1324928 3 0.000 1.000 0.000 0.000 1
#> GSM1324938 2 0.000 0.992 0.000 1.000 0
#> GSM1324939 2 0.000 0.992 0.000 1.000 0
#> GSM1324940 2 0.000 0.992 0.000 1.000 0
#> GSM1324944 2 0.000 0.992 0.000 1.000 0
#> GSM1324945 2 0.000 0.992 0.000 1.000 0
#> GSM1324946 2 0.000 0.992 0.000 1.000 0
#> GSM1324950 2 0.000 0.992 0.000 1.000 0
#> GSM1324951 2 0.000 0.992 0.000 1.000 0
#> GSM1324952 1 0.556 0.525 0.700 0.300 0
#> GSM1324932 3 0.000 1.000 0.000 0.000 1
#> GSM1324933 3 0.000 1.000 0.000 0.000 1
#> GSM1324934 3 0.000 1.000 0.000 0.000 1
#> GSM1324893 1 0.000 0.953 1.000 0.000 0
#> GSM1324894 1 0.000 0.953 1.000 0.000 0
#> GSM1324895 1 0.000 0.953 1.000 0.000 0
#> GSM1324899 1 0.000 0.953 1.000 0.000 0
#> GSM1324900 1 0.000 0.953 1.000 0.000 0
#> GSM1324901 1 0.000 0.953 1.000 0.000 0
#> GSM1324905 2 0.493 0.680 0.232 0.768 0
#> GSM1324906 2 0.000 0.992 0.000 1.000 0
#> GSM1324907 1 0.000 0.953 1.000 0.000 0
#> GSM1324911 2 0.000 0.992 0.000 1.000 0
#> GSM1324912 1 0.000 0.953 1.000 0.000 0
#> GSM1324913 2 0.000 0.992 0.000 1.000 0
#> GSM1324917 2 0.000 0.992 0.000 1.000 0
#> GSM1324918 2 0.000 0.992 0.000 1.000 0
#> GSM1324919 2 0.000 0.992 0.000 1.000 0
#> GSM1324923 2 0.000 0.992 0.000 1.000 0
#> GSM1324924 2 0.000 0.992 0.000 1.000 0
#> GSM1324925 2 0.000 0.992 0.000 1.000 0
#> GSM1324929 2 0.000 0.992 0.000 1.000 0
#> GSM1324930 2 0.000 0.992 0.000 1.000 0
#> GSM1324931 2 0.000 0.992 0.000 1.000 0
#> GSM1324935 2 0.000 0.992 0.000 1.000 0
#> GSM1324936 2 0.000 0.992 0.000 1.000 0
#> GSM1324937 2 0.000 0.992 0.000 1.000 0
#> GSM1324941 2 0.000 0.992 0.000 1.000 0
#> GSM1324942 2 0.000 0.992 0.000 1.000 0
#> GSM1324943 2 0.000 0.992 0.000 1.000 0
#> GSM1324947 2 0.000 0.992 0.000 1.000 0
#> GSM1324948 2 0.000 0.992 0.000 1.000 0
#> GSM1324949 2 0.000 0.992 0.000 1.000 0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324897 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324898 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324902 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324903 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324904 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324908 4 0.0000 0.850 0.000 0.000 0 1.000
#> GSM1324909 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324910 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324914 4 0.2469 0.882 0.000 0.108 0 0.892
#> GSM1324915 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324916 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324920 4 0.2216 0.886 0.000 0.092 0 0.908
#> GSM1324921 4 0.2149 0.886 0.000 0.088 0 0.912
#> GSM1324922 4 0.0336 0.856 0.000 0.008 0 0.992
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324938 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324939 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324940 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324944 2 0.2408 0.810 0.000 0.896 0 0.104
#> GSM1324945 2 0.1302 0.816 0.000 0.956 0 0.044
#> GSM1324946 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324950 2 0.4564 0.756 0.000 0.672 0 0.328
#> GSM1324951 2 0.4564 0.756 0.000 0.672 0 0.328
#> GSM1324952 1 0.6781 0.419 0.608 0.180 0 0.212
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000
#> GSM1324893 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324894 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324895 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324899 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324900 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324901 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324905 4 0.0188 0.847 0.000 0.004 0 0.996
#> GSM1324906 4 0.0188 0.847 0.000 0.004 0 0.996
#> GSM1324907 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324911 4 0.1792 0.883 0.000 0.068 0 0.932
#> GSM1324912 1 0.0000 0.974 1.000 0.000 0 0.000
#> GSM1324913 4 0.2530 0.880 0.000 0.112 0 0.888
#> GSM1324917 4 0.3801 0.798 0.000 0.220 0 0.780
#> GSM1324918 4 0.4564 0.659 0.000 0.328 0 0.672
#> GSM1324919 4 0.3726 0.806 0.000 0.212 0 0.788
#> GSM1324923 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324924 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324925 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324929 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324930 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324931 2 0.0188 0.815 0.000 0.996 0 0.004
#> GSM1324935 2 0.4356 0.771 0.000 0.708 0 0.292
#> GSM1324936 2 0.2345 0.812 0.000 0.900 0 0.100
#> GSM1324937 2 0.4454 0.766 0.000 0.692 0 0.308
#> GSM1324941 2 0.4564 0.756 0.000 0.672 0 0.328
#> GSM1324942 2 0.4564 0.756 0.000 0.672 0 0.328
#> GSM1324943 2 0.4564 0.756 0.000 0.672 0 0.328
#> GSM1324947 2 0.5497 0.748 0.044 0.672 0 0.284
#> GSM1324948 2 0.4564 0.756 0.000 0.672 0 0.328
#> GSM1324949 2 0.4564 0.756 0.000 0.672 0 0.328
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324908 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324909 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324914 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324915 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324920 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324921 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324922 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324926 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> GSM1324938 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324939 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324940 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324944 2 0.4305 0.129 0 0.512 0 0.000 0.488
#> GSM1324945 2 0.2732 0.761 0 0.840 0 0.000 0.160
#> GSM1324946 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324950 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324951 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324952 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324932 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0 0.000 1 0.000 0.000
#> GSM1324893 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324905 5 0.0703 0.954 0 0.000 0 0.024 0.976
#> GSM1324906 5 0.1851 0.900 0 0.000 0 0.088 0.912
#> GSM1324907 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324911 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324912 1 0.0000 1.000 1 0.000 0 0.000 0.000
#> GSM1324913 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324917 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324918 2 0.2813 0.735 0 0.832 0 0.168 0.000
#> GSM1324919 4 0.0000 1.000 0 0.000 0 1.000 0.000
#> GSM1324923 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324924 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324925 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324929 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324930 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324931 2 0.0000 0.884 0 1.000 0 0.000 0.000
#> GSM1324935 5 0.3993 0.714 0 0.028 0 0.216 0.756
#> GSM1324936 2 0.4648 0.179 0 0.524 0 0.012 0.464
#> GSM1324937 5 0.0162 0.967 0 0.000 0 0.004 0.996
#> GSM1324941 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324942 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324943 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324947 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324948 5 0.0000 0.969 0 0.000 0 0.000 1.000
#> GSM1324949 5 0.0000 0.969 0 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324908 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324909 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324916 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324920 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324921 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324922 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324926 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324939 2 0.1204 0.931 0 0.944 0 0.000 0.000 0.056
#> GSM1324940 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324944 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324945 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324946 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324950 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324905 5 0.1910 0.872 0 0.000 0 0.108 0.892 0.000
#> GSM1324906 5 0.3076 0.706 0 0.000 0 0.240 0.760 0.000
#> GSM1324907 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324911 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324912 1 0.0000 1.000 1 0.000 0 0.000 0.000 0.000
#> GSM1324913 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324917 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324918 6 0.4882 0.380 0 0.072 0 0.352 0.000 0.576
#> GSM1324919 4 0.0000 1.000 0 0.000 0 1.000 0.000 0.000
#> GSM1324923 6 0.0146 0.923 0 0.004 0 0.000 0.000 0.996
#> GSM1324924 6 0.0000 0.925 0 0.000 0 0.000 0.000 1.000
#> GSM1324925 6 0.0000 0.925 0 0.000 0 0.000 0.000 1.000
#> GSM1324929 6 0.0000 0.925 0 0.000 0 0.000 0.000 1.000
#> GSM1324930 6 0.0000 0.925 0 0.000 0 0.000 0.000 1.000
#> GSM1324931 6 0.0000 0.925 0 0.000 0 0.000 0.000 1.000
#> GSM1324935 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324936 2 0.0000 0.979 0 1.000 0 0.000 0.000 0.000
#> GSM1324937 2 0.1663 0.891 0 0.912 0 0.000 0.088 0.000
#> GSM1324941 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324942 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324943 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324947 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 0.962 0 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 0.962 0 0.000 0 0.000 1.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 agent(p) individual(p) k
#> ATC:pam 60 0.03142 3.87e-06 2
#> ATC:pam 59 0.00909 3.30e-08 3
#> ATC:pam 59 0.03399 5.06e-11 4
#> ATC:pam 58 0.03369 4.22e-13 5
#> ATC:pam 59 0.00811 1.25e-18 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 46323 rows and 60 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 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 1.000 1.000 0.5090 0.492 0.492
#> 3 3 0.658 0.934 0.917 0.2411 0.750 0.533
#> 4 4 1.000 1.000 1.000 0.1318 0.956 0.866
#> 5 5 0.987 0.957 0.980 0.0933 0.939 0.786
#> 6 6 0.977 0.931 0.953 0.0251 0.975 0.887
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 4 5
There is also optional best \(k\) = 2 4 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
#> GSM1324896 1 0 1 1 0
#> GSM1324897 1 0 1 1 0
#> GSM1324898 1 0 1 1 0
#> GSM1324902 1 0 1 1 0
#> GSM1324903 1 0 1 1 0
#> GSM1324904 1 0 1 1 0
#> GSM1324908 1 0 1 1 0
#> GSM1324909 1 0 1 1 0
#> GSM1324910 1 0 1 1 0
#> GSM1324914 1 0 1 1 0
#> GSM1324915 1 0 1 1 0
#> GSM1324916 1 0 1 1 0
#> GSM1324920 1 0 1 1 0
#> GSM1324921 1 0 1 1 0
#> GSM1324922 1 0 1 1 0
#> GSM1324926 2 0 1 0 1
#> GSM1324927 2 0 1 0 1
#> GSM1324928 2 0 1 0 1
#> GSM1324938 2 0 1 0 1
#> GSM1324939 2 0 1 0 1
#> GSM1324940 2 0 1 0 1
#> GSM1324944 2 0 1 0 1
#> GSM1324945 2 0 1 0 1
#> GSM1324946 2 0 1 0 1
#> GSM1324950 2 0 1 0 1
#> GSM1324951 2 0 1 0 1
#> GSM1324952 2 0 1 0 1
#> GSM1324932 2 0 1 0 1
#> GSM1324933 2 0 1 0 1
#> GSM1324934 2 0 1 0 1
#> GSM1324893 1 0 1 1 0
#> GSM1324894 1 0 1 1 0
#> GSM1324895 1 0 1 1 0
#> GSM1324899 1 0 1 1 0
#> GSM1324900 1 0 1 1 0
#> GSM1324901 1 0 1 1 0
#> GSM1324905 1 0 1 1 0
#> GSM1324906 1 0 1 1 0
#> GSM1324907 1 0 1 1 0
#> GSM1324911 1 0 1 1 0
#> GSM1324912 1 0 1 1 0
#> GSM1324913 1 0 1 1 0
#> GSM1324917 1 0 1 1 0
#> GSM1324918 1 0 1 1 0
#> GSM1324919 1 0 1 1 0
#> GSM1324923 2 0 1 0 1
#> GSM1324924 2 0 1 0 1
#> GSM1324925 2 0 1 0 1
#> GSM1324929 2 0 1 0 1
#> GSM1324930 2 0 1 0 1
#> GSM1324931 2 0 1 0 1
#> GSM1324935 2 0 1 0 1
#> GSM1324936 2 0 1 0 1
#> GSM1324937 2 0 1 0 1
#> GSM1324941 2 0 1 0 1
#> GSM1324942 2 0 1 0 1
#> GSM1324943 2 0 1 0 1
#> GSM1324947 2 0 1 0 1
#> GSM1324948 2 0 1 0 1
#> GSM1324949 2 0 1 0 1
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324897 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324898 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324902 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324903 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324904 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324908 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324909 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324910 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324914 3 0.857 0.834 0.196 0.196 0.608
#> GSM1324915 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324916 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324920 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324921 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324922 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324926 3 0.000 0.709 0.000 0.000 1.000
#> GSM1324927 3 0.000 0.709 0.000 0.000 1.000
#> GSM1324928 3 0.000 0.709 0.000 0.000 1.000
#> GSM1324938 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324939 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324940 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324944 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324945 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324946 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324950 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324951 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324952 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324932 3 0.000 0.709 0.000 0.000 1.000
#> GSM1324933 3 0.000 0.709 0.000 0.000 1.000
#> GSM1324934 3 0.000 0.709 0.000 0.000 1.000
#> GSM1324893 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324894 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324895 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324899 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324900 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324901 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324905 3 0.848 0.833 0.188 0.196 0.616
#> GSM1324906 3 0.848 0.833 0.188 0.196 0.616
#> GSM1324907 1 0.000 1.000 1.000 0.000 0.000
#> GSM1324911 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324912 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324913 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324917 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324918 3 0.507 0.760 0.012 0.196 0.792
#> GSM1324919 3 0.865 0.834 0.204 0.196 0.600
#> GSM1324923 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324924 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324925 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324929 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324930 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324931 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324935 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324936 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324937 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324941 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324942 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324943 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324947 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324948 2 0.000 1.000 0.000 1.000 0.000
#> GSM1324949 2 0.000 1.000 0.000 1.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324897 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324898 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324902 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324903 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324904 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324908 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324909 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324910 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324914 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324915 1 0.0188 0.995 0.996 0 0 0.004
#> GSM1324916 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324920 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324921 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324922 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324926 3 0.0000 1.000 0.000 0 1 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0 1 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0 1 0.000
#> GSM1324938 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324939 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324940 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324944 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324945 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324946 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324950 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324951 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324952 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0 1 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0 1 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0 1 0.000
#> GSM1324893 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324894 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324895 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324899 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324900 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324901 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324905 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324906 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324907 1 0.0000 1.000 1.000 0 0 0.000
#> GSM1324911 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324912 4 0.0188 0.995 0.004 0 0 0.996
#> GSM1324913 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324917 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324918 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324919 4 0.0000 1.000 0.000 0 0 1.000
#> GSM1324923 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324924 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324925 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324929 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324930 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324931 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324935 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324936 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324937 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324941 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324942 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324943 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324947 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324948 2 0.0000 1.000 0.000 1 0 0.000
#> GSM1324949 2 0.0000 1.000 0.000 1 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324897 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324898 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324902 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324903 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324904 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324908 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324909 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324910 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324914 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324915 1 0.029 0.991 0.992 0.000 0 0.008 0.000
#> GSM1324916 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324920 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324921 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324922 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324926 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324927 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324928 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324938 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324939 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324940 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324944 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324945 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324946 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324950 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324951 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324952 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324932 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324933 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324934 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> GSM1324893 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324894 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324895 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324899 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324900 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324901 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324905 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324906 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324907 1 0.000 0.999 1.000 0.000 0 0.000 0.000
#> GSM1324911 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324912 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324913 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324917 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324918 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324919 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> GSM1324923 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324924 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324925 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324929 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324930 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324931 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324935 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324936 2 0.000 0.925 0.000 1.000 0 0.000 0.000
#> GSM1324937 2 0.285 0.783 0.000 0.828 0 0.000 0.172
#> GSM1324941 2 0.400 0.562 0.000 0.656 0 0.000 0.344
#> GSM1324942 2 0.400 0.562 0.000 0.656 0 0.000 0.344
#> GSM1324943 2 0.400 0.562 0.000 0.656 0 0.000 0.344
#> GSM1324947 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324948 5 0.000 1.000 0.000 0.000 0 0.000 1.000
#> GSM1324949 5 0.000 1.000 0.000 0.000 0 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324897 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324898 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324902 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324908 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324909 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324914 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324915 1 0.2009 0.918 0.908 0.000 0 0.024 0.000 0.068
#> GSM1324916 1 0.0291 0.984 0.992 0.000 0 0.004 0.000 0.004
#> GSM1324920 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324921 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324922 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324926 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324927 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324928 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324938 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324939 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324940 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324944 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324945 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324946 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324950 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324951 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324952 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324932 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324933 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324934 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> GSM1324893 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324901 1 0.1779 0.929 0.920 0.000 0 0.016 0.000 0.064
#> GSM1324905 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324906 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324907 1 0.0000 0.990 1.000 0.000 0 0.000 0.000 0.000
#> GSM1324911 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324912 4 0.1204 0.948 0.000 0.000 0 0.944 0.000 0.056
#> GSM1324913 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324917 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324918 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324919 4 0.0000 0.996 0.000 0.000 0 1.000 0.000 0.000
#> GSM1324923 2 0.3706 0.828 0.000 0.620 0 0.000 0.000 0.380
#> GSM1324924 2 0.3737 0.838 0.000 0.608 0 0.000 0.000 0.392
#> GSM1324925 2 0.3727 0.836 0.000 0.612 0 0.000 0.000 0.388
#> GSM1324929 2 0.0000 0.393 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324930 2 0.0000 0.393 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324931 2 0.0000 0.393 0.000 1.000 0 0.000 0.000 0.000
#> GSM1324935 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324936 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324937 2 0.3747 0.841 0.000 0.604 0 0.000 0.000 0.396
#> GSM1324941 6 0.1531 1.000 0.000 0.068 0 0.000 0.004 0.928
#> GSM1324942 6 0.1531 1.000 0.000 0.068 0 0.000 0.004 0.928
#> GSM1324943 6 0.1531 1.000 0.000 0.068 0 0.000 0.004 0.928
#> GSM1324947 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324948 5 0.0000 1.000 0.000 0.000 0 0.000 1.000 0.000
#> GSM1324949 5 0.0000 1.000 0.000 0.000 0 0.000 1.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 agent(p) individual(p) k
#> ATC:mclust 60 1.0000 3.87e-06 2
#> ATC:mclust 60 0.2861 1.98e-08 3
#> ATC:mclust 60 0.0332 2.98e-12 4
#> ATC:mclust 60 0.0558 1.80e-16 5
#> ATC:mclust 57 0.0727 8.30e-20 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 46323 rows and 60 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 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.930 0.929 0.971 0.4487 0.548 0.548
#> 3 3 0.866 0.925 0.968 0.3718 0.593 0.390
#> 4 4 0.960 0.921 0.965 0.1734 0.841 0.612
#> 5 5 0.910 0.870 0.921 0.0301 0.973 0.908
#> 6 6 0.815 0.805 0.860 0.0450 0.980 0.927
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 4
There is also optional best \(k\) = 2 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1324896 1 0.0000 0.9777 1.000 0.000
#> GSM1324897 1 0.0000 0.9777 1.000 0.000
#> GSM1324898 1 0.0000 0.9777 1.000 0.000
#> GSM1324902 1 0.0000 0.9777 1.000 0.000
#> GSM1324903 1 0.0000 0.9777 1.000 0.000
#> GSM1324904 1 0.0000 0.9777 1.000 0.000
#> GSM1324908 1 0.0000 0.9777 1.000 0.000
#> GSM1324909 1 0.0000 0.9777 1.000 0.000
#> GSM1324910 1 0.0000 0.9777 1.000 0.000
#> GSM1324914 1 0.0376 0.9749 0.996 0.004
#> GSM1324915 1 0.0000 0.9777 1.000 0.000
#> GSM1324916 1 0.0000 0.9777 1.000 0.000
#> GSM1324920 1 0.0376 0.9749 0.996 0.004
#> GSM1324921 1 0.0376 0.9749 0.996 0.004
#> GSM1324922 1 0.0000 0.9777 1.000 0.000
#> GSM1324926 2 0.0000 0.9501 0.000 1.000
#> GSM1324927 2 0.0000 0.9501 0.000 1.000
#> GSM1324928 2 0.0000 0.9501 0.000 1.000
#> GSM1324938 2 0.0672 0.9473 0.008 0.992
#> GSM1324939 2 0.0000 0.9501 0.000 1.000
#> GSM1324940 2 0.2236 0.9302 0.036 0.964
#> GSM1324944 2 0.9460 0.4604 0.364 0.636
#> GSM1324945 2 0.7745 0.7233 0.228 0.772
#> GSM1324946 2 0.0376 0.9488 0.004 0.996
#> GSM1324950 1 0.0000 0.9777 1.000 0.000
#> GSM1324951 1 0.0000 0.9777 1.000 0.000
#> GSM1324952 1 0.0000 0.9777 1.000 0.000
#> GSM1324932 2 0.0000 0.9501 0.000 1.000
#> GSM1324933 2 0.0000 0.9501 0.000 1.000
#> GSM1324934 2 0.0000 0.9501 0.000 1.000
#> GSM1324893 1 0.0000 0.9777 1.000 0.000
#> GSM1324894 1 0.0000 0.9777 1.000 0.000
#> GSM1324895 1 0.0000 0.9777 1.000 0.000
#> GSM1324899 1 0.0000 0.9777 1.000 0.000
#> GSM1324900 1 0.0000 0.9777 1.000 0.000
#> GSM1324901 1 0.0000 0.9777 1.000 0.000
#> GSM1324905 1 0.0000 0.9777 1.000 0.000
#> GSM1324906 1 0.0000 0.9777 1.000 0.000
#> GSM1324907 1 0.0000 0.9777 1.000 0.000
#> GSM1324911 1 0.0376 0.9749 0.996 0.004
#> GSM1324912 1 0.0000 0.9777 1.000 0.000
#> GSM1324913 1 0.7883 0.6669 0.764 0.236
#> GSM1324917 2 0.7299 0.7573 0.204 0.796
#> GSM1324918 2 0.0938 0.9453 0.012 0.988
#> GSM1324919 1 0.9988 -0.0059 0.520 0.480
#> GSM1324923 2 0.3114 0.9149 0.056 0.944
#> GSM1324924 2 0.0000 0.9501 0.000 1.000
#> GSM1324925 2 0.0000 0.9501 0.000 1.000
#> GSM1324929 2 0.0000 0.9501 0.000 1.000
#> GSM1324930 2 0.0000 0.9501 0.000 1.000
#> GSM1324931 2 0.0000 0.9501 0.000 1.000
#> GSM1324935 1 0.0376 0.9749 0.996 0.004
#> GSM1324936 1 0.3733 0.9041 0.928 0.072
#> GSM1324937 1 0.0000 0.9777 1.000 0.000
#> GSM1324941 1 0.0000 0.9777 1.000 0.000
#> GSM1324942 1 0.0000 0.9777 1.000 0.000
#> GSM1324943 1 0.0000 0.9777 1.000 0.000
#> GSM1324947 1 0.0000 0.9777 1.000 0.000
#> GSM1324948 1 0.0000 0.9777 1.000 0.000
#> GSM1324949 1 0.0000 0.9777 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1324896 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324897 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324898 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324902 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324903 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324904 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324908 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324909 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324910 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324914 2 0.6673 0.628 0.224 0.720 0.056
#> GSM1324915 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324916 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324920 1 0.7984 0.535 0.652 0.216 0.132
#> GSM1324921 1 0.6447 0.663 0.744 0.196 0.060
#> GSM1324922 1 0.4555 0.714 0.800 0.200 0.000
#> GSM1324926 3 0.0000 0.937 0.000 0.000 1.000
#> GSM1324927 3 0.0000 0.937 0.000 0.000 1.000
#> GSM1324928 3 0.0000 0.937 0.000 0.000 1.000
#> GSM1324938 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324939 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324940 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324944 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324945 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324946 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324950 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324951 2 0.1753 0.934 0.048 0.952 0.000
#> GSM1324952 2 0.2165 0.918 0.064 0.936 0.000
#> GSM1324932 3 0.0000 0.937 0.000 0.000 1.000
#> GSM1324933 3 0.0000 0.937 0.000 0.000 1.000
#> GSM1324934 3 0.0000 0.937 0.000 0.000 1.000
#> GSM1324893 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324894 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324895 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324899 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324900 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324901 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324905 2 0.3267 0.861 0.116 0.884 0.000
#> GSM1324906 2 0.0892 0.958 0.020 0.980 0.000
#> GSM1324907 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324911 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324912 1 0.0000 0.954 1.000 0.000 0.000
#> GSM1324913 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324917 3 0.0237 0.934 0.004 0.000 0.996
#> GSM1324918 3 0.4504 0.748 0.000 0.196 0.804
#> GSM1324919 3 0.5254 0.619 0.264 0.000 0.736
#> GSM1324923 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324924 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324925 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324929 2 0.0237 0.970 0.000 0.996 0.004
#> GSM1324930 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324931 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324935 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324936 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324937 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324941 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324942 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324943 2 0.0000 0.973 0.000 1.000 0.000
#> GSM1324947 2 0.3340 0.853 0.120 0.880 0.000
#> GSM1324948 2 0.0237 0.970 0.004 0.996 0.000
#> GSM1324949 2 0.0237 0.970 0.004 0.996 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1324896 1 0.0188 0.9726 0.996 0.000 0.000 0.004
#> GSM1324897 1 0.0188 0.9726 0.996 0.000 0.000 0.004
#> GSM1324898 1 0.0188 0.9726 0.996 0.000 0.000 0.004
#> GSM1324902 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324903 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324904 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324908 4 0.3024 0.7926 0.148 0.000 0.000 0.852
#> GSM1324909 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324910 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324914 4 0.0524 0.9506 0.004 0.008 0.000 0.988
#> GSM1324915 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324916 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324920 4 0.0524 0.9488 0.008 0.000 0.004 0.988
#> GSM1324921 4 0.0524 0.9505 0.008 0.004 0.000 0.988
#> GSM1324922 4 0.1059 0.9482 0.016 0.012 0.000 0.972
#> GSM1324926 3 0.0188 0.9949 0.000 0.000 0.996 0.004
#> GSM1324927 3 0.0000 0.9969 0.000 0.000 1.000 0.000
#> GSM1324928 3 0.0000 0.9969 0.000 0.000 1.000 0.000
#> GSM1324938 2 0.0188 0.9460 0.000 0.996 0.000 0.004
#> GSM1324939 2 0.0188 0.9460 0.000 0.996 0.000 0.004
#> GSM1324940 2 0.0672 0.9422 0.000 0.984 0.008 0.008
#> GSM1324944 2 0.0188 0.9460 0.000 0.996 0.000 0.004
#> GSM1324945 2 0.0188 0.9460 0.000 0.996 0.000 0.004
#> GSM1324946 2 0.0336 0.9451 0.000 0.992 0.000 0.008
#> GSM1324950 2 0.0376 0.9438 0.004 0.992 0.000 0.004
#> GSM1324951 2 0.1109 0.9273 0.028 0.968 0.000 0.004
#> GSM1324952 2 0.1209 0.9234 0.032 0.964 0.000 0.004
#> GSM1324932 3 0.0188 0.9969 0.000 0.000 0.996 0.004
#> GSM1324933 3 0.0188 0.9969 0.000 0.000 0.996 0.004
#> GSM1324934 3 0.0336 0.9947 0.000 0.000 0.992 0.008
#> GSM1324893 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324894 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324895 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324899 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324900 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324901 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324905 4 0.1042 0.9483 0.008 0.020 0.000 0.972
#> GSM1324906 4 0.0895 0.9465 0.004 0.020 0.000 0.976
#> GSM1324907 1 0.0000 0.9758 1.000 0.000 0.000 0.000
#> GSM1324911 4 0.0657 0.9499 0.004 0.012 0.000 0.984
#> GSM1324912 1 0.4661 0.4458 0.652 0.000 0.000 0.348
#> GSM1324913 4 0.0707 0.9456 0.000 0.020 0.000 0.980
#> GSM1324917 4 0.0672 0.9471 0.008 0.000 0.008 0.984
#> GSM1324918 4 0.0376 0.9491 0.004 0.000 0.004 0.992
#> GSM1324919 4 0.0657 0.9471 0.012 0.000 0.004 0.984
#> GSM1324923 2 0.0921 0.9343 0.000 0.972 0.000 0.028
#> GSM1324924 2 0.1022 0.9316 0.000 0.968 0.000 0.032
#> GSM1324925 2 0.1792 0.9013 0.000 0.932 0.000 0.068
#> GSM1324929 4 0.5007 0.6904 0.000 0.172 0.068 0.760
#> GSM1324930 2 0.7370 -0.0462 0.000 0.428 0.160 0.412
#> GSM1324931 2 0.4387 0.6789 0.000 0.752 0.012 0.236
#> GSM1324935 2 0.0336 0.9451 0.000 0.992 0.000 0.008
#> GSM1324936 2 0.0188 0.9460 0.000 0.996 0.000 0.004
#> GSM1324937 2 0.0000 0.9458 0.000 1.000 0.000 0.000
#> GSM1324941 2 0.0000 0.9458 0.000 1.000 0.000 0.000
#> GSM1324942 2 0.0000 0.9458 0.000 1.000 0.000 0.000
#> GSM1324943 2 0.0000 0.9458 0.000 1.000 0.000 0.000
#> GSM1324947 2 0.1489 0.9116 0.044 0.952 0.000 0.004
#> GSM1324948 2 0.0376 0.9438 0.004 0.992 0.000 0.004
#> GSM1324949 2 0.0376 0.9438 0.004 0.992 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1324896 1 0.0609 0.9534 0.980 0.000 0.000 0.000 0.020
#> GSM1324897 1 0.0510 0.9547 0.984 0.000 0.000 0.000 0.016
#> GSM1324898 1 0.0510 0.9547 0.984 0.000 0.000 0.000 0.016
#> GSM1324902 1 0.0290 0.9587 0.992 0.000 0.000 0.000 0.008
#> GSM1324903 1 0.0290 0.9587 0.992 0.000 0.000 0.000 0.008
#> GSM1324904 1 0.0794 0.9518 0.972 0.000 0.000 0.000 0.028
#> GSM1324908 4 0.1568 0.9131 0.020 0.000 0.000 0.944 0.036
#> GSM1324909 1 0.0000 0.9584 1.000 0.000 0.000 0.000 0.000
#> GSM1324910 1 0.0162 0.9580 0.996 0.000 0.000 0.000 0.004
#> GSM1324914 4 0.0955 0.9156 0.004 0.000 0.000 0.968 0.028
#> GSM1324915 1 0.0880 0.9494 0.968 0.000 0.000 0.000 0.032
#> GSM1324916 1 0.0290 0.9582 0.992 0.000 0.000 0.000 0.008
#> GSM1324920 4 0.1357 0.9132 0.004 0.000 0.000 0.948 0.048
#> GSM1324921 4 0.1502 0.9118 0.004 0.000 0.000 0.940 0.056
#> GSM1324922 4 0.1662 0.9121 0.004 0.004 0.000 0.936 0.056
#> GSM1324926 3 0.0290 0.8220 0.000 0.000 0.992 0.000 0.008
#> GSM1324927 3 0.0000 0.8244 0.000 0.000 1.000 0.000 0.000
#> GSM1324928 3 0.0000 0.8244 0.000 0.000 1.000 0.000 0.000
#> GSM1324938 2 0.1124 0.9285 0.000 0.960 0.004 0.000 0.036
#> GSM1324939 2 0.0955 0.9300 0.000 0.968 0.004 0.000 0.028
#> GSM1324940 2 0.1168 0.9300 0.000 0.960 0.008 0.000 0.032
#> GSM1324944 2 0.0609 0.9325 0.000 0.980 0.000 0.000 0.020
#> GSM1324945 2 0.1502 0.9221 0.000 0.940 0.000 0.004 0.056
#> GSM1324946 2 0.0404 0.9328 0.000 0.988 0.000 0.000 0.012
#> GSM1324950 2 0.1270 0.9238 0.000 0.948 0.000 0.000 0.052
#> GSM1324951 2 0.1502 0.9229 0.004 0.940 0.000 0.000 0.056
#> GSM1324952 2 0.2722 0.8739 0.020 0.872 0.000 0.000 0.108
#> GSM1324932 3 0.0162 0.8246 0.000 0.000 0.996 0.000 0.004
#> GSM1324933 3 0.0162 0.8246 0.000 0.000 0.996 0.000 0.004
#> GSM1324934 3 0.0162 0.8246 0.000 0.000 0.996 0.000 0.004
#> GSM1324893 1 0.0510 0.9564 0.984 0.000 0.000 0.000 0.016
#> GSM1324894 1 0.0290 0.9585 0.992 0.000 0.000 0.000 0.008
#> GSM1324895 1 0.0290 0.9585 0.992 0.000 0.000 0.000 0.008
#> GSM1324899 1 0.0290 0.9585 0.992 0.000 0.000 0.000 0.008
#> GSM1324900 1 0.0404 0.9580 0.988 0.000 0.000 0.000 0.012
#> GSM1324901 1 0.0703 0.9538 0.976 0.000 0.000 0.000 0.024
#> GSM1324905 4 0.3067 0.8730 0.012 0.012 0.000 0.856 0.120
#> GSM1324906 4 0.2880 0.8778 0.004 0.020 0.000 0.868 0.108
#> GSM1324907 1 0.0880 0.9474 0.968 0.000 0.000 0.000 0.032
#> GSM1324911 4 0.1544 0.9103 0.000 0.000 0.000 0.932 0.068
#> GSM1324912 1 0.5435 0.0688 0.512 0.000 0.000 0.428 0.060
#> GSM1324913 4 0.1478 0.9095 0.000 0.000 0.000 0.936 0.064
#> GSM1324917 4 0.3048 0.8463 0.004 0.000 0.000 0.820 0.176
#> GSM1324918 4 0.0510 0.9171 0.000 0.000 0.000 0.984 0.016
#> GSM1324919 4 0.3838 0.7655 0.004 0.000 0.000 0.716 0.280
#> GSM1324923 2 0.2689 0.8888 0.000 0.888 0.012 0.016 0.084
#> GSM1324924 2 0.2611 0.8927 0.000 0.896 0.016 0.016 0.072
#> GSM1324925 2 0.3279 0.8632 0.000 0.864 0.048 0.016 0.072
#> GSM1324929 3 0.8068 0.2743 0.000 0.264 0.368 0.272 0.096
#> GSM1324930 3 0.7626 0.2132 0.000 0.368 0.404 0.128 0.100
#> GSM1324931 2 0.6579 0.5093 0.000 0.632 0.144 0.120 0.104
#> GSM1324935 2 0.1121 0.9284 0.000 0.956 0.000 0.000 0.044
#> GSM1324936 2 0.0880 0.9299 0.000 0.968 0.000 0.000 0.032
#> GSM1324937 2 0.0963 0.9296 0.000 0.964 0.000 0.000 0.036
#> GSM1324941 2 0.2074 0.9015 0.000 0.896 0.000 0.000 0.104
#> GSM1324942 2 0.1043 0.9320 0.000 0.960 0.000 0.000 0.040
#> GSM1324943 2 0.1043 0.9312 0.000 0.960 0.000 0.000 0.040
#> GSM1324947 2 0.1281 0.9291 0.012 0.956 0.000 0.000 0.032
#> GSM1324948 2 0.1197 0.9248 0.000 0.952 0.000 0.000 0.048
#> GSM1324949 2 0.0880 0.9297 0.000 0.968 0.000 0.000 0.032
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1324896 1 0.1663 0.9125 0.912 0.000 0.000 0.000 NA 0.000
#> GSM1324897 1 0.1387 0.9207 0.932 0.000 0.000 0.000 NA 0.000
#> GSM1324898 1 0.1387 0.9214 0.932 0.000 0.000 0.000 NA 0.000
#> GSM1324902 1 0.0508 0.9326 0.984 0.000 0.000 0.000 NA 0.004
#> GSM1324903 1 0.0603 0.9323 0.980 0.000 0.000 0.000 NA 0.004
#> GSM1324904 1 0.1168 0.9250 0.956 0.000 0.000 0.000 NA 0.016
#> GSM1324908 4 0.0806 0.8530 0.000 0.000 0.000 0.972 NA 0.008
#> GSM1324909 1 0.0713 0.9321 0.972 0.000 0.000 0.000 NA 0.000
#> GSM1324910 1 0.0713 0.9321 0.972 0.000 0.000 0.000 NA 0.000
#> GSM1324914 4 0.2669 0.8511 0.000 0.000 0.000 0.836 NA 0.156
#> GSM1324915 1 0.2237 0.9014 0.896 0.000 0.000 0.004 NA 0.020
#> GSM1324916 1 0.0937 0.9307 0.960 0.000 0.000 0.000 NA 0.000
#> GSM1324920 4 0.2632 0.8564 0.004 0.000 0.000 0.832 NA 0.164
#> GSM1324921 4 0.2695 0.8627 0.004 0.000 0.000 0.844 NA 0.144
#> GSM1324922 4 0.3023 0.8544 0.004 0.000 0.000 0.808 NA 0.180
#> GSM1324926 3 0.0891 0.9584 0.000 0.000 0.968 0.000 NA 0.008
#> GSM1324927 3 0.0363 0.9752 0.000 0.000 0.988 0.000 NA 0.000
#> GSM1324928 3 0.0363 0.9752 0.000 0.000 0.988 0.000 NA 0.000
#> GSM1324938 2 0.2009 0.8117 0.000 0.916 0.000 0.004 NA 0.040
#> GSM1324939 2 0.2393 0.8076 0.000 0.892 0.000 0.004 NA 0.064
#> GSM1324940 2 0.2407 0.8078 0.000 0.892 0.000 0.004 NA 0.056
#> GSM1324944 2 0.3080 0.7977 0.000 0.860 0.000 0.036 NA 0.068
#> GSM1324945 2 0.3977 0.7579 0.000 0.800 0.000 0.068 NA 0.088
#> GSM1324946 2 0.3320 0.7874 0.000 0.844 0.004 0.056 NA 0.080
#> GSM1324950 2 0.2092 0.8053 0.000 0.876 0.000 0.000 NA 0.000
#> GSM1324951 2 0.3505 0.7683 0.048 0.808 0.000 0.000 NA 0.008
#> GSM1324952 2 0.3939 0.7190 0.068 0.752 0.000 0.000 NA 0.000
#> GSM1324932 3 0.0458 0.9736 0.000 0.000 0.984 0.000 NA 0.016
#> GSM1324933 3 0.0363 0.9762 0.000 0.000 0.988 0.000 NA 0.012
#> GSM1324934 3 0.0363 0.9762 0.000 0.000 0.988 0.000 NA 0.012
#> GSM1324893 1 0.1176 0.9255 0.956 0.000 0.000 0.000 NA 0.020
#> GSM1324894 1 0.0909 0.9302 0.968 0.000 0.000 0.000 NA 0.012
#> GSM1324895 1 0.0909 0.9302 0.968 0.000 0.000 0.000 NA 0.012
#> GSM1324899 1 0.0146 0.9341 0.996 0.000 0.000 0.000 NA 0.000
#> GSM1324900 1 0.0363 0.9338 0.988 0.000 0.000 0.000 NA 0.000
#> GSM1324901 1 0.0363 0.9338 0.988 0.000 0.000 0.000 NA 0.000
#> GSM1324905 4 0.2478 0.8044 0.000 0.012 0.000 0.888 NA 0.024
#> GSM1324906 4 0.2699 0.8044 0.004 0.012 0.000 0.880 NA 0.028
#> GSM1324907 1 0.1908 0.9038 0.900 0.004 0.000 0.000 NA 0.000
#> GSM1324911 4 0.0806 0.8508 0.000 0.000 0.000 0.972 NA 0.020
#> GSM1324912 1 0.5303 0.0526 0.464 0.000 0.000 0.456 NA 0.012
#> GSM1324913 4 0.0891 0.8540 0.000 0.000 0.000 0.968 NA 0.024
#> GSM1324917 4 0.4294 0.8004 0.004 0.000 0.000 0.728 NA 0.188
#> GSM1324918 4 0.2146 0.8671 0.000 0.000 0.000 0.880 NA 0.116
#> GSM1324919 4 0.5171 0.7117 0.008 0.000 0.000 0.628 NA 0.248
#> GSM1324923 2 0.5331 0.0364 0.000 0.504 0.048 0.020 NA 0.424
#> GSM1324924 2 0.5020 0.2490 0.000 0.568 0.032 0.020 NA 0.376
#> GSM1324925 2 0.6451 -0.3295 0.000 0.412 0.224 0.016 NA 0.344
#> GSM1324929 6 0.5834 0.8250 0.000 0.056 0.388 0.060 NA 0.496
#> GSM1324930 6 0.5780 0.8293 0.000 0.072 0.404 0.040 NA 0.484
#> GSM1324931 6 0.6281 0.7575 0.000 0.164 0.284 0.040 NA 0.512
#> GSM1324935 2 0.1889 0.8089 0.000 0.920 0.000 0.004 NA 0.056
#> GSM1324936 2 0.1708 0.8114 0.000 0.932 0.000 0.004 NA 0.040
#> GSM1324937 2 0.1562 0.8120 0.000 0.940 0.000 0.004 NA 0.032
#> GSM1324941 2 0.2917 0.8037 0.000 0.872 0.000 0.040 NA 0.040
#> GSM1324942 2 0.2009 0.8137 0.000 0.916 0.000 0.004 NA 0.040
#> GSM1324943 2 0.2119 0.8127 0.000 0.912 0.000 0.008 NA 0.044
#> GSM1324947 2 0.2609 0.7960 0.036 0.868 0.000 0.000 NA 0.000
#> GSM1324948 2 0.2402 0.7980 0.012 0.868 0.000 0.000 NA 0.000
#> GSM1324949 2 0.1858 0.8106 0.004 0.904 0.000 0.000 NA 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 agent(p) individual(p) k
#> ATC:NMF 58 0.5758 7.98e-06 2
#> ATC:NMF 60 0.0662 5.50e-09 3
#> ATC:NMF 58 0.0484 5.85e-11 4
#> ATC:NMF 57 0.0588 5.68e-11 5
#> ATC:NMF 56 0.0472 3.79e-15 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