Date: 2019-12-25 22:00: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 51979 rows and 56 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4, anno = anno)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 51979 56
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, top_annotation = HeatmapAnnotation(df = get_anno(res_list),
col = get_anno_col(res_list)), ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:hclust | 2 | 1.000 | 0.987 | 0.992 | ** | |
SD:kmeans | 2 | 1.000 | 0.993 | 0.997 | ** | |
CV:hclust | 5 | 1.000 | 0.973 | 0.987 | ** | 2 |
CV:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:hclust | 5 | 1.000 | 0.998 | 0.981 | ** | 2,4 |
MAD:kmeans | 2 | 1.000 | 0.992 | 0.996 | ** | |
MAD:mclust | 6 | 1.000 | 0.996 | 0.998 | ** | 2,5 |
ATC:hclust | 5 | 1.000 | 0.960 | 0.984 | ** | 2,4 |
ATC:kmeans | 2 | 1.000 | 0.992 | 0.996 | ** | |
ATC:mclust | 4 | 1.000 | 0.962 | 0.978 | ** | 2 |
ATC:NMF | 2 | 1.000 | 0.986 | 0.994 | ** | |
CV:mclust | 6 | 0.990 | 0.983 | 0.988 | ** | 2,3,5 |
CV:pam | 6 | 0.984 | 0.961 | 0.966 | ** | 2,5 |
SD:mclust | 6 | 0.983 | 0.971 | 0.980 | ** | 2,5 |
SD:pam | 6 | 0.971 | 0.953 | 0.967 | ** | 2,5 |
SD:skmeans | 5 | 0.962 | 0.936 | 0.961 | ** | 2,3,4 |
CV:skmeans | 5 | 0.955 | 0.873 | 0.944 | ** | 2,3,4 |
MAD:pam | 6 | 0.948 | 0.975 | 0.970 | * | 2,4,5 |
CV:NMF | 5 | 0.945 | 0.884 | 0.963 | * | 2,4 |
MAD:NMF | 5 | 0.938 | 0.903 | 0.944 | * | 2,4 |
ATC:pam | 6 | 0.936 | 0.915 | 0.954 | * | 2,3 |
MAD:skmeans | 5 | 0.931 | 0.918 | 0.961 | * | 2,3,4 |
SD:NMF | 5 | 0.918 | 0.800 | 0.904 | * | 2,4 |
ATC:skmeans | 5 | 0.917 | 0.974 | 0.970 | * | 2 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 1 0.991 0.996 0.495 0.507 0.507
#> CV:NMF 2 1 0.986 0.994 0.495 0.507 0.507
#> MAD:NMF 2 1 0.984 0.994 0.495 0.507 0.507
#> ATC:NMF 2 1 0.986 0.994 0.495 0.507 0.507
#> SD:skmeans 2 1 0.979 0.992 0.497 0.501 0.501
#> CV:skmeans 2 1 0.980 0.993 0.497 0.501 0.501
#> MAD:skmeans 2 1 0.987 0.994 0.498 0.501 0.501
#> ATC:skmeans 2 1 1.000 1.000 0.493 0.507 0.507
#> SD:mclust 2 1 1.000 1.000 0.510 0.491 0.491
#> CV:mclust 2 1 0.998 0.999 0.510 0.491 0.491
#> MAD:mclust 2 1 1.000 1.000 0.510 0.491 0.491
#> ATC:mclust 2 1 0.981 0.990 0.508 0.491 0.491
#> SD:kmeans 2 1 0.993 0.997 0.494 0.507 0.507
#> CV:kmeans 2 1 1.000 1.000 0.493 0.507 0.507
#> MAD:kmeans 2 1 0.992 0.996 0.495 0.507 0.507
#> ATC:kmeans 2 1 0.992 0.996 0.480 0.523 0.523
#> SD:pam 2 1 0.966 0.986 0.484 0.523 0.523
#> CV:pam 2 1 0.970 0.988 0.491 0.514 0.514
#> MAD:pam 2 1 0.992 0.996 0.494 0.507 0.507
#> ATC:pam 2 1 1.000 1.000 0.478 0.523 0.523
#> SD:hclust 2 1 0.987 0.992 0.489 0.507 0.507
#> CV:hclust 2 1 0.994 0.996 0.491 0.507 0.507
#> MAD:hclust 2 1 1.000 1.000 0.493 0.507 0.507
#> ATC:hclust 2 1 0.963 0.986 0.487 0.507 0.507
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.850 0.872 0.944 0.294 0.830 0.675
#> CV:NMF 3 0.786 0.808 0.921 0.302 0.829 0.672
#> MAD:NMF 3 0.782 0.837 0.925 0.337 0.778 0.578
#> ATC:NMF 3 0.628 0.624 0.782 0.258 0.960 0.921
#> SD:skmeans 3 1.000 0.998 0.998 0.218 0.879 0.761
#> CV:skmeans 3 1.000 0.997 0.997 0.219 0.879 0.761
#> MAD:skmeans 3 1.000 0.946 0.974 0.199 0.894 0.790
#> ATC:skmeans 3 0.787 0.910 0.926 0.192 0.909 0.821
#> SD:mclust 3 0.730 0.830 0.811 0.210 1.000 1.000
#> CV:mclust 3 0.906 0.963 0.961 0.240 0.873 0.741
#> MAD:mclust 3 0.778 0.767 0.890 0.210 0.873 0.745
#> ATC:mclust 3 0.631 0.831 0.864 0.267 0.671 0.437
#> SD:kmeans 3 0.702 0.695 0.692 0.276 0.897 0.813
#> CV:kmeans 3 0.663 0.678 0.822 0.284 0.875 0.757
#> MAD:kmeans 3 0.710 0.728 0.804 0.275 0.964 0.932
#> ATC:kmeans 3 0.679 0.664 0.864 0.239 0.908 0.825
#> SD:pam 3 0.713 0.932 0.940 0.269 0.826 0.681
#> CV:pam 3 0.669 0.791 0.802 0.329 0.788 0.596
#> MAD:pam 3 0.739 0.865 0.864 0.271 0.860 0.731
#> ATC:pam 3 1.000 0.992 0.997 0.212 0.873 0.762
#> SD:hclust 3 0.799 0.935 0.926 0.275 0.860 0.723
#> CV:hclust 3 0.827 0.892 0.889 0.251 0.860 0.723
#> MAD:hclust 3 0.827 0.957 0.944 0.262 0.860 0.723
#> ATC:hclust 3 0.899 0.933 0.922 0.170 0.914 0.831
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.945 0.937 0.972 0.1545 0.877 0.677
#> CV:NMF 4 0.927 0.886 0.955 0.1525 0.834 0.582
#> MAD:NMF 4 0.980 0.933 0.974 0.1139 0.817 0.524
#> ATC:NMF 4 0.580 0.785 0.783 0.0948 0.798 0.578
#> SD:skmeans 4 1.000 0.998 0.998 0.1828 0.889 0.719
#> CV:skmeans 4 1.000 0.996 0.995 0.1809 0.889 0.719
#> MAD:skmeans 4 1.000 0.956 0.985 0.1829 0.889 0.726
#> ATC:skmeans 4 0.821 0.958 0.911 0.1215 0.889 0.733
#> SD:mclust 4 0.894 0.944 0.959 0.2038 0.764 0.520
#> CV:mclust 4 0.877 0.871 0.927 0.1868 0.845 0.594
#> MAD:mclust 4 0.889 0.906 0.938 0.2110 0.816 0.551
#> ATC:mclust 4 1.000 0.962 0.978 0.1553 0.884 0.678
#> SD:kmeans 4 0.763 0.905 0.877 0.1351 0.725 0.463
#> CV:kmeans 4 0.786 0.854 0.840 0.1329 0.803 0.535
#> MAD:kmeans 4 0.781 0.843 0.845 0.1269 0.695 0.424
#> ATC:kmeans 4 0.729 0.794 0.808 0.1589 0.801 0.568
#> SD:pam 4 0.817 0.891 0.934 0.1985 0.864 0.655
#> CV:pam 4 0.897 0.918 0.942 0.1522 0.880 0.650
#> MAD:pam 4 0.933 0.937 0.967 0.1988 0.832 0.584
#> ATC:pam 4 0.784 0.822 0.890 0.2758 0.843 0.627
#> SD:hclust 4 0.775 0.933 0.911 0.1256 0.914 0.766
#> CV:hclust 4 0.734 0.510 0.670 0.1276 0.717 0.437
#> MAD:hclust 4 1.000 1.000 1.000 0.1167 0.938 0.832
#> ATC:hclust 4 1.000 0.960 0.984 0.0912 0.960 0.904
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.918 0.800 0.904 0.01898 0.969 0.889
#> CV:NMF 5 0.945 0.884 0.963 0.00267 0.960 0.858
#> MAD:NMF 5 0.938 0.903 0.944 0.01559 0.971 0.894
#> ATC:NMF 5 0.758 0.827 0.882 0.07416 0.920 0.747
#> SD:skmeans 5 0.962 0.936 0.961 0.08569 0.912 0.702
#> CV:skmeans 5 0.955 0.873 0.944 0.08183 0.921 0.730
#> MAD:skmeans 5 0.931 0.918 0.961 0.09185 0.931 0.767
#> ATC:skmeans 5 0.917 0.974 0.970 0.06996 0.973 0.911
#> SD:mclust 5 0.900 0.938 0.947 0.07388 0.943 0.776
#> CV:mclust 5 0.907 0.937 0.920 0.05969 0.953 0.809
#> MAD:mclust 5 0.911 0.934 0.930 0.06381 0.928 0.729
#> ATC:mclust 5 0.783 0.856 0.871 0.06025 0.932 0.741
#> SD:kmeans 5 0.723 0.937 0.902 0.07082 0.964 0.860
#> CV:kmeans 5 0.701 0.916 0.880 0.06729 0.935 0.758
#> MAD:kmeans 5 0.742 0.902 0.869 0.07232 0.953 0.820
#> ATC:kmeans 5 0.687 0.889 0.871 0.08273 0.938 0.781
#> SD:pam 5 1.000 0.992 0.996 0.06228 0.929 0.742
#> CV:pam 5 0.952 0.904 0.965 0.05023 0.903 0.645
#> MAD:pam 5 1.000 0.941 0.979 0.04513 0.934 0.745
#> ATC:pam 5 0.776 0.873 0.892 0.04448 0.911 0.689
#> SD:hclust 5 0.855 0.971 0.968 0.09432 0.938 0.781
#> CV:hclust 5 1.000 0.973 0.987 0.12434 0.850 0.586
#> MAD:hclust 5 1.000 0.998 0.981 0.11278 0.914 0.719
#> ATC:hclust 5 1.000 0.960 0.984 0.13597 0.916 0.779
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.879 0.811 0.883 0.0193 0.973 0.900
#> CV:NMF 6 0.842 0.785 0.881 0.0185 0.974 0.904
#> MAD:NMF 6 0.874 0.836 0.903 0.0195 0.982 0.933
#> ATC:NMF 6 0.742 0.727 0.854 0.0351 0.977 0.917
#> SD:skmeans 6 0.878 0.874 0.899 0.0403 0.982 0.917
#> CV:skmeans 6 0.855 0.630 0.778 0.0499 0.940 0.739
#> MAD:skmeans 6 0.890 0.894 0.913 0.0389 0.947 0.783
#> ATC:skmeans 6 0.949 0.930 0.961 0.0412 0.995 0.981
#> SD:mclust 6 0.983 0.971 0.980 0.0500 0.964 0.820
#> CV:mclust 6 0.990 0.983 0.988 0.0541 0.964 0.820
#> MAD:mclust 6 1.000 0.996 0.998 0.0553 0.949 0.757
#> ATC:mclust 6 0.833 0.899 0.906 0.0506 0.933 0.688
#> SD:kmeans 6 0.870 0.875 0.865 0.0422 1.000 1.000
#> CV:kmeans 6 0.832 0.848 0.841 0.0468 1.000 1.000
#> MAD:kmeans 6 0.815 0.857 0.852 0.0519 1.000 1.000
#> ATC:kmeans 6 0.754 0.817 0.876 0.0507 0.995 0.976
#> SD:pam 6 0.971 0.953 0.967 0.0668 0.945 0.751
#> CV:pam 6 0.984 0.961 0.966 0.0575 0.943 0.735
#> MAD:pam 6 0.948 0.975 0.970 0.0521 0.949 0.764
#> ATC:pam 6 0.936 0.915 0.954 0.0315 0.981 0.912
#> SD:hclust 6 0.956 0.943 0.962 0.0170 0.991 0.959
#> CV:hclust 6 0.987 0.959 0.973 0.0103 0.991 0.959
#> MAD:hclust 6 1.000 0.941 0.983 0.0171 0.995 0.976
#> ATC:hclust 6 1.000 0.987 0.993 0.0152 0.988 0.961
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 infection(p) disease.state(p) individual(p) k
#> SD:NMF 56 0.0181 1.69e-08 0.955 2
#> CV:NMF 56 0.0181 1.69e-08 0.955 2
#> MAD:NMF 55 0.0159 6.02e-09 0.956 2
#> ATC:NMF 56 0.0181 1.69e-08 0.955 2
#> SD:skmeans 55 0.0159 6.02e-09 0.956 2
#> CV:skmeans 55 0.0159 6.02e-09 0.956 2
#> MAD:skmeans 56 0.0136 3.63e-09 0.949 2
#> ATC:skmeans 56 0.0181 1.69e-08 0.955 2
#> SD:mclust 56 0.0036 4.20e-12 0.995 2
#> CV:mclust 56 0.0036 4.20e-12 0.995 2
#> MAD:mclust 56 0.0036 4.20e-12 0.995 2
#> ATC:mclust 56 0.0036 4.20e-12 0.995 2
#> SD:kmeans 56 0.0181 1.69e-08 0.955 2
#> CV:kmeans 56 0.0181 1.69e-08 0.955 2
#> MAD:kmeans 56 0.0181 1.69e-08 0.955 2
#> ATC:kmeans 56 0.0307 2.22e-07 0.937 2
#> SD:pam 54 0.0246 4.58e-08 0.950 2
#> CV:pam 55 0.0211 2.77e-08 0.962 2
#> MAD:pam 56 0.0181 1.69e-08 0.955 2
#> ATC:pam 56 0.0307 2.22e-07 0.937 2
#> SD:hclust 56 0.0181 1.69e-08 0.955 2
#> CV:hclust 56 0.0181 1.69e-08 0.955 2
#> MAD:hclust 56 0.0181 1.69e-08 0.955 2
#> ATC:hclust 54 0.0246 4.58e-08 0.950 2
test_to_known_factors(res_list, k = 3)
#> n infection(p) disease.state(p) individual(p) k
#> SD:NMF 51 1.47e-02 8.96e-09 0.908 3
#> CV:NMF 51 1.47e-02 8.96e-09 0.908 3
#> MAD:NMF 51 4.81e-03 1.14e-08 0.819 3
#> ATC:NMF 46 4.65e-03 5.67e-10 0.929 3
#> SD:skmeans 56 4.69e-03 2.40e-10 0.902 3
#> CV:skmeans 56 4.69e-03 2.40e-10 0.902 3
#> MAD:skmeans 54 6.64e-03 7.33e-10 0.903 3
#> ATC:skmeans 56 4.69e-03 2.78e-10 0.907 3
#> SD:mclust 56 3.60e-03 4.20e-12 0.995 3
#> CV:mclust 56 4.69e-03 2.85e-11 0.932 3
#> MAD:mclust 48 9.80e-05 1.38e-10 0.911 3
#> ATC:mclust 55 1.57e-05 1.41e-08 0.749 3
#> SD:kmeans 51 8.61e-03 4.89e-11 0.985 3
#> CV:kmeans 51 1.12e-02 2.87e-09 0.897 3
#> MAD:kmeans 51 8.61e-03 4.89e-11 0.985 3
#> ATC:kmeans 45 1.09e-01 4.72e-06 0.908 3
#> SD:pam 56 1.32e-02 4.24e-10 0.807 3
#> CV:pam 51 2.35e-03 2.27e-08 0.663 3
#> MAD:pam 55 1.13e-02 1.36e-10 0.845 3
#> ATC:pam 56 2.38e-02 6.27e-10 0.856 3
#> SD:hclust 56 7.86e-04 1.93e-09 0.944 3
#> CV:hclust 51 1.01e-04 1.43e-11 0.940 3
#> MAD:hclust 56 7.86e-04 1.93e-09 0.944 3
#> ATC:hclust 56 2.38e-02 2.72e-09 0.851 3
test_to_known_factors(res_list, k = 4)
#> n infection(p) disease.state(p) individual(p) k
#> SD:NMF 55 2.43e-04 2.81e-11 0.903 4
#> CV:NMF 52 8.33e-04 2.25e-10 0.893 4
#> MAD:NMF 54 5.56e-04 7.17e-11 0.899 4
#> ATC:NMF 54 2.60e-03 1.39e-09 0.853 4
#> SD:skmeans 56 1.11e-04 2.41e-11 0.905 4
#> CV:skmeans 56 1.11e-04 2.41e-11 0.905 4
#> MAD:skmeans 54 1.78e-04 8.70e-11 0.880 4
#> ATC:skmeans 54 1.78e-04 8.70e-11 0.880 4
#> SD:mclust 56 1.11e-04 4.17e-13 0.934 4
#> CV:mclust 55 3.17e-05 4.79e-14 0.806 4
#> MAD:mclust 56 1.11e-04 4.17e-13 0.934 4
#> ATC:mclust 56 4.80e-05 1.44e-12 0.933 4
#> SD:kmeans 56 1.11e-04 4.17e-13 0.934 4
#> CV:kmeans 53 2.26e-04 6.92e-12 0.914 4
#> MAD:kmeans 45 1.51e-03 1.02e-09 0.803 4
#> ATC:kmeans 51 3.63e-04 9.82e-13 0.899 4
#> SD:pam 53 2.37e-03 1.13e-10 0.793 4
#> CV:pam 54 4.02e-03 2.84e-10 0.605 4
#> MAD:pam 55 9.85e-03 5.06e-10 0.657 4
#> ATC:pam 53 6.45e-03 1.27e-10 0.856 4
#> SD:hclust 56 2.53e-03 2.21e-10 0.885 4
#> CV:hclust 25 NA 1.05e-05 0.512 4
#> MAD:hclust 56 1.11e-04 2.78e-11 0.909 4
#> ATC:hclust 54 4.57e-02 1.51e-07 0.938 4
test_to_known_factors(res_list, k = 5)
#> n infection(p) disease.state(p) individual(p) k
#> SD:NMF 51 4.91e-04 2.54e-09 0.903 5
#> CV:NMF 52 8.33e-04 3.91e-10 0.883 5
#> MAD:NMF 55 1.90e-04 2.25e-10 0.951 5
#> ATC:NMF 53 2.26e-04 9.38e-11 0.826 5
#> SD:skmeans 55 4.18e-04 7.90e-12 0.835 5
#> CV:skmeans 50 1.29e-03 1.08e-10 0.837 5
#> MAD:skmeans 52 8.21e-04 1.18e-11 0.874 5
#> ATC:skmeans 56 3.34e-04 2.11e-10 0.784 5
#> SD:mclust 55 3.22e-05 1.22e-12 0.837 5
#> CV:mclust 56 3.15e-05 6.30e-13 0.853 5
#> MAD:mclust 55 3.22e-05 1.22e-12 0.837 5
#> ATC:mclust 55 3.22e-05 1.22e-12 0.837 5
#> SD:kmeans 56 3.34e-04 2.92e-12 0.862 5
#> CV:kmeans 56 3.34e-04 2.92e-12 0.862 5
#> MAD:kmeans 56 3.34e-04 2.92e-12 0.862 5
#> ATC:kmeans 55 4.18e-04 7.69e-12 0.811 5
#> SD:pam 56 3.34e-04 2.92e-12 0.862 5
#> CV:pam 52 5.10e-04 2.18e-11 0.817 5
#> MAD:pam 54 1.54e-03 2.07e-11 0.842 5
#> ATC:pam 56 3.34e-04 7.23e-13 0.865 5
#> SD:hclust 56 3.34e-04 2.92e-12 0.862 5
#> CV:hclust 56 3.34e-04 2.92e-12 0.862 5
#> MAD:hclust 56 3.34e-04 2.92e-12 0.862 5
#> ATC:hclust 54 2.03e-02 1.75e-09 0.912 5
test_to_known_factors(res_list, k = 6)
#> n infection(p) disease.state(p) individual(p) k
#> SD:NMF 53 3.05e-04 4.19e-10 0.882 6
#> CV:NMF 47 2.74e-04 8.31e-09 0.704 6
#> MAD:NMF 52 3.87e-04 1.02e-09 0.875 6
#> ATC:NMF 50 4.60e-04 1.38e-09 0.827 6
#> SD:skmeans 54 1.31e-03 2.49e-10 0.774 6
#> CV:skmeans 45 2.48e-02 2.01e-07 0.662 6
#> MAD:skmeans 55 1.06e-03 1.02e-10 0.777 6
#> ATC:skmeans 54 5.24e-04 1.24e-09 0.745 6
#> SD:mclust 56 8.89e-05 3.40e-12 0.778 6
#> CV:mclust 56 8.89e-05 3.40e-12 0.778 6
#> MAD:mclust 56 8.89e-05 3.40e-12 0.778 6
#> ATC:mclust 56 1.06e-04 4.21e-12 0.740 6
#> SD:kmeans 56 3.34e-04 2.92e-12 0.862 6
#> CV:kmeans 56 3.34e-04 2.92e-12 0.862 6
#> MAD:kmeans 56 3.34e-04 2.92e-12 0.862 6
#> ATC:kmeans 52 8.21e-04 1.44e-10 0.778 6
#> SD:pam 55 2.22e-04 1.93e-11 0.772 6
#> CV:pam 56 2.39e-04 1.10e-11 0.786 6
#> MAD:pam 56 4.88e-04 2.57e-11 0.785 6
#> ATC:pam 55 1.06e-03 3.22e-11 0.711 6
#> SD:hclust 54 5.24e-04 2.07e-11 0.813 6
#> CV:hclust 56 8.53e-04 5.02e-11 0.923 6
#> MAD:hclust 54 5.24e-04 2.07e-11 0.813 6
#> ATC:hclust 56 3.00e-02 3.73e-09 0.810 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.987 0.992 0.4894 0.507 0.507
#> 3 3 0.799 0.935 0.926 0.2755 0.860 0.723
#> 4 4 0.775 0.933 0.911 0.1256 0.914 0.766
#> 5 5 0.855 0.971 0.968 0.0943 0.938 0.781
#> 6 6 0.956 0.943 0.962 0.0170 0.991 0.959
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
#> GSM1253056 1 0.000 1.000 1.000 0.000
#> GSM1253057 1 0.000 1.000 1.000 0.000
#> GSM1253058 1 0.000 1.000 1.000 0.000
#> GSM1253059 1 0.000 1.000 1.000 0.000
#> GSM1253060 1 0.000 1.000 1.000 0.000
#> GSM1253061 1 0.000 1.000 1.000 0.000
#> GSM1253062 1 0.000 1.000 1.000 0.000
#> GSM1253063 1 0.000 1.000 1.000 0.000
#> GSM1253064 1 0.000 1.000 1.000 0.000
#> GSM1253065 1 0.000 1.000 1.000 0.000
#> GSM1253066 1 0.000 1.000 1.000 0.000
#> GSM1253067 1 0.000 1.000 1.000 0.000
#> GSM1253068 1 0.000 1.000 1.000 0.000
#> GSM1253069 1 0.000 1.000 1.000 0.000
#> GSM1253070 1 0.000 1.000 1.000 0.000
#> GSM1253071 1 0.000 1.000 1.000 0.000
#> GSM1253072 1 0.000 1.000 1.000 0.000
#> GSM1253073 1 0.000 1.000 1.000 0.000
#> GSM1253074 1 0.000 1.000 1.000 0.000
#> GSM1253032 1 0.000 1.000 1.000 0.000
#> GSM1253034 2 0.000 0.981 0.000 1.000
#> GSM1253039 2 0.000 0.981 0.000 1.000
#> GSM1253040 2 0.000 0.981 0.000 1.000
#> GSM1253041 2 0.000 0.981 0.000 1.000
#> GSM1253046 1 0.000 1.000 1.000 0.000
#> GSM1253048 2 0.000 0.981 0.000 1.000
#> GSM1253049 2 0.000 0.981 0.000 1.000
#> GSM1253052 2 0.000 0.981 0.000 1.000
#> GSM1253037 2 0.000 0.981 0.000 1.000
#> GSM1253028 2 0.327 0.944 0.060 0.940
#> GSM1253029 2 0.000 0.981 0.000 1.000
#> GSM1253030 2 0.000 0.981 0.000 1.000
#> GSM1253031 2 0.358 0.937 0.068 0.932
#> GSM1253033 1 0.000 1.000 1.000 0.000
#> GSM1253035 2 0.204 0.963 0.032 0.968
#> GSM1253036 2 0.000 0.981 0.000 1.000
#> GSM1253038 2 0.000 0.981 0.000 1.000
#> GSM1253042 2 0.000 0.981 0.000 1.000
#> GSM1253045 2 0.482 0.902 0.104 0.896
#> GSM1253043 2 0.518 0.889 0.116 0.884
#> GSM1253044 2 0.000 0.981 0.000 1.000
#> GSM1253047 1 0.000 1.000 1.000 0.000
#> GSM1253050 2 0.000 0.981 0.000 1.000
#> GSM1253051 2 0.000 0.981 0.000 1.000
#> GSM1253053 2 0.000 0.981 0.000 1.000
#> GSM1253054 1 0.000 1.000 1.000 0.000
#> GSM1253055 2 0.278 0.953 0.048 0.952
#> GSM1253079 1 0.000 1.000 1.000 0.000
#> GSM1253083 1 0.000 1.000 1.000 0.000
#> GSM1253075 1 0.000 1.000 1.000 0.000
#> GSM1253077 1 0.000 1.000 1.000 0.000
#> GSM1253076 1 0.000 1.000 1.000 0.000
#> GSM1253078 1 0.000 1.000 1.000 0.000
#> GSM1253081 1 0.000 1.000 1.000 0.000
#> GSM1253080 1 0.000 1.000 1.000 0.000
#> GSM1253082 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253057 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253058 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253059 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253060 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253061 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253062 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253063 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253064 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253065 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253066 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253067 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253068 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253069 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253070 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253071 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253072 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253073 3 0.525 1.000 0.264 0.000 0.736
#> GSM1253074 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253032 1 0.525 0.705 0.736 0.000 0.264
#> GSM1253034 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253039 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253040 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253041 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253046 1 0.525 0.705 0.736 0.000 0.264
#> GSM1253048 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253049 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253052 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253037 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253028 2 0.207 0.951 0.000 0.940 0.060
#> GSM1253029 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253030 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253031 2 0.226 0.946 0.000 0.932 0.068
#> GSM1253033 1 0.525 0.705 0.736 0.000 0.264
#> GSM1253035 2 0.129 0.967 0.000 0.968 0.032
#> GSM1253036 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253038 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253042 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253045 2 0.304 0.918 0.000 0.896 0.104
#> GSM1253043 2 0.327 0.907 0.000 0.884 0.116
#> GSM1253044 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253047 1 0.525 0.705 0.736 0.000 0.264
#> GSM1253050 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253051 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253053 2 0.000 0.983 0.000 1.000 0.000
#> GSM1253054 1 0.525 0.705 0.736 0.000 0.264
#> GSM1253055 2 0.175 0.958 0.000 0.952 0.048
#> GSM1253079 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253083 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253075 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253077 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253076 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253078 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253081 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253080 1 0.000 0.921 1.000 0.000 0.000
#> GSM1253082 1 0.000 0.921 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0469 0.996 0.012 0.000 0.000 0.988
#> GSM1253057 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253058 4 0.0469 0.996 0.012 0.000 0.000 0.988
#> GSM1253059 4 0.0000 0.987 0.000 0.000 0.000 1.000
#> GSM1253060 4 0.0469 0.996 0.012 0.000 0.000 0.988
#> GSM1253061 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253062 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253063 4 0.0469 0.996 0.012 0.000 0.000 0.988
#> GSM1253064 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253065 4 0.0592 0.992 0.016 0.000 0.000 0.984
#> GSM1253066 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253067 4 0.0469 0.996 0.012 0.000 0.000 0.988
#> GSM1253068 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253069 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253070 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253071 4 0.0469 0.996 0.012 0.000 0.000 0.988
#> GSM1253072 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253073 4 0.0000 0.987 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253032 1 0.1637 0.687 0.940 0.000 0.060 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.1637 0.687 0.940 0.000 0.060 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.3024 0.952 0.000 0.148 0.852 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.2149 0.950 0.000 0.088 0.912 0.000
#> GSM1253029 3 0.3024 0.952 0.000 0.148 0.852 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.2011 0.946 0.000 0.080 0.920 0.000
#> GSM1253033 1 0.2011 0.686 0.920 0.000 0.080 0.000
#> GSM1253035 3 0.2589 0.955 0.000 0.116 0.884 0.000
#> GSM1253036 3 0.3024 0.952 0.000 0.148 0.852 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.3024 0.952 0.000 0.148 0.852 0.000
#> GSM1253045 3 0.2002 0.920 0.020 0.044 0.936 0.000
#> GSM1253043 3 0.2313 0.914 0.032 0.044 0.924 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.1637 0.687 0.940 0.000 0.060 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.3024 0.952 0.000 0.148 0.852 0.000
#> GSM1253054 1 0.2760 0.682 0.872 0.000 0.128 0.000
#> GSM1253055 3 0.2345 0.953 0.000 0.100 0.900 0.000
#> GSM1253079 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253083 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253075 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253077 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253076 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253078 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253081 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253080 1 0.3907 0.920 0.768 0.000 0.000 0.232
#> GSM1253082 1 0.3907 0.920 0.768 0.000 0.000 0.232
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.2074 0.957 0.104 0.000 0.000 0.896 0.000
#> GSM1253057 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.2074 0.957 0.104 0.000 0.000 0.896 0.000
#> GSM1253059 4 0.0000 0.859 0.000 0.000 0.000 1.000 0.000
#> GSM1253060 4 0.2074 0.957 0.104 0.000 0.000 0.896 0.000
#> GSM1253061 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.2074 0.957 0.104 0.000 0.000 0.896 0.000
#> GSM1253064 1 0.0703 0.978 0.976 0.000 0.000 0.024 0.000
#> GSM1253065 4 0.2424 0.925 0.132 0.000 0.000 0.868 0.000
#> GSM1253066 1 0.0609 0.982 0.980 0.000 0.000 0.020 0.000
#> GSM1253067 4 0.2074 0.957 0.104 0.000 0.000 0.896 0.000
#> GSM1253068 1 0.0404 0.987 0.988 0.000 0.000 0.012 0.000
#> GSM1253069 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253071 4 0.2074 0.957 0.104 0.000 0.000 0.896 0.000
#> GSM1253072 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.0000 0.859 0.000 0.000 0.000 1.000 0.000
#> GSM1253074 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.979 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.979 0.000 0.000 0.000 0.000 1.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.2074 0.949 0.000 0.104 0.896 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.1121 0.944 0.000 0.044 0.956 0.000 0.000
#> GSM1253029 3 0.2074 0.949 0.000 0.104 0.896 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253031 3 0.0963 0.939 0.000 0.036 0.964 0.000 0.000
#> GSM1253033 5 0.0963 0.964 0.000 0.000 0.036 0.000 0.964
#> GSM1253035 3 0.1608 0.951 0.000 0.072 0.928 0.000 0.000
#> GSM1253036 3 0.2074 0.949 0.000 0.104 0.896 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.2074 0.949 0.000 0.104 0.896 0.000 0.000
#> GSM1253045 3 0.0963 0.907 0.000 0.000 0.964 0.000 0.036
#> GSM1253043 3 0.1197 0.900 0.000 0.000 0.952 0.000 0.048
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.979 0.000 0.000 0.000 0.000 1.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 3 0.2074 0.949 0.000 0.104 0.896 0.000 0.000
#> GSM1253054 5 0.1544 0.940 0.000 0.000 0.068 0.000 0.932
#> GSM1253055 3 0.1341 0.949 0.000 0.056 0.944 0.000 0.000
#> GSM1253079 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0609 0.982 0.980 0.000 0.000 0.020 0.000
#> GSM1253080 1 0.0000 0.994 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0703 0.978 0.976 0.000 0.000 0.024 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.1663 0.945 0.088 0.000 0.000 0.912 0.000 0.000
#> GSM1253057 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253058 6 0.5157 0.194 0.088 0.000 0.000 0.404 0.000 0.508
#> GSM1253059 6 0.2631 0.494 0.000 0.000 0.000 0.180 0.000 0.820
#> GSM1253060 4 0.1663 0.945 0.088 0.000 0.000 0.912 0.000 0.000
#> GSM1253061 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.1663 0.945 0.088 0.000 0.000 0.912 0.000 0.000
#> GSM1253064 1 0.0937 0.961 0.960 0.000 0.000 0.040 0.000 0.000
#> GSM1253065 4 0.2003 0.888 0.116 0.000 0.000 0.884 0.000 0.000
#> GSM1253066 1 0.0865 0.965 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM1253067 4 0.1663 0.945 0.088 0.000 0.000 0.912 0.000 0.000
#> GSM1253068 1 0.0547 0.976 0.980 0.000 0.000 0.020 0.000 0.000
#> GSM1253069 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253071 4 0.1663 0.945 0.088 0.000 0.000 0.912 0.000 0.000
#> GSM1253072 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.0547 0.712 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM1253074 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.943 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0146 0.943 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.1092 0.961 0.000 0.020 0.960 0.000 0.000 0.020
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.0547 0.956 0.000 0.000 0.980 0.000 0.000 0.020
#> GSM1253029 3 0.1092 0.961 0.000 0.020 0.960 0.000 0.000 0.020
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253031 3 0.0713 0.953 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM1253033 5 0.1556 0.905 0.000 0.000 0.000 0.000 0.920 0.080
#> GSM1253035 3 0.0260 0.961 0.000 0.008 0.992 0.000 0.000 0.000
#> GSM1253036 3 0.1092 0.961 0.000 0.020 0.960 0.000 0.000 0.020
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.1092 0.961 0.000 0.020 0.960 0.000 0.000 0.020
#> GSM1253045 3 0.1572 0.932 0.000 0.000 0.936 0.000 0.036 0.028
#> GSM1253043 3 0.1780 0.923 0.000 0.000 0.924 0.000 0.048 0.028
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.1141 0.934 0.000 0.000 0.000 0.000 0.948 0.052
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.1092 0.961 0.000 0.020 0.960 0.000 0.000 0.020
#> GSM1253054 5 0.2474 0.888 0.000 0.000 0.040 0.000 0.880 0.080
#> GSM1253055 3 0.0260 0.959 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM1253079 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0865 0.965 0.964 0.000 0.000 0.036 0.000 0.000
#> GSM1253080 1 0.0000 0.989 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0937 0.961 0.960 0.000 0.000 0.040 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> SD:hclust 56 0.018077 1.69e-08 0.955 2
#> SD:hclust 56 0.000786 1.93e-09 0.944 3
#> SD:hclust 56 0.002526 2.21e-10 0.885 4
#> SD:hclust 56 0.000334 2.92e-12 0.862 5
#> SD:hclust 54 0.000524 2.07e-11 0.813 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.993 0.997 0.4944 0.507 0.507
#> 3 3 0.702 0.695 0.692 0.2759 0.897 0.813
#> 4 4 0.763 0.905 0.877 0.1351 0.725 0.463
#> 5 5 0.723 0.937 0.902 0.0708 0.964 0.860
#> 6 6 0.870 0.875 0.865 0.0422 1.000 1.000
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
#> GSM1253056 1 0.00 0.994 1.00 0.00
#> GSM1253057 1 0.00 0.994 1.00 0.00
#> GSM1253058 1 0.00 0.994 1.00 0.00
#> GSM1253059 1 0.00 0.994 1.00 0.00
#> GSM1253060 1 0.00 0.994 1.00 0.00
#> GSM1253061 1 0.00 0.994 1.00 0.00
#> GSM1253062 1 0.00 0.994 1.00 0.00
#> GSM1253063 1 0.00 0.994 1.00 0.00
#> GSM1253064 1 0.00 0.994 1.00 0.00
#> GSM1253065 1 0.00 0.994 1.00 0.00
#> GSM1253066 1 0.00 0.994 1.00 0.00
#> GSM1253067 1 0.00 0.994 1.00 0.00
#> GSM1253068 1 0.00 0.994 1.00 0.00
#> GSM1253069 1 0.00 0.994 1.00 0.00
#> GSM1253070 1 0.00 0.994 1.00 0.00
#> GSM1253071 1 0.00 0.994 1.00 0.00
#> GSM1253072 1 0.00 0.994 1.00 0.00
#> GSM1253073 1 0.00 0.994 1.00 0.00
#> GSM1253074 1 0.00 0.994 1.00 0.00
#> GSM1253032 1 0.00 0.994 1.00 0.00
#> GSM1253034 2 0.00 1.000 0.00 1.00
#> GSM1253039 2 0.00 1.000 0.00 1.00
#> GSM1253040 2 0.00 1.000 0.00 1.00
#> GSM1253041 2 0.00 1.000 0.00 1.00
#> GSM1253046 1 0.00 0.994 1.00 0.00
#> GSM1253048 2 0.00 1.000 0.00 1.00
#> GSM1253049 2 0.00 1.000 0.00 1.00
#> GSM1253052 2 0.00 1.000 0.00 1.00
#> GSM1253037 2 0.00 1.000 0.00 1.00
#> GSM1253028 2 0.00 1.000 0.00 1.00
#> GSM1253029 2 0.00 1.000 0.00 1.00
#> GSM1253030 2 0.00 1.000 0.00 1.00
#> GSM1253031 2 0.00 1.000 0.00 1.00
#> GSM1253033 1 0.00 0.994 1.00 0.00
#> GSM1253035 2 0.00 1.000 0.00 1.00
#> GSM1253036 2 0.00 1.000 0.00 1.00
#> GSM1253038 2 0.00 1.000 0.00 1.00
#> GSM1253042 2 0.00 1.000 0.00 1.00
#> GSM1253045 2 0.00 1.000 0.00 1.00
#> GSM1253043 2 0.00 1.000 0.00 1.00
#> GSM1253044 2 0.00 1.000 0.00 1.00
#> GSM1253047 1 0.00 0.994 1.00 0.00
#> GSM1253050 2 0.00 1.000 0.00 1.00
#> GSM1253051 2 0.00 1.000 0.00 1.00
#> GSM1253053 2 0.00 1.000 0.00 1.00
#> GSM1253054 1 0.68 0.780 0.82 0.18
#> GSM1253055 2 0.00 1.000 0.00 1.00
#> GSM1253079 1 0.00 0.994 1.00 0.00
#> GSM1253083 1 0.00 0.994 1.00 0.00
#> GSM1253075 1 0.00 0.994 1.00 0.00
#> GSM1253077 1 0.00 0.994 1.00 0.00
#> GSM1253076 1 0.00 0.994 1.00 0.00
#> GSM1253078 1 0.00 0.994 1.00 0.00
#> GSM1253081 1 0.00 0.994 1.00 0.00
#> GSM1253080 1 0.00 0.994 1.00 0.00
#> GSM1253082 1 0.00 0.994 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253057 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253058 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253059 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253060 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253061 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253063 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253064 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253065 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253066 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253067 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253068 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253070 1 0.0592 0.8302 0.988 0.000 0.012
#> GSM1253071 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253072 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253073 1 0.6204 0.6640 0.576 0.000 0.424
#> GSM1253074 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253032 2 0.9633 -0.0170 0.368 0.424 0.208
#> GSM1253034 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253039 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253040 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253041 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253046 1 0.9606 0.1188 0.440 0.352 0.208
#> GSM1253048 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253049 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253052 2 0.1860 0.7342 0.000 0.948 0.052
#> GSM1253037 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253028 2 0.1643 0.7041 0.000 0.956 0.044
#> GSM1253029 2 0.4121 0.7473 0.000 0.832 0.168
#> GSM1253030 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253031 2 0.1643 0.7041 0.000 0.956 0.044
#> GSM1253033 1 0.9606 0.1188 0.440 0.352 0.208
#> GSM1253035 2 0.0000 0.7196 0.000 1.000 0.000
#> GSM1253036 2 0.1860 0.7342 0.000 0.948 0.052
#> GSM1253038 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253042 2 0.3116 0.7419 0.000 0.892 0.108
#> GSM1253045 2 0.3879 0.6455 0.000 0.848 0.152
#> GSM1253043 2 0.3879 0.6455 0.000 0.848 0.152
#> GSM1253044 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253047 2 0.9633 -0.0170 0.368 0.424 0.208
#> GSM1253050 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253051 2 0.6204 0.7559 0.000 0.576 0.424
#> GSM1253053 2 0.1860 0.7342 0.000 0.948 0.052
#> GSM1253054 2 0.9614 0.0112 0.356 0.436 0.208
#> GSM1253055 2 0.1643 0.7041 0.000 0.956 0.044
#> GSM1253079 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.8349 1.000 0.000 0.000
#> GSM1253082 1 0.0000 0.8349 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.4277 0.994 0.280 0.000 0.000 0.720
#> GSM1253057 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253058 4 0.5010 0.982 0.276 0.000 0.024 0.700
#> GSM1253059 4 0.5010 0.982 0.276 0.000 0.024 0.700
#> GSM1253060 4 0.4277 0.994 0.280 0.000 0.000 0.720
#> GSM1253061 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253063 4 0.4277 0.994 0.280 0.000 0.000 0.720
#> GSM1253064 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.4277 0.994 0.280 0.000 0.000 0.720
#> GSM1253066 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.4250 0.993 0.276 0.000 0.000 0.724
#> GSM1253068 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253070 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253071 4 0.4277 0.994 0.280 0.000 0.000 0.720
#> GSM1253072 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.4250 0.993 0.276 0.000 0.000 0.724
#> GSM1253074 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253032 3 0.4898 0.662 0.024 0.000 0.716 0.260
#> GSM1253034 2 0.0336 0.992 0.000 0.992 0.000 0.008
#> GSM1253039 2 0.0592 0.991 0.000 0.984 0.000 0.016
#> GSM1253040 2 0.0469 0.991 0.000 0.988 0.000 0.012
#> GSM1253041 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.6194 0.611 0.096 0.000 0.644 0.260
#> GSM1253048 2 0.0188 0.992 0.000 0.996 0.000 0.004
#> GSM1253049 2 0.0469 0.991 0.000 0.988 0.000 0.012
#> GSM1253052 3 0.4356 0.683 0.000 0.292 0.708 0.000
#> GSM1253037 2 0.0469 0.991 0.000 0.988 0.000 0.012
#> GSM1253028 3 0.3400 0.748 0.000 0.180 0.820 0.000
#> GSM1253029 3 0.4761 0.571 0.000 0.372 0.628 0.000
#> GSM1253030 2 0.0336 0.992 0.000 0.992 0.000 0.008
#> GSM1253031 3 0.3400 0.748 0.000 0.180 0.820 0.000
#> GSM1253033 3 0.6164 0.612 0.092 0.000 0.644 0.264
#> GSM1253035 3 0.3726 0.735 0.000 0.212 0.788 0.000
#> GSM1253036 3 0.4356 0.683 0.000 0.292 0.708 0.000
#> GSM1253038 2 0.0469 0.991 0.000 0.988 0.000 0.012
#> GSM1253042 3 0.4564 0.642 0.000 0.328 0.672 0.000
#> GSM1253045 3 0.0817 0.737 0.000 0.024 0.976 0.000
#> GSM1253043 3 0.0817 0.737 0.000 0.024 0.976 0.000
#> GSM1253044 2 0.0188 0.992 0.000 0.996 0.000 0.004
#> GSM1253047 3 0.5416 0.648 0.048 0.000 0.692 0.260
#> GSM1253050 2 0.0000 0.993 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0336 0.992 0.000 0.992 0.000 0.008
#> GSM1253053 3 0.4356 0.683 0.000 0.292 0.708 0.000
#> GSM1253054 3 0.4868 0.665 0.024 0.000 0.720 0.256
#> GSM1253055 3 0.3400 0.748 0.000 0.180 0.820 0.000
#> GSM1253079 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253083 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253075 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253077 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253076 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253078 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253081 1 0.0000 0.996 1.000 0.000 0.000 0.000
#> GSM1253080 1 0.0188 0.997 0.996 0.000 0.004 0.000
#> GSM1253082 1 0.0188 0.991 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.2424 0.975 0.132 0.000 0.000 0.868 0.000
#> GSM1253057 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.4624 0.929 0.132 0.000 0.016 0.768 0.084
#> GSM1253059 4 0.4718 0.927 0.132 0.000 0.020 0.764 0.084
#> GSM1253060 4 0.2424 0.975 0.132 0.000 0.000 0.868 0.000
#> GSM1253061 1 0.2848 0.906 0.868 0.000 0.028 0.000 0.104
#> GSM1253062 1 0.0162 0.931 0.996 0.000 0.000 0.000 0.004
#> GSM1253063 4 0.2424 0.975 0.132 0.000 0.000 0.868 0.000
#> GSM1253064 1 0.3497 0.895 0.836 0.000 0.048 0.004 0.112
#> GSM1253065 4 0.3297 0.958 0.132 0.000 0.020 0.840 0.008
#> GSM1253066 1 0.3497 0.895 0.836 0.000 0.048 0.004 0.112
#> GSM1253067 4 0.2583 0.975 0.132 0.000 0.000 0.864 0.004
#> GSM1253068 1 0.3497 0.895 0.836 0.000 0.048 0.004 0.112
#> GSM1253069 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.2848 0.906 0.868 0.000 0.028 0.000 0.104
#> GSM1253071 4 0.2424 0.975 0.132 0.000 0.000 0.868 0.000
#> GSM1253072 1 0.3497 0.895 0.836 0.000 0.048 0.004 0.112
#> GSM1253073 4 0.2583 0.975 0.132 0.000 0.000 0.864 0.004
#> GSM1253074 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.3210 0.986 0.000 0.000 0.212 0.000 0.788
#> GSM1253034 2 0.1282 0.967 0.000 0.952 0.000 0.044 0.004
#> GSM1253039 2 0.1981 0.963 0.000 0.920 0.000 0.064 0.016
#> GSM1253040 2 0.1364 0.971 0.000 0.952 0.000 0.036 0.012
#> GSM1253041 2 0.0000 0.974 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.3421 0.985 0.008 0.000 0.204 0.000 0.788
#> GSM1253048 2 0.0162 0.974 0.000 0.996 0.000 0.004 0.000
#> GSM1253049 2 0.1012 0.971 0.000 0.968 0.000 0.020 0.012
#> GSM1253052 3 0.2825 0.911 0.000 0.124 0.860 0.016 0.000
#> GSM1253037 2 0.1012 0.971 0.000 0.968 0.000 0.020 0.012
#> GSM1253028 3 0.2325 0.904 0.000 0.068 0.904 0.028 0.000
#> GSM1253029 3 0.2920 0.903 0.000 0.132 0.852 0.016 0.000
#> GSM1253030 2 0.1357 0.966 0.000 0.948 0.000 0.048 0.004
#> GSM1253031 3 0.2325 0.904 0.000 0.068 0.904 0.028 0.000
#> GSM1253033 5 0.3421 0.985 0.008 0.000 0.204 0.000 0.788
#> GSM1253035 3 0.2020 0.917 0.000 0.100 0.900 0.000 0.000
#> GSM1253036 3 0.2921 0.911 0.000 0.124 0.856 0.020 0.000
#> GSM1253038 2 0.1281 0.971 0.000 0.956 0.000 0.032 0.012
#> GSM1253042 3 0.2825 0.911 0.000 0.124 0.860 0.016 0.000
#> GSM1253045 3 0.2719 0.805 0.000 0.000 0.884 0.048 0.068
#> GSM1253043 3 0.2569 0.811 0.000 0.000 0.892 0.040 0.068
#> GSM1253044 2 0.0162 0.974 0.000 0.996 0.000 0.004 0.000
#> GSM1253047 5 0.3487 0.986 0.000 0.000 0.212 0.008 0.780
#> GSM1253050 2 0.0162 0.975 0.000 0.996 0.000 0.004 0.000
#> GSM1253051 2 0.1282 0.967 0.000 0.952 0.000 0.044 0.004
#> GSM1253053 3 0.2825 0.911 0.000 0.124 0.860 0.016 0.000
#> GSM1253054 5 0.3877 0.978 0.000 0.000 0.212 0.024 0.764
#> GSM1253055 3 0.1704 0.907 0.000 0.068 0.928 0.004 0.000
#> GSM1253079 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.3497 0.895 0.836 0.000 0.048 0.004 0.112
#> GSM1253080 1 0.0000 0.931 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.3497 0.895 0.836 0.000 0.048 0.004 0.112
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.1714 0.944 0.092 0.000 0.000 0.908 0.000 NA
#> GSM1253057 1 0.3988 0.828 0.660 0.000 0.004 0.000 0.012 NA
#> GSM1253058 4 0.5371 0.839 0.092 0.000 0.016 0.692 0.040 NA
#> GSM1253059 4 0.5578 0.825 0.092 0.000 0.020 0.672 0.040 NA
#> GSM1253060 4 0.1714 0.944 0.092 0.000 0.000 0.908 0.000 NA
#> GSM1253061 1 0.1411 0.781 0.936 0.000 0.000 0.000 0.004 NA
#> GSM1253062 1 0.3724 0.837 0.716 0.000 0.004 0.000 0.012 NA
#> GSM1253063 4 0.1714 0.944 0.092 0.000 0.000 0.908 0.000 NA
#> GSM1253064 1 0.1313 0.763 0.952 0.000 0.004 0.016 0.000 NA
#> GSM1253065 4 0.2701 0.918 0.104 0.000 0.004 0.864 0.000 NA
#> GSM1253066 1 0.1218 0.765 0.956 0.000 0.004 0.012 0.000 NA
#> GSM1253067 4 0.2306 0.940 0.092 0.000 0.004 0.888 0.000 NA
#> GSM1253068 1 0.1218 0.765 0.956 0.000 0.004 0.012 0.000 NA
#> GSM1253069 1 0.3699 0.828 0.660 0.000 0.000 0.000 0.004 NA
#> GSM1253070 1 0.1349 0.781 0.940 0.000 0.000 0.000 0.004 NA
#> GSM1253071 4 0.1714 0.944 0.092 0.000 0.000 0.908 0.000 NA
#> GSM1253072 1 0.1218 0.765 0.956 0.000 0.004 0.012 0.000 NA
#> GSM1253073 4 0.2518 0.939 0.092 0.000 0.016 0.880 0.000 NA
#> GSM1253074 1 0.3699 0.828 0.660 0.000 0.000 0.000 0.004 NA
#> GSM1253032 5 0.1204 0.989 0.000 0.000 0.056 0.000 0.944 NA
#> GSM1253034 2 0.3027 0.879 0.000 0.824 0.000 0.028 0.000 NA
#> GSM1253039 2 0.3672 0.878 0.000 0.776 0.000 0.056 0.000 NA
#> GSM1253040 2 0.2237 0.909 0.000 0.896 0.000 0.036 0.000 NA
#> GSM1253041 2 0.0146 0.920 0.000 0.996 0.000 0.004 0.000 NA
#> GSM1253046 5 0.1204 0.989 0.000 0.000 0.056 0.000 0.944 NA
#> GSM1253048 2 0.0806 0.918 0.000 0.972 0.000 0.008 0.000 NA
#> GSM1253049 2 0.1333 0.916 0.000 0.944 0.000 0.008 0.000 NA
#> GSM1253052 3 0.3927 0.884 0.000 0.072 0.756 0.000 0.000 NA
#> GSM1253037 2 0.1333 0.916 0.000 0.944 0.000 0.008 0.000 NA
#> GSM1253028 3 0.1929 0.886 0.000 0.048 0.924 0.004 0.008 NA
#> GSM1253029 3 0.3927 0.884 0.000 0.072 0.756 0.000 0.000 NA
#> GSM1253030 2 0.3422 0.871 0.000 0.792 0.000 0.040 0.000 NA
#> GSM1253031 3 0.2143 0.886 0.000 0.048 0.916 0.012 0.008 NA
#> GSM1253033 5 0.2058 0.975 0.000 0.000 0.056 0.000 0.908 NA
#> GSM1253035 3 0.2733 0.901 0.000 0.056 0.864 0.000 0.000 NA
#> GSM1253036 3 0.1895 0.897 0.000 0.072 0.912 0.000 0.000 NA
#> GSM1253038 2 0.1921 0.913 0.000 0.916 0.000 0.032 0.000 NA
#> GSM1253042 3 0.3927 0.884 0.000 0.072 0.756 0.000 0.000 NA
#> GSM1253045 3 0.2434 0.839 0.000 0.000 0.896 0.016 0.056 NA
#> GSM1253043 3 0.2366 0.841 0.000 0.000 0.900 0.020 0.056 NA
#> GSM1253044 2 0.0891 0.917 0.000 0.968 0.000 0.008 0.000 NA
#> GSM1253047 5 0.1349 0.989 0.000 0.000 0.056 0.000 0.940 NA
#> GSM1253050 2 0.0717 0.921 0.000 0.976 0.000 0.008 0.000 NA
#> GSM1253051 2 0.3027 0.879 0.000 0.824 0.000 0.028 0.000 NA
#> GSM1253053 3 0.3927 0.884 0.000 0.072 0.756 0.000 0.000 NA
#> GSM1253054 5 0.1914 0.981 0.000 0.000 0.056 0.008 0.920 NA
#> GSM1253055 3 0.2697 0.901 0.000 0.048 0.876 0.000 0.008 NA
#> GSM1253079 1 0.3988 0.828 0.660 0.000 0.004 0.000 0.012 NA
#> GSM1253083 1 0.3788 0.836 0.704 0.000 0.012 0.000 0.004 NA
#> GSM1253075 1 0.3948 0.836 0.704 0.000 0.012 0.000 0.012 NA
#> GSM1253077 1 0.3670 0.836 0.704 0.000 0.012 0.000 0.000 NA
#> GSM1253076 1 0.3670 0.836 0.704 0.000 0.012 0.000 0.000 NA
#> GSM1253078 1 0.3670 0.836 0.704 0.000 0.012 0.000 0.000 NA
#> GSM1253081 1 0.1485 0.757 0.944 0.000 0.004 0.024 0.000 NA
#> GSM1253080 1 0.3699 0.828 0.660 0.000 0.000 0.000 0.004 NA
#> GSM1253082 1 0.1485 0.757 0.944 0.000 0.004 0.024 0.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 infection(p) disease.state(p) individual(p) k
#> SD:kmeans 56 0.018077 1.69e-08 0.955 2
#> SD:kmeans 51 0.008612 4.89e-11 0.985 3
#> SD:kmeans 56 0.000111 4.17e-13 0.934 4
#> SD:kmeans 56 0.000334 2.92e-12 0.862 5
#> SD:kmeans 56 0.000334 2.92e-12 0.862 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.979 0.992 0.4967 0.501 0.501
#> 3 3 1.000 0.998 0.998 0.2175 0.879 0.761
#> 4 4 1.000 0.998 0.998 0.1828 0.889 0.719
#> 5 5 0.962 0.936 0.961 0.0857 0.912 0.702
#> 6 6 0.878 0.874 0.899 0.0403 0.982 0.917
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 3 4
There is also optional best \(k\) = 2 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
#> GSM1253056 1 0.000 1.000 1.000 0.000
#> GSM1253057 1 0.000 1.000 1.000 0.000
#> GSM1253058 1 0.000 1.000 1.000 0.000
#> GSM1253059 1 0.000 1.000 1.000 0.000
#> GSM1253060 1 0.000 1.000 1.000 0.000
#> GSM1253061 1 0.000 1.000 1.000 0.000
#> GSM1253062 1 0.000 1.000 1.000 0.000
#> GSM1253063 1 0.000 1.000 1.000 0.000
#> GSM1253064 1 0.000 1.000 1.000 0.000
#> GSM1253065 1 0.000 1.000 1.000 0.000
#> GSM1253066 1 0.000 1.000 1.000 0.000
#> GSM1253067 1 0.000 1.000 1.000 0.000
#> GSM1253068 1 0.000 1.000 1.000 0.000
#> GSM1253069 1 0.000 1.000 1.000 0.000
#> GSM1253070 1 0.000 1.000 1.000 0.000
#> GSM1253071 1 0.000 1.000 1.000 0.000
#> GSM1253072 1 0.000 1.000 1.000 0.000
#> GSM1253073 1 0.000 1.000 1.000 0.000
#> GSM1253074 1 0.000 1.000 1.000 0.000
#> GSM1253032 1 0.000 1.000 1.000 0.000
#> GSM1253034 2 0.000 0.981 0.000 1.000
#> GSM1253039 2 0.000 0.981 0.000 1.000
#> GSM1253040 2 0.000 0.981 0.000 1.000
#> GSM1253041 2 0.000 0.981 0.000 1.000
#> GSM1253046 1 0.000 1.000 1.000 0.000
#> GSM1253048 2 0.000 0.981 0.000 1.000
#> GSM1253049 2 0.000 0.981 0.000 1.000
#> GSM1253052 2 0.000 0.981 0.000 1.000
#> GSM1253037 2 0.000 0.981 0.000 1.000
#> GSM1253028 2 0.000 0.981 0.000 1.000
#> GSM1253029 2 0.000 0.981 0.000 1.000
#> GSM1253030 2 0.000 0.981 0.000 1.000
#> GSM1253031 2 0.000 0.981 0.000 1.000
#> GSM1253033 1 0.000 1.000 1.000 0.000
#> GSM1253035 2 0.000 0.981 0.000 1.000
#> GSM1253036 2 0.000 0.981 0.000 1.000
#> GSM1253038 2 0.000 0.981 0.000 1.000
#> GSM1253042 2 0.000 0.981 0.000 1.000
#> GSM1253045 2 0.000 0.981 0.000 1.000
#> GSM1253043 2 0.000 0.981 0.000 1.000
#> GSM1253044 2 0.000 0.981 0.000 1.000
#> GSM1253047 1 0.000 1.000 1.000 0.000
#> GSM1253050 2 0.000 0.981 0.000 1.000
#> GSM1253051 2 0.000 0.981 0.000 1.000
#> GSM1253053 2 0.000 0.981 0.000 1.000
#> GSM1253054 2 0.985 0.252 0.428 0.572
#> GSM1253055 2 0.000 0.981 0.000 1.000
#> GSM1253079 1 0.000 1.000 1.000 0.000
#> GSM1253083 1 0.000 1.000 1.000 0.000
#> GSM1253075 1 0.000 1.000 1.000 0.000
#> GSM1253077 1 0.000 1.000 1.000 0.000
#> GSM1253076 1 0.000 1.000 1.000 0.000
#> GSM1253078 1 0.000 1.000 1.000 0.000
#> GSM1253081 1 0.000 1.000 1.000 0.000
#> GSM1253080 1 0.000 1.000 1.000 0.000
#> GSM1253082 1 0.000 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253057 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253058 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253059 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253060 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253061 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253063 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253064 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253065 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253066 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253067 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253068 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253070 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253071 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253072 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253073 1 0.0237 0.997 0.996 0.000 0.004
#> GSM1253074 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253032 3 0.0237 0.993 0.004 0.000 0.996
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253046 3 0.0237 0.993 0.004 0.000 0.996
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253033 3 0.0237 0.993 0.004 0.000 0.996
#> GSM1253035 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253045 3 0.0237 0.990 0.000 0.004 0.996
#> GSM1253043 3 0.1411 0.963 0.000 0.036 0.964
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253047 3 0.0237 0.993 0.004 0.000 0.996
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253054 3 0.0237 0.993 0.004 0.000 0.996
#> GSM1253055 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.999 1.000 0.000 0.000
#> GSM1253082 1 0.0237 0.997 0.996 0.000 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253057 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253059 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253060 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253061 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253064 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253066 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253068 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253072 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253074 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.0000 0.991 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 0.991 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253052 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253037 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253028 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM1253029 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253030 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253031 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM1253033 3 0.0000 0.991 0.000 0.000 1.000 0.000
#> GSM1253035 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253036 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253038 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253042 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.0188 0.989 0.000 0.000 0.996 0.004
#> GSM1253043 3 0.1305 0.950 0.000 0.036 0.960 0.004
#> GSM1253044 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 0.991 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253053 2 0.0000 0.999 0.000 1.000 0.000 0.000
#> GSM1253054 3 0.0000 0.991 0.000 0.000 1.000 0.000
#> GSM1253055 2 0.0188 0.997 0.000 0.996 0.000 0.004
#> GSM1253079 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.0000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253057 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253059 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253060 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253061 1 0.0510 0.989 0.984 0.000 0.016 0.000 0.000
#> GSM1253062 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253064 1 0.0703 0.986 0.976 0.000 0.024 0.000 0.000
#> GSM1253065 4 0.0290 0.992 0.000 0.000 0.008 0.992 0.000
#> GSM1253066 1 0.0703 0.986 0.976 0.000 0.024 0.000 0.000
#> GSM1253067 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253068 1 0.0703 0.986 0.976 0.000 0.024 0.000 0.000
#> GSM1253069 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0510 0.989 0.984 0.000 0.016 0.000 0.000
#> GSM1253071 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253072 1 0.0703 0.986 0.976 0.000 0.024 0.000 0.000
#> GSM1253073 4 0.0000 0.999 0.000 0.000 0.000 1.000 0.000
#> GSM1253074 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.3932 0.683 0.000 0.328 0.672 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.0703 0.777 0.000 0.024 0.976 0.000 0.000
#> GSM1253029 3 0.3932 0.683 0.000 0.328 0.672 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253031 3 0.0703 0.777 0.000 0.024 0.976 0.000 0.000
#> GSM1253033 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253035 3 0.1965 0.791 0.000 0.096 0.904 0.000 0.000
#> GSM1253036 3 0.1965 0.791 0.000 0.096 0.904 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.3966 0.671 0.000 0.336 0.664 0.000 0.000
#> GSM1253045 3 0.4074 0.242 0.000 0.000 0.636 0.000 0.364
#> GSM1253043 3 0.0771 0.758 0.000 0.004 0.976 0.000 0.020
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 3 0.3932 0.683 0.000 0.328 0.672 0.000 0.000
#> GSM1253054 5 0.0162 0.996 0.000 0.000 0.004 0.000 0.996
#> GSM1253055 3 0.0703 0.777 0.000 0.024 0.976 0.000 0.000
#> GSM1253079 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0703 0.986 0.976 0.000 0.024 0.000 0.000
#> GSM1253080 1 0.0000 0.991 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0865 0.984 0.972 0.000 0.024 0.004 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253057 1 0.0713 0.861 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM1253058 4 0.0146 0.993 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM1253059 4 0.0146 0.993 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM1253060 4 0.0000 0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253061 1 0.3221 0.820 0.736 0.000 0.000 0.000 0.000 0.264
#> GSM1253062 1 0.0458 0.864 0.984 0.000 0.000 0.000 0.000 0.016
#> GSM1253063 4 0.0000 0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253064 1 0.3464 0.796 0.688 0.000 0.000 0.000 0.000 0.312
#> GSM1253065 4 0.0937 0.956 0.000 0.000 0.000 0.960 0.000 0.040
#> GSM1253066 1 0.3464 0.796 0.688 0.000 0.000 0.000 0.000 0.312
#> GSM1253067 4 0.0146 0.993 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM1253068 1 0.3464 0.796 0.688 0.000 0.000 0.000 0.000 0.312
#> GSM1253069 1 0.0713 0.861 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM1253070 1 0.3309 0.815 0.720 0.000 0.000 0.000 0.000 0.280
#> GSM1253071 4 0.0000 0.993 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253072 1 0.3464 0.796 0.688 0.000 0.000 0.000 0.000 0.312
#> GSM1253073 4 0.0146 0.993 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM1253074 1 0.0713 0.861 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM1253032 5 0.0000 0.984 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0146 0.983 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.2730 0.751 0.000 0.192 0.808 0.000 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 6 0.3833 0.895 0.000 0.000 0.444 0.000 0.000 0.556
#> GSM1253029 3 0.2730 0.751 0.000 0.192 0.808 0.000 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253031 6 0.3833 0.895 0.000 0.000 0.444 0.000 0.000 0.556
#> GSM1253033 5 0.0260 0.982 0.000 0.000 0.000 0.000 0.992 0.008
#> GSM1253035 3 0.2001 0.564 0.000 0.040 0.912 0.000 0.000 0.048
#> GSM1253036 3 0.5184 -0.264 0.000 0.120 0.584 0.000 0.000 0.296
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.2969 0.716 0.000 0.224 0.776 0.000 0.000 0.000
#> GSM1253045 6 0.4747 0.824 0.000 0.000 0.324 0.000 0.068 0.608
#> GSM1253043 6 0.3672 0.883 0.000 0.000 0.368 0.000 0.000 0.632
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.0458 0.980 0.000 0.000 0.000 0.000 0.984 0.016
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.2730 0.751 0.000 0.192 0.808 0.000 0.000 0.000
#> GSM1253054 5 0.1204 0.957 0.000 0.000 0.000 0.000 0.944 0.056
#> GSM1253055 3 0.0790 0.497 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM1253079 1 0.0713 0.861 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM1253083 1 0.0000 0.866 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.866 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.866 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.866 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.866 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.3601 0.793 0.684 0.000 0.000 0.004 0.000 0.312
#> GSM1253080 1 0.0713 0.861 0.972 0.000 0.000 0.000 0.000 0.028
#> GSM1253082 1 0.3601 0.793 0.684 0.000 0.000 0.004 0.000 0.312
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 infection(p) disease.state(p) individual(p) k
#> SD:skmeans 55 0.015882 6.02e-09 0.956 2
#> SD:skmeans 56 0.004693 2.40e-10 0.902 3
#> SD:skmeans 56 0.000111 2.41e-11 0.905 4
#> SD:skmeans 55 0.000418 7.90e-12 0.835 5
#> SD:skmeans 54 0.001308 2.49e-10 0.774 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.966 0.986 0.4837 0.523 0.523
#> 3 3 0.713 0.932 0.940 0.2690 0.826 0.681
#> 4 4 0.817 0.891 0.934 0.1985 0.864 0.655
#> 5 5 1.000 0.992 0.996 0.0623 0.929 0.742
#> 6 6 0.971 0.953 0.967 0.0668 0.945 0.751
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
#> GSM1253056 1 0.000 0.977 1.00 0.00
#> GSM1253057 1 0.000 0.977 1.00 0.00
#> GSM1253058 1 0.000 0.977 1.00 0.00
#> GSM1253059 1 0.000 0.977 1.00 0.00
#> GSM1253060 1 0.000 0.977 1.00 0.00
#> GSM1253061 1 0.000 0.977 1.00 0.00
#> GSM1253062 1 0.000 0.977 1.00 0.00
#> GSM1253063 1 0.000 0.977 1.00 0.00
#> GSM1253064 1 0.000 0.977 1.00 0.00
#> GSM1253065 1 0.000 0.977 1.00 0.00
#> GSM1253066 1 0.000 0.977 1.00 0.00
#> GSM1253067 1 0.000 0.977 1.00 0.00
#> GSM1253068 1 0.000 0.977 1.00 0.00
#> GSM1253069 1 0.000 0.977 1.00 0.00
#> GSM1253070 1 0.000 0.977 1.00 0.00
#> GSM1253071 1 0.000 0.977 1.00 0.00
#> GSM1253072 1 0.000 0.977 1.00 0.00
#> GSM1253073 1 0.000 0.977 1.00 0.00
#> GSM1253074 1 0.000 0.977 1.00 0.00
#> GSM1253032 1 0.000 0.977 1.00 0.00
#> GSM1253034 2 0.000 1.000 0.00 1.00
#> GSM1253039 2 0.000 1.000 0.00 1.00
#> GSM1253040 2 0.000 1.000 0.00 1.00
#> GSM1253041 2 0.000 1.000 0.00 1.00
#> GSM1253046 1 0.000 0.977 1.00 0.00
#> GSM1253048 2 0.000 1.000 0.00 1.00
#> GSM1253049 2 0.000 1.000 0.00 1.00
#> GSM1253052 2 0.000 1.000 0.00 1.00
#> GSM1253037 2 0.000 1.000 0.00 1.00
#> GSM1253028 2 0.000 1.000 0.00 1.00
#> GSM1253029 2 0.000 1.000 0.00 1.00
#> GSM1253030 2 0.000 1.000 0.00 1.00
#> GSM1253031 2 0.000 1.000 0.00 1.00
#> GSM1253033 1 0.000 0.977 1.00 0.00
#> GSM1253035 2 0.000 1.000 0.00 1.00
#> GSM1253036 2 0.000 1.000 0.00 1.00
#> GSM1253038 2 0.000 1.000 0.00 1.00
#> GSM1253042 2 0.000 1.000 0.00 1.00
#> GSM1253045 1 0.971 0.355 0.60 0.40
#> GSM1253043 1 0.925 0.498 0.66 0.34
#> GSM1253044 2 0.000 1.000 0.00 1.00
#> GSM1253047 1 0.000 0.977 1.00 0.00
#> GSM1253050 2 0.000 1.000 0.00 1.00
#> GSM1253051 2 0.000 1.000 0.00 1.00
#> GSM1253053 2 0.000 1.000 0.00 1.00
#> GSM1253054 1 0.141 0.959 0.98 0.02
#> GSM1253055 2 0.000 1.000 0.00 1.00
#> GSM1253079 1 0.000 0.977 1.00 0.00
#> GSM1253083 1 0.000 0.977 1.00 0.00
#> GSM1253075 1 0.000 0.977 1.00 0.00
#> GSM1253077 1 0.000 0.977 1.00 0.00
#> GSM1253076 1 0.000 0.977 1.00 0.00
#> GSM1253078 1 0.000 0.977 1.00 0.00
#> GSM1253081 1 0.000 0.977 1.00 0.00
#> GSM1253080 1 0.000 0.977 1.00 0.00
#> GSM1253082 1 0.000 0.977 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253057 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253058 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253059 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253060 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253061 1 0.1753 0.944 0.952 0.000 0.048
#> GSM1253062 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253063 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253064 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253065 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253066 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253067 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253068 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253070 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253071 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253072 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253073 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253074 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253032 3 0.0424 0.837 0.008 0.000 0.992
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253046 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253052 3 0.4555 0.874 0.000 0.200 0.800
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253028 3 0.2959 0.901 0.000 0.100 0.900
#> GSM1253029 3 0.4654 0.867 0.000 0.208 0.792
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253031 3 0.2959 0.901 0.000 0.100 0.900
#> GSM1253033 1 0.3116 0.936 0.892 0.000 0.108
#> GSM1253035 3 0.2959 0.901 0.000 0.100 0.900
#> GSM1253036 3 0.4555 0.874 0.000 0.200 0.800
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253042 3 0.4654 0.867 0.000 0.208 0.792
#> GSM1253045 3 0.2959 0.840 0.100 0.000 0.900
#> GSM1253043 3 0.2959 0.840 0.100 0.000 0.900
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253047 1 0.5216 0.623 0.740 0.000 0.260
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253053 3 0.4555 0.874 0.000 0.200 0.800
#> GSM1253054 3 0.0000 0.841 0.000 0.000 1.000
#> GSM1253055 3 0.2959 0.901 0.000 0.100 0.900
#> GSM1253079 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253081 1 0.2959 0.940 0.900 0.000 0.100
#> GSM1253080 1 0.0000 0.945 1.000 0.000 0.000
#> GSM1253082 1 0.2959 0.940 0.900 0.000 0.100
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253057 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253059 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253060 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253061 1 0.0469 0.909 0.988 0.000 0.000 0.012
#> GSM1253062 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253064 1 0.3569 0.689 0.804 0.000 0.000 0.196
#> GSM1253065 4 0.2530 0.939 0.112 0.000 0.000 0.888
#> GSM1253066 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253068 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253072 1 0.0707 0.903 0.980 0.000 0.000 0.020
#> GSM1253073 4 0.2408 0.946 0.104 0.000 0.000 0.896
#> GSM1253074 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.4406 0.637 0.000 0.000 0.700 0.300
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.2760 0.816 0.872 0.000 0.000 0.128
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.1940 0.921 0.000 0.076 0.924 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.0000 0.933 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.2011 0.919 0.000 0.080 0.920 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 0.933 0.000 0.000 1.000 0.000
#> GSM1253033 1 0.6790 0.462 0.576 0.000 0.128 0.296
#> GSM1253035 3 0.0000 0.933 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.1940 0.921 0.000 0.076 0.924 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.2011 0.919 0.000 0.080 0.920 0.000
#> GSM1253045 3 0.0000 0.933 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.0000 0.933 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.6010 0.590 0.676 0.000 0.220 0.104
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.1940 0.921 0.000 0.076 0.924 0.000
#> GSM1253054 3 0.2408 0.877 0.000 0.000 0.896 0.104
#> GSM1253055 3 0.0000 0.933 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.4697 0.334 0.644 0.000 0.000 0.356
#> GSM1253080 1 0.0000 0.918 1.000 0.000 0.000 0.000
#> GSM1253082 4 0.4999 0.152 0.492 0.000 0.000 0.508
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253057 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253058 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253059 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253060 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253061 1 0.0290 0.984 0.992 0.000 0.000 0.008 0
#> GSM1253062 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253063 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253064 1 0.0703 0.972 0.976 0.000 0.000 0.024 0
#> GSM1253065 4 0.0703 0.966 0.024 0.000 0.000 0.976 0
#> GSM1253066 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253067 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253068 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253069 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253070 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253071 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253072 1 0.0290 0.984 0.992 0.000 0.000 0.008 0
#> GSM1253073 4 0.0000 0.996 0.000 0.000 0.000 1.000 0
#> GSM1253074 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253032 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253046 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253052 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253028 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253029 3 0.0162 0.996 0.000 0.004 0.996 0.000 0
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253031 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253033 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253035 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253036 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253042 3 0.0162 0.996 0.000 0.004 0.996 0.000 0
#> GSM1253045 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253043 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253047 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0
#> GSM1253053 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253054 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253055 3 0.0000 0.999 0.000 0.000 1.000 0.000 0
#> GSM1253079 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253083 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253075 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253077 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253076 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253078 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253081 1 0.1792 0.914 0.916 0.000 0.000 0.084 0
#> GSM1253080 1 0.0000 0.989 1.000 0.000 0.000 0.000 0
#> GSM1253082 1 0.1478 0.936 0.936 0.000 0.000 0.064 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253057 1 0.0000 0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253059 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253060 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253061 6 0.3828 0.355 0.440 0.000 0.000 0.000 0.000 0.560
#> GSM1253062 1 0.2562 0.852 0.828 0.000 0.000 0.000 0.000 0.172
#> GSM1253063 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253064 6 0.0865 0.926 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM1253065 4 0.0858 0.962 0.004 0.000 0.000 0.968 0.000 0.028
#> GSM1253066 6 0.0865 0.926 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM1253067 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253068 6 0.0865 0.926 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM1253069 1 0.0000 0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.2135 0.879 0.872 0.000 0.000 0.000 0.000 0.128
#> GSM1253071 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253072 6 0.0865 0.926 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM1253073 4 0.0000 0.995 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253074 1 0.0000 0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0146 0.996 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.0146 0.984 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.0790 0.982 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM1253029 3 0.0291 0.983 0.000 0.004 0.992 0.000 0.000 0.004
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253031 3 0.0790 0.982 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM1253033 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253035 3 0.0000 0.985 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253036 3 0.0000 0.985 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.0291 0.983 0.000 0.004 0.992 0.000 0.000 0.004
#> GSM1253045 3 0.0790 0.982 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM1253043 3 0.0790 0.982 0.000 0.000 0.968 0.000 0.000 0.032
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.994 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.0146 0.984 0.000 0.000 0.996 0.000 0.000 0.004
#> GSM1253054 5 0.0632 0.978 0.000 0.000 0.000 0.000 0.976 0.024
#> GSM1253055 3 0.0713 0.983 0.000 0.000 0.972 0.000 0.000 0.028
#> GSM1253079 1 0.0000 0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.1327 0.912 0.936 0.000 0.000 0.000 0.000 0.064
#> GSM1253075 1 0.2562 0.852 0.828 0.000 0.000 0.000 0.000 0.172
#> GSM1253077 1 0.0000 0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.2491 0.859 0.836 0.000 0.000 0.000 0.000 0.164
#> GSM1253078 1 0.1765 0.901 0.904 0.000 0.000 0.000 0.000 0.096
#> GSM1253081 6 0.0865 0.926 0.036 0.000 0.000 0.000 0.000 0.964
#> GSM1253080 1 0.0000 0.919 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253082 6 0.0865 0.926 0.036 0.000 0.000 0.000 0.000 0.964
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 infection(p) disease.state(p) individual(p) k
#> SD:pam 54 0.024635 4.58e-08 0.950 2
#> SD:pam 56 0.013247 4.24e-10 0.807 3
#> SD:pam 53 0.002372 1.13e-10 0.793 4
#> SD:pam 56 0.000334 2.92e-12 0.862 5
#> SD:pam 55 0.000222 1.93e-11 0.772 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5096 0.491 0.491
#> 3 3 0.730 0.830 0.811 0.2102 1.000 1.000
#> 4 4 0.894 0.944 0.959 0.2038 0.764 0.520
#> 5 5 0.900 0.938 0.947 0.0739 0.943 0.776
#> 6 6 0.983 0.971 0.980 0.0500 0.964 0.820
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
#> GSM1253056 1 0 1 1 0
#> GSM1253057 1 0 1 1 0
#> GSM1253058 1 0 1 1 0
#> GSM1253059 1 0 1 1 0
#> GSM1253060 1 0 1 1 0
#> GSM1253061 1 0 1 1 0
#> GSM1253062 1 0 1 1 0
#> GSM1253063 1 0 1 1 0
#> GSM1253064 1 0 1 1 0
#> GSM1253065 1 0 1 1 0
#> GSM1253066 1 0 1 1 0
#> GSM1253067 1 0 1 1 0
#> GSM1253068 1 0 1 1 0
#> GSM1253069 1 0 1 1 0
#> GSM1253070 1 0 1 1 0
#> GSM1253071 1 0 1 1 0
#> GSM1253072 1 0 1 1 0
#> GSM1253073 1 0 1 1 0
#> GSM1253074 1 0 1 1 0
#> GSM1253032 2 0 1 0 1
#> GSM1253034 2 0 1 0 1
#> GSM1253039 2 0 1 0 1
#> GSM1253040 2 0 1 0 1
#> GSM1253041 2 0 1 0 1
#> GSM1253046 2 0 1 0 1
#> GSM1253048 2 0 1 0 1
#> GSM1253049 2 0 1 0 1
#> GSM1253052 2 0 1 0 1
#> GSM1253037 2 0 1 0 1
#> GSM1253028 2 0 1 0 1
#> GSM1253029 2 0 1 0 1
#> GSM1253030 2 0 1 0 1
#> GSM1253031 2 0 1 0 1
#> GSM1253033 2 0 1 0 1
#> GSM1253035 2 0 1 0 1
#> GSM1253036 2 0 1 0 1
#> GSM1253038 2 0 1 0 1
#> GSM1253042 2 0 1 0 1
#> GSM1253045 2 0 1 0 1
#> GSM1253043 2 0 1 0 1
#> GSM1253044 2 0 1 0 1
#> GSM1253047 2 0 1 0 1
#> GSM1253050 2 0 1 0 1
#> GSM1253051 2 0 1 0 1
#> GSM1253053 2 0 1 0 1
#> GSM1253054 2 0 1 0 1
#> GSM1253055 2 0 1 0 1
#> GSM1253079 1 0 1 1 0
#> GSM1253083 1 0 1 1 0
#> GSM1253075 1 0 1 1 0
#> GSM1253077 1 0 1 1 0
#> GSM1253076 1 0 1 1 0
#> GSM1253078 1 0 1 1 0
#> GSM1253081 1 0 1 1 0
#> GSM1253080 1 0 1 1 0
#> GSM1253082 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.3038 0.910 0.896 0.000 0.104
#> GSM1253057 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253058 1 0.5327 0.788 0.728 0.000 0.272
#> GSM1253059 1 0.5327 0.788 0.728 0.000 0.272
#> GSM1253060 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253061 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253063 1 0.3752 0.887 0.856 0.000 0.144
#> GSM1253064 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253065 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253066 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253067 1 0.4178 0.868 0.828 0.000 0.172
#> GSM1253068 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253070 1 0.3845 0.876 0.872 0.012 0.116
#> GSM1253071 1 0.0237 0.961 0.996 0.000 0.004
#> GSM1253072 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253073 1 0.3879 0.882 0.848 0.000 0.152
#> GSM1253074 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253032 2 0.5560 0.645 0.000 0.700 0.300
#> GSM1253034 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253039 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253040 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253041 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253046 2 0.5529 0.647 0.000 0.704 0.296
#> GSM1253048 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253049 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253052 2 0.0000 0.758 0.000 1.000 0.000
#> GSM1253037 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253028 2 0.2959 0.762 0.000 0.900 0.100
#> GSM1253029 2 0.0000 0.758 0.000 1.000 0.000
#> GSM1253030 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253031 2 0.5560 0.657 0.000 0.700 0.300
#> GSM1253033 2 0.5988 0.599 0.000 0.632 0.368
#> GSM1253035 2 0.0000 0.758 0.000 1.000 0.000
#> GSM1253036 2 0.2711 0.762 0.000 0.912 0.088
#> GSM1253038 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253042 2 0.0000 0.758 0.000 1.000 0.000
#> GSM1253045 2 0.4654 0.712 0.000 0.792 0.208
#> GSM1253043 2 0.1411 0.759 0.000 0.964 0.036
#> GSM1253044 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253047 2 0.5529 0.647 0.000 0.704 0.296
#> GSM1253050 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253051 2 0.6308 0.735 0.000 0.508 0.492
#> GSM1253053 2 0.0000 0.758 0.000 1.000 0.000
#> GSM1253054 2 0.4887 0.680 0.000 0.772 0.228
#> GSM1253055 2 0.0000 0.758 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.963 1.000 0.000 0.000
#> GSM1253082 1 0.0000 0.963 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.1022 0.989 0.032 0.000 0.000 0.968
#> GSM1253057 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.969 0.000 0.000 0.000 1.000
#> GSM1253059 4 0.0000 0.969 0.000 0.000 0.000 1.000
#> GSM1253060 4 0.0817 0.984 0.024 0.000 0.000 0.976
#> GSM1253061 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253062 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.1022 0.989 0.032 0.000 0.000 0.968
#> GSM1253064 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253065 4 0.1022 0.989 0.032 0.000 0.000 0.968
#> GSM1253066 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253067 4 0.1022 0.989 0.032 0.000 0.000 0.968
#> GSM1253068 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253069 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.4500 0.842 0.776 0.000 0.032 0.192
#> GSM1253071 4 0.1022 0.989 0.032 0.000 0.000 0.968
#> GSM1253072 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253073 4 0.1022 0.989 0.032 0.000 0.000 0.968
#> GSM1253074 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253032 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253037 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253029 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253030 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253033 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253035 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253036 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253038 2 0.4222 0.612 0.000 0.728 0.272 0.000
#> GSM1253042 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253045 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253044 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.971 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253054 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.1022 0.984 0.000 0.032 0.968 0.000
#> GSM1253079 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0188 0.908 0.996 0.000 0.000 0.004
#> GSM1253075 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.3172 0.887 0.840 0.000 0.000 0.160
#> GSM1253080 1 0.0000 0.908 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.3172 0.887 0.840 0.000 0.000 0.160
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253057 1 0.256 0.868 0.856 0 0.000 0 0.144
#> GSM1253058 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253059 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253060 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253061 5 0.252 0.911 0.140 0 0.000 0 0.860
#> GSM1253062 1 0.256 0.868 0.856 0 0.000 0 0.144
#> GSM1253063 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253064 5 0.252 0.911 0.140 0 0.000 0 0.860
#> GSM1253065 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253066 5 0.252 0.911 0.140 0 0.000 0 0.860
#> GSM1253067 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253068 5 0.252 0.911 0.140 0 0.000 0 0.860
#> GSM1253069 1 0.148 0.905 0.936 0 0.000 0 0.064
#> GSM1253070 5 0.569 0.266 0.088 0 0.376 0 0.536
#> GSM1253071 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253072 5 0.252 0.911 0.140 0 0.000 0 0.860
#> GSM1253073 4 0.000 1.000 0.000 0 0.000 1 0.000
#> GSM1253074 1 0.300 0.814 0.812 0 0.000 0 0.188
#> GSM1253032 3 0.252 0.904 0.000 0 0.860 0 0.140
#> GSM1253034 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253039 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253040 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253041 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253046 3 0.252 0.904 0.000 0 0.860 0 0.140
#> GSM1253048 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253049 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253052 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253037 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253028 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253029 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253030 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253031 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253033 3 0.252 0.904 0.000 0 0.860 0 0.140
#> GSM1253035 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253036 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253038 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253042 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253045 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253043 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253044 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253047 3 0.252 0.904 0.000 0 0.860 0 0.140
#> GSM1253050 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253051 2 0.000 1.000 0.000 1 0.000 0 0.000
#> GSM1253053 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253054 3 0.252 0.904 0.000 0 0.860 0 0.140
#> GSM1253055 3 0.000 0.958 0.000 0 1.000 0 0.000
#> GSM1253079 1 0.256 0.868 0.856 0 0.000 0 0.144
#> GSM1253083 1 0.000 0.919 1.000 0 0.000 0 0.000
#> GSM1253075 1 0.000 0.919 1.000 0 0.000 0 0.000
#> GSM1253077 1 0.000 0.919 1.000 0 0.000 0 0.000
#> GSM1253076 1 0.000 0.919 1.000 0 0.000 0 0.000
#> GSM1253078 1 0.000 0.919 1.000 0 0.000 0 0.000
#> GSM1253081 5 0.252 0.911 0.140 0 0.000 0 0.860
#> GSM1253080 1 0.000 0.919 1.000 0 0.000 0 0.000
#> GSM1253082 5 0.252 0.911 0.140 0 0.000 0 0.860
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253057 1 0.2697 0.864 0.812 0 0.000 0 0.000 0.188
#> GSM1253058 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253059 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253060 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253061 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.000
#> GSM1253062 1 0.2762 0.859 0.804 0 0.000 0 0.000 0.196
#> GSM1253063 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253064 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.000
#> GSM1253065 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253066 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.000
#> GSM1253067 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253068 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.000
#> GSM1253069 1 0.2048 0.891 0.880 0 0.000 0 0.000 0.120
#> GSM1253070 6 0.1765 0.876 0.000 0 0.000 0 0.096 0.904
#> GSM1253071 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253072 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.000
#> GSM1253073 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> GSM1253074 1 0.2823 0.851 0.796 0 0.000 0 0.000 0.204
#> GSM1253032 5 0.0000 1.000 0.000 0 0.000 0 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253046 5 0.0000 1.000 0.000 0 0.000 0 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253052 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253028 3 0.0146 0.992 0.000 0 0.996 0 0.004 0.000
#> GSM1253029 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253031 3 0.0547 0.984 0.000 0 0.980 0 0.020 0.000
#> GSM1253033 5 0.0000 1.000 0.000 0 0.000 0 1.000 0.000
#> GSM1253035 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253036 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253042 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253045 3 0.0547 0.984 0.000 0 0.980 0 0.020 0.000
#> GSM1253043 3 0.0547 0.984 0.000 0 0.980 0 0.020 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253047 5 0.0000 1.000 0.000 0 0.000 0 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> GSM1253053 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253054 5 0.0000 1.000 0.000 0 0.000 0 1.000 0.000
#> GSM1253055 3 0.0000 0.993 0.000 0 1.000 0 0.000 0.000
#> GSM1253079 1 0.2762 0.859 0.804 0 0.000 0 0.000 0.196
#> GSM1253083 1 0.0000 0.897 1.000 0 0.000 0 0.000 0.000
#> GSM1253075 1 0.0713 0.904 0.972 0 0.000 0 0.000 0.028
#> GSM1253077 1 0.0000 0.897 1.000 0 0.000 0 0.000 0.000
#> GSM1253076 1 0.0000 0.897 1.000 0 0.000 0 0.000 0.000
#> GSM1253078 1 0.0000 0.897 1.000 0 0.000 0 0.000 0.000
#> GSM1253081 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.000
#> GSM1253080 1 0.0713 0.904 0.972 0 0.000 0 0.000 0.028
#> GSM1253082 6 0.0000 0.984 0.000 0 0.000 0 0.000 1.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 infection(p) disease.state(p) individual(p) k
#> SD:mclust 56 3.60e-03 4.20e-12 0.995 2
#> SD:mclust 56 3.60e-03 4.20e-12 0.995 3
#> SD:mclust 56 1.11e-04 4.17e-13 0.934 4
#> SD:mclust 55 3.22e-05 1.22e-12 0.837 5
#> SD:mclust 56 8.89e-05 3.40e-12 0.778 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.991 0.996 0.4946 0.507 0.507
#> 3 3 0.850 0.872 0.944 0.2943 0.830 0.675
#> 4 4 0.945 0.937 0.972 0.1545 0.877 0.677
#> 5 5 0.918 0.800 0.904 0.0190 0.969 0.889
#> 6 6 0.879 0.811 0.883 0.0193 0.973 0.900
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
#> GSM1253056 1 0.000 0.993 1.000 0.000
#> GSM1253057 1 0.000 0.993 1.000 0.000
#> GSM1253058 1 0.000 0.993 1.000 0.000
#> GSM1253059 1 0.000 0.993 1.000 0.000
#> GSM1253060 1 0.000 0.993 1.000 0.000
#> GSM1253061 1 0.000 0.993 1.000 0.000
#> GSM1253062 1 0.000 0.993 1.000 0.000
#> GSM1253063 1 0.000 0.993 1.000 0.000
#> GSM1253064 1 0.000 0.993 1.000 0.000
#> GSM1253065 1 0.000 0.993 1.000 0.000
#> GSM1253066 1 0.000 0.993 1.000 0.000
#> GSM1253067 1 0.000 0.993 1.000 0.000
#> GSM1253068 1 0.000 0.993 1.000 0.000
#> GSM1253069 1 0.000 0.993 1.000 0.000
#> GSM1253070 1 0.000 0.993 1.000 0.000
#> GSM1253071 1 0.000 0.993 1.000 0.000
#> GSM1253072 1 0.000 0.993 1.000 0.000
#> GSM1253073 1 0.000 0.993 1.000 0.000
#> GSM1253074 1 0.000 0.993 1.000 0.000
#> GSM1253032 1 0.000 0.993 1.000 0.000
#> GSM1253034 2 0.000 1.000 0.000 1.000
#> GSM1253039 2 0.000 1.000 0.000 1.000
#> GSM1253040 2 0.000 1.000 0.000 1.000
#> GSM1253041 2 0.000 1.000 0.000 1.000
#> GSM1253046 1 0.000 0.993 1.000 0.000
#> GSM1253048 2 0.000 1.000 0.000 1.000
#> GSM1253049 2 0.000 1.000 0.000 1.000
#> GSM1253052 2 0.000 1.000 0.000 1.000
#> GSM1253037 2 0.000 1.000 0.000 1.000
#> GSM1253028 2 0.000 1.000 0.000 1.000
#> GSM1253029 2 0.000 1.000 0.000 1.000
#> GSM1253030 2 0.000 1.000 0.000 1.000
#> GSM1253031 2 0.000 1.000 0.000 1.000
#> GSM1253033 1 0.000 0.993 1.000 0.000
#> GSM1253035 2 0.000 1.000 0.000 1.000
#> GSM1253036 2 0.000 1.000 0.000 1.000
#> GSM1253038 2 0.000 1.000 0.000 1.000
#> GSM1253042 2 0.000 1.000 0.000 1.000
#> GSM1253045 2 0.000 1.000 0.000 1.000
#> GSM1253043 2 0.000 1.000 0.000 1.000
#> GSM1253044 2 0.000 1.000 0.000 1.000
#> GSM1253047 1 0.000 0.993 1.000 0.000
#> GSM1253050 2 0.000 1.000 0.000 1.000
#> GSM1253051 2 0.000 1.000 0.000 1.000
#> GSM1253053 2 0.000 1.000 0.000 1.000
#> GSM1253054 1 0.753 0.724 0.784 0.216
#> GSM1253055 2 0.000 1.000 0.000 1.000
#> GSM1253079 1 0.000 0.993 1.000 0.000
#> GSM1253083 1 0.000 0.993 1.000 0.000
#> GSM1253075 1 0.000 0.993 1.000 0.000
#> GSM1253077 1 0.000 0.993 1.000 0.000
#> GSM1253076 1 0.000 0.993 1.000 0.000
#> GSM1253078 1 0.000 0.993 1.000 0.000
#> GSM1253081 1 0.000 0.993 1.000 0.000
#> GSM1253080 1 0.000 0.993 1.000 0.000
#> GSM1253082 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
#> GSM1253056 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253057 1 0.1163 0.915 0.972 0.000 0.028
#> GSM1253058 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253059 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253060 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253061 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253063 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253064 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253065 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253066 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253067 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253068 1 0.0424 0.925 0.992 0.000 0.008
#> GSM1253069 1 0.1643 0.906 0.956 0.000 0.044
#> GSM1253070 3 0.5016 0.560 0.240 0.000 0.760
#> GSM1253071 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253072 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253073 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253074 1 0.4235 0.797 0.824 0.000 0.176
#> GSM1253032 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253034 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253046 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253048 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253052 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253037 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253028 2 0.5785 0.424 0.000 0.668 0.332
#> GSM1253029 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253030 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253031 3 0.6026 0.404 0.000 0.376 0.624
#> GSM1253033 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253035 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253036 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253038 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253042 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253045 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253043 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253044 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253047 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253050 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253053 2 0.0237 0.975 0.000 0.996 0.004
#> GSM1253054 3 0.0000 0.876 0.000 0.000 1.000
#> GSM1253055 3 0.6079 0.376 0.000 0.388 0.612
#> GSM1253079 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253083 1 0.6095 0.471 0.608 0.000 0.392
#> GSM1253075 1 0.3038 0.864 0.896 0.000 0.104
#> GSM1253077 1 0.6045 0.497 0.620 0.000 0.380
#> GSM1253076 1 0.2537 0.883 0.920 0.000 0.080
#> GSM1253078 1 0.4974 0.728 0.764 0.000 0.236
#> GSM1253081 1 0.0000 0.928 1.000 0.000 0.000
#> GSM1253080 1 0.5882 0.558 0.652 0.000 0.348
#> GSM1253082 1 0.0000 0.928 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0000 0.998 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0188 0.997 0.004 0.000 0.000 0.996
#> GSM1253059 4 0.0000 0.998 0.000 0.000 0.000 1.000
#> GSM1253060 4 0.0188 0.997 0.004 0.000 0.000 0.996
#> GSM1253061 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0188 0.997 0.004 0.000 0.000 0.996
#> GSM1253064 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.0188 0.997 0.004 0.000 0.000 0.996
#> GSM1253066 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.0000 0.998 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.2868 0.820 0.864 0.000 0.136 0.000
#> GSM1253071 4 0.0000 0.998 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.0000 0.998 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253052 2 0.1637 0.917 0.000 0.940 0.060 0.000
#> GSM1253037 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253028 2 0.2973 0.841 0.000 0.856 0.144 0.000
#> GSM1253029 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253030 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253033 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253035 2 0.3907 0.732 0.000 0.768 0.232 0.000
#> GSM1253036 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253038 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253042 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.960 0.000 1.000 0.000 0.000
#> GSM1253053 2 0.4304 0.650 0.000 0.716 0.284 0.000
#> GSM1253054 3 0.0000 0.999 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.0336 0.990 0.000 0.008 0.992 0.000
#> GSM1253079 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.4961 0.225 0.552 0.000 0.000 0.448
#> GSM1253080 1 0.0000 0.953 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.4008 0.676 0.756 0.000 0.000 0.244
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0000 0.5359 0.000 0.000 0.000 1.000 0.000
#> GSM1253057 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 3 0.4171 0.7822 0.000 0.000 0.604 0.396 0.000
#> GSM1253059 3 0.3949 0.7103 0.000 0.000 0.668 0.332 0.000
#> GSM1253060 4 0.4291 -0.7026 0.000 0.000 0.464 0.536 0.000
#> GSM1253061 1 0.0324 0.9513 0.992 0.000 0.004 0.004 0.000
#> GSM1253062 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 3 0.4300 0.7598 0.000 0.000 0.524 0.476 0.000
#> GSM1253064 1 0.1041 0.9382 0.964 0.000 0.032 0.004 0.000
#> GSM1253065 4 0.1270 0.5077 0.000 0.000 0.052 0.948 0.000
#> GSM1253066 1 0.0703 0.9444 0.976 0.000 0.024 0.000 0.000
#> GSM1253067 4 0.0290 0.5338 0.000 0.000 0.008 0.992 0.000
#> GSM1253068 1 0.0404 0.9501 0.988 0.000 0.012 0.000 0.000
#> GSM1253069 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.4450 0.0216 0.508 0.000 0.004 0.000 0.488
#> GSM1253071 4 0.4249 -0.6120 0.000 0.000 0.432 0.568 0.000
#> GSM1253072 1 0.0404 0.9501 0.988 0.000 0.012 0.000 0.000
#> GSM1253073 3 0.4287 0.7917 0.000 0.000 0.540 0.460 0.000
#> GSM1253074 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.8983 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.0000 0.9543 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0404 0.9522 0.000 0.988 0.012 0.000 0.000
#> GSM1253040 2 0.0404 0.9522 0.000 0.988 0.012 0.000 0.000
#> GSM1253041 2 0.0162 0.9535 0.000 0.996 0.004 0.000 0.000
#> GSM1253046 5 0.0609 0.8990 0.000 0.000 0.020 0.000 0.980
#> GSM1253048 2 0.0000 0.9543 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.9543 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 2 0.0566 0.9488 0.000 0.984 0.012 0.004 0.000
#> GSM1253037 2 0.0162 0.9541 0.000 0.996 0.004 0.000 0.000
#> GSM1253028 5 0.5483 0.1925 0.000 0.424 0.064 0.000 0.512
#> GSM1253029 2 0.0162 0.9535 0.000 0.996 0.004 0.000 0.000
#> GSM1253030 2 0.1671 0.9163 0.000 0.924 0.076 0.000 0.000
#> GSM1253031 5 0.1894 0.8847 0.000 0.008 0.072 0.000 0.920
#> GSM1253033 5 0.0794 0.8982 0.000 0.000 0.028 0.000 0.972
#> GSM1253035 2 0.4392 0.3266 0.000 0.612 0.008 0.000 0.380
#> GSM1253036 2 0.1851 0.9080 0.000 0.912 0.088 0.000 0.000
#> GSM1253038 2 0.0162 0.9541 0.000 0.996 0.004 0.000 0.000
#> GSM1253042 2 0.0703 0.9496 0.000 0.976 0.024 0.000 0.000
#> GSM1253045 5 0.0880 0.8954 0.000 0.000 0.032 0.000 0.968
#> GSM1253043 5 0.1908 0.8786 0.000 0.000 0.092 0.000 0.908
#> GSM1253044 2 0.0000 0.9543 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0162 0.8980 0.000 0.000 0.004 0.000 0.996
#> GSM1253050 2 0.0510 0.9512 0.000 0.984 0.016 0.000 0.000
#> GSM1253051 2 0.0000 0.9543 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 2 0.3369 0.8446 0.000 0.856 0.024 0.092 0.028
#> GSM1253054 5 0.0510 0.8951 0.000 0.000 0.016 0.000 0.984
#> GSM1253055 5 0.2079 0.8533 0.000 0.064 0.020 0.000 0.916
#> GSM1253079 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0162 0.9523 0.996 0.000 0.004 0.000 0.000
#> GSM1253075 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0162 0.9523 0.996 0.000 0.004 0.000 0.000
#> GSM1253076 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.3099 0.8177 0.848 0.000 0.028 0.124 0.000
#> GSM1253080 1 0.0000 0.9530 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.1893 0.9052 0.928 0.000 0.024 0.048 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 3 0.3547 0.9116 0.000 0.000 0.668 0.332 0.000 NA
#> GSM1253057 1 0.0984 0.9313 0.968 0.000 0.008 0.012 0.000 NA
#> GSM1253058 4 0.4079 0.5946 0.000 0.000 0.084 0.744 0.000 NA
#> GSM1253059 4 0.3612 0.6094 0.000 0.000 0.052 0.780 0.000 NA
#> GSM1253060 4 0.3103 0.5766 0.000 0.000 0.208 0.784 0.000 NA
#> GSM1253061 1 0.0862 0.9315 0.972 0.000 0.004 0.016 0.000 NA
#> GSM1253062 1 0.0858 0.9303 0.968 0.000 0.004 0.000 0.000 NA
#> GSM1253063 4 0.1265 0.6957 0.000 0.000 0.044 0.948 0.000 NA
#> GSM1253064 1 0.2542 0.8832 0.884 0.000 0.020 0.016 0.000 NA
#> GSM1253065 3 0.3508 0.8742 0.004 0.000 0.704 0.292 0.000 NA
#> GSM1253066 1 0.1511 0.9161 0.940 0.000 0.012 0.004 0.000 NA
#> GSM1253067 3 0.3782 0.8784 0.000 0.000 0.636 0.360 0.000 NA
#> GSM1253068 1 0.0806 0.9293 0.972 0.000 0.008 0.000 0.000 NA
#> GSM1253069 1 0.0717 0.9319 0.976 0.000 0.008 0.000 0.000 NA
#> GSM1253070 1 0.5391 0.0049 0.476 0.000 0.016 0.020 0.456 NA
#> GSM1253071 4 0.3298 0.5219 0.000 0.000 0.236 0.756 0.000 NA
#> GSM1253072 1 0.0458 0.9315 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253073 4 0.1908 0.6786 0.000 0.000 0.028 0.916 0.000 NA
#> GSM1253074 1 0.0881 0.9323 0.972 0.000 0.008 0.008 0.000 NA
#> GSM1253032 5 0.0000 0.8818 0.000 0.000 0.000 0.000 1.000 NA
#> GSM1253034 2 0.0458 0.8941 0.000 0.984 0.000 0.000 0.000 NA
#> GSM1253039 2 0.0865 0.8903 0.000 0.964 0.000 0.000 0.000 NA
#> GSM1253040 2 0.0713 0.8916 0.000 0.972 0.000 0.000 0.000 NA
#> GSM1253041 2 0.0146 0.8933 0.000 0.996 0.000 0.000 0.000 NA
#> GSM1253046 5 0.0260 0.8826 0.000 0.000 0.000 0.000 0.992 NA
#> GSM1253048 2 0.0146 0.8933 0.000 0.996 0.000 0.000 0.000 NA
#> GSM1253049 2 0.0260 0.8939 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253052 2 0.0870 0.8882 0.000 0.972 0.012 0.000 0.004 NA
#> GSM1253037 2 0.0260 0.8938 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253028 2 0.5927 -0.0270 0.000 0.428 0.000 0.000 0.356 NA
#> GSM1253029 2 0.0820 0.8884 0.000 0.972 0.012 0.000 0.000 NA
#> GSM1253030 2 0.3531 0.6744 0.000 0.672 0.000 0.000 0.000 NA
#> GSM1253031 5 0.3460 0.8008 0.000 0.020 0.000 0.000 0.760 NA
#> GSM1253033 5 0.1411 0.8746 0.000 0.000 0.000 0.004 0.936 NA
#> GSM1253035 2 0.4206 0.4569 0.000 0.620 0.000 0.000 0.356 NA
#> GSM1253036 2 0.3650 0.7015 0.000 0.708 0.000 0.000 0.012 NA
#> GSM1253038 2 0.0632 0.8926 0.000 0.976 0.000 0.000 0.000 NA
#> GSM1253042 2 0.0858 0.8918 0.000 0.968 0.004 0.000 0.000 NA
#> GSM1253045 5 0.1701 0.8714 0.000 0.008 0.000 0.000 0.920 NA
#> GSM1253043 5 0.3499 0.7187 0.000 0.000 0.000 0.000 0.680 NA
#> GSM1253044 2 0.0260 0.8941 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253047 5 0.0363 0.8812 0.000 0.000 0.012 0.000 0.988 NA
#> GSM1253050 2 0.0547 0.8925 0.000 0.980 0.000 0.000 0.000 NA
#> GSM1253051 2 0.0713 0.8902 0.000 0.972 0.000 0.000 0.000 NA
#> GSM1253053 2 0.3203 0.7685 0.000 0.812 0.160 0.000 0.004 NA
#> GSM1253054 5 0.1010 0.8742 0.000 0.000 0.036 0.000 0.960 NA
#> GSM1253055 5 0.4443 0.6933 0.000 0.176 0.016 0.000 0.732 NA
#> GSM1253079 1 0.0862 0.9308 0.972 0.000 0.008 0.016 0.000 NA
#> GSM1253083 1 0.0632 0.9310 0.976 0.000 0.000 0.000 0.000 NA
#> GSM1253075 1 0.0146 0.9330 0.996 0.000 0.000 0.000 0.000 NA
#> GSM1253077 1 0.0547 0.9318 0.980 0.000 0.000 0.000 0.000 NA
#> GSM1253076 1 0.0458 0.9323 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253078 1 0.0458 0.9323 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253081 1 0.3997 0.7934 0.800 0.000 0.052 0.084 0.000 NA
#> GSM1253080 1 0.0717 0.9321 0.976 0.000 0.008 0.000 0.000 NA
#> GSM1253082 1 0.2540 0.8840 0.892 0.000 0.020 0.044 0.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 infection(p) disease.state(p) individual(p) k
#> SD:NMF 56 0.018077 1.69e-08 0.955 2
#> SD:NMF 51 0.014712 8.96e-09 0.908 3
#> SD:NMF 55 0.000243 2.81e-11 0.903 4
#> SD:NMF 51 0.000491 2.54e-09 0.903 5
#> SD:NMF 53 0.000305 4.19e-10 0.882 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.994 0.996 0.4909 0.507 0.507
#> 3 3 0.827 0.892 0.889 0.2508 0.860 0.723
#> 4 4 0.734 0.510 0.670 0.1276 0.717 0.437
#> 5 5 1.000 0.973 0.987 0.1243 0.850 0.586
#> 6 6 0.987 0.959 0.973 0.0103 0.991 0.959
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
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
#> GSM1253056 1 0.0000 1.000 1.000 0.000
#> GSM1253057 1 0.0000 1.000 1.000 0.000
#> GSM1253058 1 0.0000 1.000 1.000 0.000
#> GSM1253059 1 0.0000 1.000 1.000 0.000
#> GSM1253060 1 0.0000 1.000 1.000 0.000
#> GSM1253061 1 0.0000 1.000 1.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000
#> GSM1253063 1 0.0000 1.000 1.000 0.000
#> GSM1253064 1 0.0000 1.000 1.000 0.000
#> GSM1253065 1 0.0000 1.000 1.000 0.000
#> GSM1253066 1 0.0000 1.000 1.000 0.000
#> GSM1253067 1 0.0000 1.000 1.000 0.000
#> GSM1253068 1 0.0000 1.000 1.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000
#> GSM1253071 1 0.0000 1.000 1.000 0.000
#> GSM1253072 1 0.0000 1.000 1.000 0.000
#> GSM1253073 1 0.0000 1.000 1.000 0.000
#> GSM1253074 1 0.0000 1.000 1.000 0.000
#> GSM1253032 1 0.0000 1.000 1.000 0.000
#> GSM1253034 2 0.0000 0.989 0.000 1.000
#> GSM1253039 2 0.0000 0.989 0.000 1.000
#> GSM1253040 2 0.0000 0.989 0.000 1.000
#> GSM1253041 2 0.0000 0.989 0.000 1.000
#> GSM1253046 1 0.0000 1.000 1.000 0.000
#> GSM1253048 2 0.0000 0.989 0.000 1.000
#> GSM1253049 2 0.0000 0.989 0.000 1.000
#> GSM1253052 2 0.0376 0.989 0.004 0.996
#> GSM1253037 2 0.0000 0.989 0.000 1.000
#> GSM1253028 2 0.2236 0.972 0.036 0.964
#> GSM1253029 2 0.0376 0.989 0.004 0.996
#> GSM1253030 2 0.0000 0.989 0.000 1.000
#> GSM1253031 2 0.2236 0.972 0.036 0.964
#> GSM1253033 1 0.0000 1.000 1.000 0.000
#> GSM1253035 2 0.2236 0.972 0.036 0.964
#> GSM1253036 2 0.0376 0.989 0.004 0.996
#> GSM1253038 2 0.0000 0.989 0.000 1.000
#> GSM1253042 2 0.0376 0.989 0.004 0.996
#> GSM1253045 2 0.2236 0.972 0.036 0.964
#> GSM1253043 2 0.2236 0.972 0.036 0.964
#> GSM1253044 2 0.0000 0.989 0.000 1.000
#> GSM1253047 1 0.0000 1.000 1.000 0.000
#> GSM1253050 2 0.0000 0.989 0.000 1.000
#> GSM1253051 2 0.0000 0.989 0.000 1.000
#> GSM1253053 2 0.0376 0.989 0.004 0.996
#> GSM1253054 1 0.0000 1.000 1.000 0.000
#> GSM1253055 2 0.2236 0.972 0.036 0.964
#> GSM1253079 1 0.0000 1.000 1.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000
#> GSM1253082 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
#> GSM1253056 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253057 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253058 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253059 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253060 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253061 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253062 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253063 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253064 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253065 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253066 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253067 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253068 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253069 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253070 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253071 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253072 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253073 3 0.0000 1.000 0.000 0.000 1.000
#> GSM1253074 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253032 1 0.0000 0.464 1.000 0.000 0.000
#> GSM1253034 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253046 1 0.0000 0.464 1.000 0.000 0.000
#> GSM1253048 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253052 2 0.0237 0.990 0.004 0.996 0.000
#> GSM1253037 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253028 2 0.1411 0.976 0.036 0.964 0.000
#> GSM1253029 2 0.0237 0.990 0.004 0.996 0.000
#> GSM1253030 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253031 2 0.1411 0.976 0.036 0.964 0.000
#> GSM1253033 1 0.0000 0.464 1.000 0.000 0.000
#> GSM1253035 2 0.1411 0.976 0.036 0.964 0.000
#> GSM1253036 2 0.0237 0.990 0.004 0.996 0.000
#> GSM1253038 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253042 2 0.0237 0.990 0.004 0.996 0.000
#> GSM1253045 2 0.1411 0.976 0.036 0.964 0.000
#> GSM1253043 2 0.1411 0.976 0.036 0.964 0.000
#> GSM1253044 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253047 1 0.0000 0.464 1.000 0.000 0.000
#> GSM1253050 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.991 0.000 1.000 0.000
#> GSM1253053 2 0.0237 0.990 0.004 0.996 0.000
#> GSM1253054 1 0.0000 0.464 1.000 0.000 0.000
#> GSM1253055 2 0.1411 0.976 0.036 0.964 0.000
#> GSM1253079 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253083 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253075 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253077 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253076 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253078 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253081 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253080 1 0.6215 0.837 0.572 0.000 0.428
#> GSM1253082 1 0.6215 0.837 0.572 0.000 0.428
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253058 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253059 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253060 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253061 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253062 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253063 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253064 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253065 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253066 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253067 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253069 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253070 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253071 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253073 4 0.000 1.000 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253032 2 0.480 0.999 0.340 0.656 0.004 0.000
#> GSM1253034 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253039 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253040 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253041 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253046 2 0.480 0.999 0.340 0.656 0.004 0.000
#> GSM1253048 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253049 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253052 3 0.112 0.917 0.036 0.000 0.964 0.000
#> GSM1253037 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253028 3 0.000 0.918 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.112 0.917 0.036 0.000 0.964 0.000
#> GSM1253030 3 0.785 0.293 0.280 0.320 0.400 0.000
#> GSM1253031 3 0.000 0.918 0.000 0.000 1.000 0.000
#> GSM1253033 2 0.480 0.999 0.340 0.656 0.004 0.000
#> GSM1253035 3 0.000 0.918 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.247 0.880 0.056 0.028 0.916 0.000
#> GSM1253038 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253042 3 0.112 0.917 0.036 0.000 0.964 0.000
#> GSM1253045 3 0.000 0.918 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.000 0.918 0.000 0.000 1.000 0.000
#> GSM1253044 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253047 2 0.480 0.999 0.340 0.656 0.004 0.000
#> GSM1253050 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253051 1 0.777 -0.158 0.412 0.344 0.244 0.000
#> GSM1253053 3 0.112 0.917 0.036 0.000 0.964 0.000
#> GSM1253054 2 0.494 0.996 0.340 0.652 0.008 0.000
#> GSM1253055 3 0.000 0.918 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253083 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253075 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253077 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253076 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253078 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253081 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253080 1 0.489 0.314 0.588 0.000 0.000 0.412
#> GSM1253082 1 0.489 0.314 0.588 0.000 0.000 0.412
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0404 0.971 0.012 0.000 0.000 0.988 0.000
#> GSM1253057 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.965 0.000 0.000 0.000 1.000 0.000
#> GSM1253059 4 0.0000 0.965 0.000 0.000 0.000 1.000 0.000
#> GSM1253060 4 0.0404 0.971 0.012 0.000 0.000 0.988 0.000
#> GSM1253061 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0404 0.971 0.012 0.000 0.000 0.988 0.000
#> GSM1253064 1 0.0404 0.990 0.988 0.000 0.000 0.012 0.000
#> GSM1253065 4 0.2516 0.803 0.140 0.000 0.000 0.860 0.000
#> GSM1253066 1 0.0404 0.990 0.988 0.000 0.000 0.012 0.000
#> GSM1253067 4 0.0404 0.971 0.012 0.000 0.000 0.988 0.000
#> GSM1253068 1 0.0404 0.990 0.988 0.000 0.000 0.012 0.000
#> GSM1253069 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253071 4 0.0404 0.971 0.012 0.000 0.000 0.988 0.000
#> GSM1253072 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.0000 0.965 0.000 0.000 0.000 1.000 0.000
#> GSM1253074 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253048 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.0963 0.957 0.000 0.036 0.964 0.000 0.000
#> GSM1253037 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.0000 0.963 0.000 0.000 1.000 0.000 0.000
#> GSM1253029 3 0.0963 0.957 0.000 0.036 0.964 0.000 0.000
#> GSM1253030 2 0.2690 0.802 0.000 0.844 0.156 0.000 0.000
#> GSM1253031 3 0.0000 0.963 0.000 0.000 1.000 0.000 0.000
#> GSM1253033 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253035 3 0.0000 0.963 0.000 0.000 1.000 0.000 0.000
#> GSM1253036 3 0.2813 0.808 0.000 0.168 0.832 0.000 0.000
#> GSM1253038 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.0963 0.957 0.000 0.036 0.964 0.000 0.000
#> GSM1253045 3 0.0000 0.963 0.000 0.000 1.000 0.000 0.000
#> GSM1253043 3 0.0000 0.963 0.000 0.000 1.000 0.000 0.000
#> GSM1253044 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.999 0.000 0.000 0.000 0.000 1.000
#> GSM1253050 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 3 0.0963 0.957 0.000 0.036 0.964 0.000 0.000
#> GSM1253054 5 0.0162 0.996 0.000 0.000 0.004 0.000 0.996
#> GSM1253055 3 0.0000 0.963 0.000 0.000 1.000 0.000 0.000
#> GSM1253079 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0404 0.990 0.988 0.000 0.000 0.012 0.000
#> GSM1253080 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0510 0.986 0.984 0.000 0.000 0.016 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0363 0.943 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM1253057 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253058 6 0.2730 1.000 0.000 0.000 0.000 0.192 0.000 0.808
#> GSM1253059 6 0.2730 1.000 0.000 0.000 0.000 0.192 0.000 0.808
#> GSM1253060 4 0.0363 0.943 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM1253061 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0363 0.943 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM1253064 1 0.0363 0.989 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM1253065 4 0.2260 0.714 0.140 0.000 0.000 0.860 0.000 0.000
#> GSM1253066 1 0.0363 0.989 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM1253067 4 0.1074 0.922 0.012 0.000 0.000 0.960 0.000 0.028
#> GSM1253068 1 0.0363 0.989 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM1253069 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253071 4 0.0363 0.943 0.012 0.000 0.000 0.988 0.000 0.000
#> GSM1253072 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.0260 0.926 0.000 0.000 0.000 0.992 0.000 0.008
#> GSM1253074 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.2219 0.895 0.000 0.000 0.000 0.000 0.864 0.136
#> GSM1253048 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.0865 0.953 0.000 0.036 0.964 0.000 0.000 0.000
#> GSM1253037 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253029 3 0.0865 0.953 0.000 0.036 0.964 0.000 0.000 0.000
#> GSM1253030 2 0.2416 0.779 0.000 0.844 0.156 0.000 0.000 0.000
#> GSM1253031 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253033 5 0.2980 0.862 0.000 0.000 0.000 0.008 0.800 0.192
#> GSM1253035 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253036 3 0.2527 0.785 0.000 0.168 0.832 0.000 0.000 0.000
#> GSM1253038 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.0865 0.953 0.000 0.036 0.964 0.000 0.000 0.000
#> GSM1253045 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253043 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253044 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.930 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.982 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.0865 0.953 0.000 0.036 0.964 0.000 0.000 0.000
#> GSM1253054 5 0.0146 0.929 0.000 0.000 0.004 0.000 0.996 0.000
#> GSM1253055 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253079 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0363 0.989 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM1253080 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0458 0.985 0.984 0.000 0.000 0.016 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> CV:hclust 56 0.018077 1.69e-08 0.955 2
#> CV:hclust 51 0.000101 1.43e-11 0.940 3
#> CV:hclust 25 NA 1.05e-05 0.512 4
#> CV:hclust 56 0.000334 2.92e-12 0.862 5
#> CV:hclust 56 0.000853 5.02e-11 0.923 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4934 0.507 0.507
#> 3 3 0.663 0.678 0.822 0.2841 0.875 0.757
#> 4 4 0.786 0.854 0.840 0.1329 0.803 0.535
#> 5 5 0.701 0.916 0.880 0.0673 0.935 0.758
#> 6 6 0.832 0.848 0.841 0.0468 1.000 1.000
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
#> GSM1253056 1 0.0000 1.000 1.000 0.000
#> GSM1253057 1 0.0000 1.000 1.000 0.000
#> GSM1253058 1 0.0000 1.000 1.000 0.000
#> GSM1253059 1 0.0000 1.000 1.000 0.000
#> GSM1253060 1 0.0000 1.000 1.000 0.000
#> GSM1253061 1 0.0000 1.000 1.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000
#> GSM1253063 1 0.0000 1.000 1.000 0.000
#> GSM1253064 1 0.0000 1.000 1.000 0.000
#> GSM1253065 1 0.0000 1.000 1.000 0.000
#> GSM1253066 1 0.0000 1.000 1.000 0.000
#> GSM1253067 1 0.0000 1.000 1.000 0.000
#> GSM1253068 1 0.0000 1.000 1.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000
#> GSM1253071 1 0.0000 1.000 1.000 0.000
#> GSM1253072 1 0.0000 1.000 1.000 0.000
#> GSM1253073 1 0.0000 1.000 1.000 0.000
#> GSM1253074 1 0.0000 1.000 1.000 0.000
#> GSM1253032 1 0.0000 1.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000
#> GSM1253046 1 0.0000 1.000 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000
#> GSM1253033 1 0.0000 1.000 1.000 0.000
#> GSM1253035 2 0.0000 1.000 0.000 1.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000
#> GSM1253045 2 0.0000 1.000 0.000 1.000
#> GSM1253043 2 0.0000 1.000 0.000 1.000
#> GSM1253044 2 0.0000 1.000 0.000 1.000
#> GSM1253047 1 0.0000 1.000 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000
#> GSM1253054 1 0.0376 0.996 0.996 0.004
#> GSM1253055 2 0.0000 1.000 0.000 1.000
#> GSM1253079 1 0.0000 1.000 1.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000
#> GSM1253082 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
#> GSM1253056 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253057 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253058 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253059 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253060 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253061 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253063 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253064 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253065 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253066 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253067 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253068 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253070 1 0.0892 0.789 0.980 0.000 0.020
#> GSM1253071 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253072 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253073 1 0.6274 0.569 0.544 0.000 0.456
#> GSM1253074 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253032 3 0.5882 0.716 0.348 0.000 0.652
#> GSM1253034 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253046 3 0.6045 0.694 0.380 0.000 0.620
#> GSM1253048 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253052 2 0.6045 0.524 0.000 0.620 0.380
#> GSM1253037 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253028 2 0.6252 0.404 0.000 0.556 0.444
#> GSM1253029 2 0.4654 0.710 0.000 0.792 0.208
#> GSM1253030 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253031 2 0.6252 0.404 0.000 0.556 0.444
#> GSM1253033 3 0.6026 0.696 0.376 0.000 0.624
#> GSM1253035 2 0.6062 0.517 0.000 0.616 0.384
#> GSM1253036 2 0.4654 0.710 0.000 0.792 0.208
#> GSM1253038 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253042 2 0.4654 0.710 0.000 0.792 0.208
#> GSM1253045 3 0.6483 -0.242 0.004 0.452 0.544
#> GSM1253043 3 0.6274 -0.255 0.000 0.456 0.544
#> GSM1253044 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253047 3 0.6008 0.704 0.372 0.000 0.628
#> GSM1253050 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.807 0.000 1.000 0.000
#> GSM1253053 2 0.6045 0.524 0.000 0.620 0.380
#> GSM1253054 3 0.5882 0.716 0.348 0.000 0.652
#> GSM1253055 2 0.6252 0.404 0.000 0.556 0.444
#> GSM1253079 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.802 1.000 0.000 0.000
#> GSM1253082 1 0.0000 0.802 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0000 0.996 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253058 4 0.0592 0.989 0.000 0.000 0.016 0.984
#> GSM1253059 4 0.0592 0.989 0.000 0.000 0.016 0.984
#> GSM1253060 4 0.0000 0.996 0.000 0.000 0.000 1.000
#> GSM1253061 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253062 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253063 4 0.0000 0.996 0.000 0.000 0.000 1.000
#> GSM1253064 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253065 4 0.0000 0.996 0.000 0.000 0.000 1.000
#> GSM1253066 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253067 4 0.0000 0.996 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253069 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253070 1 0.4304 0.988 0.716 0.000 0.000 0.284
#> GSM1253071 4 0.0000 0.996 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253073 4 0.0188 0.995 0.000 0.000 0.004 0.996
#> GSM1253074 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253032 3 0.1059 0.703 0.016 0.000 0.972 0.012
#> GSM1253034 2 0.0000 0.874 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0592 0.874 0.016 0.984 0.000 0.000
#> GSM1253040 2 0.0592 0.874 0.016 0.984 0.000 0.000
#> GSM1253041 2 0.0000 0.874 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.1677 0.693 0.040 0.000 0.948 0.012
#> GSM1253048 2 0.0000 0.874 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0592 0.874 0.016 0.984 0.000 0.000
#> GSM1253052 3 0.7576 0.619 0.260 0.256 0.484 0.000
#> GSM1253037 2 0.0592 0.874 0.016 0.984 0.000 0.000
#> GSM1253028 3 0.7159 0.693 0.260 0.188 0.552 0.000
#> GSM1253029 2 0.7249 0.177 0.260 0.540 0.200 0.000
#> GSM1253030 2 0.0592 0.874 0.016 0.984 0.000 0.000
#> GSM1253031 3 0.7159 0.693 0.260 0.188 0.552 0.000
#> GSM1253033 3 0.1724 0.692 0.020 0.000 0.948 0.032
#> GSM1253035 3 0.7557 0.625 0.260 0.252 0.488 0.000
#> GSM1253036 2 0.7249 0.177 0.260 0.540 0.200 0.000
#> GSM1253038 2 0.0592 0.874 0.016 0.984 0.000 0.000
#> GSM1253042 2 0.7249 0.177 0.260 0.540 0.200 0.000
#> GSM1253045 3 0.4576 0.736 0.260 0.012 0.728 0.000
#> GSM1253043 3 0.4576 0.736 0.260 0.012 0.728 0.000
#> GSM1253044 2 0.0000 0.874 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.1677 0.693 0.040 0.000 0.948 0.012
#> GSM1253050 2 0.0000 0.874 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.874 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.7576 0.619 0.260 0.256 0.484 0.000
#> GSM1253054 3 0.0592 0.706 0.016 0.000 0.984 0.000
#> GSM1253055 3 0.7159 0.693 0.260 0.188 0.552 0.000
#> GSM1253079 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253083 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253075 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253077 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253076 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253078 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253081 1 0.4304 0.989 0.716 0.000 0.000 0.284
#> GSM1253080 1 0.4250 0.998 0.724 0.000 0.000 0.276
#> GSM1253082 1 0.4304 0.989 0.716 0.000 0.000 0.284
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.2648 0.972 0.152 0.000 0.000 0.848 0.000
#> GSM1253057 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.4903 0.940 0.152 0.000 0.036 0.752 0.060
#> GSM1253059 4 0.4903 0.940 0.152 0.000 0.036 0.752 0.060
#> GSM1253060 4 0.2648 0.972 0.152 0.000 0.000 0.848 0.000
#> GSM1253061 1 0.2932 0.895 0.864 0.000 0.032 0.000 0.104
#> GSM1253062 1 0.0992 0.917 0.968 0.000 0.024 0.000 0.008
#> GSM1253063 4 0.2648 0.972 0.152 0.000 0.000 0.848 0.000
#> GSM1253064 1 0.4071 0.875 0.816 0.000 0.052 0.028 0.104
#> GSM1253065 4 0.3394 0.957 0.152 0.000 0.020 0.824 0.004
#> GSM1253066 1 0.3985 0.878 0.820 0.000 0.052 0.024 0.104
#> GSM1253067 4 0.3516 0.967 0.152 0.000 0.008 0.820 0.020
#> GSM1253068 1 0.3800 0.882 0.828 0.000 0.052 0.016 0.104
#> GSM1253069 1 0.0324 0.919 0.992 0.000 0.004 0.000 0.004
#> GSM1253070 1 0.3170 0.893 0.856 0.000 0.036 0.004 0.104
#> GSM1253071 4 0.2648 0.972 0.152 0.000 0.000 0.848 0.000
#> GSM1253072 1 0.3851 0.882 0.824 0.000 0.052 0.016 0.108
#> GSM1253073 4 0.3606 0.966 0.152 0.000 0.008 0.816 0.024
#> GSM1253074 1 0.0324 0.919 0.992 0.000 0.004 0.000 0.004
#> GSM1253032 5 0.3398 0.998 0.000 0.000 0.216 0.004 0.780
#> GSM1253034 2 0.0162 0.935 0.000 0.996 0.000 0.000 0.004
#> GSM1253039 2 0.3130 0.931 0.000 0.856 0.000 0.096 0.048
#> GSM1253040 2 0.3130 0.931 0.000 0.856 0.000 0.096 0.048
#> GSM1253041 2 0.0162 0.935 0.000 0.996 0.000 0.000 0.004
#> GSM1253046 5 0.3398 0.998 0.000 0.000 0.216 0.004 0.780
#> GSM1253048 2 0.0000 0.935 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.3003 0.933 0.000 0.864 0.000 0.092 0.044
#> GSM1253052 3 0.2984 0.884 0.000 0.108 0.860 0.032 0.000
#> GSM1253037 2 0.3075 0.932 0.000 0.860 0.000 0.092 0.048
#> GSM1253028 3 0.2597 0.885 0.000 0.092 0.884 0.024 0.000
#> GSM1253029 3 0.4066 0.822 0.000 0.196 0.768 0.032 0.004
#> GSM1253030 2 0.2903 0.934 0.000 0.872 0.000 0.080 0.048
#> GSM1253031 3 0.2597 0.885 0.000 0.092 0.884 0.024 0.000
#> GSM1253033 5 0.3398 0.998 0.000 0.000 0.216 0.004 0.780
#> GSM1253035 3 0.2020 0.889 0.000 0.100 0.900 0.000 0.000
#> GSM1253036 3 0.3631 0.826 0.000 0.196 0.788 0.008 0.008
#> GSM1253038 2 0.3130 0.931 0.000 0.856 0.000 0.096 0.048
#> GSM1253042 3 0.4066 0.822 0.000 0.196 0.768 0.032 0.004
#> GSM1253045 3 0.2707 0.760 0.000 0.000 0.876 0.024 0.100
#> GSM1253043 3 0.2707 0.760 0.000 0.000 0.876 0.024 0.100
#> GSM1253044 2 0.0000 0.935 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.3398 0.998 0.000 0.000 0.216 0.004 0.780
#> GSM1253050 2 0.0000 0.935 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0162 0.935 0.000 0.996 0.000 0.000 0.004
#> GSM1253053 3 0.2984 0.884 0.000 0.108 0.860 0.032 0.000
#> GSM1253054 5 0.3274 0.993 0.000 0.000 0.220 0.000 0.780
#> GSM1253055 3 0.2408 0.886 0.000 0.092 0.892 0.016 0.000
#> GSM1253079 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0324 0.919 0.992 0.000 0.004 0.000 0.004
#> GSM1253075 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0162 0.920 0.996 0.000 0.004 0.000 0.000
#> GSM1253076 1 0.0162 0.920 0.996 0.000 0.004 0.000 0.000
#> GSM1253078 1 0.0162 0.920 0.996 0.000 0.004 0.000 0.000
#> GSM1253081 1 0.4381 0.863 0.800 0.000 0.052 0.044 0.104
#> GSM1253080 1 0.0324 0.919 0.992 0.000 0.004 0.000 0.004
#> GSM1253082 1 0.4381 0.863 0.800 0.000 0.052 0.044 0.104
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.1411 0.914 0.060 0.000 0.000 0.936 0.000 0.004
#> GSM1253057 1 0.3942 0.821 0.624 0.000 0.004 0.000 0.004 0.368
#> GSM1253058 4 0.5941 0.792 0.060 0.000 0.044 0.656 0.064 0.176
#> GSM1253059 4 0.5911 0.792 0.060 0.000 0.044 0.660 0.064 0.172
#> GSM1253060 4 0.1610 0.910 0.084 0.000 0.000 0.916 0.000 0.000
#> GSM1253061 1 0.2196 0.780 0.884 0.000 0.004 0.000 0.004 0.108
#> GSM1253062 1 0.3452 0.822 0.736 0.000 0.004 0.000 0.004 0.256
#> GSM1253063 4 0.1267 0.914 0.060 0.000 0.000 0.940 0.000 0.000
#> GSM1253064 1 0.1007 0.737 0.956 0.000 0.000 0.044 0.000 0.000
#> GSM1253065 4 0.2320 0.878 0.132 0.000 0.000 0.864 0.000 0.004
#> GSM1253066 1 0.0790 0.745 0.968 0.000 0.000 0.032 0.000 0.000
#> GSM1253067 4 0.2258 0.906 0.060 0.000 0.000 0.896 0.000 0.044
#> GSM1253068 1 0.0790 0.745 0.968 0.000 0.000 0.032 0.000 0.000
#> GSM1253069 1 0.4187 0.820 0.624 0.000 0.004 0.000 0.016 0.356
#> GSM1253070 1 0.1732 0.771 0.920 0.000 0.004 0.000 0.004 0.072
#> GSM1253071 4 0.1610 0.910 0.084 0.000 0.000 0.916 0.000 0.000
#> GSM1253072 1 0.0790 0.745 0.968 0.000 0.000 0.032 0.000 0.000
#> GSM1253073 4 0.3113 0.899 0.060 0.000 0.020 0.864 0.008 0.048
#> GSM1253074 1 0.4187 0.820 0.624 0.000 0.004 0.000 0.016 0.356
#> GSM1253032 5 0.2006 0.986 0.000 0.000 0.104 0.004 0.892 0.000
#> GSM1253034 2 0.3589 0.876 0.000 0.752 0.000 0.012 0.008 0.228
#> GSM1253039 2 0.0405 0.870 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM1253040 2 0.0405 0.870 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM1253041 2 0.3298 0.877 0.000 0.756 0.000 0.000 0.008 0.236
#> GSM1253046 5 0.2405 0.982 0.000 0.000 0.100 0.004 0.880 0.016
#> GSM1253048 2 0.3323 0.876 0.000 0.752 0.000 0.000 0.008 0.240
#> GSM1253049 2 0.0146 0.872 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM1253052 3 0.4846 0.855 0.000 0.092 0.716 0.036 0.000 0.156
#> GSM1253037 2 0.0146 0.872 0.000 0.996 0.000 0.000 0.004 0.000
#> GSM1253028 3 0.1556 0.856 0.000 0.080 0.920 0.000 0.000 0.000
#> GSM1253029 3 0.5426 0.826 0.000 0.148 0.656 0.036 0.000 0.160
#> GSM1253030 2 0.1261 0.873 0.000 0.952 0.000 0.024 0.000 0.024
#> GSM1253031 3 0.1556 0.856 0.000 0.080 0.920 0.000 0.000 0.000
#> GSM1253033 5 0.2870 0.973 0.000 0.000 0.100 0.004 0.856 0.040
#> GSM1253035 3 0.3852 0.872 0.000 0.092 0.800 0.020 0.000 0.088
#> GSM1253036 3 0.3219 0.837 0.000 0.148 0.820 0.012 0.000 0.020
#> GSM1253038 2 0.0405 0.870 0.000 0.988 0.000 0.000 0.004 0.008
#> GSM1253042 3 0.5426 0.826 0.000 0.148 0.656 0.036 0.000 0.160
#> GSM1253045 3 0.1858 0.766 0.000 0.000 0.904 0.000 0.092 0.004
#> GSM1253043 3 0.1806 0.770 0.000 0.000 0.908 0.000 0.088 0.004
#> GSM1253044 2 0.3323 0.876 0.000 0.752 0.000 0.000 0.008 0.240
#> GSM1253047 5 0.2149 0.985 0.000 0.000 0.104 0.004 0.888 0.004
#> GSM1253050 2 0.3323 0.876 0.000 0.752 0.000 0.000 0.008 0.240
#> GSM1253051 2 0.3589 0.876 0.000 0.752 0.000 0.012 0.008 0.228
#> GSM1253053 3 0.4846 0.855 0.000 0.092 0.716 0.036 0.000 0.156
#> GSM1253054 5 0.2053 0.983 0.000 0.000 0.108 0.000 0.888 0.004
#> GSM1253055 3 0.3439 0.870 0.000 0.080 0.832 0.020 0.000 0.068
#> GSM1253079 1 0.3930 0.822 0.628 0.000 0.004 0.000 0.004 0.364
#> GSM1253083 1 0.4224 0.826 0.660 0.000 0.012 0.000 0.016 0.312
#> GSM1253075 1 0.3972 0.827 0.664 0.000 0.012 0.000 0.004 0.320
#> GSM1253077 1 0.3789 0.826 0.660 0.000 0.008 0.000 0.000 0.332
#> GSM1253076 1 0.3789 0.826 0.660 0.000 0.008 0.000 0.000 0.332
#> GSM1253078 1 0.3789 0.826 0.660 0.000 0.008 0.000 0.000 0.332
#> GSM1253081 1 0.1444 0.713 0.928 0.000 0.000 0.072 0.000 0.000
#> GSM1253080 1 0.4187 0.820 0.624 0.000 0.004 0.000 0.016 0.356
#> GSM1253082 1 0.1444 0.713 0.928 0.000 0.000 0.072 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> CV:kmeans 56 0.018077 1.69e-08 0.955 2
#> CV:kmeans 51 0.011237 2.87e-09 0.897 3
#> CV:kmeans 53 0.000226 6.92e-12 0.914 4
#> CV:kmeans 56 0.000334 2.92e-12 0.862 5
#> CV:kmeans 56 0.000334 2.92e-12 0.862 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.980 0.993 0.4968 0.501 0.501
#> 3 3 1.000 0.997 0.997 0.2190 0.879 0.761
#> 4 4 1.000 0.996 0.995 0.1809 0.889 0.719
#> 5 5 0.955 0.873 0.944 0.0818 0.921 0.730
#> 6 6 0.855 0.630 0.778 0.0499 0.940 0.739
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 3 4
There is also optional best \(k\) = 2 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
#> GSM1253056 1 0.00 1.000 1.000 0.000
#> GSM1253057 1 0.00 1.000 1.000 0.000
#> GSM1253058 1 0.00 1.000 1.000 0.000
#> GSM1253059 1 0.00 1.000 1.000 0.000
#> GSM1253060 1 0.00 1.000 1.000 0.000
#> GSM1253061 1 0.00 1.000 1.000 0.000
#> GSM1253062 1 0.00 1.000 1.000 0.000
#> GSM1253063 1 0.00 1.000 1.000 0.000
#> GSM1253064 1 0.00 1.000 1.000 0.000
#> GSM1253065 1 0.00 1.000 1.000 0.000
#> GSM1253066 1 0.00 1.000 1.000 0.000
#> GSM1253067 1 0.00 1.000 1.000 0.000
#> GSM1253068 1 0.00 1.000 1.000 0.000
#> GSM1253069 1 0.00 1.000 1.000 0.000
#> GSM1253070 1 0.00 1.000 1.000 0.000
#> GSM1253071 1 0.00 1.000 1.000 0.000
#> GSM1253072 1 0.00 1.000 1.000 0.000
#> GSM1253073 1 0.00 1.000 1.000 0.000
#> GSM1253074 1 0.00 1.000 1.000 0.000
#> GSM1253032 1 0.00 1.000 1.000 0.000
#> GSM1253034 2 0.00 0.982 0.000 1.000
#> GSM1253039 2 0.00 0.982 0.000 1.000
#> GSM1253040 2 0.00 0.982 0.000 1.000
#> GSM1253041 2 0.00 0.982 0.000 1.000
#> GSM1253046 1 0.00 1.000 1.000 0.000
#> GSM1253048 2 0.00 0.982 0.000 1.000
#> GSM1253049 2 0.00 0.982 0.000 1.000
#> GSM1253052 2 0.00 0.982 0.000 1.000
#> GSM1253037 2 0.00 0.982 0.000 1.000
#> GSM1253028 2 0.00 0.982 0.000 1.000
#> GSM1253029 2 0.00 0.982 0.000 1.000
#> GSM1253030 2 0.00 0.982 0.000 1.000
#> GSM1253031 2 0.00 0.982 0.000 1.000
#> GSM1253033 1 0.00 1.000 1.000 0.000
#> GSM1253035 2 0.00 0.982 0.000 1.000
#> GSM1253036 2 0.00 0.982 0.000 1.000
#> GSM1253038 2 0.00 0.982 0.000 1.000
#> GSM1253042 2 0.00 0.982 0.000 1.000
#> GSM1253045 2 0.00 0.982 0.000 1.000
#> GSM1253043 2 0.00 0.982 0.000 1.000
#> GSM1253044 2 0.00 0.982 0.000 1.000
#> GSM1253047 1 0.00 1.000 1.000 0.000
#> GSM1253050 2 0.00 0.982 0.000 1.000
#> GSM1253051 2 0.00 0.982 0.000 1.000
#> GSM1253053 2 0.00 0.982 0.000 1.000
#> GSM1253054 2 0.98 0.288 0.416 0.584
#> GSM1253055 2 0.00 0.982 0.000 1.000
#> GSM1253079 1 0.00 1.000 1.000 0.000
#> GSM1253083 1 0.00 1.000 1.000 0.000
#> GSM1253075 1 0.00 1.000 1.000 0.000
#> GSM1253077 1 0.00 1.000 1.000 0.000
#> GSM1253076 1 0.00 1.000 1.000 0.000
#> GSM1253078 1 0.00 1.000 1.000 0.000
#> GSM1253081 1 0.00 1.000 1.000 0.000
#> GSM1253080 1 0.00 1.000 1.000 0.000
#> GSM1253082 1 0.00 1.000 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253057 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253058 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253059 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253060 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253061 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253063 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253064 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253065 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253066 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253067 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253068 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253070 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253071 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253072 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253073 1 0.0592 0.993 0.988 0.000 0.012
#> GSM1253074 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253032 3 0.0237 0.995 0.004 0.000 0.996
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253046 3 0.0237 0.995 0.004 0.000 0.996
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253033 3 0.0237 0.995 0.004 0.000 0.996
#> GSM1253035 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253045 3 0.0592 0.990 0.000 0.012 0.988
#> GSM1253043 3 0.0592 0.990 0.000 0.012 0.988
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253047 3 0.0237 0.995 0.004 0.000 0.996
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253054 3 0.0475 0.994 0.004 0.004 0.992
#> GSM1253055 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.996 1.000 0.000 0.000
#> GSM1253082 1 0.0237 0.995 0.996 0.000 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253057 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253059 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253060 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253061 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253064 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253066 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253068 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253072 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.0592 1.000 0.016 0.000 0.000 0.984
#> GSM1253074 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253052 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM1253037 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253028 2 0.0592 0.989 0.000 0.984 0.000 0.016
#> GSM1253029 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM1253030 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253031 2 0.0592 0.989 0.000 0.984 0.000 0.016
#> GSM1253033 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> GSM1253035 2 0.0592 0.989 0.000 0.984 0.000 0.016
#> GSM1253036 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM1253038 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253042 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM1253045 3 0.0592 0.989 0.000 0.000 0.984 0.016
#> GSM1253043 3 0.0592 0.989 0.000 0.000 0.984 0.016
#> GSM1253044 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> GSM1253053 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> GSM1253054 3 0.0000 0.996 0.000 0.000 1.000 0.000
#> GSM1253055 2 0.0592 0.989 0.000 0.984 0.000 0.016
#> GSM1253079 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.0707 0.980 0.980 0.000 0.000 0.020
#> GSM1253080 1 0.0000 0.998 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.0707 0.980 0.980 0.000 0.000 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253057 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253059 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253060 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253061 1 0.1043 0.9733 0.960 0.000 0.040 0.000 0.000
#> GSM1253062 1 0.0290 0.9796 0.992 0.000 0.008 0.000 0.000
#> GSM1253063 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253064 1 0.1197 0.9710 0.952 0.000 0.048 0.000 0.000
#> GSM1253065 4 0.0290 0.9916 0.000 0.000 0.008 0.992 0.000
#> GSM1253066 1 0.1197 0.9710 0.952 0.000 0.048 0.000 0.000
#> GSM1253067 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253068 1 0.1197 0.9710 0.952 0.000 0.048 0.000 0.000
#> GSM1253069 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0963 0.9744 0.964 0.000 0.036 0.000 0.000
#> GSM1253071 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253072 1 0.1197 0.9710 0.952 0.000 0.048 0.000 0.000
#> GSM1253073 4 0.0000 0.9990 0.000 0.000 0.000 1.000 0.000
#> GSM1253074 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM1253048 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.4268 0.3615 0.000 0.444 0.556 0.000 0.000
#> GSM1253037 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.1282 0.7408 0.000 0.044 0.952 0.000 0.004
#> GSM1253029 3 0.4268 0.3615 0.000 0.444 0.556 0.000 0.000
#> GSM1253030 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253031 3 0.1282 0.7408 0.000 0.044 0.952 0.000 0.004
#> GSM1253033 5 0.0000 1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM1253035 3 0.1544 0.7394 0.000 0.068 0.932 0.000 0.000
#> GSM1253036 2 0.4278 -0.0287 0.000 0.548 0.452 0.000 0.000
#> GSM1253038 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 2 0.4088 0.2126 0.000 0.632 0.368 0.000 0.000
#> GSM1253045 3 0.3636 0.3983 0.000 0.000 0.728 0.000 0.272
#> GSM1253043 3 0.1197 0.6937 0.000 0.000 0.952 0.000 0.048
#> GSM1253044 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM1253050 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.9198 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 3 0.4268 0.3615 0.000 0.444 0.556 0.000 0.000
#> GSM1253054 5 0.0000 1.0000 0.000 0.000 0.000 0.000 1.000
#> GSM1253055 3 0.1282 0.7408 0.000 0.044 0.952 0.000 0.004
#> GSM1253079 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.1800 0.9587 0.932 0.000 0.048 0.020 0.000
#> GSM1253080 1 0.0000 0.9805 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.1981 0.9521 0.924 0.000 0.048 0.028 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0458 0.968 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM1253057 6 0.3868 0.900 0.492 0.000 0.000 0.000 0.000 0.508
#> GSM1253058 4 0.0865 0.961 0.000 0.000 0.000 0.964 0.000 0.036
#> GSM1253059 4 0.0865 0.961 0.000 0.000 0.000 0.964 0.000 0.036
#> GSM1253060 4 0.0547 0.967 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM1253061 1 0.2664 0.332 0.816 0.000 0.000 0.000 0.000 0.184
#> GSM1253062 1 0.3428 -0.218 0.696 0.000 0.000 0.000 0.000 0.304
#> GSM1253063 4 0.0458 0.968 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM1253064 1 0.0790 0.508 0.968 0.000 0.000 0.032 0.000 0.000
#> GSM1253065 4 0.1765 0.901 0.096 0.000 0.000 0.904 0.000 0.000
#> GSM1253066 1 0.0146 0.514 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM1253067 4 0.0547 0.965 0.000 0.000 0.000 0.980 0.000 0.020
#> GSM1253068 1 0.0000 0.514 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253069 6 0.3857 0.951 0.468 0.000 0.000 0.000 0.000 0.532
#> GSM1253070 1 0.2092 0.427 0.876 0.000 0.000 0.000 0.000 0.124
#> GSM1253071 4 0.0547 0.967 0.020 0.000 0.000 0.980 0.000 0.000
#> GSM1253072 1 0.0260 0.512 0.992 0.000 0.000 0.000 0.000 0.008
#> GSM1253073 4 0.0632 0.964 0.000 0.000 0.000 0.976 0.000 0.024
#> GSM1253074 6 0.3857 0.951 0.468 0.000 0.000 0.000 0.000 0.532
#> GSM1253032 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.3468 0.548 0.000 0.284 0.712 0.000 0.000 0.004
#> GSM1253037 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.3765 0.566 0.000 0.000 0.596 0.000 0.000 0.404
#> GSM1253029 3 0.3468 0.548 0.000 0.284 0.712 0.000 0.000 0.004
#> GSM1253030 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253031 3 0.3765 0.566 0.000 0.000 0.596 0.000 0.000 0.404
#> GSM1253033 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253035 3 0.0972 0.612 0.000 0.028 0.964 0.000 0.000 0.008
#> GSM1253036 2 0.3404 0.626 0.000 0.760 0.224 0.000 0.000 0.016
#> GSM1253038 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.3950 0.244 0.000 0.432 0.564 0.000 0.000 0.004
#> GSM1253045 3 0.5167 0.472 0.000 0.000 0.500 0.000 0.088 0.412
#> GSM1253043 3 0.3804 0.560 0.000 0.000 0.576 0.000 0.000 0.424
#> GSM1253044 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.3468 0.548 0.000 0.284 0.712 0.000 0.000 0.004
#> GSM1253054 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.0260 0.605 0.000 0.000 0.992 0.000 0.000 0.008
#> GSM1253079 1 0.3854 -0.781 0.536 0.000 0.000 0.000 0.000 0.464
#> GSM1253083 6 0.3869 0.877 0.500 0.000 0.000 0.000 0.000 0.500
#> GSM1253075 1 0.3797 -0.684 0.580 0.000 0.000 0.000 0.000 0.420
#> GSM1253077 1 0.3868 -0.898 0.504 0.000 0.000 0.000 0.000 0.496
#> GSM1253076 1 0.3868 -0.898 0.504 0.000 0.000 0.000 0.000 0.496
#> GSM1253078 1 0.3868 -0.898 0.504 0.000 0.000 0.000 0.000 0.496
#> GSM1253081 1 0.1007 0.501 0.956 0.000 0.000 0.044 0.000 0.000
#> GSM1253080 6 0.3857 0.951 0.468 0.000 0.000 0.000 0.000 0.532
#> GSM1253082 1 0.1204 0.490 0.944 0.000 0.000 0.056 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> CV:skmeans 55 0.015882 6.02e-09 0.956 2
#> CV:skmeans 56 0.004693 2.40e-10 0.902 3
#> CV:skmeans 56 0.000111 2.41e-11 0.905 4
#> CV:skmeans 50 0.001286 1.08e-10 0.837 5
#> CV:skmeans 45 0.024755 2.01e-07 0.662 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.970 0.988 0.4906 0.514 0.514
#> 3 3 0.669 0.791 0.802 0.3289 0.788 0.596
#> 4 4 0.897 0.918 0.942 0.1522 0.880 0.650
#> 5 5 0.952 0.904 0.965 0.0502 0.903 0.645
#> 6 6 0.984 0.961 0.966 0.0575 0.943 0.735
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
#> GSM1253056 1 0.0000 0.980 1.000 0.000
#> GSM1253057 1 0.0000 0.980 1.000 0.000
#> GSM1253058 1 0.0000 0.980 1.000 0.000
#> GSM1253059 1 0.0000 0.980 1.000 0.000
#> GSM1253060 1 0.0000 0.980 1.000 0.000
#> GSM1253061 1 0.0000 0.980 1.000 0.000
#> GSM1253062 1 0.0000 0.980 1.000 0.000
#> GSM1253063 1 0.0000 0.980 1.000 0.000
#> GSM1253064 1 0.0000 0.980 1.000 0.000
#> GSM1253065 1 0.0000 0.980 1.000 0.000
#> GSM1253066 1 0.0000 0.980 1.000 0.000
#> GSM1253067 1 0.0000 0.980 1.000 0.000
#> GSM1253068 1 0.0000 0.980 1.000 0.000
#> GSM1253069 1 0.0000 0.980 1.000 0.000
#> GSM1253070 1 0.0000 0.980 1.000 0.000
#> GSM1253071 1 0.0000 0.980 1.000 0.000
#> GSM1253072 1 0.0000 0.980 1.000 0.000
#> GSM1253073 1 0.0000 0.980 1.000 0.000
#> GSM1253074 1 0.0000 0.980 1.000 0.000
#> GSM1253032 1 0.1184 0.966 0.984 0.016
#> GSM1253034 2 0.0000 1.000 0.000 1.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000
#> GSM1253046 1 0.0000 0.980 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000
#> GSM1253033 1 0.0000 0.980 1.000 0.000
#> GSM1253035 2 0.0000 1.000 0.000 1.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000
#> GSM1253045 2 0.0000 1.000 0.000 1.000
#> GSM1253043 1 0.9866 0.259 0.568 0.432
#> GSM1253044 2 0.0000 1.000 0.000 1.000
#> GSM1253047 1 0.0376 0.977 0.996 0.004
#> GSM1253050 2 0.0000 1.000 0.000 1.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000
#> GSM1253054 1 0.7299 0.742 0.796 0.204
#> GSM1253055 2 0.0000 1.000 0.000 1.000
#> GSM1253079 1 0.0000 0.980 1.000 0.000
#> GSM1253083 1 0.0000 0.980 1.000 0.000
#> GSM1253075 1 0.0000 0.980 1.000 0.000
#> GSM1253077 1 0.0000 0.980 1.000 0.000
#> GSM1253076 1 0.0000 0.980 1.000 0.000
#> GSM1253078 1 0.0000 0.980 1.000 0.000
#> GSM1253081 1 0.0000 0.980 1.000 0.000
#> GSM1253080 1 0.0000 0.980 1.000 0.000
#> GSM1253082 1 0.0000 0.980 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253057 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253058 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253059 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253060 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253061 1 0.1031 0.835 0.976 0.000 0.024
#> GSM1253062 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253063 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253064 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253065 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253066 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253067 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253068 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253069 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253070 3 0.6274 0.785 0.456 0.000 0.544
#> GSM1253071 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253072 1 0.4555 0.452 0.800 0.000 0.200
#> GSM1253073 1 0.0000 0.864 1.000 0.000 0.000
#> GSM1253074 3 0.6140 0.857 0.404 0.000 0.596
#> GSM1253032 1 0.7492 0.437 0.608 0.340 0.052
#> GSM1253034 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253039 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253040 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253041 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253046 3 0.8047 0.677 0.256 0.112 0.632
#> GSM1253048 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253049 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253052 2 0.0000 0.789 0.000 1.000 0.000
#> GSM1253037 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253028 2 0.1860 0.763 0.000 0.948 0.052
#> GSM1253029 2 0.0000 0.789 0.000 1.000 0.000
#> GSM1253030 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253031 2 0.1860 0.763 0.000 0.948 0.052
#> GSM1253033 1 0.5138 0.662 0.828 0.120 0.052
#> GSM1253035 2 0.1860 0.763 0.000 0.948 0.052
#> GSM1253036 2 0.0000 0.789 0.000 1.000 0.000
#> GSM1253038 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253042 2 0.0000 0.789 0.000 1.000 0.000
#> GSM1253045 3 0.6192 0.328 0.000 0.420 0.580
#> GSM1253043 3 0.8731 0.296 0.116 0.368 0.516
#> GSM1253044 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253047 3 0.8103 0.668 0.248 0.120 0.632
#> GSM1253050 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253051 2 0.5882 0.851 0.000 0.652 0.348
#> GSM1253053 2 0.0892 0.780 0.000 0.980 0.020
#> GSM1253054 1 0.7607 0.414 0.584 0.364 0.052
#> GSM1253055 2 0.1860 0.763 0.000 0.948 0.052
#> GSM1253079 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253083 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253075 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253077 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253076 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253078 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253081 1 0.0424 0.856 0.992 0.000 0.008
#> GSM1253080 3 0.6126 0.861 0.400 0.000 0.600
#> GSM1253082 1 0.0747 0.848 0.984 0.000 0.016
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253057 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253059 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253060 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253061 4 0.3688 0.830 0.208 0.000 0.000 0.792
#> GSM1253062 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253064 4 0.3528 0.845 0.192 0.000 0.000 0.808
#> GSM1253065 4 0.2011 0.901 0.080 0.000 0.000 0.920
#> GSM1253066 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253068 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.2011 0.885 0.920 0.000 0.000 0.080
#> GSM1253071 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253072 4 0.4977 0.375 0.460 0.000 0.000 0.540
#> GSM1253073 4 0.1867 0.904 0.072 0.000 0.000 0.928
#> GSM1253074 1 0.0188 0.959 0.996 0.000 0.000 0.004
#> GSM1253032 4 0.4543 0.459 0.000 0.000 0.324 0.676
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.4362 0.804 0.816 0.000 0.096 0.088
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.2011 0.934 0.000 0.080 0.920 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.2011 0.934 0.000 0.080 0.920 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM1253033 4 0.2805 0.792 0.012 0.000 0.100 0.888
#> GSM1253035 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.2011 0.934 0.000 0.080 0.920 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.2011 0.934 0.000 0.080 0.920 0.000
#> GSM1253045 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.5610 0.698 0.720 0.000 0.176 0.104
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.1022 0.954 0.000 0.032 0.968 0.000
#> GSM1253054 3 0.1867 0.917 0.000 0.000 0.928 0.072
#> GSM1253055 3 0.0000 0.960 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253081 4 0.3311 0.861 0.172 0.000 0.000 0.828
#> GSM1253080 1 0.0000 0.962 1.000 0.000 0.000 0.000
#> GSM1253082 4 0.3400 0.856 0.180 0.000 0.000 0.820
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253057 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253059 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253060 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253061 1 0.4088 0.406 0.632 0 0.000 0.368 0.000
#> GSM1253062 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253063 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253064 1 0.4088 0.406 0.632 0 0.000 0.368 0.000
#> GSM1253065 4 0.0162 0.882 0.004 0 0.000 0.996 0.000
#> GSM1253066 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253067 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253068 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253070 1 0.0609 0.909 0.980 0 0.000 0.020 0.000
#> GSM1253071 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253072 1 0.3730 0.569 0.712 0 0.000 0.288 0.000
#> GSM1253073 4 0.0000 0.885 0.000 0 0.000 1.000 0.000
#> GSM1253074 1 0.0162 0.921 0.996 0 0.000 0.004 0.000
#> GSM1253032 5 0.0000 0.998 0.000 0 0.000 0.000 1.000
#> GSM1253034 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.998 0.000 0 0.000 0.000 1.000
#> GSM1253048 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253052 3 0.0000 0.996 0.000 0 1.000 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253028 3 0.0290 0.995 0.000 0 0.992 0.000 0.008
#> GSM1253029 3 0.0000 0.996 0.000 0 1.000 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253031 3 0.0290 0.995 0.000 0 0.992 0.000 0.008
#> GSM1253033 5 0.0290 0.990 0.000 0 0.000 0.008 0.992
#> GSM1253035 3 0.0000 0.996 0.000 0 1.000 0.000 0.000
#> GSM1253036 3 0.0000 0.996 0.000 0 1.000 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253042 3 0.0000 0.996 0.000 0 1.000 0.000 0.000
#> GSM1253045 3 0.0290 0.995 0.000 0 0.992 0.000 0.008
#> GSM1253043 3 0.0290 0.995 0.000 0 0.992 0.000 0.008
#> GSM1253044 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.998 0.000 0 0.000 0.000 1.000
#> GSM1253050 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> GSM1253053 3 0.0000 0.996 0.000 0 1.000 0.000 0.000
#> GSM1253054 5 0.0000 0.998 0.000 0 0.000 0.000 1.000
#> GSM1253055 3 0.0290 0.995 0.000 0 0.992 0.000 0.008
#> GSM1253079 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253081 4 0.4210 0.255 0.412 0 0.000 0.588 0.000
#> GSM1253080 1 0.0000 0.924 1.000 0 0.000 0.000 0.000
#> GSM1253082 4 0.4249 0.193 0.432 0 0.000 0.568 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253057 1 0.0000 0.927 1.000 0 0.000 0.000 0 0.000
#> GSM1253058 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253059 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253060 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253061 6 0.3384 0.876 0.120 0 0.000 0.068 0 0.812
#> GSM1253062 1 0.2664 0.834 0.816 0 0.000 0.000 0 0.184
#> GSM1253063 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253064 6 0.1838 0.946 0.016 0 0.000 0.068 0 0.916
#> GSM1253065 4 0.0146 0.995 0.000 0 0.000 0.996 0 0.004
#> GSM1253066 6 0.1610 0.907 0.084 0 0.000 0.000 0 0.916
#> GSM1253067 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253068 6 0.1610 0.907 0.084 0 0.000 0.000 0 0.916
#> GSM1253069 1 0.0000 0.927 1.000 0 0.000 0.000 0 0.000
#> GSM1253070 1 0.3076 0.702 0.760 0 0.000 0.000 0 0.240
#> GSM1253071 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253072 6 0.1838 0.946 0.016 0 0.000 0.068 0 0.916
#> GSM1253073 4 0.0000 0.999 0.000 0 0.000 1.000 0 0.000
#> GSM1253074 1 0.0000 0.927 1.000 0 0.000 0.000 0 0.000
#> GSM1253032 5 0.0000 1.000 0.000 0 0.000 0.000 1 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253046 5 0.0000 1.000 0.000 0 0.000 0.000 1 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253052 3 0.1610 0.949 0.000 0 0.916 0.000 0 0.084
#> GSM1253037 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253028 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253029 3 0.1610 0.949 0.000 0 0.916 0.000 0 0.084
#> GSM1253030 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253031 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253033 5 0.0000 1.000 0.000 0 0.000 0.000 1 0.000
#> GSM1253035 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253036 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253042 3 0.1610 0.949 0.000 0 0.916 0.000 0 0.084
#> GSM1253045 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253043 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253047 5 0.0000 1.000 0.000 0 0.000 0.000 1 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1 0.000 0.000 0 0.000
#> GSM1253053 3 0.1610 0.949 0.000 0 0.916 0.000 0 0.084
#> GSM1253054 5 0.0000 1.000 0.000 0 0.000 0.000 1 0.000
#> GSM1253055 3 0.0000 0.972 0.000 0 1.000 0.000 0 0.000
#> GSM1253079 1 0.0937 0.917 0.960 0 0.000 0.000 0 0.040
#> GSM1253083 1 0.1204 0.920 0.944 0 0.000 0.000 0 0.056
#> GSM1253075 1 0.1387 0.917 0.932 0 0.000 0.000 0 0.068
#> GSM1253077 1 0.0146 0.927 0.996 0 0.000 0.000 0 0.004
#> GSM1253076 1 0.1910 0.895 0.892 0 0.000 0.000 0 0.108
#> GSM1253078 1 0.1501 0.912 0.924 0 0.000 0.000 0 0.076
#> GSM1253081 6 0.1838 0.946 0.016 0 0.000 0.068 0 0.916
#> GSM1253080 1 0.0000 0.927 1.000 0 0.000 0.000 0 0.000
#> GSM1253082 6 0.1838 0.946 0.016 0 0.000 0.068 0 0.916
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 infection(p) disease.state(p) individual(p) k
#> CV:pam 55 0.021088 2.77e-08 0.962 2
#> CV:pam 51 0.002346 2.27e-08 0.663 3
#> CV:pam 54 0.004017 2.84e-10 0.605 4
#> CV:pam 52 0.000510 2.18e-11 0.817 5
#> CV:pam 56 0.000239 1.10e-11 0.786 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.998 0.999 0.5095 0.491 0.491
#> 3 3 0.906 0.963 0.961 0.2396 0.873 0.741
#> 4 4 0.877 0.871 0.927 0.1868 0.845 0.594
#> 5 5 0.907 0.937 0.920 0.0597 0.953 0.809
#> 6 6 0.990 0.983 0.988 0.0541 0.964 0.820
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 5
There is also optional best \(k\) = 2 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
#> GSM1253056 1 0.000 0.998 1.000 0.000
#> GSM1253057 1 0.000 0.998 1.000 0.000
#> GSM1253058 1 0.000 0.998 1.000 0.000
#> GSM1253059 1 0.000 0.998 1.000 0.000
#> GSM1253060 1 0.000 0.998 1.000 0.000
#> GSM1253061 1 0.000 0.998 1.000 0.000
#> GSM1253062 1 0.000 0.998 1.000 0.000
#> GSM1253063 1 0.000 0.998 1.000 0.000
#> GSM1253064 1 0.000 0.998 1.000 0.000
#> GSM1253065 1 0.000 0.998 1.000 0.000
#> GSM1253066 1 0.000 0.998 1.000 0.000
#> GSM1253067 1 0.000 0.998 1.000 0.000
#> GSM1253068 1 0.000 0.998 1.000 0.000
#> GSM1253069 1 0.000 0.998 1.000 0.000
#> GSM1253070 1 0.343 0.932 0.936 0.064
#> GSM1253071 1 0.000 0.998 1.000 0.000
#> GSM1253072 1 0.000 0.998 1.000 0.000
#> GSM1253073 1 0.000 0.998 1.000 0.000
#> GSM1253074 1 0.000 0.998 1.000 0.000
#> GSM1253032 2 0.000 1.000 0.000 1.000
#> GSM1253034 2 0.000 1.000 0.000 1.000
#> GSM1253039 2 0.000 1.000 0.000 1.000
#> GSM1253040 2 0.000 1.000 0.000 1.000
#> GSM1253041 2 0.000 1.000 0.000 1.000
#> GSM1253046 2 0.000 1.000 0.000 1.000
#> GSM1253048 2 0.000 1.000 0.000 1.000
#> GSM1253049 2 0.000 1.000 0.000 1.000
#> GSM1253052 2 0.000 1.000 0.000 1.000
#> GSM1253037 2 0.000 1.000 0.000 1.000
#> GSM1253028 2 0.000 1.000 0.000 1.000
#> GSM1253029 2 0.000 1.000 0.000 1.000
#> GSM1253030 2 0.000 1.000 0.000 1.000
#> GSM1253031 2 0.000 1.000 0.000 1.000
#> GSM1253033 2 0.000 1.000 0.000 1.000
#> GSM1253035 2 0.000 1.000 0.000 1.000
#> GSM1253036 2 0.000 1.000 0.000 1.000
#> GSM1253038 2 0.000 1.000 0.000 1.000
#> GSM1253042 2 0.000 1.000 0.000 1.000
#> GSM1253045 2 0.000 1.000 0.000 1.000
#> GSM1253043 2 0.000 1.000 0.000 1.000
#> GSM1253044 2 0.000 1.000 0.000 1.000
#> GSM1253047 2 0.000 1.000 0.000 1.000
#> GSM1253050 2 0.000 1.000 0.000 1.000
#> GSM1253051 2 0.000 1.000 0.000 1.000
#> GSM1253053 2 0.000 1.000 0.000 1.000
#> GSM1253054 2 0.000 1.000 0.000 1.000
#> GSM1253055 2 0.000 1.000 0.000 1.000
#> GSM1253079 1 0.000 0.998 1.000 0.000
#> GSM1253083 1 0.000 0.998 1.000 0.000
#> GSM1253075 1 0.000 0.998 1.000 0.000
#> GSM1253077 1 0.000 0.998 1.000 0.000
#> GSM1253076 1 0.000 0.998 1.000 0.000
#> GSM1253078 1 0.000 0.998 1.000 0.000
#> GSM1253081 1 0.000 0.998 1.000 0.000
#> GSM1253080 1 0.000 0.998 1.000 0.000
#> GSM1253082 1 0.000 0.998 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253057 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253058 1 0.1529 0.976 0.960 0.000 0.040
#> GSM1253059 1 0.1529 0.976 0.960 0.000 0.040
#> GSM1253060 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253061 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253063 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253064 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253065 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253066 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253067 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253068 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253070 1 0.1529 0.963 0.960 0.000 0.040
#> GSM1253071 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253072 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253073 1 0.1289 0.980 0.968 0.000 0.032
#> GSM1253074 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253032 3 0.1289 0.897 0.000 0.032 0.968
#> GSM1253034 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253046 3 0.1289 0.897 0.000 0.032 0.968
#> GSM1253048 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253052 3 0.4504 0.903 0.000 0.196 0.804
#> GSM1253037 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253028 3 0.4121 0.905 0.000 0.168 0.832
#> GSM1253029 3 0.4504 0.903 0.000 0.196 0.804
#> GSM1253030 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253031 2 0.3551 0.838 0.000 0.868 0.132
#> GSM1253033 3 0.1289 0.897 0.000 0.032 0.968
#> GSM1253035 3 0.4504 0.903 0.000 0.196 0.804
#> GSM1253036 2 0.0237 0.984 0.000 0.996 0.004
#> GSM1253038 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253042 3 0.4555 0.900 0.000 0.200 0.800
#> GSM1253045 3 0.2448 0.910 0.000 0.076 0.924
#> GSM1253043 3 0.2878 0.914 0.000 0.096 0.904
#> GSM1253044 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253047 3 0.1289 0.897 0.000 0.032 0.968
#> GSM1253050 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.988 0.000 1.000 0.000
#> GSM1253053 3 0.4504 0.903 0.000 0.196 0.804
#> GSM1253054 3 0.2261 0.909 0.000 0.068 0.932
#> GSM1253055 3 0.4504 0.903 0.000 0.196 0.804
#> GSM1253079 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.989 1.000 0.000 0.000
#> GSM1253082 1 0.0000 0.989 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.4972 0.740 0.000 0.000 0.456 0.544
#> GSM1253057 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253058 4 0.4972 0.740 0.000 0.000 0.456 0.544
#> GSM1253059 4 0.4972 0.740 0.000 0.000 0.456 0.544
#> GSM1253060 4 0.4955 0.741 0.000 0.000 0.444 0.556
#> GSM1253061 4 0.0000 0.518 0.000 0.000 0.000 1.000
#> GSM1253062 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253063 4 0.4972 0.740 0.000 0.000 0.456 0.544
#> GSM1253064 4 0.0592 0.532 0.000 0.000 0.016 0.984
#> GSM1253065 4 0.4948 0.741 0.000 0.000 0.440 0.560
#> GSM1253066 4 0.0000 0.518 0.000 0.000 0.000 1.000
#> GSM1253067 4 0.4972 0.740 0.000 0.000 0.456 0.544
#> GSM1253068 4 0.0000 0.518 0.000 0.000 0.000 1.000
#> GSM1253069 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253070 4 0.3900 0.536 0.164 0.000 0.020 0.816
#> GSM1253071 4 0.4955 0.741 0.000 0.000 0.444 0.556
#> GSM1253072 4 0.0000 0.518 0.000 0.000 0.000 1.000
#> GSM1253073 4 0.4972 0.740 0.000 0.000 0.456 0.544
#> GSM1253074 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253032 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253034 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253048 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253037 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253029 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253030 2 0.0336 0.957 0.008 0.992 0.000 0.000
#> GSM1253031 3 0.5564 0.980 0.436 0.020 0.544 0.000
#> GSM1253033 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253035 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253036 3 0.5564 0.980 0.436 0.020 0.544 0.000
#> GSM1253038 2 0.5929 0.435 0.296 0.640 0.064 0.000
#> GSM1253042 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253045 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253043 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253044 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253050 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253054 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253055 3 0.4972 0.997 0.456 0.000 0.544 0.000
#> GSM1253079 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253083 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253075 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253077 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253076 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253078 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253081 4 0.0000 0.518 0.000 0.000 0.000 1.000
#> GSM1253080 1 0.4972 1.000 0.544 0.000 0.000 0.456
#> GSM1253082 4 0.0000 0.518 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253057 1 0.1270 0.941 0.948 0.000 0.000 0.000 0.052
#> GSM1253058 4 0.0000 0.991 0.000 0.000 0.000 1.000 0.000
#> GSM1253059 4 0.0000 0.991 0.000 0.000 0.000 1.000 0.000
#> GSM1253060 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253061 5 0.3636 0.938 0.272 0.000 0.000 0.000 0.728
#> GSM1253062 1 0.1270 0.941 0.948 0.000 0.000 0.000 0.052
#> GSM1253063 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253064 5 0.3636 0.938 0.272 0.000 0.000 0.000 0.728
#> GSM1253065 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253066 5 0.3707 0.939 0.284 0.000 0.000 0.000 0.716
#> GSM1253067 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253068 5 0.3707 0.939 0.284 0.000 0.000 0.000 0.716
#> GSM1253069 1 0.1197 0.943 0.952 0.000 0.000 0.000 0.048
#> GSM1253070 5 0.6381 0.629 0.240 0.000 0.196 0.008 0.556
#> GSM1253071 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253072 5 0.3707 0.939 0.284 0.000 0.000 0.000 0.716
#> GSM1253073 4 0.0290 0.997 0.008 0.000 0.000 0.992 0.000
#> GSM1253074 1 0.2230 0.855 0.884 0.000 0.000 0.000 0.116
#> GSM1253032 3 0.3636 0.814 0.000 0.000 0.728 0.000 0.272
#> GSM1253034 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 3 0.3636 0.814 0.000 0.000 0.728 0.000 0.272
#> GSM1253048 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253037 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253029 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253030 2 0.0162 0.989 0.000 0.996 0.004 0.000 0.000
#> GSM1253031 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253033 3 0.3636 0.814 0.000 0.000 0.728 0.000 0.272
#> GSM1253035 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253036 3 0.0703 0.907 0.000 0.024 0.976 0.000 0.000
#> GSM1253038 2 0.1544 0.918 0.000 0.932 0.068 0.000 0.000
#> GSM1253042 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253043 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253044 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 3 0.3636 0.814 0.000 0.000 0.728 0.000 0.272
#> GSM1253050 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.992 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253054 3 0.3636 0.814 0.000 0.000 0.728 0.000 0.272
#> GSM1253055 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253079 1 0.1410 0.934 0.940 0.000 0.000 0.000 0.060
#> GSM1253083 1 0.0000 0.954 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.954 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.954 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0162 0.950 0.996 0.000 0.000 0.004 0.000
#> GSM1253078 1 0.0000 0.954 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 5 0.3707 0.939 0.284 0.000 0.000 0.000 0.716
#> GSM1253080 1 0.0000 0.954 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 5 0.3636 0.938 0.272 0.000 0.000 0.000 0.728
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253057 1 0.2135 0.899 0.872 0 0 0 0.000 0.128
#> GSM1253058 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253059 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253060 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253061 6 0.0000 0.999 0.000 0 0 0 0.000 1.000
#> GSM1253062 1 0.2300 0.889 0.856 0 0 0 0.000 0.144
#> GSM1253063 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253064 6 0.0000 0.999 0.000 0 0 0 0.000 1.000
#> GSM1253065 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253066 6 0.0000 0.999 0.000 0 0 0 0.000 1.000
#> GSM1253067 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253068 6 0.0000 0.999 0.000 0 0 0 0.000 1.000
#> GSM1253069 1 0.1387 0.920 0.932 0 0 0 0.000 0.068
#> GSM1253070 6 0.0146 0.995 0.000 0 0 0 0.004 0.996
#> GSM1253071 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253072 6 0.0000 0.999 0.000 0 0 0 0.000 1.000
#> GSM1253073 4 0.0000 1.000 0.000 0 0 1 0.000 0.000
#> GSM1253074 1 0.2260 0.893 0.860 0 0 0 0.000 0.140
#> GSM1253032 5 0.0000 1.000 0.000 0 0 0 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253046 5 0.0000 1.000 0.000 0 0 0 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253052 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253028 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253029 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253031 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253033 5 0.0000 1.000 0.000 0 0 0 1.000 0.000
#> GSM1253035 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253036 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253042 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253045 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253043 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253047 5 0.0000 1.000 0.000 0 0 0 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1 0 0 0.000 0.000
#> GSM1253053 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253054 5 0.0000 1.000 0.000 0 0 0 1.000 0.000
#> GSM1253055 3 0.0000 1.000 0.000 0 1 0 0.000 0.000
#> GSM1253079 1 0.2527 0.866 0.832 0 0 0 0.000 0.168
#> GSM1253083 1 0.0000 0.930 1.000 0 0 0 0.000 0.000
#> GSM1253075 1 0.0000 0.930 1.000 0 0 0 0.000 0.000
#> GSM1253077 1 0.0000 0.930 1.000 0 0 0 0.000 0.000
#> GSM1253076 1 0.0000 0.930 1.000 0 0 0 0.000 0.000
#> GSM1253078 1 0.0000 0.930 1.000 0 0 0 0.000 0.000
#> GSM1253081 6 0.0000 0.999 0.000 0 0 0 0.000 1.000
#> GSM1253080 1 0.0000 0.930 1.000 0 0 0 0.000 0.000
#> GSM1253082 6 0.0000 0.999 0.000 0 0 0 0.000 1.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 infection(p) disease.state(p) individual(p) k
#> CV:mclust 56 3.60e-03 4.20e-12 0.995 2
#> CV:mclust 56 4.69e-03 2.85e-11 0.932 3
#> CV:mclust 55 3.17e-05 4.79e-14 0.806 4
#> CV:mclust 56 3.15e-05 6.30e-13 0.853 5
#> CV:mclust 56 8.89e-05 3.40e-12 0.778 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.986 0.994 0.49523 0.507 0.507
#> 3 3 0.786 0.808 0.921 0.30173 0.829 0.672
#> 4 4 0.927 0.886 0.955 0.15249 0.834 0.582
#> 5 5 0.945 0.884 0.963 0.00267 0.960 0.858
#> 6 6 0.842 0.785 0.881 0.01852 0.974 0.904
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
#> GSM1253056 1 0.000 0.990 1.00 0.00
#> GSM1253057 1 0.000 0.990 1.00 0.00
#> GSM1253058 1 0.000 0.990 1.00 0.00
#> GSM1253059 1 0.000 0.990 1.00 0.00
#> GSM1253060 1 0.000 0.990 1.00 0.00
#> GSM1253061 1 0.000 0.990 1.00 0.00
#> GSM1253062 1 0.000 0.990 1.00 0.00
#> GSM1253063 1 0.000 0.990 1.00 0.00
#> GSM1253064 1 0.000 0.990 1.00 0.00
#> GSM1253065 1 0.000 0.990 1.00 0.00
#> GSM1253066 1 0.000 0.990 1.00 0.00
#> GSM1253067 1 0.000 0.990 1.00 0.00
#> GSM1253068 1 0.000 0.990 1.00 0.00
#> GSM1253069 1 0.000 0.990 1.00 0.00
#> GSM1253070 1 0.000 0.990 1.00 0.00
#> GSM1253071 1 0.000 0.990 1.00 0.00
#> GSM1253072 1 0.000 0.990 1.00 0.00
#> GSM1253073 1 0.000 0.990 1.00 0.00
#> GSM1253074 1 0.000 0.990 1.00 0.00
#> GSM1253032 1 0.000 0.990 1.00 0.00
#> GSM1253034 2 0.000 1.000 0.00 1.00
#> GSM1253039 2 0.000 1.000 0.00 1.00
#> GSM1253040 2 0.000 1.000 0.00 1.00
#> GSM1253041 2 0.000 1.000 0.00 1.00
#> GSM1253046 1 0.000 0.990 1.00 0.00
#> GSM1253048 2 0.000 1.000 0.00 1.00
#> GSM1253049 2 0.000 1.000 0.00 1.00
#> GSM1253052 2 0.000 1.000 0.00 1.00
#> GSM1253037 2 0.000 1.000 0.00 1.00
#> GSM1253028 2 0.000 1.000 0.00 1.00
#> GSM1253029 2 0.000 1.000 0.00 1.00
#> GSM1253030 2 0.000 1.000 0.00 1.00
#> GSM1253031 2 0.000 1.000 0.00 1.00
#> GSM1253033 1 0.000 0.990 1.00 0.00
#> GSM1253035 2 0.000 1.000 0.00 1.00
#> GSM1253036 2 0.000 1.000 0.00 1.00
#> GSM1253038 2 0.000 1.000 0.00 1.00
#> GSM1253042 2 0.000 1.000 0.00 1.00
#> GSM1253045 2 0.000 1.000 0.00 1.00
#> GSM1253043 2 0.000 1.000 0.00 1.00
#> GSM1253044 2 0.000 1.000 0.00 1.00
#> GSM1253047 1 0.000 0.990 1.00 0.00
#> GSM1253050 2 0.000 1.000 0.00 1.00
#> GSM1253051 2 0.000 1.000 0.00 1.00
#> GSM1253053 2 0.000 1.000 0.00 1.00
#> GSM1253054 1 0.904 0.529 0.68 0.32
#> GSM1253055 2 0.000 1.000 0.00 1.00
#> GSM1253079 1 0.000 0.990 1.00 0.00
#> GSM1253083 1 0.000 0.990 1.00 0.00
#> GSM1253075 1 0.000 0.990 1.00 0.00
#> GSM1253077 1 0.000 0.990 1.00 0.00
#> GSM1253076 1 0.000 0.990 1.00 0.00
#> GSM1253078 1 0.000 0.990 1.00 0.00
#> GSM1253081 1 0.000 0.990 1.00 0.00
#> GSM1253080 1 0.000 0.990 1.00 0.00
#> GSM1253082 1 0.000 0.990 1.00 0.00
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253057 1 0.4931 0.756 0.768 0.000 0.232
#> GSM1253058 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253059 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253060 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253061 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253062 1 0.4346 0.803 0.816 0.000 0.184
#> GSM1253063 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253064 1 0.2796 0.864 0.908 0.000 0.092
#> GSM1253065 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253066 1 0.1411 0.886 0.964 0.000 0.036
#> GSM1253067 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253068 1 0.4504 0.793 0.804 0.000 0.196
#> GSM1253069 1 0.0237 0.894 0.996 0.000 0.004
#> GSM1253070 3 0.3619 0.709 0.136 0.000 0.864
#> GSM1253071 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253072 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253073 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253074 1 0.3192 0.853 0.888 0.000 0.112
#> GSM1253032 3 0.0000 0.852 0.000 0.000 1.000
#> GSM1253034 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253046 3 0.0000 0.852 0.000 0.000 1.000
#> GSM1253048 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253052 2 0.1411 0.918 0.000 0.964 0.036
#> GSM1253037 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253028 2 0.6168 0.302 0.000 0.588 0.412
#> GSM1253029 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253030 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253031 2 0.6295 0.153 0.000 0.528 0.472
#> GSM1253033 3 0.0000 0.852 0.000 0.000 1.000
#> GSM1253035 2 0.0747 0.936 0.000 0.984 0.016
#> GSM1253036 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253038 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253042 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253045 3 0.0000 0.852 0.000 0.000 1.000
#> GSM1253043 3 0.0237 0.850 0.000 0.004 0.996
#> GSM1253044 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253047 3 0.0000 0.852 0.000 0.000 1.000
#> GSM1253050 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253053 2 0.0000 0.948 0.000 1.000 0.000
#> GSM1253054 3 0.0000 0.852 0.000 0.000 1.000
#> GSM1253055 3 0.6305 -0.140 0.000 0.484 0.516
#> GSM1253079 1 0.3879 0.827 0.848 0.000 0.152
#> GSM1253083 1 0.1163 0.889 0.972 0.000 0.028
#> GSM1253075 3 0.6309 -0.275 0.496 0.000 0.504
#> GSM1253077 1 0.6280 0.310 0.540 0.000 0.460
#> GSM1253076 1 0.5216 0.723 0.740 0.000 0.260
#> GSM1253078 1 0.5785 0.613 0.668 0.000 0.332
#> GSM1253081 1 0.0000 0.895 1.000 0.000 0.000
#> GSM1253080 1 0.5497 0.680 0.708 0.000 0.292
#> GSM1253082 1 0.0000 0.895 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0188 0.9967 0.000 0.000 0.004 0.996
#> GSM1253057 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.9979 0.000 0.000 0.000 1.000
#> GSM1253059 4 0.0188 0.9948 0.004 0.000 0.000 0.996
#> GSM1253060 4 0.0188 0.9967 0.000 0.000 0.004 0.996
#> GSM1253061 1 0.0336 0.9366 0.992 0.000 0.000 0.008
#> GSM1253062 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 0.9979 0.000 0.000 0.000 1.000
#> GSM1253064 1 0.0336 0.9371 0.992 0.000 0.000 0.008
#> GSM1253065 4 0.0188 0.9967 0.000 0.000 0.004 0.996
#> GSM1253066 1 0.0376 0.9376 0.992 0.000 0.004 0.004
#> GSM1253067 4 0.0000 0.9979 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.0336 0.9368 0.992 0.000 0.008 0.000
#> GSM1253069 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.4103 0.6497 0.744 0.000 0.256 0.000
#> GSM1253071 4 0.0000 0.9979 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.0469 0.9346 0.988 0.000 0.000 0.012
#> GSM1253073 4 0.0000 0.9979 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.0000 0.9280 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 0.9280 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253052 2 0.4855 0.3339 0.000 0.600 0.400 0.000
#> GSM1253037 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253028 2 0.4382 0.5786 0.000 0.704 0.296 0.000
#> GSM1253029 2 0.0188 0.9396 0.000 0.996 0.004 0.000
#> GSM1253030 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.1118 0.9075 0.000 0.036 0.964 0.000
#> GSM1253033 3 0.0000 0.9280 0.000 0.000 1.000 0.000
#> GSM1253035 3 0.4985 0.0102 0.000 0.468 0.532 0.000
#> GSM1253036 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253038 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253042 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.0336 0.9235 0.008 0.000 0.992 0.000
#> GSM1253043 3 0.0188 0.9270 0.000 0.004 0.996 0.000
#> GSM1253044 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 0.9280 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.9425 0.000 1.000 0.000 0.000
#> GSM1253053 2 0.3610 0.7333 0.000 0.800 0.200 0.000
#> GSM1253054 3 0.0000 0.9280 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.0817 0.9161 0.000 0.024 0.976 0.000
#> GSM1253079 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.4730 0.4647 0.636 0.000 0.000 0.364
#> GSM1253080 1 0.0000 0.9403 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.4804 0.4194 0.616 0.000 0.000 0.384
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0162 0.7805 0.000 0.000 0.004 0.996 0.000
#> GSM1253057 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.3707 0.2030 0.000 0.000 0.284 0.716 0.000
#> GSM1253059 3 0.3661 0.0000 0.000 0.000 0.724 0.276 0.000
#> GSM1253060 4 0.0510 0.7791 0.000 0.000 0.016 0.984 0.000
#> GSM1253061 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0162 0.9579 0.996 0.000 0.004 0.000 0.000
#> GSM1253063 4 0.0794 0.7739 0.000 0.000 0.028 0.972 0.000
#> GSM1253064 1 0.0880 0.9312 0.968 0.000 0.000 0.032 0.000
#> GSM1253065 4 0.0404 0.7765 0.000 0.000 0.012 0.988 0.000
#> GSM1253066 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253067 4 0.0290 0.7810 0.000 0.000 0.008 0.992 0.000
#> GSM1253068 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.2843 0.7852 0.848 0.000 0.008 0.000 0.144
#> GSM1253071 4 0.0162 0.7805 0.000 0.000 0.004 0.996 0.000
#> GSM1253072 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.1478 0.7424 0.000 0.000 0.064 0.936 0.000
#> GSM1253074 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.9911 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0162 0.9909 0.000 0.000 0.004 0.000 0.996
#> GSM1253048 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 2 0.0771 0.9709 0.000 0.976 0.004 0.000 0.020
#> GSM1253037 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 2 0.2470 0.8660 0.000 0.884 0.012 0.000 0.104
#> GSM1253029 2 0.0162 0.9843 0.000 0.996 0.004 0.000 0.000
#> GSM1253030 2 0.0290 0.9823 0.000 0.992 0.008 0.000 0.000
#> GSM1253031 5 0.0566 0.9851 0.000 0.004 0.012 0.000 0.984
#> GSM1253033 5 0.0162 0.9909 0.000 0.000 0.004 0.000 0.996
#> GSM1253035 2 0.1410 0.9333 0.000 0.940 0.000 0.000 0.060
#> GSM1253036 2 0.0290 0.9822 0.000 0.992 0.008 0.000 0.000
#> GSM1253038 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253045 5 0.0162 0.9907 0.000 0.000 0.004 0.000 0.996
#> GSM1253043 5 0.0510 0.9870 0.000 0.000 0.016 0.000 0.984
#> GSM1253044 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.9911 0.000 0.000 0.000 0.000 1.000
#> GSM1253050 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.9860 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 2 0.0579 0.9775 0.000 0.984 0.008 0.000 0.008
#> GSM1253054 5 0.0162 0.9898 0.000 0.000 0.004 0.000 0.996
#> GSM1253055 5 0.0807 0.9743 0.000 0.012 0.012 0.000 0.976
#> GSM1253079 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 4 0.4294 0.0579 0.468 0.000 0.000 0.532 0.000
#> GSM1253080 1 0.0000 0.9607 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.4138 0.3109 0.616 0.000 0.000 0.384 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0146 0.4482 0.000 0.000 0.004 0.996 0.000 0.000
#> GSM1253057 1 0.0146 0.9499 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253058 6 0.4695 0.0000 0.000 0.000 0.044 0.448 0.000 0.508
#> GSM1253059 3 0.5444 0.3285 0.000 0.000 0.576 0.216 0.000 0.208
#> GSM1253060 4 0.3727 0.0355 0.000 0.000 0.388 0.612 0.000 0.000
#> GSM1253061 1 0.0858 0.9449 0.968 0.000 0.028 0.000 0.000 0.004
#> GSM1253062 1 0.0603 0.9477 0.980 0.000 0.004 0.000 0.000 0.016
#> GSM1253063 4 0.3868 -0.3878 0.000 0.000 0.496 0.504 0.000 0.000
#> GSM1253064 1 0.2094 0.9042 0.908 0.000 0.004 0.064 0.000 0.024
#> GSM1253065 4 0.0790 0.4035 0.000 0.000 0.000 0.968 0.000 0.032
#> GSM1253066 1 0.1138 0.9405 0.960 0.000 0.004 0.012 0.000 0.024
#> GSM1253067 4 0.0458 0.4511 0.000 0.000 0.016 0.984 0.000 0.000
#> GSM1253068 1 0.0748 0.9469 0.976 0.000 0.004 0.004 0.000 0.016
#> GSM1253069 1 0.0146 0.9499 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253070 1 0.3968 0.7054 0.756 0.000 0.060 0.000 0.180 0.004
#> GSM1253071 4 0.3565 0.2706 0.000 0.000 0.304 0.692 0.000 0.004
#> GSM1253072 1 0.0964 0.9455 0.968 0.000 0.012 0.004 0.000 0.016
#> GSM1253073 3 0.4072 0.1609 0.000 0.000 0.544 0.448 0.000 0.008
#> GSM1253074 1 0.0146 0.9499 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.8924 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0291 0.9410 0.000 0.992 0.004 0.000 0.000 0.004
#> GSM1253039 2 0.0291 0.9406 0.000 0.992 0.004 0.000 0.000 0.004
#> GSM1253040 2 0.0291 0.9406 0.000 0.992 0.004 0.000 0.000 0.004
#> GSM1253041 2 0.0260 0.9402 0.000 0.992 0.000 0.000 0.000 0.008
#> GSM1253046 5 0.0260 0.8928 0.000 0.000 0.008 0.000 0.992 0.000
#> GSM1253048 2 0.0622 0.9393 0.000 0.980 0.008 0.000 0.000 0.012
#> GSM1253049 2 0.0000 0.9405 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 2 0.0912 0.9349 0.000 0.972 0.004 0.012 0.004 0.008
#> GSM1253037 2 0.0146 0.9406 0.000 0.996 0.004 0.000 0.000 0.000
#> GSM1253028 2 0.4322 0.7356 0.000 0.736 0.192 0.000 0.052 0.020
#> GSM1253029 2 0.0405 0.9396 0.000 0.988 0.004 0.000 0.000 0.008
#> GSM1253030 2 0.2814 0.8329 0.000 0.820 0.172 0.000 0.000 0.008
#> GSM1253031 5 0.2963 0.8470 0.000 0.004 0.152 0.000 0.828 0.016
#> GSM1253033 5 0.1806 0.8688 0.000 0.000 0.088 0.000 0.908 0.004
#> GSM1253035 2 0.2518 0.8749 0.000 0.880 0.012 0.000 0.092 0.016
#> GSM1253036 2 0.2896 0.8414 0.000 0.824 0.160 0.000 0.000 0.016
#> GSM1253038 2 0.0520 0.9401 0.000 0.984 0.008 0.000 0.000 0.008
#> GSM1253042 2 0.1003 0.9382 0.000 0.964 0.020 0.000 0.000 0.016
#> GSM1253045 5 0.2358 0.8658 0.000 0.000 0.108 0.000 0.876 0.016
#> GSM1253043 5 0.3952 0.7782 0.000 0.000 0.212 0.000 0.736 0.052
#> GSM1253044 2 0.0717 0.9387 0.000 0.976 0.008 0.000 0.000 0.016
#> GSM1253047 5 0.0146 0.8921 0.000 0.000 0.000 0.000 0.996 0.004
#> GSM1253050 2 0.1003 0.9376 0.000 0.964 0.016 0.000 0.000 0.020
#> GSM1253051 2 0.0909 0.9387 0.000 0.968 0.012 0.000 0.000 0.020
#> GSM1253053 2 0.3959 0.7730 0.000 0.792 0.004 0.132 0.024 0.048
#> GSM1253054 5 0.0363 0.8907 0.000 0.000 0.000 0.000 0.988 0.012
#> GSM1253055 5 0.3357 0.7305 0.000 0.144 0.020 0.000 0.816 0.020
#> GSM1253079 1 0.0146 0.9499 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253083 1 0.0547 0.9442 0.980 0.000 0.000 0.000 0.000 0.020
#> GSM1253075 1 0.0363 0.9493 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM1253077 1 0.0000 0.9500 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0146 0.9500 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1253078 1 0.0000 0.9500 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.3790 0.7529 0.772 0.000 0.020 0.184 0.000 0.024
#> GSM1253080 1 0.0146 0.9499 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253082 1 0.3233 0.8276 0.828 0.000 0.016 0.132 0.000 0.024
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> CV:NMF 56 0.018077 1.69e-08 0.955 2
#> CV:NMF 51 0.014712 8.96e-09 0.908 3
#> CV:NMF 52 0.000833 2.25e-10 0.893 4
#> CV:NMF 52 0.000833 3.91e-10 0.883 5
#> CV:NMF 47 0.000274 8.31e-09 0.704 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 1.000 1.000 0.4933 0.507 0.507
#> 3 3 0.827 0.957 0.944 0.2618 0.860 0.723
#> 4 4 1.000 1.000 1.000 0.1167 0.938 0.832
#> 5 5 1.000 0.998 0.981 0.1128 0.914 0.719
#> 6 6 1.000 0.941 0.983 0.0171 0.995 0.976
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
#> GSM1253056 1 0.0000 1.000 1.000 0.000
#> GSM1253057 1 0.0000 1.000 1.000 0.000
#> GSM1253058 1 0.0000 1.000 1.000 0.000
#> GSM1253059 1 0.0000 1.000 1.000 0.000
#> GSM1253060 1 0.0000 1.000 1.000 0.000
#> GSM1253061 1 0.0000 1.000 1.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000
#> GSM1253063 1 0.0000 1.000 1.000 0.000
#> GSM1253064 1 0.0000 1.000 1.000 0.000
#> GSM1253065 1 0.0000 1.000 1.000 0.000
#> GSM1253066 1 0.0000 1.000 1.000 0.000
#> GSM1253067 1 0.0000 1.000 1.000 0.000
#> GSM1253068 1 0.0000 1.000 1.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000
#> GSM1253071 1 0.0000 1.000 1.000 0.000
#> GSM1253072 1 0.0000 1.000 1.000 0.000
#> GSM1253073 1 0.0000 1.000 1.000 0.000
#> GSM1253074 1 0.0000 1.000 1.000 0.000
#> GSM1253032 1 0.0000 1.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000
#> GSM1253046 1 0.0000 1.000 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000
#> GSM1253033 1 0.0000 1.000 1.000 0.000
#> GSM1253035 2 0.0000 1.000 0.000 1.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000
#> GSM1253045 2 0.0000 1.000 0.000 1.000
#> GSM1253043 2 0.0376 0.996 0.004 0.996
#> GSM1253044 2 0.0000 1.000 0.000 1.000
#> GSM1253047 1 0.0000 1.000 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000
#> GSM1253054 1 0.0000 1.000 1.000 0.000
#> GSM1253055 2 0.0000 1.000 0.000 1.000
#> GSM1253079 1 0.0000 1.000 1.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000
#> GSM1253082 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
#> GSM1253056 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253057 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253058 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253059 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253060 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253061 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253063 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253064 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253065 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253066 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253067 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253068 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253070 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253071 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253072 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253073 3 0.4842 1.000 0.224 0.000 0.776
#> GSM1253074 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253032 1 0.4842 0.761 0.776 0.000 0.224
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253046 1 0.4842 0.761 0.776 0.000 0.224
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253033 1 0.4842 0.761 0.776 0.000 0.224
#> GSM1253035 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253045 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253043 2 0.0237 0.996 0.000 0.996 0.004
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253047 1 0.4842 0.761 0.776 0.000 0.224
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253054 1 0.4842 0.761 0.776 0.000 0.224
#> GSM1253055 2 0.0000 1.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.937 1.000 0.000 0.000
#> GSM1253082 1 0.0000 0.937 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253057 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253058 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253059 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253060 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253061 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253062 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253063 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253064 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253065 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253066 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253067 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253068 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253069 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253070 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253071 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253072 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253073 4 0.0000 1.000 0 0.000 0.000 1
#> GSM1253074 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253032 3 0.0000 1.000 0 0.000 1.000 0
#> GSM1253034 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253039 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253040 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253041 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253046 3 0.0000 1.000 0 0.000 1.000 0
#> GSM1253048 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253049 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253052 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253037 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253028 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253029 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253030 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253031 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253033 3 0.0000 1.000 0 0.000 1.000 0
#> GSM1253035 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253036 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253038 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253042 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253045 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253043 2 0.0188 0.996 0 0.996 0.004 0
#> GSM1253044 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253047 3 0.0000 1.000 0 0.000 1.000 0
#> GSM1253050 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253051 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253053 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253054 3 0.0000 1.000 0 0.000 1.000 0
#> GSM1253055 2 0.0000 1.000 0 1.000 0.000 0
#> GSM1253079 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253083 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253075 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253077 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253076 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253078 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253081 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253080 1 0.0000 1.000 1 0.000 0.000 0
#> GSM1253082 1 0.0000 1.000 1 0.000 0.000 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253057 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253058 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253059 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253060 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253061 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253062 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253063 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253064 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253065 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253066 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253067 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253068 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253069 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253070 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253071 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253072 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253073 4 0.000 1.000 0 0.000 0.000 1 0.000
#> GSM1253074 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253032 5 0.000 0.987 0 0.000 0.000 0 1.000
#> GSM1253034 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253039 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253040 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253041 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253046 5 0.000 0.987 0 0.000 0.000 0 1.000
#> GSM1253048 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253049 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253052 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253037 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253028 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253029 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253030 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253031 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253033 5 0.185 0.946 0 0.000 0.088 0 0.912
#> GSM1253035 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253036 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253038 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253042 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253045 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253043 3 0.195 0.995 0 0.084 0.912 0 0.004
#> GSM1253044 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253047 5 0.000 0.987 0 0.000 0.000 0 1.000
#> GSM1253050 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253051 2 0.000 1.000 0 1.000 0.000 0 0.000
#> GSM1253053 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253054 5 0.000 0.987 0 0.000 0.000 0 1.000
#> GSM1253055 3 0.185 0.999 0 0.088 0.912 0 0.000
#> GSM1253079 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253083 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253075 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253077 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253076 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253078 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253081 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253080 1 0.000 1.000 1 0.000 0.000 0 0.000
#> GSM1253082 1 0.000 1.000 1 0.000 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253057 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.3756 -0.190 0 0 0.000 0.600 0.000 0.400
#> GSM1253059 6 0.3288 0.000 0 0 0.000 0.276 0.000 0.724
#> GSM1253060 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253061 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253064 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253065 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253066 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253067 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253068 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253071 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253072 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.0000 0.916 0 0 0.000 1.000 0.000 0.000
#> GSM1253074 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.940 0 0 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.940 0 0 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253029 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253031 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253033 5 0.3288 0.726 0 0 0.000 0.000 0.724 0.276
#> GSM1253035 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253036 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253045 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253043 3 0.0146 0.996 0 0 0.996 0.000 0.004 0.000
#> GSM1253044 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.940 0 0 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0 1 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253054 5 0.0000 0.940 0 0 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.0000 1.000 0 0 1.000 0.000 0.000 0.000
#> GSM1253079 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253080 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0000 1.000 1 0 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> MAD:hclust 56 0.018077 1.69e-08 0.955 2
#> MAD:hclust 56 0.000786 1.93e-09 0.944 3
#> MAD:hclust 56 0.000111 2.78e-11 0.909 4
#> MAD:hclust 56 0.000334 2.92e-12 0.862 5
#> MAD:hclust 54 0.000524 2.07e-11 0.813 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.992 0.996 0.4945 0.507 0.507
#> 3 3 0.710 0.728 0.804 0.2749 0.964 0.932
#> 4 4 0.781 0.843 0.845 0.1269 0.695 0.424
#> 5 5 0.742 0.902 0.869 0.0723 0.953 0.820
#> 6 6 0.815 0.857 0.852 0.0519 1.000 1.000
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
#> GSM1253056 1 0.000 0.994 1.0 0.0
#> GSM1253057 1 0.000 0.994 1.0 0.0
#> GSM1253058 1 0.000 0.994 1.0 0.0
#> GSM1253059 1 0.000 0.994 1.0 0.0
#> GSM1253060 1 0.000 0.994 1.0 0.0
#> GSM1253061 1 0.000 0.994 1.0 0.0
#> GSM1253062 1 0.000 0.994 1.0 0.0
#> GSM1253063 1 0.000 0.994 1.0 0.0
#> GSM1253064 1 0.000 0.994 1.0 0.0
#> GSM1253065 1 0.000 0.994 1.0 0.0
#> GSM1253066 1 0.000 0.994 1.0 0.0
#> GSM1253067 1 0.000 0.994 1.0 0.0
#> GSM1253068 1 0.000 0.994 1.0 0.0
#> GSM1253069 1 0.000 0.994 1.0 0.0
#> GSM1253070 1 0.000 0.994 1.0 0.0
#> GSM1253071 1 0.000 0.994 1.0 0.0
#> GSM1253072 1 0.000 0.994 1.0 0.0
#> GSM1253073 1 0.000 0.994 1.0 0.0
#> GSM1253074 1 0.000 0.994 1.0 0.0
#> GSM1253032 1 0.000 0.994 1.0 0.0
#> GSM1253034 2 0.000 1.000 0.0 1.0
#> GSM1253039 2 0.000 1.000 0.0 1.0
#> GSM1253040 2 0.000 1.000 0.0 1.0
#> GSM1253041 2 0.000 1.000 0.0 1.0
#> GSM1253046 1 0.000 0.994 1.0 0.0
#> GSM1253048 2 0.000 1.000 0.0 1.0
#> GSM1253049 2 0.000 1.000 0.0 1.0
#> GSM1253052 2 0.000 1.000 0.0 1.0
#> GSM1253037 2 0.000 1.000 0.0 1.0
#> GSM1253028 2 0.000 1.000 0.0 1.0
#> GSM1253029 2 0.000 1.000 0.0 1.0
#> GSM1253030 2 0.000 1.000 0.0 1.0
#> GSM1253031 2 0.000 1.000 0.0 1.0
#> GSM1253033 1 0.000 0.994 1.0 0.0
#> GSM1253035 2 0.000 1.000 0.0 1.0
#> GSM1253036 2 0.000 1.000 0.0 1.0
#> GSM1253038 2 0.000 1.000 0.0 1.0
#> GSM1253042 2 0.000 1.000 0.0 1.0
#> GSM1253045 2 0.000 1.000 0.0 1.0
#> GSM1253043 2 0.000 1.000 0.0 1.0
#> GSM1253044 2 0.000 1.000 0.0 1.0
#> GSM1253047 1 0.000 0.994 1.0 0.0
#> GSM1253050 2 0.000 1.000 0.0 1.0
#> GSM1253051 2 0.000 1.000 0.0 1.0
#> GSM1253053 2 0.000 1.000 0.0 1.0
#> GSM1253054 1 0.722 0.750 0.8 0.2
#> GSM1253055 2 0.000 1.000 0.0 1.0
#> GSM1253079 1 0.000 0.994 1.0 0.0
#> GSM1253083 1 0.000 0.994 1.0 0.0
#> GSM1253075 1 0.000 0.994 1.0 0.0
#> GSM1253077 1 0.000 0.994 1.0 0.0
#> GSM1253076 1 0.000 0.994 1.0 0.0
#> GSM1253078 1 0.000 0.994 1.0 0.0
#> GSM1253081 1 0.000 0.994 1.0 0.0
#> GSM1253080 1 0.000 0.994 1.0 0.0
#> GSM1253082 1 0.000 0.994 1.0 0.0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253057 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253058 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253059 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253060 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253061 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253062 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253063 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253064 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253065 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253066 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253067 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253068 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253069 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253070 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253071 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253072 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253073 1 0.6308 0.617 0.508 0.000 NA
#> GSM1253074 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253032 1 0.9944 0.244 0.372 0.284 NA
#> GSM1253034 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253039 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253040 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253041 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253046 1 0.9517 0.376 0.476 0.212 NA
#> GSM1253048 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253049 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253052 2 0.0000 0.805 0.000 1.000 NA
#> GSM1253037 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253028 2 0.1411 0.790 0.000 0.964 NA
#> GSM1253029 2 0.5058 0.848 0.000 0.756 NA
#> GSM1253030 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253031 2 0.1031 0.796 0.000 0.976 NA
#> GSM1253033 1 0.9616 0.363 0.444 0.212 NA
#> GSM1253035 2 0.0000 0.805 0.000 1.000 NA
#> GSM1253036 2 0.3038 0.828 0.000 0.896 NA
#> GSM1253038 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253042 2 0.0000 0.805 0.000 1.000 NA
#> GSM1253045 2 0.4796 0.658 0.000 0.780 NA
#> GSM1253043 2 0.4796 0.658 0.000 0.780 NA
#> GSM1253044 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253047 1 0.9895 0.261 0.404 0.284 NA
#> GSM1253050 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253051 2 0.5431 0.852 0.000 0.716 NA
#> GSM1253053 2 0.0000 0.805 0.000 1.000 NA
#> GSM1253054 2 0.9925 -0.122 0.336 0.384 NA
#> GSM1253055 2 0.1411 0.790 0.000 0.964 NA
#> GSM1253079 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253083 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253075 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253077 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253076 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253078 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253081 1 0.0000 0.804 1.000 0.000 NA
#> GSM1253080 1 0.0237 0.803 0.996 0.000 NA
#> GSM1253082 1 0.0000 0.804 1.000 0.000 NA
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253057 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.4769 0.994 0.308 0.000 0.008 0.684
#> GSM1253059 4 0.4769 0.994 0.308 0.000 0.008 0.684
#> GSM1253060 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253061 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253064 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253066 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253068 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253072 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.4454 0.998 0.308 0.000 0.000 0.692
#> GSM1253074 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.4769 0.534 0.008 0.000 0.684 0.308
#> GSM1253034 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.5786 0.497 0.052 0.000 0.640 0.308
#> GSM1253048 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.4877 0.467 0.000 0.408 0.592 0.000
#> GSM1253037 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.4804 0.491 0.000 0.384 0.616 0.000
#> GSM1253029 2 0.4564 0.320 0.000 0.672 0.328 0.000
#> GSM1253030 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.4817 0.488 0.000 0.388 0.612 0.000
#> GSM1253033 3 0.5186 0.497 0.016 0.000 0.640 0.344
#> GSM1253035 3 0.4877 0.467 0.000 0.408 0.592 0.000
#> GSM1253036 3 0.4999 0.255 0.000 0.492 0.508 0.000
#> GSM1253038 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.4877 0.467 0.000 0.408 0.592 0.000
#> GSM1253045 3 0.0336 0.582 0.000 0.008 0.992 0.000
#> GSM1253043 3 0.0336 0.582 0.000 0.008 0.992 0.000
#> GSM1253044 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.4769 0.534 0.008 0.000 0.684 0.308
#> GSM1253050 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.4877 0.467 0.000 0.408 0.592 0.000
#> GSM1253054 3 0.4769 0.534 0.008 0.000 0.684 0.308
#> GSM1253055 3 0.4804 0.491 0.000 0.384 0.616 0.000
#> GSM1253079 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.0000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.265 0.980 0.152 0.000 0.000 0.848 0.000
#> GSM1253057 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.440 0.938 0.152 0.000 0.000 0.760 0.088
#> GSM1253059 4 0.451 0.935 0.152 0.000 0.000 0.752 0.096
#> GSM1253060 4 0.265 0.980 0.152 0.000 0.000 0.848 0.000
#> GSM1253061 1 0.311 0.856 0.800 0.000 0.000 0.000 0.200
#> GSM1253062 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.265 0.980 0.152 0.000 0.000 0.848 0.000
#> GSM1253064 1 0.327 0.849 0.780 0.000 0.000 0.000 0.220
#> GSM1253065 4 0.265 0.980 0.152 0.000 0.000 0.848 0.000
#> GSM1253066 1 0.327 0.849 0.780 0.000 0.000 0.000 0.220
#> GSM1253067 4 0.281 0.979 0.152 0.000 0.000 0.844 0.004
#> GSM1253068 1 0.327 0.849 0.780 0.000 0.000 0.000 0.220
#> GSM1253069 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.314 0.855 0.796 0.000 0.000 0.000 0.204
#> GSM1253071 4 0.265 0.980 0.152 0.000 0.000 0.848 0.000
#> GSM1253072 1 0.327 0.849 0.780 0.000 0.000 0.000 0.220
#> GSM1253073 4 0.314 0.976 0.152 0.000 0.000 0.832 0.016
#> GSM1253074 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.395 0.985 0.000 0.000 0.332 0.000 0.668
#> GSM1253034 2 0.179 0.936 0.000 0.916 0.000 0.084 0.000
#> GSM1253039 2 0.208 0.934 0.000 0.908 0.000 0.084 0.008
#> GSM1253040 2 0.029 0.965 0.000 0.992 0.000 0.000 0.008
#> GSM1253041 2 0.000 0.967 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.423 0.973 0.012 0.000 0.312 0.000 0.676
#> GSM1253048 2 0.000 0.967 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.000 0.967 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.497 0.880 0.000 0.260 0.672 0.068 0.000
#> GSM1253037 2 0.000 0.967 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.351 0.867 0.000 0.252 0.748 0.000 0.000
#> GSM1253029 3 0.530 0.797 0.000 0.328 0.604 0.068 0.000
#> GSM1253030 2 0.208 0.934 0.000 0.908 0.000 0.084 0.008
#> GSM1253031 3 0.353 0.868 0.000 0.256 0.744 0.000 0.000
#> GSM1253033 5 0.419 0.974 0.000 0.000 0.304 0.012 0.684
#> GSM1253035 3 0.497 0.880 0.000 0.260 0.672 0.068 0.000
#> GSM1253036 3 0.368 0.855 0.000 0.280 0.720 0.000 0.000
#> GSM1253038 2 0.000 0.967 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.497 0.880 0.000 0.260 0.672 0.068 0.000
#> GSM1253045 3 0.000 0.501 0.000 0.000 1.000 0.000 0.000
#> GSM1253043 3 0.000 0.501 0.000 0.000 1.000 0.000 0.000
#> GSM1253044 2 0.000 0.967 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.395 0.985 0.000 0.000 0.332 0.000 0.668
#> GSM1253050 2 0.029 0.965 0.000 0.992 0.000 0.000 0.008
#> GSM1253051 2 0.179 0.936 0.000 0.916 0.000 0.084 0.000
#> GSM1253053 3 0.497 0.880 0.000 0.260 0.672 0.068 0.000
#> GSM1253054 5 0.395 0.985 0.000 0.000 0.332 0.000 0.668
#> GSM1253055 3 0.492 0.879 0.000 0.252 0.680 0.068 0.000
#> GSM1253079 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.402 0.828 0.752 0.000 0.000 0.028 0.220
#> GSM1253080 1 0.000 0.898 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.402 0.828 0.752 0.000 0.000 0.028 0.220
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.1946 0.959 0.072 0.000 0.012 0.912 0.000 NA
#> GSM1253057 1 0.0405 0.803 0.988 0.000 0.008 0.000 0.000 NA
#> GSM1253058 4 0.4621 0.890 0.072 0.000 0.060 0.768 0.012 NA
#> GSM1253059 4 0.4879 0.861 0.072 0.000 0.048 0.740 0.012 NA
#> GSM1253060 4 0.1444 0.960 0.072 0.000 0.000 0.928 0.000 NA
#> GSM1253061 1 0.3965 0.729 0.604 0.000 0.008 0.000 0.000 NA
#> GSM1253062 1 0.0260 0.804 0.992 0.000 0.008 0.000 0.000 NA
#> GSM1253063 4 0.1444 0.960 0.072 0.000 0.000 0.928 0.000 NA
#> GSM1253064 1 0.3944 0.718 0.568 0.000 0.000 0.004 0.000 NA
#> GSM1253065 4 0.2058 0.958 0.072 0.000 0.012 0.908 0.000 NA
#> GSM1253066 1 0.3810 0.720 0.572 0.000 0.000 0.000 0.000 NA
#> GSM1253067 4 0.2151 0.958 0.072 0.000 0.016 0.904 0.000 NA
#> GSM1253068 1 0.3937 0.720 0.572 0.000 0.004 0.000 0.000 NA
#> GSM1253069 1 0.0291 0.803 0.992 0.000 0.004 0.000 0.000 NA
#> GSM1253070 1 0.4057 0.728 0.600 0.000 0.012 0.000 0.000 NA
#> GSM1253071 4 0.1444 0.960 0.072 0.000 0.000 0.928 0.000 NA
#> GSM1253072 1 0.3937 0.720 0.572 0.000 0.004 0.000 0.000 NA
#> GSM1253073 4 0.2039 0.956 0.072 0.000 0.004 0.908 0.000 NA
#> GSM1253074 1 0.0508 0.804 0.984 0.000 0.012 0.000 0.000 NA
#> GSM1253032 5 0.0547 0.982 0.000 0.000 0.020 0.000 0.980 NA
#> GSM1253034 2 0.3081 0.851 0.000 0.776 0.000 0.000 0.004 NA
#> GSM1253039 2 0.3370 0.852 0.000 0.772 0.000 0.012 0.004 NA
#> GSM1253040 2 0.0725 0.923 0.000 0.976 0.000 0.012 0.000 NA
#> GSM1253041 2 0.0146 0.925 0.000 0.996 0.000 0.004 0.000 NA
#> GSM1253046 5 0.0622 0.979 0.000 0.000 0.012 0.000 0.980 NA
#> GSM1253048 2 0.0260 0.925 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253049 2 0.0000 0.925 0.000 1.000 0.000 0.000 0.000 NA
#> GSM1253052 3 0.4486 0.879 0.000 0.124 0.728 0.008 0.000 NA
#> GSM1253037 2 0.0000 0.925 0.000 1.000 0.000 0.000 0.000 NA
#> GSM1253028 3 0.3584 0.842 0.000 0.108 0.824 0.044 0.016 NA
#> GSM1253029 3 0.4739 0.870 0.000 0.136 0.712 0.008 0.004 NA
#> GSM1253030 2 0.3192 0.851 0.000 0.776 0.000 0.004 0.004 NA
#> GSM1253031 3 0.3483 0.845 0.000 0.116 0.824 0.044 0.008 NA
#> GSM1253033 5 0.1765 0.960 0.000 0.000 0.024 0.000 0.924 NA
#> GSM1253035 3 0.4240 0.880 0.000 0.124 0.736 0.000 0.000 NA
#> GSM1253036 3 0.3331 0.843 0.000 0.136 0.816 0.044 0.004 NA
#> GSM1253038 2 0.0622 0.923 0.000 0.980 0.000 0.012 0.000 NA
#> GSM1253042 3 0.4486 0.879 0.000 0.124 0.728 0.008 0.000 NA
#> GSM1253045 3 0.3607 0.729 0.000 0.000 0.812 0.040 0.124 NA
#> GSM1253043 3 0.3607 0.729 0.000 0.000 0.812 0.040 0.124 NA
#> GSM1253044 2 0.0146 0.925 0.000 0.996 0.000 0.004 0.000 NA
#> GSM1253047 5 0.0909 0.981 0.000 0.000 0.020 0.000 0.968 NA
#> GSM1253050 2 0.0146 0.925 0.000 0.996 0.000 0.000 0.000 NA
#> GSM1253051 2 0.3081 0.851 0.000 0.776 0.000 0.000 0.004 NA
#> GSM1253053 3 0.4486 0.879 0.000 0.124 0.728 0.008 0.000 NA
#> GSM1253054 5 0.1092 0.979 0.000 0.000 0.020 0.000 0.960 NA
#> GSM1253055 3 0.4506 0.876 0.000 0.108 0.736 0.000 0.016 NA
#> GSM1253079 1 0.0405 0.803 0.988 0.000 0.008 0.000 0.000 NA
#> GSM1253083 1 0.1010 0.802 0.960 0.000 0.036 0.000 0.004 NA
#> GSM1253075 1 0.0603 0.804 0.980 0.000 0.016 0.000 0.004 NA
#> GSM1253077 1 0.0935 0.802 0.964 0.000 0.032 0.000 0.004 NA
#> GSM1253076 1 0.0935 0.803 0.964 0.000 0.032 0.000 0.004 NA
#> GSM1253078 1 0.0935 0.802 0.964 0.000 0.032 0.000 0.004 NA
#> GSM1253081 1 0.4366 0.703 0.548 0.000 0.000 0.024 0.000 NA
#> GSM1253080 1 0.0922 0.803 0.968 0.000 0.024 0.000 0.004 NA
#> GSM1253082 1 0.4366 0.703 0.548 0.000 0.000 0.024 0.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 infection(p) disease.state(p) individual(p) k
#> MAD:kmeans 56 0.018077 1.69e-08 0.955 2
#> MAD:kmeans 51 0.008612 4.89e-11 0.985 3
#> MAD:kmeans 45 0.001509 1.02e-09 0.803 4
#> MAD:kmeans 56 0.000334 2.92e-12 0.862 5
#> MAD:kmeans 56 0.000334 2.92e-12 0.862 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.987 0.994 0.4977 0.501 0.501
#> 3 3 1.000 0.946 0.974 0.1988 0.894 0.790
#> 4 4 1.000 0.956 0.985 0.1829 0.889 0.726
#> 5 5 0.931 0.918 0.961 0.0919 0.931 0.767
#> 6 6 0.890 0.894 0.913 0.0389 0.947 0.783
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 3 4
There is also optional best \(k\) = 2 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
#> GSM1253056 1 0.000 0.999 1.000 0.000
#> GSM1253057 1 0.000 0.999 1.000 0.000
#> GSM1253058 1 0.000 0.999 1.000 0.000
#> GSM1253059 1 0.000 0.999 1.000 0.000
#> GSM1253060 1 0.000 0.999 1.000 0.000
#> GSM1253061 1 0.000 0.999 1.000 0.000
#> GSM1253062 1 0.000 0.999 1.000 0.000
#> GSM1253063 1 0.000 0.999 1.000 0.000
#> GSM1253064 1 0.000 0.999 1.000 0.000
#> GSM1253065 1 0.000 0.999 1.000 0.000
#> GSM1253066 1 0.000 0.999 1.000 0.000
#> GSM1253067 1 0.000 0.999 1.000 0.000
#> GSM1253068 1 0.000 0.999 1.000 0.000
#> GSM1253069 1 0.000 0.999 1.000 0.000
#> GSM1253070 1 0.000 0.999 1.000 0.000
#> GSM1253071 1 0.000 0.999 1.000 0.000
#> GSM1253072 1 0.000 0.999 1.000 0.000
#> GSM1253073 1 0.000 0.999 1.000 0.000
#> GSM1253074 1 0.000 0.999 1.000 0.000
#> GSM1253032 1 0.184 0.971 0.972 0.028
#> GSM1253034 2 0.000 0.988 0.000 1.000
#> GSM1253039 2 0.000 0.988 0.000 1.000
#> GSM1253040 2 0.000 0.988 0.000 1.000
#> GSM1253041 2 0.000 0.988 0.000 1.000
#> GSM1253046 1 0.000 0.999 1.000 0.000
#> GSM1253048 2 0.000 0.988 0.000 1.000
#> GSM1253049 2 0.000 0.988 0.000 1.000
#> GSM1253052 2 0.000 0.988 0.000 1.000
#> GSM1253037 2 0.000 0.988 0.000 1.000
#> GSM1253028 2 0.000 0.988 0.000 1.000
#> GSM1253029 2 0.000 0.988 0.000 1.000
#> GSM1253030 2 0.000 0.988 0.000 1.000
#> GSM1253031 2 0.000 0.988 0.000 1.000
#> GSM1253033 1 0.000 0.999 1.000 0.000
#> GSM1253035 2 0.000 0.988 0.000 1.000
#> GSM1253036 2 0.000 0.988 0.000 1.000
#> GSM1253038 2 0.000 0.988 0.000 1.000
#> GSM1253042 2 0.000 0.988 0.000 1.000
#> GSM1253045 2 0.000 0.988 0.000 1.000
#> GSM1253043 2 0.000 0.988 0.000 1.000
#> GSM1253044 2 0.000 0.988 0.000 1.000
#> GSM1253047 1 0.000 0.999 1.000 0.000
#> GSM1253050 2 0.000 0.988 0.000 1.000
#> GSM1253051 2 0.000 0.988 0.000 1.000
#> GSM1253053 2 0.000 0.988 0.000 1.000
#> GSM1253054 2 0.861 0.602 0.284 0.716
#> GSM1253055 2 0.000 0.988 0.000 1.000
#> GSM1253079 1 0.000 0.999 1.000 0.000
#> GSM1253083 1 0.000 0.999 1.000 0.000
#> GSM1253075 1 0.000 0.999 1.000 0.000
#> GSM1253077 1 0.000 0.999 1.000 0.000
#> GSM1253076 1 0.000 0.999 1.000 0.000
#> GSM1253078 1 0.000 0.999 1.000 0.000
#> GSM1253081 1 0.000 0.999 1.000 0.000
#> GSM1253080 1 0.000 0.999 1.000 0.000
#> GSM1253082 1 0.000 0.999 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253057 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253058 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253059 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253060 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253061 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253063 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253064 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253065 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253066 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253067 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253068 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253070 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253071 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253072 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253073 1 0.1643 0.969 0.956 0.000 0.044
#> GSM1253074 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253032 3 0.1529 0.907 0.040 0.000 0.960
#> GSM1253034 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253046 3 0.1643 0.907 0.044 0.000 0.956
#> GSM1253048 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253052 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253037 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253028 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253029 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253030 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253031 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253033 3 0.1529 0.907 0.040 0.000 0.960
#> GSM1253035 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253036 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253038 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253042 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253045 3 0.6215 0.216 0.000 0.428 0.572
#> GSM1253043 2 0.6095 0.259 0.000 0.608 0.392
#> GSM1253044 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253047 3 0.1643 0.907 0.044 0.000 0.956
#> GSM1253050 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253053 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253054 3 0.1765 0.906 0.040 0.004 0.956
#> GSM1253055 2 0.0000 0.979 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.985 1.000 0.000 0.000
#> GSM1253082 1 0.0592 0.981 0.988 0.000 0.012
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253057 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253059 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253060 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253061 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253064 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253066 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253068 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253072 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.0188 1.000 0.004 0.000 0.000 0.996
#> GSM1253074 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.0000 0.893 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 0.893 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253052 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253037 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253028 2 0.0188 0.975 0.000 0.996 0.000 0.004
#> GSM1253029 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253030 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253031 2 0.0188 0.975 0.000 0.996 0.000 0.004
#> GSM1253033 3 0.0000 0.893 0.000 0.000 1.000 0.000
#> GSM1253035 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253036 2 0.0188 0.975 0.000 0.996 0.000 0.004
#> GSM1253038 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253042 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.4978 0.342 0.000 0.384 0.612 0.004
#> GSM1253043 2 0.5060 0.194 0.000 0.584 0.412 0.004
#> GSM1253044 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 0.893 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253053 2 0.0000 0.977 0.000 1.000 0.000 0.000
#> GSM1253054 3 0.0000 0.893 0.000 0.000 1.000 0.000
#> GSM1253055 2 0.0188 0.975 0.000 0.996 0.000 0.004
#> GSM1253079 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.0000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253057 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253058 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253059 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253060 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253061 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
#> GSM1253062 1 0.0162 0.992 0.996 0.000 0.004 0 0.000
#> GSM1253063 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253064 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
#> GSM1253065 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253066 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
#> GSM1253067 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253068 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
#> GSM1253069 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253070 1 0.0510 0.990 0.984 0.000 0.016 0 0.000
#> GSM1253071 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253072 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
#> GSM1253073 4 0.0000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253074 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253032 5 0.0000 0.988 0.000 0.000 0.000 0 1.000
#> GSM1253034 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253039 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253040 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253041 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253046 5 0.0000 0.988 0.000 0.000 0.000 0 1.000
#> GSM1253048 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253049 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253052 2 0.4138 0.438 0.000 0.616 0.384 0 0.000
#> GSM1253037 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253028 3 0.0880 0.934 0.000 0.032 0.968 0 0.000
#> GSM1253029 2 0.4138 0.438 0.000 0.616 0.384 0 0.000
#> GSM1253030 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253031 3 0.0703 0.933 0.000 0.024 0.976 0 0.000
#> GSM1253033 5 0.0000 0.988 0.000 0.000 0.000 0 1.000
#> GSM1253035 3 0.2813 0.816 0.000 0.168 0.832 0 0.000
#> GSM1253036 3 0.2179 0.892 0.000 0.112 0.888 0 0.000
#> GSM1253038 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253042 2 0.4138 0.438 0.000 0.616 0.384 0 0.000
#> GSM1253045 3 0.0798 0.919 0.000 0.008 0.976 0 0.016
#> GSM1253043 3 0.0693 0.925 0.000 0.012 0.980 0 0.008
#> GSM1253044 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253047 5 0.0162 0.987 0.000 0.000 0.004 0 0.996
#> GSM1253050 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253051 2 0.0000 0.879 0.000 1.000 0.000 0 0.000
#> GSM1253053 2 0.4138 0.438 0.000 0.616 0.384 0 0.000
#> GSM1253054 5 0.1270 0.955 0.000 0.000 0.052 0 0.948
#> GSM1253055 3 0.1270 0.929 0.000 0.052 0.948 0 0.000
#> GSM1253079 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253083 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253075 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253077 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253076 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253078 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253081 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
#> GSM1253080 1 0.0000 0.992 1.000 0.000 0.000 0 0.000
#> GSM1253082 1 0.0609 0.989 0.980 0.000 0.020 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253057 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253059 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253060 4 0.0146 0.996 0.000 0.000 0.000 0.996 0.000 0.004
#> GSM1253061 1 0.3094 0.877 0.824 0.000 0.036 0.000 0.000 0.140
#> GSM1253062 1 0.0146 0.912 0.996 0.000 0.000 0.000 0.000 0.004
#> GSM1253063 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253064 1 0.3523 0.863 0.780 0.000 0.040 0.000 0.000 0.180
#> GSM1253065 4 0.0291 0.992 0.000 0.000 0.004 0.992 0.000 0.004
#> GSM1253066 1 0.3523 0.863 0.780 0.000 0.040 0.000 0.000 0.180
#> GSM1253067 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253068 1 0.3523 0.863 0.780 0.000 0.040 0.000 0.000 0.180
#> GSM1253069 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253070 1 0.2826 0.883 0.844 0.000 0.028 0.000 0.000 0.128
#> GSM1253071 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253072 1 0.3523 0.863 0.780 0.000 0.040 0.000 0.000 0.180
#> GSM1253073 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253074 1 0.0000 0.913 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.1367 0.939 0.000 0.000 0.044 0.000 0.944 0.012
#> GSM1253048 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.3050 0.862 0.000 0.236 0.764 0.000 0.000 0.000
#> GSM1253037 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 6 0.3244 0.957 0.000 0.000 0.268 0.000 0.000 0.732
#> GSM1253029 3 0.3076 0.857 0.000 0.240 0.760 0.000 0.000 0.000
#> GSM1253030 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253031 6 0.3244 0.957 0.000 0.000 0.268 0.000 0.000 0.732
#> GSM1253033 5 0.1594 0.936 0.000 0.000 0.052 0.000 0.932 0.016
#> GSM1253035 3 0.2365 0.686 0.000 0.072 0.888 0.000 0.000 0.040
#> GSM1253036 2 0.6082 -0.320 0.000 0.396 0.292 0.000 0.000 0.312
#> GSM1253038 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.3050 0.862 0.000 0.236 0.764 0.000 0.000 0.000
#> GSM1253045 6 0.2902 0.917 0.000 0.000 0.196 0.000 0.004 0.800
#> GSM1253043 6 0.3101 0.955 0.000 0.000 0.244 0.000 0.000 0.756
#> GSM1253044 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.1563 0.934 0.000 0.000 0.012 0.000 0.932 0.056
#> GSM1253050 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.940 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.3050 0.862 0.000 0.236 0.764 0.000 0.000 0.000
#> GSM1253054 5 0.1967 0.920 0.000 0.000 0.012 0.000 0.904 0.084
#> GSM1253055 3 0.2170 0.560 0.000 0.012 0.888 0.000 0.000 0.100
#> GSM1253079 1 0.0000 0.913 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253075 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253077 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253076 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253078 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253081 1 0.3523 0.863 0.780 0.000 0.040 0.000 0.000 0.180
#> GSM1253080 1 0.0146 0.913 0.996 0.000 0.004 0.000 0.000 0.000
#> GSM1253082 1 0.3663 0.860 0.776 0.000 0.040 0.004 0.000 0.180
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 infection(p) disease.state(p) individual(p) k
#> MAD:skmeans 56 0.013575 3.63e-09 0.949 2
#> MAD:skmeans 54 0.006642 7.33e-10 0.903 3
#> MAD:skmeans 54 0.000178 8.70e-11 0.880 4
#> MAD:skmeans 52 0.000821 1.18e-11 0.874 5
#> MAD:skmeans 55 0.001056 1.02e-10 0.777 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.992 0.996 0.4945 0.507 0.507
#> 3 3 0.739 0.865 0.864 0.2706 0.860 0.731
#> 4 4 0.933 0.937 0.967 0.1988 0.832 0.584
#> 5 5 1.000 0.941 0.979 0.0451 0.934 0.745
#> 6 6 0.948 0.975 0.970 0.0521 0.949 0.764
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
#> GSM1253056 1 0.0000 0.994 1.000 0.000
#> GSM1253057 1 0.0000 0.994 1.000 0.000
#> GSM1253058 1 0.0000 0.994 1.000 0.000
#> GSM1253059 1 0.0000 0.994 1.000 0.000
#> GSM1253060 1 0.0000 0.994 1.000 0.000
#> GSM1253061 1 0.0000 0.994 1.000 0.000
#> GSM1253062 1 0.0000 0.994 1.000 0.000
#> GSM1253063 1 0.0000 0.994 1.000 0.000
#> GSM1253064 1 0.0000 0.994 1.000 0.000
#> GSM1253065 1 0.0000 0.994 1.000 0.000
#> GSM1253066 1 0.0000 0.994 1.000 0.000
#> GSM1253067 1 0.0000 0.994 1.000 0.000
#> GSM1253068 1 0.0000 0.994 1.000 0.000
#> GSM1253069 1 0.0000 0.994 1.000 0.000
#> GSM1253070 1 0.0000 0.994 1.000 0.000
#> GSM1253071 1 0.0000 0.994 1.000 0.000
#> GSM1253072 1 0.0000 0.994 1.000 0.000
#> GSM1253073 1 0.0000 0.994 1.000 0.000
#> GSM1253074 1 0.0000 0.994 1.000 0.000
#> GSM1253032 1 0.0000 0.994 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000
#> GSM1253046 1 0.0000 0.994 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000
#> GSM1253052 2 0.0000 1.000 0.000 1.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000
#> GSM1253028 2 0.0000 1.000 0.000 1.000
#> GSM1253029 2 0.0000 1.000 0.000 1.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000
#> GSM1253031 2 0.0000 1.000 0.000 1.000
#> GSM1253033 1 0.0000 0.994 1.000 0.000
#> GSM1253035 2 0.0000 1.000 0.000 1.000
#> GSM1253036 2 0.0000 1.000 0.000 1.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000
#> GSM1253042 2 0.0000 1.000 0.000 1.000
#> GSM1253045 2 0.0672 0.992 0.008 0.992
#> GSM1253043 2 0.0000 1.000 0.000 1.000
#> GSM1253044 2 0.0000 1.000 0.000 1.000
#> GSM1253047 1 0.0000 0.994 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000
#> GSM1253053 2 0.0000 1.000 0.000 1.000
#> GSM1253054 1 0.7219 0.750 0.800 0.200
#> GSM1253055 2 0.0000 1.000 0.000 1.000
#> GSM1253079 1 0.0000 0.994 1.000 0.000
#> GSM1253083 1 0.0000 0.994 1.000 0.000
#> GSM1253075 1 0.0000 0.994 1.000 0.000
#> GSM1253077 1 0.0000 0.994 1.000 0.000
#> GSM1253076 1 0.0000 0.994 1.000 0.000
#> GSM1253078 1 0.0000 0.994 1.000 0.000
#> GSM1253081 1 0.0000 0.994 1.000 0.000
#> GSM1253080 1 0.0000 0.994 1.000 0.000
#> GSM1253082 1 0.0000 0.994 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253057 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253058 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253059 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253060 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253061 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253063 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253064 1 0.5327 0.817 0.728 0.272 0.000
#> GSM1253065 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253066 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253067 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253068 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253070 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253071 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253072 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253073 1 0.5431 0.813 0.716 0.284 0.000
#> GSM1253074 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253032 3 0.5431 0.600 0.000 0.284 0.716
#> GSM1253034 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253039 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253040 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253041 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253046 1 0.1765 0.859 0.956 0.040 0.004
#> GSM1253048 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253049 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253052 3 0.1529 0.882 0.000 0.040 0.960
#> GSM1253037 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253028 3 0.0000 0.895 0.000 0.000 1.000
#> GSM1253029 3 0.1964 0.863 0.000 0.056 0.944
#> GSM1253030 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253031 3 0.0000 0.895 0.000 0.000 1.000
#> GSM1253033 1 0.9809 0.386 0.432 0.284 0.284
#> GSM1253035 3 0.0000 0.895 0.000 0.000 1.000
#> GSM1253036 3 0.1529 0.882 0.000 0.040 0.960
#> GSM1253038 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253042 3 0.1529 0.882 0.000 0.040 0.960
#> GSM1253045 3 0.0424 0.889 0.008 0.000 0.992
#> GSM1253043 3 0.0000 0.895 0.000 0.000 1.000
#> GSM1253044 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253047 1 0.5098 0.586 0.752 0.000 0.248
#> GSM1253050 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253051 2 0.5431 1.000 0.000 0.716 0.284
#> GSM1253053 3 0.1529 0.882 0.000 0.040 0.960
#> GSM1253054 3 0.5325 0.635 0.004 0.248 0.748
#> GSM1253055 3 0.0000 0.895 0.000 0.000 1.000
#> GSM1253079 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253081 1 0.5397 0.815 0.720 0.280 0.000
#> GSM1253080 1 0.0000 0.865 1.000 0.000 0.000
#> GSM1253082 1 0.5397 0.815 0.720 0.280 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253059 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253060 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253061 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253064 4 0.441 0.631 0.300 0.000 0.000 0.700
#> GSM1253065 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253066 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.000 0.905 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253032 4 0.494 0.312 0.000 0.000 0.436 0.564
#> GSM1253034 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.323 0.882 0.880 0.000 0.072 0.048
#> GSM1253048 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.194 0.943 0.000 0.076 0.924 0.000
#> GSM1253037 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.222 0.929 0.000 0.092 0.908 0.000
#> GSM1253030 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253033 4 0.413 0.819 0.108 0.000 0.064 0.828
#> GSM1253035 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.194 0.943 0.000 0.076 0.924 0.000
#> GSM1253038 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.194 0.943 0.000 0.076 0.924 0.000
#> GSM1253045 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.276 0.863 0.872 0.000 0.128 0.000
#> GSM1253050 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.000 1.000 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.194 0.943 0.000 0.076 0.924 0.000
#> GSM1253054 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.000 0.960 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253081 4 0.281 0.839 0.132 0.000 0.000 0.868
#> GSM1253080 1 0.000 0.986 1.000 0.000 0.000 0.000
#> GSM1253082 4 0.317 0.817 0.160 0.000 0.000 0.840
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253057 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253059 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253060 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253061 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253064 1 0.318 0.697 0.792 0.000 0.000 0.208 0.000
#> GSM1253065 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253066 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253067 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253068 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253069 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253071 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253072 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.000 0.876 0.000 0.000 0.000 1.000 0.000
#> GSM1253074 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.000 0.998 0.000 0.000 0.000 0.000 1.000
#> GSM1253034 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.000 0.998 0.000 0.000 0.000 0.000 1.000
#> GSM1253048 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253037 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253029 3 0.088 0.961 0.000 0.032 0.968 0.000 0.000
#> GSM1253030 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253031 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253033 5 0.000 0.998 0.000 0.000 0.000 0.000 1.000
#> GSM1253035 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253036 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253038 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253043 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253044 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.000 0.998 0.000 0.000 0.000 0.000 1.000
#> GSM1253050 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253054 5 0.029 0.992 0.000 0.000 0.008 0.000 0.992
#> GSM1253055 3 0.000 0.996 0.000 0.000 1.000 0.000 0.000
#> GSM1253079 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 4 0.423 0.297 0.424 0.000 0.000 0.576 0.000
#> GSM1253080 1 0.000 0.985 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 4 0.430 0.125 0.480 0.000 0.000 0.520 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253057 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253059 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253060 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253061 1 0.2340 0.799 0.852 0.000 0.000 0.000 0.000 0.148
#> GSM1253062 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253064 6 0.2633 0.963 0.104 0.000 0.000 0.032 0.000 0.864
#> GSM1253065 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253066 6 0.2219 0.964 0.136 0.000 0.000 0.000 0.000 0.864
#> GSM1253067 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253068 6 0.2219 0.964 0.136 0.000 0.000 0.000 0.000 0.864
#> GSM1253069 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0363 0.974 0.988 0.000 0.000 0.000 0.000 0.012
#> GSM1253071 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253072 6 0.2219 0.964 0.136 0.000 0.000 0.000 0.000 0.864
#> GSM1253073 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253074 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0000 0.993 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.993 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.0865 0.938 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.1814 0.932 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM1253029 3 0.1649 0.917 0.000 0.032 0.932 0.000 0.000 0.036
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253031 3 0.1814 0.932 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM1253033 5 0.0000 0.993 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253035 3 0.0000 0.941 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253036 3 0.1556 0.936 0.000 0.000 0.920 0.000 0.000 0.080
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.0865 0.938 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM1253045 3 0.1814 0.932 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM1253043 3 0.1814 0.932 0.000 0.000 0.900 0.000 0.000 0.100
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.0000 0.993 0.000 0.000 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253053 3 0.0865 0.938 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM1253054 5 0.0806 0.974 0.000 0.000 0.008 0.000 0.972 0.020
#> GSM1253055 3 0.0865 0.938 0.000 0.000 0.964 0.000 0.000 0.036
#> GSM1253079 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 6 0.2679 0.958 0.096 0.000 0.000 0.040 0.000 0.864
#> GSM1253080 1 0.0000 0.985 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253082 6 0.2697 0.953 0.092 0.000 0.000 0.044 0.000 0.864
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 infection(p) disease.state(p) individual(p) k
#> MAD:pam 56 0.018077 1.69e-08 0.955 2
#> MAD:pam 55 0.011292 1.36e-10 0.845 3
#> MAD:pam 55 0.009848 5.06e-10 0.657 4
#> MAD:pam 54 0.001542 2.07e-11 0.842 5
#> MAD:pam 56 0.000488 2.57e-11 0.785 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5096 0.491 0.491
#> 3 3 0.778 0.767 0.890 0.2096 0.873 0.745
#> 4 4 0.889 0.906 0.938 0.2110 0.816 0.551
#> 5 5 0.911 0.934 0.930 0.0638 0.928 0.729
#> 6 6 1.000 0.996 0.998 0.0553 0.949 0.757
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
#> GSM1253056 1 0 1 1 0
#> GSM1253057 1 0 1 1 0
#> GSM1253058 1 0 1 1 0
#> GSM1253059 1 0 1 1 0
#> GSM1253060 1 0 1 1 0
#> GSM1253061 1 0 1 1 0
#> GSM1253062 1 0 1 1 0
#> GSM1253063 1 0 1 1 0
#> GSM1253064 1 0 1 1 0
#> GSM1253065 1 0 1 1 0
#> GSM1253066 1 0 1 1 0
#> GSM1253067 1 0 1 1 0
#> GSM1253068 1 0 1 1 0
#> GSM1253069 1 0 1 1 0
#> GSM1253070 1 0 1 1 0
#> GSM1253071 1 0 1 1 0
#> GSM1253072 1 0 1 1 0
#> GSM1253073 1 0 1 1 0
#> GSM1253074 1 0 1 1 0
#> GSM1253032 2 0 1 0 1
#> GSM1253034 2 0 1 0 1
#> GSM1253039 2 0 1 0 1
#> GSM1253040 2 0 1 0 1
#> GSM1253041 2 0 1 0 1
#> GSM1253046 2 0 1 0 1
#> GSM1253048 2 0 1 0 1
#> GSM1253049 2 0 1 0 1
#> GSM1253052 2 0 1 0 1
#> GSM1253037 2 0 1 0 1
#> GSM1253028 2 0 1 0 1
#> GSM1253029 2 0 1 0 1
#> GSM1253030 2 0 1 0 1
#> GSM1253031 2 0 1 0 1
#> GSM1253033 2 0 1 0 1
#> GSM1253035 2 0 1 0 1
#> GSM1253036 2 0 1 0 1
#> GSM1253038 2 0 1 0 1
#> GSM1253042 2 0 1 0 1
#> GSM1253045 2 0 1 0 1
#> GSM1253043 2 0 1 0 1
#> GSM1253044 2 0 1 0 1
#> GSM1253047 2 0 1 0 1
#> GSM1253050 2 0 1 0 1
#> GSM1253051 2 0 1 0 1
#> GSM1253053 2 0 1 0 1
#> GSM1253054 2 0 1 0 1
#> GSM1253055 2 0 1 0 1
#> GSM1253079 1 0 1 1 0
#> GSM1253083 1 0 1 1 0
#> GSM1253075 1 0 1 1 0
#> GSM1253077 1 0 1 1 0
#> GSM1253076 1 0 1 1 0
#> GSM1253078 1 0 1 1 0
#> GSM1253081 1 0 1 1 0
#> GSM1253080 1 0 1 1 0
#> GSM1253082 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 3 0.6286 0.542 0.464 0.000 0.536
#> GSM1253057 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253058 3 0.5760 0.599 0.328 0.000 0.672
#> GSM1253059 3 0.5760 0.599 0.328 0.000 0.672
#> GSM1253060 1 0.5760 0.105 0.672 0.000 0.328
#> GSM1253061 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253062 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253063 3 0.6286 0.542 0.464 0.000 0.536
#> GSM1253064 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253065 1 0.6192 -0.275 0.580 0.000 0.420
#> GSM1253066 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253067 3 0.6286 0.542 0.464 0.000 0.536
#> GSM1253068 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253069 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253070 1 0.5529 0.390 0.704 0.000 0.296
#> GSM1253071 1 0.6126 -0.200 0.600 0.000 0.400
#> GSM1253072 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253073 3 0.6286 0.542 0.464 0.000 0.536
#> GSM1253074 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253032 3 0.4796 0.281 0.000 0.220 0.780
#> GSM1253034 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253046 2 0.6669 0.435 0.008 0.524 0.468
#> GSM1253048 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253052 2 0.1289 0.934 0.000 0.968 0.032
#> GSM1253037 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253028 2 0.1163 0.934 0.000 0.972 0.028
#> GSM1253029 2 0.1289 0.934 0.000 0.968 0.032
#> GSM1253030 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253031 2 0.3038 0.889 0.000 0.896 0.104
#> GSM1253033 3 0.5220 0.304 0.012 0.208 0.780
#> GSM1253035 2 0.1289 0.934 0.000 0.968 0.032
#> GSM1253036 2 0.1163 0.934 0.000 0.972 0.028
#> GSM1253038 2 0.0424 0.935 0.000 0.992 0.008
#> GSM1253042 2 0.1289 0.934 0.000 0.968 0.032
#> GSM1253045 2 0.2959 0.890 0.000 0.900 0.100
#> GSM1253043 2 0.1163 0.934 0.000 0.972 0.028
#> GSM1253044 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253047 2 0.6291 0.450 0.000 0.532 0.468
#> GSM1253050 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.935 0.000 1.000 0.000
#> GSM1253053 2 0.1289 0.934 0.000 0.968 0.032
#> GSM1253054 2 0.5785 0.652 0.000 0.668 0.332
#> GSM1253055 2 0.1289 0.934 0.000 0.968 0.032
#> GSM1253079 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253083 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253075 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253077 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253076 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253078 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253081 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253080 1 0.0000 0.890 1.000 0.000 0.000
#> GSM1253082 1 0.0000 0.890 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253059 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253060 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253061 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253062 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253064 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253065 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253066 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253067 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253069 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253071 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253073 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253032 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253034 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253048 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253030 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253033 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253035 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253038 2 0.2216 0.892 0.000 0.908 0.092 0.000
#> GSM1253042 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253045 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253050 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.991 0.000 1.000 0.000 0.000
#> GSM1253053 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253054 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253055 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.1716 0.769 0.936 0.000 0.000 0.064
#> GSM1253075 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.776 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.4746 0.688 0.632 0.000 0.000 0.368
#> GSM1253080 1 0.0707 0.775 0.980 0.000 0.000 0.020
#> GSM1253082 1 0.4746 0.688 0.632 0.000 0.000 0.368
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253057 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253058 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253059 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253060 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253061 5 0.366 1.000 0.276 0.000 0.000 0 0.724
#> GSM1253062 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253063 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253064 5 0.366 1.000 0.276 0.000 0.000 0 0.724
#> GSM1253065 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253066 5 0.366 1.000 0.276 0.000 0.000 0 0.724
#> GSM1253067 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253068 5 0.366 1.000 0.276 0.000 0.000 0 0.724
#> GSM1253069 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253070 3 0.678 -0.361 0.276 0.000 0.376 0 0.348
#> GSM1253071 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253072 5 0.366 1.000 0.276 0.000 0.000 0 0.724
#> GSM1253073 4 0.000 1.000 0.000 0.000 0.000 1 0.000
#> GSM1253074 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253032 3 0.000 0.786 0.000 0.000 1.000 0 0.000
#> GSM1253034 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253039 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253040 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253041 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253046 3 0.000 0.786 0.000 0.000 1.000 0 0.000
#> GSM1253048 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253049 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253052 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253037 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253028 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253029 3 0.379 0.884 0.000 0.004 0.724 0 0.272
#> GSM1253030 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253031 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253033 3 0.000 0.786 0.000 0.000 1.000 0 0.000
#> GSM1253035 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253036 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253038 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253042 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253045 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253043 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253044 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253047 3 0.000 0.786 0.000 0.000 1.000 0 0.000
#> GSM1253050 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253051 2 0.000 1.000 0.000 1.000 0.000 0 0.000
#> GSM1253053 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253054 3 0.000 0.786 0.000 0.000 1.000 0 0.000
#> GSM1253055 3 0.366 0.885 0.000 0.000 0.724 0 0.276
#> GSM1253079 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253083 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253075 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253077 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253076 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253078 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253081 5 0.366 1.000 0.276 0.000 0.000 0 0.724
#> GSM1253080 1 0.000 1.000 1.000 0.000 0.000 0 0.000
#> GSM1253082 5 0.366 1.000 0.276 0.000 0.000 0 0.724
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253057 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253058 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253059 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253060 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253061 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253062 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253063 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253064 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253065 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253066 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253067 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253068 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253069 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253070 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253071 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253072 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253073 4 0.000 1.000 0.000 0 0 1 0 0.000
#> GSM1253074 1 0.171 0.894 0.908 0 0 0 0 0.092
#> GSM1253032 5 0.000 1.000 0.000 0 0 0 1 0.000
#> GSM1253034 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253039 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253040 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253041 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253046 5 0.000 1.000 0.000 0 0 0 1 0.000
#> GSM1253048 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253049 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253052 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253037 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253028 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253029 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253030 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253031 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253033 5 0.000 1.000 0.000 0 0 0 1 0.000
#> GSM1253035 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253036 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253038 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253042 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253045 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253043 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253044 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253047 5 0.000 1.000 0.000 0 0 0 1 0.000
#> GSM1253050 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253051 2 0.000 1.000 0.000 1 0 0 0 0.000
#> GSM1253053 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253054 5 0.000 1.000 0.000 0 0 0 1 0.000
#> GSM1253055 3 0.000 1.000 0.000 0 1 0 0 0.000
#> GSM1253079 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253083 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253075 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253077 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253076 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253078 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253081 6 0.000 1.000 0.000 0 0 0 0 1.000
#> GSM1253080 1 0.000 0.990 1.000 0 0 0 0 0.000
#> GSM1253082 6 0.000 1.000 0.000 0 0 0 0 1.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 infection(p) disease.state(p) individual(p) k
#> MAD:mclust 56 3.60e-03 4.20e-12 0.995 2
#> MAD:mclust 48 9.80e-05 1.38e-10 0.911 3
#> MAD:mclust 56 1.11e-04 4.17e-13 0.934 4
#> MAD:mclust 55 3.22e-05 1.22e-12 0.837 5
#> MAD:mclust 56 8.89e-05 3.40e-12 0.778 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.984 0.994 0.4954 0.507 0.507
#> 3 3 0.782 0.837 0.925 0.3365 0.778 0.578
#> 4 4 0.980 0.933 0.974 0.1139 0.817 0.524
#> 5 5 0.938 0.903 0.944 0.0156 0.971 0.894
#> 6 6 0.874 0.836 0.903 0.0195 0.982 0.933
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
#> GSM1253056 1 0.000 0.989 1.000 0.000
#> GSM1253057 1 0.000 0.989 1.000 0.000
#> GSM1253058 1 0.000 0.989 1.000 0.000
#> GSM1253059 1 0.000 0.989 1.000 0.000
#> GSM1253060 1 0.000 0.989 1.000 0.000
#> GSM1253061 1 0.000 0.989 1.000 0.000
#> GSM1253062 1 0.000 0.989 1.000 0.000
#> GSM1253063 1 0.000 0.989 1.000 0.000
#> GSM1253064 1 0.000 0.989 1.000 0.000
#> GSM1253065 1 0.000 0.989 1.000 0.000
#> GSM1253066 1 0.000 0.989 1.000 0.000
#> GSM1253067 1 0.000 0.989 1.000 0.000
#> GSM1253068 1 0.000 0.989 1.000 0.000
#> GSM1253069 1 0.000 0.989 1.000 0.000
#> GSM1253070 1 0.000 0.989 1.000 0.000
#> GSM1253071 1 0.000 0.989 1.000 0.000
#> GSM1253072 1 0.000 0.989 1.000 0.000
#> GSM1253073 1 0.000 0.989 1.000 0.000
#> GSM1253074 1 0.000 0.989 1.000 0.000
#> GSM1253032 1 0.000 0.989 1.000 0.000
#> GSM1253034 2 0.000 1.000 0.000 1.000
#> GSM1253039 2 0.000 1.000 0.000 1.000
#> GSM1253040 2 0.000 1.000 0.000 1.000
#> GSM1253041 2 0.000 1.000 0.000 1.000
#> GSM1253046 1 0.000 0.989 1.000 0.000
#> GSM1253048 2 0.000 1.000 0.000 1.000
#> GSM1253049 2 0.000 1.000 0.000 1.000
#> GSM1253052 2 0.000 1.000 0.000 1.000
#> GSM1253037 2 0.000 1.000 0.000 1.000
#> GSM1253028 2 0.000 1.000 0.000 1.000
#> GSM1253029 2 0.000 1.000 0.000 1.000
#> GSM1253030 2 0.000 1.000 0.000 1.000
#> GSM1253031 2 0.000 1.000 0.000 1.000
#> GSM1253033 1 0.000 0.989 1.000 0.000
#> GSM1253035 2 0.000 1.000 0.000 1.000
#> GSM1253036 2 0.000 1.000 0.000 1.000
#> GSM1253038 2 0.000 1.000 0.000 1.000
#> GSM1253042 2 0.000 1.000 0.000 1.000
#> GSM1253045 2 0.000 1.000 0.000 1.000
#> GSM1253043 2 0.000 1.000 0.000 1.000
#> GSM1253044 2 0.000 1.000 0.000 1.000
#> GSM1253047 1 0.000 0.989 1.000 0.000
#> GSM1253050 2 0.000 1.000 0.000 1.000
#> GSM1253051 2 0.000 1.000 0.000 1.000
#> GSM1253053 2 0.000 1.000 0.000 1.000
#> GSM1253054 1 0.932 0.466 0.652 0.348
#> GSM1253055 2 0.000 1.000 0.000 1.000
#> GSM1253079 1 0.000 0.989 1.000 0.000
#> GSM1253083 1 0.000 0.989 1.000 0.000
#> GSM1253075 1 0.000 0.989 1.000 0.000
#> GSM1253077 1 0.000 0.989 1.000 0.000
#> GSM1253076 1 0.000 0.989 1.000 0.000
#> GSM1253078 1 0.000 0.989 1.000 0.000
#> GSM1253081 1 0.000 0.989 1.000 0.000
#> GSM1253080 1 0.000 0.989 1.000 0.000
#> GSM1253082 1 0.000 0.989 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253057 3 0.6260 0.142 0.448 0.000 0.552
#> GSM1253058 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253059 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253060 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253061 1 0.4062 0.782 0.836 0.000 0.164
#> GSM1253062 1 0.6111 0.382 0.604 0.000 0.396
#> GSM1253063 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253064 1 0.4235 0.772 0.824 0.000 0.176
#> GSM1253065 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253066 1 0.4399 0.759 0.812 0.000 0.188
#> GSM1253067 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253068 1 0.5968 0.465 0.636 0.000 0.364
#> GSM1253069 3 0.4796 0.706 0.220 0.000 0.780
#> GSM1253070 3 0.0747 0.831 0.016 0.000 0.984
#> GSM1253071 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253072 1 0.3941 0.788 0.844 0.000 0.156
#> GSM1253073 1 0.0000 0.867 1.000 0.000 0.000
#> GSM1253074 3 0.4291 0.755 0.180 0.000 0.820
#> GSM1253032 3 0.0661 0.825 0.004 0.008 0.988
#> GSM1253034 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253046 3 0.0000 0.827 0.000 0.000 1.000
#> GSM1253048 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253052 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253037 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253028 2 0.0747 0.982 0.000 0.984 0.016
#> GSM1253029 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253030 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253031 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253033 3 0.2448 0.818 0.076 0.000 0.924
#> GSM1253035 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253036 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253038 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253042 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253045 3 0.3038 0.773 0.000 0.104 0.896
#> GSM1253043 3 0.6286 0.171 0.000 0.464 0.536
#> GSM1253044 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253047 3 0.0000 0.827 0.000 0.000 1.000
#> GSM1253050 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253051 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253053 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253054 3 0.1289 0.813 0.000 0.032 0.968
#> GSM1253055 2 0.0000 0.999 0.000 1.000 0.000
#> GSM1253079 1 0.6180 0.323 0.584 0.000 0.416
#> GSM1253083 3 0.0592 0.831 0.012 0.000 0.988
#> GSM1253075 3 0.5529 0.579 0.296 0.000 0.704
#> GSM1253077 3 0.0592 0.831 0.012 0.000 0.988
#> GSM1253076 3 0.4178 0.762 0.172 0.000 0.828
#> GSM1253078 3 0.3619 0.789 0.136 0.000 0.864
#> GSM1253081 1 0.0237 0.865 0.996 0.000 0.004
#> GSM1253080 3 0.2537 0.818 0.080 0.000 0.920
#> GSM1253082 1 0.0000 0.867 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253057 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253058 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253059 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253060 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253061 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253062 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253063 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253064 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253065 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253066 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253067 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253068 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253069 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253070 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253071 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253072 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253073 4 0.000 0.947 0.00 0.000 0.000 1.00
#> GSM1253074 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253032 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253034 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253039 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253040 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253041 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253046 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253048 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253049 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253052 2 0.164 0.922 0.00 0.940 0.060 0.00
#> GSM1253037 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253028 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253029 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253030 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253031 3 0.322 0.802 0.00 0.164 0.836 0.00
#> GSM1253033 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253035 2 0.215 0.893 0.00 0.912 0.088 0.00
#> GSM1253036 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253038 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253042 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253045 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253043 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253044 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253047 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253050 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253051 2 0.000 0.972 0.00 1.000 0.000 0.00
#> GSM1253053 2 0.456 0.509 0.00 0.672 0.328 0.00
#> GSM1253054 3 0.000 0.964 0.00 0.000 1.000 0.00
#> GSM1253055 3 0.179 0.910 0.00 0.068 0.932 0.00
#> GSM1253079 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253083 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253075 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253077 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253076 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253078 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253081 4 0.479 0.356 0.38 0.000 0.000 0.62
#> GSM1253080 1 0.000 0.977 1.00 0.000 0.000 0.00
#> GSM1253082 1 0.471 0.392 0.64 0.000 0.000 0.36
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 3 0.4088 0.843 0.000 0.000 0.632 0.368 0.000
#> GSM1253057 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.1043 0.942 0.000 0.000 0.040 0.960 0.000
#> GSM1253059 4 0.1043 0.915 0.000 0.000 0.040 0.960 0.000
#> GSM1253060 4 0.1270 0.928 0.000 0.000 0.052 0.948 0.000
#> GSM1253061 1 0.0162 0.965 0.996 0.000 0.000 0.004 0.000
#> GSM1253062 1 0.0162 0.965 0.996 0.000 0.004 0.000 0.000
#> GSM1253063 4 0.0162 0.951 0.000 0.000 0.004 0.996 0.000
#> GSM1253064 1 0.0290 0.963 0.992 0.000 0.008 0.000 0.000
#> GSM1253065 3 0.3305 0.834 0.000 0.000 0.776 0.224 0.000
#> GSM1253066 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253067 3 0.3876 0.886 0.000 0.000 0.684 0.316 0.000
#> GSM1253068 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.4722 0.363 0.608 0.000 0.024 0.000 0.368
#> GSM1253071 4 0.0963 0.947 0.000 0.000 0.036 0.964 0.000
#> GSM1253072 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253073 4 0.0162 0.949 0.000 0.000 0.004 0.996 0.000
#> GSM1253074 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0162 0.917 0.000 0.000 0.004 0.000 0.996
#> GSM1253034 2 0.0290 0.943 0.000 0.992 0.008 0.000 0.000
#> GSM1253039 2 0.0290 0.943 0.000 0.992 0.008 0.000 0.000
#> GSM1253040 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0000 0.918 0.000 0.000 0.000 0.000 1.000
#> GSM1253048 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 2 0.0693 0.934 0.000 0.980 0.012 0.000 0.008
#> GSM1253037 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 2 0.4199 0.720 0.000 0.764 0.056 0.000 0.180
#> GSM1253029 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253030 2 0.0794 0.932 0.000 0.972 0.028 0.000 0.000
#> GSM1253031 5 0.1597 0.904 0.000 0.012 0.048 0.000 0.940
#> GSM1253033 5 0.0703 0.916 0.000 0.000 0.024 0.000 0.976
#> GSM1253035 2 0.3885 0.628 0.000 0.724 0.008 0.000 0.268
#> GSM1253036 2 0.1168 0.925 0.000 0.960 0.032 0.000 0.008
#> GSM1253038 2 0.0290 0.943 0.000 0.992 0.008 0.000 0.000
#> GSM1253042 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253045 5 0.1197 0.911 0.000 0.000 0.048 0.000 0.952
#> GSM1253043 5 0.1043 0.913 0.000 0.000 0.040 0.000 0.960
#> GSM1253044 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0404 0.915 0.000 0.000 0.012 0.000 0.988
#> GSM1253050 2 0.0000 0.944 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0162 0.944 0.000 0.996 0.004 0.000 0.000
#> GSM1253053 2 0.4620 0.524 0.000 0.652 0.320 0.000 0.028
#> GSM1253054 5 0.1121 0.900 0.000 0.000 0.044 0.000 0.956
#> GSM1253055 5 0.4130 0.516 0.000 0.292 0.012 0.000 0.696
#> GSM1253079 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.2426 0.874 0.900 0.000 0.036 0.064 0.000
#> GSM1253080 1 0.0000 0.967 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0865 0.945 0.972 0.000 0.004 0.024 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 3 0.3371 0.853 0.000 0.000 0.708 0.292 0.000 NA
#> GSM1253057 1 0.0653 0.939 0.980 0.000 0.004 0.004 0.000 NA
#> GSM1253058 4 0.3121 0.791 0.004 0.000 0.116 0.836 0.000 NA
#> GSM1253059 4 0.2311 0.777 0.000 0.000 0.104 0.880 0.000 NA
#> GSM1253060 4 0.1814 0.842 0.000 0.000 0.100 0.900 0.000 NA
#> GSM1253061 1 0.0458 0.937 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253062 1 0.0914 0.935 0.968 0.000 0.016 0.000 0.000 NA
#> GSM1253063 4 0.0820 0.851 0.000 0.000 0.012 0.972 0.000 NA
#> GSM1253064 1 0.2361 0.891 0.896 0.000 0.008 0.032 0.000 NA
#> GSM1253065 3 0.2260 0.811 0.000 0.000 0.860 0.140 0.000 NA
#> GSM1253066 1 0.1149 0.929 0.960 0.000 0.008 0.008 0.000 NA
#> GSM1253067 3 0.3221 0.878 0.000 0.000 0.736 0.264 0.000 NA
#> GSM1253068 1 0.0692 0.938 0.976 0.000 0.004 0.000 0.000 NA
#> GSM1253069 1 0.0603 0.939 0.980 0.000 0.004 0.000 0.000 NA
#> GSM1253070 1 0.5338 0.142 0.508 0.000 0.020 0.000 0.412 NA
#> GSM1253071 4 0.1858 0.840 0.000 0.000 0.092 0.904 0.000 NA
#> GSM1253072 1 0.0713 0.935 0.972 0.000 0.000 0.000 0.000 NA
#> GSM1253073 4 0.2163 0.813 0.000 0.000 0.016 0.892 0.000 NA
#> GSM1253074 1 0.0458 0.939 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253032 5 0.0363 0.798 0.000 0.000 0.000 0.000 0.988 NA
#> GSM1253034 2 0.0260 0.929 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253039 2 0.0260 0.929 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253040 2 0.0146 0.929 0.000 0.996 0.000 0.000 0.000 NA
#> GSM1253041 2 0.0260 0.928 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253046 5 0.0547 0.797 0.000 0.000 0.000 0.000 0.980 NA
#> GSM1253048 2 0.0000 0.929 0.000 1.000 0.000 0.000 0.000 NA
#> GSM1253049 2 0.0146 0.929 0.000 0.996 0.000 0.000 0.000 NA
#> GSM1253052 2 0.1082 0.916 0.000 0.956 0.000 0.004 0.000 NA
#> GSM1253037 2 0.0000 0.929 0.000 1.000 0.000 0.000 0.000 NA
#> GSM1253028 5 0.5479 0.361 0.000 0.368 0.000 0.000 0.500 NA
#> GSM1253029 2 0.0790 0.922 0.000 0.968 0.000 0.000 0.000 NA
#> GSM1253030 2 0.3446 0.664 0.000 0.692 0.000 0.000 0.000 NA
#> GSM1253031 5 0.3044 0.768 0.000 0.048 0.000 0.000 0.836 NA
#> GSM1253033 5 0.1332 0.794 0.000 0.000 0.012 0.008 0.952 NA
#> GSM1253035 2 0.4230 0.344 0.000 0.612 0.000 0.000 0.364 NA
#> GSM1253036 2 0.3108 0.811 0.000 0.828 0.000 0.000 0.044 NA
#> GSM1253038 2 0.0260 0.928 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253042 2 0.0790 0.923 0.000 0.968 0.000 0.000 0.000 NA
#> GSM1253045 5 0.2558 0.768 0.000 0.000 0.004 0.000 0.840 NA
#> GSM1253043 5 0.3371 0.673 0.000 0.000 0.000 0.000 0.708 NA
#> GSM1253044 2 0.0260 0.928 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253047 5 0.0790 0.795 0.000 0.000 0.000 0.000 0.968 NA
#> GSM1253050 2 0.0146 0.929 0.000 0.996 0.000 0.000 0.000 NA
#> GSM1253051 2 0.0458 0.926 0.000 0.984 0.000 0.000 0.000 NA
#> GSM1253053 2 0.3736 0.775 0.000 0.792 0.144 0.004 0.004 NA
#> GSM1253054 5 0.1333 0.791 0.000 0.000 0.008 0.000 0.944 NA
#> GSM1253055 5 0.4787 0.443 0.000 0.336 0.000 0.000 0.596 NA
#> GSM1253079 1 0.0551 0.940 0.984 0.000 0.004 0.008 0.000 NA
#> GSM1253083 1 0.0458 0.939 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253075 1 0.0146 0.940 0.996 0.000 0.000 0.000 0.000 NA
#> GSM1253077 1 0.0458 0.939 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253076 1 0.0000 0.939 1.000 0.000 0.000 0.000 0.000 NA
#> GSM1253078 1 0.0146 0.939 0.996 0.000 0.000 0.000 0.000 NA
#> GSM1253081 1 0.3425 0.825 0.836 0.000 0.048 0.084 0.000 NA
#> GSM1253080 1 0.0458 0.939 0.984 0.000 0.000 0.000 0.000 NA
#> GSM1253082 1 0.2657 0.866 0.880 0.000 0.020 0.076 0.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 infection(p) disease.state(p) individual(p) k
#> MAD:NMF 55 0.015882 6.02e-09 0.956 2
#> MAD:NMF 51 0.004809 1.14e-08 0.819 3
#> MAD:NMF 54 0.000556 7.17e-11 0.899 4
#> MAD:NMF 55 0.000190 2.25e-10 0.951 5
#> MAD:NMF 52 0.000387 1.02e-09 0.875 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 0.963 0.986 0.4871 0.507 0.507
#> 3 3 0.899 0.933 0.922 0.1696 0.914 0.831
#> 4 4 1.000 0.960 0.984 0.0912 0.960 0.904
#> 5 5 1.000 0.960 0.984 0.1360 0.916 0.779
#> 6 6 1.000 0.987 0.993 0.0152 0.988 0.961
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
#> GSM1253056 1 0.000 1.000 1.0 0.0
#> GSM1253057 1 0.000 1.000 1.0 0.0
#> GSM1253058 1 0.000 1.000 1.0 0.0
#> GSM1253059 1 0.000 1.000 1.0 0.0
#> GSM1253060 1 0.000 1.000 1.0 0.0
#> GSM1253061 1 0.000 1.000 1.0 0.0
#> GSM1253062 1 0.000 1.000 1.0 0.0
#> GSM1253063 1 0.000 1.000 1.0 0.0
#> GSM1253064 1 0.000 1.000 1.0 0.0
#> GSM1253065 1 0.000 1.000 1.0 0.0
#> GSM1253066 1 0.000 1.000 1.0 0.0
#> GSM1253067 1 0.000 1.000 1.0 0.0
#> GSM1253068 1 0.000 1.000 1.0 0.0
#> GSM1253069 1 0.000 1.000 1.0 0.0
#> GSM1253070 1 0.000 1.000 1.0 0.0
#> GSM1253071 1 0.000 1.000 1.0 0.0
#> GSM1253072 1 0.000 1.000 1.0 0.0
#> GSM1253073 1 0.000 1.000 1.0 0.0
#> GSM1253074 1 0.000 1.000 1.0 0.0
#> GSM1253032 1 0.000 1.000 1.0 0.0
#> GSM1253034 2 0.000 0.963 0.0 1.0
#> GSM1253039 2 0.000 0.963 0.0 1.0
#> GSM1253040 2 0.000 0.963 0.0 1.0
#> GSM1253041 2 0.000 0.963 0.0 1.0
#> GSM1253046 1 0.000 1.000 1.0 0.0
#> GSM1253048 2 0.000 0.963 0.0 1.0
#> GSM1253049 2 0.000 0.963 0.0 1.0
#> GSM1253052 2 0.000 0.963 0.0 1.0
#> GSM1253037 2 0.000 0.963 0.0 1.0
#> GSM1253028 2 0.000 0.963 0.0 1.0
#> GSM1253029 2 0.000 0.963 0.0 1.0
#> GSM1253030 2 0.000 0.963 0.0 1.0
#> GSM1253031 2 0.000 0.963 0.0 1.0
#> GSM1253033 1 0.000 1.000 1.0 0.0
#> GSM1253035 2 0.000 0.963 0.0 1.0
#> GSM1253036 2 0.000 0.963 0.0 1.0
#> GSM1253038 2 0.000 0.963 0.0 1.0
#> GSM1253042 2 0.000 0.963 0.0 1.0
#> GSM1253045 2 0.971 0.364 0.4 0.6
#> GSM1253043 2 0.971 0.364 0.4 0.6
#> GSM1253044 2 0.000 0.963 0.0 1.0
#> GSM1253047 1 0.000 1.000 1.0 0.0
#> GSM1253050 2 0.000 0.963 0.0 1.0
#> GSM1253051 2 0.000 0.963 0.0 1.0
#> GSM1253053 2 0.000 0.963 0.0 1.0
#> GSM1253054 1 0.000 1.000 1.0 0.0
#> GSM1253055 2 0.000 0.963 0.0 1.0
#> GSM1253079 1 0.000 1.000 1.0 0.0
#> GSM1253083 1 0.000 1.000 1.0 0.0
#> GSM1253075 1 0.000 1.000 1.0 0.0
#> GSM1253077 1 0.000 1.000 1.0 0.0
#> GSM1253076 1 0.000 1.000 1.0 0.0
#> GSM1253078 1 0.000 1.000 1.0 0.0
#> GSM1253081 1 0.000 1.000 1.0 0.0
#> GSM1253080 1 0.000 1.000 1.0 0.0
#> GSM1253082 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
#> GSM1253056 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253057 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253058 1 0.588 0.595 0.652 0.0 0.348
#> GSM1253059 1 0.613 0.517 0.600 0.0 0.400
#> GSM1253060 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253061 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253062 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253063 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253064 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253065 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253066 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253067 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253068 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253069 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253070 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253071 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253072 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253073 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253074 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253032 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253034 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253039 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253040 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253041 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253046 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253048 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253049 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253052 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253037 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253028 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253029 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253030 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253031 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253033 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253035 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253036 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253038 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253042 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253045 3 0.000 0.532 0.000 0.0 1.000
#> GSM1253043 3 0.000 0.532 0.000 0.0 1.000
#> GSM1253044 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253047 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253050 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253051 2 0.000 1.000 0.000 1.0 0.000
#> GSM1253053 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253054 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253055 3 0.613 0.862 0.000 0.4 0.600
#> GSM1253079 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253083 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253075 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253077 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253076 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253078 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253081 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253080 1 0.000 0.979 1.000 0.0 0.000
#> GSM1253082 1 0.000 0.979 1.000 0.0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253057 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.1716 0.880 0.064 0.000 0.000 0.936
#> GSM1253059 4 0.0000 0.879 0.000 0.000 0.000 1.000
#> GSM1253060 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253061 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253063 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253064 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253065 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253066 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253067 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253068 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253071 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253072 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253073 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253074 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253032 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253034 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253048 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253030 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253033 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253035 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253038 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253045 3 0.4855 0.413 0.000 0.000 0.600 0.400
#> GSM1253043 3 0.4855 0.413 0.000 0.000 0.600 0.400
#> GSM1253044 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253050 2 0.0000 0.997 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0817 0.970 0.000 0.976 0.024 0.000
#> GSM1253053 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253054 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253055 3 0.0000 0.914 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.0000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253057 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253058 4 0.1478 0.871 0.064 0.000 0.000 0.936 0
#> GSM1253059 4 0.0000 0.871 0.000 0.000 0.000 1.000 0
#> GSM1253060 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253061 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253062 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253063 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253064 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253065 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253066 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253067 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253068 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253069 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253070 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253071 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253072 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253073 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253074 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253032 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253034 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253039 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253040 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253041 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253046 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253048 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253049 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253052 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253037 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253028 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253029 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253030 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253031 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253033 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253035 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253036 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253038 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253042 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253045 3 0.4182 0.412 0.000 0.000 0.600 0.400 0
#> GSM1253043 3 0.4182 0.412 0.000 0.000 0.600 0.400 0
#> GSM1253044 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253047 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253050 2 0.0000 0.997 0.000 1.000 0.000 0.000 0
#> GSM1253051 2 0.0703 0.970 0.000 0.976 0.024 0.000 0
#> GSM1253053 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253054 5 0.0000 1.000 0.000 0.000 0.000 0.000 1
#> GSM1253055 3 0.0000 0.914 0.000 0.000 1.000 0.000 0
#> GSM1253079 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253083 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253075 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253077 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253076 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253078 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253081 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253080 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
#> GSM1253082 1 0.0000 1.000 1.000 0.000 0.000 0.000 0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253057 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253058 4 0.1500 0.851 0.052 0.000 0.000 0.936 0 0.012
#> GSM1253059 4 0.0000 0.849 0.000 0.000 0.000 1.000 0 0.000
#> GSM1253060 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253061 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253062 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253063 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253064 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253065 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253066 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253067 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253068 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253069 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253070 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253071 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253072 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253073 1 0.0865 0.972 0.964 0.000 0.000 0.000 0 0.036
#> GSM1253074 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253032 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253034 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253039 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253040 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253041 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253046 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253048 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253049 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253052 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253037 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253028 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253029 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253030 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253031 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253033 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253035 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253036 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253038 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253042 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253045 6 0.0865 1.000 0.000 0.000 0.036 0.000 0 0.964
#> GSM1253043 6 0.0865 1.000 0.000 0.000 0.036 0.000 0 0.964
#> GSM1253044 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253047 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253050 2 0.0000 0.997 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253051 2 0.0632 0.970 0.000 0.976 0.024 0.000 0 0.000
#> GSM1253053 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253054 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253055 3 0.0000 1.000 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253079 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253083 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253075 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253077 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253076 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253078 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253081 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253080 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253082 1 0.0000 0.990 1.000 0.000 0.000 0.000 0 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> ATC:hclust 54 0.0246 4.58e-08 0.950 2
#> ATC:hclust 56 0.0238 2.72e-09 0.851 3
#> ATC:hclust 54 0.0457 1.51e-07 0.938 4
#> ATC:hclust 54 0.0203 1.75e-09 0.912 5
#> ATC:hclust 56 0.0300 3.73e-09 0.810 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.992 0.996 0.4795 0.523 0.523
#> 3 3 0.679 0.664 0.864 0.2393 0.908 0.825
#> 4 4 0.729 0.794 0.808 0.1589 0.801 0.568
#> 5 5 0.687 0.889 0.871 0.0827 0.938 0.781
#> 6 6 0.754 0.817 0.876 0.0507 0.995 0.976
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
#> GSM1253056 1 0.00 0.994 1.000 0.000
#> GSM1253057 1 0.00 0.994 1.000 0.000
#> GSM1253058 1 0.00 0.994 1.000 0.000
#> GSM1253059 1 0.00 0.994 1.000 0.000
#> GSM1253060 1 0.00 0.994 1.000 0.000
#> GSM1253061 1 0.00 0.994 1.000 0.000
#> GSM1253062 1 0.00 0.994 1.000 0.000
#> GSM1253063 1 0.00 0.994 1.000 0.000
#> GSM1253064 1 0.00 0.994 1.000 0.000
#> GSM1253065 1 0.00 0.994 1.000 0.000
#> GSM1253066 1 0.00 0.994 1.000 0.000
#> GSM1253067 1 0.00 0.994 1.000 0.000
#> GSM1253068 1 0.00 0.994 1.000 0.000
#> GSM1253069 1 0.00 0.994 1.000 0.000
#> GSM1253070 1 0.00 0.994 1.000 0.000
#> GSM1253071 1 0.00 0.994 1.000 0.000
#> GSM1253072 1 0.00 0.994 1.000 0.000
#> GSM1253073 1 0.00 0.994 1.000 0.000
#> GSM1253074 1 0.00 0.994 1.000 0.000
#> GSM1253032 1 0.00 0.994 1.000 0.000
#> GSM1253034 2 0.00 1.000 0.000 1.000
#> GSM1253039 2 0.00 1.000 0.000 1.000
#> GSM1253040 2 0.00 1.000 0.000 1.000
#> GSM1253041 2 0.00 1.000 0.000 1.000
#> GSM1253046 1 0.00 0.994 1.000 0.000
#> GSM1253048 2 0.00 1.000 0.000 1.000
#> GSM1253049 2 0.00 1.000 0.000 1.000
#> GSM1253052 2 0.00 1.000 0.000 1.000
#> GSM1253037 2 0.00 1.000 0.000 1.000
#> GSM1253028 2 0.00 1.000 0.000 1.000
#> GSM1253029 2 0.00 1.000 0.000 1.000
#> GSM1253030 2 0.00 1.000 0.000 1.000
#> GSM1253031 2 0.00 1.000 0.000 1.000
#> GSM1253033 1 0.00 0.994 1.000 0.000
#> GSM1253035 2 0.00 1.000 0.000 1.000
#> GSM1253036 2 0.00 1.000 0.000 1.000
#> GSM1253038 2 0.00 1.000 0.000 1.000
#> GSM1253042 2 0.00 1.000 0.000 1.000
#> GSM1253045 1 0.00 0.994 1.000 0.000
#> GSM1253043 1 0.73 0.744 0.796 0.204
#> GSM1253044 2 0.00 1.000 0.000 1.000
#> GSM1253047 1 0.00 0.994 1.000 0.000
#> GSM1253050 2 0.00 1.000 0.000 1.000
#> GSM1253051 2 0.00 1.000 0.000 1.000
#> GSM1253053 2 0.00 1.000 0.000 1.000
#> GSM1253054 1 0.00 0.994 1.000 0.000
#> GSM1253055 2 0.00 1.000 0.000 1.000
#> GSM1253079 1 0.00 0.994 1.000 0.000
#> GSM1253083 1 0.00 0.994 1.000 0.000
#> GSM1253075 1 0.00 0.994 1.000 0.000
#> GSM1253077 1 0.00 0.994 1.000 0.000
#> GSM1253076 1 0.00 0.994 1.000 0.000
#> GSM1253078 1 0.00 0.994 1.000 0.000
#> GSM1253081 1 0.00 0.994 1.000 0.000
#> GSM1253080 1 0.00 0.994 1.000 0.000
#> GSM1253082 1 0.00 0.994 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253057 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253058 1 0.484 0.814 0.776 0.000 0.224
#> GSM1253059 1 0.624 0.592 0.560 0.000 0.440
#> GSM1253060 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253061 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253062 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253063 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253064 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253065 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253066 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253067 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253068 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253069 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253070 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253071 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253072 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253073 1 0.382 0.854 0.852 0.000 0.148
#> GSM1253074 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253032 1 0.493 0.754 0.768 0.000 0.232
#> GSM1253034 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253039 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253040 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253041 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253046 1 0.327 0.848 0.884 0.000 0.116
#> GSM1253048 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253049 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253052 2 0.631 -0.489 0.000 0.500 0.500
#> GSM1253037 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253028 3 0.606 0.443 0.000 0.384 0.616
#> GSM1253029 2 0.631 -0.489 0.000 0.500 0.500
#> GSM1253030 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253031 2 0.631 -0.489 0.000 0.500 0.500
#> GSM1253033 1 0.590 0.610 0.648 0.000 0.352
#> GSM1253035 3 0.631 0.348 0.000 0.500 0.500
#> GSM1253036 3 0.631 0.348 0.000 0.500 0.500
#> GSM1253038 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253042 3 0.631 0.348 0.000 0.500 0.500
#> GSM1253045 3 0.382 0.416 0.148 0.000 0.852
#> GSM1253043 3 0.469 0.446 0.096 0.052 0.852
#> GSM1253044 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253047 1 0.429 0.799 0.820 0.000 0.180
#> GSM1253050 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253051 2 0.000 0.742 0.000 1.000 0.000
#> GSM1253053 2 0.631 -0.489 0.000 0.500 0.500
#> GSM1253054 1 0.590 0.610 0.648 0.000 0.352
#> GSM1253055 2 0.631 -0.489 0.000 0.500 0.500
#> GSM1253079 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253083 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253075 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253077 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253076 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253078 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253081 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253080 1 0.000 0.914 1.000 0.000 0.000
#> GSM1253082 1 0.000 0.914 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0000 0.8942 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253058 4 0.2741 0.7784 0.096 0.000 0.012 0.892
#> GSM1253059 4 0.5690 0.5385 0.268 0.000 0.060 0.672
#> GSM1253060 4 0.0000 0.8942 0.000 0.000 0.000 1.000
#> GSM1253061 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253062 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253063 4 0.0188 0.8892 0.004 0.000 0.000 0.996
#> GSM1253064 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253065 4 0.0817 0.8537 0.024 0.000 0.000 0.976
#> GSM1253066 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253067 4 0.0000 0.8942 0.000 0.000 0.000 1.000
#> GSM1253068 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253069 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253070 1 0.4898 0.7016 0.584 0.000 0.000 0.416
#> GSM1253071 4 0.0000 0.8942 0.000 0.000 0.000 1.000
#> GSM1253072 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253073 4 0.0000 0.8942 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253032 1 0.6586 0.2156 0.628 0.000 0.156 0.216
#> GSM1253034 2 0.1302 0.9643 0.044 0.956 0.000 0.000
#> GSM1253039 2 0.1302 0.9643 0.044 0.956 0.000 0.000
#> GSM1253040 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.6781 0.3182 0.596 0.000 0.148 0.256
#> GSM1253048 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.3764 0.8992 0.000 0.216 0.784 0.000
#> GSM1253037 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.3266 0.8706 0.000 0.168 0.832 0.000
#> GSM1253029 3 0.4635 0.8853 0.028 0.216 0.756 0.000
#> GSM1253030 2 0.1867 0.9474 0.072 0.928 0.000 0.000
#> GSM1253031 3 0.3764 0.8992 0.000 0.216 0.784 0.000
#> GSM1253033 1 0.5875 0.0526 0.692 0.000 0.204 0.104
#> GSM1253035 3 0.3764 0.8992 0.000 0.216 0.784 0.000
#> GSM1253036 3 0.4904 0.8780 0.040 0.216 0.744 0.000
#> GSM1253038 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.3764 0.8992 0.000 0.216 0.784 0.000
#> GSM1253045 3 0.3311 0.6429 0.172 0.000 0.828 0.000
#> GSM1253043 3 0.3311 0.6429 0.172 0.000 0.828 0.000
#> GSM1253044 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.6703 0.2861 0.612 0.000 0.156 0.232
#> GSM1253050 2 0.0000 0.9809 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.1867 0.9474 0.072 0.928 0.000 0.000
#> GSM1253053 3 0.3764 0.8992 0.000 0.216 0.784 0.000
#> GSM1253054 1 0.5982 0.0603 0.684 0.000 0.204 0.112
#> GSM1253055 3 0.3764 0.8992 0.000 0.216 0.784 0.000
#> GSM1253079 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253083 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253075 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253077 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253076 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253078 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253081 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253080 1 0.4999 0.7948 0.508 0.000 0.000 0.492
#> GSM1253082 1 0.4999 0.7948 0.508 0.000 0.000 0.492
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.3612 0.882 0.268 0.000 0.000 0.732 0.000
#> GSM1253057 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.5150 0.687 0.132 0.000 0.048 0.744 0.076
#> GSM1253059 4 0.6117 0.490 0.088 0.000 0.048 0.636 0.228
#> GSM1253060 4 0.3636 0.881 0.272 0.000 0.000 0.728 0.000
#> GSM1253061 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> GSM1253062 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> GSM1253063 4 0.3707 0.873 0.284 0.000 0.000 0.716 0.000
#> GSM1253064 1 0.1571 0.940 0.936 0.000 0.060 0.004 0.000
#> GSM1253065 4 0.5218 0.754 0.336 0.000 0.060 0.604 0.000
#> GSM1253066 1 0.1809 0.937 0.928 0.000 0.060 0.012 0.000
#> GSM1253067 4 0.3612 0.882 0.268 0.000 0.000 0.732 0.000
#> GSM1253068 1 0.1809 0.937 0.928 0.000 0.060 0.012 0.000
#> GSM1253069 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.1444 0.909 0.948 0.000 0.000 0.012 0.040
#> GSM1253071 4 0.3612 0.880 0.268 0.000 0.000 0.732 0.000
#> GSM1253072 1 0.1809 0.937 0.928 0.000 0.060 0.012 0.000
#> GSM1253073 4 0.3661 0.880 0.276 0.000 0.000 0.724 0.000
#> GSM1253074 1 0.0000 0.960 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.3988 0.849 0.252 0.000 0.000 0.016 0.732
#> GSM1253034 2 0.3216 0.895 0.000 0.848 0.000 0.108 0.044
#> GSM1253039 2 0.3216 0.895 0.000 0.848 0.000 0.108 0.044
#> GSM1253040 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.4661 0.798 0.324 0.000 0.012 0.012 0.652
#> GSM1253048 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.3293 0.908 0.000 0.108 0.852 0.012 0.028
#> GSM1253037 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.2694 0.908 0.000 0.108 0.876 0.008 0.008
#> GSM1253029 3 0.4142 0.884 0.000 0.108 0.812 0.044 0.036
#> GSM1253030 2 0.3916 0.867 0.000 0.804 0.000 0.104 0.092
#> GSM1253031 3 0.2694 0.908 0.000 0.108 0.876 0.008 0.008
#> GSM1253033 5 0.3016 0.791 0.132 0.000 0.000 0.020 0.848
#> GSM1253035 3 0.2127 0.909 0.000 0.108 0.892 0.000 0.000
#> GSM1253036 3 0.4289 0.869 0.000 0.108 0.804 0.040 0.048
#> GSM1253038 2 0.0609 0.941 0.000 0.980 0.000 0.020 0.000
#> GSM1253042 3 0.3293 0.908 0.000 0.108 0.852 0.012 0.028
#> GSM1253045 3 0.5128 0.641 0.000 0.000 0.656 0.076 0.268
#> GSM1253043 3 0.5128 0.641 0.000 0.000 0.656 0.076 0.268
#> GSM1253044 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.4213 0.825 0.308 0.000 0.000 0.012 0.680
#> GSM1253050 2 0.0000 0.946 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.3916 0.867 0.000 0.804 0.000 0.104 0.092
#> GSM1253053 3 0.3293 0.908 0.000 0.108 0.852 0.012 0.028
#> GSM1253054 5 0.3098 0.810 0.148 0.000 0.000 0.016 0.836
#> GSM1253055 3 0.2445 0.909 0.000 0.108 0.884 0.004 0.004
#> GSM1253079 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> GSM1253083 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> GSM1253075 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> GSM1253077 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> GSM1253076 1 0.0290 0.957 0.992 0.000 0.000 0.008 0.000
#> GSM1253078 1 0.0162 0.960 0.996 0.000 0.000 0.004 0.000
#> GSM1253081 1 0.1809 0.937 0.928 0.000 0.060 0.012 0.000
#> GSM1253080 1 0.1697 0.939 0.932 0.000 0.060 0.008 0.000
#> GSM1253082 1 0.1697 0.939 0.932 0.000 0.060 0.008 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.2260 0.843 0.140 0.000 0.000 0.860 0.000 0.000
#> GSM1253057 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.5126 -0.453 0.056 0.000 0.000 0.564 0.016 0.364
#> GSM1253059 6 0.5655 0.000 0.028 0.000 0.000 0.360 0.084 0.528
#> GSM1253060 4 0.2783 0.837 0.148 0.000 0.000 0.836 0.000 0.016
#> GSM1253061 1 0.0363 0.917 0.988 0.000 0.012 0.000 0.000 0.000
#> GSM1253062 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.2692 0.839 0.148 0.000 0.000 0.840 0.000 0.012
#> GSM1253064 1 0.3128 0.866 0.844 0.000 0.052 0.008 0.000 0.096
#> GSM1253065 4 0.4631 0.655 0.160 0.000 0.000 0.704 0.004 0.132
#> GSM1253066 1 0.4021 0.834 0.788 0.000 0.052 0.024 0.004 0.132
#> GSM1253067 4 0.2260 0.843 0.140 0.000 0.000 0.860 0.000 0.000
#> GSM1253068 1 0.4021 0.834 0.788 0.000 0.052 0.024 0.004 0.132
#> GSM1253069 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0547 0.904 0.980 0.000 0.000 0.000 0.020 0.000
#> GSM1253071 4 0.2340 0.838 0.148 0.000 0.000 0.852 0.000 0.000
#> GSM1253072 1 0.4021 0.834 0.788 0.000 0.052 0.024 0.004 0.132
#> GSM1253073 4 0.2553 0.843 0.144 0.000 0.000 0.848 0.000 0.008
#> GSM1253074 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.2445 0.871 0.108 0.000 0.000 0.020 0.872 0.000
#> GSM1253034 2 0.3526 0.863 0.000 0.828 0.000 0.056 0.028 0.088
#> GSM1253039 2 0.3526 0.863 0.000 0.828 0.000 0.056 0.028 0.088
#> GSM1253040 2 0.0260 0.923 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM1253041 2 0.0260 0.923 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM1253046 5 0.3352 0.832 0.172 0.000 0.012 0.016 0.800 0.000
#> GSM1253048 2 0.0260 0.923 0.000 0.992 0.000 0.000 0.008 0.000
#> GSM1253049 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.2359 0.870 0.000 0.052 0.904 0.016 0.004 0.024
#> GSM1253037 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.2095 0.870 0.000 0.052 0.916 0.004 0.016 0.012
#> GSM1253029 3 0.3037 0.850 0.000 0.052 0.864 0.016 0.004 0.064
#> GSM1253030 2 0.4124 0.782 0.000 0.728 0.000 0.036 0.012 0.224
#> GSM1253031 3 0.2095 0.870 0.000 0.052 0.916 0.004 0.016 0.012
#> GSM1253033 5 0.1785 0.834 0.048 0.000 0.000 0.016 0.928 0.008
#> GSM1253035 3 0.1141 0.872 0.000 0.052 0.948 0.000 0.000 0.000
#> GSM1253036 3 0.3567 0.783 0.000 0.052 0.804 0.000 0.008 0.136
#> GSM1253038 2 0.1421 0.910 0.000 0.944 0.000 0.028 0.028 0.000
#> GSM1253042 3 0.2359 0.870 0.000 0.052 0.904 0.016 0.004 0.024
#> GSM1253045 3 0.5396 0.483 0.000 0.000 0.564 0.000 0.152 0.284
#> GSM1253043 3 0.5396 0.483 0.000 0.000 0.564 0.000 0.152 0.284
#> GSM1253044 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.2968 0.846 0.168 0.000 0.000 0.016 0.816 0.000
#> GSM1253050 2 0.0000 0.923 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.4124 0.782 0.000 0.728 0.000 0.036 0.012 0.224
#> GSM1253053 3 0.2359 0.870 0.000 0.052 0.904 0.016 0.004 0.024
#> GSM1253054 5 0.1738 0.841 0.052 0.000 0.000 0.016 0.928 0.004
#> GSM1253055 3 0.2095 0.870 0.000 0.052 0.916 0.004 0.016 0.012
#> GSM1253079 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.4021 0.834 0.788 0.000 0.052 0.024 0.004 0.132
#> GSM1253080 1 0.3598 0.852 0.816 0.000 0.052 0.012 0.004 0.116
#> GSM1253082 1 0.3319 0.862 0.836 0.000 0.052 0.016 0.000 0.096
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 infection(p) disease.state(p) individual(p) k
#> ATC:kmeans 56 0.030714 2.22e-07 0.937 2
#> ATC:kmeans 45 0.109327 4.72e-06 0.908 3
#> ATC:kmeans 51 0.000363 9.82e-13 0.899 4
#> ATC:kmeans 55 0.000418 7.69e-12 0.811 5
#> ATC:kmeans 52 0.000821 1.44e-10 0.778 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 1.000 1.000 0.4934 0.507 0.507
#> 3 3 0.787 0.910 0.926 0.1922 0.909 0.821
#> 4 4 0.821 0.958 0.911 0.1215 0.889 0.733
#> 5 5 0.917 0.974 0.970 0.0700 0.973 0.911
#> 6 6 0.949 0.930 0.961 0.0412 0.995 0.981
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
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
#> GSM1253056 1 0 1 1 0
#> GSM1253057 1 0 1 1 0
#> GSM1253058 1 0 1 1 0
#> GSM1253059 1 0 1 1 0
#> GSM1253060 1 0 1 1 0
#> GSM1253061 1 0 1 1 0
#> GSM1253062 1 0 1 1 0
#> GSM1253063 1 0 1 1 0
#> GSM1253064 1 0 1 1 0
#> GSM1253065 1 0 1 1 0
#> GSM1253066 1 0 1 1 0
#> GSM1253067 1 0 1 1 0
#> GSM1253068 1 0 1 1 0
#> GSM1253069 1 0 1 1 0
#> GSM1253070 1 0 1 1 0
#> GSM1253071 1 0 1 1 0
#> GSM1253072 1 0 1 1 0
#> GSM1253073 1 0 1 1 0
#> GSM1253074 1 0 1 1 0
#> GSM1253032 1 0 1 1 0
#> GSM1253034 2 0 1 0 1
#> GSM1253039 2 0 1 0 1
#> GSM1253040 2 0 1 0 1
#> GSM1253041 2 0 1 0 1
#> GSM1253046 1 0 1 1 0
#> GSM1253048 2 0 1 0 1
#> GSM1253049 2 0 1 0 1
#> GSM1253052 2 0 1 0 1
#> GSM1253037 2 0 1 0 1
#> GSM1253028 2 0 1 0 1
#> GSM1253029 2 0 1 0 1
#> GSM1253030 2 0 1 0 1
#> GSM1253031 2 0 1 0 1
#> GSM1253033 1 0 1 1 0
#> GSM1253035 2 0 1 0 1
#> GSM1253036 2 0 1 0 1
#> GSM1253038 2 0 1 0 1
#> GSM1253042 2 0 1 0 1
#> GSM1253045 2 0 1 0 1
#> GSM1253043 2 0 1 0 1
#> GSM1253044 2 0 1 0 1
#> GSM1253047 1 0 1 1 0
#> GSM1253050 2 0 1 0 1
#> GSM1253051 2 0 1 0 1
#> GSM1253053 2 0 1 0 1
#> GSM1253054 1 0 1 1 0
#> GSM1253055 2 0 1 0 1
#> GSM1253079 1 0 1 1 0
#> GSM1253083 1 0 1 1 0
#> GSM1253075 1 0 1 1 0
#> GSM1253077 1 0 1 1 0
#> GSM1253076 1 0 1 1 0
#> GSM1253078 1 0 1 1 0
#> GSM1253081 1 0 1 1 0
#> GSM1253080 1 0 1 1 0
#> GSM1253082 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253057 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253058 1 0.502 0.740 0.760 0.000 0.240
#> GSM1253059 1 0.502 0.740 0.760 0.000 0.240
#> GSM1253060 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253061 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253062 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253063 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253064 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253065 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253066 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253067 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253068 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253069 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253070 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253071 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253072 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253073 1 0.497 0.745 0.764 0.000 0.236
#> GSM1253074 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253032 3 0.593 1.000 0.356 0.000 0.644
#> GSM1253034 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253039 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253040 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253041 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253046 3 0.593 1.000 0.356 0.000 0.644
#> GSM1253048 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253049 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253052 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253037 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253028 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253029 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253030 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253031 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253033 3 0.593 1.000 0.356 0.000 0.644
#> GSM1253035 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253036 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253038 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253042 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253045 2 0.327 0.896 0.000 0.884 0.116
#> GSM1253043 2 0.327 0.896 0.000 0.884 0.116
#> GSM1253044 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253047 3 0.593 1.000 0.356 0.000 0.644
#> GSM1253050 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253051 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253053 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253054 3 0.593 1.000 0.356 0.000 0.644
#> GSM1253055 2 0.000 0.991 0.000 1.000 0.000
#> GSM1253079 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253083 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253075 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253077 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253076 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253078 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253081 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253080 1 0.000 0.878 1.000 0.000 0.000
#> GSM1253082 1 0.000 0.878 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.4661 0.966 0.348 0.000 0.000 0.652
#> GSM1253057 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253058 4 0.4193 0.893 0.268 0.000 0.000 0.732
#> GSM1253059 4 0.4343 0.888 0.264 0.000 0.004 0.732
#> GSM1253060 4 0.4679 0.962 0.352 0.000 0.000 0.648
#> GSM1253061 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253062 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.4661 0.966 0.348 0.000 0.000 0.652
#> GSM1253064 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253065 4 0.4679 0.962 0.352 0.000 0.000 0.648
#> GSM1253066 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253067 4 0.4643 0.964 0.344 0.000 0.000 0.656
#> GSM1253068 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253069 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253070 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253071 4 0.4661 0.966 0.348 0.000 0.000 0.652
#> GSM1253072 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253073 4 0.4661 0.966 0.348 0.000 0.000 0.652
#> GSM1253074 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253032 3 0.3400 0.998 0.180 0.000 0.820 0.000
#> GSM1253034 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.3400 0.998 0.180 0.000 0.820 0.000
#> GSM1253048 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253052 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253037 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253028 2 0.0188 0.960 0.000 0.996 0.000 0.004
#> GSM1253029 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253030 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253031 2 0.0188 0.960 0.000 0.996 0.000 0.004
#> GSM1253033 3 0.3356 0.994 0.176 0.000 0.824 0.000
#> GSM1253035 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253036 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253038 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253042 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253045 2 0.7105 0.461 0.000 0.556 0.176 0.268
#> GSM1253043 2 0.7105 0.461 0.000 0.556 0.176 0.268
#> GSM1253044 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253047 3 0.3400 0.998 0.180 0.000 0.820 0.000
#> GSM1253050 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253053 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> GSM1253054 3 0.3400 0.998 0.180 0.000 0.820 0.000
#> GSM1253055 2 0.0188 0.960 0.000 0.996 0.000 0.004
#> GSM1253079 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253080 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> GSM1253082 1 0.0000 1.000 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.3177 0.914 0.208 0.000 0.000 0.792 0.000
#> GSM1253057 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.0000 0.667 0.000 0.000 0.000 1.000 0.000
#> GSM1253059 4 0.0404 0.660 0.000 0.000 0.000 0.988 0.012
#> GSM1253060 4 0.3210 0.910 0.212 0.000 0.000 0.788 0.000
#> GSM1253061 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253062 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.3177 0.914 0.208 0.000 0.000 0.792 0.000
#> GSM1253064 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253065 4 0.3177 0.914 0.208 0.000 0.000 0.792 0.000
#> GSM1253066 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253067 4 0.3143 0.913 0.204 0.000 0.000 0.796 0.000
#> GSM1253068 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253069 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253071 4 0.3143 0.913 0.204 0.000 0.000 0.796 0.000
#> GSM1253072 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253073 4 0.3177 0.914 0.208 0.000 0.000 0.792 0.000
#> GSM1253074 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253032 5 0.0510 0.994 0.016 0.000 0.000 0.000 0.984
#> GSM1253034 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.0510 0.994 0.016 0.000 0.000 0.000 0.984
#> GSM1253048 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253037 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 2 0.0290 0.992 0.000 0.992 0.008 0.000 0.000
#> GSM1253029 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253030 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253031 2 0.0404 0.989 0.000 0.988 0.012 0.000 0.000
#> GSM1253033 5 0.0290 0.983 0.008 0.000 0.000 0.000 0.992
#> GSM1253035 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253036 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253038 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253045 3 0.0162 0.985 0.000 0.004 0.996 0.000 0.000
#> GSM1253043 3 0.0404 0.985 0.000 0.012 0.988 0.000 0.000
#> GSM1253044 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.0609 0.989 0.020 0.000 0.000 0.000 0.980
#> GSM1253050 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253053 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> GSM1253054 5 0.0510 0.994 0.016 0.000 0.000 0.000 0.984
#> GSM1253055 2 0.0290 0.992 0.000 0.992 0.008 0.000 0.000
#> GSM1253079 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
#> GSM1253080 1 0.0000 0.998 1.000 0.000 0.000 0.000 0.000
#> GSM1253082 1 0.0162 0.998 0.996 0.000 0.004 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.1075 0.932 0.048 0.000 0.000 0.952 0 0.000
#> GSM1253057 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253058 4 0.3409 0.379 0.000 0.000 0.000 0.700 0 0.300
#> GSM1253059 6 0.2562 0.000 0.000 0.000 0.000 0.172 0 0.828
#> GSM1253060 4 0.1471 0.910 0.064 0.000 0.000 0.932 0 0.004
#> GSM1253061 1 0.0291 0.994 0.992 0.000 0.000 0.004 0 0.004
#> GSM1253062 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253063 4 0.1219 0.931 0.048 0.000 0.000 0.948 0 0.004
#> GSM1253064 1 0.0291 0.994 0.992 0.000 0.000 0.004 0 0.004
#> GSM1253065 4 0.1285 0.928 0.052 0.000 0.000 0.944 0 0.004
#> GSM1253066 1 0.0291 0.994 0.992 0.000 0.000 0.004 0 0.004
#> GSM1253067 4 0.1219 0.929 0.048 0.000 0.000 0.948 0 0.004
#> GSM1253068 1 0.0291 0.994 0.992 0.000 0.000 0.004 0 0.004
#> GSM1253069 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253070 1 0.0146 0.995 0.996 0.000 0.000 0.000 0 0.004
#> GSM1253071 4 0.1075 0.932 0.048 0.000 0.000 0.952 0 0.000
#> GSM1253072 1 0.0291 0.994 0.992 0.000 0.000 0.004 0 0.004
#> GSM1253073 4 0.1075 0.932 0.048 0.000 0.000 0.952 0 0.000
#> GSM1253074 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253032 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253034 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253039 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253040 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253041 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253046 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253048 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253049 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253052 2 0.1556 0.927 0.000 0.920 0.000 0.000 0 0.080
#> GSM1253037 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253028 2 0.3417 0.850 0.000 0.796 0.044 0.000 0 0.160
#> GSM1253029 2 0.1556 0.927 0.000 0.920 0.000 0.000 0 0.080
#> GSM1253030 2 0.0260 0.942 0.000 0.992 0.000 0.000 0 0.008
#> GSM1253031 2 0.3344 0.856 0.000 0.804 0.044 0.000 0 0.152
#> GSM1253033 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253035 2 0.2135 0.905 0.000 0.872 0.000 0.000 0 0.128
#> GSM1253036 2 0.2260 0.898 0.000 0.860 0.000 0.000 0 0.140
#> GSM1253038 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253042 2 0.1556 0.927 0.000 0.920 0.000 0.000 0 0.080
#> GSM1253045 3 0.1074 0.969 0.000 0.000 0.960 0.028 0 0.012
#> GSM1253043 3 0.0000 0.969 0.000 0.000 1.000 0.000 0 0.000
#> GSM1253044 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253047 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253050 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253051 2 0.0000 0.945 0.000 1.000 0.000 0.000 0 0.000
#> GSM1253053 2 0.1714 0.923 0.000 0.908 0.000 0.000 0 0.092
#> GSM1253054 5 0.0000 1.000 0.000 0.000 0.000 0.000 1 0.000
#> GSM1253055 2 0.3417 0.850 0.000 0.796 0.044 0.000 0 0.160
#> GSM1253079 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253083 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253075 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253077 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253076 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253078 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253081 1 0.0508 0.987 0.984 0.000 0.000 0.012 0 0.004
#> GSM1253080 1 0.0000 0.996 1.000 0.000 0.000 0.000 0 0.000
#> GSM1253082 1 0.0405 0.991 0.988 0.000 0.000 0.008 0 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 infection(p) disease.state(p) individual(p) k
#> ATC:skmeans 56 0.018077 1.69e-08 0.955 2
#> ATC:skmeans 56 0.004693 2.78e-10 0.907 3
#> ATC:skmeans 54 0.000178 8.70e-11 0.880 4
#> ATC:skmeans 56 0.000334 2.11e-10 0.784 5
#> ATC:skmeans 54 0.000524 1.24e-09 0.745 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.4778 0.523 0.523
#> 3 3 1.000 0.992 0.997 0.2118 0.873 0.762
#> 4 4 0.784 0.822 0.890 0.2758 0.843 0.627
#> 5 5 0.776 0.873 0.892 0.0445 0.911 0.689
#> 6 6 0.936 0.915 0.954 0.0315 0.981 0.912
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
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
#> GSM1253056 1 0 1 1 0
#> GSM1253057 1 0 1 1 0
#> GSM1253058 1 0 1 1 0
#> GSM1253059 1 0 1 1 0
#> GSM1253060 1 0 1 1 0
#> GSM1253061 1 0 1 1 0
#> GSM1253062 1 0 1 1 0
#> GSM1253063 1 0 1 1 0
#> GSM1253064 1 0 1 1 0
#> GSM1253065 1 0 1 1 0
#> GSM1253066 1 0 1 1 0
#> GSM1253067 1 0 1 1 0
#> GSM1253068 1 0 1 1 0
#> GSM1253069 1 0 1 1 0
#> GSM1253070 1 0 1 1 0
#> GSM1253071 1 0 1 1 0
#> GSM1253072 1 0 1 1 0
#> GSM1253073 1 0 1 1 0
#> GSM1253074 1 0 1 1 0
#> GSM1253032 1 0 1 1 0
#> GSM1253034 2 0 1 0 1
#> GSM1253039 2 0 1 0 1
#> GSM1253040 2 0 1 0 1
#> GSM1253041 2 0 1 0 1
#> GSM1253046 1 0 1 1 0
#> GSM1253048 2 0 1 0 1
#> GSM1253049 2 0 1 0 1
#> GSM1253052 2 0 1 0 1
#> GSM1253037 2 0 1 0 1
#> GSM1253028 2 0 1 0 1
#> GSM1253029 2 0 1 0 1
#> GSM1253030 2 0 1 0 1
#> GSM1253031 2 0 1 0 1
#> GSM1253033 1 0 1 1 0
#> GSM1253035 2 0 1 0 1
#> GSM1253036 2 0 1 0 1
#> GSM1253038 2 0 1 0 1
#> GSM1253042 2 0 1 0 1
#> GSM1253045 1 0 1 1 0
#> GSM1253043 1 0 1 1 0
#> GSM1253044 2 0 1 0 1
#> GSM1253047 1 0 1 1 0
#> GSM1253050 2 0 1 0 1
#> GSM1253051 2 0 1 0 1
#> GSM1253053 2 0 1 0 1
#> GSM1253054 1 0 1 1 0
#> GSM1253055 2 0 1 0 1
#> GSM1253079 1 0 1 1 0
#> GSM1253083 1 0 1 1 0
#> GSM1253075 1 0 1 1 0
#> GSM1253077 1 0 1 1 0
#> GSM1253076 1 0 1 1 0
#> GSM1253078 1 0 1 1 0
#> GSM1253081 1 0 1 1 0
#> GSM1253080 1 0 1 1 0
#> GSM1253082 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.00 1.000 1 0.000 0.000
#> GSM1253057 1 0.00 1.000 1 0.000 0.000
#> GSM1253058 1 0.00 1.000 1 0.000 0.000
#> GSM1253059 1 0.00 1.000 1 0.000 0.000
#> GSM1253060 1 0.00 1.000 1 0.000 0.000
#> GSM1253061 1 0.00 1.000 1 0.000 0.000
#> GSM1253062 1 0.00 1.000 1 0.000 0.000
#> GSM1253063 1 0.00 1.000 1 0.000 0.000
#> GSM1253064 1 0.00 1.000 1 0.000 0.000
#> GSM1253065 1 0.00 1.000 1 0.000 0.000
#> GSM1253066 1 0.00 1.000 1 0.000 0.000
#> GSM1253067 1 0.00 1.000 1 0.000 0.000
#> GSM1253068 1 0.00 1.000 1 0.000 0.000
#> GSM1253069 1 0.00 1.000 1 0.000 0.000
#> GSM1253070 1 0.00 1.000 1 0.000 0.000
#> GSM1253071 1 0.00 1.000 1 0.000 0.000
#> GSM1253072 1 0.00 1.000 1 0.000 0.000
#> GSM1253073 1 0.00 1.000 1 0.000 0.000
#> GSM1253074 1 0.00 1.000 1 0.000 0.000
#> GSM1253032 1 0.00 1.000 1 0.000 0.000
#> GSM1253034 2 0.00 1.000 0 1.000 0.000
#> GSM1253039 2 0.00 1.000 0 1.000 0.000
#> GSM1253040 2 0.00 1.000 0 1.000 0.000
#> GSM1253041 2 0.00 1.000 0 1.000 0.000
#> GSM1253046 1 0.00 1.000 1 0.000 0.000
#> GSM1253048 2 0.00 1.000 0 1.000 0.000
#> GSM1253049 2 0.00 1.000 0 1.000 0.000
#> GSM1253052 3 0.00 0.983 0 0.000 1.000
#> GSM1253037 2 0.00 1.000 0 1.000 0.000
#> GSM1253028 3 0.00 0.983 0 0.000 1.000
#> GSM1253029 3 0.00 0.983 0 0.000 1.000
#> GSM1253030 2 0.00 1.000 0 1.000 0.000
#> GSM1253031 3 0.00 0.983 0 0.000 1.000
#> GSM1253033 1 0.00 1.000 1 0.000 0.000
#> GSM1253035 3 0.00 0.983 0 0.000 1.000
#> GSM1253036 3 0.00 0.983 0 0.000 1.000
#> GSM1253038 2 0.00 1.000 0 1.000 0.000
#> GSM1253042 3 0.00 0.983 0 0.000 1.000
#> GSM1253045 3 0.00 0.983 0 0.000 1.000
#> GSM1253043 3 0.00 0.983 0 0.000 1.000
#> GSM1253044 2 0.00 1.000 0 1.000 0.000
#> GSM1253047 1 0.00 1.000 1 0.000 0.000
#> GSM1253050 2 0.00 1.000 0 1.000 0.000
#> GSM1253051 3 0.44 0.768 0 0.188 0.812
#> GSM1253053 3 0.00 0.983 0 0.000 1.000
#> GSM1253054 1 0.00 1.000 1 0.000 0.000
#> GSM1253055 3 0.00 0.983 0 0.000 1.000
#> GSM1253079 1 0.00 1.000 1 0.000 0.000
#> GSM1253083 1 0.00 1.000 1 0.000 0.000
#> GSM1253075 1 0.00 1.000 1 0.000 0.000
#> GSM1253077 1 0.00 1.000 1 0.000 0.000
#> GSM1253076 1 0.00 1.000 1 0.000 0.000
#> GSM1253078 1 0.00 1.000 1 0.000 0.000
#> GSM1253081 1 0.00 1.000 1 0.000 0.000
#> GSM1253080 1 0.00 1.000 1 0.000 0.000
#> GSM1253082 1 0.00 1.000 1 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0000 0.750 0.000 0.000 0.000 1.000
#> GSM1253057 1 0.3873 0.754 0.772 0.000 0.000 0.228
#> GSM1253058 4 0.4072 0.759 0.252 0.000 0.000 0.748
#> GSM1253059 4 0.4072 0.759 0.252 0.000 0.000 0.748
#> GSM1253060 4 0.3688 0.770 0.208 0.000 0.000 0.792
#> GSM1253061 1 0.2921 0.802 0.860 0.000 0.000 0.140
#> GSM1253062 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 0.750 0.000 0.000 0.000 1.000
#> GSM1253064 1 0.3801 0.751 0.780 0.000 0.000 0.220
#> GSM1253065 4 0.0000 0.750 0.000 0.000 0.000 1.000
#> GSM1253066 1 0.4072 0.739 0.748 0.000 0.000 0.252
#> GSM1253067 4 0.3975 0.764 0.240 0.000 0.000 0.760
#> GSM1253068 1 0.4072 0.739 0.748 0.000 0.000 0.252
#> GSM1253069 1 0.3400 0.783 0.820 0.000 0.000 0.180
#> GSM1253070 1 0.1211 0.798 0.960 0.000 0.000 0.040
#> GSM1253071 4 0.4072 0.759 0.252 0.000 0.000 0.748
#> GSM1253072 1 0.4072 0.739 0.748 0.000 0.000 0.252
#> GSM1253073 4 0.0000 0.750 0.000 0.000 0.000 1.000
#> GSM1253074 1 0.3024 0.797 0.852 0.000 0.000 0.148
#> GSM1253032 1 0.4992 -0.355 0.524 0.000 0.000 0.476
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253046 1 0.4356 0.723 0.708 0.000 0.000 0.292
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253031 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253033 1 0.1716 0.780 0.936 0.000 0.000 0.064
#> GSM1253035 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253045 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253047 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> GSM1253051 3 0.3486 0.768 0.000 0.188 0.812 0.000
#> GSM1253053 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253054 1 0.2530 0.728 0.888 0.000 0.000 0.112
#> GSM1253055 3 0.0000 0.982 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0188 0.820 0.996 0.000 0.000 0.004
#> GSM1253077 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.820 1.000 0.000 0.000 0.000
#> GSM1253081 4 0.4522 0.296 0.320 0.000 0.000 0.680
#> GSM1253080 1 0.4072 0.739 0.748 0.000 0.000 0.252
#> GSM1253082 4 0.4981 0.304 0.464 0.000 0.000 0.536
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0162 0.849 0.004 0.000 0.000 0.996 0.000
#> GSM1253057 1 0.2516 0.830 0.860 0.000 0.000 0.140 0.000
#> GSM1253058 4 0.2732 0.850 0.160 0.000 0.000 0.840 0.000
#> GSM1253059 4 0.3875 0.825 0.160 0.000 0.000 0.792 0.048
#> GSM1253060 4 0.2329 0.865 0.124 0.000 0.000 0.876 0.000
#> GSM1253061 1 0.1608 0.852 0.928 0.000 0.000 0.072 0.000
#> GSM1253062 1 0.0000 0.873 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0162 0.849 0.004 0.000 0.000 0.996 0.000
#> GSM1253064 1 0.1792 0.859 0.916 0.000 0.000 0.084 0.000
#> GSM1253065 4 0.0162 0.849 0.004 0.000 0.000 0.996 0.000
#> GSM1253066 1 0.2690 0.821 0.844 0.000 0.000 0.156 0.000
#> GSM1253067 4 0.2605 0.859 0.148 0.000 0.000 0.852 0.000
#> GSM1253068 1 0.2690 0.821 0.844 0.000 0.000 0.156 0.000
#> GSM1253069 1 0.1851 0.861 0.912 0.000 0.000 0.088 0.000
#> GSM1253070 1 0.1357 0.836 0.948 0.000 0.000 0.048 0.004
#> GSM1253071 4 0.2732 0.850 0.160 0.000 0.000 0.840 0.000
#> GSM1253072 1 0.2690 0.821 0.844 0.000 0.000 0.156 0.000
#> GSM1253073 4 0.0162 0.849 0.004 0.000 0.000 0.996 0.000
#> GSM1253074 1 0.1410 0.871 0.940 0.000 0.000 0.060 0.000
#> GSM1253032 5 0.5162 0.849 0.308 0.000 0.000 0.064 0.628
#> GSM1253034 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253039 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 5 0.5696 0.742 0.172 0.000 0.000 0.200 0.628
#> GSM1253048 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253037 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253029 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253030 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253031 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253033 5 0.3492 0.775 0.188 0.000 0.000 0.016 0.796
#> GSM1253035 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253036 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253038 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253045 3 0.4251 0.635 0.000 0.000 0.624 0.004 0.372
#> GSM1253043 3 0.4251 0.635 0.000 0.000 0.624 0.004 0.372
#> GSM1253044 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253047 5 0.4101 0.813 0.372 0.000 0.000 0.000 0.628
#> GSM1253050 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 3 0.3003 0.731 0.000 0.188 0.812 0.000 0.000
#> GSM1253053 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253054 5 0.5162 0.849 0.308 0.000 0.000 0.064 0.628
#> GSM1253055 3 0.0000 0.919 0.000 0.000 1.000 0.000 0.000
#> GSM1253079 1 0.0000 0.873 1.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.873 1.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0162 0.873 0.996 0.000 0.000 0.004 0.000
#> GSM1253077 1 0.0000 0.873 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.873 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.873 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.3561 0.719 0.740 0.000 0.000 0.260 0.000
#> GSM1253080 1 0.2690 0.821 0.844 0.000 0.000 0.156 0.000
#> GSM1253082 1 0.2891 0.703 0.824 0.000 0.000 0.176 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.0000 0.968 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253057 1 0.1334 0.943 0.948 0.000 0.000 0.020 0.032 0.000
#> GSM1253058 4 0.0632 0.963 0.024 0.000 0.000 0.976 0.000 0.000
#> GSM1253059 6 0.4648 -0.230 0.040 0.000 0.000 0.464 0.000 0.496
#> GSM1253060 4 0.0458 0.969 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM1253061 1 0.1141 0.928 0.948 0.000 0.000 0.052 0.000 0.000
#> GSM1253062 1 0.0000 0.950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0000 0.968 0.000 0.000 0.000 1.000 0.000 0.000
#> GSM1253064 1 0.0937 0.938 0.960 0.000 0.000 0.040 0.000 0.000
#> GSM1253065 4 0.0777 0.943 0.004 0.000 0.000 0.972 0.024 0.000
#> GSM1253066 1 0.1564 0.939 0.936 0.000 0.000 0.024 0.040 0.000
#> GSM1253067 4 0.0458 0.969 0.016 0.000 0.000 0.984 0.000 0.000
#> GSM1253068 1 0.1564 0.939 0.936 0.000 0.000 0.024 0.040 0.000
#> GSM1253069 1 0.0820 0.949 0.972 0.000 0.000 0.012 0.016 0.000
#> GSM1253070 1 0.2432 0.856 0.876 0.000 0.000 0.024 0.100 0.000
#> GSM1253071 4 0.0632 0.963 0.024 0.000 0.000 0.976 0.000 0.000
#> GSM1253072 1 0.1564 0.939 0.936 0.000 0.000 0.024 0.040 0.000
#> GSM1253073 4 0.0458 0.956 0.000 0.000 0.000 0.984 0.016 0.000
#> GSM1253074 1 0.0820 0.949 0.972 0.000 0.000 0.016 0.012 0.000
#> GSM1253032 5 0.1418 0.956 0.032 0.000 0.000 0.024 0.944 0.000
#> GSM1253034 2 0.0458 0.989 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM1253039 2 0.0458 0.989 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM1253040 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.0458 0.915 0.000 0.000 0.000 0.016 0.984 0.000
#> GSM1253048 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253037 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253029 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253030 2 0.0458 0.989 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM1253031 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253033 5 0.1464 0.944 0.016 0.000 0.000 0.004 0.944 0.036
#> GSM1253035 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253036 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253038 2 0.0458 0.989 0.000 0.984 0.000 0.000 0.016 0.000
#> GSM1253042 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253045 6 0.3198 0.589 0.000 0.000 0.260 0.000 0.000 0.740
#> GSM1253043 6 0.3198 0.589 0.000 0.000 0.260 0.000 0.000 0.740
#> GSM1253044 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.1267 0.940 0.060 0.000 0.000 0.000 0.940 0.000
#> GSM1253050 2 0.0000 0.994 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 3 0.3136 0.639 0.000 0.188 0.796 0.000 0.016 0.000
#> GSM1253053 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253054 5 0.1418 0.956 0.032 0.000 0.000 0.024 0.944 0.000
#> GSM1253055 3 0.0000 0.965 0.000 0.000 1.000 0.000 0.000 0.000
#> GSM1253079 1 0.0000 0.950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253075 1 0.0146 0.950 0.996 0.000 0.000 0.004 0.000 0.000
#> GSM1253077 1 0.0000 0.950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.950 1.000 0.000 0.000 0.000 0.000 0.000
#> GSM1253081 1 0.2867 0.869 0.848 0.000 0.000 0.112 0.040 0.000
#> GSM1253080 1 0.1564 0.939 0.936 0.000 0.000 0.024 0.040 0.000
#> GSM1253082 1 0.2454 0.822 0.840 0.000 0.000 0.160 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> ATC:pam 56 0.030714 2.22e-07 0.937 2
#> ATC:pam 56 0.023827 6.27e-10 0.856 3
#> ATC:pam 53 0.006453 1.27e-10 0.856 4
#> ATC:pam 56 0.000334 7.23e-13 0.865 5
#> ATC:pam 55 0.001056 3.22e-11 0.711 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.981 0.990 0.5082 0.491 0.491
#> 3 3 0.631 0.831 0.864 0.2671 0.671 0.437
#> 4 4 1.000 0.962 0.978 0.1553 0.884 0.678
#> 5 5 0.783 0.856 0.871 0.0602 0.932 0.741
#> 6 6 0.833 0.899 0.906 0.0506 0.933 0.688
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> GSM1253056 1 0.0376 0.997 0.996 0.004
#> GSM1253057 1 0.0000 0.999 1.000 0.000
#> GSM1253058 1 0.0376 0.997 0.996 0.004
#> GSM1253059 1 0.0376 0.997 0.996 0.004
#> GSM1253060 1 0.0376 0.997 0.996 0.004
#> GSM1253061 1 0.0000 0.999 1.000 0.000
#> GSM1253062 1 0.0000 0.999 1.000 0.000
#> GSM1253063 1 0.0376 0.997 0.996 0.004
#> GSM1253064 1 0.0000 0.999 1.000 0.000
#> GSM1253065 1 0.0376 0.997 0.996 0.004
#> GSM1253066 1 0.0000 0.999 1.000 0.000
#> GSM1253067 1 0.0376 0.997 0.996 0.004
#> GSM1253068 1 0.0000 0.999 1.000 0.000
#> GSM1253069 1 0.0000 0.999 1.000 0.000
#> GSM1253070 1 0.0000 0.999 1.000 0.000
#> GSM1253071 1 0.0376 0.997 0.996 0.004
#> GSM1253072 1 0.0000 0.999 1.000 0.000
#> GSM1253073 1 0.0376 0.997 0.996 0.004
#> GSM1253074 1 0.0000 0.999 1.000 0.000
#> GSM1253032 2 0.4939 0.887 0.108 0.892
#> GSM1253034 2 0.0000 0.981 0.000 1.000
#> GSM1253039 2 0.0000 0.981 0.000 1.000
#> GSM1253040 2 0.0000 0.981 0.000 1.000
#> GSM1253041 2 0.0000 0.981 0.000 1.000
#> GSM1253046 2 0.5946 0.847 0.144 0.856
#> GSM1253048 2 0.0000 0.981 0.000 1.000
#> GSM1253049 2 0.0000 0.981 0.000 1.000
#> GSM1253052 2 0.0000 0.981 0.000 1.000
#> GSM1253037 2 0.0000 0.981 0.000 1.000
#> GSM1253028 2 0.0000 0.981 0.000 1.000
#> GSM1253029 2 0.0000 0.981 0.000 1.000
#> GSM1253030 2 0.0000 0.981 0.000 1.000
#> GSM1253031 2 0.0000 0.981 0.000 1.000
#> GSM1253033 2 0.1414 0.968 0.020 0.980
#> GSM1253035 2 0.0000 0.981 0.000 1.000
#> GSM1253036 2 0.0000 0.981 0.000 1.000
#> GSM1253038 2 0.0000 0.981 0.000 1.000
#> GSM1253042 2 0.0000 0.981 0.000 1.000
#> GSM1253045 2 0.0672 0.976 0.008 0.992
#> GSM1253043 2 0.0672 0.976 0.008 0.992
#> GSM1253044 2 0.0000 0.981 0.000 1.000
#> GSM1253047 2 0.7056 0.783 0.192 0.808
#> GSM1253050 2 0.0000 0.981 0.000 1.000
#> GSM1253051 2 0.0000 0.981 0.000 1.000
#> GSM1253053 2 0.0000 0.981 0.000 1.000
#> GSM1253054 2 0.2603 0.949 0.044 0.956
#> GSM1253055 2 0.0000 0.981 0.000 1.000
#> GSM1253079 1 0.0000 0.999 1.000 0.000
#> GSM1253083 1 0.0000 0.999 1.000 0.000
#> GSM1253075 1 0.0000 0.999 1.000 0.000
#> GSM1253077 1 0.0000 0.999 1.000 0.000
#> GSM1253076 1 0.0000 0.999 1.000 0.000
#> GSM1253078 1 0.0000 0.999 1.000 0.000
#> GSM1253081 1 0.0000 0.999 1.000 0.000
#> GSM1253080 1 0.0000 0.999 1.000 0.000
#> GSM1253082 1 0.0000 0.999 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253057 1 0.0000 0.938 1.000 0.000 0.000
#> GSM1253058 3 0.5397 0.694 0.280 0.000 0.720
#> GSM1253059 3 0.5397 0.694 0.280 0.000 0.720
#> GSM1253060 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253061 1 0.1964 0.924 0.944 0.000 0.056
#> GSM1253062 1 0.0424 0.936 0.992 0.000 0.008
#> GSM1253063 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253064 1 0.2066 0.923 0.940 0.000 0.060
#> GSM1253065 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253066 1 0.2066 0.923 0.940 0.000 0.060
#> GSM1253067 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253068 1 0.2066 0.923 0.940 0.000 0.060
#> GSM1253069 1 0.0237 0.937 0.996 0.000 0.004
#> GSM1253070 1 0.5988 0.433 0.632 0.000 0.368
#> GSM1253071 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253072 1 0.2066 0.923 0.940 0.000 0.060
#> GSM1253073 3 0.5431 0.692 0.284 0.000 0.716
#> GSM1253074 1 0.1643 0.917 0.956 0.000 0.044
#> GSM1253032 3 0.3038 0.749 0.104 0.000 0.896
#> GSM1253034 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253039 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253040 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253041 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253046 3 0.3272 0.750 0.104 0.004 0.892
#> GSM1253048 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253049 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253052 3 0.5363 0.686 0.000 0.276 0.724
#> GSM1253037 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253028 3 0.5363 0.684 0.000 0.276 0.724
#> GSM1253029 3 0.5363 0.686 0.000 0.276 0.724
#> GSM1253030 2 0.1031 0.974 0.000 0.976 0.024
#> GSM1253031 3 0.6490 0.700 0.036 0.256 0.708
#> GSM1253033 3 0.2625 0.747 0.084 0.000 0.916
#> GSM1253035 3 0.5760 0.647 0.000 0.328 0.672
#> GSM1253036 3 0.5733 0.651 0.000 0.324 0.676
#> GSM1253038 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253042 3 0.5363 0.686 0.000 0.276 0.724
#> GSM1253045 3 0.2866 0.745 0.076 0.008 0.916
#> GSM1253043 3 0.2866 0.745 0.076 0.008 0.916
#> GSM1253044 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253047 3 0.3349 0.748 0.108 0.004 0.888
#> GSM1253050 2 0.0000 0.994 0.000 1.000 0.000
#> GSM1253051 2 0.1163 0.967 0.000 0.972 0.028
#> GSM1253053 3 0.5327 0.687 0.000 0.272 0.728
#> GSM1253054 3 0.3193 0.750 0.100 0.004 0.896
#> GSM1253055 3 0.5706 0.653 0.000 0.320 0.680
#> GSM1253079 1 0.0424 0.937 0.992 0.000 0.008
#> GSM1253083 1 0.1529 0.920 0.960 0.000 0.040
#> GSM1253075 1 0.1163 0.928 0.972 0.000 0.028
#> GSM1253077 1 0.0000 0.938 1.000 0.000 0.000
#> GSM1253076 1 0.1643 0.917 0.956 0.000 0.044
#> GSM1253078 1 0.1031 0.930 0.976 0.000 0.024
#> GSM1253081 1 0.2066 0.923 0.940 0.000 0.060
#> GSM1253080 1 0.0237 0.937 0.996 0.000 0.004
#> GSM1253082 1 0.2165 0.919 0.936 0.000 0.064
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.0336 0.991 0.008 0.000 0.000 0.992
#> GSM1253057 1 0.0336 0.982 0.992 0.000 0.000 0.008
#> GSM1253058 4 0.0336 0.981 0.000 0.000 0.008 0.992
#> GSM1253059 4 0.0469 0.977 0.000 0.000 0.012 0.988
#> GSM1253060 4 0.0707 0.983 0.020 0.000 0.000 0.980
#> GSM1253061 1 0.1118 0.977 0.964 0.000 0.000 0.036
#> GSM1253062 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253063 4 0.0469 0.991 0.012 0.000 0.000 0.988
#> GSM1253064 1 0.1211 0.975 0.960 0.000 0.000 0.040
#> GSM1253065 4 0.0469 0.991 0.012 0.000 0.000 0.988
#> GSM1253066 1 0.1118 0.977 0.964 0.000 0.000 0.036
#> GSM1253067 4 0.0336 0.991 0.008 0.000 0.000 0.992
#> GSM1253068 1 0.1118 0.977 0.964 0.000 0.000 0.036
#> GSM1253069 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253070 3 0.4420 0.702 0.240 0.000 0.748 0.012
#> GSM1253071 4 0.0336 0.991 0.008 0.000 0.000 0.992
#> GSM1253072 1 0.1118 0.977 0.964 0.000 0.000 0.036
#> GSM1253073 4 0.0469 0.991 0.012 0.000 0.000 0.988
#> GSM1253074 1 0.0469 0.981 0.988 0.000 0.000 0.012
#> GSM1253032 3 0.1722 0.940 0.048 0.000 0.944 0.008
#> GSM1253034 2 0.0336 0.965 0.000 0.992 0.008 0.000
#> GSM1253039 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253040 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253041 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253046 3 0.1722 0.940 0.048 0.000 0.944 0.008
#> GSM1253048 2 0.0336 0.965 0.000 0.992 0.008 0.000
#> GSM1253049 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253052 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253037 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253028 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253029 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253030 2 0.2921 0.850 0.000 0.860 0.140 0.000
#> GSM1253031 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253033 3 0.1022 0.953 0.032 0.000 0.968 0.000
#> GSM1253035 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253036 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253038 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253042 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253045 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253043 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253044 2 0.0188 0.967 0.000 0.996 0.004 0.000
#> GSM1253047 3 0.2101 0.927 0.060 0.000 0.928 0.012
#> GSM1253050 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> GSM1253051 2 0.3074 0.837 0.000 0.848 0.152 0.000
#> GSM1253053 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253054 3 0.1677 0.945 0.040 0.000 0.948 0.012
#> GSM1253055 3 0.0000 0.965 0.000 0.000 1.000 0.000
#> GSM1253079 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253083 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253075 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.982 1.000 0.000 0.000 0.000
#> GSM1253081 1 0.1474 0.966 0.948 0.000 0.000 0.052
#> GSM1253080 1 0.0707 0.981 0.980 0.000 0.000 0.020
#> GSM1253082 1 0.1211 0.975 0.960 0.000 0.000 0.040
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.0404 0.932 0.012 0.000 0.000 0.988 0.000
#> GSM1253057 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253058 4 0.3318 0.789 0.000 0.000 0.008 0.800 0.192
#> GSM1253059 4 0.3318 0.789 0.000 0.000 0.008 0.800 0.192
#> GSM1253060 4 0.0703 0.921 0.024 0.000 0.000 0.976 0.000
#> GSM1253061 5 0.6071 0.994 0.236 0.000 0.000 0.192 0.572
#> GSM1253062 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253063 4 0.0404 0.932 0.012 0.000 0.000 0.988 0.000
#> GSM1253064 5 0.6071 0.994 0.236 0.000 0.000 0.192 0.572
#> GSM1253065 4 0.0510 0.930 0.016 0.000 0.000 0.984 0.000
#> GSM1253066 5 0.6071 0.994 0.236 0.000 0.000 0.192 0.572
#> GSM1253067 4 0.0566 0.931 0.012 0.000 0.000 0.984 0.004
#> GSM1253068 5 0.6071 0.994 0.236 0.000 0.000 0.192 0.572
#> GSM1253069 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253070 1 0.6561 -0.195 0.424 0.000 0.204 0.000 0.372
#> GSM1253071 4 0.0566 0.931 0.012 0.000 0.000 0.984 0.004
#> GSM1253072 5 0.6071 0.994 0.236 0.000 0.000 0.192 0.572
#> GSM1253073 4 0.0404 0.932 0.012 0.000 0.000 0.988 0.000
#> GSM1253074 1 0.1965 0.809 0.904 0.000 0.000 0.000 0.096
#> GSM1253032 3 0.6181 0.639 0.196 0.000 0.552 0.000 0.252
#> GSM1253034 2 0.0290 0.974 0.000 0.992 0.008 0.000 0.000
#> GSM1253039 2 0.0162 0.975 0.000 0.996 0.004 0.000 0.000
#> GSM1253040 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000
#> GSM1253046 3 0.6187 0.637 0.200 0.000 0.552 0.000 0.248
#> GSM1253048 2 0.0290 0.974 0.000 0.992 0.008 0.000 0.000
#> GSM1253049 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000
#> GSM1253052 3 0.0162 0.832 0.000 0.004 0.996 0.000 0.000
#> GSM1253037 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000
#> GSM1253028 3 0.0324 0.832 0.000 0.004 0.992 0.000 0.004
#> GSM1253029 3 0.0162 0.832 0.000 0.004 0.996 0.000 0.000
#> GSM1253030 2 0.2127 0.893 0.000 0.892 0.108 0.000 0.000
#> GSM1253031 3 0.0162 0.832 0.000 0.000 0.996 0.000 0.004
#> GSM1253033 3 0.6021 0.660 0.188 0.000 0.580 0.000 0.232
#> GSM1253035 3 0.0000 0.832 0.000 0.000 1.000 0.000 0.000
#> GSM1253036 3 0.0162 0.832 0.000 0.000 0.996 0.000 0.004
#> GSM1253038 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000
#> GSM1253042 3 0.0162 0.832 0.000 0.004 0.996 0.000 0.000
#> GSM1253045 3 0.4479 0.711 0.000 0.184 0.744 0.000 0.072
#> GSM1253043 3 0.4593 0.710 0.000 0.184 0.736 0.000 0.080
#> GSM1253044 2 0.0162 0.976 0.000 0.996 0.004 0.000 0.000
#> GSM1253047 3 0.6259 0.580 0.248 0.000 0.540 0.000 0.212
#> GSM1253050 2 0.0000 0.976 0.000 1.000 0.000 0.000 0.000
#> GSM1253051 2 0.2280 0.881 0.000 0.880 0.120 0.000 0.000
#> GSM1253053 3 0.0324 0.832 0.000 0.004 0.992 0.000 0.004
#> GSM1253054 3 0.6155 0.643 0.192 0.000 0.556 0.000 0.252
#> GSM1253055 3 0.0162 0.832 0.000 0.000 0.996 0.000 0.004
#> GSM1253079 1 0.0162 0.896 0.996 0.000 0.000 0.000 0.004
#> GSM1253083 1 0.0162 0.896 0.996 0.000 0.000 0.000 0.004
#> GSM1253075 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253077 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253076 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253078 1 0.0000 0.899 1.000 0.000 0.000 0.000 0.000
#> GSM1253081 5 0.6085 0.966 0.216 0.000 0.000 0.212 0.572
#> GSM1253080 1 0.3749 0.634 0.816 0.000 0.000 0.104 0.080
#> GSM1253082 5 0.6071 0.994 0.236 0.000 0.000 0.192 0.572
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.2527 0.933 0.168 0.000 0.000 0.832 0.000 0.000
#> GSM1253057 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253058 4 0.1015 0.797 0.004 0.000 0.004 0.968 0.012 0.012
#> GSM1253059 4 0.1015 0.797 0.004 0.000 0.004 0.968 0.012 0.012
#> GSM1253060 4 0.3190 0.896 0.220 0.000 0.000 0.772 0.000 0.008
#> GSM1253061 1 0.0865 0.897 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM1253062 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253063 4 0.2562 0.933 0.172 0.000 0.000 0.828 0.000 0.000
#> GSM1253064 1 0.0865 0.897 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM1253065 4 0.2631 0.930 0.180 0.000 0.000 0.820 0.000 0.000
#> GSM1253066 1 0.0865 0.897 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM1253067 4 0.2491 0.933 0.164 0.000 0.000 0.836 0.000 0.000
#> GSM1253068 1 0.0865 0.897 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM1253069 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253070 1 0.3885 0.695 0.736 0.000 0.000 0.000 0.044 0.220
#> GSM1253071 4 0.2631 0.931 0.180 0.000 0.000 0.820 0.000 0.000
#> GSM1253072 1 0.0865 0.897 0.964 0.000 0.000 0.000 0.000 0.036
#> GSM1253073 4 0.2562 0.934 0.172 0.000 0.000 0.828 0.000 0.000
#> GSM1253074 1 0.3446 0.605 0.692 0.000 0.000 0.000 0.000 0.308
#> GSM1253032 5 0.1251 0.883 0.024 0.000 0.012 0.000 0.956 0.008
#> GSM1253034 2 0.0291 0.966 0.004 0.992 0.004 0.000 0.000 0.000
#> GSM1253039 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253040 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253041 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253046 5 0.3482 0.823 0.024 0.000 0.012 0.000 0.796 0.168
#> GSM1253048 2 0.0291 0.966 0.004 0.992 0.004 0.000 0.000 0.000
#> GSM1253049 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253052 3 0.1675 0.883 0.000 0.024 0.936 0.000 0.032 0.008
#> GSM1253037 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253028 3 0.2905 0.858 0.004 0.000 0.856 0.000 0.092 0.048
#> GSM1253029 3 0.1663 0.882 0.004 0.024 0.940 0.000 0.024 0.008
#> GSM1253030 2 0.2939 0.845 0.000 0.848 0.120 0.000 0.016 0.016
#> GSM1253031 3 0.1924 0.885 0.004 0.000 0.920 0.000 0.028 0.048
#> GSM1253033 5 0.1710 0.862 0.020 0.000 0.028 0.000 0.936 0.016
#> GSM1253035 3 0.0862 0.890 0.004 0.000 0.972 0.000 0.016 0.008
#> GSM1253036 3 0.1636 0.887 0.004 0.000 0.936 0.000 0.024 0.036
#> GSM1253038 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253042 3 0.1663 0.882 0.004 0.024 0.940 0.000 0.024 0.008
#> GSM1253045 3 0.3721 0.672 0.004 0.000 0.684 0.000 0.308 0.004
#> GSM1253043 3 0.3753 0.686 0.004 0.000 0.696 0.000 0.292 0.008
#> GSM1253044 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253047 5 0.3834 0.814 0.044 0.000 0.012 0.000 0.776 0.168
#> GSM1253050 2 0.0000 0.969 0.000 1.000 0.000 0.000 0.000 0.000
#> GSM1253051 2 0.2806 0.839 0.000 0.844 0.136 0.000 0.016 0.004
#> GSM1253053 3 0.1675 0.883 0.000 0.024 0.936 0.000 0.032 0.008
#> GSM1253054 5 0.1251 0.883 0.024 0.000 0.012 0.000 0.956 0.008
#> GSM1253055 3 0.1938 0.884 0.004 0.000 0.920 0.000 0.036 0.040
#> GSM1253079 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253083 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253075 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253077 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253076 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253078 6 0.1387 1.000 0.068 0.000 0.000 0.000 0.000 0.932
#> GSM1253081 1 0.0363 0.869 0.988 0.000 0.000 0.012 0.000 0.000
#> GSM1253080 1 0.2823 0.774 0.796 0.000 0.000 0.000 0.000 0.204
#> GSM1253082 1 0.0508 0.880 0.984 0.000 0.000 0.004 0.000 0.012
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
Test correlation between subgroups and known annotations. If the known annotation is numeric, one-way ANOVA test is applied, and if the known annotation is discrete, chi-squared contingency table test is applied.
test_to_known_factors(res)
#> n infection(p) disease.state(p) individual(p) k
#> ATC:mclust 56 3.60e-03 4.20e-12 0.995 2
#> ATC:mclust 55 1.57e-05 1.41e-08 0.749 3
#> ATC:mclust 56 4.80e-05 1.44e-12 0.933 4
#> ATC:mclust 55 3.22e-05 1.22e-12 0.837 5
#> ATC:mclust 56 1.06e-04 4.21e-12 0.740 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 51979 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.986 0.994 0.4952 0.507 0.507
#> 3 3 0.628 0.624 0.782 0.2583 0.960 0.921
#> 4 4 0.580 0.785 0.783 0.0948 0.798 0.578
#> 5 5 0.758 0.827 0.882 0.0742 0.920 0.747
#> 6 6 0.742 0.727 0.854 0.0351 0.977 0.917
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
#> GSM1253056 1 0.000 0.990 1.000 0.000
#> GSM1253057 1 0.000 0.990 1.000 0.000
#> GSM1253058 1 0.000 0.990 1.000 0.000
#> GSM1253059 1 0.861 0.607 0.716 0.284
#> GSM1253060 1 0.000 0.990 1.000 0.000
#> GSM1253061 1 0.000 0.990 1.000 0.000
#> GSM1253062 1 0.000 0.990 1.000 0.000
#> GSM1253063 1 0.000 0.990 1.000 0.000
#> GSM1253064 1 0.000 0.990 1.000 0.000
#> GSM1253065 1 0.000 0.990 1.000 0.000
#> GSM1253066 1 0.000 0.990 1.000 0.000
#> GSM1253067 1 0.000 0.990 1.000 0.000
#> GSM1253068 1 0.000 0.990 1.000 0.000
#> GSM1253069 1 0.000 0.990 1.000 0.000
#> GSM1253070 1 0.000 0.990 1.000 0.000
#> GSM1253071 1 0.000 0.990 1.000 0.000
#> GSM1253072 1 0.000 0.990 1.000 0.000
#> GSM1253073 1 0.000 0.990 1.000 0.000
#> GSM1253074 1 0.000 0.990 1.000 0.000
#> GSM1253032 1 0.000 0.990 1.000 0.000
#> GSM1253034 2 0.000 1.000 0.000 1.000
#> GSM1253039 2 0.000 1.000 0.000 1.000
#> GSM1253040 2 0.000 1.000 0.000 1.000
#> GSM1253041 2 0.000 1.000 0.000 1.000
#> GSM1253046 1 0.000 0.990 1.000 0.000
#> GSM1253048 2 0.000 1.000 0.000 1.000
#> GSM1253049 2 0.000 1.000 0.000 1.000
#> GSM1253052 2 0.000 1.000 0.000 1.000
#> GSM1253037 2 0.000 1.000 0.000 1.000
#> GSM1253028 2 0.000 1.000 0.000 1.000
#> GSM1253029 2 0.000 1.000 0.000 1.000
#> GSM1253030 2 0.000 1.000 0.000 1.000
#> GSM1253031 2 0.000 1.000 0.000 1.000
#> GSM1253033 1 0.242 0.951 0.960 0.040
#> GSM1253035 2 0.000 1.000 0.000 1.000
#> GSM1253036 2 0.000 1.000 0.000 1.000
#> GSM1253038 2 0.000 1.000 0.000 1.000
#> GSM1253042 2 0.000 1.000 0.000 1.000
#> GSM1253045 2 0.000 1.000 0.000 1.000
#> GSM1253043 2 0.000 1.000 0.000 1.000
#> GSM1253044 2 0.000 1.000 0.000 1.000
#> GSM1253047 1 0.000 0.990 1.000 0.000
#> GSM1253050 2 0.000 1.000 0.000 1.000
#> GSM1253051 2 0.000 1.000 0.000 1.000
#> GSM1253053 2 0.000 1.000 0.000 1.000
#> GSM1253054 1 0.000 0.990 1.000 0.000
#> GSM1253055 2 0.000 1.000 0.000 1.000
#> GSM1253079 1 0.000 0.990 1.000 0.000
#> GSM1253083 1 0.000 0.990 1.000 0.000
#> GSM1253075 1 0.000 0.990 1.000 0.000
#> GSM1253077 1 0.000 0.990 1.000 0.000
#> GSM1253076 1 0.000 0.990 1.000 0.000
#> GSM1253078 1 0.000 0.990 1.000 0.000
#> GSM1253081 1 0.000 0.990 1.000 0.000
#> GSM1253080 1 0.000 0.990 1.000 0.000
#> GSM1253082 1 0.000 0.990 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> GSM1253056 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253057 1 0.1031 0.6132 0.976 0.000 0.024
#> GSM1253058 1 0.7378 0.0947 0.560 0.036 0.404
#> GSM1253059 3 0.9042 -0.0803 0.356 0.144 0.500
#> GSM1253060 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253061 1 0.2959 0.5929 0.900 0.000 0.100
#> GSM1253062 1 0.2261 0.6023 0.932 0.000 0.068
#> GSM1253063 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253064 1 0.3686 0.5792 0.860 0.000 0.140
#> GSM1253065 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253066 1 0.1411 0.6139 0.964 0.000 0.036
#> GSM1253067 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253068 1 0.4504 0.5764 0.804 0.000 0.196
#> GSM1253069 1 0.5254 0.5312 0.736 0.000 0.264
#> GSM1253070 1 0.5926 0.4354 0.644 0.000 0.356
#> GSM1253071 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253072 1 0.3816 0.5980 0.852 0.000 0.148
#> GSM1253073 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253074 1 0.5859 0.4501 0.656 0.000 0.344
#> GSM1253032 1 0.5926 0.4354 0.644 0.000 0.356
#> GSM1253034 2 0.1031 0.8857 0.000 0.976 0.024
#> GSM1253039 2 0.3816 0.8291 0.000 0.852 0.148
#> GSM1253040 2 0.1964 0.8787 0.000 0.944 0.056
#> GSM1253041 2 0.3619 0.8390 0.000 0.864 0.136
#> GSM1253046 1 0.5926 0.4354 0.644 0.000 0.356
#> GSM1253048 2 0.0747 0.8847 0.000 0.984 0.016
#> GSM1253049 2 0.3116 0.8571 0.000 0.892 0.108
#> GSM1253052 2 0.1163 0.8859 0.000 0.972 0.028
#> GSM1253037 2 0.2878 0.8629 0.000 0.904 0.096
#> GSM1253028 2 0.3752 0.8303 0.000 0.856 0.144
#> GSM1253029 2 0.1529 0.8855 0.000 0.960 0.040
#> GSM1253030 2 0.0592 0.8860 0.000 0.988 0.012
#> GSM1253031 2 0.3752 0.8303 0.000 0.856 0.144
#> GSM1253033 3 0.9735 -0.0664 0.316 0.244 0.440
#> GSM1253035 2 0.3686 0.8326 0.000 0.860 0.140
#> GSM1253036 2 0.3752 0.8303 0.000 0.856 0.144
#> GSM1253038 2 0.1753 0.8833 0.000 0.952 0.048
#> GSM1253042 2 0.0424 0.8855 0.000 0.992 0.008
#> GSM1253045 2 0.8338 0.1758 0.084 0.516 0.400
#> GSM1253043 2 0.3879 0.8243 0.000 0.848 0.152
#> GSM1253044 2 0.3412 0.8480 0.000 0.876 0.124
#> GSM1253047 1 0.5926 0.4354 0.644 0.000 0.356
#> GSM1253050 2 0.3192 0.8549 0.000 0.888 0.112
#> GSM1253051 2 0.0592 0.8849 0.000 0.988 0.012
#> GSM1253053 2 0.0592 0.8846 0.000 0.988 0.012
#> GSM1253054 1 0.8143 0.2338 0.560 0.080 0.360
#> GSM1253055 2 0.3752 0.8303 0.000 0.856 0.144
#> GSM1253079 1 0.3551 0.5825 0.868 0.000 0.132
#> GSM1253083 1 0.4931 0.5553 0.768 0.000 0.232
#> GSM1253075 1 0.3192 0.6091 0.888 0.000 0.112
#> GSM1253077 1 0.5497 0.5048 0.708 0.000 0.292
#> GSM1253076 1 0.3038 0.6090 0.896 0.000 0.104
#> GSM1253078 1 0.3686 0.6001 0.860 0.000 0.140
#> GSM1253081 1 0.5016 0.5276 0.760 0.000 0.240
#> GSM1253080 1 0.5016 0.5502 0.760 0.000 0.240
#> GSM1253082 1 0.5016 0.5276 0.760 0.000 0.240
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> GSM1253056 4 0.4406 0.904 0.300 0.000 0.000 0.700
#> GSM1253057 1 0.0817 0.870 0.976 0.000 0.000 0.024
#> GSM1253058 4 0.5475 0.797 0.236 0.024 0.024 0.716
#> GSM1253059 4 0.5596 0.720 0.232 0.040 0.016 0.712
#> GSM1253060 4 0.4431 0.902 0.304 0.000 0.000 0.696
#> GSM1253061 1 0.2466 0.831 0.900 0.000 0.004 0.096
#> GSM1253062 1 0.1211 0.864 0.960 0.000 0.000 0.040
#> GSM1253063 4 0.4406 0.904 0.300 0.000 0.000 0.700
#> GSM1253064 1 0.2924 0.827 0.884 0.000 0.016 0.100
#> GSM1253065 4 0.4431 0.902 0.304 0.000 0.000 0.696
#> GSM1253066 1 0.3862 0.766 0.824 0.000 0.024 0.152
#> GSM1253067 4 0.4406 0.904 0.300 0.000 0.000 0.700
#> GSM1253068 1 0.3107 0.816 0.884 0.000 0.036 0.080
#> GSM1253069 1 0.0707 0.864 0.980 0.000 0.020 0.000
#> GSM1253070 1 0.3625 0.637 0.828 0.000 0.160 0.012
#> GSM1253071 4 0.4454 0.889 0.308 0.000 0.000 0.692
#> GSM1253072 1 0.3279 0.812 0.872 0.000 0.032 0.096
#> GSM1253073 4 0.4406 0.904 0.300 0.000 0.000 0.700
#> GSM1253074 1 0.1635 0.849 0.948 0.000 0.044 0.008
#> GSM1253032 3 0.7000 0.721 0.404 0.028 0.512 0.056
#> GSM1253034 2 0.2489 0.844 0.000 0.912 0.068 0.020
#> GSM1253039 2 0.4820 0.760 0.000 0.772 0.168 0.060
#> GSM1253040 2 0.2546 0.844 0.000 0.912 0.060 0.028
#> GSM1253041 2 0.3398 0.845 0.000 0.872 0.068 0.060
#> GSM1253046 3 0.6257 0.674 0.436 0.000 0.508 0.056
#> GSM1253048 2 0.0707 0.854 0.000 0.980 0.020 0.000
#> GSM1253049 2 0.2021 0.850 0.000 0.936 0.040 0.024
#> GSM1253052 2 0.4123 0.830 0.000 0.820 0.136 0.044
#> GSM1253037 2 0.3015 0.833 0.000 0.884 0.092 0.024
#> GSM1253028 2 0.4508 0.784 0.004 0.764 0.216 0.016
#> GSM1253029 2 0.3876 0.834 0.000 0.836 0.124 0.040
#> GSM1253030 2 0.3763 0.816 0.000 0.832 0.144 0.024
#> GSM1253031 2 0.5327 0.756 0.000 0.720 0.220 0.060
#> GSM1253033 3 0.7649 0.724 0.300 0.116 0.548 0.036
#> GSM1253035 2 0.3597 0.832 0.000 0.836 0.148 0.016
#> GSM1253036 2 0.3324 0.836 0.000 0.852 0.136 0.012
#> GSM1253038 2 0.2313 0.849 0.000 0.924 0.044 0.032
#> GSM1253042 2 0.4088 0.830 0.000 0.820 0.140 0.040
#> GSM1253045 3 0.7381 0.309 0.180 0.328 0.492 0.000
#> GSM1253043 2 0.7291 0.544 0.148 0.636 0.172 0.044
#> GSM1253044 2 0.2675 0.852 0.000 0.908 0.044 0.048
#> GSM1253047 3 0.6252 0.680 0.432 0.000 0.512 0.056
#> GSM1253050 2 0.2882 0.837 0.000 0.892 0.084 0.024
#> GSM1253051 2 0.2266 0.849 0.000 0.912 0.084 0.004
#> GSM1253053 2 0.3999 0.831 0.000 0.824 0.140 0.036
#> GSM1253054 3 0.7636 0.747 0.332 0.072 0.536 0.060
#> GSM1253055 2 0.4661 0.657 0.000 0.652 0.348 0.000
#> GSM1253079 1 0.1022 0.867 0.968 0.000 0.000 0.032
#> GSM1253083 1 0.0469 0.866 0.988 0.000 0.000 0.012
#> GSM1253075 1 0.0469 0.871 0.988 0.000 0.000 0.012
#> GSM1253077 1 0.0927 0.857 0.976 0.000 0.008 0.016
#> GSM1253076 1 0.0817 0.866 0.976 0.000 0.000 0.024
#> GSM1253078 1 0.0921 0.864 0.972 0.000 0.000 0.028
#> GSM1253081 1 0.4843 -0.197 0.604 0.000 0.000 0.396
#> GSM1253080 1 0.2131 0.851 0.932 0.000 0.036 0.032
#> GSM1253082 4 0.4999 0.521 0.492 0.000 0.000 0.508
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> GSM1253056 4 0.2329 0.822 0.124 0.000 0.000 0.876 NA
#> GSM1253057 1 0.0727 0.902 0.980 0.000 0.004 0.004 NA
#> GSM1253058 4 0.4563 0.646 0.032 0.004 0.008 0.732 NA
#> GSM1253059 4 0.4971 0.469 0.020 0.000 0.004 0.504 NA
#> GSM1253060 4 0.4269 0.674 0.300 0.000 0.000 0.684 NA
#> GSM1253061 1 0.1121 0.897 0.956 0.000 0.000 0.044 NA
#> GSM1253062 1 0.2284 0.881 0.896 0.000 0.004 0.004 NA
#> GSM1253063 4 0.2818 0.822 0.132 0.000 0.000 0.856 NA
#> GSM1253064 1 0.1408 0.895 0.948 0.000 0.000 0.044 NA
#> GSM1253065 4 0.4642 0.617 0.328 0.000 0.004 0.648 NA
#> GSM1253066 1 0.2233 0.873 0.904 0.000 0.000 0.080 NA
#> GSM1253067 4 0.2513 0.819 0.116 0.000 0.000 0.876 NA
#> GSM1253068 1 0.1981 0.883 0.920 0.000 0.000 0.064 NA
#> GSM1253069 1 0.1087 0.902 0.968 0.000 0.008 0.008 NA
#> GSM1253070 1 0.4076 0.721 0.768 0.000 0.200 0.020 NA
#> GSM1253071 4 0.3719 0.805 0.116 0.000 0.000 0.816 NA
#> GSM1253072 1 0.2046 0.881 0.916 0.000 0.000 0.068 NA
#> GSM1253073 4 0.3044 0.816 0.148 0.000 0.004 0.840 NA
#> GSM1253074 1 0.1059 0.901 0.968 0.000 0.008 0.020 NA
#> GSM1253032 3 0.2353 0.727 0.060 0.000 0.908 0.028 NA
#> GSM1253034 2 0.0162 0.959 0.000 0.996 0.000 0.000 NA
#> GSM1253039 2 0.0290 0.957 0.000 0.992 0.000 0.000 NA
#> GSM1253040 2 0.0162 0.958 0.000 0.996 0.000 0.000 NA
#> GSM1253041 2 0.0290 0.958 0.000 0.992 0.000 0.000 NA
#> GSM1253046 3 0.2879 0.709 0.080 0.000 0.880 0.032 NA
#> GSM1253048 2 0.0290 0.958 0.000 0.992 0.008 0.000 NA
#> GSM1253049 2 0.0162 0.958 0.000 0.996 0.000 0.000 NA
#> GSM1253052 2 0.1612 0.950 0.000 0.948 0.024 0.012 NA
#> GSM1253037 2 0.0162 0.958 0.000 0.996 0.000 0.000 NA
#> GSM1253028 3 0.5173 0.182 0.000 0.460 0.500 0.000 NA
#> GSM1253029 2 0.1372 0.951 0.000 0.956 0.024 0.004 NA
#> GSM1253030 2 0.4023 0.821 0.000 0.812 0.048 0.020 NA
#> GSM1253031 3 0.4477 0.651 0.000 0.252 0.708 0.000 NA
#> GSM1253033 3 0.1016 0.738 0.004 0.008 0.972 0.012 NA
#> GSM1253035 2 0.2482 0.902 0.000 0.892 0.084 0.000 NA
#> GSM1253036 2 0.2871 0.885 0.000 0.872 0.088 0.000 NA
#> GSM1253038 2 0.0290 0.957 0.000 0.992 0.000 0.000 NA
#> GSM1253042 2 0.1106 0.954 0.000 0.964 0.012 0.000 NA
#> GSM1253045 3 0.1799 0.745 0.012 0.028 0.940 0.000 NA
#> GSM1253043 3 0.4697 0.677 0.008 0.224 0.720 0.000 NA
#> GSM1253044 2 0.0833 0.957 0.000 0.976 0.016 0.004 NA
#> GSM1253047 3 0.2615 0.719 0.080 0.000 0.892 0.020 NA
#> GSM1253050 2 0.0162 0.958 0.000 0.996 0.000 0.000 NA
#> GSM1253051 2 0.1901 0.937 0.000 0.932 0.040 0.004 NA
#> GSM1253053 2 0.1653 0.948 0.000 0.944 0.028 0.004 NA
#> GSM1253054 3 0.2273 0.740 0.048 0.008 0.920 0.016 NA
#> GSM1253055 3 0.4920 0.497 0.000 0.348 0.620 0.008 NA
#> GSM1253079 1 0.2011 0.884 0.908 0.000 0.000 0.004 NA
#> GSM1253083 1 0.1764 0.890 0.928 0.000 0.008 0.000 NA
#> GSM1253075 1 0.1764 0.891 0.928 0.000 0.008 0.000 NA
#> GSM1253077 1 0.2077 0.883 0.908 0.000 0.008 0.000 NA
#> GSM1253076 1 0.1956 0.887 0.916 0.000 0.008 0.000 NA
#> GSM1253078 1 0.3171 0.809 0.816 0.000 0.008 0.000 NA
#> GSM1253081 1 0.2136 0.869 0.904 0.000 0.000 0.088 NA
#> GSM1253080 1 0.1492 0.898 0.948 0.000 0.008 0.040 NA
#> GSM1253082 1 0.3242 0.761 0.816 0.000 0.000 0.172 NA
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> GSM1253056 4 0.1970 0.604 0.060 0.000 0.028 0.912 0.000 NA
#> GSM1253057 1 0.0582 0.902 0.984 0.000 0.004 0.004 0.004 NA
#> GSM1253058 4 0.3791 -0.240 0.004 0.000 0.300 0.688 0.000 NA
#> GSM1253059 3 0.4275 0.000 0.004 0.000 0.592 0.388 0.000 NA
#> GSM1253060 4 0.4353 0.561 0.204 0.000 0.060 0.724 0.000 NA
#> GSM1253061 1 0.1844 0.892 0.924 0.000 0.024 0.048 0.000 NA
#> GSM1253062 1 0.1382 0.894 0.948 0.000 0.036 0.000 0.008 NA
#> GSM1253063 4 0.4385 0.579 0.120 0.000 0.100 0.756 0.000 NA
#> GSM1253064 1 0.2085 0.893 0.912 0.000 0.024 0.056 0.008 NA
#> GSM1253065 4 0.4864 0.528 0.220 0.000 0.072 0.688 0.008 NA
#> GSM1253066 1 0.2670 0.865 0.872 0.000 0.040 0.084 0.004 NA
#> GSM1253067 4 0.2594 0.573 0.048 0.000 0.040 0.892 0.004 NA
#> GSM1253068 1 0.2237 0.878 0.896 0.000 0.036 0.068 0.000 NA
#> GSM1253069 1 0.0912 0.901 0.972 0.000 0.004 0.008 0.012 NA
#> GSM1253070 1 0.4069 0.736 0.760 0.000 0.028 0.012 0.188 NA
#> GSM1253071 4 0.3794 0.277 0.040 0.000 0.216 0.744 0.000 NA
#> GSM1253072 1 0.2685 0.866 0.872 0.000 0.044 0.080 0.000 NA
#> GSM1253073 4 0.4030 0.611 0.132 0.000 0.068 0.780 0.000 NA
#> GSM1253074 1 0.1116 0.901 0.960 0.000 0.004 0.028 0.008 NA
#> GSM1253032 5 0.0951 0.755 0.020 0.000 0.000 0.004 0.968 NA
#> GSM1253034 2 0.0547 0.882 0.000 0.980 0.000 0.000 0.000 NA
#> GSM1253039 2 0.1531 0.858 0.000 0.928 0.004 0.000 0.000 NA
#> GSM1253040 2 0.0790 0.877 0.000 0.968 0.000 0.000 0.000 NA
#> GSM1253041 2 0.0260 0.880 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253046 5 0.1074 0.753 0.028 0.000 0.000 0.000 0.960 NA
#> GSM1253048 2 0.0547 0.879 0.000 0.980 0.000 0.000 0.000 NA
#> GSM1253049 2 0.0713 0.877 0.000 0.972 0.000 0.000 0.000 NA
#> GSM1253052 2 0.1075 0.877 0.000 0.952 0.000 0.000 0.000 NA
#> GSM1253037 2 0.0260 0.881 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253028 2 0.6459 -0.242 0.000 0.348 0.004 0.008 0.324 NA
#> GSM1253029 2 0.0713 0.881 0.000 0.972 0.000 0.000 0.000 NA
#> GSM1253030 2 0.4520 0.530 0.000 0.580 0.016 0.008 0.004 NA
#> GSM1253031 5 0.5852 0.472 0.000 0.240 0.004 0.000 0.516 NA
#> GSM1253033 5 0.1657 0.744 0.000 0.000 0.016 0.000 0.928 NA
#> GSM1253035 2 0.3682 0.768 0.000 0.792 0.008 0.000 0.052 NA
#> GSM1253036 2 0.3915 0.685 0.000 0.704 0.004 0.000 0.020 NA
#> GSM1253038 2 0.1531 0.859 0.000 0.928 0.004 0.000 0.000 NA
#> GSM1253042 2 0.0865 0.875 0.000 0.964 0.000 0.000 0.000 NA
#> GSM1253045 5 0.2660 0.736 0.008 0.016 0.004 0.000 0.872 NA
#> GSM1253043 5 0.5400 0.592 0.000 0.112 0.024 0.000 0.628 NA
#> GSM1253044 2 0.0937 0.874 0.000 0.960 0.000 0.000 0.000 NA
#> GSM1253047 5 0.0935 0.752 0.032 0.000 0.000 0.000 0.964 NA
#> GSM1253050 2 0.0260 0.880 0.000 0.992 0.000 0.000 0.000 NA
#> GSM1253051 2 0.2814 0.795 0.000 0.820 0.008 0.000 0.000 NA
#> GSM1253053 2 0.1753 0.855 0.000 0.912 0.000 0.000 0.004 NA
#> GSM1253054 5 0.1368 0.756 0.012 0.004 0.008 0.004 0.956 NA
#> GSM1253055 5 0.6377 0.382 0.000 0.276 0.012 0.004 0.444 NA
#> GSM1253079 1 0.1080 0.899 0.960 0.000 0.032 0.000 0.004 NA
#> GSM1253083 1 0.2113 0.881 0.912 0.000 0.048 0.000 0.008 NA
#> GSM1253075 1 0.1511 0.892 0.944 0.000 0.032 0.000 0.012 NA
#> GSM1253077 1 0.2414 0.871 0.896 0.000 0.056 0.000 0.012 NA
#> GSM1253076 1 0.2484 0.876 0.896 0.000 0.056 0.004 0.012 NA
#> GSM1253078 1 0.3174 0.831 0.840 0.000 0.108 0.000 0.012 NA
#> GSM1253081 1 0.3125 0.852 0.852 0.000 0.040 0.092 0.004 NA
#> GSM1253080 1 0.1679 0.900 0.936 0.000 0.016 0.036 0.012 NA
#> GSM1253082 1 0.3617 0.790 0.800 0.000 0.044 0.144 0.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 infection(p) disease.state(p) individual(p) k
#> ATC:NMF 56 0.018077 1.69e-08 0.955 2
#> ATC:NMF 46 0.004646 5.67e-10 0.929 3
#> ATC:NMF 54 0.002595 1.39e-09 0.853 4
#> ATC:NMF 53 0.000226 9.38e-11 0.826 5
#> ATC:NMF 50 0.000460 1.38e-09 0.827 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