Date: 2019-12-25 23:37:22 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 14902 rows and 52 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 14902 52
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:kmeans | 2 | 1.000 | 0.965 | 0.979 | ** | |
SD:pam | 4 | 1.000 | 0.929 | 0.968 | ** | 2 |
SD:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:skmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:pam | 2 | 1.000 | 0.977 | 0.989 | ** | |
CV:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
MAD:kmeans | 2 | 1.000 | 0.983 | 0.985 | ** | |
MAD:skmeans | 3 | 1.000 | 0.957 | 0.974 | ** | 2 |
MAD:NMF | 2 | 1.000 | 0.999 | 1.000 | ** | |
ATC:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:NMF | 2 | 1.000 | 0.967 | 0.985 | ** | |
ATC:hclust | 6 | 0.952 | 0.967 | 0.949 | ** | 2,3,4,5 |
ATC:skmeans | 4 | 0.946 | 0.972 | 0.964 | * | 2,3 |
ATC:pam | 6 | 0.944 | 0.875 | 0.939 | * | 2,3 |
SD:hclust | 6 | 0.939 | 0.905 | 0.905 | * | 5 |
CV:hclust | 3 | 0.939 | 0.890 | 0.951 | * | |
SD:mclust | 6 | 0.931 | 0.946 | 0.921 | * | 5 |
MAD:hclust | 5 | 0.931 | 0.866 | 0.902 | * | 2,3,4 |
MAD:pam | 4 | 0.931 | 0.942 | 0.972 | * | 2,3 |
MAD:mclust | 6 | 0.916 | 0.940 | 0.903 | * | 5 |
SD:skmeans | 5 | 0.908 | 0.838 | 0.908 | * | 2 |
CV:mclust | 6 | 0.908 | 0.865 | 0.890 | * | 5 |
CV:kmeans | 2 | 0.781 | 0.912 | 0.954 | ||
ATC:mclust | 2 | 0.683 | 0.961 | 0.950 |
**: 1-PAC > 0.95, *: 1-PAC > 0.9
Cumulative distribution function curves of consensus matrix for all methods.
collect_plots(res_list, fun = plot_ecdf)
Consensus heatmaps for all methods. (What is a consensus heatmap?)
collect_plots(res_list, k = 2, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = consensus_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = consensus_heatmap, mc.cores = 4)
Membership heatmaps for all methods. (What is a membership heatmap?)
collect_plots(res_list, k = 2, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 3, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 4, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 5, fun = membership_heatmap, mc.cores = 4)
collect_plots(res_list, k = 6, fun = membership_heatmap, mc.cores = 4)
Signature heatmaps for all methods. (What is a signature heatmap?)
Note in following heatmaps, rows are scaled.
collect_plots(res_list, k = 2, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 3, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 4, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 5, fun = get_signatures, mc.cores = 4)
collect_plots(res_list, k = 6, fun = get_signatures, mc.cores = 4)
The statistics used for measuring the stability of consensus partitioning. (How are they defined?)
get_stats(res_list, k = 2)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 2 1.000 1.000 1.000 0.510 0.491 0.491
#> CV:NMF 2 1.000 1.000 1.000 0.510 0.491 0.491
#> MAD:NMF 2 1.000 0.999 1.000 0.510 0.491 0.491
#> ATC:NMF 2 1.000 0.967 0.985 0.501 0.502 0.502
#> SD:skmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> CV:skmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> MAD:skmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> ATC:skmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> SD:mclust 2 0.464 0.769 0.871 0.481 0.509 0.509
#> CV:mclust 2 0.694 0.827 0.906 0.432 0.618 0.618
#> MAD:mclust 2 0.805 0.951 0.957 0.492 0.502 0.502
#> ATC:mclust 2 0.683 0.961 0.950 0.475 0.493 0.493
#> SD:kmeans 2 1.000 0.965 0.979 0.504 0.491 0.491
#> CV:kmeans 2 0.781 0.912 0.954 0.499 0.491 0.491
#> MAD:kmeans 2 1.000 0.983 0.985 0.505 0.491 0.491
#> ATC:kmeans 2 1.000 1.000 1.000 0.510 0.491 0.491
#> SD:pam 2 1.000 0.971 0.985 0.507 0.493 0.493
#> CV:pam 2 1.000 0.977 0.989 0.500 0.502 0.502
#> MAD:pam 2 1.000 0.973 0.987 0.508 0.493 0.493
#> ATC:pam 2 1.000 0.980 0.990 0.509 0.491 0.491
#> SD:hclust 2 0.638 0.920 0.949 0.470 0.538 0.538
#> CV:hclust 2 0.792 0.968 0.974 0.499 0.502 0.502
#> MAD:hclust 2 1.000 0.978 0.984 0.465 0.538 0.538
#> ATC:hclust 2 1.000 0.999 0.999 0.462 0.538 0.538
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.709 0.807 0.808 0.240 0.891 0.779
#> CV:NMF 3 0.630 0.673 0.842 0.245 0.801 0.622
#> MAD:NMF 3 0.663 0.808 0.842 0.253 0.891 0.779
#> ATC:NMF 3 0.776 0.850 0.911 0.321 0.767 0.560
#> SD:skmeans 3 0.888 0.952 0.972 0.261 0.842 0.686
#> CV:skmeans 3 0.875 0.917 0.960 0.234 0.889 0.777
#> MAD:skmeans 3 1.000 0.957 0.974 0.243 0.842 0.686
#> ATC:skmeans 3 1.000 0.984 0.988 0.174 0.889 0.777
#> SD:mclust 3 0.577 0.811 0.804 0.303 0.824 0.653
#> CV:mclust 3 0.628 0.915 0.899 0.326 0.851 0.758
#> MAD:mclust 3 0.630 0.755 0.796 0.238 0.640 0.448
#> ATC:mclust 3 0.582 0.690 0.784 0.279 0.738 0.543
#> SD:kmeans 3 0.561 0.608 0.755 0.267 0.846 0.695
#> CV:kmeans 3 0.566 0.707 0.742 0.269 0.889 0.799
#> MAD:kmeans 3 0.577 0.634 0.776 0.256 0.889 0.777
#> ATC:kmeans 3 0.686 0.834 0.892 0.288 0.751 0.532
#> SD:pam 3 0.765 0.866 0.910 0.295 0.855 0.706
#> CV:pam 3 0.727 0.791 0.855 0.247 0.891 0.784
#> MAD:pam 3 0.929 0.957 0.978 0.301 0.792 0.600
#> ATC:pam 3 1.000 1.000 1.000 0.298 0.808 0.624
#> SD:hclust 3 0.819 0.875 0.923 0.406 0.801 0.630
#> CV:hclust 3 0.939 0.890 0.951 0.264 0.891 0.784
#> MAD:hclust 3 1.000 0.998 0.998 0.422 0.801 0.630
#> ATC:hclust 3 0.929 0.918 0.959 0.443 0.801 0.630
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.855 0.877 0.932 0.1833 0.864 0.645
#> CV:NMF 4 0.794 0.861 0.902 0.1641 0.733 0.401
#> MAD:NMF 4 0.816 0.816 0.900 0.1627 0.864 0.645
#> ATC:NMF 4 0.817 0.779 0.891 0.0768 0.973 0.916
#> SD:skmeans 4 0.837 0.774 0.810 0.1253 1.000 1.000
#> CV:skmeans 4 0.758 0.663 0.796 0.1150 0.928 0.816
#> MAD:skmeans 4 0.809 0.849 0.902 0.1291 0.910 0.748
#> ATC:skmeans 4 0.946 0.972 0.964 0.0802 0.952 0.879
#> SD:mclust 4 0.824 0.919 0.889 0.1282 0.946 0.837
#> CV:mclust 4 0.679 0.664 0.733 0.2414 0.729 0.452
#> MAD:mclust 4 0.692 0.696 0.743 0.1542 0.710 0.421
#> ATC:mclust 4 0.713 0.711 0.892 0.1581 0.771 0.495
#> SD:kmeans 4 0.594 0.693 0.752 0.1208 0.835 0.620
#> CV:kmeans 4 0.526 0.618 0.727 0.1099 0.767 0.560
#> MAD:kmeans 4 0.561 0.428 0.654 0.1243 0.853 0.651
#> ATC:kmeans 4 0.704 0.787 0.826 0.1028 1.000 1.000
#> SD:pam 4 1.000 0.929 0.968 0.1391 0.803 0.506
#> CV:pam 4 0.787 0.750 0.884 0.1350 0.910 0.770
#> MAD:pam 4 0.931 0.942 0.972 0.1285 0.912 0.740
#> ATC:pam 4 0.857 0.882 0.923 0.1318 0.910 0.733
#> SD:hclust 4 0.758 0.832 0.888 0.0573 0.966 0.900
#> CV:hclust 4 0.837 0.805 0.905 0.1274 0.928 0.816
#> MAD:hclust 4 0.939 0.915 0.923 0.0634 0.966 0.900
#> ATC:hclust 4 1.000 0.979 0.989 0.1009 0.928 0.787
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.732 0.747 0.806 0.0405 0.959 0.851
#> CV:NMF 5 0.742 0.735 0.840 0.0814 0.842 0.485
#> MAD:NMF 5 0.694 0.709 0.786 0.0455 0.959 0.851
#> ATC:NMF 5 0.764 0.715 0.831 0.0672 0.937 0.791
#> SD:skmeans 5 0.908 0.838 0.908 0.0778 0.869 0.635
#> CV:skmeans 5 0.732 0.807 0.852 0.0854 0.864 0.600
#> MAD:skmeans 5 0.883 0.844 0.909 0.0771 0.916 0.713
#> ATC:skmeans 5 0.872 0.912 0.909 0.0683 0.993 0.980
#> SD:mclust 5 1.000 0.976 0.988 0.1157 0.932 0.756
#> CV:mclust 5 0.916 0.908 0.952 0.1234 0.891 0.610
#> MAD:mclust 5 0.977 0.971 0.983 0.1200 0.941 0.782
#> ATC:mclust 5 0.760 0.717 0.879 0.1038 0.869 0.590
#> SD:kmeans 5 0.613 0.649 0.689 0.0710 0.910 0.733
#> CV:kmeans 5 0.543 0.388 0.645 0.0748 0.792 0.528
#> MAD:kmeans 5 0.597 0.665 0.742 0.0699 0.819 0.506
#> ATC:kmeans 5 0.712 0.651 0.699 0.0646 0.930 0.788
#> SD:pam 5 0.865 0.870 0.917 0.0676 0.930 0.728
#> CV:pam 5 0.871 0.831 0.911 0.0959 0.888 0.653
#> MAD:pam 5 0.865 0.908 0.904 0.0676 0.946 0.784
#> ATC:pam 5 0.857 0.881 0.923 0.0725 0.946 0.782
#> SD:hclust 5 0.931 0.904 0.940 0.1268 0.912 0.711
#> CV:hclust 5 0.860 0.814 0.903 0.0981 0.919 0.746
#> MAD:hclust 5 0.931 0.866 0.902 0.1254 0.912 0.711
#> ATC:hclust 5 1.000 0.979 0.989 0.0738 0.946 0.797
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.717 0.742 0.810 0.0331 0.898 0.634
#> CV:NMF 6 0.788 0.772 0.846 0.0360 0.937 0.708
#> MAD:NMF 6 0.735 0.745 0.804 0.0343 0.898 0.634
#> ATC:NMF 6 0.788 0.806 0.854 0.0389 0.871 0.548
#> SD:skmeans 6 0.862 0.811 0.865 0.0343 0.943 0.775
#> CV:skmeans 6 0.778 0.694 0.802 0.0563 0.952 0.792
#> MAD:skmeans 6 0.885 0.882 0.893 0.0348 0.986 0.941
#> ATC:skmeans 6 0.875 0.899 0.880 0.0554 0.959 0.880
#> SD:mclust 6 0.931 0.946 0.921 0.0383 0.968 0.849
#> CV:mclust 6 0.908 0.865 0.890 0.0256 0.986 0.931
#> MAD:mclust 6 0.916 0.940 0.903 0.0366 0.968 0.849
#> ATC:mclust 6 0.890 0.912 0.937 0.0552 0.946 0.765
#> SD:kmeans 6 0.640 0.509 0.674 0.0429 0.896 0.617
#> CV:kmeans 6 0.589 0.534 0.629 0.0523 0.765 0.399
#> MAD:kmeans 6 0.625 0.506 0.665 0.0485 0.966 0.865
#> ATC:kmeans 6 0.702 0.641 0.701 0.0390 0.912 0.685
#> SD:pam 6 0.857 0.759 0.867 0.0285 0.882 0.527
#> CV:pam 6 0.890 0.816 0.872 0.0356 0.975 0.891
#> MAD:pam 6 0.847 0.856 0.882 0.0394 0.968 0.839
#> ATC:pam 6 0.944 0.875 0.939 0.0440 0.910 0.592
#> SD:hclust 6 0.939 0.905 0.905 0.0362 0.959 0.812
#> CV:hclust 6 0.821 0.783 0.782 0.0459 0.946 0.774
#> MAD:hclust 6 0.878 0.776 0.829 0.0348 0.946 0.765
#> ATC:hclust 6 0.952 0.967 0.949 0.0317 0.973 0.872
Following heatmap plots the partition for each combination of methods and the lightness correspond to the silhouette scores for samples in each method. On top the consensus subgroup is inferred from all methods by taking the mean silhouette scores as weight.
collect_stats(res_list, k = 2)
collect_stats(res_list, k = 3)
collect_stats(res_list, k = 4)
collect_stats(res_list, k = 5)
collect_stats(res_list, k = 6)
Collect partitions from all methods:
collect_classes(res_list, k = 2)
collect_classes(res_list, k = 3)
collect_classes(res_list, k = 4)
collect_classes(res_list, k = 5)
collect_classes(res_list, k = 6)
Overlap of top rows from different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "euler")
top_rows_overlap(res_list, top_n = 2000, method = "euler")
top_rows_overlap(res_list, top_n = 3000, method = "euler")
top_rows_overlap(res_list, top_n = 4000, method = "euler")
top_rows_overlap(res_list, top_n = 5000, method = "euler")
Also visualize the correspondance of rankings between different top-row methods:
top_rows_overlap(res_list, top_n = 1000, method = "correspondance")
top_rows_overlap(res_list, top_n = 2000, method = "correspondance")
top_rows_overlap(res_list, top_n = 3000, method = "correspondance")
top_rows_overlap(res_list, top_n = 4000, method = "correspondance")
top_rows_overlap(res_list, top_n = 5000, method = "correspondance")
Heatmaps of the top rows:
top_rows_heatmap(res_list, top_n = 1000)
top_rows_heatmap(res_list, top_n = 2000)
top_rows_heatmap(res_list, top_n = 3000)
top_rows_heatmap(res_list, top_n = 4000)
top_rows_heatmap(res_list, top_n = 5000)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.638 0.920 0.949 0.4700 0.538 0.538
#> 3 3 0.819 0.875 0.923 0.4063 0.801 0.630
#> 4 4 0.758 0.832 0.888 0.0573 0.966 0.900
#> 5 5 0.931 0.904 0.940 0.1268 0.912 0.711
#> 6 6 0.939 0.905 0.905 0.0362 0.959 0.812
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.00 1.000 1.00 0.00
#> SRR886566 1 0.00 1.000 1.00 0.00
#> SRR886567 1 0.00 1.000 1.00 0.00
#> SRR886568 2 0.76 0.812 0.22 0.78
#> SRR886569 2 0.76 0.812 0.22 0.78
#> SRR886570 2 0.76 0.812 0.22 0.78
#> SRR886571 1 0.00 1.000 1.00 0.00
#> SRR886572 1 0.00 1.000 1.00 0.00
#> SRR886573 1 0.00 1.000 1.00 0.00
#> SRR886574 1 0.00 1.000 1.00 0.00
#> SRR886575 1 0.00 1.000 1.00 0.00
#> SRR886576 1 0.00 1.000 1.00 0.00
#> SRR886577 1 0.00 1.000 1.00 0.00
#> SRR886578 1 0.00 1.000 1.00 0.00
#> SRR886579 1 0.00 1.000 1.00 0.00
#> SRR886580 2 0.00 0.913 0.00 1.00
#> SRR886581 2 0.00 0.913 0.00 1.00
#> SRR886582 2 0.00 0.913 0.00 1.00
#> SRR886583 1 0.00 1.000 1.00 0.00
#> SRR886584 1 0.00 1.000 1.00 0.00
#> SRR886585 1 0.00 1.000 1.00 0.00
#> SRR886586 2 0.00 0.913 0.00 1.00
#> SRR886587 2 0.00 0.913 0.00 1.00
#> SRR886588 2 0.00 0.913 0.00 1.00
#> SRR886589 2 0.76 0.812 0.22 0.78
#> SRR886590 2 0.76 0.812 0.22 0.78
#> SRR886591 2 0.76 0.812 0.22 0.78
#> SRR886592 2 0.00 0.913 0.00 1.00
#> SRR886593 2 0.00 0.913 0.00 1.00
#> SRR886594 2 0.00 0.913 0.00 1.00
#> SRR886595 2 0.00 0.913 0.00 1.00
#> SRR886596 2 0.00 0.913 0.00 1.00
#> SRR886597 2 0.00 0.913 0.00 1.00
#> SRR886598 2 0.00 0.913 0.00 1.00
#> SRR886599 2 0.00 0.913 0.00 1.00
#> SRR886600 2 0.00 0.913 0.00 1.00
#> SRR886601 2 0.00 0.913 0.00 1.00
#> SRR886602 1 0.00 1.000 1.00 0.00
#> SRR886603 1 0.00 1.000 1.00 0.00
#> SRR886604 1 0.00 1.000 1.00 0.00
#> SRR886605 2 0.76 0.812 0.22 0.78
#> SRR886606 2 0.76 0.812 0.22 0.78
#> SRR886607 2 0.76 0.812 0.22 0.78
#> SRR886608 2 0.00 0.913 0.00 1.00
#> SRR886609 2 0.00 0.913 0.00 1.00
#> SRR886610 2 0.00 0.913 0.00 1.00
#> SRR886611 2 0.00 0.913 0.00 1.00
#> SRR886612 2 0.00 0.913 0.00 1.00
#> SRR886613 2 0.00 0.913 0.00 1.00
#> SRR886614 2 0.76 0.812 0.22 0.78
#> SRR886615 2 0.76 0.812 0.22 0.78
#> SRR886616 2 0.76 0.812 0.22 0.78
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.000 1.000 1 0.0 0.0
#> SRR886566 1 0.000 1.000 1 0.0 0.0
#> SRR886567 1 0.000 1.000 1 0.0 0.0
#> SRR886568 3 0.613 1.000 0 0.4 0.6
#> SRR886569 3 0.613 1.000 0 0.4 0.6
#> SRR886570 3 0.613 1.000 0 0.4 0.6
#> SRR886571 1 0.000 1.000 1 0.0 0.0
#> SRR886572 1 0.000 1.000 1 0.0 0.0
#> SRR886573 1 0.000 1.000 1 0.0 0.0
#> SRR886574 1 0.000 1.000 1 0.0 0.0
#> SRR886575 1 0.000 1.000 1 0.0 0.0
#> SRR886576 1 0.000 1.000 1 0.0 0.0
#> SRR886577 1 0.000 1.000 1 0.0 0.0
#> SRR886578 1 0.000 1.000 1 0.0 0.0
#> SRR886579 1 0.000 1.000 1 0.0 0.0
#> SRR886580 2 0.613 0.775 0 0.6 0.4
#> SRR886581 2 0.613 0.775 0 0.6 0.4
#> SRR886582 2 0.613 0.775 0 0.6 0.4
#> SRR886583 1 0.000 1.000 1 0.0 0.0
#> SRR886584 1 0.000 1.000 1 0.0 0.0
#> SRR886585 1 0.000 1.000 1 0.0 0.0
#> SRR886586 2 0.613 0.775 0 0.6 0.4
#> SRR886587 2 0.613 0.775 0 0.6 0.4
#> SRR886588 2 0.613 0.775 0 0.6 0.4
#> SRR886589 3 0.613 1.000 0 0.4 0.6
#> SRR886590 3 0.613 1.000 0 0.4 0.6
#> SRR886591 3 0.613 1.000 0 0.4 0.6
#> SRR886592 2 0.613 0.775 0 0.6 0.4
#> SRR886593 2 0.613 0.775 0 0.6 0.4
#> SRR886594 2 0.613 0.775 0 0.6 0.4
#> SRR886595 2 0.613 0.775 0 0.6 0.4
#> SRR886596 2 0.613 0.775 0 0.6 0.4
#> SRR886597 2 0.613 0.775 0 0.6 0.4
#> SRR886598 2 0.000 0.619 0 1.0 0.0
#> SRR886599 2 0.000 0.619 0 1.0 0.0
#> SRR886600 2 0.000 0.619 0 1.0 0.0
#> SRR886601 2 0.000 0.619 0 1.0 0.0
#> SRR886602 1 0.000 1.000 1 0.0 0.0
#> SRR886603 1 0.000 1.000 1 0.0 0.0
#> SRR886604 1 0.000 1.000 1 0.0 0.0
#> SRR886605 3 0.613 1.000 0 0.4 0.6
#> SRR886606 3 0.613 1.000 0 0.4 0.6
#> SRR886607 3 0.613 1.000 0 0.4 0.6
#> SRR886608 2 0.000 0.619 0 1.0 0.0
#> SRR886609 2 0.000 0.619 0 1.0 0.0
#> SRR886610 2 0.000 0.619 0 1.0 0.0
#> SRR886611 2 0.000 0.619 0 1.0 0.0
#> SRR886612 2 0.000 0.619 0 1.0 0.0
#> SRR886613 2 0.000 0.619 0 1.0 0.0
#> SRR886614 3 0.613 1.000 0 0.4 0.6
#> SRR886615 3 0.613 1.000 0 0.4 0.6
#> SRR886616 3 0.613 1.000 0 0.4 0.6
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886566 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886567 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886568 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886569 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886570 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886571 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886572 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886573 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886574 4 0.000 1.000 0.000 0.0 0.0 1.000
#> SRR886575 4 0.000 1.000 0.000 0.0 0.0 1.000
#> SRR886576 4 0.000 1.000 0.000 0.0 0.0 1.000
#> SRR886577 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886578 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886579 1 0.357 0.896 0.804 0.0 0.0 0.196
#> SRR886580 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886581 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886582 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886583 1 0.000 0.848 1.000 0.0 0.0 0.000
#> SRR886584 1 0.000 0.848 1.000 0.0 0.0 0.000
#> SRR886585 1 0.000 0.848 1.000 0.0 0.0 0.000
#> SRR886586 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886587 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886588 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886589 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886590 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886591 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886592 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886593 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886594 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886595 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886596 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886597 2 0.485 0.745 0.000 0.6 0.4 0.000
#> SRR886598 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886599 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886600 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886601 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886602 1 0.000 0.848 1.000 0.0 0.0 0.000
#> SRR886603 1 0.000 0.848 1.000 0.0 0.0 0.000
#> SRR886604 1 0.000 0.848 1.000 0.0 0.0 0.000
#> SRR886605 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886606 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886607 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886608 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886609 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886610 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886611 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886612 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886613 2 0.000 0.619 0.000 1.0 0.0 0.000
#> SRR886614 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886615 3 0.485 1.000 0.000 0.4 0.6 0.000
#> SRR886616 3 0.485 1.000 0.000 0.4 0.6 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886566 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886567 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886568 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886569 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886570 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886571 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886572 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886573 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886574 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886575 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886576 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886577 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886578 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886579 1 0.3074 0.896 0.804 0.000 0 0.196 0.000
#> SRR886580 2 0.0000 0.986 0.000 1.000 0 0.000 0.000
#> SRR886581 2 0.0000 0.986 0.000 1.000 0 0.000 0.000
#> SRR886582 2 0.0000 0.986 0.000 1.000 0 0.000 0.000
#> SRR886583 1 0.0000 0.848 1.000 0.000 0 0.000 0.000
#> SRR886584 1 0.0000 0.848 1.000 0.000 0 0.000 0.000
#> SRR886585 1 0.0000 0.848 1.000 0.000 0 0.000 0.000
#> SRR886586 2 0.0794 0.972 0.000 0.972 0 0.000 0.028
#> SRR886587 2 0.0794 0.972 0.000 0.972 0 0.000 0.028
#> SRR886588 2 0.0794 0.972 0.000 0.972 0 0.000 0.028
#> SRR886589 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886590 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886591 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886592 2 0.0000 0.986 0.000 1.000 0 0.000 0.000
#> SRR886593 2 0.0000 0.986 0.000 1.000 0 0.000 0.000
#> SRR886594 2 0.0000 0.986 0.000 1.000 0 0.000 0.000
#> SRR886595 5 0.4192 0.421 0.000 0.404 0 0.000 0.596
#> SRR886596 5 0.4192 0.421 0.000 0.404 0 0.000 0.596
#> SRR886597 5 0.4192 0.421 0.000 0.404 0 0.000 0.596
#> SRR886598 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886599 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886600 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886601 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886602 1 0.0000 0.848 1.000 0.000 0 0.000 0.000
#> SRR886603 1 0.0000 0.848 1.000 0.000 0 0.000 0.000
#> SRR886604 1 0.0000 0.848 1.000 0.000 0 0.000 0.000
#> SRR886605 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886608 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886609 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886610 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886611 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886612 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886613 5 0.0000 0.875 0.000 0.000 0 0.000 1.000
#> SRR886614 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886566 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886567 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886568 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886569 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886570 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886571 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886572 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886573 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886574 6 0.377 1.000 0.000 0.000 0 0.404 0.000 0.596
#> SRR886575 6 0.377 1.000 0.000 0.000 0 0.404 0.000 0.596
#> SRR886576 6 0.377 1.000 0.000 0.000 0 0.404 0.000 0.596
#> SRR886577 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886578 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886579 1 0.000 1.000 1.000 0.000 0 0.000 0.000 0.000
#> SRR886580 2 0.377 0.822 0.000 0.596 0 0.000 0.404 0.000
#> SRR886581 2 0.377 0.822 0.000 0.596 0 0.000 0.404 0.000
#> SRR886582 2 0.377 0.822 0.000 0.596 0 0.000 0.404 0.000
#> SRR886583 4 0.377 1.000 0.404 0.000 0 0.596 0.000 0.000
#> SRR886584 4 0.377 1.000 0.404 0.000 0 0.596 0.000 0.000
#> SRR886585 4 0.377 1.000 0.404 0.000 0 0.596 0.000 0.000
#> SRR886586 2 0.382 0.815 0.000 0.568 0 0.000 0.432 0.000
#> SRR886587 2 0.382 0.815 0.000 0.568 0 0.000 0.432 0.000
#> SRR886588 2 0.382 0.815 0.000 0.568 0 0.000 0.432 0.000
#> SRR886589 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886590 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886591 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886592 2 0.000 0.623 0.000 1.000 0 0.000 0.000 0.000
#> SRR886593 2 0.000 0.623 0.000 1.000 0 0.000 0.000 0.000
#> SRR886594 2 0.000 0.623 0.000 1.000 0 0.000 0.000 0.000
#> SRR886595 5 0.000 0.485 0.000 0.000 0 0.000 1.000 0.000
#> SRR886596 5 0.000 0.485 0.000 0.000 0 0.000 1.000 0.000
#> SRR886597 5 0.000 0.485 0.000 0.000 0 0.000 1.000 0.000
#> SRR886598 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886599 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886600 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886601 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886602 4 0.377 1.000 0.404 0.000 0 0.596 0.000 0.000
#> SRR886603 4 0.377 1.000 0.404 0.000 0 0.596 0.000 0.000
#> SRR886604 4 0.377 1.000 0.404 0.000 0 0.596 0.000 0.000
#> SRR886605 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886606 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886607 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886608 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886609 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886610 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886611 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886612 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886613 5 0.377 0.883 0.000 0.000 0 0.000 0.596 0.404
#> SRR886614 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886615 3 0.000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR886616 3 0.000 1.000 0.000 0.000 1 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.965 0.979 0.5042 0.491 0.491
#> 3 3 0.561 0.608 0.755 0.2666 0.846 0.695
#> 4 4 0.594 0.693 0.752 0.1208 0.835 0.620
#> 5 5 0.613 0.649 0.689 0.0710 0.910 0.733
#> 6 6 0.640 0.509 0.674 0.0429 0.896 0.617
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
#> SRR886565 1 0.0000 0.985 1.000 0.000
#> SRR886566 1 0.0000 0.985 1.000 0.000
#> SRR886567 1 0.0000 0.985 1.000 0.000
#> SRR886568 1 0.1414 0.977 0.980 0.020
#> SRR886569 1 0.1414 0.977 0.980 0.020
#> SRR886570 1 0.1414 0.977 0.980 0.020
#> SRR886571 1 0.0000 0.985 1.000 0.000
#> SRR886572 1 0.0000 0.985 1.000 0.000
#> SRR886573 1 0.0000 0.985 1.000 0.000
#> SRR886574 1 0.0672 0.980 0.992 0.008
#> SRR886575 1 0.0672 0.980 0.992 0.008
#> SRR886576 1 0.0672 0.980 0.992 0.008
#> SRR886577 1 0.0000 0.985 1.000 0.000
#> SRR886578 1 0.0000 0.985 1.000 0.000
#> SRR886579 1 0.0000 0.985 1.000 0.000
#> SRR886580 2 0.0672 0.975 0.008 0.992
#> SRR886581 2 0.0672 0.975 0.008 0.992
#> SRR886582 2 0.0672 0.975 0.008 0.992
#> SRR886583 1 0.0000 0.985 1.000 0.000
#> SRR886584 1 0.0000 0.985 1.000 0.000
#> SRR886585 1 0.0000 0.985 1.000 0.000
#> SRR886586 2 0.0672 0.975 0.008 0.992
#> SRR886587 2 0.0672 0.975 0.008 0.992
#> SRR886588 2 0.0672 0.975 0.008 0.992
#> SRR886589 1 0.1414 0.977 0.980 0.020
#> SRR886590 1 0.1414 0.977 0.980 0.020
#> SRR886591 1 0.1414 0.977 0.980 0.020
#> SRR886592 2 0.0000 0.970 0.000 1.000
#> SRR886593 2 0.0000 0.970 0.000 1.000
#> SRR886594 2 0.0000 0.970 0.000 1.000
#> SRR886595 2 0.0672 0.975 0.008 0.992
#> SRR886596 2 0.0672 0.975 0.008 0.992
#> SRR886597 2 0.0672 0.975 0.008 0.992
#> SRR886598 2 0.0672 0.975 0.008 0.992
#> SRR886599 2 0.0672 0.975 0.008 0.992
#> SRR886600 2 0.0672 0.975 0.008 0.992
#> SRR886601 2 0.0672 0.975 0.008 0.992
#> SRR886602 1 0.0000 0.985 1.000 0.000
#> SRR886603 1 0.0000 0.985 1.000 0.000
#> SRR886604 1 0.0000 0.985 1.000 0.000
#> SRR886605 2 0.6973 0.791 0.188 0.812
#> SRR886606 2 0.6973 0.791 0.188 0.812
#> SRR886607 2 0.6973 0.791 0.188 0.812
#> SRR886608 2 0.0672 0.975 0.008 0.992
#> SRR886609 2 0.0672 0.975 0.008 0.992
#> SRR886610 2 0.0672 0.975 0.008 0.992
#> SRR886611 2 0.0672 0.975 0.008 0.992
#> SRR886612 2 0.0672 0.975 0.008 0.992
#> SRR886613 2 0.0672 0.975 0.008 0.992
#> SRR886614 1 0.4022 0.924 0.920 0.080
#> SRR886615 1 0.4022 0.924 0.920 0.080
#> SRR886616 1 0.4022 0.924 0.920 0.080
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0237 0.788 0.996 0.000 0.004
#> SRR886566 1 0.0237 0.788 0.996 0.000 0.004
#> SRR886567 1 0.0237 0.788 0.996 0.000 0.004
#> SRR886568 1 0.7169 0.188 0.520 0.024 0.456
#> SRR886569 1 0.7169 0.188 0.520 0.024 0.456
#> SRR886570 1 0.7169 0.188 0.520 0.024 0.456
#> SRR886571 1 0.1163 0.787 0.972 0.000 0.028
#> SRR886572 1 0.1163 0.787 0.972 0.000 0.028
#> SRR886573 1 0.1163 0.787 0.972 0.000 0.028
#> SRR886574 1 0.4002 0.723 0.840 0.000 0.160
#> SRR886575 1 0.4002 0.723 0.840 0.000 0.160
#> SRR886576 1 0.4002 0.723 0.840 0.000 0.160
#> SRR886577 1 0.0000 0.788 1.000 0.000 0.000
#> SRR886578 1 0.0000 0.788 1.000 0.000 0.000
#> SRR886579 1 0.0000 0.788 1.000 0.000 0.000
#> SRR886580 2 0.1643 0.790 0.000 0.956 0.044
#> SRR886581 2 0.1643 0.790 0.000 0.956 0.044
#> SRR886582 2 0.1643 0.790 0.000 0.956 0.044
#> SRR886583 1 0.3192 0.762 0.888 0.000 0.112
#> SRR886584 1 0.3192 0.762 0.888 0.000 0.112
#> SRR886585 1 0.3192 0.762 0.888 0.000 0.112
#> SRR886586 2 0.0237 0.804 0.000 0.996 0.004
#> SRR886587 2 0.0237 0.804 0.000 0.996 0.004
#> SRR886588 2 0.0237 0.804 0.000 0.996 0.004
#> SRR886589 1 0.7112 0.214 0.552 0.024 0.424
#> SRR886590 1 0.7112 0.214 0.552 0.024 0.424
#> SRR886591 1 0.7112 0.214 0.552 0.024 0.424
#> SRR886592 2 0.3686 0.724 0.000 0.860 0.140
#> SRR886593 2 0.3686 0.724 0.000 0.860 0.140
#> SRR886594 2 0.3686 0.724 0.000 0.860 0.140
#> SRR886595 2 0.2356 0.799 0.000 0.928 0.072
#> SRR886596 2 0.2356 0.799 0.000 0.928 0.072
#> SRR886597 2 0.2356 0.799 0.000 0.928 0.072
#> SRR886598 2 0.4062 0.749 0.000 0.836 0.164
#> SRR886599 2 0.4062 0.749 0.000 0.836 0.164
#> SRR886600 2 0.4062 0.749 0.000 0.836 0.164
#> SRR886601 2 0.4062 0.749 0.000 0.836 0.164
#> SRR886602 1 0.3192 0.762 0.888 0.000 0.112
#> SRR886603 1 0.3192 0.762 0.888 0.000 0.112
#> SRR886604 1 0.3192 0.762 0.888 0.000 0.112
#> SRR886605 3 0.7411 0.604 0.076 0.256 0.668
#> SRR886606 3 0.7411 0.604 0.076 0.256 0.668
#> SRR886607 3 0.7411 0.604 0.076 0.256 0.668
#> SRR886608 3 0.6305 0.197 0.000 0.484 0.516
#> SRR886609 3 0.6305 0.197 0.000 0.484 0.516
#> SRR886610 3 0.6305 0.197 0.000 0.484 0.516
#> SRR886611 2 0.6079 0.282 0.000 0.612 0.388
#> SRR886612 2 0.6079 0.282 0.000 0.612 0.388
#> SRR886613 2 0.6079 0.282 0.000 0.612 0.388
#> SRR886614 3 0.7551 0.323 0.372 0.048 0.580
#> SRR886615 3 0.7551 0.323 0.372 0.048 0.580
#> SRR886616 3 0.7551 0.323 0.372 0.048 0.580
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.314 0.752 0.876 0.000 0.100 NA
#> SRR886566 1 0.314 0.752 0.876 0.000 0.100 NA
#> SRR886567 1 0.314 0.752 0.876 0.000 0.100 NA
#> SRR886568 3 0.577 0.736 0.292 0.000 0.652 NA
#> SRR886569 3 0.577 0.736 0.292 0.000 0.652 NA
#> SRR886570 3 0.577 0.736 0.292 0.000 0.652 NA
#> SRR886571 1 0.355 0.768 0.864 0.000 0.064 NA
#> SRR886572 1 0.355 0.768 0.864 0.000 0.064 NA
#> SRR886573 1 0.355 0.768 0.864 0.000 0.064 NA
#> SRR886574 1 0.546 0.665 0.704 0.000 0.060 NA
#> SRR886575 1 0.546 0.665 0.704 0.000 0.060 NA
#> SRR886576 1 0.546 0.665 0.704 0.000 0.060 NA
#> SRR886577 1 0.198 0.773 0.928 0.000 0.068 NA
#> SRR886578 1 0.198 0.773 0.928 0.000 0.068 NA
#> SRR886579 1 0.198 0.773 0.928 0.000 0.068 NA
#> SRR886580 2 0.506 0.688 0.000 0.648 0.012 NA
#> SRR886581 2 0.506 0.688 0.000 0.648 0.012 NA
#> SRR886582 2 0.506 0.688 0.000 0.648 0.012 NA
#> SRR886583 1 0.469 0.699 0.712 0.000 0.012 NA
#> SRR886584 1 0.469 0.699 0.712 0.000 0.012 NA
#> SRR886585 1 0.469 0.699 0.712 0.000 0.012 NA
#> SRR886586 2 0.428 0.725 0.000 0.764 0.012 NA
#> SRR886587 2 0.428 0.725 0.000 0.764 0.012 NA
#> SRR886588 2 0.428 0.725 0.000 0.764 0.012 NA
#> SRR886589 3 0.506 0.753 0.300 0.000 0.680 NA
#> SRR886590 3 0.506 0.753 0.300 0.000 0.680 NA
#> SRR886591 3 0.506 0.753 0.300 0.000 0.680 NA
#> SRR886592 2 0.533 0.656 0.000 0.568 0.012 NA
#> SRR886593 2 0.533 0.656 0.000 0.568 0.012 NA
#> SRR886594 2 0.533 0.656 0.000 0.568 0.012 NA
#> SRR886595 2 0.247 0.733 0.000 0.900 0.004 NA
#> SRR886596 2 0.247 0.733 0.000 0.900 0.004 NA
#> SRR886597 2 0.247 0.733 0.000 0.900 0.004 NA
#> SRR886598 2 0.316 0.701 0.000 0.872 0.108 NA
#> SRR886599 2 0.316 0.701 0.000 0.872 0.108 NA
#> SRR886600 2 0.316 0.701 0.000 0.872 0.108 NA
#> SRR886601 2 0.316 0.701 0.000 0.872 0.108 NA
#> SRR886602 1 0.516 0.693 0.720 0.000 0.044 NA
#> SRR886603 1 0.516 0.693 0.720 0.000 0.044 NA
#> SRR886604 1 0.516 0.693 0.720 0.000 0.044 NA
#> SRR886605 3 0.342 0.674 0.016 0.088 0.876 NA
#> SRR886606 3 0.342 0.674 0.016 0.088 0.876 NA
#> SRR886607 3 0.342 0.674 0.016 0.088 0.876 NA
#> SRR886608 2 0.629 0.395 0.000 0.524 0.416 NA
#> SRR886609 2 0.629 0.395 0.000 0.524 0.416 NA
#> SRR886610 2 0.629 0.395 0.000 0.524 0.416 NA
#> SRR886611 2 0.572 0.580 0.000 0.668 0.272 NA
#> SRR886612 2 0.572 0.580 0.000 0.668 0.272 NA
#> SRR886613 2 0.572 0.580 0.000 0.668 0.272 NA
#> SRR886614 3 0.294 0.787 0.128 0.004 0.868 NA
#> SRR886615 3 0.294 0.787 0.128 0.004 0.868 NA
#> SRR886616 3 0.294 0.787 0.128 0.004 0.868 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.205 0.694 0.912 0.000 0.080 NA 0.004
#> SRR886566 1 0.205 0.694 0.912 0.000 0.080 NA 0.004
#> SRR886567 1 0.205 0.694 0.912 0.000 0.080 NA 0.004
#> SRR886568 3 0.491 0.650 0.284 0.000 0.672 NA 0.016
#> SRR886569 3 0.491 0.650 0.284 0.000 0.672 NA 0.016
#> SRR886570 3 0.491 0.650 0.284 0.000 0.672 NA 0.016
#> SRR886571 1 0.196 0.721 0.928 0.000 0.008 NA 0.012
#> SRR886572 1 0.196 0.721 0.928 0.000 0.008 NA 0.012
#> SRR886573 1 0.196 0.721 0.928 0.000 0.008 NA 0.012
#> SRR886574 1 0.661 0.588 0.588 0.004 0.080 NA 0.064
#> SRR886575 1 0.661 0.588 0.588 0.004 0.080 NA 0.064
#> SRR886576 1 0.664 0.588 0.588 0.004 0.080 NA 0.068
#> SRR886577 1 0.262 0.723 0.900 0.000 0.048 NA 0.012
#> SRR886578 1 0.262 0.723 0.900 0.000 0.048 NA 0.012
#> SRR886579 1 0.262 0.723 0.900 0.000 0.048 NA 0.012
#> SRR886580 2 0.288 0.728 0.000 0.876 0.024 NA 0.008
#> SRR886581 2 0.288 0.728 0.000 0.876 0.024 NA 0.008
#> SRR886582 2 0.288 0.728 0.000 0.876 0.024 NA 0.008
#> SRR886583 1 0.423 0.658 0.576 0.000 0.000 NA 0.000
#> SRR886584 1 0.423 0.658 0.576 0.000 0.000 NA 0.000
#> SRR886585 1 0.423 0.658 0.576 0.000 0.000 NA 0.000
#> SRR886586 2 0.355 0.694 0.000 0.832 0.024 NA 0.128
#> SRR886587 2 0.355 0.694 0.000 0.832 0.024 NA 0.128
#> SRR886588 2 0.355 0.694 0.000 0.832 0.024 NA 0.128
#> SRR886589 3 0.384 0.682 0.280 0.000 0.716 NA 0.004
#> SRR886590 3 0.384 0.682 0.280 0.000 0.716 NA 0.004
#> SRR886591 3 0.384 0.682 0.280 0.000 0.716 NA 0.004
#> SRR886592 2 0.516 0.683 0.000 0.748 0.072 NA 0.060
#> SRR886593 2 0.516 0.683 0.000 0.748 0.072 NA 0.060
#> SRR886594 2 0.516 0.683 0.000 0.748 0.072 NA 0.060
#> SRR886595 2 0.505 0.517 0.000 0.724 0.024 NA 0.188
#> SRR886596 2 0.505 0.517 0.000 0.724 0.024 NA 0.188
#> SRR886597 2 0.505 0.517 0.000 0.724 0.024 NA 0.188
#> SRR886598 5 0.656 0.452 0.000 0.412 0.036 NA 0.464
#> SRR886599 5 0.656 0.452 0.000 0.412 0.036 NA 0.464
#> SRR886600 5 0.656 0.452 0.000 0.412 0.036 NA 0.464
#> SRR886601 5 0.656 0.452 0.000 0.412 0.036 NA 0.464
#> SRR886602 1 0.561 0.648 0.556 0.000 0.036 NA 0.024
#> SRR886603 1 0.561 0.648 0.556 0.000 0.036 NA 0.024
#> SRR886604 1 0.561 0.648 0.556 0.000 0.036 NA 0.024
#> SRR886605 3 0.609 0.579 0.020 0.004 0.548 NA 0.360
#> SRR886606 3 0.609 0.579 0.020 0.004 0.548 NA 0.360
#> SRR886607 3 0.609 0.579 0.020 0.004 0.548 NA 0.360
#> SRR886608 5 0.475 0.676 0.000 0.124 0.080 NA 0.768
#> SRR886609 5 0.475 0.676 0.000 0.124 0.080 NA 0.768
#> SRR886610 5 0.475 0.676 0.000 0.124 0.080 NA 0.768
#> SRR886611 5 0.316 0.706 0.000 0.164 0.012 NA 0.824
#> SRR886612 5 0.316 0.706 0.000 0.164 0.012 NA 0.824
#> SRR886613 5 0.316 0.706 0.000 0.164 0.012 NA 0.824
#> SRR886614 3 0.611 0.694 0.072 0.000 0.632 NA 0.240
#> SRR886615 3 0.611 0.694 0.072 0.000 0.632 NA 0.240
#> SRR886616 3 0.611 0.694 0.072 0.000 0.632 NA 0.240
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.212 0.5010 0.916 0.004 0.048 0.012 0.000 0.020
#> SRR886566 1 0.212 0.5010 0.916 0.004 0.048 0.012 0.000 0.020
#> SRR886567 1 0.212 0.5010 0.916 0.004 0.048 0.012 0.000 0.020
#> SRR886568 3 0.693 0.5735 0.236 0.024 0.504 0.052 0.000 0.184
#> SRR886569 3 0.693 0.5735 0.236 0.024 0.504 0.052 0.000 0.184
#> SRR886570 3 0.693 0.5735 0.236 0.024 0.504 0.052 0.000 0.184
#> SRR886571 1 0.328 0.3373 0.836 0.008 0.016 0.020 0.000 0.120
#> SRR886572 1 0.328 0.3373 0.836 0.008 0.016 0.020 0.000 0.120
#> SRR886573 1 0.328 0.3373 0.836 0.008 0.016 0.020 0.000 0.120
#> SRR886574 6 0.539 0.9831 0.444 0.016 0.008 0.040 0.004 0.488
#> SRR886575 6 0.504 0.9900 0.444 0.008 0.008 0.036 0.000 0.504
#> SRR886576 6 0.513 0.9891 0.444 0.008 0.012 0.036 0.000 0.500
#> SRR886577 1 0.256 0.4959 0.896 0.000 0.036 0.040 0.004 0.024
#> SRR886578 1 0.256 0.4959 0.896 0.000 0.036 0.040 0.004 0.024
#> SRR886579 1 0.256 0.4959 0.896 0.000 0.036 0.040 0.004 0.024
#> SRR886580 2 0.249 0.7084 0.000 0.884 0.004 0.004 0.088 0.020
#> SRR886581 2 0.249 0.7084 0.000 0.884 0.004 0.004 0.088 0.020
#> SRR886582 2 0.249 0.7084 0.000 0.884 0.004 0.004 0.088 0.020
#> SRR886583 4 0.424 0.9956 0.444 0.000 0.000 0.540 0.000 0.016
#> SRR886584 4 0.424 0.9956 0.444 0.000 0.000 0.540 0.000 0.016
#> SRR886585 4 0.433 0.9912 0.444 0.000 0.004 0.540 0.004 0.008
#> SRR886586 2 0.593 0.5214 0.000 0.532 0.004 0.128 0.316 0.020
#> SRR886587 2 0.593 0.5214 0.000 0.532 0.004 0.128 0.316 0.020
#> SRR886588 2 0.597 0.5211 0.000 0.532 0.004 0.124 0.316 0.024
#> SRR886589 3 0.591 0.6482 0.216 0.012 0.620 0.044 0.000 0.108
#> SRR886590 3 0.591 0.6482 0.216 0.012 0.620 0.044 0.000 0.108
#> SRR886591 3 0.591 0.6482 0.216 0.012 0.620 0.044 0.000 0.108
#> SRR886592 2 0.519 0.6973 0.000 0.712 0.004 0.112 0.080 0.092
#> SRR886593 2 0.519 0.6973 0.000 0.712 0.004 0.112 0.080 0.092
#> SRR886594 2 0.520 0.6972 0.000 0.712 0.004 0.104 0.080 0.100
#> SRR886595 5 0.660 0.0884 0.000 0.380 0.000 0.172 0.400 0.048
#> SRR886596 5 0.660 0.0884 0.000 0.380 0.000 0.172 0.400 0.048
#> SRR886597 5 0.660 0.0884 0.000 0.380 0.000 0.172 0.400 0.048
#> SRR886598 5 0.581 0.5142 0.000 0.188 0.008 0.076 0.644 0.084
#> SRR886599 5 0.581 0.5142 0.000 0.188 0.008 0.076 0.644 0.084
#> SRR886600 5 0.581 0.5142 0.000 0.188 0.008 0.076 0.644 0.084
#> SRR886601 5 0.581 0.5142 0.000 0.188 0.008 0.076 0.644 0.084
#> SRR886602 1 0.605 -0.7988 0.448 0.024 0.008 0.444 0.016 0.060
#> SRR886603 1 0.605 -0.7988 0.448 0.024 0.008 0.444 0.016 0.060
#> SRR886604 1 0.606 -0.7997 0.448 0.028 0.008 0.444 0.016 0.056
#> SRR886605 3 0.311 0.6250 0.000 0.000 0.840 0.016 0.120 0.024
#> SRR886606 3 0.311 0.6250 0.000 0.000 0.840 0.016 0.120 0.024
#> SRR886607 3 0.311 0.6250 0.000 0.000 0.840 0.016 0.120 0.024
#> SRR886608 5 0.467 0.5006 0.000 0.000 0.208 0.040 0.708 0.044
#> SRR886609 5 0.467 0.5006 0.000 0.000 0.208 0.040 0.708 0.044
#> SRR886610 5 0.467 0.5006 0.000 0.000 0.208 0.040 0.708 0.044
#> SRR886611 5 0.216 0.5688 0.000 0.016 0.092 0.000 0.892 0.000
#> SRR886612 5 0.216 0.5688 0.000 0.016 0.092 0.000 0.892 0.000
#> SRR886613 5 0.216 0.5688 0.000 0.016 0.092 0.000 0.892 0.000
#> SRR886614 3 0.278 0.6879 0.028 0.004 0.892 0.016 0.040 0.020
#> SRR886615 3 0.278 0.6879 0.028 0.004 0.892 0.016 0.040 0.020
#> SRR886616 3 0.278 0.6879 0.028 0.004 0.892 0.016 0.040 0.020
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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.5095 0.491 0.491
#> 3 3 0.888 0.952 0.972 0.2606 0.842 0.686
#> 4 4 0.837 0.774 0.810 0.1253 1.000 1.000
#> 5 5 0.908 0.838 0.908 0.0778 0.869 0.635
#> 6 6 0.862 0.811 0.865 0.0343 0.943 0.775
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
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886566 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886567 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886568 1 0.0237 0.996 0.996 0.00 0.004
#> SRR886569 1 0.0237 0.996 0.996 0.00 0.004
#> SRR886570 1 0.0237 0.996 0.996 0.00 0.004
#> SRR886571 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886572 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886573 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886574 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886575 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886576 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886577 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886578 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886579 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886580 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886581 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886582 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886583 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886584 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886585 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886586 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886587 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886588 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886589 3 0.4062 0.839 0.164 0.00 0.836
#> SRR886590 3 0.4062 0.839 0.164 0.00 0.836
#> SRR886591 3 0.4062 0.839 0.164 0.00 0.836
#> SRR886592 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886593 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886594 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886595 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886596 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886597 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886598 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886599 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886600 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886601 2 0.0000 0.954 0.000 1.00 0.000
#> SRR886602 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886603 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886604 1 0.0000 0.999 1.000 0.00 0.000
#> SRR886605 3 0.0000 0.927 0.000 0.00 1.000
#> SRR886606 3 0.0000 0.927 0.000 0.00 1.000
#> SRR886607 3 0.0000 0.927 0.000 0.00 1.000
#> SRR886608 2 0.4002 0.864 0.000 0.84 0.160
#> SRR886609 2 0.4002 0.864 0.000 0.84 0.160
#> SRR886610 2 0.4002 0.864 0.000 0.84 0.160
#> SRR886611 2 0.4002 0.864 0.000 0.84 0.160
#> SRR886612 2 0.4002 0.864 0.000 0.84 0.160
#> SRR886613 2 0.4002 0.864 0.000 0.84 0.160
#> SRR886614 3 0.0000 0.927 0.000 0.00 1.000
#> SRR886615 3 0.0000 0.927 0.000 0.00 1.000
#> SRR886616 3 0.0000 0.927 0.000 0.00 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886566 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886567 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886568 1 0.521 0.784 0.748 0.000 0.080 NA
#> SRR886569 1 0.521 0.784 0.748 0.000 0.080 NA
#> SRR886570 1 0.521 0.784 0.748 0.000 0.080 NA
#> SRR886571 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886572 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886573 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886574 1 0.222 0.924 0.928 0.000 0.032 NA
#> SRR886575 1 0.222 0.924 0.928 0.000 0.032 NA
#> SRR886576 1 0.222 0.924 0.928 0.000 0.032 NA
#> SRR886577 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886578 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886579 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886580 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886581 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886582 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886583 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886584 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886585 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886586 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886587 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886588 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886589 3 0.635 0.891 0.064 0.000 0.524 NA
#> SRR886590 3 0.635 0.891 0.064 0.000 0.524 NA
#> SRR886591 3 0.635 0.891 0.064 0.000 0.524 NA
#> SRR886592 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886593 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886594 2 0.478 0.558 0.000 0.624 0.376 NA
#> SRR886595 2 0.000 0.595 0.000 1.000 0.000 NA
#> SRR886596 2 0.000 0.595 0.000 1.000 0.000 NA
#> SRR886597 2 0.000 0.595 0.000 1.000 0.000 NA
#> SRR886598 2 0.483 0.581 0.000 0.608 0.000 NA
#> SRR886599 2 0.483 0.581 0.000 0.608 0.000 NA
#> SRR886600 2 0.483 0.581 0.000 0.608 0.000 NA
#> SRR886601 2 0.483 0.581 0.000 0.608 0.000 NA
#> SRR886602 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886603 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886604 1 0.000 0.958 1.000 0.000 0.000 NA
#> SRR886605 3 0.496 0.944 0.000 0.000 0.552 NA
#> SRR886606 3 0.496 0.944 0.000 0.000 0.552 NA
#> SRR886607 3 0.496 0.944 0.000 0.000 0.552 NA
#> SRR886608 2 0.498 0.546 0.000 0.540 0.000 NA
#> SRR886609 2 0.498 0.546 0.000 0.540 0.000 NA
#> SRR886610 2 0.498 0.546 0.000 0.540 0.000 NA
#> SRR886611 2 0.496 0.555 0.000 0.552 0.000 NA
#> SRR886612 2 0.496 0.555 0.000 0.552 0.000 NA
#> SRR886613 2 0.496 0.555 0.000 0.552 0.000 NA
#> SRR886614 3 0.495 0.945 0.000 0.000 0.556 NA
#> SRR886615 3 0.495 0.945 0.000 0.000 0.556 NA
#> SRR886616 3 0.495 0.945 0.000 0.000 0.556 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0566 0.898 0.984 0.004 0.000 0.012 0.000
#> SRR886566 1 0.0566 0.898 0.984 0.004 0.000 0.012 0.000
#> SRR886567 1 0.0566 0.898 0.984 0.004 0.000 0.012 0.000
#> SRR886568 4 0.2280 1.000 0.120 0.000 0.000 0.880 0.000
#> SRR886569 4 0.2280 1.000 0.120 0.000 0.000 0.880 0.000
#> SRR886570 4 0.2280 1.000 0.120 0.000 0.000 0.880 0.000
#> SRR886571 1 0.0671 0.898 0.980 0.004 0.000 0.016 0.000
#> SRR886572 1 0.0671 0.898 0.980 0.004 0.000 0.016 0.000
#> SRR886573 1 0.0671 0.898 0.980 0.004 0.000 0.016 0.000
#> SRR886574 1 0.4199 0.539 0.692 0.008 0.000 0.296 0.004
#> SRR886575 1 0.4199 0.539 0.692 0.008 0.000 0.296 0.004
#> SRR886576 1 0.4199 0.539 0.692 0.008 0.000 0.296 0.004
#> SRR886577 1 0.0162 0.899 0.996 0.000 0.000 0.004 0.000
#> SRR886578 1 0.0162 0.899 0.996 0.000 0.000 0.004 0.000
#> SRR886579 1 0.0162 0.899 0.996 0.000 0.000 0.004 0.000
#> SRR886580 2 0.0865 0.843 0.000 0.972 0.000 0.004 0.024
#> SRR886581 2 0.0865 0.843 0.000 0.972 0.000 0.004 0.024
#> SRR886582 2 0.0865 0.843 0.000 0.972 0.000 0.004 0.024
#> SRR886583 1 0.1544 0.883 0.932 0.000 0.000 0.068 0.000
#> SRR886584 1 0.1544 0.883 0.932 0.000 0.000 0.068 0.000
#> SRR886585 1 0.1544 0.883 0.932 0.000 0.000 0.068 0.000
#> SRR886586 2 0.1310 0.841 0.000 0.956 0.000 0.020 0.024
#> SRR886587 2 0.1310 0.841 0.000 0.956 0.000 0.020 0.024
#> SRR886588 2 0.1310 0.841 0.000 0.956 0.000 0.020 0.024
#> SRR886589 3 0.5417 0.668 0.056 0.016 0.664 0.260 0.004
#> SRR886590 3 0.5417 0.668 0.056 0.016 0.664 0.260 0.004
#> SRR886591 3 0.5417 0.668 0.056 0.016 0.664 0.260 0.004
#> SRR886592 2 0.0609 0.841 0.000 0.980 0.000 0.000 0.020
#> SRR886593 2 0.0609 0.841 0.000 0.980 0.000 0.000 0.020
#> SRR886594 2 0.0609 0.841 0.000 0.980 0.000 0.000 0.020
#> SRR886595 2 0.5092 0.333 0.000 0.524 0.000 0.036 0.440
#> SRR886596 2 0.5092 0.333 0.000 0.524 0.000 0.036 0.440
#> SRR886597 2 0.5092 0.333 0.000 0.524 0.000 0.036 0.440
#> SRR886598 5 0.1117 0.976 0.000 0.016 0.000 0.020 0.964
#> SRR886599 5 0.1117 0.976 0.000 0.016 0.000 0.020 0.964
#> SRR886600 5 0.1117 0.976 0.000 0.016 0.000 0.020 0.964
#> SRR886601 5 0.1117 0.976 0.000 0.016 0.000 0.020 0.964
#> SRR886602 1 0.1544 0.883 0.932 0.000 0.000 0.068 0.000
#> SRR886603 1 0.1544 0.883 0.932 0.000 0.000 0.068 0.000
#> SRR886604 1 0.1544 0.883 0.932 0.000 0.000 0.068 0.000
#> SRR886605 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> SRR886606 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> SRR886607 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> SRR886608 5 0.0290 0.982 0.000 0.000 0.008 0.000 0.992
#> SRR886609 5 0.0290 0.982 0.000 0.000 0.008 0.000 0.992
#> SRR886610 5 0.0290 0.982 0.000 0.000 0.008 0.000 0.992
#> SRR886611 5 0.0324 0.983 0.000 0.004 0.004 0.000 0.992
#> SRR886612 5 0.0324 0.983 0.000 0.004 0.004 0.000 0.992
#> SRR886613 5 0.0324 0.983 0.000 0.004 0.004 0.000 0.992
#> SRR886614 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.0000 0.868 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.1434 0.832 0.940 0.000 0.000 0.048 0.000 0.012
#> SRR886566 1 0.1434 0.832 0.940 0.000 0.000 0.048 0.000 0.012
#> SRR886567 1 0.1434 0.832 0.940 0.000 0.000 0.048 0.000 0.012
#> SRR886568 6 0.0260 1.000 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR886569 6 0.0260 1.000 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR886570 6 0.0260 1.000 0.008 0.000 0.000 0.000 0.000 0.992
#> SRR886571 1 0.2118 0.816 0.888 0.000 0.000 0.104 0.000 0.008
#> SRR886572 1 0.2118 0.816 0.888 0.000 0.000 0.104 0.000 0.008
#> SRR886573 1 0.2118 0.816 0.888 0.000 0.000 0.104 0.000 0.008
#> SRR886574 1 0.5697 0.388 0.520 0.000 0.000 0.272 0.000 0.208
#> SRR886575 1 0.5697 0.388 0.520 0.000 0.000 0.272 0.000 0.208
#> SRR886576 1 0.5697 0.388 0.520 0.000 0.000 0.272 0.000 0.208
#> SRR886577 1 0.0520 0.840 0.984 0.000 0.000 0.008 0.000 0.008
#> SRR886578 1 0.0520 0.840 0.984 0.000 0.000 0.008 0.000 0.008
#> SRR886579 1 0.0520 0.840 0.984 0.000 0.000 0.008 0.000 0.008
#> SRR886580 2 0.0000 0.956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.956 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886583 1 0.2100 0.818 0.884 0.000 0.000 0.112 0.000 0.004
#> SRR886584 1 0.2100 0.818 0.884 0.000 0.000 0.112 0.000 0.004
#> SRR886585 1 0.2100 0.818 0.884 0.000 0.000 0.112 0.000 0.004
#> SRR886586 2 0.1957 0.914 0.000 0.888 0.000 0.112 0.000 0.000
#> SRR886587 2 0.1957 0.914 0.000 0.888 0.000 0.112 0.000 0.000
#> SRR886588 2 0.1957 0.914 0.000 0.888 0.000 0.112 0.000 0.000
#> SRR886589 4 0.6667 1.000 0.056 0.000 0.308 0.452 0.000 0.184
#> SRR886590 4 0.6667 1.000 0.056 0.000 0.308 0.452 0.000 0.184
#> SRR886591 4 0.6667 1.000 0.056 0.000 0.308 0.452 0.000 0.184
#> SRR886592 2 0.0146 0.956 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR886593 2 0.0146 0.956 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR886594 2 0.0146 0.956 0.000 0.996 0.000 0.004 0.000 0.000
#> SRR886595 5 0.5635 0.119 0.000 0.432 0.000 0.128 0.436 0.004
#> SRR886596 5 0.5635 0.119 0.000 0.432 0.000 0.128 0.436 0.004
#> SRR886597 5 0.5635 0.119 0.000 0.432 0.000 0.128 0.436 0.004
#> SRR886598 5 0.1296 0.807 0.000 0.004 0.000 0.044 0.948 0.004
#> SRR886599 5 0.1296 0.807 0.000 0.004 0.000 0.044 0.948 0.004
#> SRR886600 5 0.1296 0.807 0.000 0.004 0.000 0.044 0.948 0.004
#> SRR886601 5 0.1296 0.807 0.000 0.004 0.000 0.044 0.948 0.004
#> SRR886602 1 0.2146 0.817 0.880 0.000 0.000 0.116 0.000 0.004
#> SRR886603 1 0.2146 0.817 0.880 0.000 0.000 0.116 0.000 0.004
#> SRR886604 1 0.2146 0.817 0.880 0.000 0.000 0.116 0.000 0.004
#> SRR886605 3 0.0146 0.962 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR886606 3 0.0146 0.962 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR886607 3 0.0146 0.962 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR886608 5 0.1124 0.793 0.000 0.000 0.008 0.036 0.956 0.000
#> SRR886609 5 0.1124 0.793 0.000 0.000 0.008 0.036 0.956 0.000
#> SRR886610 5 0.1124 0.793 0.000 0.000 0.008 0.036 0.956 0.000
#> SRR886611 5 0.0000 0.807 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886612 5 0.0000 0.807 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886613 5 0.0000 0.807 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886614 3 0.0937 0.961 0.000 0.000 0.960 0.040 0.000 0.000
#> SRR886615 3 0.0937 0.961 0.000 0.000 0.960 0.040 0.000 0.000
#> SRR886616 3 0.0937 0.961 0.000 0.000 0.960 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.971 0.985 0.5070 0.493 0.493
#> 3 3 0.765 0.866 0.910 0.2955 0.855 0.706
#> 4 4 1.000 0.929 0.968 0.1391 0.803 0.506
#> 5 5 0.865 0.870 0.917 0.0676 0.930 0.728
#> 6 6 0.857 0.759 0.867 0.0285 0.882 0.527
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
#> SRR886565 1 0.000 1.000 1.000 0.000
#> SRR886566 1 0.000 1.000 1.000 0.000
#> SRR886567 1 0.000 1.000 1.000 0.000
#> SRR886568 1 0.000 1.000 1.000 0.000
#> SRR886569 1 0.000 1.000 1.000 0.000
#> SRR886570 1 0.000 1.000 1.000 0.000
#> SRR886571 1 0.000 1.000 1.000 0.000
#> SRR886572 1 0.000 1.000 1.000 0.000
#> SRR886573 1 0.000 1.000 1.000 0.000
#> SRR886574 1 0.000 1.000 1.000 0.000
#> SRR886575 1 0.000 1.000 1.000 0.000
#> SRR886576 1 0.000 1.000 1.000 0.000
#> SRR886577 1 0.000 1.000 1.000 0.000
#> SRR886578 1 0.000 1.000 1.000 0.000
#> SRR886579 1 0.000 1.000 1.000 0.000
#> SRR886580 2 0.000 0.971 0.000 1.000
#> SRR886581 2 0.000 0.971 0.000 1.000
#> SRR886582 2 0.000 0.971 0.000 1.000
#> SRR886583 1 0.000 1.000 1.000 0.000
#> SRR886584 1 0.000 1.000 1.000 0.000
#> SRR886585 1 0.000 1.000 1.000 0.000
#> SRR886586 2 0.000 0.971 0.000 1.000
#> SRR886587 2 0.000 0.971 0.000 1.000
#> SRR886588 2 0.000 0.971 0.000 1.000
#> SRR886589 1 0.000 1.000 1.000 0.000
#> SRR886590 1 0.000 1.000 1.000 0.000
#> SRR886591 1 0.000 1.000 1.000 0.000
#> SRR886592 2 0.000 0.971 0.000 1.000
#> SRR886593 2 0.000 0.971 0.000 1.000
#> SRR886594 2 0.000 0.971 0.000 1.000
#> SRR886595 2 0.000 0.971 0.000 1.000
#> SRR886596 2 0.000 0.971 0.000 1.000
#> SRR886597 2 0.000 0.971 0.000 1.000
#> SRR886598 2 0.000 0.971 0.000 1.000
#> SRR886599 2 0.000 0.971 0.000 1.000
#> SRR886600 2 0.000 0.971 0.000 1.000
#> SRR886601 2 0.000 0.971 0.000 1.000
#> SRR886602 1 0.000 1.000 1.000 0.000
#> SRR886603 1 0.000 1.000 1.000 0.000
#> SRR886604 1 0.000 1.000 1.000 0.000
#> SRR886605 2 0.343 0.927 0.064 0.936
#> SRR886606 2 0.327 0.930 0.060 0.940
#> SRR886607 2 0.327 0.930 0.060 0.940
#> SRR886608 2 0.000 0.971 0.000 1.000
#> SRR886609 2 0.000 0.971 0.000 1.000
#> SRR886610 2 0.000 0.971 0.000 1.000
#> SRR886611 2 0.000 0.971 0.000 1.000
#> SRR886612 2 0.000 0.971 0.000 1.000
#> SRR886613 2 0.000 0.971 0.000 1.000
#> SRR886614 2 0.722 0.782 0.200 0.800
#> SRR886615 2 0.722 0.782 0.200 0.800
#> SRR886616 2 0.722 0.782 0.200 0.800
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.000 0.926 1.000 0.000 0.000
#> SRR886566 1 0.000 0.926 1.000 0.000 0.000
#> SRR886567 1 0.000 0.926 1.000 0.000 0.000
#> SRR886568 1 0.497 0.775 0.764 0.000 0.236
#> SRR886569 1 0.497 0.775 0.764 0.000 0.236
#> SRR886570 1 0.497 0.775 0.764 0.000 0.236
#> SRR886571 1 0.000 0.926 1.000 0.000 0.000
#> SRR886572 1 0.000 0.926 1.000 0.000 0.000
#> SRR886573 1 0.000 0.926 1.000 0.000 0.000
#> SRR886574 1 0.000 0.926 1.000 0.000 0.000
#> SRR886575 1 0.000 0.926 1.000 0.000 0.000
#> SRR886576 1 0.000 0.926 1.000 0.000 0.000
#> SRR886577 1 0.000 0.926 1.000 0.000 0.000
#> SRR886578 1 0.000 0.926 1.000 0.000 0.000
#> SRR886579 1 0.000 0.926 1.000 0.000 0.000
#> SRR886580 2 0.000 1.000 0.000 1.000 0.000
#> SRR886581 2 0.000 1.000 0.000 1.000 0.000
#> SRR886582 2 0.000 1.000 0.000 1.000 0.000
#> SRR886583 1 0.000 0.926 1.000 0.000 0.000
#> SRR886584 1 0.000 0.926 1.000 0.000 0.000
#> SRR886585 1 0.000 0.926 1.000 0.000 0.000
#> SRR886586 2 0.000 1.000 0.000 1.000 0.000
#> SRR886587 2 0.000 1.000 0.000 1.000 0.000
#> SRR886588 2 0.000 1.000 0.000 1.000 0.000
#> SRR886589 1 0.599 0.628 0.632 0.000 0.368
#> SRR886590 1 0.599 0.628 0.632 0.000 0.368
#> SRR886591 1 0.599 0.628 0.632 0.000 0.368
#> SRR886592 2 0.000 1.000 0.000 1.000 0.000
#> SRR886593 2 0.000 1.000 0.000 1.000 0.000
#> SRR886594 2 0.000 1.000 0.000 1.000 0.000
#> SRR886595 2 0.000 1.000 0.000 1.000 0.000
#> SRR886596 2 0.000 1.000 0.000 1.000 0.000
#> SRR886597 2 0.000 1.000 0.000 1.000 0.000
#> SRR886598 3 0.599 0.686 0.000 0.368 0.632
#> SRR886599 3 0.599 0.686 0.000 0.368 0.632
#> SRR886600 3 0.599 0.686 0.000 0.368 0.632
#> SRR886601 3 0.599 0.686 0.000 0.368 0.632
#> SRR886602 1 0.000 0.926 1.000 0.000 0.000
#> SRR886603 1 0.000 0.926 1.000 0.000 0.000
#> SRR886604 1 0.000 0.926 1.000 0.000 0.000
#> SRR886605 3 0.000 0.768 0.000 0.000 1.000
#> SRR886606 3 0.000 0.768 0.000 0.000 1.000
#> SRR886607 3 0.000 0.768 0.000 0.000 1.000
#> SRR886608 3 0.484 0.805 0.000 0.224 0.776
#> SRR886609 3 0.475 0.805 0.000 0.216 0.784
#> SRR886610 3 0.489 0.804 0.000 0.228 0.772
#> SRR886611 3 0.510 0.798 0.000 0.248 0.752
#> SRR886612 3 0.510 0.798 0.000 0.248 0.752
#> SRR886613 3 0.510 0.798 0.000 0.248 0.752
#> SRR886614 3 0.000 0.768 0.000 0.000 1.000
#> SRR886615 3 0.000 0.768 0.000 0.000 1.000
#> SRR886616 3 0.000 0.768 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886568 3 0.2281 0.904 0.096 0.000 0.904 0.000
#> SRR886569 3 0.2281 0.904 0.096 0.000 0.904 0.000
#> SRR886570 3 0.2281 0.904 0.096 0.000 0.904 0.000
#> SRR886571 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886574 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886575 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886576 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886577 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886580 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886581 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886582 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886583 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886586 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886587 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886588 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886589 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886590 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886591 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886592 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886593 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886594 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886595 2 0.4916 0.381 0.000 0.576 0.000 0.424
#> SRR886596 2 0.4933 0.362 0.000 0.568 0.000 0.432
#> SRR886597 2 0.4907 0.389 0.000 0.580 0.000 0.420
#> SRR886598 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886599 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886600 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886601 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886602 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886605 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886606 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886607 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886608 2 0.0921 0.867 0.000 0.972 0.028 0.000
#> SRR886609 2 0.0921 0.867 0.000 0.972 0.028 0.000
#> SRR886610 2 0.0921 0.867 0.000 0.972 0.028 0.000
#> SRR886611 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886612 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886613 2 0.0000 0.878 0.000 1.000 0.000 0.000
#> SRR886614 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886615 3 0.0000 0.969 0.000 0.000 1.000 0.000
#> SRR886616 3 0.0000 0.969 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.1478 0.922 0.936 0.000 0.064 0.000 0.000
#> SRR886566 1 0.1478 0.922 0.936 0.000 0.064 0.000 0.000
#> SRR886567 1 0.1478 0.922 0.936 0.000 0.064 0.000 0.000
#> SRR886568 3 0.2377 0.871 0.128 0.000 0.872 0.000 0.000
#> SRR886569 3 0.2377 0.871 0.128 0.000 0.872 0.000 0.000
#> SRR886570 3 0.2377 0.871 0.128 0.000 0.872 0.000 0.000
#> SRR886571 1 0.1478 0.947 0.936 0.000 0.000 0.064 0.000
#> SRR886572 1 0.1478 0.947 0.936 0.000 0.000 0.064 0.000
#> SRR886573 1 0.1478 0.947 0.936 0.000 0.000 0.064 0.000
#> SRR886574 1 0.0510 0.925 0.984 0.000 0.000 0.016 0.000
#> SRR886575 1 0.0510 0.925 0.984 0.000 0.000 0.016 0.000
#> SRR886576 1 0.0510 0.925 0.984 0.000 0.000 0.016 0.000
#> SRR886577 1 0.1478 0.947 0.936 0.000 0.000 0.064 0.000
#> SRR886578 1 0.1478 0.947 0.936 0.000 0.000 0.064 0.000
#> SRR886579 1 0.1478 0.947 0.936 0.000 0.000 0.064 0.000
#> SRR886580 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> SRR886583 4 0.2690 1.000 0.156 0.000 0.000 0.844 0.000
#> SRR886584 4 0.2690 1.000 0.156 0.000 0.000 0.844 0.000
#> SRR886585 4 0.2690 1.000 0.156 0.000 0.000 0.844 0.000
#> SRR886586 2 0.0290 0.924 0.000 0.992 0.000 0.000 0.008
#> SRR886587 2 0.0290 0.924 0.000 0.992 0.000 0.000 0.008
#> SRR886588 2 0.0290 0.924 0.000 0.992 0.000 0.000 0.008
#> SRR886589 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886590 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886591 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886592 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.927 0.000 1.000 0.000 0.000 0.000
#> SRR886595 5 0.6219 0.153 0.000 0.424 0.000 0.140 0.436
#> SRR886596 2 0.6220 -0.278 0.000 0.432 0.000 0.140 0.428
#> SRR886597 5 0.6219 0.165 0.000 0.420 0.000 0.140 0.440
#> SRR886598 5 0.2516 0.834 0.000 0.000 0.000 0.140 0.860
#> SRR886599 5 0.2516 0.834 0.000 0.000 0.000 0.140 0.860
#> SRR886600 5 0.2516 0.834 0.000 0.000 0.000 0.140 0.860
#> SRR886601 5 0.2516 0.834 0.000 0.000 0.000 0.140 0.860
#> SRR886602 4 0.2690 1.000 0.156 0.000 0.000 0.844 0.000
#> SRR886603 4 0.2690 1.000 0.156 0.000 0.000 0.844 0.000
#> SRR886604 4 0.2690 1.000 0.156 0.000 0.000 0.844 0.000
#> SRR886605 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886606 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886607 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886608 5 0.0794 0.837 0.000 0.000 0.028 0.000 0.972
#> SRR886609 5 0.0794 0.837 0.000 0.000 0.028 0.000 0.972
#> SRR886610 5 0.0794 0.837 0.000 0.000 0.028 0.000 0.972
#> SRR886611 5 0.0000 0.845 0.000 0.000 0.000 0.000 1.000
#> SRR886612 5 0.0000 0.845 0.000 0.000 0.000 0.000 1.000
#> SRR886613 5 0.0000 0.845 0.000 0.000 0.000 0.000 1.000
#> SRR886614 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.0000 0.959 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.3944 0.697 0.568 0.000 0.000 0.004 0.000 0.428
#> SRR886566 1 0.3944 0.697 0.568 0.000 0.000 0.004 0.000 0.428
#> SRR886567 1 0.3944 0.697 0.568 0.000 0.000 0.004 0.000 0.428
#> SRR886568 1 0.0000 0.485 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886569 1 0.0000 0.485 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886570 1 0.0000 0.485 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886571 1 0.3944 0.697 0.568 0.000 0.000 0.004 0.000 0.428
#> SRR886572 1 0.3944 0.697 0.568 0.000 0.000 0.004 0.000 0.428
#> SRR886573 1 0.3944 0.697 0.568 0.000 0.000 0.004 0.000 0.428
#> SRR886574 6 0.2631 1.000 0.000 0.000 0.180 0.000 0.000 0.820
#> SRR886575 6 0.2631 1.000 0.000 0.000 0.180 0.000 0.000 0.820
#> SRR886576 6 0.2631 1.000 0.000 0.000 0.180 0.000 0.000 0.820
#> SRR886577 1 0.4039 0.696 0.568 0.000 0.000 0.008 0.000 0.424
#> SRR886578 1 0.4039 0.696 0.568 0.000 0.000 0.008 0.000 0.424
#> SRR886579 1 0.4039 0.696 0.568 0.000 0.000 0.008 0.000 0.424
#> SRR886580 2 0.0000 0.816 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.816 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.816 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886583 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886584 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886585 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886586 2 0.0363 0.813 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR886587 2 0.0363 0.813 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR886588 2 0.0363 0.813 0.000 0.988 0.000 0.000 0.012 0.000
#> SRR886589 1 0.0363 0.466 0.988 0.000 0.012 0.000 0.000 0.000
#> SRR886590 1 0.1267 0.360 0.940 0.000 0.060 0.000 0.000 0.000
#> SRR886591 1 0.0547 0.452 0.980 0.000 0.020 0.000 0.000 0.000
#> SRR886592 2 0.0000 0.816 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.816 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.816 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886595 2 0.5995 0.149 0.000 0.428 0.248 0.000 0.324 0.000
#> SRR886596 2 0.6007 0.144 0.000 0.424 0.252 0.000 0.324 0.000
#> SRR886597 2 0.6018 0.122 0.000 0.416 0.252 0.000 0.332 0.000
#> SRR886598 5 0.3151 0.774 0.000 0.000 0.252 0.000 0.748 0.000
#> SRR886599 5 0.3151 0.774 0.000 0.000 0.252 0.000 0.748 0.000
#> SRR886600 5 0.3151 0.774 0.000 0.000 0.252 0.000 0.748 0.000
#> SRR886601 5 0.3151 0.774 0.000 0.000 0.252 0.000 0.748 0.000
#> SRR886602 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886603 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886604 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886605 3 0.3817 1.000 0.432 0.000 0.568 0.000 0.000 0.000
#> SRR886606 3 0.3817 1.000 0.432 0.000 0.568 0.000 0.000 0.000
#> SRR886607 3 0.3817 1.000 0.432 0.000 0.568 0.000 0.000 0.000
#> SRR886608 5 0.2491 0.735 0.000 0.000 0.164 0.000 0.836 0.000
#> SRR886609 5 0.2562 0.729 0.000 0.000 0.172 0.000 0.828 0.000
#> SRR886610 5 0.2454 0.737 0.000 0.000 0.160 0.000 0.840 0.000
#> SRR886611 5 0.0000 0.809 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886612 5 0.0000 0.809 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886613 5 0.0000 0.809 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886614 3 0.3817 1.000 0.432 0.000 0.568 0.000 0.000 0.000
#> SRR886615 3 0.3817 1.000 0.432 0.000 0.568 0.000 0.000 0.000
#> SRR886616 3 0.3817 1.000 0.432 0.000 0.568 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.464 0.769 0.871 0.4806 0.509 0.509
#> 3 3 0.577 0.811 0.804 0.3029 0.824 0.653
#> 4 4 0.824 0.919 0.889 0.1282 0.946 0.837
#> 5 5 1.000 0.976 0.988 0.1157 0.932 0.756
#> 6 6 0.931 0.946 0.921 0.0383 0.968 0.849
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.2043 0.887 0.968 0.032
#> SRR886566 1 0.2043 0.887 0.968 0.032
#> SRR886567 1 0.2043 0.887 0.968 0.032
#> SRR886568 1 0.6247 0.899 0.844 0.156
#> SRR886569 1 0.6247 0.899 0.844 0.156
#> SRR886570 1 0.6247 0.899 0.844 0.156
#> SRR886571 1 0.2043 0.887 0.968 0.032
#> SRR886572 1 0.2043 0.887 0.968 0.032
#> SRR886573 1 0.2043 0.887 0.968 0.032
#> SRR886574 2 0.9996 0.337 0.488 0.512
#> SRR886575 2 0.9996 0.337 0.488 0.512
#> SRR886576 2 0.9996 0.337 0.488 0.512
#> SRR886577 1 0.2603 0.880 0.956 0.044
#> SRR886578 1 0.2603 0.880 0.956 0.044
#> SRR886579 1 0.2603 0.880 0.956 0.044
#> SRR886580 2 0.0000 0.826 0.000 1.000
#> SRR886581 2 0.0000 0.826 0.000 1.000
#> SRR886582 2 0.0000 0.826 0.000 1.000
#> SRR886583 2 0.9983 0.341 0.476 0.524
#> SRR886584 2 0.9983 0.341 0.476 0.524
#> SRR886585 2 0.9983 0.341 0.476 0.524
#> SRR886586 2 0.0938 0.831 0.012 0.988
#> SRR886587 2 0.0938 0.831 0.012 0.988
#> SRR886588 2 0.0938 0.831 0.012 0.988
#> SRR886589 1 0.6247 0.899 0.844 0.156
#> SRR886590 1 0.6247 0.899 0.844 0.156
#> SRR886591 1 0.6247 0.899 0.844 0.156
#> SRR886592 2 0.0000 0.826 0.000 1.000
#> SRR886593 2 0.0000 0.826 0.000 1.000
#> SRR886594 2 0.0000 0.826 0.000 1.000
#> SRR886595 2 0.0938 0.831 0.012 0.988
#> SRR886596 2 0.0938 0.831 0.012 0.988
#> SRR886597 2 0.0938 0.831 0.012 0.988
#> SRR886598 2 0.0938 0.831 0.012 0.988
#> SRR886599 2 0.0938 0.831 0.012 0.988
#> SRR886600 2 0.0938 0.831 0.012 0.988
#> SRR886601 2 0.0938 0.831 0.012 0.988
#> SRR886602 2 0.9983 0.341 0.476 0.524
#> SRR886603 2 0.9983 0.341 0.476 0.524
#> SRR886604 2 0.9983 0.341 0.476 0.524
#> SRR886605 1 0.5946 0.886 0.856 0.144
#> SRR886606 1 0.5946 0.886 0.856 0.144
#> SRR886607 1 0.5946 0.886 0.856 0.144
#> SRR886608 2 0.0938 0.831 0.012 0.988
#> SRR886609 2 0.0938 0.831 0.012 0.988
#> SRR886610 2 0.0938 0.831 0.012 0.988
#> SRR886611 2 0.0938 0.831 0.012 0.988
#> SRR886612 2 0.0938 0.831 0.012 0.988
#> SRR886613 2 0.0938 0.831 0.012 0.988
#> SRR886614 1 0.5842 0.889 0.860 0.140
#> SRR886615 1 0.5842 0.889 0.860 0.140
#> SRR886616 1 0.5842 0.889 0.860 0.140
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.000 0.844 1.000 0.000 0.000
#> SRR886566 1 0.000 0.844 1.000 0.000 0.000
#> SRR886567 1 0.000 0.844 1.000 0.000 0.000
#> SRR886568 1 0.000 0.844 1.000 0.000 0.000
#> SRR886569 1 0.000 0.844 1.000 0.000 0.000
#> SRR886570 1 0.000 0.844 1.000 0.000 0.000
#> SRR886571 1 0.000 0.844 1.000 0.000 0.000
#> SRR886572 1 0.000 0.844 1.000 0.000 0.000
#> SRR886573 1 0.000 0.844 1.000 0.000 0.000
#> SRR886574 3 0.533 0.518 0.272 0.000 0.728
#> SRR886575 3 0.533 0.518 0.272 0.000 0.728
#> SRR886576 3 0.533 0.518 0.272 0.000 0.728
#> SRR886577 1 0.369 0.727 0.860 0.000 0.140
#> SRR886578 1 0.369 0.727 0.860 0.000 0.140
#> SRR886579 1 0.369 0.727 0.860 0.000 0.140
#> SRR886580 3 0.116 0.802 0.028 0.000 0.972
#> SRR886581 3 0.116 0.802 0.028 0.000 0.972
#> SRR886582 3 0.116 0.802 0.028 0.000 0.972
#> SRR886583 3 0.375 0.766 0.000 0.144 0.856
#> SRR886584 3 0.375 0.766 0.000 0.144 0.856
#> SRR886585 3 0.375 0.766 0.000 0.144 0.856
#> SRR886586 3 0.153 0.766 0.000 0.040 0.960
#> SRR886587 3 0.153 0.766 0.000 0.040 0.960
#> SRR886588 3 0.153 0.766 0.000 0.040 0.960
#> SRR886589 1 0.000 0.844 1.000 0.000 0.000
#> SRR886590 1 0.000 0.844 1.000 0.000 0.000
#> SRR886591 1 0.000 0.844 1.000 0.000 0.000
#> SRR886592 3 0.116 0.802 0.028 0.000 0.972
#> SRR886593 3 0.116 0.802 0.028 0.000 0.972
#> SRR886594 3 0.116 0.802 0.028 0.000 0.972
#> SRR886595 2 0.621 1.000 0.000 0.572 0.428
#> SRR886596 2 0.621 1.000 0.000 0.572 0.428
#> SRR886597 2 0.621 1.000 0.000 0.572 0.428
#> SRR886598 2 0.621 1.000 0.000 0.572 0.428
#> SRR886599 2 0.621 1.000 0.000 0.572 0.428
#> SRR886600 2 0.621 1.000 0.000 0.572 0.428
#> SRR886601 2 0.621 1.000 0.000 0.572 0.428
#> SRR886602 3 0.375 0.766 0.000 0.144 0.856
#> SRR886603 3 0.375 0.766 0.000 0.144 0.856
#> SRR886604 3 0.375 0.766 0.000 0.144 0.856
#> SRR886605 1 0.630 0.599 0.528 0.472 0.000
#> SRR886606 1 0.630 0.594 0.524 0.476 0.000
#> SRR886607 1 0.630 0.594 0.524 0.476 0.000
#> SRR886608 2 0.621 1.000 0.000 0.572 0.428
#> SRR886609 2 0.621 1.000 0.000 0.572 0.428
#> SRR886610 2 0.621 1.000 0.000 0.572 0.428
#> SRR886611 2 0.621 1.000 0.000 0.572 0.428
#> SRR886612 2 0.621 1.000 0.000 0.572 0.428
#> SRR886613 2 0.621 1.000 0.000 0.572 0.428
#> SRR886614 1 0.630 0.599 0.528 0.472 0.000
#> SRR886615 1 0.630 0.599 0.528 0.472 0.000
#> SRR886616 1 0.630 0.599 0.528 0.472 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886566 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886567 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886568 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886569 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886570 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886571 3 0.0336 0.915 0.000 0.000 0.992 0.008
#> SRR886572 3 0.0336 0.915 0.000 0.000 0.992 0.008
#> SRR886573 3 0.0188 0.916 0.000 0.000 0.996 0.004
#> SRR886574 4 0.4483 0.919 0.004 0.284 0.000 0.712
#> SRR886575 4 0.4483 0.919 0.004 0.284 0.000 0.712
#> SRR886576 4 0.4483 0.919 0.004 0.284 0.000 0.712
#> SRR886577 3 0.0336 0.915 0.008 0.000 0.992 0.000
#> SRR886578 3 0.0336 0.915 0.008 0.000 0.992 0.000
#> SRR886579 3 0.0336 0.915 0.008 0.000 0.992 0.000
#> SRR886580 4 0.4304 0.920 0.000 0.284 0.000 0.716
#> SRR886581 4 0.4304 0.920 0.000 0.284 0.000 0.716
#> SRR886582 4 0.4304 0.920 0.000 0.284 0.000 0.716
#> SRR886583 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886586 4 0.4994 0.693 0.000 0.480 0.000 0.520
#> SRR886587 4 0.4994 0.693 0.000 0.480 0.000 0.520
#> SRR886588 4 0.4994 0.693 0.000 0.480 0.000 0.520
#> SRR886589 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886590 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886591 3 0.0000 0.918 0.000 0.000 1.000 0.000
#> SRR886592 4 0.4304 0.920 0.000 0.284 0.000 0.716
#> SRR886593 4 0.4304 0.920 0.000 0.284 0.000 0.716
#> SRR886594 4 0.4304 0.920 0.000 0.284 0.000 0.716
#> SRR886595 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886596 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886597 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886598 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886599 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886600 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886601 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886602 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 1.000 1.000 0.000 0.000 0.000
#> SRR886605 3 0.4304 0.780 0.000 0.000 0.716 0.284
#> SRR886606 3 0.4304 0.780 0.000 0.000 0.716 0.284
#> SRR886607 3 0.4304 0.780 0.000 0.000 0.716 0.284
#> SRR886608 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886609 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886610 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886611 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886612 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886613 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR886614 3 0.4304 0.780 0.000 0.000 0.716 0.284
#> SRR886615 3 0.4304 0.780 0.000 0.000 0.716 0.284
#> SRR886616 3 0.4304 0.780 0.000 0.000 0.716 0.284
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886566 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886567 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886568 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886569 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886570 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886571 1 0.0162 0.995 0.996 0.004 0 0.000 0.000
#> SRR886572 1 0.0162 0.995 0.996 0.004 0 0.000 0.000
#> SRR886573 1 0.0162 0.995 0.996 0.004 0 0.000 0.000
#> SRR886574 2 0.0162 0.933 0.000 0.996 0 0.004 0.000
#> SRR886575 2 0.0162 0.933 0.000 0.996 0 0.004 0.000
#> SRR886576 2 0.0162 0.933 0.000 0.996 0 0.004 0.000
#> SRR886577 1 0.0290 0.993 0.992 0.000 0 0.008 0.000
#> SRR886578 1 0.0290 0.993 0.992 0.000 0 0.008 0.000
#> SRR886579 1 0.0290 0.993 0.992 0.000 0 0.008 0.000
#> SRR886580 2 0.0000 0.934 0.000 1.000 0 0.000 0.000
#> SRR886581 2 0.0000 0.934 0.000 1.000 0 0.000 0.000
#> SRR886582 2 0.0000 0.934 0.000 1.000 0 0.000 0.000
#> SRR886583 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886584 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886585 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886586 2 0.3074 0.796 0.000 0.804 0 0.000 0.196
#> SRR886587 2 0.3074 0.796 0.000 0.804 0 0.000 0.196
#> SRR886588 2 0.3074 0.796 0.000 0.804 0 0.000 0.196
#> SRR886589 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886590 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886591 1 0.0000 0.997 1.000 0.000 0 0.000 0.000
#> SRR886592 2 0.0000 0.934 0.000 1.000 0 0.000 0.000
#> SRR886593 2 0.0000 0.934 0.000 1.000 0 0.000 0.000
#> SRR886594 2 0.0000 0.934 0.000 1.000 0 0.000 0.000
#> SRR886595 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886596 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886597 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886598 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886599 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886600 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886601 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886602 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886603 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886604 4 0.0000 1.000 0.000 0.000 0 1.000 0.000
#> SRR886605 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886608 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886609 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886610 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886611 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886612 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886613 5 0.0000 1.000 0.000 0.000 0 0.000 1.000
#> SRR886614 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886568 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886569 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886570 1 0.0000 0.996 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886571 1 0.0146 0.995 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR886572 1 0.0146 0.995 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR886573 1 0.0146 0.995 0.996 0.004 0.000 0.000 0.000 0.000
#> SRR886574 2 0.3706 0.675 0.000 0.620 0.000 0.000 0.000 0.380
#> SRR886575 2 0.3706 0.675 0.000 0.620 0.000 0.000 0.000 0.380
#> SRR886576 2 0.3706 0.675 0.000 0.620 0.000 0.000 0.000 0.380
#> SRR886577 1 0.0291 0.994 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR886578 1 0.0291 0.994 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR886579 1 0.0291 0.994 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR886580 2 0.0000 0.846 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.846 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.846 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886583 4 0.0146 0.998 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR886584 4 0.0146 0.998 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR886585 4 0.0146 0.998 0.000 0.000 0.000 0.996 0.000 0.004
#> SRR886586 2 0.2730 0.742 0.000 0.808 0.000 0.000 0.000 0.192
#> SRR886587 2 0.2730 0.742 0.000 0.808 0.000 0.000 0.000 0.192
#> SRR886588 2 0.2730 0.742 0.000 0.808 0.000 0.000 0.000 0.192
#> SRR886589 1 0.0260 0.993 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886590 1 0.0260 0.993 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886591 1 0.0260 0.993 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886592 2 0.0458 0.847 0.000 0.984 0.000 0.000 0.000 0.016
#> SRR886593 2 0.0458 0.847 0.000 0.984 0.000 0.000 0.000 0.016
#> SRR886594 2 0.0458 0.847 0.000 0.984 0.000 0.000 0.000 0.016
#> SRR886595 6 0.3706 0.998 0.000 0.000 0.000 0.000 0.380 0.620
#> SRR886596 6 0.3706 0.998 0.000 0.000 0.000 0.000 0.380 0.620
#> SRR886597 6 0.3706 0.998 0.000 0.000 0.000 0.000 0.380 0.620
#> SRR886598 6 0.3706 0.998 0.000 0.000 0.000 0.000 0.380 0.620
#> SRR886599 6 0.3706 0.998 0.000 0.000 0.000 0.000 0.380 0.620
#> SRR886600 6 0.3717 0.994 0.000 0.000 0.000 0.000 0.384 0.616
#> SRR886601 6 0.3717 0.994 0.000 0.000 0.000 0.000 0.384 0.616
#> SRR886602 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886603 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886604 4 0.0000 0.998 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886605 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886608 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886609 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886610 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886611 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886612 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886613 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886614 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5095 0.491 0.491
#> 3 3 0.709 0.807 0.808 0.2402 0.891 0.779
#> 4 4 0.855 0.877 0.932 0.1833 0.864 0.645
#> 5 5 0.732 0.747 0.806 0.0405 0.959 0.851
#> 6 6 0.717 0.742 0.810 0.0331 0.898 0.634
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
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.1643 0.833 0.956 0.044 0.000
#> SRR886566 1 0.1411 0.833 0.964 0.036 0.000
#> SRR886567 1 0.1411 0.833 0.964 0.036 0.000
#> SRR886568 1 0.4931 0.784 0.768 0.232 0.000
#> SRR886569 1 0.4555 0.796 0.800 0.200 0.000
#> SRR886570 1 0.4346 0.801 0.816 0.184 0.000
#> SRR886571 1 0.6008 0.717 0.628 0.372 0.000
#> SRR886572 1 0.6008 0.717 0.628 0.372 0.000
#> SRR886573 1 0.6008 0.717 0.628 0.372 0.000
#> SRR886574 1 0.6026 0.714 0.624 0.376 0.000
#> SRR886575 1 0.6026 0.714 0.624 0.376 0.000
#> SRR886576 1 0.6026 0.714 0.624 0.376 0.000
#> SRR886577 1 0.2356 0.830 0.928 0.072 0.000
#> SRR886578 1 0.1753 0.833 0.952 0.048 0.000
#> SRR886579 1 0.1753 0.833 0.952 0.048 0.000
#> SRR886580 2 0.6026 0.896 0.000 0.624 0.376
#> SRR886581 2 0.6026 0.896 0.000 0.624 0.376
#> SRR886582 2 0.6026 0.896 0.000 0.624 0.376
#> SRR886583 1 0.0237 0.829 0.996 0.004 0.000
#> SRR886584 1 0.0237 0.829 0.996 0.004 0.000
#> SRR886585 1 0.0237 0.829 0.996 0.004 0.000
#> SRR886586 2 0.6274 0.934 0.000 0.544 0.456
#> SRR886587 2 0.6274 0.934 0.000 0.544 0.456
#> SRR886588 2 0.6274 0.934 0.000 0.544 0.456
#> SRR886589 1 0.1529 0.820 0.960 0.000 0.040
#> SRR886590 1 0.1529 0.820 0.960 0.000 0.040
#> SRR886591 1 0.1529 0.820 0.960 0.000 0.040
#> SRR886592 2 0.6026 0.896 0.000 0.624 0.376
#> SRR886593 2 0.6026 0.896 0.000 0.624 0.376
#> SRR886594 2 0.6026 0.896 0.000 0.624 0.376
#> SRR886595 2 0.6274 0.934 0.000 0.544 0.456
#> SRR886596 2 0.6274 0.934 0.000 0.544 0.456
#> SRR886597 2 0.6274 0.934 0.000 0.544 0.456
#> SRR886598 2 0.6280 0.931 0.000 0.540 0.460
#> SRR886599 2 0.6280 0.931 0.000 0.540 0.460
#> SRR886600 2 0.6280 0.931 0.000 0.540 0.460
#> SRR886601 2 0.6280 0.931 0.000 0.540 0.460
#> SRR886602 1 0.2400 0.808 0.932 0.004 0.064
#> SRR886603 1 0.2400 0.808 0.932 0.004 0.064
#> SRR886604 1 0.2400 0.808 0.932 0.004 0.064
#> SRR886605 3 0.1643 0.825 0.044 0.000 0.956
#> SRR886606 3 0.1289 0.842 0.032 0.000 0.968
#> SRR886607 3 0.1411 0.838 0.036 0.000 0.964
#> SRR886608 3 0.0424 0.861 0.000 0.008 0.992
#> SRR886609 3 0.0424 0.861 0.000 0.008 0.992
#> SRR886610 3 0.0424 0.861 0.000 0.008 0.992
#> SRR886611 3 0.3686 0.713 0.000 0.140 0.860
#> SRR886612 3 0.3686 0.713 0.000 0.140 0.860
#> SRR886613 3 0.3816 0.693 0.000 0.148 0.852
#> SRR886614 1 0.6410 0.348 0.576 0.004 0.420
#> SRR886615 1 0.6421 0.339 0.572 0.004 0.424
#> SRR886616 1 0.6410 0.348 0.576 0.004 0.420
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.3486 0.799 0.812 0.000 0.188 0.000
#> SRR886566 1 0.3400 0.809 0.820 0.000 0.180 0.000
#> SRR886567 1 0.3356 0.814 0.824 0.000 0.176 0.000
#> SRR886568 3 0.0657 0.839 0.012 0.000 0.984 0.004
#> SRR886569 3 0.0657 0.839 0.012 0.000 0.984 0.004
#> SRR886570 3 0.0657 0.839 0.012 0.000 0.984 0.004
#> SRR886571 1 0.1022 0.942 0.968 0.000 0.032 0.000
#> SRR886572 1 0.1022 0.942 0.968 0.000 0.032 0.000
#> SRR886573 1 0.1022 0.942 0.968 0.000 0.032 0.000
#> SRR886574 3 0.3266 0.747 0.168 0.000 0.832 0.000
#> SRR886575 3 0.3266 0.747 0.168 0.000 0.832 0.000
#> SRR886576 3 0.3266 0.747 0.168 0.000 0.832 0.000
#> SRR886577 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886580 2 0.0188 0.973 0.000 0.996 0.004 0.000
#> SRR886581 2 0.0188 0.973 0.000 0.996 0.004 0.000
#> SRR886582 2 0.0188 0.973 0.000 0.996 0.004 0.000
#> SRR886583 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886586 2 0.0336 0.975 0.000 0.992 0.000 0.008
#> SRR886587 2 0.0336 0.975 0.000 0.992 0.000 0.008
#> SRR886588 2 0.0336 0.975 0.000 0.992 0.000 0.008
#> SRR886589 3 0.0524 0.838 0.008 0.000 0.988 0.004
#> SRR886590 3 0.0524 0.838 0.008 0.000 0.988 0.004
#> SRR886591 3 0.0524 0.838 0.008 0.000 0.988 0.004
#> SRR886592 2 0.0000 0.974 0.000 1.000 0.000 0.000
#> SRR886593 2 0.0000 0.974 0.000 1.000 0.000 0.000
#> SRR886594 2 0.0000 0.974 0.000 1.000 0.000 0.000
#> SRR886595 2 0.0592 0.974 0.000 0.984 0.000 0.016
#> SRR886596 2 0.0592 0.974 0.000 0.984 0.000 0.016
#> SRR886597 2 0.0592 0.974 0.000 0.984 0.000 0.016
#> SRR886598 2 0.2081 0.938 0.000 0.916 0.000 0.084
#> SRR886599 2 0.2081 0.938 0.000 0.916 0.000 0.084
#> SRR886600 2 0.2149 0.935 0.000 0.912 0.000 0.088
#> SRR886601 2 0.2081 0.938 0.000 0.916 0.000 0.084
#> SRR886602 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.952 1.000 0.000 0.000 0.000
#> SRR886605 4 0.4391 0.724 0.008 0.000 0.252 0.740
#> SRR886606 4 0.4295 0.736 0.008 0.000 0.240 0.752
#> SRR886607 4 0.4391 0.724 0.008 0.000 0.252 0.740
#> SRR886608 4 0.0336 0.861 0.000 0.000 0.008 0.992
#> SRR886609 4 0.0188 0.860 0.000 0.000 0.004 0.996
#> SRR886610 4 0.0188 0.860 0.000 0.000 0.004 0.996
#> SRR886611 4 0.2256 0.859 0.000 0.056 0.020 0.924
#> SRR886612 4 0.2335 0.858 0.000 0.060 0.020 0.920
#> SRR886613 4 0.2413 0.856 0.000 0.064 0.020 0.916
#> SRR886614 3 0.4663 0.586 0.012 0.000 0.716 0.272
#> SRR886615 3 0.4663 0.586 0.012 0.000 0.716 0.272
#> SRR886616 3 0.4663 0.586 0.012 0.000 0.716 0.272
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.3608 0.834 0.812 0.000 0.148 NA 0.000
#> SRR886566 1 0.3452 0.837 0.820 0.000 0.148 NA 0.000
#> SRR886567 1 0.3495 0.833 0.816 0.000 0.152 NA 0.000
#> SRR886568 3 0.1443 0.702 0.000 0.004 0.948 NA 0.004
#> SRR886569 3 0.1365 0.702 0.000 0.004 0.952 NA 0.004
#> SRR886570 3 0.1365 0.702 0.000 0.004 0.952 NA 0.004
#> SRR886571 1 0.3752 0.846 0.812 0.000 0.064 NA 0.000
#> SRR886572 1 0.3657 0.850 0.820 0.000 0.064 NA 0.000
#> SRR886573 1 0.3752 0.846 0.812 0.000 0.064 NA 0.000
#> SRR886574 3 0.5584 0.523 0.096 0.000 0.592 NA 0.000
#> SRR886575 3 0.5584 0.523 0.096 0.000 0.592 NA 0.000
#> SRR886576 3 0.5584 0.523 0.096 0.000 0.592 NA 0.000
#> SRR886577 1 0.0324 0.919 0.992 0.000 0.004 NA 0.000
#> SRR886578 1 0.0324 0.919 0.992 0.000 0.004 NA 0.000
#> SRR886579 1 0.0451 0.919 0.988 0.000 0.008 NA 0.000
#> SRR886580 2 0.1830 0.773 0.000 0.924 0.000 NA 0.008
#> SRR886581 2 0.2017 0.768 0.000 0.912 0.000 NA 0.008
#> SRR886582 2 0.1956 0.770 0.000 0.916 0.000 NA 0.008
#> SRR886583 1 0.0162 0.919 0.996 0.000 0.000 NA 0.000
#> SRR886584 1 0.0162 0.919 0.996 0.000 0.000 NA 0.000
#> SRR886585 1 0.0162 0.919 0.996 0.000 0.000 NA 0.000
#> SRR886586 2 0.1787 0.787 0.000 0.936 0.004 NA 0.016
#> SRR886587 2 0.1988 0.786 0.000 0.928 0.008 NA 0.016
#> SRR886588 2 0.2060 0.785 0.000 0.924 0.008 NA 0.016
#> SRR886589 3 0.3196 0.693 0.000 0.000 0.804 NA 0.004
#> SRR886590 3 0.3243 0.697 0.004 0.000 0.812 NA 0.004
#> SRR886591 3 0.3048 0.696 0.000 0.000 0.820 NA 0.004
#> SRR886592 2 0.1281 0.786 0.000 0.956 0.000 NA 0.012
#> SRR886593 2 0.1281 0.786 0.000 0.956 0.000 NA 0.012
#> SRR886594 2 0.1281 0.786 0.000 0.956 0.000 NA 0.012
#> SRR886595 2 0.3722 0.737 0.000 0.796 0.004 NA 0.176
#> SRR886596 2 0.3722 0.737 0.000 0.796 0.004 NA 0.176
#> SRR886597 2 0.3769 0.738 0.000 0.796 0.004 NA 0.172
#> SRR886598 2 0.4437 0.389 0.000 0.532 0.000 NA 0.464
#> SRR886599 2 0.4437 0.389 0.000 0.532 0.000 NA 0.464
#> SRR886600 2 0.4437 0.389 0.000 0.532 0.000 NA 0.464
#> SRR886601 2 0.4434 0.395 0.000 0.536 0.000 NA 0.460
#> SRR886602 1 0.0566 0.917 0.984 0.000 0.004 NA 0.000
#> SRR886603 1 0.0566 0.917 0.984 0.000 0.004 NA 0.000
#> SRR886604 1 0.0566 0.917 0.984 0.000 0.004 NA 0.000
#> SRR886605 3 0.6665 0.387 0.000 0.000 0.436 NA 0.312
#> SRR886606 3 0.6623 0.388 0.000 0.000 0.444 NA 0.320
#> SRR886607 3 0.6645 0.386 0.000 0.000 0.440 NA 0.316
#> SRR886608 5 0.0510 0.977 0.000 0.000 0.016 NA 0.984
#> SRR886609 5 0.0671 0.974 0.000 0.000 0.016 NA 0.980
#> SRR886610 5 0.0510 0.977 0.000 0.000 0.016 NA 0.984
#> SRR886611 5 0.1461 0.976 0.000 0.004 0.016 NA 0.952
#> SRR886612 5 0.1461 0.976 0.000 0.004 0.016 NA 0.952
#> SRR886613 5 0.1372 0.977 0.000 0.004 0.016 NA 0.956
#> SRR886614 3 0.4155 0.659 0.000 0.000 0.780 NA 0.144
#> SRR886615 3 0.4277 0.653 0.000 0.000 0.768 NA 0.156
#> SRR886616 3 0.4277 0.653 0.000 0.000 0.768 NA 0.156
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.3284 0.807 0.832 0.000 0.104 0.008 0.000 0.056
#> SRR886566 1 0.3269 0.806 0.832 0.000 0.108 0.008 0.000 0.052
#> SRR886567 1 0.3429 0.801 0.824 0.000 0.108 0.012 0.000 0.056
#> SRR886568 3 0.4823 0.683 0.016 0.032 0.680 0.020 0.000 0.252
#> SRR886569 3 0.4778 0.689 0.016 0.032 0.688 0.020 0.000 0.244
#> SRR886570 3 0.4754 0.693 0.016 0.032 0.692 0.020 0.000 0.240
#> SRR886571 1 0.5356 0.627 0.636 0.000 0.016 0.152 0.000 0.196
#> SRR886572 1 0.5214 0.651 0.656 0.000 0.016 0.148 0.000 0.180
#> SRR886573 1 0.5350 0.640 0.644 0.000 0.020 0.148 0.000 0.188
#> SRR886574 6 0.2179 1.000 0.036 0.000 0.064 0.000 0.000 0.900
#> SRR886575 6 0.2179 1.000 0.036 0.000 0.064 0.000 0.000 0.900
#> SRR886576 6 0.2179 1.000 0.036 0.000 0.064 0.000 0.000 0.900
#> SRR886577 1 0.0790 0.873 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR886578 1 0.0632 0.874 0.976 0.000 0.000 0.000 0.000 0.024
#> SRR886579 1 0.0790 0.873 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR886580 4 0.4856 0.988 0.000 0.468 0.000 0.476 0.056 0.000
#> SRR886581 4 0.4856 0.990 0.000 0.464 0.000 0.480 0.056 0.000
#> SRR886582 4 0.4856 0.990 0.000 0.464 0.000 0.480 0.056 0.000
#> SRR886583 1 0.0146 0.874 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR886584 1 0.0146 0.874 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR886585 1 0.0146 0.874 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR886586 2 0.1563 0.571 0.000 0.932 0.056 0.000 0.012 0.000
#> SRR886587 2 0.1686 0.567 0.000 0.924 0.064 0.000 0.012 0.000
#> SRR886588 2 0.1686 0.567 0.000 0.924 0.064 0.000 0.012 0.000
#> SRR886589 3 0.3823 0.709 0.004 0.000 0.764 0.048 0.000 0.184
#> SRR886590 3 0.3823 0.709 0.004 0.000 0.760 0.044 0.000 0.192
#> SRR886591 3 0.3853 0.707 0.004 0.000 0.756 0.044 0.000 0.196
#> SRR886592 2 0.3372 0.460 0.000 0.824 0.000 0.124 0.016 0.036
#> SRR886593 2 0.3372 0.460 0.000 0.824 0.000 0.124 0.016 0.036
#> SRR886594 2 0.3441 0.454 0.000 0.820 0.000 0.124 0.016 0.040
#> SRR886595 2 0.4550 0.466 0.000 0.704 0.016 0.060 0.220 0.000
#> SRR886596 2 0.4575 0.462 0.000 0.700 0.016 0.060 0.224 0.000
#> SRR886597 2 0.4687 0.466 0.000 0.700 0.016 0.060 0.220 0.004
#> SRR886598 5 0.4503 0.628 0.000 0.192 0.000 0.108 0.700 0.000
#> SRR886599 5 0.4383 0.649 0.000 0.176 0.000 0.108 0.716 0.000
#> SRR886600 5 0.4351 0.651 0.000 0.172 0.000 0.108 0.720 0.000
#> SRR886601 5 0.4532 0.625 0.000 0.196 0.000 0.108 0.696 0.000
#> SRR886602 1 0.0870 0.867 0.972 0.000 0.000 0.012 0.012 0.004
#> SRR886603 1 0.0870 0.867 0.972 0.000 0.000 0.012 0.012 0.004
#> SRR886604 1 0.0870 0.867 0.972 0.000 0.000 0.012 0.012 0.004
#> SRR886605 3 0.1921 0.769 0.000 0.004 0.924 0.004 0.044 0.024
#> SRR886606 3 0.1921 0.769 0.000 0.004 0.924 0.004 0.044 0.024
#> SRR886607 3 0.1988 0.768 0.000 0.004 0.920 0.004 0.048 0.024
#> SRR886608 5 0.1531 0.769 0.000 0.000 0.068 0.004 0.928 0.000
#> SRR886609 5 0.1531 0.769 0.000 0.000 0.068 0.004 0.928 0.000
#> SRR886610 5 0.1531 0.769 0.000 0.000 0.068 0.004 0.928 0.000
#> SRR886611 5 0.3535 0.755 0.000 0.052 0.144 0.004 0.800 0.000
#> SRR886612 5 0.3595 0.752 0.000 0.056 0.144 0.004 0.796 0.000
#> SRR886613 5 0.3496 0.755 0.000 0.052 0.140 0.004 0.804 0.000
#> SRR886614 3 0.2433 0.786 0.000 0.000 0.884 0.000 0.044 0.072
#> SRR886615 3 0.2554 0.786 0.000 0.000 0.876 0.000 0.048 0.076
#> SRR886616 3 0.2519 0.787 0.000 0.000 0.884 0.004 0.044 0.068
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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.792 0.968 0.974 0.4986 0.502 0.502
#> 3 3 0.939 0.890 0.951 0.2641 0.891 0.784
#> 4 4 0.837 0.805 0.905 0.1274 0.928 0.816
#> 5 5 0.860 0.814 0.903 0.0981 0.919 0.746
#> 6 6 0.821 0.783 0.782 0.0459 0.946 0.774
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.000 0.965 1.000 0.000
#> SRR886566 1 0.000 0.965 1.000 0.000
#> SRR886567 1 0.000 0.965 1.000 0.000
#> SRR886568 1 0.118 0.961 0.984 0.016
#> SRR886569 1 0.118 0.961 0.984 0.016
#> SRR886570 1 0.118 0.961 0.984 0.016
#> SRR886571 1 0.000 0.965 1.000 0.000
#> SRR886572 1 0.000 0.965 1.000 0.000
#> SRR886573 1 0.000 0.965 1.000 0.000
#> SRR886574 1 0.000 0.965 1.000 0.000
#> SRR886575 1 0.000 0.965 1.000 0.000
#> SRR886576 1 0.000 0.965 1.000 0.000
#> SRR886577 1 0.000 0.965 1.000 0.000
#> SRR886578 1 0.000 0.965 1.000 0.000
#> SRR886579 1 0.000 0.965 1.000 0.000
#> SRR886580 2 0.000 1.000 0.000 1.000
#> SRR886581 2 0.000 1.000 0.000 1.000
#> SRR886582 2 0.000 1.000 0.000 1.000
#> SRR886583 1 0.000 0.965 1.000 0.000
#> SRR886584 1 0.000 0.965 1.000 0.000
#> SRR886585 1 0.000 0.965 1.000 0.000
#> SRR886586 2 0.000 1.000 0.000 1.000
#> SRR886587 2 0.000 1.000 0.000 1.000
#> SRR886588 2 0.000 1.000 0.000 1.000
#> SRR886589 1 0.204 0.953 0.968 0.032
#> SRR886590 1 0.204 0.953 0.968 0.032
#> SRR886591 1 0.204 0.953 0.968 0.032
#> SRR886592 2 0.000 1.000 0.000 1.000
#> SRR886593 2 0.000 1.000 0.000 1.000
#> SRR886594 2 0.000 1.000 0.000 1.000
#> SRR886595 2 0.000 1.000 0.000 1.000
#> SRR886596 2 0.000 1.000 0.000 1.000
#> SRR886597 2 0.000 1.000 0.000 1.000
#> SRR886598 2 0.000 1.000 0.000 1.000
#> SRR886599 2 0.000 1.000 0.000 1.000
#> SRR886600 2 0.000 1.000 0.000 1.000
#> SRR886601 2 0.000 1.000 0.000 1.000
#> SRR886602 1 0.000 0.965 1.000 0.000
#> SRR886603 1 0.000 0.965 1.000 0.000
#> SRR886604 1 0.000 0.965 1.000 0.000
#> SRR886605 1 0.595 0.870 0.856 0.144
#> SRR886606 1 0.595 0.870 0.856 0.144
#> SRR886607 1 0.595 0.870 0.856 0.144
#> SRR886608 2 0.000 1.000 0.000 1.000
#> SRR886609 2 0.000 1.000 0.000 1.000
#> SRR886610 2 0.000 1.000 0.000 1.000
#> SRR886611 2 0.000 1.000 0.000 1.000
#> SRR886612 2 0.000 1.000 0.000 1.000
#> SRR886613 2 0.000 1.000 0.000 1.000
#> SRR886614 1 0.595 0.870 0.856 0.144
#> SRR886615 1 0.595 0.870 0.856 0.144
#> SRR886616 1 0.595 0.870 0.856 0.144
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886566 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886567 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886568 1 0.6026 0.498 0.624 0.000 0.376
#> SRR886569 1 0.6026 0.498 0.624 0.000 0.376
#> SRR886570 1 0.6026 0.498 0.624 0.000 0.376
#> SRR886571 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886572 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886573 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886574 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886575 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886576 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886577 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886578 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886579 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886580 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886581 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886582 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886583 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886584 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886585 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886586 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886587 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886588 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886589 1 0.6286 0.322 0.536 0.000 0.464
#> SRR886590 1 0.6286 0.322 0.536 0.000 0.464
#> SRR886591 1 0.6286 0.322 0.536 0.000 0.464
#> SRR886592 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886593 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886594 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886595 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886596 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886597 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886598 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886599 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886600 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886601 2 0.0000 0.999 0.000 1.000 0.000
#> SRR886602 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886603 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886604 1 0.0000 0.880 1.000 0.000 0.000
#> SRR886605 3 0.0000 1.000 0.000 0.000 1.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1.000
#> SRR886608 2 0.0237 0.997 0.000 0.996 0.004
#> SRR886609 2 0.0237 0.997 0.000 0.996 0.004
#> SRR886610 2 0.0237 0.997 0.000 0.996 0.004
#> SRR886611 2 0.0237 0.997 0.000 0.996 0.004
#> SRR886612 2 0.0237 0.997 0.000 0.996 0.004
#> SRR886613 2 0.0237 0.997 0.000 0.996 0.004
#> SRR886614 3 0.0000 1.000 0.000 0.000 1.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886568 1 0.4776 0.489 0.624 0.000 0.376 0.000
#> SRR886569 1 0.4776 0.489 0.624 0.000 0.376 0.000
#> SRR886570 1 0.4776 0.489 0.624 0.000 0.376 0.000
#> SRR886571 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886574 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886575 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886576 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886577 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.867 1.000 0.000 0.000 0.000
#> SRR886580 4 0.1302 1.000 0.000 0.044 0.000 0.956
#> SRR886581 4 0.1302 1.000 0.000 0.044 0.000 0.956
#> SRR886582 4 0.1302 1.000 0.000 0.044 0.000 0.956
#> SRR886583 1 0.1302 0.854 0.956 0.000 0.000 0.044
#> SRR886584 1 0.1302 0.854 0.956 0.000 0.000 0.044
#> SRR886585 1 0.1302 0.854 0.956 0.000 0.000 0.044
#> SRR886586 2 0.4977 0.279 0.000 0.540 0.000 0.460
#> SRR886587 2 0.4977 0.279 0.000 0.540 0.000 0.460
#> SRR886588 2 0.4977 0.279 0.000 0.540 0.000 0.460
#> SRR886589 1 0.4981 0.311 0.536 0.000 0.464 0.000
#> SRR886590 1 0.4981 0.311 0.536 0.000 0.464 0.000
#> SRR886591 1 0.4981 0.311 0.536 0.000 0.464 0.000
#> SRR886592 4 0.1302 1.000 0.000 0.044 0.000 0.956
#> SRR886593 4 0.1302 1.000 0.000 0.044 0.000 0.956
#> SRR886594 4 0.1302 1.000 0.000 0.044 0.000 0.956
#> SRR886595 2 0.2704 0.805 0.000 0.876 0.000 0.124
#> SRR886596 2 0.2704 0.805 0.000 0.876 0.000 0.124
#> SRR886597 2 0.2704 0.805 0.000 0.876 0.000 0.124
#> SRR886598 2 0.0000 0.867 0.000 1.000 0.000 0.000
#> SRR886599 2 0.0000 0.867 0.000 1.000 0.000 0.000
#> SRR886600 2 0.0000 0.867 0.000 1.000 0.000 0.000
#> SRR886601 2 0.0000 0.867 0.000 1.000 0.000 0.000
#> SRR886602 1 0.1302 0.854 0.956 0.000 0.000 0.044
#> SRR886603 1 0.1302 0.854 0.956 0.000 0.000 0.044
#> SRR886604 1 0.1302 0.854 0.956 0.000 0.000 0.044
#> SRR886605 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886608 2 0.0188 0.867 0.000 0.996 0.004 0.000
#> SRR886609 2 0.0188 0.867 0.000 0.996 0.004 0.000
#> SRR886610 2 0.0188 0.867 0.000 0.996 0.004 0.000
#> SRR886611 2 0.0188 0.867 0.000 0.996 0.004 0.000
#> SRR886612 2 0.0188 0.867 0.000 0.996 0.004 0.000
#> SRR886613 2 0.0188 0.867 0.000 0.996 0.004 0.000
#> SRR886614 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0162 0.818 0.996 0.000 0.000 0.004 0.000
#> SRR886566 1 0.0162 0.818 0.996 0.000 0.000 0.004 0.000
#> SRR886567 1 0.0162 0.818 0.996 0.000 0.000 0.004 0.000
#> SRR886568 1 0.4114 0.525 0.624 0.000 0.376 0.000 0.000
#> SRR886569 1 0.4114 0.525 0.624 0.000 0.376 0.000 0.000
#> SRR886570 1 0.4114 0.525 0.624 0.000 0.376 0.000 0.000
#> SRR886571 1 0.1661 0.800 0.940 0.036 0.000 0.024 0.000
#> SRR886572 1 0.1661 0.800 0.940 0.036 0.000 0.024 0.000
#> SRR886573 1 0.1661 0.800 0.940 0.036 0.000 0.024 0.000
#> SRR886574 1 0.0324 0.816 0.992 0.004 0.000 0.004 0.000
#> SRR886575 1 0.0324 0.816 0.992 0.004 0.000 0.004 0.000
#> SRR886576 1 0.0324 0.816 0.992 0.004 0.000 0.004 0.000
#> SRR886577 1 0.0162 0.818 0.996 0.000 0.000 0.004 0.000
#> SRR886578 1 0.0162 0.818 0.996 0.000 0.000 0.004 0.000
#> SRR886579 1 0.0162 0.818 0.996 0.000 0.000 0.004 0.000
#> SRR886580 2 0.4302 1.000 0.000 0.520 0.000 0.000 0.480
#> SRR886581 2 0.4302 1.000 0.000 0.520 0.000 0.000 0.480
#> SRR886582 2 0.4302 1.000 0.000 0.520 0.000 0.000 0.480
#> SRR886583 4 0.5230 1.000 0.044 0.452 0.000 0.504 0.000
#> SRR886584 4 0.5230 1.000 0.044 0.452 0.000 0.504 0.000
#> SRR886585 4 0.5230 1.000 0.044 0.452 0.000 0.504 0.000
#> SRR886586 5 0.0000 0.295 0.000 0.000 0.000 0.000 1.000
#> SRR886587 5 0.0000 0.295 0.000 0.000 0.000 0.000 1.000
#> SRR886588 5 0.0000 0.295 0.000 0.000 0.000 0.000 1.000
#> SRR886589 1 0.5092 0.352 0.508 0.016 0.464 0.012 0.000
#> SRR886590 1 0.5092 0.352 0.508 0.016 0.464 0.012 0.000
#> SRR886591 1 0.5092 0.352 0.508 0.016 0.464 0.012 0.000
#> SRR886592 2 0.4302 1.000 0.000 0.520 0.000 0.000 0.480
#> SRR886593 2 0.4302 1.000 0.000 0.520 0.000 0.000 0.480
#> SRR886594 2 0.4302 1.000 0.000 0.520 0.000 0.000 0.480
#> SRR886595 5 0.3966 0.798 0.000 0.000 0.000 0.336 0.664
#> SRR886596 5 0.3966 0.798 0.000 0.000 0.000 0.336 0.664
#> SRR886597 5 0.3966 0.798 0.000 0.000 0.000 0.336 0.664
#> SRR886598 5 0.4300 0.866 0.000 0.000 0.000 0.476 0.524
#> SRR886599 5 0.4300 0.866 0.000 0.000 0.000 0.476 0.524
#> SRR886600 5 0.4300 0.866 0.000 0.000 0.000 0.476 0.524
#> SRR886601 5 0.4300 0.866 0.000 0.000 0.000 0.476 0.524
#> SRR886602 4 0.5230 1.000 0.044 0.452 0.000 0.504 0.000
#> SRR886603 4 0.5230 1.000 0.044 0.452 0.000 0.504 0.000
#> SRR886604 4 0.5230 1.000 0.044 0.452 0.000 0.504 0.000
#> SRR886605 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR886608 5 0.4446 0.866 0.000 0.000 0.004 0.476 0.520
#> SRR886609 5 0.4446 0.866 0.000 0.000 0.004 0.476 0.520
#> SRR886610 5 0.4446 0.866 0.000 0.000 0.004 0.476 0.520
#> SRR886611 5 0.4446 0.866 0.000 0.000 0.004 0.476 0.520
#> SRR886612 5 0.4446 0.866 0.000 0.000 0.004 0.476 0.520
#> SRR886613 5 0.4446 0.866 0.000 0.000 0.004 0.476 0.520
#> SRR886614 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.3728 0.506 0.652 0.000 0.344 0.004 0.000 0.000
#> SRR886566 1 0.3728 0.506 0.652 0.000 0.344 0.004 0.000 0.000
#> SRR886567 1 0.3728 0.506 0.652 0.000 0.344 0.004 0.000 0.000
#> SRR886568 3 0.3309 0.823 0.280 0.000 0.720 0.000 0.000 0.000
#> SRR886569 3 0.3309 0.823 0.280 0.000 0.720 0.000 0.000 0.000
#> SRR886570 3 0.3309 0.823 0.280 0.000 0.720 0.000 0.000 0.000
#> SRR886571 1 0.3395 0.535 0.808 0.000 0.060 0.000 0.000 0.132
#> SRR886572 1 0.3395 0.535 0.808 0.000 0.060 0.000 0.000 0.132
#> SRR886573 1 0.3395 0.535 0.808 0.000 0.060 0.000 0.000 0.132
#> SRR886574 1 0.0260 0.619 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886575 1 0.0260 0.619 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886576 1 0.0260 0.619 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886577 1 0.3728 0.506 0.652 0.000 0.344 0.004 0.000 0.000
#> SRR886578 1 0.3728 0.506 0.652 0.000 0.344 0.004 0.000 0.000
#> SRR886579 1 0.3728 0.506 0.652 0.000 0.344 0.004 0.000 0.000
#> SRR886580 2 0.3101 0.885 0.000 0.756 0.000 0.000 0.000 0.244
#> SRR886581 2 0.3101 0.885 0.000 0.756 0.000 0.000 0.000 0.244
#> SRR886582 2 0.3101 0.885 0.000 0.756 0.000 0.000 0.000 0.244
#> SRR886583 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886584 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886585 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886586 5 0.5634 0.342 0.000 0.348 0.000 0.000 0.492 0.160
#> SRR886587 5 0.5634 0.342 0.000 0.348 0.000 0.000 0.492 0.160
#> SRR886588 5 0.5634 0.342 0.000 0.348 0.000 0.000 0.492 0.160
#> SRR886589 3 0.2178 0.843 0.132 0.000 0.868 0.000 0.000 0.000
#> SRR886590 3 0.2178 0.843 0.132 0.000 0.868 0.000 0.000 0.000
#> SRR886591 3 0.2178 0.843 0.132 0.000 0.868 0.000 0.000 0.000
#> SRR886592 2 0.0000 0.884 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.884 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.884 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886595 5 0.2706 0.782 0.000 0.008 0.000 0.000 0.832 0.160
#> SRR886596 5 0.2706 0.782 0.000 0.008 0.000 0.000 0.832 0.160
#> SRR886597 5 0.2706 0.782 0.000 0.008 0.000 0.000 0.832 0.160
#> SRR886598 5 0.0000 0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886599 5 0.0000 0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886600 5 0.0000 0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886601 5 0.0000 0.851 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886602 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886603 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886604 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886605 6 0.3823 1.000 0.000 0.000 0.436 0.000 0.000 0.564
#> SRR886606 6 0.3823 1.000 0.000 0.000 0.436 0.000 0.000 0.564
#> SRR886607 6 0.3823 1.000 0.000 0.000 0.436 0.000 0.000 0.564
#> SRR886608 5 0.0865 0.852 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR886609 5 0.0865 0.852 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR886610 5 0.0865 0.852 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR886611 5 0.0865 0.852 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR886612 5 0.0865 0.852 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR886613 5 0.0865 0.852 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR886614 6 0.3823 1.000 0.000 0.000 0.436 0.000 0.000 0.564
#> SRR886615 6 0.3823 1.000 0.000 0.000 0.436 0.000 0.000 0.564
#> SRR886616 6 0.3823 1.000 0.000 0.000 0.436 0.000 0.000 0.564
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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.781 0.912 0.954 0.4986 0.491 0.491
#> 3 3 0.566 0.707 0.742 0.2689 0.889 0.799
#> 4 4 0.526 0.618 0.727 0.1099 0.767 0.560
#> 5 5 0.543 0.388 0.645 0.0748 0.792 0.528
#> 6 6 0.589 0.534 0.629 0.0523 0.765 0.399
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
#> SRR886565 1 0.000 0.951 1.000 0.000
#> SRR886566 1 0.000 0.951 1.000 0.000
#> SRR886567 1 0.000 0.951 1.000 0.000
#> SRR886568 1 0.680 0.805 0.820 0.180
#> SRR886569 1 0.680 0.805 0.820 0.180
#> SRR886570 1 0.680 0.805 0.820 0.180
#> SRR886571 1 0.118 0.940 0.984 0.016
#> SRR886572 1 0.118 0.940 0.984 0.016
#> SRR886573 1 0.118 0.940 0.984 0.016
#> SRR886574 1 0.000 0.951 1.000 0.000
#> SRR886575 1 0.000 0.951 1.000 0.000
#> SRR886576 1 0.000 0.951 1.000 0.000
#> SRR886577 1 0.000 0.951 1.000 0.000
#> SRR886578 1 0.000 0.951 1.000 0.000
#> SRR886579 1 0.000 0.951 1.000 0.000
#> SRR886580 2 0.000 0.944 0.000 1.000
#> SRR886581 2 0.000 0.944 0.000 1.000
#> SRR886582 2 0.000 0.944 0.000 1.000
#> SRR886583 1 0.000 0.951 1.000 0.000
#> SRR886584 1 0.000 0.951 1.000 0.000
#> SRR886585 1 0.000 0.951 1.000 0.000
#> SRR886586 2 0.118 0.956 0.016 0.984
#> SRR886587 2 0.118 0.956 0.016 0.984
#> SRR886588 2 0.118 0.956 0.016 0.984
#> SRR886589 1 0.000 0.951 1.000 0.000
#> SRR886590 1 0.000 0.951 1.000 0.000
#> SRR886591 1 0.000 0.951 1.000 0.000
#> SRR886592 2 0.118 0.956 0.016 0.984
#> SRR886593 2 0.118 0.956 0.016 0.984
#> SRR886594 2 0.118 0.956 0.016 0.984
#> SRR886595 2 0.118 0.956 0.016 0.984
#> SRR886596 2 0.118 0.956 0.016 0.984
#> SRR886597 2 0.118 0.956 0.016 0.984
#> SRR886598 2 0.118 0.956 0.016 0.984
#> SRR886599 2 0.118 0.956 0.016 0.984
#> SRR886600 2 0.118 0.956 0.016 0.984
#> SRR886601 2 0.118 0.956 0.016 0.984
#> SRR886602 1 0.000 0.951 1.000 0.000
#> SRR886603 1 0.000 0.951 1.000 0.000
#> SRR886604 1 0.000 0.951 1.000 0.000
#> SRR886605 2 0.895 0.556 0.312 0.688
#> SRR886606 2 0.895 0.556 0.312 0.688
#> SRR886607 2 0.895 0.556 0.312 0.688
#> SRR886608 2 0.118 0.956 0.016 0.984
#> SRR886609 2 0.118 0.956 0.016 0.984
#> SRR886610 2 0.118 0.956 0.016 0.984
#> SRR886611 2 0.118 0.956 0.016 0.984
#> SRR886612 2 0.118 0.956 0.016 0.984
#> SRR886613 2 0.118 0.956 0.016 0.984
#> SRR886614 1 0.689 0.800 0.816 0.184
#> SRR886615 1 0.689 0.800 0.816 0.184
#> SRR886616 1 0.689 0.800 0.816 0.184
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.5560 0.760 0.700 0.000 0.300
#> SRR886566 1 0.5560 0.760 0.700 0.000 0.300
#> SRR886567 1 0.5560 0.760 0.700 0.000 0.300
#> SRR886568 1 0.3031 0.645 0.912 0.012 0.076
#> SRR886569 1 0.3031 0.645 0.912 0.012 0.076
#> SRR886570 1 0.3031 0.645 0.912 0.012 0.076
#> SRR886571 1 0.5785 0.759 0.668 0.000 0.332
#> SRR886572 1 0.5785 0.759 0.668 0.000 0.332
#> SRR886573 1 0.5785 0.759 0.668 0.000 0.332
#> SRR886574 1 0.6026 0.754 0.624 0.000 0.376
#> SRR886575 1 0.6026 0.754 0.624 0.000 0.376
#> SRR886576 1 0.6026 0.754 0.624 0.000 0.376
#> SRR886577 1 0.6079 0.751 0.612 0.000 0.388
#> SRR886578 1 0.6079 0.751 0.612 0.000 0.388
#> SRR886579 1 0.6079 0.751 0.612 0.000 0.388
#> SRR886580 2 0.3941 0.837 0.000 0.844 0.156
#> SRR886581 2 0.3941 0.837 0.000 0.844 0.156
#> SRR886582 2 0.3941 0.837 0.000 0.844 0.156
#> SRR886583 1 0.6309 0.720 0.500 0.000 0.500
#> SRR886584 1 0.6309 0.720 0.500 0.000 0.500
#> SRR886585 1 0.6309 0.720 0.500 0.000 0.500
#> SRR886586 2 0.3272 0.853 0.004 0.892 0.104
#> SRR886587 2 0.3272 0.853 0.004 0.892 0.104
#> SRR886588 2 0.3272 0.853 0.004 0.892 0.104
#> SRR886589 1 0.0237 0.686 0.996 0.000 0.004
#> SRR886590 1 0.0237 0.686 0.996 0.000 0.004
#> SRR886591 1 0.0237 0.686 0.996 0.000 0.004
#> SRR886592 2 0.4575 0.825 0.004 0.812 0.184
#> SRR886593 2 0.4575 0.825 0.004 0.812 0.184
#> SRR886594 2 0.4575 0.825 0.004 0.812 0.184
#> SRR886595 2 0.0892 0.861 0.000 0.980 0.020
#> SRR886596 2 0.0892 0.861 0.000 0.980 0.020
#> SRR886597 2 0.0892 0.861 0.000 0.980 0.020
#> SRR886598 2 0.2448 0.856 0.000 0.924 0.076
#> SRR886599 2 0.2448 0.856 0.000 0.924 0.076
#> SRR886600 2 0.2448 0.856 0.000 0.924 0.076
#> SRR886601 2 0.2448 0.856 0.000 0.924 0.076
#> SRR886602 1 0.6309 0.720 0.504 0.000 0.496
#> SRR886603 1 0.6309 0.720 0.504 0.000 0.496
#> SRR886604 1 0.6309 0.720 0.504 0.000 0.496
#> SRR886605 1 0.9679 -0.122 0.448 0.320 0.232
#> SRR886606 1 0.9679 -0.122 0.448 0.320 0.232
#> SRR886607 1 0.9679 -0.122 0.448 0.320 0.232
#> SRR886608 2 0.7535 0.727 0.132 0.692 0.176
#> SRR886609 2 0.7535 0.727 0.132 0.692 0.176
#> SRR886610 2 0.7535 0.727 0.132 0.692 0.176
#> SRR886611 2 0.6435 0.778 0.076 0.756 0.168
#> SRR886612 2 0.6435 0.778 0.076 0.756 0.168
#> SRR886613 2 0.6435 0.778 0.076 0.756 0.168
#> SRR886614 1 0.5292 0.561 0.800 0.028 0.172
#> SRR886615 1 0.5292 0.561 0.800 0.028 0.172
#> SRR886616 1 0.5292 0.561 0.800 0.028 0.172
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.444 0.765 0.800 0.000 0.148 NA
#> SRR886566 1 0.444 0.765 0.800 0.000 0.148 NA
#> SRR886567 1 0.444 0.765 0.800 0.000 0.148 NA
#> SRR886568 3 0.675 0.415 0.328 0.000 0.560 NA
#> SRR886569 3 0.675 0.415 0.328 0.000 0.560 NA
#> SRR886570 3 0.675 0.415 0.328 0.000 0.560 NA
#> SRR886571 1 0.561 0.744 0.712 0.000 0.088 NA
#> SRR886572 1 0.561 0.744 0.712 0.000 0.088 NA
#> SRR886573 1 0.561 0.744 0.712 0.000 0.088 NA
#> SRR886574 1 0.545 0.760 0.736 0.000 0.108 NA
#> SRR886575 1 0.545 0.760 0.736 0.000 0.108 NA
#> SRR886576 1 0.545 0.760 0.736 0.000 0.108 NA
#> SRR886577 1 0.324 0.795 0.872 0.000 0.100 NA
#> SRR886578 1 0.324 0.795 0.872 0.000 0.100 NA
#> SRR886579 1 0.324 0.795 0.872 0.000 0.100 NA
#> SRR886580 2 0.428 0.736 0.000 0.764 0.012 NA
#> SRR886581 2 0.428 0.736 0.000 0.764 0.012 NA
#> SRR886582 2 0.428 0.736 0.000 0.764 0.012 NA
#> SRR886583 1 0.292 0.760 0.860 0.000 0.000 NA
#> SRR886584 1 0.292 0.760 0.860 0.000 0.000 NA
#> SRR886585 1 0.292 0.760 0.860 0.000 0.000 NA
#> SRR886586 2 0.247 0.774 0.000 0.916 0.028 NA
#> SRR886587 2 0.247 0.774 0.000 0.916 0.028 NA
#> SRR886588 2 0.247 0.774 0.000 0.916 0.028 NA
#> SRR886589 3 0.700 0.317 0.368 0.000 0.508 NA
#> SRR886590 3 0.700 0.317 0.368 0.000 0.508 NA
#> SRR886591 3 0.700 0.317 0.368 0.000 0.508 NA
#> SRR886592 2 0.364 0.746 0.000 0.848 0.032 NA
#> SRR886593 2 0.364 0.746 0.000 0.848 0.032 NA
#> SRR886594 2 0.364 0.746 0.000 0.848 0.032 NA
#> SRR886595 2 0.376 0.781 0.000 0.844 0.040 NA
#> SRR886596 2 0.376 0.781 0.000 0.844 0.040 NA
#> SRR886597 2 0.376 0.781 0.000 0.844 0.040 NA
#> SRR886598 2 0.569 0.746 0.000 0.712 0.104 NA
#> SRR886599 2 0.569 0.746 0.000 0.712 0.104 NA
#> SRR886600 2 0.569 0.746 0.000 0.712 0.104 NA
#> SRR886601 2 0.569 0.746 0.000 0.712 0.104 NA
#> SRR886602 1 0.316 0.749 0.852 0.000 0.004 NA
#> SRR886603 1 0.316 0.749 0.852 0.000 0.004 NA
#> SRR886604 1 0.316 0.749 0.852 0.000 0.004 NA
#> SRR886605 3 0.271 0.535 0.020 0.080 0.900 NA
#> SRR886606 3 0.271 0.535 0.020 0.080 0.900 NA
#> SRR886607 3 0.271 0.535 0.020 0.080 0.900 NA
#> SRR886608 3 0.718 -0.218 0.000 0.380 0.480 NA
#> SRR886609 3 0.718 -0.218 0.000 0.380 0.480 NA
#> SRR886610 3 0.718 -0.218 0.000 0.380 0.480 NA
#> SRR886611 2 0.692 0.489 0.000 0.536 0.340 NA
#> SRR886612 2 0.692 0.489 0.000 0.536 0.340 NA
#> SRR886613 2 0.692 0.489 0.000 0.536 0.340 NA
#> SRR886614 3 0.394 0.563 0.152 0.004 0.824 NA
#> SRR886615 3 0.394 0.563 0.152 0.004 0.824 NA
#> SRR886616 3 0.394 0.563 0.152 0.004 0.824 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.357 0.6174 0.852 0.028 0.064 NA 0.000
#> SRR886566 1 0.357 0.6174 0.852 0.028 0.064 NA 0.000
#> SRR886567 1 0.357 0.6174 0.852 0.028 0.064 NA 0.000
#> SRR886568 1 0.696 -0.0273 0.428 0.056 0.416 NA 0.000
#> SRR886569 1 0.696 -0.0273 0.428 0.056 0.416 NA 0.000
#> SRR886570 1 0.696 -0.0273 0.428 0.056 0.416 NA 0.000
#> SRR886571 1 0.551 0.5841 0.712 0.108 0.040 NA 0.000
#> SRR886572 1 0.551 0.5841 0.712 0.108 0.040 NA 0.000
#> SRR886573 1 0.551 0.5842 0.712 0.112 0.040 NA 0.000
#> SRR886574 1 0.402 0.6137 0.820 0.064 0.024 NA 0.000
#> SRR886575 1 0.402 0.6137 0.820 0.064 0.024 NA 0.000
#> SRR886576 1 0.403 0.6138 0.820 0.068 0.024 NA 0.000
#> SRR886577 1 0.329 0.6321 0.844 0.008 0.024 NA 0.000
#> SRR886578 1 0.329 0.6321 0.844 0.008 0.024 NA 0.000
#> SRR886579 1 0.329 0.6321 0.844 0.008 0.024 NA 0.000
#> SRR886580 5 0.635 -0.4552 0.000 0.408 0.016 NA 0.472
#> SRR886581 5 0.635 -0.4552 0.000 0.408 0.016 NA 0.472
#> SRR886582 5 0.635 -0.4552 0.000 0.408 0.016 NA 0.472
#> SRR886583 1 0.547 0.5633 0.560 0.032 0.020 NA 0.000
#> SRR886584 1 0.547 0.5633 0.560 0.032 0.020 NA 0.000
#> SRR886585 1 0.547 0.5633 0.560 0.032 0.020 NA 0.000
#> SRR886586 5 0.643 -0.3827 0.000 0.416 0.036 NA 0.472
#> SRR886587 5 0.643 -0.3827 0.000 0.416 0.036 NA 0.472
#> SRR886588 5 0.643 -0.3827 0.000 0.416 0.036 NA 0.472
#> SRR886589 1 0.705 0.0715 0.436 0.044 0.388 NA 0.000
#> SRR886590 1 0.705 0.0715 0.436 0.044 0.388 NA 0.000
#> SRR886591 1 0.705 0.0715 0.436 0.044 0.388 NA 0.000
#> SRR886592 2 0.479 1.0000 0.000 0.616 0.008 NA 0.360
#> SRR886593 2 0.479 1.0000 0.000 0.616 0.008 NA 0.360
#> SRR886594 2 0.479 1.0000 0.000 0.616 0.008 NA 0.360
#> SRR886595 5 0.482 0.1350 0.000 0.140 0.016 NA 0.752
#> SRR886596 5 0.482 0.1350 0.000 0.140 0.016 NA 0.752
#> SRR886597 5 0.482 0.1350 0.000 0.140 0.016 NA 0.752
#> SRR886598 5 0.104 0.3374 0.000 0.000 0.040 NA 0.960
#> SRR886599 5 0.104 0.3374 0.000 0.000 0.040 NA 0.960
#> SRR886600 5 0.104 0.3374 0.000 0.000 0.040 NA 0.960
#> SRR886601 5 0.104 0.3374 0.000 0.000 0.040 NA 0.960
#> SRR886602 1 0.476 0.5546 0.552 0.004 0.012 NA 0.000
#> SRR886603 1 0.476 0.5546 0.552 0.004 0.012 NA 0.000
#> SRR886604 1 0.476 0.5546 0.552 0.004 0.012 NA 0.000
#> SRR886605 3 0.206 0.8867 0.036 0.012 0.928 NA 0.024
#> SRR886606 3 0.206 0.8867 0.036 0.012 0.928 NA 0.024
#> SRR886607 3 0.206 0.8867 0.036 0.012 0.928 NA 0.024
#> SRR886608 5 0.703 0.2595 0.000 0.088 0.400 NA 0.440
#> SRR886609 5 0.703 0.2595 0.000 0.088 0.400 NA 0.440
#> SRR886610 5 0.703 0.2595 0.000 0.088 0.400 NA 0.440
#> SRR886611 5 0.744 0.3533 0.000 0.144 0.276 NA 0.492
#> SRR886612 5 0.744 0.3533 0.000 0.144 0.276 NA 0.492
#> SRR886613 5 0.744 0.3533 0.000 0.144 0.276 NA 0.492
#> SRR886614 3 0.356 0.8778 0.132 0.008 0.828 NA 0.000
#> SRR886615 3 0.356 0.8778 0.132 0.008 0.828 NA 0.000
#> SRR886616 3 0.356 0.8778 0.132 0.008 0.828 NA 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.1655 0.539 0.936 0.004 0.044 0.004 0.000 NA
#> SRR886566 1 0.1655 0.539 0.936 0.004 0.044 0.004 0.000 NA
#> SRR886567 1 0.1655 0.539 0.936 0.004 0.044 0.004 0.000 NA
#> SRR886568 3 0.6638 0.555 0.260 0.020 0.452 0.012 0.000 NA
#> SRR886569 3 0.6638 0.555 0.260 0.020 0.452 0.012 0.000 NA
#> SRR886570 3 0.6638 0.555 0.260 0.020 0.452 0.012 0.000 NA
#> SRR886571 1 0.5172 0.455 0.708 0.020 0.024 0.104 0.000 NA
#> SRR886572 1 0.5172 0.455 0.708 0.020 0.024 0.104 0.000 NA
#> SRR886573 1 0.5206 0.455 0.708 0.024 0.024 0.100 0.000 NA
#> SRR886574 1 0.5705 0.447 0.612 0.024 0.004 0.216 0.000 NA
#> SRR886575 1 0.5705 0.447 0.612 0.024 0.004 0.216 0.000 NA
#> SRR886576 1 0.5713 0.447 0.612 0.024 0.004 0.212 0.000 NA
#> SRR886577 1 0.4538 0.376 0.732 0.008 0.020 0.188 0.000 NA
#> SRR886578 1 0.4538 0.376 0.732 0.008 0.020 0.188 0.000 NA
#> SRR886579 1 0.4538 0.376 0.732 0.008 0.020 0.188 0.000 NA
#> SRR886580 2 0.6638 0.603 0.000 0.448 0.008 0.108 0.368 NA
#> SRR886581 2 0.6638 0.603 0.000 0.448 0.008 0.108 0.368 NA
#> SRR886582 2 0.6647 0.603 0.000 0.448 0.008 0.104 0.368 NA
#> SRR886583 4 0.4083 0.836 0.460 0.008 0.000 0.532 0.000 NA
#> SRR886584 4 0.4083 0.836 0.460 0.008 0.000 0.532 0.000 NA
#> SRR886585 4 0.4083 0.836 0.460 0.008 0.000 0.532 0.000 NA
#> SRR886586 2 0.6156 0.538 0.000 0.484 0.008 0.028 0.368 NA
#> SRR886587 2 0.6156 0.538 0.000 0.484 0.008 0.028 0.368 NA
#> SRR886588 2 0.6156 0.538 0.000 0.484 0.008 0.028 0.368 NA
#> SRR886589 3 0.6930 0.510 0.320 0.020 0.396 0.024 0.000 NA
#> SRR886590 3 0.6930 0.510 0.320 0.020 0.396 0.024 0.000 NA
#> SRR886591 3 0.6930 0.510 0.320 0.020 0.396 0.024 0.000 NA
#> SRR886592 2 0.3947 0.683 0.000 0.712 0.008 0.004 0.264 NA
#> SRR886593 2 0.3947 0.683 0.000 0.712 0.008 0.004 0.264 NA
#> SRR886594 2 0.3947 0.683 0.000 0.712 0.008 0.004 0.264 NA
#> SRR886595 5 0.5440 0.011 0.000 0.196 0.004 0.040 0.660 NA
#> SRR886596 5 0.5440 0.011 0.000 0.196 0.004 0.040 0.660 NA
#> SRR886597 5 0.5440 0.011 0.000 0.196 0.004 0.040 0.660 NA
#> SRR886598 5 0.0405 0.461 0.000 0.004 0.008 0.000 0.988 NA
#> SRR886599 5 0.0405 0.461 0.000 0.004 0.008 0.000 0.988 NA
#> SRR886600 5 0.0405 0.461 0.000 0.004 0.008 0.000 0.988 NA
#> SRR886601 5 0.0405 0.461 0.000 0.004 0.008 0.000 0.988 NA
#> SRR886602 4 0.5501 0.841 0.420 0.060 0.008 0.496 0.000 NA
#> SRR886603 4 0.5501 0.841 0.420 0.060 0.008 0.496 0.000 NA
#> SRR886604 4 0.5528 0.840 0.420 0.056 0.008 0.496 0.000 NA
#> SRR886605 3 0.3799 0.599 0.004 0.032 0.836 0.032 0.036 NA
#> SRR886606 3 0.3799 0.599 0.004 0.032 0.836 0.032 0.036 NA
#> SRR886607 3 0.3799 0.599 0.004 0.032 0.836 0.032 0.036 NA
#> SRR886608 5 0.6785 0.487 0.000 0.040 0.256 0.016 0.488 NA
#> SRR886609 5 0.6785 0.487 0.000 0.040 0.256 0.016 0.488 NA
#> SRR886610 5 0.6785 0.487 0.000 0.040 0.256 0.016 0.488 NA
#> SRR886611 5 0.6733 0.511 0.000 0.068 0.144 0.020 0.544 NA
#> SRR886612 5 0.6733 0.511 0.000 0.068 0.144 0.020 0.544 NA
#> SRR886613 5 0.6733 0.511 0.000 0.068 0.144 0.020 0.544 NA
#> SRR886614 3 0.2656 0.657 0.060 0.016 0.892 0.020 0.004 NA
#> SRR886615 3 0.2656 0.657 0.060 0.016 0.892 0.020 0.004 NA
#> SRR886616 3 0.2656 0.657 0.060 0.016 0.892 0.020 0.004 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5095 0.491 0.491
#> 3 3 0.875 0.917 0.960 0.2340 0.889 0.777
#> 4 4 0.758 0.663 0.796 0.1150 0.928 0.816
#> 5 5 0.732 0.807 0.852 0.0854 0.864 0.600
#> 6 6 0.778 0.694 0.802 0.0563 0.952 0.792
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
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886566 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886567 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886568 1 0.4555 0.752 0.800 0.000 0.200
#> SRR886569 1 0.4555 0.752 0.800 0.000 0.200
#> SRR886570 1 0.4555 0.752 0.800 0.000 0.200
#> SRR886571 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886572 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886573 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886574 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886575 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886576 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886577 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886578 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886579 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886580 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886581 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886582 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886583 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886584 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886585 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886586 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886587 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886588 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886589 1 0.5760 0.551 0.672 0.000 0.328
#> SRR886590 1 0.5760 0.551 0.672 0.000 0.328
#> SRR886591 1 0.5760 0.551 0.672 0.000 0.328
#> SRR886592 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886593 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886594 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886595 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886596 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886597 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886598 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886599 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886600 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886601 2 0.0000 0.977 0.000 1.000 0.000
#> SRR886602 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886603 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886604 1 0.0000 0.926 1.000 0.000 0.000
#> SRR886605 3 0.0000 0.997 0.000 0.000 1.000
#> SRR886606 3 0.0000 0.997 0.000 0.000 1.000
#> SRR886607 3 0.0000 0.997 0.000 0.000 1.000
#> SRR886608 2 0.3619 0.868 0.000 0.864 0.136
#> SRR886609 2 0.3619 0.868 0.000 0.864 0.136
#> SRR886610 2 0.3619 0.868 0.000 0.864 0.136
#> SRR886611 2 0.1163 0.962 0.000 0.972 0.028
#> SRR886612 2 0.1163 0.962 0.000 0.972 0.028
#> SRR886613 2 0.1163 0.962 0.000 0.972 0.028
#> SRR886614 3 0.0237 0.997 0.004 0.000 0.996
#> SRR886615 3 0.0237 0.997 0.004 0.000 0.996
#> SRR886616 3 0.0237 0.997 0.004 0.000 0.996
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.1940 0.847 0.924 0.000 0.000 0.076
#> SRR886566 1 0.1940 0.847 0.924 0.000 0.000 0.076
#> SRR886567 1 0.1940 0.847 0.924 0.000 0.000 0.076
#> SRR886568 1 0.6998 0.459 0.504 0.004 0.104 0.388
#> SRR886569 1 0.6998 0.459 0.504 0.004 0.104 0.388
#> SRR886570 1 0.6998 0.459 0.504 0.004 0.104 0.388
#> SRR886571 1 0.2216 0.841 0.908 0.000 0.000 0.092
#> SRR886572 1 0.2216 0.841 0.908 0.000 0.000 0.092
#> SRR886573 1 0.2216 0.841 0.908 0.000 0.000 0.092
#> SRR886574 1 0.1557 0.849 0.944 0.000 0.000 0.056
#> SRR886575 1 0.1557 0.849 0.944 0.000 0.000 0.056
#> SRR886576 1 0.1557 0.849 0.944 0.000 0.000 0.056
#> SRR886577 1 0.0188 0.857 0.996 0.000 0.000 0.004
#> SRR886578 1 0.0188 0.857 0.996 0.000 0.000 0.004
#> SRR886579 1 0.0188 0.857 0.996 0.000 0.000 0.004
#> SRR886580 2 0.0336 0.690 0.000 0.992 0.000 0.008
#> SRR886581 2 0.0336 0.690 0.000 0.992 0.000 0.008
#> SRR886582 2 0.0336 0.690 0.000 0.992 0.000 0.008
#> SRR886583 1 0.0000 0.857 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.857 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.857 1.000 0.000 0.000 0.000
#> SRR886586 2 0.0188 0.691 0.000 0.996 0.000 0.004
#> SRR886587 2 0.0188 0.691 0.000 0.996 0.000 0.004
#> SRR886588 2 0.0188 0.691 0.000 0.996 0.000 0.004
#> SRR886589 1 0.7530 0.428 0.492 0.000 0.236 0.272
#> SRR886590 1 0.7530 0.428 0.492 0.000 0.236 0.272
#> SRR886591 1 0.7530 0.428 0.492 0.000 0.236 0.272
#> SRR886592 2 0.0000 0.690 0.000 1.000 0.000 0.000
#> SRR886593 2 0.0000 0.690 0.000 1.000 0.000 0.000
#> SRR886594 2 0.0000 0.690 0.000 1.000 0.000 0.000
#> SRR886595 2 0.3356 0.500 0.000 0.824 0.000 0.176
#> SRR886596 2 0.3356 0.500 0.000 0.824 0.000 0.176
#> SRR886597 2 0.3356 0.500 0.000 0.824 0.000 0.176
#> SRR886598 2 0.4994 -0.702 0.000 0.520 0.000 0.480
#> SRR886599 2 0.4994 -0.702 0.000 0.520 0.000 0.480
#> SRR886600 2 0.4994 -0.702 0.000 0.520 0.000 0.480
#> SRR886601 2 0.4994 -0.702 0.000 0.520 0.000 0.480
#> SRR886602 1 0.0000 0.857 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.857 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.857 1.000 0.000 0.000 0.000
#> SRR886605 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886608 4 0.6270 0.934 0.000 0.404 0.060 0.536
#> SRR886609 4 0.6270 0.934 0.000 0.404 0.060 0.536
#> SRR886610 4 0.6270 0.934 0.000 0.404 0.060 0.536
#> SRR886611 4 0.5668 0.930 0.000 0.444 0.024 0.532
#> SRR886612 4 0.5668 0.930 0.000 0.444 0.024 0.532
#> SRR886613 4 0.5668 0.930 0.000 0.444 0.024 0.532
#> SRR886614 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886615 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR886616 3 0.0000 1.000 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.3354 0.780 0.844 0.000 0.000 0.088 0.068
#> SRR886566 1 0.3354 0.780 0.844 0.000 0.000 0.088 0.068
#> SRR886567 1 0.3354 0.780 0.844 0.000 0.000 0.088 0.068
#> SRR886568 4 0.2818 0.602 0.132 0.000 0.012 0.856 0.000
#> SRR886569 4 0.2818 0.602 0.132 0.000 0.012 0.856 0.000
#> SRR886570 4 0.2818 0.602 0.132 0.000 0.012 0.856 0.000
#> SRR886571 1 0.4501 0.692 0.756 0.000 0.000 0.128 0.116
#> SRR886572 1 0.4501 0.692 0.756 0.000 0.000 0.128 0.116
#> SRR886573 1 0.4501 0.692 0.756 0.000 0.000 0.128 0.116
#> SRR886574 1 0.2574 0.789 0.876 0.000 0.000 0.112 0.012
#> SRR886575 1 0.2574 0.789 0.876 0.000 0.000 0.112 0.012
#> SRR886576 1 0.2574 0.789 0.876 0.000 0.000 0.112 0.012
#> SRR886577 1 0.0880 0.854 0.968 0.000 0.000 0.032 0.000
#> SRR886578 1 0.0880 0.854 0.968 0.000 0.000 0.032 0.000
#> SRR886579 1 0.0880 0.854 0.968 0.000 0.000 0.032 0.000
#> SRR886580 2 0.0162 0.884 0.000 0.996 0.000 0.000 0.004
#> SRR886581 2 0.0162 0.884 0.000 0.996 0.000 0.000 0.004
#> SRR886582 2 0.0162 0.884 0.000 0.996 0.000 0.000 0.004
#> SRR886583 1 0.1124 0.855 0.960 0.000 0.000 0.036 0.004
#> SRR886584 1 0.1124 0.855 0.960 0.000 0.000 0.036 0.004
#> SRR886585 1 0.1124 0.855 0.960 0.000 0.000 0.036 0.004
#> SRR886586 2 0.0807 0.880 0.000 0.976 0.000 0.012 0.012
#> SRR886587 2 0.0807 0.880 0.000 0.976 0.000 0.012 0.012
#> SRR886588 2 0.0807 0.880 0.000 0.976 0.000 0.012 0.012
#> SRR886589 4 0.8016 0.529 0.304 0.000 0.124 0.400 0.172
#> SRR886590 4 0.8016 0.529 0.304 0.000 0.124 0.400 0.172
#> SRR886591 4 0.8016 0.529 0.304 0.000 0.124 0.400 0.172
#> SRR886592 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.883 0.000 1.000 0.000 0.000 0.000
#> SRR886595 2 0.4132 0.544 0.000 0.720 0.000 0.020 0.260
#> SRR886596 2 0.4132 0.544 0.000 0.720 0.000 0.020 0.260
#> SRR886597 2 0.4132 0.544 0.000 0.720 0.000 0.020 0.260
#> SRR886598 5 0.4147 0.824 0.000 0.316 0.000 0.008 0.676
#> SRR886599 5 0.4147 0.824 0.000 0.316 0.000 0.008 0.676
#> SRR886600 5 0.4147 0.824 0.000 0.316 0.000 0.008 0.676
#> SRR886601 5 0.4147 0.824 0.000 0.316 0.000 0.008 0.676
#> SRR886602 1 0.1205 0.854 0.956 0.000 0.000 0.040 0.004
#> SRR886603 1 0.1205 0.854 0.956 0.000 0.000 0.040 0.004
#> SRR886604 1 0.1205 0.854 0.956 0.000 0.000 0.040 0.004
#> SRR886605 3 0.0290 0.994 0.000 0.000 0.992 0.000 0.008
#> SRR886606 3 0.0290 0.994 0.000 0.000 0.992 0.000 0.008
#> SRR886607 3 0.0290 0.994 0.000 0.000 0.992 0.000 0.008
#> SRR886608 5 0.3435 0.872 0.000 0.156 0.020 0.004 0.820
#> SRR886609 5 0.3435 0.872 0.000 0.156 0.020 0.004 0.820
#> SRR886610 5 0.3435 0.872 0.000 0.156 0.020 0.004 0.820
#> SRR886611 5 0.3548 0.884 0.000 0.188 0.004 0.012 0.796
#> SRR886612 5 0.3548 0.884 0.000 0.188 0.004 0.012 0.796
#> SRR886613 5 0.3548 0.884 0.000 0.188 0.004 0.012 0.796
#> SRR886614 3 0.0000 0.994 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.0000 0.994 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.0000 0.994 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.3923 0.145 0.620 0.000 0.000 0.372 0.000 0.008
#> SRR886566 1 0.3923 0.145 0.620 0.000 0.000 0.372 0.000 0.008
#> SRR886567 1 0.3923 0.145 0.620 0.000 0.000 0.372 0.000 0.008
#> SRR886568 6 0.0291 1.000 0.004 0.000 0.000 0.004 0.000 0.992
#> SRR886569 6 0.0291 1.000 0.004 0.000 0.000 0.004 0.000 0.992
#> SRR886570 6 0.0291 1.000 0.004 0.000 0.000 0.004 0.000 0.992
#> SRR886571 4 0.3866 0.242 0.484 0.000 0.000 0.516 0.000 0.000
#> SRR886572 4 0.3866 0.242 0.484 0.000 0.000 0.516 0.000 0.000
#> SRR886573 4 0.3866 0.242 0.484 0.000 0.000 0.516 0.000 0.000
#> SRR886574 1 0.5424 0.491 0.628 0.008 0.000 0.224 0.008 0.132
#> SRR886575 1 0.5424 0.491 0.628 0.008 0.000 0.224 0.008 0.132
#> SRR886576 1 0.5424 0.491 0.628 0.008 0.000 0.224 0.008 0.132
#> SRR886577 1 0.1909 0.725 0.920 0.000 0.000 0.052 0.004 0.024
#> SRR886578 1 0.1909 0.725 0.920 0.000 0.000 0.052 0.004 0.024
#> SRR886579 1 0.1909 0.725 0.920 0.000 0.000 0.052 0.004 0.024
#> SRR886580 2 0.2918 0.804 0.000 0.856 0.000 0.088 0.052 0.004
#> SRR886581 2 0.2918 0.804 0.000 0.856 0.000 0.088 0.052 0.004
#> SRR886582 2 0.2918 0.804 0.000 0.856 0.000 0.088 0.052 0.004
#> SRR886583 1 0.0508 0.736 0.984 0.012 0.000 0.004 0.000 0.000
#> SRR886584 1 0.0508 0.736 0.984 0.012 0.000 0.004 0.000 0.000
#> SRR886585 1 0.0508 0.736 0.984 0.012 0.000 0.004 0.000 0.000
#> SRR886586 2 0.2791 0.808 0.000 0.872 0.004 0.052 0.068 0.004
#> SRR886587 2 0.2791 0.808 0.000 0.872 0.004 0.052 0.068 0.004
#> SRR886588 2 0.2791 0.808 0.000 0.872 0.004 0.052 0.068 0.004
#> SRR886589 4 0.5914 0.501 0.100 0.024 0.056 0.652 0.000 0.168
#> SRR886590 4 0.5914 0.501 0.100 0.024 0.056 0.652 0.000 0.168
#> SRR886591 4 0.5914 0.501 0.100 0.024 0.056 0.652 0.000 0.168
#> SRR886592 2 0.1007 0.810 0.000 0.956 0.000 0.000 0.044 0.000
#> SRR886593 2 0.1007 0.810 0.000 0.956 0.000 0.000 0.044 0.000
#> SRR886594 2 0.1007 0.810 0.000 0.956 0.000 0.000 0.044 0.000
#> SRR886595 2 0.5820 0.376 0.000 0.484 0.004 0.128 0.376 0.008
#> SRR886596 2 0.5820 0.376 0.000 0.484 0.004 0.128 0.376 0.008
#> SRR886597 2 0.5820 0.376 0.000 0.484 0.004 0.128 0.376 0.008
#> SRR886598 5 0.3894 0.752 0.000 0.152 0.000 0.072 0.772 0.004
#> SRR886599 5 0.3894 0.752 0.000 0.152 0.000 0.072 0.772 0.004
#> SRR886600 5 0.3894 0.752 0.000 0.152 0.000 0.072 0.772 0.004
#> SRR886601 5 0.3894 0.752 0.000 0.152 0.000 0.072 0.772 0.004
#> SRR886602 1 0.0508 0.736 0.984 0.012 0.000 0.004 0.000 0.000
#> SRR886603 1 0.0508 0.736 0.984 0.012 0.000 0.004 0.000 0.000
#> SRR886604 1 0.0508 0.736 0.984 0.012 0.000 0.004 0.000 0.000
#> SRR886605 3 0.0405 0.986 0.000 0.000 0.988 0.008 0.004 0.000
#> SRR886606 3 0.0405 0.986 0.000 0.000 0.988 0.008 0.004 0.000
#> SRR886607 3 0.0405 0.986 0.000 0.000 0.988 0.008 0.004 0.000
#> SRR886608 5 0.1500 0.832 0.000 0.000 0.012 0.052 0.936 0.000
#> SRR886609 5 0.1500 0.832 0.000 0.000 0.012 0.052 0.936 0.000
#> SRR886610 5 0.1500 0.832 0.000 0.000 0.012 0.052 0.936 0.000
#> SRR886611 5 0.0810 0.847 0.000 0.008 0.008 0.004 0.976 0.004
#> SRR886612 5 0.0810 0.847 0.000 0.008 0.008 0.004 0.976 0.004
#> SRR886613 5 0.0810 0.847 0.000 0.008 0.008 0.004 0.976 0.004
#> SRR886614 3 0.0547 0.986 0.000 0.000 0.980 0.020 0.000 0.000
#> SRR886615 3 0.0547 0.986 0.000 0.000 0.980 0.020 0.000 0.000
#> SRR886616 3 0.0547 0.986 0.000 0.000 0.980 0.020 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.977 0.989 0.5005 0.502 0.502
#> 3 3 0.727 0.791 0.855 0.2472 0.891 0.784
#> 4 4 0.787 0.750 0.884 0.1350 0.910 0.770
#> 5 5 0.871 0.831 0.911 0.0959 0.888 0.653
#> 6 6 0.890 0.816 0.872 0.0356 0.975 0.891
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
#> SRR886565 1 0.000 0.981 1.000 0.000
#> SRR886566 1 0.000 0.981 1.000 0.000
#> SRR886567 1 0.000 0.981 1.000 0.000
#> SRR886568 1 0.000 0.981 1.000 0.000
#> SRR886569 1 0.000 0.981 1.000 0.000
#> SRR886570 1 0.000 0.981 1.000 0.000
#> SRR886571 1 0.000 0.981 1.000 0.000
#> SRR886572 1 0.000 0.981 1.000 0.000
#> SRR886573 1 0.000 0.981 1.000 0.000
#> SRR886574 1 0.000 0.981 1.000 0.000
#> SRR886575 1 0.000 0.981 1.000 0.000
#> SRR886576 1 0.000 0.981 1.000 0.000
#> SRR886577 1 0.000 0.981 1.000 0.000
#> SRR886578 1 0.000 0.981 1.000 0.000
#> SRR886579 1 0.000 0.981 1.000 0.000
#> SRR886580 2 0.000 1.000 0.000 1.000
#> SRR886581 2 0.000 1.000 0.000 1.000
#> SRR886582 2 0.000 1.000 0.000 1.000
#> SRR886583 1 0.000 0.981 1.000 0.000
#> SRR886584 1 0.000 0.981 1.000 0.000
#> SRR886585 1 0.000 0.981 1.000 0.000
#> SRR886586 2 0.000 1.000 0.000 1.000
#> SRR886587 2 0.000 1.000 0.000 1.000
#> SRR886588 2 0.000 1.000 0.000 1.000
#> SRR886589 1 0.000 0.981 1.000 0.000
#> SRR886590 1 0.000 0.981 1.000 0.000
#> SRR886591 1 0.000 0.981 1.000 0.000
#> SRR886592 2 0.000 1.000 0.000 1.000
#> SRR886593 2 0.000 1.000 0.000 1.000
#> SRR886594 2 0.000 1.000 0.000 1.000
#> SRR886595 2 0.000 1.000 0.000 1.000
#> SRR886596 2 0.000 1.000 0.000 1.000
#> SRR886597 2 0.000 1.000 0.000 1.000
#> SRR886598 2 0.000 1.000 0.000 1.000
#> SRR886599 2 0.000 1.000 0.000 1.000
#> SRR886600 2 0.000 1.000 0.000 1.000
#> SRR886601 2 0.000 1.000 0.000 1.000
#> SRR886602 1 0.000 0.981 1.000 0.000
#> SRR886603 1 0.000 0.981 1.000 0.000
#> SRR886604 1 0.000 0.981 1.000 0.000
#> SRR886605 1 0.745 0.749 0.788 0.212
#> SRR886606 1 0.671 0.800 0.824 0.176
#> SRR886607 1 0.662 0.805 0.828 0.172
#> SRR886608 2 0.000 1.000 0.000 1.000
#> SRR886609 2 0.000 1.000 0.000 1.000
#> SRR886610 2 0.000 1.000 0.000 1.000
#> SRR886611 2 0.000 1.000 0.000 1.000
#> SRR886612 2 0.000 1.000 0.000 1.000
#> SRR886613 2 0.000 1.000 0.000 1.000
#> SRR886614 1 0.000 0.981 1.000 0.000
#> SRR886615 1 0.000 0.981 1.000 0.000
#> SRR886616 1 0.000 0.981 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0237 0.876 0.996 0.000 0.004
#> SRR886566 1 0.0237 0.876 0.996 0.000 0.004
#> SRR886567 1 0.0237 0.876 0.996 0.000 0.004
#> SRR886568 1 0.4605 0.760 0.796 0.000 0.204
#> SRR886569 1 0.4702 0.750 0.788 0.000 0.212
#> SRR886570 1 0.4605 0.760 0.796 0.000 0.204
#> SRR886571 1 0.4605 0.760 0.796 0.000 0.204
#> SRR886572 1 0.4605 0.760 0.796 0.000 0.204
#> SRR886573 1 0.4605 0.760 0.796 0.000 0.204
#> SRR886574 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886575 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886576 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886577 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886578 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886579 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886580 2 0.1964 0.811 0.000 0.944 0.056
#> SRR886581 2 0.1964 0.811 0.000 0.944 0.056
#> SRR886582 2 0.1964 0.811 0.000 0.944 0.056
#> SRR886583 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886584 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886585 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886586 2 0.0237 0.801 0.000 0.996 0.004
#> SRR886587 2 0.0237 0.801 0.000 0.996 0.004
#> SRR886588 2 0.0237 0.801 0.000 0.996 0.004
#> SRR886589 1 0.4702 0.750 0.788 0.000 0.212
#> SRR886590 1 0.4702 0.750 0.788 0.000 0.212
#> SRR886591 1 0.4842 0.732 0.776 0.000 0.224
#> SRR886592 2 0.0000 0.800 0.000 1.000 0.000
#> SRR886593 2 0.0000 0.800 0.000 1.000 0.000
#> SRR886594 2 0.0000 0.800 0.000 1.000 0.000
#> SRR886595 2 0.2066 0.813 0.000 0.940 0.060
#> SRR886596 2 0.2066 0.813 0.000 0.940 0.060
#> SRR886597 2 0.2066 0.813 0.000 0.940 0.060
#> SRR886598 2 0.6045 0.779 0.000 0.620 0.380
#> SRR886599 2 0.6045 0.779 0.000 0.620 0.380
#> SRR886600 2 0.6045 0.779 0.000 0.620 0.380
#> SRR886601 2 0.6045 0.779 0.000 0.620 0.380
#> SRR886602 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886603 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886604 1 0.0000 0.877 1.000 0.000 0.000
#> SRR886605 3 0.2356 0.695 0.072 0.000 0.928
#> SRR886606 3 0.2448 0.698 0.076 0.000 0.924
#> SRR886607 3 0.2356 0.695 0.072 0.000 0.928
#> SRR886608 2 0.6079 0.775 0.000 0.612 0.388
#> SRR886609 2 0.6095 0.772 0.000 0.608 0.392
#> SRR886610 2 0.6095 0.772 0.000 0.608 0.392
#> SRR886611 2 0.6062 0.778 0.000 0.616 0.384
#> SRR886612 2 0.6062 0.778 0.000 0.616 0.384
#> SRR886613 2 0.6062 0.778 0.000 0.616 0.384
#> SRR886614 3 0.6062 0.552 0.384 0.000 0.616
#> SRR886615 3 0.6062 0.552 0.384 0.000 0.616
#> SRR886616 3 0.6062 0.552 0.384 0.000 0.616
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0188 0.8987 0.996 0.000 0.004 0.000
#> SRR886566 1 0.0188 0.8987 0.996 0.000 0.004 0.000
#> SRR886567 1 0.0188 0.8987 0.996 0.000 0.004 0.000
#> SRR886568 1 0.3942 0.7931 0.764 0.000 0.236 0.000
#> SRR886569 1 0.4103 0.7705 0.744 0.000 0.256 0.000
#> SRR886570 1 0.3837 0.8029 0.776 0.000 0.224 0.000
#> SRR886571 1 0.3726 0.8115 0.788 0.000 0.212 0.000
#> SRR886572 1 0.3726 0.8115 0.788 0.000 0.212 0.000
#> SRR886573 1 0.3726 0.8115 0.788 0.000 0.212 0.000
#> SRR886574 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886575 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886576 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886577 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886580 2 0.0000 0.3926 0.000 1.000 0.000 0.000
#> SRR886581 2 0.0000 0.3926 0.000 1.000 0.000 0.000
#> SRR886582 2 0.0000 0.3926 0.000 1.000 0.000 0.000
#> SRR886583 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886586 4 0.4866 0.6958 0.000 0.404 0.000 0.596
#> SRR886587 4 0.4866 0.6958 0.000 0.404 0.000 0.596
#> SRR886588 4 0.4866 0.6958 0.000 0.404 0.000 0.596
#> SRR886589 1 0.3907 0.7969 0.768 0.000 0.232 0.000
#> SRR886590 1 0.3907 0.7969 0.768 0.000 0.232 0.000
#> SRR886591 1 0.4008 0.7853 0.756 0.000 0.244 0.000
#> SRR886592 4 0.4866 0.6958 0.000 0.404 0.000 0.596
#> SRR886593 4 0.4866 0.6958 0.000 0.404 0.000 0.596
#> SRR886594 4 0.4866 0.6958 0.000 0.404 0.000 0.596
#> SRR886595 4 0.3400 0.0439 0.000 0.180 0.000 0.820
#> SRR886596 4 0.1792 0.3014 0.000 0.068 0.000 0.932
#> SRR886597 4 0.0707 0.3655 0.000 0.020 0.000 0.980
#> SRR886598 2 0.4866 0.8013 0.000 0.596 0.000 0.404
#> SRR886599 2 0.4866 0.8013 0.000 0.596 0.000 0.404
#> SRR886600 2 0.4866 0.8013 0.000 0.596 0.000 0.404
#> SRR886601 2 0.4866 0.8013 0.000 0.596 0.000 0.404
#> SRR886602 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.8993 1.000 0.000 0.000 0.000
#> SRR886605 3 0.0000 0.9724 0.000 0.000 1.000 0.000
#> SRR886606 3 0.0000 0.9724 0.000 0.000 1.000 0.000
#> SRR886607 3 0.0000 0.9724 0.000 0.000 1.000 0.000
#> SRR886608 2 0.6039 0.7975 0.000 0.596 0.056 0.348
#> SRR886609 2 0.6464 0.7785 0.000 0.596 0.096 0.308
#> SRR886610 2 0.6430 0.7811 0.000 0.596 0.092 0.312
#> SRR886611 2 0.5691 0.7855 0.000 0.564 0.028 0.408
#> SRR886612 2 0.5613 0.8004 0.000 0.592 0.028 0.380
#> SRR886613 4 0.5776 -0.7139 0.000 0.468 0.028 0.504
#> SRR886614 3 0.0921 0.9726 0.028 0.000 0.972 0.000
#> SRR886615 3 0.0921 0.9726 0.028 0.000 0.972 0.000
#> SRR886616 3 0.0921 0.9726 0.028 0.000 0.972 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.1043 0.9511 0.960 0.000 0.000 0.040 0.000
#> SRR886566 1 0.1043 0.9511 0.960 0.000 0.000 0.040 0.000
#> SRR886567 1 0.1043 0.9511 0.960 0.000 0.000 0.040 0.000
#> SRR886568 1 0.0703 0.9384 0.976 0.000 0.024 0.000 0.000
#> SRR886569 1 0.1043 0.9260 0.960 0.000 0.040 0.000 0.000
#> SRR886570 1 0.0404 0.9453 0.988 0.000 0.012 0.000 0.000
#> SRR886571 1 0.1106 0.9520 0.964 0.000 0.012 0.024 0.000
#> SRR886572 1 0.1106 0.9520 0.964 0.000 0.012 0.024 0.000
#> SRR886573 1 0.1106 0.9520 0.964 0.000 0.012 0.024 0.000
#> SRR886574 1 0.2438 0.9301 0.900 0.000 0.060 0.040 0.000
#> SRR886575 1 0.2438 0.9301 0.900 0.000 0.060 0.040 0.000
#> SRR886576 1 0.2438 0.9301 0.900 0.000 0.060 0.040 0.000
#> SRR886577 1 0.2020 0.9221 0.900 0.000 0.000 0.100 0.000
#> SRR886578 1 0.1965 0.9253 0.904 0.000 0.000 0.096 0.000
#> SRR886579 1 0.2020 0.9221 0.900 0.000 0.000 0.100 0.000
#> SRR886580 5 0.4341 0.4082 0.000 0.404 0.000 0.004 0.592
#> SRR886581 5 0.4341 0.4082 0.000 0.404 0.000 0.004 0.592
#> SRR886582 5 0.4341 0.4082 0.000 0.404 0.000 0.004 0.592
#> SRR886583 4 0.0162 1.0000 0.004 0.000 0.000 0.996 0.000
#> SRR886584 4 0.0162 1.0000 0.004 0.000 0.000 0.996 0.000
#> SRR886585 4 0.0162 1.0000 0.004 0.000 0.000 0.996 0.000
#> SRR886586 2 0.0000 0.8385 0.000 1.000 0.000 0.000 0.000
#> SRR886587 2 0.0000 0.8385 0.000 1.000 0.000 0.000 0.000
#> SRR886588 2 0.0000 0.8385 0.000 1.000 0.000 0.000 0.000
#> SRR886589 1 0.0404 0.9453 0.988 0.000 0.012 0.000 0.000
#> SRR886590 1 0.0404 0.9453 0.988 0.000 0.012 0.000 0.000
#> SRR886591 1 0.0404 0.9453 0.988 0.000 0.012 0.000 0.000
#> SRR886592 2 0.0000 0.8385 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.8385 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.8385 0.000 1.000 0.000 0.000 0.000
#> SRR886595 5 0.4219 -0.0216 0.000 0.416 0.000 0.000 0.584
#> SRR886596 2 0.4297 0.2075 0.000 0.528 0.000 0.000 0.472
#> SRR886597 2 0.4235 0.3111 0.000 0.576 0.000 0.000 0.424
#> SRR886598 5 0.0000 0.7908 0.000 0.000 0.000 0.000 1.000
#> SRR886599 5 0.0000 0.7908 0.000 0.000 0.000 0.000 1.000
#> SRR886600 5 0.0000 0.7908 0.000 0.000 0.000 0.000 1.000
#> SRR886601 5 0.0000 0.7908 0.000 0.000 0.000 0.000 1.000
#> SRR886602 4 0.0162 1.0000 0.004 0.000 0.000 0.996 0.000
#> SRR886603 4 0.0162 1.0000 0.004 0.000 0.000 0.996 0.000
#> SRR886604 4 0.0162 1.0000 0.004 0.000 0.000 0.996 0.000
#> SRR886605 3 0.1410 0.9623 0.060 0.000 0.940 0.000 0.000
#> SRR886606 3 0.1410 0.9623 0.060 0.000 0.940 0.000 0.000
#> SRR886607 3 0.1410 0.9623 0.060 0.000 0.940 0.000 0.000
#> SRR886608 5 0.1608 0.7894 0.000 0.000 0.072 0.000 0.928
#> SRR886609 5 0.2230 0.7733 0.000 0.000 0.116 0.000 0.884
#> SRR886610 5 0.2179 0.7753 0.000 0.000 0.112 0.000 0.888
#> SRR886611 5 0.2067 0.7858 0.000 0.032 0.048 0.000 0.920
#> SRR886612 5 0.1357 0.7917 0.000 0.004 0.048 0.000 0.948
#> SRR886613 5 0.3532 0.7097 0.000 0.128 0.048 0.000 0.824
#> SRR886614 3 0.2127 0.9623 0.108 0.000 0.892 0.000 0.000
#> SRR886615 3 0.2127 0.9623 0.108 0.000 0.892 0.000 0.000
#> SRR886616 3 0.2127 0.9623 0.108 0.000 0.892 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0260 0.919 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR886566 1 0.0260 0.919 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR886567 1 0.0260 0.919 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR886568 1 0.0458 0.915 0.984 0.000 0.016 0.000 0.000 0.000
#> SRR886569 1 0.0790 0.904 0.968 0.000 0.032 0.000 0.000 0.000
#> SRR886570 1 0.0260 0.919 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886571 1 0.0551 0.920 0.984 0.000 0.008 0.004 0.000 0.004
#> SRR886572 1 0.0551 0.920 0.984 0.000 0.008 0.004 0.000 0.004
#> SRR886573 1 0.0551 0.920 0.984 0.000 0.008 0.004 0.000 0.004
#> SRR886574 1 0.3955 0.610 0.608 0.000 0.000 0.008 0.000 0.384
#> SRR886575 1 0.3955 0.610 0.608 0.000 0.000 0.008 0.000 0.384
#> SRR886576 1 0.3955 0.610 0.608 0.000 0.000 0.008 0.000 0.384
#> SRR886577 1 0.1075 0.900 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR886578 1 0.1007 0.902 0.956 0.000 0.000 0.044 0.000 0.000
#> SRR886579 1 0.1075 0.900 0.952 0.000 0.000 0.048 0.000 0.000
#> SRR886580 6 0.6772 1.000 0.000 0.260 0.040 0.000 0.336 0.364
#> SRR886581 6 0.6772 1.000 0.000 0.260 0.040 0.000 0.336 0.364
#> SRR886582 6 0.6772 1.000 0.000 0.260 0.040 0.000 0.336 0.364
#> SRR886583 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886584 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886585 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886586 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886587 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886588 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886589 1 0.0260 0.919 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886590 1 0.0260 0.919 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886591 1 0.0260 0.919 0.992 0.000 0.008 0.000 0.000 0.000
#> SRR886592 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.836 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886595 5 0.3782 -0.137 0.000 0.412 0.000 0.000 0.588 0.000
#> SRR886596 2 0.3838 0.364 0.000 0.552 0.000 0.000 0.448 0.000
#> SRR886597 2 0.3578 0.535 0.000 0.660 0.000 0.000 0.340 0.000
#> SRR886598 5 0.0000 0.653 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886599 5 0.0000 0.653 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886600 5 0.0000 0.653 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886601 5 0.0000 0.653 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886602 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886603 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886604 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886605 3 0.2001 0.946 0.040 0.000 0.912 0.000 0.000 0.048
#> SRR886606 3 0.1391 0.960 0.040 0.000 0.944 0.000 0.000 0.016
#> SRR886607 3 0.2867 0.890 0.040 0.000 0.848 0.000 0.000 0.112
#> SRR886608 5 0.3265 0.686 0.000 0.000 0.004 0.000 0.748 0.248
#> SRR886609 5 0.3265 0.686 0.000 0.000 0.004 0.000 0.748 0.248
#> SRR886610 5 0.3265 0.686 0.000 0.000 0.004 0.000 0.748 0.248
#> SRR886611 5 0.4260 0.651 0.000 0.048 0.004 0.000 0.700 0.248
#> SRR886612 5 0.3697 0.679 0.000 0.016 0.004 0.000 0.732 0.248
#> SRR886613 5 0.5594 0.443 0.000 0.184 0.004 0.000 0.564 0.248
#> SRR886614 3 0.1007 0.961 0.044 0.000 0.956 0.000 0.000 0.000
#> SRR886615 3 0.1007 0.961 0.044 0.000 0.956 0.000 0.000 0.000
#> SRR886616 3 0.1007 0.961 0.044 0.000 0.956 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.694 0.827 0.906 0.4320 0.618 0.618
#> 3 3 0.628 0.915 0.899 0.3255 0.851 0.758
#> 4 4 0.679 0.664 0.733 0.2414 0.729 0.452
#> 5 5 0.916 0.908 0.952 0.1234 0.891 0.610
#> 6 6 0.908 0.865 0.890 0.0256 0.986 0.931
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.0938 0.860 0.988 0.012
#> SRR886566 1 0.0938 0.860 0.988 0.012
#> SRR886567 1 0.0938 0.860 0.988 0.012
#> SRR886568 1 0.0376 0.859 0.996 0.004
#> SRR886569 1 0.0376 0.859 0.996 0.004
#> SRR886570 1 0.0376 0.859 0.996 0.004
#> SRR886571 1 0.0938 0.860 0.988 0.012
#> SRR886572 1 0.0938 0.860 0.988 0.012
#> SRR886573 1 0.0938 0.860 0.988 0.012
#> SRR886574 1 0.0000 0.859 1.000 0.000
#> SRR886575 1 0.0000 0.859 1.000 0.000
#> SRR886576 1 0.0000 0.859 1.000 0.000
#> SRR886577 1 0.0000 0.859 1.000 0.000
#> SRR886578 1 0.0000 0.859 1.000 0.000
#> SRR886579 1 0.0000 0.859 1.000 0.000
#> SRR886580 1 0.9209 0.621 0.664 0.336
#> SRR886581 1 0.9209 0.621 0.664 0.336
#> SRR886582 1 0.9209 0.621 0.664 0.336
#> SRR886583 1 0.0000 0.859 1.000 0.000
#> SRR886584 1 0.0000 0.859 1.000 0.000
#> SRR886585 1 0.0000 0.859 1.000 0.000
#> SRR886586 1 0.9710 0.550 0.600 0.400
#> SRR886587 1 0.9710 0.550 0.600 0.400
#> SRR886588 1 0.9710 0.550 0.600 0.400
#> SRR886589 1 0.0938 0.860 0.988 0.012
#> SRR886590 1 0.0938 0.860 0.988 0.012
#> SRR886591 1 0.0938 0.860 0.988 0.012
#> SRR886592 1 0.9661 0.562 0.608 0.392
#> SRR886593 1 0.9661 0.562 0.608 0.392
#> SRR886594 1 0.9661 0.562 0.608 0.392
#> SRR886595 2 0.0000 1.000 0.000 1.000
#> SRR886596 2 0.0000 1.000 0.000 1.000
#> SRR886597 2 0.0000 1.000 0.000 1.000
#> SRR886598 2 0.0000 1.000 0.000 1.000
#> SRR886599 2 0.0000 1.000 0.000 1.000
#> SRR886600 2 0.0000 1.000 0.000 1.000
#> SRR886601 2 0.0000 1.000 0.000 1.000
#> SRR886602 1 0.0000 0.859 1.000 0.000
#> SRR886603 1 0.0000 0.859 1.000 0.000
#> SRR886604 1 0.0000 0.859 1.000 0.000
#> SRR886605 1 0.9635 0.569 0.612 0.388
#> SRR886606 1 0.9635 0.569 0.612 0.388
#> SRR886607 1 0.9635 0.569 0.612 0.388
#> SRR886608 2 0.0000 1.000 0.000 1.000
#> SRR886609 2 0.0000 1.000 0.000 1.000
#> SRR886610 2 0.0000 1.000 0.000 1.000
#> SRR886611 2 0.0000 1.000 0.000 1.000
#> SRR886612 2 0.0000 1.000 0.000 1.000
#> SRR886613 2 0.0000 1.000 0.000 1.000
#> SRR886614 1 0.3879 0.830 0.924 0.076
#> SRR886615 1 0.3879 0.830 0.924 0.076
#> SRR886616 1 0.3879 0.830 0.924 0.076
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.4291 0.850 0.820 0.000 0.180
#> SRR886566 1 0.4291 0.850 0.820 0.000 0.180
#> SRR886567 1 0.4291 0.850 0.820 0.000 0.180
#> SRR886568 1 0.3038 0.877 0.896 0.000 0.104
#> SRR886569 1 0.3038 0.877 0.896 0.000 0.104
#> SRR886570 1 0.3038 0.877 0.896 0.000 0.104
#> SRR886571 1 0.4235 0.852 0.824 0.000 0.176
#> SRR886572 1 0.4235 0.852 0.824 0.000 0.176
#> SRR886573 1 0.4235 0.852 0.824 0.000 0.176
#> SRR886574 1 0.0000 0.884 1.000 0.000 0.000
#> SRR886575 1 0.0000 0.884 1.000 0.000 0.000
#> SRR886576 1 0.0000 0.884 1.000 0.000 0.000
#> SRR886577 1 0.1964 0.882 0.944 0.000 0.056
#> SRR886578 1 0.1964 0.882 0.944 0.000 0.056
#> SRR886579 1 0.1964 0.882 0.944 0.000 0.056
#> SRR886580 1 0.3921 0.877 0.872 0.016 0.112
#> SRR886581 1 0.3921 0.877 0.872 0.016 0.112
#> SRR886582 1 0.3921 0.877 0.872 0.016 0.112
#> SRR886583 1 0.0237 0.885 0.996 0.000 0.004
#> SRR886584 1 0.0237 0.885 0.996 0.000 0.004
#> SRR886585 1 0.0237 0.885 0.996 0.000 0.004
#> SRR886586 1 0.6510 0.848 0.756 0.088 0.156
#> SRR886587 1 0.6510 0.848 0.756 0.088 0.156
#> SRR886588 1 0.6510 0.848 0.756 0.088 0.156
#> SRR886589 1 0.5431 0.841 0.716 0.000 0.284
#> SRR886590 1 0.5431 0.841 0.716 0.000 0.284
#> SRR886591 1 0.5431 0.841 0.716 0.000 0.284
#> SRR886592 1 0.6510 0.848 0.756 0.088 0.156
#> SRR886593 1 0.6510 0.848 0.756 0.088 0.156
#> SRR886594 1 0.6510 0.848 0.756 0.088 0.156
#> SRR886595 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886596 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886597 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886598 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886599 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886600 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886601 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886602 1 0.0237 0.885 0.996 0.000 0.004
#> SRR886603 1 0.0237 0.885 0.996 0.000 0.004
#> SRR886604 1 0.0237 0.885 0.996 0.000 0.004
#> SRR886605 3 0.4062 1.000 0.000 0.164 0.836
#> SRR886606 3 0.4062 1.000 0.000 0.164 0.836
#> SRR886607 3 0.4062 1.000 0.000 0.164 0.836
#> SRR886608 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886609 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886610 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886611 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886612 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886613 2 0.0000 1.000 0.000 1.000 0.000
#> SRR886614 3 0.4062 1.000 0.000 0.164 0.836
#> SRR886615 3 0.4062 1.000 0.000 0.164 0.836
#> SRR886616 3 0.4062 1.000 0.000 0.164 0.836
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886568 1 0.4483 0.6256 0.712 0.000 0.284 0.004
#> SRR886569 1 0.4483 0.6256 0.712 0.000 0.284 0.004
#> SRR886570 1 0.4483 0.6256 0.712 0.000 0.284 0.004
#> SRR886571 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886574 1 0.6392 0.4869 0.528 0.000 0.404 0.068
#> SRR886575 1 0.6392 0.4869 0.528 0.000 0.404 0.068
#> SRR886576 1 0.6392 0.4869 0.528 0.000 0.404 0.068
#> SRR886577 1 0.4925 0.4868 0.572 0.000 0.428 0.000
#> SRR886578 1 0.4941 0.4758 0.564 0.000 0.436 0.000
#> SRR886579 1 0.4941 0.4758 0.564 0.000 0.436 0.000
#> SRR886580 4 0.5110 0.9904 0.328 0.000 0.016 0.656
#> SRR886581 4 0.5110 0.9904 0.328 0.000 0.016 0.656
#> SRR886582 4 0.5110 0.9904 0.328 0.000 0.016 0.656
#> SRR886583 3 0.4761 -0.0997 0.372 0.000 0.628 0.000
#> SRR886584 3 0.4761 -0.0997 0.372 0.000 0.628 0.000
#> SRR886585 3 0.4761 -0.0997 0.372 0.000 0.628 0.000
#> SRR886586 4 0.5224 0.9920 0.316 0.004 0.016 0.664
#> SRR886587 4 0.5224 0.9920 0.316 0.004 0.016 0.664
#> SRR886588 4 0.5224 0.9920 0.316 0.004 0.016 0.664
#> SRR886589 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886590 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886591 1 0.0000 0.6820 1.000 0.000 0.000 0.000
#> SRR886592 4 0.5069 0.9937 0.320 0.000 0.016 0.664
#> SRR886593 4 0.5069 0.9937 0.320 0.000 0.016 0.664
#> SRR886594 4 0.5069 0.9937 0.320 0.000 0.016 0.664
#> SRR886595 2 0.0188 0.9895 0.000 0.996 0.000 0.004
#> SRR886596 2 0.0188 0.9895 0.000 0.996 0.000 0.004
#> SRR886597 2 0.0188 0.9895 0.000 0.996 0.000 0.004
#> SRR886598 2 0.0817 0.9824 0.000 0.976 0.000 0.024
#> SRR886599 2 0.0817 0.9824 0.000 0.976 0.000 0.024
#> SRR886600 2 0.0817 0.9824 0.000 0.976 0.000 0.024
#> SRR886601 2 0.0817 0.9824 0.000 0.976 0.000 0.024
#> SRR886602 3 0.4776 -0.1063 0.376 0.000 0.624 0.000
#> SRR886603 3 0.4776 -0.1063 0.376 0.000 0.624 0.000
#> SRR886604 3 0.4776 -0.1063 0.376 0.000 0.624 0.000
#> SRR886605 3 0.8416 0.4127 0.272 0.020 0.372 0.336
#> SRR886606 3 0.8416 0.4127 0.272 0.020 0.372 0.336
#> SRR886607 3 0.8416 0.4127 0.272 0.020 0.372 0.336
#> SRR886608 2 0.0000 0.9884 0.000 1.000 0.000 0.000
#> SRR886609 2 0.0000 0.9884 0.000 1.000 0.000 0.000
#> SRR886610 2 0.0000 0.9884 0.000 1.000 0.000 0.000
#> SRR886611 2 0.0336 0.9877 0.000 0.992 0.000 0.008
#> SRR886612 2 0.0336 0.9877 0.000 0.992 0.000 0.008
#> SRR886613 2 0.0336 0.9877 0.000 0.992 0.000 0.008
#> SRR886614 3 0.8731 0.4161 0.252 0.040 0.372 0.336
#> SRR886615 3 0.8731 0.4161 0.252 0.040 0.372 0.336
#> SRR886616 3 0.8731 0.4161 0.252 0.040 0.372 0.336
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 3 0.0162 0.873 0.004 0.000 0.996 0.000 0.000
#> SRR886566 3 0.0162 0.873 0.004 0.000 0.996 0.000 0.000
#> SRR886567 3 0.0162 0.873 0.004 0.000 0.996 0.000 0.000
#> SRR886568 3 0.4972 0.464 0.336 0.044 0.620 0.000 0.000
#> SRR886569 3 0.4972 0.464 0.336 0.044 0.620 0.000 0.000
#> SRR886570 3 0.4972 0.464 0.336 0.044 0.620 0.000 0.000
#> SRR886571 3 0.0000 0.872 0.000 0.000 1.000 0.000 0.000
#> SRR886572 3 0.0000 0.872 0.000 0.000 1.000 0.000 0.000
#> SRR886573 3 0.0000 0.872 0.000 0.000 1.000 0.000 0.000
#> SRR886574 1 0.3848 0.817 0.788 0.172 0.040 0.000 0.000
#> SRR886575 1 0.3848 0.817 0.788 0.172 0.040 0.000 0.000
#> SRR886576 1 0.3848 0.817 0.788 0.172 0.040 0.000 0.000
#> SRR886577 1 0.3053 0.809 0.828 0.000 0.164 0.008 0.000
#> SRR886578 1 0.3053 0.809 0.828 0.000 0.164 0.008 0.000
#> SRR886579 1 0.3053 0.809 0.828 0.000 0.164 0.008 0.000
#> SRR886580 2 0.0290 0.988 0.000 0.992 0.008 0.000 0.000
#> SRR886581 2 0.0290 0.988 0.000 0.992 0.008 0.000 0.000
#> SRR886582 2 0.0290 0.988 0.000 0.992 0.008 0.000 0.000
#> SRR886583 1 0.0000 0.888 1.000 0.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.888 1.000 0.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.888 1.000 0.000 0.000 0.000 0.000
#> SRR886586 2 0.0510 0.983 0.000 0.984 0.000 0.000 0.016
#> SRR886587 2 0.0510 0.983 0.000 0.984 0.000 0.000 0.016
#> SRR886588 2 0.0510 0.983 0.000 0.984 0.000 0.000 0.016
#> SRR886589 3 0.0865 0.865 0.004 0.000 0.972 0.024 0.000
#> SRR886590 3 0.0865 0.865 0.004 0.000 0.972 0.024 0.000
#> SRR886591 3 0.0865 0.865 0.004 0.000 0.972 0.024 0.000
#> SRR886592 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR886595 5 0.0290 0.992 0.000 0.008 0.000 0.000 0.992
#> SRR886596 5 0.0290 0.992 0.000 0.008 0.000 0.000 0.992
#> SRR886597 5 0.0290 0.992 0.000 0.008 0.000 0.000 0.992
#> SRR886598 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886599 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886600 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886601 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886602 1 0.0000 0.888 1.000 0.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.888 1.000 0.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.888 1.000 0.000 0.000 0.000 0.000
#> SRR886605 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886606 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886607 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886608 5 0.0404 0.989 0.000 0.000 0.000 0.012 0.988
#> SRR886609 5 0.0404 0.989 0.000 0.000 0.000 0.012 0.988
#> SRR886610 5 0.0404 0.989 0.000 0.000 0.000 0.012 0.988
#> SRR886611 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886612 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886613 5 0.0000 0.995 0.000 0.000 0.000 0.000 1.000
#> SRR886614 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886615 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886616 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0291 0.838 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR886566 1 0.0291 0.838 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR886567 1 0.0291 0.838 0.992 0.000 0.000 0.004 0.000 0.004
#> SRR886568 1 0.5085 0.376 0.584 0.016 0.032 0.356 0.000 0.012
#> SRR886569 1 0.5085 0.376 0.584 0.016 0.032 0.356 0.000 0.012
#> SRR886570 1 0.5085 0.376 0.584 0.016 0.032 0.356 0.000 0.012
#> SRR886571 1 0.1327 0.822 0.936 0.000 0.000 0.000 0.000 0.064
#> SRR886572 1 0.1327 0.822 0.936 0.000 0.000 0.000 0.000 0.064
#> SRR886573 1 0.1327 0.822 0.936 0.000 0.000 0.000 0.000 0.064
#> SRR886574 4 0.3740 0.765 0.008 0.084 0.032 0.824 0.000 0.052
#> SRR886575 4 0.3740 0.765 0.008 0.084 0.032 0.824 0.000 0.052
#> SRR886576 4 0.3740 0.765 0.008 0.084 0.032 0.824 0.000 0.052
#> SRR886577 4 0.2865 0.751 0.140 0.000 0.008 0.840 0.000 0.012
#> SRR886578 4 0.2865 0.751 0.140 0.000 0.008 0.840 0.000 0.012
#> SRR886579 4 0.2865 0.751 0.140 0.000 0.008 0.840 0.000 0.012
#> SRR886580 6 0.3860 1.000 0.000 0.000 0.472 0.000 0.000 0.528
#> SRR886581 6 0.3860 1.000 0.000 0.000 0.472 0.000 0.000 0.528
#> SRR886582 6 0.3860 1.000 0.000 0.000 0.472 0.000 0.000 0.528
#> SRR886583 4 0.0858 0.801 0.004 0.000 0.000 0.968 0.000 0.028
#> SRR886584 4 0.0858 0.801 0.004 0.000 0.000 0.968 0.000 0.028
#> SRR886585 4 0.0858 0.801 0.004 0.000 0.000 0.968 0.000 0.028
#> SRR886586 2 0.4217 0.974 0.000 0.524 0.464 0.000 0.008 0.004
#> SRR886587 2 0.4217 0.974 0.000 0.524 0.464 0.000 0.008 0.004
#> SRR886588 2 0.4217 0.974 0.000 0.524 0.464 0.000 0.008 0.004
#> SRR886589 1 0.1053 0.834 0.964 0.020 0.012 0.000 0.000 0.004
#> SRR886590 1 0.1053 0.834 0.964 0.020 0.012 0.000 0.000 0.004
#> SRR886591 1 0.1053 0.834 0.964 0.020 0.012 0.000 0.000 0.004
#> SRR886592 2 0.4091 0.974 0.000 0.520 0.472 0.000 0.000 0.008
#> SRR886593 2 0.4091 0.974 0.000 0.520 0.472 0.000 0.000 0.008
#> SRR886594 2 0.4091 0.974 0.000 0.520 0.472 0.000 0.000 0.008
#> SRR886595 5 0.0806 0.974 0.000 0.020 0.000 0.000 0.972 0.008
#> SRR886596 5 0.0717 0.974 0.000 0.016 0.000 0.000 0.976 0.008
#> SRR886597 5 0.0806 0.974 0.000 0.020 0.000 0.000 0.972 0.008
#> SRR886598 5 0.0767 0.976 0.004 0.012 0.000 0.000 0.976 0.008
#> SRR886599 5 0.0767 0.976 0.004 0.012 0.000 0.000 0.976 0.008
#> SRR886600 5 0.0862 0.975 0.004 0.016 0.000 0.000 0.972 0.008
#> SRR886601 5 0.1121 0.972 0.004 0.016 0.000 0.008 0.964 0.008
#> SRR886602 4 0.3659 0.641 0.000 0.000 0.000 0.636 0.000 0.364
#> SRR886603 4 0.3659 0.641 0.000 0.000 0.000 0.636 0.000 0.364
#> SRR886604 4 0.3659 0.641 0.000 0.000 0.000 0.636 0.000 0.364
#> SRR886605 3 0.3860 1.000 0.000 0.472 0.528 0.000 0.000 0.000
#> SRR886606 3 0.3860 1.000 0.000 0.472 0.528 0.000 0.000 0.000
#> SRR886607 3 0.3860 1.000 0.000 0.472 0.528 0.000 0.000 0.000
#> SRR886608 5 0.0858 0.967 0.028 0.000 0.004 0.000 0.968 0.000
#> SRR886609 5 0.0858 0.967 0.028 0.000 0.004 0.000 0.968 0.000
#> SRR886610 5 0.0858 0.967 0.028 0.000 0.004 0.000 0.968 0.000
#> SRR886611 5 0.0146 0.978 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR886612 5 0.0146 0.978 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR886613 5 0.0146 0.978 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR886614 3 0.3860 1.000 0.000 0.472 0.528 0.000 0.000 0.000
#> SRR886615 3 0.3860 1.000 0.000 0.472 0.528 0.000 0.000 0.000
#> SRR886616 3 0.3860 1.000 0.000 0.472 0.528 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5095 0.491 0.491
#> 3 3 0.630 0.673 0.842 0.2451 0.801 0.622
#> 4 4 0.794 0.861 0.902 0.1641 0.733 0.401
#> 5 5 0.742 0.735 0.840 0.0814 0.842 0.485
#> 6 6 0.788 0.772 0.846 0.0360 0.937 0.708
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
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.2959 0.933 0.900 0.100 0.000
#> SRR886566 1 0.2878 0.934 0.904 0.096 0.000
#> SRR886567 1 0.3038 0.933 0.896 0.104 0.000
#> SRR886568 1 0.0592 0.932 0.988 0.000 0.012
#> SRR886569 1 0.0983 0.931 0.980 0.004 0.016
#> SRR886570 1 0.1337 0.929 0.972 0.016 0.012
#> SRR886571 1 0.3896 0.926 0.864 0.128 0.008
#> SRR886572 1 0.3896 0.926 0.864 0.128 0.008
#> SRR886573 1 0.3896 0.926 0.864 0.128 0.008
#> SRR886574 1 0.3896 0.926 0.864 0.128 0.008
#> SRR886575 1 0.3896 0.926 0.864 0.128 0.008
#> SRR886576 1 0.3896 0.926 0.864 0.128 0.008
#> SRR886577 1 0.1163 0.929 0.972 0.028 0.000
#> SRR886578 1 0.0892 0.931 0.980 0.020 0.000
#> SRR886579 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886580 2 0.4002 0.811 0.000 0.840 0.160
#> SRR886581 2 0.4002 0.811 0.000 0.840 0.160
#> SRR886582 2 0.4002 0.811 0.000 0.840 0.160
#> SRR886583 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886584 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886585 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886586 2 0.6244 0.457 0.000 0.560 0.440
#> SRR886587 2 0.6260 0.438 0.000 0.552 0.448
#> SRR886588 2 0.6286 0.390 0.000 0.536 0.464
#> SRR886589 1 0.3607 0.930 0.880 0.112 0.008
#> SRR886590 1 0.3607 0.930 0.880 0.112 0.008
#> SRR886591 1 0.3532 0.931 0.884 0.108 0.008
#> SRR886592 2 0.3941 0.810 0.000 0.844 0.156
#> SRR886593 2 0.3941 0.810 0.000 0.844 0.156
#> SRR886594 2 0.3941 0.810 0.000 0.844 0.156
#> SRR886595 3 0.6308 -0.338 0.000 0.492 0.508
#> SRR886596 3 0.6309 -0.350 0.000 0.496 0.504
#> SRR886597 3 0.6302 -0.298 0.000 0.480 0.520
#> SRR886598 3 0.5988 0.119 0.000 0.368 0.632
#> SRR886599 3 0.6008 0.109 0.000 0.372 0.628
#> SRR886600 3 0.6008 0.109 0.000 0.372 0.628
#> SRR886601 3 0.6008 0.109 0.000 0.372 0.628
#> SRR886602 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886603 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886604 1 0.1289 0.928 0.968 0.032 0.000
#> SRR886605 3 0.0424 0.640 0.008 0.000 0.992
#> SRR886606 3 0.0424 0.640 0.008 0.000 0.992
#> SRR886607 3 0.0424 0.640 0.008 0.000 0.992
#> SRR886608 3 0.0424 0.644 0.000 0.008 0.992
#> SRR886609 3 0.0424 0.644 0.000 0.008 0.992
#> SRR886610 3 0.0424 0.644 0.000 0.008 0.992
#> SRR886611 3 0.0424 0.644 0.000 0.008 0.992
#> SRR886612 3 0.0424 0.644 0.000 0.008 0.992
#> SRR886613 3 0.0424 0.644 0.000 0.008 0.992
#> SRR886614 3 0.6217 0.432 0.264 0.024 0.712
#> SRR886615 3 0.6180 0.436 0.260 0.024 0.716
#> SRR886616 3 0.6180 0.436 0.260 0.024 0.716
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 3 0.4776 0.558 0.376 0.000 0.624 0.000
#> SRR886566 3 0.4697 0.592 0.356 0.000 0.644 0.000
#> SRR886567 3 0.4776 0.557 0.376 0.000 0.624 0.000
#> SRR886568 3 0.3168 0.804 0.060 0.000 0.884 0.056
#> SRR886569 3 0.3342 0.773 0.032 0.000 0.868 0.100
#> SRR886570 3 0.3239 0.807 0.068 0.000 0.880 0.052
#> SRR886571 3 0.3024 0.810 0.148 0.000 0.852 0.000
#> SRR886572 3 0.3024 0.810 0.148 0.000 0.852 0.000
#> SRR886573 3 0.3024 0.810 0.148 0.000 0.852 0.000
#> SRR886574 3 0.3123 0.808 0.156 0.000 0.844 0.000
#> SRR886575 3 0.3123 0.808 0.156 0.000 0.844 0.000
#> SRR886576 3 0.3123 0.808 0.156 0.000 0.844 0.000
#> SRR886577 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886578 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886579 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886580 2 0.2174 0.935 0.020 0.928 0.052 0.000
#> SRR886581 2 0.2174 0.935 0.020 0.928 0.052 0.000
#> SRR886582 2 0.2489 0.925 0.020 0.912 0.068 0.000
#> SRR886583 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886584 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886585 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886586 2 0.0895 0.966 0.000 0.976 0.004 0.020
#> SRR886587 2 0.0895 0.966 0.000 0.976 0.004 0.020
#> SRR886588 2 0.1004 0.966 0.000 0.972 0.004 0.024
#> SRR886589 3 0.0336 0.787 0.008 0.000 0.992 0.000
#> SRR886590 3 0.0779 0.792 0.016 0.000 0.980 0.004
#> SRR886591 3 0.0376 0.785 0.004 0.000 0.992 0.004
#> SRR886592 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR886593 2 0.0000 0.962 0.000 1.000 0.000 0.000
#> SRR886594 2 0.0336 0.961 0.000 0.992 0.008 0.000
#> SRR886595 2 0.1004 0.966 0.000 0.972 0.004 0.024
#> SRR886596 2 0.1004 0.966 0.000 0.972 0.004 0.024
#> SRR886597 2 0.1109 0.966 0.000 0.968 0.004 0.028
#> SRR886598 2 0.2198 0.945 0.008 0.920 0.000 0.072
#> SRR886599 2 0.2048 0.950 0.008 0.928 0.000 0.064
#> SRR886600 2 0.1970 0.953 0.008 0.932 0.000 0.060
#> SRR886601 2 0.1970 0.953 0.008 0.932 0.000 0.060
#> SRR886602 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886603 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886604 1 0.0921 1.000 0.972 0.000 0.028 0.000
#> SRR886605 4 0.3569 0.799 0.000 0.000 0.196 0.804
#> SRR886606 4 0.3444 0.816 0.000 0.000 0.184 0.816
#> SRR886607 4 0.3400 0.820 0.000 0.000 0.180 0.820
#> SRR886608 4 0.0188 0.914 0.004 0.000 0.000 0.996
#> SRR886609 4 0.0188 0.914 0.004 0.000 0.000 0.996
#> SRR886610 4 0.0188 0.914 0.004 0.000 0.000 0.996
#> SRR886611 4 0.0469 0.917 0.000 0.000 0.012 0.988
#> SRR886612 4 0.0469 0.917 0.000 0.000 0.012 0.988
#> SRR886613 4 0.0469 0.917 0.000 0.000 0.012 0.988
#> SRR886614 3 0.4761 0.396 0.000 0.000 0.628 0.372
#> SRR886615 3 0.4713 0.425 0.000 0.000 0.640 0.360
#> SRR886616 3 0.4713 0.425 0.000 0.000 0.640 0.360
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.4361 0.7183 0.768 0.000 0.108 0.124 0.000
#> SRR886566 1 0.4255 0.7275 0.776 0.000 0.096 0.128 0.000
#> SRR886567 1 0.4386 0.7071 0.764 0.000 0.096 0.140 0.000
#> SRR886568 3 0.0798 0.7970 0.000 0.000 0.976 0.016 0.008
#> SRR886569 3 0.0992 0.7964 0.000 0.000 0.968 0.024 0.008
#> SRR886570 3 0.0671 0.7962 0.000 0.000 0.980 0.016 0.004
#> SRR886571 4 0.3810 0.8917 0.088 0.000 0.100 0.812 0.000
#> SRR886572 4 0.3865 0.8862 0.100 0.000 0.092 0.808 0.000
#> SRR886573 4 0.3812 0.8901 0.096 0.000 0.092 0.812 0.000
#> SRR886574 3 0.4509 0.5784 0.048 0.000 0.716 0.236 0.000
#> SRR886575 3 0.4536 0.5719 0.048 0.000 0.712 0.240 0.000
#> SRR886576 3 0.4509 0.5784 0.048 0.000 0.716 0.236 0.000
#> SRR886577 1 0.0162 0.9221 0.996 0.000 0.004 0.000 0.000
#> SRR886578 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886580 2 0.3424 0.7864 0.000 0.760 0.000 0.240 0.000
#> SRR886581 2 0.3366 0.7926 0.000 0.768 0.000 0.232 0.000
#> SRR886582 2 0.4015 0.6599 0.000 0.652 0.000 0.348 0.000
#> SRR886583 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886586 2 0.0324 0.8863 0.000 0.992 0.004 0.000 0.004
#> SRR886587 2 0.0324 0.8863 0.000 0.992 0.004 0.000 0.004
#> SRR886588 2 0.0324 0.8863 0.000 0.992 0.004 0.000 0.004
#> SRR886589 4 0.2230 0.8881 0.000 0.000 0.116 0.884 0.000
#> SRR886590 4 0.2471 0.8830 0.000 0.000 0.136 0.864 0.000
#> SRR886591 4 0.2329 0.8873 0.000 0.000 0.124 0.876 0.000
#> SRR886592 2 0.1638 0.8833 0.000 0.932 0.004 0.064 0.000
#> SRR886593 2 0.1638 0.8833 0.000 0.932 0.004 0.064 0.000
#> SRR886594 2 0.1638 0.8833 0.000 0.932 0.004 0.064 0.000
#> SRR886595 2 0.1478 0.8622 0.000 0.936 0.000 0.000 0.064
#> SRR886596 2 0.1043 0.8761 0.000 0.960 0.000 0.000 0.040
#> SRR886597 2 0.1410 0.8651 0.000 0.940 0.000 0.000 0.060
#> SRR886598 5 0.5626 0.0904 0.000 0.420 0.000 0.076 0.504
#> SRR886599 5 0.5584 0.1609 0.000 0.392 0.000 0.076 0.532
#> SRR886600 5 0.5626 0.0881 0.000 0.420 0.000 0.076 0.504
#> SRR886601 5 0.5559 0.1909 0.000 0.380 0.000 0.076 0.544
#> SRR886602 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.9248 1.000 0.000 0.000 0.000 0.000
#> SRR886605 5 0.4756 0.5316 0.000 0.000 0.288 0.044 0.668
#> SRR886606 5 0.4728 0.5253 0.000 0.000 0.296 0.040 0.664
#> SRR886607 5 0.4780 0.5369 0.000 0.000 0.280 0.048 0.672
#> SRR886608 5 0.0162 0.6331 0.000 0.000 0.000 0.004 0.996
#> SRR886609 5 0.0162 0.6331 0.000 0.000 0.000 0.004 0.996
#> SRR886610 5 0.0162 0.6331 0.000 0.000 0.000 0.004 0.996
#> SRR886611 5 0.4459 0.6077 0.000 0.052 0.200 0.004 0.744
#> SRR886612 5 0.4284 0.6070 0.000 0.040 0.204 0.004 0.752
#> SRR886613 5 0.4316 0.6048 0.000 0.040 0.208 0.004 0.748
#> SRR886614 3 0.2249 0.7672 0.000 0.000 0.896 0.008 0.096
#> SRR886615 3 0.2136 0.7717 0.000 0.000 0.904 0.008 0.088
#> SRR886616 3 0.2249 0.7673 0.000 0.000 0.896 0.008 0.096
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 4 0.3729 0.827 0.060 0.000 0.068 0.820 0.000 0.052
#> SRR886566 4 0.3897 0.817 0.072 0.000 0.068 0.808 0.000 0.052
#> SRR886567 4 0.3666 0.831 0.060 0.000 0.068 0.824 0.000 0.048
#> SRR886568 3 0.3627 0.764 0.224 0.004 0.752 0.000 0.000 0.020
#> SRR886569 3 0.3564 0.781 0.204 0.004 0.768 0.000 0.000 0.024
#> SRR886570 3 0.3514 0.781 0.208 0.004 0.768 0.000 0.000 0.020
#> SRR886571 1 0.4765 0.450 0.536 0.000 0.024 0.016 0.000 0.424
#> SRR886572 1 0.4797 0.419 0.500 0.000 0.024 0.016 0.000 0.460
#> SRR886573 1 0.4801 0.404 0.488 0.000 0.024 0.016 0.000 0.472
#> SRR886574 1 0.0146 0.637 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR886575 1 0.0146 0.637 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR886576 1 0.0146 0.637 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR886577 4 0.0881 0.935 0.012 0.000 0.008 0.972 0.000 0.008
#> SRR886578 4 0.0881 0.936 0.012 0.000 0.008 0.972 0.000 0.008
#> SRR886579 4 0.0881 0.935 0.012 0.000 0.008 0.972 0.000 0.008
#> SRR886580 2 0.4573 0.705 0.000 0.672 0.000 0.000 0.084 0.244
#> SRR886581 2 0.4503 0.716 0.000 0.684 0.000 0.000 0.084 0.232
#> SRR886582 2 0.4918 0.618 0.000 0.596 0.000 0.000 0.084 0.320
#> SRR886583 4 0.0260 0.937 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR886584 4 0.0260 0.937 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR886585 4 0.0260 0.937 0.008 0.000 0.000 0.992 0.000 0.000
#> SRR886586 2 0.1462 0.828 0.000 0.936 0.056 0.000 0.008 0.000
#> SRR886587 2 0.1398 0.828 0.000 0.940 0.052 0.000 0.008 0.000
#> SRR886588 2 0.1524 0.826 0.000 0.932 0.060 0.000 0.008 0.000
#> SRR886589 6 0.3065 0.940 0.028 0.000 0.152 0.000 0.000 0.820
#> SRR886590 6 0.3202 0.958 0.024 0.000 0.176 0.000 0.000 0.800
#> SRR886591 6 0.3440 0.940 0.028 0.000 0.196 0.000 0.000 0.776
#> SRR886592 2 0.2361 0.829 0.000 0.884 0.000 0.000 0.088 0.028
#> SRR886593 2 0.2361 0.829 0.000 0.884 0.000 0.000 0.088 0.028
#> SRR886594 2 0.2361 0.829 0.000 0.884 0.000 0.000 0.088 0.028
#> SRR886595 2 0.2653 0.809 0.000 0.868 0.028 0.000 0.100 0.004
#> SRR886596 2 0.2173 0.827 0.000 0.904 0.028 0.000 0.064 0.004
#> SRR886597 2 0.2452 0.819 0.000 0.884 0.028 0.000 0.084 0.004
#> SRR886598 5 0.1168 0.751 0.000 0.028 0.000 0.000 0.956 0.016
#> SRR886599 5 0.1168 0.751 0.000 0.028 0.000 0.000 0.956 0.016
#> SRR886600 5 0.1168 0.751 0.000 0.028 0.000 0.000 0.956 0.016
#> SRR886601 5 0.1168 0.751 0.000 0.028 0.000 0.000 0.956 0.016
#> SRR886602 4 0.0000 0.938 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886603 4 0.0000 0.938 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886604 4 0.0000 0.938 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886605 3 0.1719 0.811 0.000 0.000 0.924 0.000 0.016 0.060
#> SRR886606 3 0.1719 0.811 0.000 0.000 0.924 0.000 0.016 0.060
#> SRR886607 3 0.2009 0.804 0.000 0.000 0.908 0.000 0.024 0.068
#> SRR886608 5 0.2218 0.755 0.000 0.000 0.104 0.000 0.884 0.012
#> SRR886609 5 0.2266 0.755 0.000 0.000 0.108 0.000 0.880 0.012
#> SRR886610 5 0.2266 0.755 0.000 0.000 0.108 0.000 0.880 0.012
#> SRR886611 5 0.4532 0.400 0.000 0.032 0.468 0.000 0.500 0.000
#> SRR886612 5 0.4337 0.399 0.000 0.020 0.480 0.000 0.500 0.000
#> SRR886613 5 0.4338 0.387 0.000 0.020 0.488 0.000 0.492 0.000
#> SRR886614 3 0.2333 0.842 0.120 0.000 0.872 0.000 0.004 0.004
#> SRR886615 3 0.2400 0.843 0.116 0.000 0.872 0.000 0.004 0.008
#> SRR886616 3 0.2308 0.842 0.108 0.000 0.880 0.000 0.004 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.978 0.984 0.4647 0.538 0.538
#> 3 3 1.000 0.998 0.998 0.4219 0.801 0.630
#> 4 4 0.939 0.915 0.923 0.0634 0.966 0.900
#> 5 5 0.931 0.866 0.902 0.1254 0.912 0.711
#> 6 6 0.878 0.776 0.829 0.0348 0.946 0.765
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
#> SRR886565 1 0.000 1.000 1.000 0.000
#> SRR886566 1 0.000 1.000 1.000 0.000
#> SRR886567 1 0.000 1.000 1.000 0.000
#> SRR886568 2 0.373 0.948 0.072 0.928
#> SRR886569 2 0.373 0.948 0.072 0.928
#> SRR886570 2 0.373 0.948 0.072 0.928
#> SRR886571 1 0.000 1.000 1.000 0.000
#> SRR886572 1 0.000 1.000 1.000 0.000
#> SRR886573 1 0.000 1.000 1.000 0.000
#> SRR886574 1 0.000 1.000 1.000 0.000
#> SRR886575 1 0.000 1.000 1.000 0.000
#> SRR886576 1 0.000 1.000 1.000 0.000
#> SRR886577 1 0.000 1.000 1.000 0.000
#> SRR886578 1 0.000 1.000 1.000 0.000
#> SRR886579 1 0.000 1.000 1.000 0.000
#> SRR886580 2 0.000 0.975 0.000 1.000
#> SRR886581 2 0.000 0.975 0.000 1.000
#> SRR886582 2 0.000 0.975 0.000 1.000
#> SRR886583 1 0.000 1.000 1.000 0.000
#> SRR886584 1 0.000 1.000 1.000 0.000
#> SRR886585 1 0.000 1.000 1.000 0.000
#> SRR886586 2 0.000 0.975 0.000 1.000
#> SRR886587 2 0.000 0.975 0.000 1.000
#> SRR886588 2 0.000 0.975 0.000 1.000
#> SRR886589 2 0.373 0.948 0.072 0.928
#> SRR886590 2 0.373 0.948 0.072 0.928
#> SRR886591 2 0.373 0.948 0.072 0.928
#> SRR886592 2 0.000 0.975 0.000 1.000
#> SRR886593 2 0.000 0.975 0.000 1.000
#> SRR886594 2 0.000 0.975 0.000 1.000
#> SRR886595 2 0.000 0.975 0.000 1.000
#> SRR886596 2 0.000 0.975 0.000 1.000
#> SRR886597 2 0.000 0.975 0.000 1.000
#> SRR886598 2 0.000 0.975 0.000 1.000
#> SRR886599 2 0.000 0.975 0.000 1.000
#> SRR886600 2 0.000 0.975 0.000 1.000
#> SRR886601 2 0.000 0.975 0.000 1.000
#> SRR886602 1 0.000 1.000 1.000 0.000
#> SRR886603 1 0.000 1.000 1.000 0.000
#> SRR886604 1 0.000 1.000 1.000 0.000
#> SRR886605 2 0.343 0.953 0.064 0.936
#> SRR886606 2 0.343 0.953 0.064 0.936
#> SRR886607 2 0.343 0.953 0.064 0.936
#> SRR886608 2 0.000 0.975 0.000 1.000
#> SRR886609 2 0.000 0.975 0.000 1.000
#> SRR886610 2 0.000 0.975 0.000 1.000
#> SRR886611 2 0.000 0.975 0.000 1.000
#> SRR886612 2 0.000 0.975 0.000 1.000
#> SRR886613 2 0.000 0.975 0.000 1.000
#> SRR886614 2 0.343 0.953 0.064 0.936
#> SRR886615 2 0.343 0.953 0.064 0.936
#> SRR886616 2 0.343 0.953 0.064 0.936
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886566 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886567 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886568 3 0.0424 0.995 0.008 0.000 0.992
#> SRR886569 3 0.0424 0.995 0.008 0.000 0.992
#> SRR886570 3 0.0424 0.995 0.008 0.000 0.992
#> SRR886571 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886572 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886573 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886574 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886575 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886576 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886577 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886578 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886579 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886580 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886581 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886582 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886583 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886584 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886585 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886586 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886587 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886588 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886589 3 0.0424 0.995 0.008 0.000 0.992
#> SRR886590 3 0.0424 0.995 0.008 0.000 0.992
#> SRR886591 3 0.0424 0.995 0.008 0.000 0.992
#> SRR886592 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886593 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886594 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886595 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886596 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886597 2 0.0000 0.998 0.000 1.000 0.000
#> SRR886598 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886599 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886600 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886601 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886602 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886603 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886604 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886605 3 0.0000 0.995 0.000 0.000 1.000
#> SRR886606 3 0.0000 0.995 0.000 0.000 1.000
#> SRR886607 3 0.0000 0.995 0.000 0.000 1.000
#> SRR886608 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886609 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886610 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886611 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886612 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886613 2 0.0237 0.998 0.000 0.996 0.004
#> SRR886614 3 0.0000 0.995 0.000 0.000 1.000
#> SRR886615 3 0.0000 0.995 0.000 0.000 1.000
#> SRR886616 3 0.0000 0.995 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886568 3 0.0336 0.994 0.008 0.000 0.992 0.000
#> SRR886569 3 0.0336 0.994 0.008 0.000 0.992 0.000
#> SRR886570 3 0.0336 0.994 0.008 0.000 0.992 0.000
#> SRR886571 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886574 4 0.4776 1.000 0.376 0.000 0.000 0.624
#> SRR886575 4 0.4776 1.000 0.376 0.000 0.000 0.624
#> SRR886576 4 0.4776 1.000 0.376 0.000 0.000 0.624
#> SRR886577 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.744 1.000 0.000 0.000 0.000
#> SRR886580 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886581 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886582 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886583 1 0.4761 0.671 0.628 0.000 0.000 0.372
#> SRR886584 1 0.4761 0.671 0.628 0.000 0.000 0.372
#> SRR886585 1 0.4761 0.671 0.628 0.000 0.000 0.372
#> SRR886586 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886587 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886588 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886589 3 0.0336 0.994 0.008 0.000 0.992 0.000
#> SRR886590 3 0.0336 0.994 0.008 0.000 0.992 0.000
#> SRR886591 3 0.0336 0.994 0.008 0.000 0.992 0.000
#> SRR886592 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886593 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886594 2 0.0188 0.996 0.000 0.996 0.000 0.004
#> SRR886595 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR886596 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR886597 2 0.0000 0.996 0.000 1.000 0.000 0.000
#> SRR886598 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886599 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886600 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886601 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886602 1 0.4761 0.671 0.628 0.000 0.000 0.372
#> SRR886603 1 0.4761 0.671 0.628 0.000 0.000 0.372
#> SRR886604 1 0.4761 0.671 0.628 0.000 0.000 0.372
#> SRR886605 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886606 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886607 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886608 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886609 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886610 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886611 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886612 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886613 2 0.0188 0.996 0.000 0.996 0.004 0.000
#> SRR886614 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886615 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886616 3 0.0000 0.994 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886566 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886567 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886568 3 0.0290 0.995 0.000 0.000 0.992 0.008 0.000
#> SRR886569 3 0.0290 0.995 0.000 0.000 0.992 0.008 0.000
#> SRR886570 3 0.0290 0.995 0.000 0.000 0.992 0.008 0.000
#> SRR886571 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886572 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886573 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886574 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886575 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886576 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886577 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886578 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886579 1 0.4114 0.742 0.624 0.000 0.000 0.376 0.000
#> SRR886580 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> SRR886583 1 0.0000 0.668 1.000 0.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.668 1.000 0.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.668 1.000 0.000 0.000 0.000 0.000
#> SRR886586 2 0.0963 0.965 0.000 0.964 0.000 0.000 0.036
#> SRR886587 2 0.0963 0.965 0.000 0.964 0.000 0.000 0.036
#> SRR886588 2 0.0963 0.965 0.000 0.964 0.000 0.000 0.036
#> SRR886589 3 0.0290 0.995 0.000 0.000 0.992 0.008 0.000
#> SRR886590 3 0.0290 0.995 0.000 0.000 0.992 0.008 0.000
#> SRR886591 3 0.0290 0.995 0.000 0.000 0.992 0.008 0.000
#> SRR886592 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.983 0.000 1.000 0.000 0.000 0.000
#> SRR886595 5 0.3999 0.551 0.000 0.344 0.000 0.000 0.656
#> SRR886596 5 0.3999 0.551 0.000 0.344 0.000 0.000 0.656
#> SRR886597 5 0.3999 0.551 0.000 0.344 0.000 0.000 0.656
#> SRR886598 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886599 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886600 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886601 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886602 1 0.0000 0.668 1.000 0.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.668 1.000 0.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.668 1.000 0.000 0.000 0.000 0.000
#> SRR886605 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000
#> SRR886606 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000
#> SRR886607 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000
#> SRR886608 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886609 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886610 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886611 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886612 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886613 5 0.0000 0.898 0.000 0.000 0.000 0.000 1.000
#> SRR886614 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.0000 0.995 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886566 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886567 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886568 3 0.026 0.995 0.008 0.000 0.992 0.00 0.000 NA
#> SRR886569 3 0.026 0.995 0.008 0.000 0.992 0.00 0.000 NA
#> SRR886570 3 0.026 0.995 0.008 0.000 0.992 0.00 0.000 NA
#> SRR886571 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886572 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886573 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886574 4 0.575 0.234 0.184 0.000 0.000 0.48 0.000 NA
#> SRR886575 4 0.575 0.234 0.184 0.000 0.000 0.48 0.000 NA
#> SRR886576 4 0.575 0.234 0.184 0.000 0.000 0.48 0.000 NA
#> SRR886577 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886578 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886579 1 0.000 1.000 1.000 0.000 0.000 0.00 0.000 NA
#> SRR886580 2 0.358 0.863 0.000 0.660 0.000 0.00 0.000 NA
#> SRR886581 2 0.358 0.863 0.000 0.660 0.000 0.00 0.000 NA
#> SRR886582 2 0.358 0.863 0.000 0.660 0.000 0.00 0.000 NA
#> SRR886583 4 0.386 0.425 0.480 0.000 0.000 0.52 0.000 NA
#> SRR886584 4 0.386 0.425 0.480 0.000 0.000 0.52 0.000 NA
#> SRR886585 4 0.386 0.425 0.480 0.000 0.000 0.52 0.000 NA
#> SRR886586 2 0.370 0.855 0.000 0.624 0.000 0.00 0.000 NA
#> SRR886587 2 0.370 0.855 0.000 0.624 0.000 0.00 0.000 NA
#> SRR886588 2 0.370 0.855 0.000 0.624 0.000 0.00 0.000 NA
#> SRR886589 3 0.026 0.995 0.008 0.000 0.992 0.00 0.000 NA
#> SRR886590 3 0.026 0.995 0.008 0.000 0.992 0.00 0.000 NA
#> SRR886591 3 0.026 0.995 0.008 0.000 0.992 0.00 0.000 NA
#> SRR886592 2 0.000 0.736 0.000 1.000 0.000 0.00 0.000 NA
#> SRR886593 2 0.000 0.736 0.000 1.000 0.000 0.00 0.000 NA
#> SRR886594 2 0.000 0.736 0.000 1.000 0.000 0.00 0.000 NA
#> SRR886595 5 0.383 0.399 0.000 0.004 0.000 0.00 0.620 NA
#> SRR886596 5 0.383 0.399 0.000 0.004 0.000 0.00 0.620 NA
#> SRR886597 5 0.383 0.399 0.000 0.004 0.000 0.00 0.620 NA
#> SRR886598 5 0.000 0.753 0.000 0.000 0.000 0.00 1.000 NA
#> SRR886599 5 0.000 0.753 0.000 0.000 0.000 0.00 1.000 NA
#> SRR886600 5 0.000 0.753 0.000 0.000 0.000 0.00 1.000 NA
#> SRR886601 5 0.000 0.753 0.000 0.000 0.000 0.00 1.000 NA
#> SRR886602 4 0.386 0.425 0.480 0.000 0.000 0.52 0.000 NA
#> SRR886603 4 0.386 0.425 0.480 0.000 0.000 0.52 0.000 NA
#> SRR886604 4 0.386 0.425 0.480 0.000 0.000 0.52 0.000 NA
#> SRR886605 3 0.000 0.995 0.000 0.000 1.000 0.00 0.000 NA
#> SRR886606 3 0.000 0.995 0.000 0.000 1.000 0.00 0.000 NA
#> SRR886607 3 0.000 0.995 0.000 0.000 1.000 0.00 0.000 NA
#> SRR886608 5 0.335 0.766 0.000 0.000 0.000 0.00 0.712 NA
#> SRR886609 5 0.335 0.766 0.000 0.000 0.000 0.00 0.712 NA
#> SRR886610 5 0.335 0.766 0.000 0.000 0.000 0.00 0.712 NA
#> SRR886611 5 0.335 0.766 0.000 0.000 0.000 0.00 0.712 NA
#> SRR886612 5 0.335 0.766 0.000 0.000 0.000 0.00 0.712 NA
#> SRR886613 5 0.335 0.766 0.000 0.000 0.000 0.00 0.712 NA
#> SRR886614 3 0.000 0.995 0.000 0.000 1.000 0.00 0.000 NA
#> SRR886615 3 0.000 0.995 0.000 0.000 1.000 0.00 0.000 NA
#> SRR886616 3 0.000 0.995 0.000 0.000 1.000 0.00 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.983 0.985 0.5046 0.491 0.491
#> 3 3 0.577 0.634 0.776 0.2560 0.889 0.777
#> 4 4 0.561 0.428 0.654 0.1243 0.853 0.651
#> 5 5 0.597 0.665 0.742 0.0699 0.819 0.506
#> 6 6 0.625 0.506 0.665 0.0485 0.966 0.865
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
#> SRR886565 1 0.000 0.985 1.000 0.000
#> SRR886566 1 0.000 0.985 1.000 0.000
#> SRR886567 1 0.000 0.985 1.000 0.000
#> SRR886568 1 0.000 0.985 1.000 0.000
#> SRR886569 1 0.000 0.985 1.000 0.000
#> SRR886570 1 0.000 0.985 1.000 0.000
#> SRR886571 1 0.000 0.985 1.000 0.000
#> SRR886572 1 0.000 0.985 1.000 0.000
#> SRR886573 1 0.000 0.985 1.000 0.000
#> SRR886574 1 0.118 0.973 0.984 0.016
#> SRR886575 1 0.118 0.973 0.984 0.016
#> SRR886576 1 0.118 0.973 0.984 0.016
#> SRR886577 1 0.000 0.985 1.000 0.000
#> SRR886578 1 0.000 0.985 1.000 0.000
#> SRR886579 1 0.000 0.985 1.000 0.000
#> SRR886580 2 0.118 0.997 0.016 0.984
#> SRR886581 2 0.118 0.997 0.016 0.984
#> SRR886582 2 0.118 0.997 0.016 0.984
#> SRR886583 1 0.000 0.985 1.000 0.000
#> SRR886584 1 0.000 0.985 1.000 0.000
#> SRR886585 1 0.000 0.985 1.000 0.000
#> SRR886586 2 0.118 0.997 0.016 0.984
#> SRR886587 2 0.118 0.997 0.016 0.984
#> SRR886588 2 0.118 0.997 0.016 0.984
#> SRR886589 1 0.000 0.985 1.000 0.000
#> SRR886590 1 0.000 0.985 1.000 0.000
#> SRR886591 1 0.000 0.985 1.000 0.000
#> SRR886592 2 0.000 0.984 0.000 1.000
#> SRR886593 2 0.000 0.984 0.000 1.000
#> SRR886594 2 0.000 0.984 0.000 1.000
#> SRR886595 2 0.118 0.997 0.016 0.984
#> SRR886596 2 0.118 0.997 0.016 0.984
#> SRR886597 2 0.118 0.997 0.016 0.984
#> SRR886598 2 0.118 0.997 0.016 0.984
#> SRR886599 2 0.118 0.997 0.016 0.984
#> SRR886600 2 0.118 0.997 0.016 0.984
#> SRR886601 2 0.118 0.997 0.016 0.984
#> SRR886602 1 0.000 0.985 1.000 0.000
#> SRR886603 1 0.000 0.985 1.000 0.000
#> SRR886604 1 0.000 0.985 1.000 0.000
#> SRR886605 2 0.163 0.991 0.024 0.976
#> SRR886606 2 0.163 0.991 0.024 0.976
#> SRR886607 2 0.163 0.991 0.024 0.976
#> SRR886608 2 0.118 0.997 0.016 0.984
#> SRR886609 2 0.118 0.997 0.016 0.984
#> SRR886610 2 0.118 0.997 0.016 0.984
#> SRR886611 2 0.118 0.997 0.016 0.984
#> SRR886612 2 0.118 0.997 0.016 0.984
#> SRR886613 2 0.118 0.997 0.016 0.984
#> SRR886614 1 0.506 0.881 0.888 0.112
#> SRR886615 1 0.506 0.881 0.888 0.112
#> SRR886616 1 0.506 0.881 0.888 0.112
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0237 0.779 0.996 0.000 0.004
#> SRR886566 1 0.0237 0.779 0.996 0.000 0.004
#> SRR886567 1 0.0237 0.779 0.996 0.000 0.004
#> SRR886568 1 0.6735 0.169 0.564 0.012 0.424
#> SRR886569 1 0.6735 0.169 0.564 0.012 0.424
#> SRR886570 1 0.6735 0.169 0.564 0.012 0.424
#> SRR886571 1 0.0592 0.779 0.988 0.000 0.012
#> SRR886572 1 0.0592 0.779 0.988 0.000 0.012
#> SRR886573 1 0.0592 0.779 0.988 0.000 0.012
#> SRR886574 1 0.4062 0.703 0.836 0.000 0.164
#> SRR886575 1 0.4062 0.703 0.836 0.000 0.164
#> SRR886576 1 0.4062 0.703 0.836 0.000 0.164
#> SRR886577 1 0.0424 0.779 0.992 0.000 0.008
#> SRR886578 1 0.0424 0.779 0.992 0.000 0.008
#> SRR886579 1 0.0424 0.779 0.992 0.000 0.008
#> SRR886580 2 0.2066 0.764 0.000 0.940 0.060
#> SRR886581 2 0.2066 0.764 0.000 0.940 0.060
#> SRR886582 2 0.2066 0.764 0.000 0.940 0.060
#> SRR886583 1 0.3340 0.747 0.880 0.000 0.120
#> SRR886584 1 0.3340 0.747 0.880 0.000 0.120
#> SRR886585 1 0.3340 0.747 0.880 0.000 0.120
#> SRR886586 2 0.0747 0.788 0.000 0.984 0.016
#> SRR886587 2 0.0747 0.788 0.000 0.984 0.016
#> SRR886588 2 0.0747 0.788 0.000 0.984 0.016
#> SRR886589 1 0.6632 0.150 0.596 0.012 0.392
#> SRR886590 1 0.6632 0.150 0.596 0.012 0.392
#> SRR886591 1 0.6632 0.150 0.596 0.012 0.392
#> SRR886592 2 0.3116 0.746 0.000 0.892 0.108
#> SRR886593 2 0.3116 0.746 0.000 0.892 0.108
#> SRR886594 2 0.3116 0.746 0.000 0.892 0.108
#> SRR886595 2 0.3038 0.796 0.000 0.896 0.104
#> SRR886596 2 0.3038 0.796 0.000 0.896 0.104
#> SRR886597 2 0.3038 0.796 0.000 0.896 0.104
#> SRR886598 2 0.4399 0.777 0.000 0.812 0.188
#> SRR886599 2 0.4399 0.777 0.000 0.812 0.188
#> SRR886600 2 0.4399 0.777 0.000 0.812 0.188
#> SRR886601 2 0.4399 0.777 0.000 0.812 0.188
#> SRR886602 1 0.3267 0.747 0.884 0.000 0.116
#> SRR886603 1 0.3267 0.747 0.884 0.000 0.116
#> SRR886604 1 0.3267 0.747 0.884 0.000 0.116
#> SRR886605 3 0.7218 0.445 0.052 0.296 0.652
#> SRR886606 3 0.7218 0.445 0.052 0.296 0.652
#> SRR886607 3 0.7218 0.445 0.052 0.296 0.652
#> SRR886608 2 0.6215 0.500 0.000 0.572 0.428
#> SRR886609 2 0.6215 0.500 0.000 0.572 0.428
#> SRR886610 2 0.6215 0.500 0.000 0.572 0.428
#> SRR886611 2 0.5785 0.667 0.000 0.668 0.332
#> SRR886612 2 0.5785 0.667 0.000 0.668 0.332
#> SRR886613 2 0.5785 0.667 0.000 0.668 0.332
#> SRR886614 3 0.7337 0.402 0.428 0.032 0.540
#> SRR886615 3 0.7337 0.402 0.428 0.032 0.540
#> SRR886616 3 0.7337 0.402 0.428 0.032 0.540
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.1389 0.6678 0.952 0.000 0.000 0.048
#> SRR886566 1 0.1389 0.6678 0.952 0.000 0.000 0.048
#> SRR886567 1 0.1389 0.6678 0.952 0.000 0.000 0.048
#> SRR886568 4 0.7842 1.0000 0.360 0.000 0.264 0.376
#> SRR886569 4 0.7842 1.0000 0.360 0.000 0.264 0.376
#> SRR886570 4 0.7842 1.0000 0.360 0.000 0.264 0.376
#> SRR886571 1 0.1940 0.6692 0.924 0.000 0.000 0.076
#> SRR886572 1 0.1940 0.6692 0.924 0.000 0.000 0.076
#> SRR886573 1 0.1940 0.6692 0.924 0.000 0.000 0.076
#> SRR886574 1 0.4793 0.5810 0.756 0.000 0.040 0.204
#> SRR886575 1 0.4793 0.5810 0.756 0.000 0.040 0.204
#> SRR886576 1 0.4793 0.5810 0.756 0.000 0.040 0.204
#> SRR886577 1 0.0592 0.6739 0.984 0.000 0.000 0.016
#> SRR886578 1 0.0592 0.6739 0.984 0.000 0.000 0.016
#> SRR886579 1 0.0592 0.6739 0.984 0.000 0.000 0.016
#> SRR886580 2 0.1389 0.7182 0.000 0.952 0.000 0.048
#> SRR886581 2 0.1389 0.7182 0.000 0.952 0.000 0.048
#> SRR886582 2 0.1389 0.7182 0.000 0.952 0.000 0.048
#> SRR886583 1 0.4193 0.6248 0.732 0.000 0.000 0.268
#> SRR886584 1 0.4193 0.6248 0.732 0.000 0.000 0.268
#> SRR886585 1 0.4193 0.6248 0.732 0.000 0.000 0.268
#> SRR886586 2 0.2915 0.7343 0.000 0.892 0.080 0.028
#> SRR886587 2 0.2915 0.7343 0.000 0.892 0.080 0.028
#> SRR886588 2 0.2915 0.7343 0.000 0.892 0.080 0.028
#> SRR886589 1 0.7900 -0.9223 0.368 0.000 0.300 0.332
#> SRR886590 1 0.7900 -0.9223 0.368 0.000 0.300 0.332
#> SRR886591 1 0.7900 -0.9223 0.368 0.000 0.300 0.332
#> SRR886592 2 0.3099 0.6852 0.000 0.876 0.020 0.104
#> SRR886593 2 0.3099 0.6852 0.000 0.876 0.020 0.104
#> SRR886594 2 0.3099 0.6852 0.000 0.876 0.020 0.104
#> SRR886595 2 0.5590 0.6706 0.000 0.692 0.244 0.064
#> SRR886596 2 0.5590 0.6706 0.000 0.692 0.244 0.064
#> SRR886597 2 0.5590 0.6706 0.000 0.692 0.244 0.064
#> SRR886598 2 0.6201 0.5407 0.000 0.564 0.376 0.060
#> SRR886599 2 0.6201 0.5407 0.000 0.564 0.376 0.060
#> SRR886600 2 0.6201 0.5407 0.000 0.564 0.376 0.060
#> SRR886601 2 0.6201 0.5407 0.000 0.564 0.376 0.060
#> SRR886602 1 0.4535 0.6165 0.744 0.000 0.016 0.240
#> SRR886603 1 0.4535 0.6165 0.744 0.000 0.016 0.240
#> SRR886604 1 0.4535 0.6165 0.744 0.000 0.016 0.240
#> SRR886605 3 0.6376 0.1823 0.028 0.064 0.672 0.236
#> SRR886606 3 0.6376 0.1823 0.028 0.064 0.672 0.236
#> SRR886607 3 0.6376 0.1823 0.028 0.064 0.672 0.236
#> SRR886608 3 0.4647 0.2277 0.000 0.288 0.704 0.008
#> SRR886609 3 0.4647 0.2277 0.000 0.288 0.704 0.008
#> SRR886610 3 0.4647 0.2277 0.000 0.288 0.704 0.008
#> SRR886611 3 0.5070 -0.0143 0.000 0.372 0.620 0.008
#> SRR886612 3 0.5070 -0.0143 0.000 0.372 0.620 0.008
#> SRR886613 3 0.5070 -0.0143 0.000 0.372 0.620 0.008
#> SRR886614 3 0.7513 -0.4202 0.188 0.004 0.508 0.300
#> SRR886615 3 0.7513 -0.4202 0.188 0.004 0.508 0.300
#> SRR886616 3 0.7513 -0.4202 0.188 0.004 0.508 0.300
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.546 0.715 0.524 0.000 0.052 NA 0.004
#> SRR886566 1 0.546 0.715 0.524 0.000 0.052 NA 0.004
#> SRR886567 1 0.546 0.715 0.524 0.000 0.052 NA 0.004
#> SRR886568 3 0.680 0.648 0.116 0.008 0.564 NA 0.040
#> SRR886569 3 0.680 0.648 0.116 0.008 0.564 NA 0.040
#> SRR886570 3 0.680 0.648 0.116 0.008 0.564 NA 0.040
#> SRR886571 1 0.567 0.751 0.580 0.000 0.040 NA 0.028
#> SRR886572 1 0.567 0.751 0.580 0.000 0.040 NA 0.028
#> SRR886573 1 0.567 0.751 0.580 0.000 0.040 NA 0.028
#> SRR886574 1 0.665 0.636 0.432 0.000 0.024 NA 0.120
#> SRR886575 1 0.662 0.636 0.432 0.000 0.024 NA 0.116
#> SRR886576 1 0.682 0.637 0.432 0.004 0.024 NA 0.124
#> SRR886577 1 0.534 0.758 0.616 0.000 0.040 NA 0.016
#> SRR886578 1 0.534 0.758 0.616 0.000 0.040 NA 0.016
#> SRR886579 1 0.534 0.758 0.616 0.000 0.040 NA 0.016
#> SRR886580 2 0.379 0.767 0.000 0.832 0.016 NA 0.072
#> SRR886581 2 0.379 0.767 0.000 0.832 0.016 NA 0.072
#> SRR886582 2 0.379 0.767 0.000 0.832 0.016 NA 0.072
#> SRR886583 1 0.000 0.682 1.000 0.000 0.000 NA 0.000
#> SRR886584 1 0.000 0.682 1.000 0.000 0.000 NA 0.000
#> SRR886585 1 0.000 0.682 1.000 0.000 0.000 NA 0.000
#> SRR886586 2 0.440 0.657 0.000 0.772 0.012 NA 0.160
#> SRR886587 2 0.440 0.657 0.000 0.772 0.012 NA 0.160
#> SRR886588 2 0.440 0.657 0.000 0.772 0.012 NA 0.160
#> SRR886589 3 0.558 0.726 0.096 0.000 0.680 NA 0.024
#> SRR886590 3 0.558 0.726 0.096 0.000 0.680 NA 0.024
#> SRR886591 3 0.558 0.726 0.096 0.000 0.680 NA 0.024
#> SRR886592 2 0.111 0.787 0.000 0.964 0.012 NA 0.000
#> SRR886593 2 0.111 0.787 0.000 0.964 0.012 NA 0.000
#> SRR886594 2 0.111 0.787 0.000 0.964 0.012 NA 0.000
#> SRR886595 5 0.569 0.319 0.000 0.428 0.008 NA 0.504
#> SRR886596 5 0.569 0.319 0.000 0.428 0.008 NA 0.504
#> SRR886597 5 0.569 0.319 0.000 0.428 0.008 NA 0.504
#> SRR886598 5 0.451 0.597 0.000 0.296 0.000 NA 0.676
#> SRR886599 5 0.451 0.597 0.000 0.296 0.000 NA 0.676
#> SRR886600 5 0.451 0.597 0.000 0.296 0.000 NA 0.676
#> SRR886601 5 0.451 0.597 0.000 0.296 0.000 NA 0.676
#> SRR886602 1 0.245 0.666 0.900 0.000 0.000 NA 0.048
#> SRR886603 1 0.245 0.666 0.900 0.000 0.000 NA 0.048
#> SRR886604 1 0.245 0.666 0.900 0.000 0.000 NA 0.048
#> SRR886605 3 0.288 0.675 0.000 0.008 0.876 NA 0.092
#> SRR886606 3 0.288 0.675 0.000 0.008 0.876 NA 0.092
#> SRR886607 3 0.288 0.675 0.000 0.008 0.876 NA 0.092
#> SRR886608 5 0.729 0.560 0.000 0.172 0.236 NA 0.520
#> SRR886609 5 0.729 0.560 0.000 0.172 0.236 NA 0.520
#> SRR886610 5 0.729 0.560 0.000 0.172 0.236 NA 0.520
#> SRR886611 5 0.648 0.630 0.000 0.216 0.128 NA 0.608
#> SRR886612 5 0.648 0.630 0.000 0.216 0.128 NA 0.608
#> SRR886613 5 0.648 0.630 0.000 0.216 0.128 NA 0.608
#> SRR886614 3 0.200 0.756 0.040 0.004 0.932 NA 0.016
#> SRR886615 3 0.200 0.756 0.040 0.004 0.932 NA 0.016
#> SRR886616 3 0.200 0.756 0.040 0.004 0.932 NA 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.195 0.453 0.924 0.000 0.048 0.012 0.008 NA
#> SRR886566 1 0.195 0.453 0.924 0.000 0.048 0.012 0.008 NA
#> SRR886567 1 0.195 0.453 0.924 0.000 0.048 0.012 0.008 NA
#> SRR886568 3 0.557 0.618 0.208 0.008 0.656 0.036 0.004 NA
#> SRR886569 3 0.557 0.618 0.208 0.008 0.656 0.036 0.004 NA
#> SRR886570 3 0.557 0.618 0.208 0.008 0.656 0.036 0.004 NA
#> SRR886571 1 0.344 0.443 0.832 0.000 0.008 0.056 0.008 NA
#> SRR886572 1 0.344 0.443 0.832 0.000 0.008 0.056 0.008 NA
#> SRR886573 1 0.344 0.443 0.832 0.000 0.008 0.056 0.008 NA
#> SRR886574 1 0.597 0.294 0.480 0.000 0.020 0.136 0.000 NA
#> SRR886575 1 0.595 0.294 0.480 0.000 0.020 0.132 0.000 NA
#> SRR886576 1 0.611 0.293 0.480 0.000 0.020 0.140 0.004 NA
#> SRR886577 1 0.216 0.418 0.908 0.000 0.008 0.056 0.000 NA
#> SRR886578 1 0.216 0.418 0.908 0.000 0.008 0.056 0.000 NA
#> SRR886579 1 0.216 0.418 0.908 0.000 0.008 0.056 0.000 NA
#> SRR886580 2 0.410 0.749 0.000 0.784 0.004 0.132 0.052 NA
#> SRR886581 2 0.410 0.749 0.000 0.784 0.004 0.132 0.052 NA
#> SRR886582 2 0.420 0.749 0.000 0.784 0.008 0.124 0.052 NA
#> SRR886583 4 0.400 1.000 0.488 0.000 0.000 0.508 0.000 NA
#> SRR886584 4 0.400 1.000 0.488 0.000 0.000 0.508 0.000 NA
#> SRR886585 4 0.400 1.000 0.488 0.000 0.000 0.508 0.000 NA
#> SRR886586 2 0.441 0.654 0.000 0.756 0.000 0.044 0.144 NA
#> SRR886587 2 0.441 0.654 0.000 0.756 0.000 0.044 0.144 NA
#> SRR886588 2 0.441 0.654 0.000 0.756 0.000 0.044 0.144 NA
#> SRR886589 3 0.296 0.706 0.160 0.000 0.824 0.008 0.008 NA
#> SRR886590 3 0.296 0.706 0.160 0.000 0.824 0.008 0.008 NA
#> SRR886591 3 0.296 0.706 0.160 0.000 0.824 0.008 0.008 NA
#> SRR886592 2 0.206 0.756 0.000 0.916 0.008 0.016 0.004 NA
#> SRR886593 2 0.206 0.756 0.000 0.916 0.008 0.016 0.004 NA
#> SRR886594 2 0.207 0.756 0.000 0.916 0.012 0.012 0.004 NA
#> SRR886595 5 0.596 0.174 0.000 0.420 0.004 0.088 0.456 NA
#> SRR886596 5 0.596 0.174 0.000 0.420 0.004 0.088 0.456 NA
#> SRR886597 5 0.596 0.174 0.000 0.420 0.004 0.088 0.456 NA
#> SRR886598 5 0.288 0.568 0.000 0.212 0.000 0.000 0.788 NA
#> SRR886599 5 0.288 0.568 0.000 0.212 0.000 0.000 0.788 NA
#> SRR886600 5 0.288 0.568 0.000 0.212 0.000 0.000 0.788 NA
#> SRR886601 5 0.288 0.568 0.000 0.212 0.000 0.000 0.788 NA
#> SRR886602 1 0.550 -0.773 0.472 0.000 0.008 0.448 0.052 NA
#> SRR886603 1 0.550 -0.773 0.472 0.000 0.008 0.448 0.052 NA
#> SRR886604 1 0.550 -0.773 0.472 0.000 0.008 0.448 0.052 NA
#> SRR886605 3 0.517 0.665 0.000 0.000 0.668 0.028 0.104 NA
#> SRR886606 3 0.517 0.665 0.000 0.000 0.668 0.028 0.104 NA
#> SRR886607 3 0.517 0.665 0.000 0.000 0.668 0.028 0.104 NA
#> SRR886608 5 0.679 0.538 0.000 0.116 0.124 0.000 0.480 NA
#> SRR886609 5 0.679 0.538 0.000 0.116 0.124 0.000 0.480 NA
#> SRR886610 5 0.679 0.538 0.000 0.116 0.124 0.000 0.480 NA
#> SRR886611 5 0.622 0.602 0.000 0.152 0.044 0.020 0.604 NA
#> SRR886612 5 0.622 0.602 0.000 0.152 0.044 0.020 0.604 NA
#> SRR886613 5 0.622 0.602 0.000 0.152 0.044 0.020 0.604 NA
#> SRR886614 3 0.482 0.724 0.028 0.000 0.740 0.052 0.028 NA
#> SRR886615 3 0.482 0.724 0.028 0.000 0.740 0.052 0.028 NA
#> SRR886616 3 0.482 0.724 0.028 0.000 0.740 0.052 0.028 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 3.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5095 0.491 0.491
#> 3 3 1.000 0.957 0.974 0.2426 0.842 0.686
#> 4 4 0.809 0.849 0.902 0.1291 0.910 0.748
#> 5 5 0.883 0.844 0.909 0.0771 0.916 0.713
#> 6 6 0.885 0.882 0.893 0.0348 0.986 0.941
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 3
#> attr(,"optional")
#> [1] 2
There is also optional best \(k\) = 2 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886566 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886567 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886568 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886569 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886570 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886571 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886572 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886573 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886574 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886575 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886576 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886577 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886578 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886579 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886580 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886581 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886582 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886583 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886584 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886585 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886586 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886587 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886588 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886589 3 0.5529 0.691 0.296 0.000 0.704
#> SRR886590 3 0.5529 0.691 0.296 0.000 0.704
#> SRR886591 3 0.5529 0.691 0.296 0.000 0.704
#> SRR886592 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886593 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886594 2 0.0237 0.982 0.000 0.996 0.004
#> SRR886595 2 0.0000 0.982 0.000 1.000 0.000
#> SRR886596 2 0.0000 0.982 0.000 1.000 0.000
#> SRR886597 2 0.0000 0.982 0.000 1.000 0.000
#> SRR886598 2 0.0424 0.981 0.000 0.992 0.008
#> SRR886599 2 0.0424 0.981 0.000 0.992 0.008
#> SRR886600 2 0.0424 0.981 0.000 0.992 0.008
#> SRR886601 2 0.0424 0.981 0.000 0.992 0.008
#> SRR886602 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886603 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886604 1 0.0000 1.000 1.000 0.000 0.000
#> SRR886605 3 0.0237 0.878 0.000 0.004 0.996
#> SRR886606 3 0.0237 0.878 0.000 0.004 0.996
#> SRR886607 3 0.0237 0.878 0.000 0.004 0.996
#> SRR886608 2 0.2261 0.949 0.000 0.932 0.068
#> SRR886609 2 0.2261 0.949 0.000 0.932 0.068
#> SRR886610 2 0.2261 0.949 0.000 0.932 0.068
#> SRR886611 2 0.1753 0.962 0.000 0.952 0.048
#> SRR886612 2 0.1753 0.962 0.000 0.952 0.048
#> SRR886613 2 0.1753 0.962 0.000 0.952 0.048
#> SRR886614 3 0.0592 0.882 0.012 0.000 0.988
#> SRR886615 3 0.0592 0.882 0.012 0.000 0.988
#> SRR886616 3 0.0592 0.882 0.012 0.000 0.988
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886568 1 0.3306 0.8417 0.840 0.000 0.004 0.156
#> SRR886569 1 0.3306 0.8417 0.840 0.000 0.004 0.156
#> SRR886570 1 0.3306 0.8417 0.840 0.000 0.004 0.156
#> SRR886571 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886574 1 0.0336 0.9684 0.992 0.000 0.000 0.008
#> SRR886575 1 0.0336 0.9684 0.992 0.000 0.000 0.008
#> SRR886576 1 0.0336 0.9684 0.992 0.000 0.000 0.008
#> SRR886577 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.9714 1.000 0.000 0.000 0.000
#> SRR886580 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886581 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886582 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886583 1 0.0524 0.9686 0.988 0.000 0.004 0.008
#> SRR886584 1 0.0524 0.9686 0.988 0.000 0.004 0.008
#> SRR886585 1 0.0524 0.9686 0.988 0.000 0.004 0.008
#> SRR886586 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886587 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886588 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886589 3 0.6448 0.6632 0.252 0.000 0.628 0.120
#> SRR886590 3 0.6448 0.6632 0.252 0.000 0.628 0.120
#> SRR886591 3 0.6448 0.6632 0.252 0.000 0.628 0.120
#> SRR886592 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886593 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886594 2 0.0000 0.8333 0.000 1.000 0.000 0.000
#> SRR886595 2 0.4989 -0.0709 0.000 0.528 0.000 0.472
#> SRR886596 2 0.4989 -0.0709 0.000 0.528 0.000 0.472
#> SRR886597 2 0.4989 -0.0709 0.000 0.528 0.000 0.472
#> SRR886598 4 0.3356 0.9800 0.000 0.176 0.000 0.824
#> SRR886599 4 0.3356 0.9800 0.000 0.176 0.000 0.824
#> SRR886600 4 0.3356 0.9800 0.000 0.176 0.000 0.824
#> SRR886601 4 0.3356 0.9800 0.000 0.176 0.000 0.824
#> SRR886602 1 0.0524 0.9686 0.988 0.000 0.004 0.008
#> SRR886603 1 0.0524 0.9686 0.988 0.000 0.004 0.008
#> SRR886604 1 0.0524 0.9686 0.988 0.000 0.004 0.008
#> SRR886605 3 0.0469 0.8454 0.000 0.000 0.988 0.012
#> SRR886606 3 0.0469 0.8454 0.000 0.000 0.988 0.012
#> SRR886607 3 0.0469 0.8454 0.000 0.000 0.988 0.012
#> SRR886608 4 0.3577 0.9834 0.000 0.156 0.012 0.832
#> SRR886609 4 0.3577 0.9834 0.000 0.156 0.012 0.832
#> SRR886610 4 0.3577 0.9834 0.000 0.156 0.012 0.832
#> SRR886611 4 0.3498 0.9858 0.000 0.160 0.008 0.832
#> SRR886612 4 0.3498 0.9858 0.000 0.160 0.008 0.832
#> SRR886613 4 0.3498 0.9858 0.000 0.160 0.008 0.832
#> SRR886614 3 0.0336 0.8458 0.000 0.000 0.992 0.008
#> SRR886615 3 0.0336 0.8458 0.000 0.000 0.992 0.008
#> SRR886616 3 0.0336 0.8458 0.000 0.000 0.992 0.008
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 0.944 1.000 0.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.944 1.000 0.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.944 1.000 0.000 0.000 0.000 0.000
#> SRR886568 4 0.2424 1.000 0.132 0.000 0.000 0.868 0.000
#> SRR886569 4 0.2424 1.000 0.132 0.000 0.000 0.868 0.000
#> SRR886570 4 0.2424 1.000 0.132 0.000 0.000 0.868 0.000
#> SRR886571 1 0.0162 0.943 0.996 0.000 0.000 0.004 0.000
#> SRR886572 1 0.0162 0.943 0.996 0.000 0.000 0.004 0.000
#> SRR886573 1 0.0162 0.943 0.996 0.000 0.000 0.004 0.000
#> SRR886574 1 0.2377 0.839 0.872 0.000 0.000 0.128 0.000
#> SRR886575 1 0.2377 0.839 0.872 0.000 0.000 0.128 0.000
#> SRR886576 1 0.2377 0.839 0.872 0.000 0.000 0.128 0.000
#> SRR886577 1 0.0000 0.944 1.000 0.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.944 1.000 0.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.944 1.000 0.000 0.000 0.000 0.000
#> SRR886580 2 0.1168 0.989 0.000 0.960 0.000 0.008 0.032
#> SRR886581 2 0.1168 0.989 0.000 0.960 0.000 0.008 0.032
#> SRR886582 2 0.1168 0.989 0.000 0.960 0.000 0.008 0.032
#> SRR886583 1 0.1638 0.925 0.932 0.004 0.000 0.064 0.000
#> SRR886584 1 0.1638 0.925 0.932 0.004 0.000 0.064 0.000
#> SRR886585 1 0.1638 0.925 0.932 0.004 0.000 0.064 0.000
#> SRR886586 2 0.1469 0.985 0.000 0.948 0.000 0.016 0.036
#> SRR886587 2 0.1469 0.985 0.000 0.948 0.000 0.016 0.036
#> SRR886588 2 0.1469 0.985 0.000 0.948 0.000 0.016 0.036
#> SRR886589 3 0.7156 0.223 0.168 0.028 0.436 0.364 0.004
#> SRR886590 3 0.7156 0.223 0.168 0.028 0.436 0.364 0.004
#> SRR886591 3 0.7156 0.223 0.168 0.028 0.436 0.364 0.004
#> SRR886592 2 0.0880 0.990 0.000 0.968 0.000 0.000 0.032
#> SRR886593 2 0.0880 0.990 0.000 0.968 0.000 0.000 0.032
#> SRR886594 2 0.0880 0.990 0.000 0.968 0.000 0.000 0.032
#> SRR886595 5 0.4822 0.498 0.000 0.352 0.000 0.032 0.616
#> SRR886596 5 0.4822 0.498 0.000 0.352 0.000 0.032 0.616
#> SRR886597 5 0.4822 0.498 0.000 0.352 0.000 0.032 0.616
#> SRR886598 5 0.0912 0.879 0.000 0.016 0.000 0.012 0.972
#> SRR886599 5 0.0912 0.879 0.000 0.016 0.000 0.012 0.972
#> SRR886600 5 0.0912 0.879 0.000 0.016 0.000 0.012 0.972
#> SRR886601 5 0.0912 0.879 0.000 0.016 0.000 0.012 0.972
#> SRR886602 1 0.1638 0.925 0.932 0.004 0.000 0.064 0.000
#> SRR886603 1 0.1638 0.925 0.932 0.004 0.000 0.064 0.000
#> SRR886604 1 0.1638 0.925 0.932 0.004 0.000 0.064 0.000
#> SRR886605 3 0.0798 0.750 0.000 0.000 0.976 0.016 0.008
#> SRR886606 3 0.0798 0.750 0.000 0.000 0.976 0.016 0.008
#> SRR886607 3 0.0798 0.750 0.000 0.000 0.976 0.016 0.008
#> SRR886608 5 0.0324 0.877 0.000 0.000 0.004 0.004 0.992
#> SRR886609 5 0.0324 0.877 0.000 0.000 0.004 0.004 0.992
#> SRR886610 5 0.0324 0.877 0.000 0.000 0.004 0.004 0.992
#> SRR886611 5 0.0162 0.879 0.000 0.004 0.000 0.000 0.996
#> SRR886612 5 0.0162 0.879 0.000 0.004 0.000 0.000 0.996
#> SRR886613 5 0.0162 0.879 0.000 0.004 0.000 0.000 0.996
#> SRR886614 3 0.0000 0.753 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.0000 0.753 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.0000 0.753 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.1049 0.891 0.960 0.000 0.000 0.032 0.000 0.008
#> SRR886566 1 0.1049 0.891 0.960 0.000 0.000 0.032 0.000 0.008
#> SRR886567 1 0.1049 0.891 0.960 0.000 0.000 0.032 0.000 0.008
#> SRR886568 6 0.2869 1.000 0.020 0.000 0.000 0.148 0.000 0.832
#> SRR886569 6 0.2869 1.000 0.020 0.000 0.000 0.148 0.000 0.832
#> SRR886570 6 0.2869 1.000 0.020 0.000 0.000 0.148 0.000 0.832
#> SRR886571 1 0.1410 0.888 0.944 0.004 0.000 0.044 0.000 0.008
#> SRR886572 1 0.1410 0.888 0.944 0.004 0.000 0.044 0.000 0.008
#> SRR886573 1 0.1410 0.888 0.944 0.004 0.000 0.044 0.000 0.008
#> SRR886574 1 0.4032 0.754 0.768 0.008 0.000 0.080 0.000 0.144
#> SRR886575 1 0.4032 0.754 0.768 0.008 0.000 0.080 0.000 0.144
#> SRR886576 1 0.4032 0.754 0.768 0.008 0.000 0.080 0.000 0.144
#> SRR886577 1 0.0000 0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.896 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886580 2 0.0748 0.964 0.000 0.976 0.000 0.004 0.016 0.004
#> SRR886581 2 0.0748 0.964 0.000 0.976 0.000 0.004 0.016 0.004
#> SRR886582 2 0.0748 0.964 0.000 0.976 0.000 0.004 0.016 0.004
#> SRR886583 1 0.2649 0.869 0.876 0.004 0.000 0.068 0.000 0.052
#> SRR886584 1 0.2649 0.869 0.876 0.004 0.000 0.068 0.000 0.052
#> SRR886585 1 0.2649 0.869 0.876 0.004 0.000 0.068 0.000 0.052
#> SRR886586 2 0.2277 0.938 0.000 0.908 0.000 0.032 0.032 0.028
#> SRR886587 2 0.2277 0.938 0.000 0.908 0.000 0.032 0.032 0.028
#> SRR886588 2 0.2277 0.938 0.000 0.908 0.000 0.032 0.032 0.028
#> SRR886589 4 0.3608 1.000 0.064 0.000 0.148 0.788 0.000 0.000
#> SRR886590 4 0.3608 1.000 0.064 0.000 0.148 0.788 0.000 0.000
#> SRR886591 4 0.3608 1.000 0.064 0.000 0.148 0.788 0.000 0.000
#> SRR886592 2 0.0508 0.964 0.000 0.984 0.000 0.004 0.012 0.000
#> SRR886593 2 0.0508 0.964 0.000 0.984 0.000 0.004 0.012 0.000
#> SRR886594 2 0.0508 0.964 0.000 0.984 0.000 0.004 0.012 0.000
#> SRR886595 5 0.4915 0.477 0.000 0.316 0.000 0.032 0.620 0.032
#> SRR886596 5 0.4915 0.477 0.000 0.316 0.000 0.032 0.620 0.032
#> SRR886597 5 0.4915 0.477 0.000 0.316 0.000 0.032 0.620 0.032
#> SRR886598 5 0.0000 0.857 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886599 5 0.0000 0.857 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886600 5 0.0000 0.857 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886601 5 0.0000 0.857 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886602 1 0.2705 0.867 0.872 0.004 0.000 0.072 0.000 0.052
#> SRR886603 1 0.2705 0.867 0.872 0.004 0.000 0.072 0.000 0.052
#> SRR886604 1 0.2705 0.867 0.872 0.004 0.000 0.072 0.000 0.052
#> SRR886605 3 0.0000 0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886606 3 0.0000 0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886607 3 0.0000 0.964 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886608 5 0.1575 0.856 0.000 0.000 0.000 0.032 0.936 0.032
#> SRR886609 5 0.1575 0.856 0.000 0.000 0.000 0.032 0.936 0.032
#> SRR886610 5 0.1575 0.856 0.000 0.000 0.000 0.032 0.936 0.032
#> SRR886611 5 0.1334 0.859 0.000 0.000 0.000 0.020 0.948 0.032
#> SRR886612 5 0.1334 0.859 0.000 0.000 0.000 0.020 0.948 0.032
#> SRR886613 5 0.1334 0.859 0.000 0.000 0.000 0.020 0.948 0.032
#> SRR886614 3 0.1265 0.964 0.000 0.000 0.948 0.044 0.000 0.008
#> SRR886615 3 0.1265 0.964 0.000 0.000 0.948 0.044 0.000 0.008
#> SRR886616 3 0.1265 0.964 0.000 0.000 0.948 0.044 0.000 0.008
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.973 0.987 0.5078 0.493 0.493
#> 3 3 0.929 0.957 0.978 0.3014 0.792 0.600
#> 4 4 0.931 0.942 0.972 0.1285 0.912 0.740
#> 5 5 0.865 0.908 0.904 0.0676 0.946 0.784
#> 6 6 0.847 0.856 0.882 0.0394 0.968 0.839
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.00 1.000 1.00 0.00
#> SRR886566 1 0.00 1.000 1.00 0.00
#> SRR886567 1 0.00 1.000 1.00 0.00
#> SRR886568 1 0.00 1.000 1.00 0.00
#> SRR886569 1 0.00 1.000 1.00 0.00
#> SRR886570 1 0.00 1.000 1.00 0.00
#> SRR886571 1 0.00 1.000 1.00 0.00
#> SRR886572 1 0.00 1.000 1.00 0.00
#> SRR886573 1 0.00 1.000 1.00 0.00
#> SRR886574 1 0.00 1.000 1.00 0.00
#> SRR886575 1 0.00 1.000 1.00 0.00
#> SRR886576 1 0.00 1.000 1.00 0.00
#> SRR886577 1 0.00 1.000 1.00 0.00
#> SRR886578 1 0.00 1.000 1.00 0.00
#> SRR886579 1 0.00 1.000 1.00 0.00
#> SRR886580 2 0.00 0.975 0.00 1.00
#> SRR886581 2 0.00 0.975 0.00 1.00
#> SRR886582 2 0.00 0.975 0.00 1.00
#> SRR886583 1 0.00 1.000 1.00 0.00
#> SRR886584 1 0.00 1.000 1.00 0.00
#> SRR886585 1 0.00 1.000 1.00 0.00
#> SRR886586 2 0.00 0.975 0.00 1.00
#> SRR886587 2 0.00 0.975 0.00 1.00
#> SRR886588 2 0.00 0.975 0.00 1.00
#> SRR886589 1 0.00 1.000 1.00 0.00
#> SRR886590 1 0.00 1.000 1.00 0.00
#> SRR886591 1 0.00 1.000 1.00 0.00
#> SRR886592 2 0.00 0.975 0.00 1.00
#> SRR886593 2 0.00 0.975 0.00 1.00
#> SRR886594 2 0.00 0.975 0.00 1.00
#> SRR886595 2 0.00 0.975 0.00 1.00
#> SRR886596 2 0.00 0.975 0.00 1.00
#> SRR886597 2 0.00 0.975 0.00 1.00
#> SRR886598 2 0.00 0.975 0.00 1.00
#> SRR886599 2 0.00 0.975 0.00 1.00
#> SRR886600 2 0.00 0.975 0.00 1.00
#> SRR886601 2 0.00 0.975 0.00 1.00
#> SRR886602 1 0.00 1.000 1.00 0.00
#> SRR886603 1 0.00 1.000 1.00 0.00
#> SRR886604 1 0.00 1.000 1.00 0.00
#> SRR886605 2 0.00 0.975 0.00 1.00
#> SRR886606 2 0.00 0.975 0.00 1.00
#> SRR886607 2 0.00 0.975 0.00 1.00
#> SRR886608 2 0.00 0.975 0.00 1.00
#> SRR886609 2 0.00 0.975 0.00 1.00
#> SRR886610 2 0.00 0.975 0.00 1.00
#> SRR886611 2 0.00 0.975 0.00 1.00
#> SRR886612 2 0.00 0.975 0.00 1.00
#> SRR886613 2 0.00 0.975 0.00 1.00
#> SRR886614 2 0.76 0.739 0.22 0.78
#> SRR886615 2 0.76 0.739 0.22 0.78
#> SRR886616 2 0.76 0.739 0.22 0.78
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.000 1.000 1.000 0.000 0.000
#> SRR886566 1 0.000 1.000 1.000 0.000 0.000
#> SRR886567 1 0.000 1.000 1.000 0.000 0.000
#> SRR886568 3 0.460 0.783 0.204 0.000 0.796
#> SRR886569 3 0.460 0.783 0.204 0.000 0.796
#> SRR886570 3 0.460 0.783 0.204 0.000 0.796
#> SRR886571 1 0.000 1.000 1.000 0.000 0.000
#> SRR886572 1 0.000 1.000 1.000 0.000 0.000
#> SRR886573 1 0.000 1.000 1.000 0.000 0.000
#> SRR886574 1 0.000 1.000 1.000 0.000 0.000
#> SRR886575 1 0.000 1.000 1.000 0.000 0.000
#> SRR886576 1 0.000 1.000 1.000 0.000 0.000
#> SRR886577 1 0.000 1.000 1.000 0.000 0.000
#> SRR886578 1 0.000 1.000 1.000 0.000 0.000
#> SRR886579 1 0.000 1.000 1.000 0.000 0.000
#> SRR886580 2 0.000 0.975 0.000 1.000 0.000
#> SRR886581 2 0.000 0.975 0.000 1.000 0.000
#> SRR886582 2 0.000 0.975 0.000 1.000 0.000
#> SRR886583 1 0.000 1.000 1.000 0.000 0.000
#> SRR886584 1 0.000 1.000 1.000 0.000 0.000
#> SRR886585 1 0.000 1.000 1.000 0.000 0.000
#> SRR886586 2 0.000 0.975 0.000 1.000 0.000
#> SRR886587 2 0.000 0.975 0.000 1.000 0.000
#> SRR886588 2 0.000 0.975 0.000 1.000 0.000
#> SRR886589 3 0.000 0.940 0.000 0.000 1.000
#> SRR886590 3 0.000 0.940 0.000 0.000 1.000
#> SRR886591 3 0.000 0.940 0.000 0.000 1.000
#> SRR886592 2 0.000 0.975 0.000 1.000 0.000
#> SRR886593 2 0.000 0.975 0.000 1.000 0.000
#> SRR886594 2 0.000 0.975 0.000 1.000 0.000
#> SRR886595 2 0.000 0.975 0.000 1.000 0.000
#> SRR886596 2 0.000 0.975 0.000 1.000 0.000
#> SRR886597 2 0.000 0.975 0.000 1.000 0.000
#> SRR886598 2 0.000 0.975 0.000 1.000 0.000
#> SRR886599 2 0.000 0.975 0.000 1.000 0.000
#> SRR886600 2 0.000 0.975 0.000 1.000 0.000
#> SRR886601 2 0.000 0.975 0.000 1.000 0.000
#> SRR886602 1 0.000 1.000 1.000 0.000 0.000
#> SRR886603 1 0.000 1.000 1.000 0.000 0.000
#> SRR886604 1 0.000 1.000 1.000 0.000 0.000
#> SRR886605 3 0.000 0.940 0.000 0.000 1.000
#> SRR886606 3 0.000 0.940 0.000 0.000 1.000
#> SRR886607 3 0.000 0.940 0.000 0.000 1.000
#> SRR886608 2 0.424 0.815 0.000 0.824 0.176
#> SRR886609 2 0.424 0.815 0.000 0.824 0.176
#> SRR886610 2 0.424 0.815 0.000 0.824 0.176
#> SRR886611 2 0.000 0.975 0.000 1.000 0.000
#> SRR886612 2 0.000 0.975 0.000 1.000 0.000
#> SRR886613 2 0.000 0.975 0.000 1.000 0.000
#> SRR886614 3 0.000 0.940 0.000 0.000 1.000
#> SRR886615 3 0.000 0.940 0.000 0.000 1.000
#> SRR886616 3 0.000 0.940 0.000 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886566 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886567 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886568 3 0.365 0.789 0.204 0.000 0.796 0.000
#> SRR886569 3 0.365 0.789 0.204 0.000 0.796 0.000
#> SRR886570 3 0.365 0.789 0.204 0.000 0.796 0.000
#> SRR886571 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886572 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886573 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886574 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886575 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886576 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886577 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886578 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886579 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886580 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886581 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886582 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886583 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886584 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886585 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886586 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886587 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886588 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886589 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886590 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886591 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886592 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886593 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886594 4 0.000 1.000 0.000 0.000 0.000 1.000
#> SRR886595 2 0.419 0.688 0.000 0.732 0.000 0.268
#> SRR886596 2 0.443 0.635 0.000 0.696 0.000 0.304
#> SRR886597 2 0.430 0.666 0.000 0.716 0.000 0.284
#> SRR886598 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886599 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886600 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886601 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886602 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886603 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886604 1 0.000 1.000 1.000 0.000 0.000 0.000
#> SRR886605 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886606 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886607 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886608 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886609 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886610 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886611 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886612 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886613 2 0.000 0.925 0.000 1.000 0.000 0.000
#> SRR886614 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886615 3 0.000 0.932 0.000 0.000 1.000 0.000
#> SRR886616 3 0.000 0.932 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886566 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886567 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886568 3 0.318 0.783 0.208 0.000 0.792 0.000 0.000
#> SRR886569 3 0.318 0.783 0.208 0.000 0.792 0.000 0.000
#> SRR886570 3 0.318 0.783 0.208 0.000 0.792 0.000 0.000
#> SRR886571 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886572 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886573 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886574 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886575 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886576 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886577 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886578 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886579 1 0.375 1.000 0.708 0.000 0.000 0.292 0.000
#> SRR886580 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886581 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886582 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886583 4 0.000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886584 4 0.000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886585 4 0.000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886586 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886587 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886588 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886589 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886590 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886591 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886592 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR886595 5 0.361 0.558 0.000 0.268 0.000 0.000 0.732
#> SRR886596 5 0.382 0.500 0.000 0.304 0.000 0.000 0.696
#> SRR886597 5 0.371 0.535 0.000 0.284 0.000 0.000 0.716
#> SRR886598 5 0.000 0.783 0.000 0.000 0.000 0.000 1.000
#> SRR886599 5 0.000 0.783 0.000 0.000 0.000 0.000 1.000
#> SRR886600 5 0.000 0.783 0.000 0.000 0.000 0.000 1.000
#> SRR886601 5 0.000 0.783 0.000 0.000 0.000 0.000 1.000
#> SRR886602 4 0.000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886603 4 0.000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886604 4 0.000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR886605 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886606 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886607 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886608 5 0.375 0.790 0.292 0.000 0.000 0.000 0.708
#> SRR886609 5 0.375 0.790 0.292 0.000 0.000 0.000 0.708
#> SRR886610 5 0.375 0.790 0.292 0.000 0.000 0.000 0.708
#> SRR886611 5 0.375 0.790 0.292 0.000 0.000 0.000 0.708
#> SRR886612 5 0.375 0.790 0.292 0.000 0.000 0.000 0.708
#> SRR886613 5 0.375 0.790 0.292 0.000 0.000 0.000 0.708
#> SRR886614 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886615 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
#> SRR886616 3 0.000 0.934 0.000 0.000 1.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886566 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886567 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886568 3 0.3934 0.619 0.008 0.000 0.616 0.000 0.000 0.376
#> SRR886569 3 0.3934 0.619 0.008 0.000 0.616 0.000 0.000 0.376
#> SRR886570 3 0.3934 0.619 0.008 0.000 0.616 0.000 0.000 0.376
#> SRR886571 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886572 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886573 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886574 1 0.0000 0.614 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886575 1 0.0000 0.614 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886576 1 0.0000 0.614 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886577 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886578 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886579 1 0.3756 0.888 0.600 0.000 0.000 0.000 0.000 0.400
#> SRR886580 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886583 4 0.1444 0.946 0.072 0.000 0.000 0.928 0.000 0.000
#> SRR886584 4 0.1444 0.946 0.072 0.000 0.000 0.928 0.000 0.000
#> SRR886585 4 0.1387 0.948 0.068 0.000 0.000 0.932 0.000 0.000
#> SRR886586 2 0.0146 0.997 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR886587 2 0.0146 0.997 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR886588 2 0.0146 0.997 0.000 0.996 0.000 0.000 0.004 0.000
#> SRR886589 3 0.2048 0.826 0.000 0.000 0.880 0.000 0.000 0.120
#> SRR886590 3 0.2697 0.800 0.000 0.000 0.812 0.000 0.000 0.188
#> SRR886591 3 0.2562 0.808 0.000 0.000 0.828 0.000 0.000 0.172
#> SRR886592 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.998 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886595 6 0.5348 0.686 0.000 0.272 0.000 0.000 0.152 0.576
#> SRR886596 6 0.5248 0.659 0.000 0.304 0.000 0.000 0.124 0.572
#> SRR886597 6 0.5336 0.680 0.000 0.284 0.000 0.000 0.144 0.572
#> SRR886598 6 0.3756 0.698 0.000 0.000 0.000 0.000 0.400 0.600
#> SRR886599 6 0.3756 0.698 0.000 0.000 0.000 0.000 0.400 0.600
#> SRR886600 6 0.3756 0.698 0.000 0.000 0.000 0.000 0.400 0.600
#> SRR886601 6 0.3756 0.698 0.000 0.000 0.000 0.000 0.400 0.600
#> SRR886602 4 0.0000 0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886603 4 0.0000 0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886604 4 0.0000 0.948 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886605 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886606 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886607 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886608 5 0.0363 0.984 0.000 0.000 0.012 0.000 0.988 0.000
#> SRR886609 5 0.0458 0.978 0.000 0.000 0.016 0.000 0.984 0.000
#> SRR886610 5 0.0260 0.986 0.000 0.000 0.008 0.000 0.992 0.000
#> SRR886611 5 0.0000 0.987 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886612 5 0.0000 0.987 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886613 5 0.0000 0.987 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR886614 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886615 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886616 3 0.0000 0.834 0.000 0.000 1.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.805 0.951 0.957 0.4916 0.502 0.502
#> 3 3 0.630 0.755 0.796 0.2384 0.640 0.448
#> 4 4 0.692 0.696 0.743 0.1542 0.710 0.421
#> 5 5 0.977 0.971 0.983 0.1200 0.941 0.782
#> 6 6 0.916 0.940 0.903 0.0366 0.968 0.849
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 5
There is also optional best \(k\) = 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.000 0.950 1.000 0.000
#> SRR886566 1 0.000 0.950 1.000 0.000
#> SRR886567 1 0.000 0.950 1.000 0.000
#> SRR886568 1 0.278 0.948 0.952 0.048
#> SRR886569 1 0.278 0.948 0.952 0.048
#> SRR886570 1 0.278 0.948 0.952 0.048
#> SRR886571 1 0.000 0.950 1.000 0.000
#> SRR886572 1 0.000 0.950 1.000 0.000
#> SRR886573 1 0.000 0.950 1.000 0.000
#> SRR886574 1 0.163 0.942 0.976 0.024
#> SRR886575 1 0.163 0.942 0.976 0.024
#> SRR886576 1 0.163 0.942 0.976 0.024
#> SRR886577 1 0.000 0.950 1.000 0.000
#> SRR886578 1 0.000 0.950 1.000 0.000
#> SRR886579 1 0.000 0.950 1.000 0.000
#> SRR886580 2 0.204 0.961 0.032 0.968
#> SRR886581 2 0.204 0.961 0.032 0.968
#> SRR886582 2 0.204 0.961 0.032 0.968
#> SRR886583 1 0.518 0.901 0.884 0.116
#> SRR886584 1 0.518 0.901 0.884 0.116
#> SRR886585 1 0.518 0.901 0.884 0.116
#> SRR886586 2 0.204 0.964 0.032 0.968
#> SRR886587 2 0.204 0.964 0.032 0.968
#> SRR886588 2 0.204 0.964 0.032 0.968
#> SRR886589 1 0.278 0.948 0.952 0.048
#> SRR886590 1 0.278 0.948 0.952 0.048
#> SRR886591 1 0.278 0.948 0.952 0.048
#> SRR886592 2 0.204 0.961 0.032 0.968
#> SRR886593 2 0.204 0.961 0.032 0.968
#> SRR886594 2 0.204 0.961 0.032 0.968
#> SRR886595 2 0.242 0.975 0.040 0.960
#> SRR886596 2 0.242 0.975 0.040 0.960
#> SRR886597 2 0.242 0.975 0.040 0.960
#> SRR886598 2 0.242 0.975 0.040 0.960
#> SRR886599 2 0.242 0.975 0.040 0.960
#> SRR886600 2 0.242 0.975 0.040 0.960
#> SRR886601 2 0.242 0.975 0.040 0.960
#> SRR886602 1 0.518 0.901 0.884 0.116
#> SRR886603 1 0.518 0.901 0.884 0.116
#> SRR886604 1 0.518 0.901 0.884 0.116
#> SRR886605 1 0.343 0.940 0.936 0.064
#> SRR886606 1 0.343 0.940 0.936 0.064
#> SRR886607 1 0.343 0.940 0.936 0.064
#> SRR886608 2 0.242 0.975 0.040 0.960
#> SRR886609 2 0.242 0.975 0.040 0.960
#> SRR886610 2 0.242 0.975 0.040 0.960
#> SRR886611 2 0.242 0.975 0.040 0.960
#> SRR886612 2 0.242 0.975 0.040 0.960
#> SRR886613 2 0.242 0.975 0.040 0.960
#> SRR886614 1 0.343 0.940 0.936 0.064
#> SRR886615 1 0.343 0.940 0.936 0.064
#> SRR886616 1 0.343 0.940 0.936 0.064
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 0.965 1.000 0.000 0.000
#> SRR886566 1 0.0000 0.965 1.000 0.000 0.000
#> SRR886567 1 0.0000 0.965 1.000 0.000 0.000
#> SRR886568 1 0.0892 0.961 0.980 0.000 0.020
#> SRR886569 1 0.0892 0.961 0.980 0.000 0.020
#> SRR886570 1 0.0892 0.961 0.980 0.000 0.020
#> SRR886571 1 0.1031 0.956 0.976 0.024 0.000
#> SRR886572 1 0.1031 0.956 0.976 0.024 0.000
#> SRR886573 1 0.1031 0.956 0.976 0.024 0.000
#> SRR886574 2 0.6786 0.341 0.448 0.540 0.012
#> SRR886575 2 0.6786 0.341 0.448 0.540 0.012
#> SRR886576 2 0.6786 0.341 0.448 0.540 0.012
#> SRR886577 1 0.1643 0.943 0.956 0.044 0.000
#> SRR886578 1 0.1643 0.943 0.956 0.044 0.000
#> SRR886579 1 0.1643 0.943 0.956 0.044 0.000
#> SRR886580 2 0.3207 0.661 0.084 0.904 0.012
#> SRR886581 2 0.3207 0.661 0.084 0.904 0.012
#> SRR886582 2 0.3207 0.661 0.084 0.904 0.012
#> SRR886583 2 0.2096 0.660 0.052 0.944 0.004
#> SRR886584 2 0.2096 0.660 0.052 0.944 0.004
#> SRR886585 2 0.2096 0.660 0.052 0.944 0.004
#> SRR886586 2 0.2772 0.678 0.004 0.916 0.080
#> SRR886587 2 0.2772 0.678 0.004 0.916 0.080
#> SRR886588 2 0.2772 0.678 0.004 0.916 0.080
#> SRR886589 1 0.0892 0.961 0.980 0.000 0.020
#> SRR886590 1 0.0892 0.961 0.980 0.000 0.020
#> SRR886591 1 0.0892 0.961 0.980 0.000 0.020
#> SRR886592 2 0.3207 0.661 0.084 0.904 0.012
#> SRR886593 2 0.3207 0.661 0.084 0.904 0.012
#> SRR886594 2 0.3207 0.661 0.084 0.904 0.012
#> SRR886595 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886596 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886597 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886598 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886599 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886600 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886601 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886602 2 0.2096 0.660 0.052 0.944 0.004
#> SRR886603 2 0.2096 0.660 0.052 0.944 0.004
#> SRR886604 2 0.2096 0.660 0.052 0.944 0.004
#> SRR886605 3 0.5016 1.000 0.240 0.000 0.760
#> SRR886606 3 0.5016 1.000 0.240 0.000 0.760
#> SRR886607 3 0.5016 1.000 0.240 0.000 0.760
#> SRR886608 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886609 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886610 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886611 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886612 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886613 2 0.6305 0.609 0.000 0.516 0.484
#> SRR886614 3 0.5016 1.000 0.240 0.000 0.760
#> SRR886615 3 0.5016 1.000 0.240 0.000 0.760
#> SRR886616 3 0.5016 1.000 0.240 0.000 0.760
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886566 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886567 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886568 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886569 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886570 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886571 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886572 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886573 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886574 4 0.3853 0.753 0.020 0.000 0.160 0.820
#> SRR886575 4 0.3853 0.753 0.020 0.000 0.160 0.820
#> SRR886576 4 0.3853 0.753 0.020 0.000 0.160 0.820
#> SRR886577 3 0.0895 0.976 0.020 0.000 0.976 0.004
#> SRR886578 3 0.0895 0.976 0.020 0.000 0.976 0.004
#> SRR886579 3 0.0895 0.976 0.020 0.000 0.976 0.004
#> SRR886580 4 0.0592 0.862 0.000 0.000 0.016 0.984
#> SRR886581 4 0.0592 0.862 0.000 0.000 0.016 0.984
#> SRR886582 4 0.0592 0.862 0.000 0.000 0.016 0.984
#> SRR886583 1 0.4843 1.000 0.604 0.000 0.000 0.396
#> SRR886584 1 0.4843 1.000 0.604 0.000 0.000 0.396
#> SRR886585 1 0.4843 1.000 0.604 0.000 0.000 0.396
#> SRR886586 4 0.2888 0.780 0.000 0.124 0.004 0.872
#> SRR886587 4 0.2888 0.780 0.000 0.124 0.004 0.872
#> SRR886588 4 0.2888 0.780 0.000 0.124 0.004 0.872
#> SRR886589 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886590 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886591 3 0.0000 0.994 0.000 0.000 1.000 0.000
#> SRR886592 4 0.0592 0.862 0.000 0.000 0.016 0.984
#> SRR886593 4 0.0592 0.862 0.000 0.000 0.016 0.984
#> SRR886594 4 0.0592 0.862 0.000 0.000 0.016 0.984
#> SRR886595 2 0.4994 0.356 0.000 0.520 0.000 0.480
#> SRR886596 2 0.4994 0.356 0.000 0.520 0.000 0.480
#> SRR886597 2 0.4994 0.356 0.000 0.520 0.000 0.480
#> SRR886598 2 0.4981 0.383 0.000 0.536 0.000 0.464
#> SRR886599 2 0.4981 0.383 0.000 0.536 0.000 0.464
#> SRR886600 2 0.4981 0.383 0.000 0.536 0.000 0.464
#> SRR886601 2 0.4981 0.383 0.000 0.536 0.000 0.464
#> SRR886602 1 0.4843 1.000 0.604 0.000 0.000 0.396
#> SRR886603 1 0.4843 1.000 0.604 0.000 0.000 0.396
#> SRR886604 1 0.4843 1.000 0.604 0.000 0.000 0.396
#> SRR886605 2 0.7202 0.102 0.396 0.464 0.140 0.000
#> SRR886606 2 0.7202 0.102 0.396 0.464 0.140 0.000
#> SRR886607 2 0.7202 0.102 0.396 0.464 0.140 0.000
#> SRR886608 2 0.4967 0.390 0.000 0.548 0.000 0.452
#> SRR886609 2 0.4967 0.390 0.000 0.548 0.000 0.452
#> SRR886610 2 0.4967 0.390 0.000 0.548 0.000 0.452
#> SRR886611 2 0.5137 0.389 0.004 0.544 0.000 0.452
#> SRR886612 2 0.5137 0.389 0.004 0.544 0.000 0.452
#> SRR886613 2 0.5137 0.389 0.004 0.544 0.000 0.452
#> SRR886614 2 0.7202 0.102 0.396 0.464 0.140 0.000
#> SRR886615 2 0.7202 0.102 0.396 0.464 0.140 0.000
#> SRR886616 2 0.7202 0.102 0.396 0.464 0.140 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886566 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886567 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886568 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886569 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886570 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886571 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886572 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886573 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886574 2 0.2331 0.879 0.08 0.900 0 0.02 0.000
#> SRR886575 2 0.2331 0.879 0.08 0.900 0 0.02 0.000
#> SRR886576 2 0.2331 0.879 0.08 0.900 0 0.02 0.000
#> SRR886577 1 0.0609 0.981 0.98 0.000 0 0.02 0.000
#> SRR886578 1 0.0609 0.981 0.98 0.000 0 0.02 0.000
#> SRR886579 1 0.0609 0.981 0.98 0.000 0 0.02 0.000
#> SRR886580 2 0.0000 0.916 0.00 1.000 0 0.00 0.000
#> SRR886581 2 0.0000 0.916 0.00 1.000 0 0.00 0.000
#> SRR886582 2 0.0000 0.916 0.00 1.000 0 0.00 0.000
#> SRR886583 4 0.0000 1.000 0.00 0.000 0 1.00 0.000
#> SRR886584 4 0.0000 1.000 0.00 0.000 0 1.00 0.000
#> SRR886585 4 0.0000 1.000 0.00 0.000 0 1.00 0.000
#> SRR886586 2 0.2813 0.829 0.00 0.832 0 0.00 0.168
#> SRR886587 2 0.2813 0.829 0.00 0.832 0 0.00 0.168
#> SRR886588 2 0.2813 0.829 0.00 0.832 0 0.00 0.168
#> SRR886589 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886590 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886591 1 0.0000 0.995 1.00 0.000 0 0.00 0.000
#> SRR886592 2 0.0000 0.916 0.00 1.000 0 0.00 0.000
#> SRR886593 2 0.0000 0.916 0.00 1.000 0 0.00 0.000
#> SRR886594 2 0.0000 0.916 0.00 1.000 0 0.00 0.000
#> SRR886595 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886596 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886597 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886598 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886599 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886600 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886601 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886602 4 0.0000 1.000 0.00 0.000 0 1.00 0.000
#> SRR886603 4 0.0000 1.000 0.00 0.000 0 1.00 0.000
#> SRR886604 4 0.0000 1.000 0.00 0.000 0 1.00 0.000
#> SRR886605 3 0.0000 1.000 0.00 0.000 1 0.00 0.000
#> SRR886606 3 0.0000 1.000 0.00 0.000 1 0.00 0.000
#> SRR886607 3 0.0000 1.000 0.00 0.000 1 0.00 0.000
#> SRR886608 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886609 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886610 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886611 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886612 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886613 5 0.0000 1.000 0.00 0.000 0 0.00 1.000
#> SRR886614 3 0.0000 1.000 0.00 0.000 1 0.00 0.000
#> SRR886615 3 0.0000 1.000 0.00 0.000 1 0.00 0.000
#> SRR886616 3 0.0000 1.000 0.00 0.000 1 0.00 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0146 0.979 0.996 0.004 0.000 0.00 0.000 0.000
#> SRR886566 1 0.0146 0.979 0.996 0.004 0.000 0.00 0.000 0.000
#> SRR886567 1 0.0146 0.979 0.996 0.004 0.000 0.00 0.000 0.000
#> SRR886568 1 0.0000 0.979 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR886569 1 0.0000 0.979 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR886570 1 0.0000 0.979 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR886571 1 0.0937 0.971 0.960 0.040 0.000 0.00 0.000 0.000
#> SRR886572 1 0.0937 0.971 0.960 0.040 0.000 0.00 0.000 0.000
#> SRR886573 1 0.0937 0.971 0.960 0.040 0.000 0.00 0.000 0.000
#> SRR886574 2 0.0260 0.620 0.008 0.992 0.000 0.00 0.000 0.000
#> SRR886575 2 0.0260 0.620 0.008 0.992 0.000 0.00 0.000 0.000
#> SRR886576 2 0.0260 0.620 0.008 0.992 0.000 0.00 0.000 0.000
#> SRR886577 1 0.1327 0.960 0.936 0.064 0.000 0.00 0.000 0.000
#> SRR886578 1 0.1327 0.960 0.936 0.064 0.000 0.00 0.000 0.000
#> SRR886579 1 0.1327 0.960 0.936 0.064 0.000 0.00 0.000 0.000
#> SRR886580 2 0.3857 0.848 0.000 0.532 0.468 0.00 0.000 0.000
#> SRR886581 2 0.3857 0.848 0.000 0.532 0.468 0.00 0.000 0.000
#> SRR886582 2 0.3857 0.848 0.000 0.532 0.468 0.00 0.000 0.000
#> SRR886583 4 0.0547 0.988 0.000 0.020 0.000 0.98 0.000 0.000
#> SRR886584 4 0.0547 0.988 0.000 0.020 0.000 0.98 0.000 0.000
#> SRR886585 4 0.0547 0.988 0.000 0.020 0.000 0.98 0.000 0.000
#> SRR886586 2 0.6001 0.797 0.008 0.508 0.356 0.00 0.104 0.024
#> SRR886587 2 0.6001 0.797 0.008 0.508 0.356 0.00 0.104 0.024
#> SRR886588 2 0.6001 0.797 0.008 0.508 0.356 0.00 0.104 0.024
#> SRR886589 1 0.0000 0.979 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR886590 1 0.0000 0.979 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR886591 1 0.0000 0.979 1.000 0.000 0.000 0.00 0.000 0.000
#> SRR886592 2 0.3857 0.848 0.000 0.532 0.468 0.00 0.000 0.000
#> SRR886593 2 0.3857 0.848 0.000 0.532 0.468 0.00 0.000 0.000
#> SRR886594 2 0.3857 0.848 0.000 0.532 0.468 0.00 0.000 0.000
#> SRR886595 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886596 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886597 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886598 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886599 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886600 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886601 6 0.3857 1.000 0.000 0.000 0.000 0.00 0.468 0.532
#> SRR886602 4 0.0000 0.988 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR886603 4 0.0000 0.988 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR886604 4 0.0000 0.988 0.000 0.000 0.000 1.00 0.000 0.000
#> SRR886605 3 0.3857 1.000 0.000 0.000 0.532 0.00 0.000 0.468
#> SRR886606 3 0.3857 1.000 0.000 0.000 0.532 0.00 0.000 0.468
#> SRR886607 3 0.3857 1.000 0.000 0.000 0.532 0.00 0.000 0.468
#> SRR886608 5 0.0000 1.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR886609 5 0.0000 1.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR886610 5 0.0000 1.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR886611 5 0.0000 1.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR886612 5 0.0000 1.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR886613 5 0.0000 1.000 0.000 0.000 0.000 0.00 1.000 0.000
#> SRR886614 3 0.3857 1.000 0.000 0.000 0.532 0.00 0.000 0.468
#> SRR886615 3 0.3857 1.000 0.000 0.000 0.532 0.00 0.000 0.468
#> SRR886616 3 0.3857 1.000 0.000 0.000 0.532 0.00 0.000 0.468
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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.999 1.000 0.5095 0.491 0.491
#> 3 3 0.663 0.808 0.842 0.2532 0.891 0.779
#> 4 4 0.816 0.816 0.900 0.1627 0.864 0.645
#> 5 5 0.694 0.709 0.786 0.0455 0.959 0.851
#> 6 6 0.735 0.745 0.804 0.0343 0.898 0.634
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
#> SRR886565 1 0.0000 1.000 1.000 0.000
#> SRR886566 1 0.0000 1.000 1.000 0.000
#> SRR886567 1 0.0000 1.000 1.000 0.000
#> SRR886568 1 0.0000 1.000 1.000 0.000
#> SRR886569 1 0.0000 1.000 1.000 0.000
#> SRR886570 1 0.0000 1.000 1.000 0.000
#> SRR886571 1 0.0000 1.000 1.000 0.000
#> SRR886572 1 0.0000 1.000 1.000 0.000
#> SRR886573 1 0.0000 1.000 1.000 0.000
#> SRR886574 1 0.0000 1.000 1.000 0.000
#> SRR886575 1 0.0000 1.000 1.000 0.000
#> SRR886576 1 0.0000 1.000 1.000 0.000
#> SRR886577 1 0.0000 1.000 1.000 0.000
#> SRR886578 1 0.0000 1.000 1.000 0.000
#> SRR886579 1 0.0000 1.000 1.000 0.000
#> SRR886580 2 0.0000 0.999 0.000 1.000
#> SRR886581 2 0.0000 0.999 0.000 1.000
#> SRR886582 2 0.0000 0.999 0.000 1.000
#> SRR886583 1 0.0000 1.000 1.000 0.000
#> SRR886584 1 0.0000 1.000 1.000 0.000
#> SRR886585 1 0.0000 1.000 1.000 0.000
#> SRR886586 2 0.0000 0.999 0.000 1.000
#> SRR886587 2 0.0000 0.999 0.000 1.000
#> SRR886588 2 0.0000 0.999 0.000 1.000
#> SRR886589 1 0.0000 1.000 1.000 0.000
#> SRR886590 1 0.0000 1.000 1.000 0.000
#> SRR886591 1 0.0000 1.000 1.000 0.000
#> SRR886592 2 0.0000 0.999 0.000 1.000
#> SRR886593 2 0.0000 0.999 0.000 1.000
#> SRR886594 2 0.0000 0.999 0.000 1.000
#> SRR886595 2 0.0000 0.999 0.000 1.000
#> SRR886596 2 0.0000 0.999 0.000 1.000
#> SRR886597 2 0.0000 0.999 0.000 1.000
#> SRR886598 2 0.0000 0.999 0.000 1.000
#> SRR886599 2 0.0000 0.999 0.000 1.000
#> SRR886600 2 0.0000 0.999 0.000 1.000
#> SRR886601 2 0.0000 0.999 0.000 1.000
#> SRR886602 1 0.0000 1.000 1.000 0.000
#> SRR886603 1 0.0000 1.000 1.000 0.000
#> SRR886604 1 0.0000 1.000 1.000 0.000
#> SRR886605 2 0.0376 0.996 0.004 0.996
#> SRR886606 2 0.0376 0.996 0.004 0.996
#> SRR886607 2 0.0376 0.996 0.004 0.996
#> SRR886608 2 0.0000 0.999 0.000 1.000
#> SRR886609 2 0.0000 0.999 0.000 1.000
#> SRR886610 2 0.0000 0.999 0.000 1.000
#> SRR886611 2 0.0000 0.999 0.000 1.000
#> SRR886612 2 0.0000 0.999 0.000 1.000
#> SRR886613 2 0.0000 0.999 0.000 1.000
#> SRR886614 1 0.0000 1.000 1.000 0.000
#> SRR886615 1 0.0376 0.996 0.996 0.004
#> SRR886616 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
#> SRR886565 1 0.0000 0.833 1.000 0.000 0.000
#> SRR886566 1 0.0000 0.833 1.000 0.000 0.000
#> SRR886567 1 0.0000 0.833 1.000 0.000 0.000
#> SRR886568 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886569 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886570 1 0.4842 0.800 0.776 0.000 0.224
#> SRR886571 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886572 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886573 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886574 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886575 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886576 1 0.4887 0.799 0.772 0.000 0.228
#> SRR886577 1 0.2959 0.828 0.900 0.000 0.100
#> SRR886578 1 0.2261 0.831 0.932 0.000 0.068
#> SRR886579 1 0.2878 0.829 0.904 0.000 0.096
#> SRR886580 2 0.1860 0.905 0.000 0.948 0.052
#> SRR886581 2 0.1860 0.905 0.000 0.948 0.052
#> SRR886582 2 0.1860 0.905 0.000 0.948 0.052
#> SRR886583 1 0.1411 0.828 0.964 0.000 0.036
#> SRR886584 1 0.1411 0.828 0.964 0.000 0.036
#> SRR886585 1 0.1411 0.828 0.964 0.000 0.036
#> SRR886586 2 0.0592 0.924 0.000 0.988 0.012
#> SRR886587 2 0.0592 0.924 0.000 0.988 0.012
#> SRR886588 2 0.0592 0.924 0.000 0.988 0.012
#> SRR886589 1 0.2261 0.818 0.932 0.000 0.068
#> SRR886590 1 0.2261 0.818 0.932 0.000 0.068
#> SRR886591 1 0.2165 0.820 0.936 0.000 0.064
#> SRR886592 2 0.1860 0.905 0.000 0.948 0.052
#> SRR886593 2 0.1860 0.905 0.000 0.948 0.052
#> SRR886594 2 0.1860 0.905 0.000 0.948 0.052
#> SRR886595 2 0.1964 0.915 0.000 0.944 0.056
#> SRR886596 2 0.1964 0.915 0.000 0.944 0.056
#> SRR886597 2 0.1964 0.915 0.000 0.944 0.056
#> SRR886598 2 0.2356 0.903 0.000 0.928 0.072
#> SRR886599 2 0.2356 0.903 0.000 0.928 0.072
#> SRR886600 2 0.2356 0.903 0.000 0.928 0.072
#> SRR886601 2 0.2261 0.906 0.000 0.932 0.068
#> SRR886602 1 0.2448 0.815 0.924 0.000 0.076
#> SRR886603 1 0.2448 0.815 0.924 0.000 0.076
#> SRR886604 1 0.2448 0.815 0.924 0.000 0.076
#> SRR886605 3 0.7031 0.803 0.088 0.196 0.716
#> SRR886606 3 0.6933 0.815 0.076 0.208 0.716
#> SRR886607 3 0.7001 0.808 0.084 0.200 0.716
#> SRR886608 3 0.5733 0.868 0.000 0.324 0.676
#> SRR886609 3 0.5733 0.868 0.000 0.324 0.676
#> SRR886610 3 0.5733 0.868 0.000 0.324 0.676
#> SRR886611 3 0.6079 0.821 0.000 0.388 0.612
#> SRR886612 3 0.6095 0.817 0.000 0.392 0.608
#> SRR886613 3 0.6111 0.810 0.000 0.396 0.604
#> SRR886614 1 0.6305 0.142 0.516 0.000 0.484
#> SRR886615 1 0.6307 0.130 0.512 0.000 0.488
#> SRR886616 1 0.6307 0.130 0.512 0.000 0.488
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.3528 0.775 0.808 0.000 0.192 0.000
#> SRR886566 1 0.3486 0.781 0.812 0.000 0.188 0.000
#> SRR886567 1 0.3486 0.781 0.812 0.000 0.188 0.000
#> SRR886568 3 0.1004 0.717 0.024 0.004 0.972 0.000
#> SRR886569 3 0.1004 0.717 0.024 0.004 0.972 0.000
#> SRR886570 3 0.1022 0.720 0.032 0.000 0.968 0.000
#> SRR886571 1 0.1474 0.918 0.948 0.000 0.052 0.000
#> SRR886572 1 0.1389 0.921 0.952 0.000 0.048 0.000
#> SRR886573 1 0.1474 0.918 0.948 0.000 0.052 0.000
#> SRR886574 3 0.4888 0.338 0.412 0.000 0.588 0.000
#> SRR886575 3 0.4888 0.338 0.412 0.000 0.588 0.000
#> SRR886576 3 0.4888 0.338 0.412 0.000 0.588 0.000
#> SRR886577 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886580 2 0.0592 0.959 0.000 0.984 0.016 0.000
#> SRR886581 2 0.0592 0.959 0.000 0.984 0.016 0.000
#> SRR886582 2 0.0592 0.959 0.000 0.984 0.016 0.000
#> SRR886583 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886586 2 0.0336 0.963 0.000 0.992 0.000 0.008
#> SRR886587 2 0.0336 0.963 0.000 0.992 0.000 0.008
#> SRR886588 2 0.0336 0.963 0.000 0.992 0.000 0.008
#> SRR886589 3 0.2596 0.725 0.068 0.000 0.908 0.024
#> SRR886590 3 0.2443 0.726 0.060 0.000 0.916 0.024
#> SRR886591 3 0.2197 0.724 0.048 0.000 0.928 0.024
#> SRR886592 2 0.1022 0.949 0.000 0.968 0.032 0.000
#> SRR886593 2 0.1022 0.949 0.000 0.968 0.032 0.000
#> SRR886594 2 0.1022 0.949 0.000 0.968 0.032 0.000
#> SRR886595 2 0.0469 0.963 0.000 0.988 0.000 0.012
#> SRR886596 2 0.0469 0.963 0.000 0.988 0.000 0.012
#> SRR886597 2 0.0469 0.963 0.000 0.988 0.000 0.012
#> SRR886598 2 0.2345 0.921 0.000 0.900 0.000 0.100
#> SRR886599 2 0.2345 0.921 0.000 0.900 0.000 0.100
#> SRR886600 2 0.2345 0.921 0.000 0.900 0.000 0.100
#> SRR886601 2 0.2345 0.921 0.000 0.900 0.000 0.100
#> SRR886602 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.938 1.000 0.000 0.000 0.000
#> SRR886605 4 0.4222 0.697 0.000 0.000 0.272 0.728
#> SRR886606 4 0.4164 0.708 0.000 0.000 0.264 0.736
#> SRR886607 4 0.4164 0.708 0.000 0.000 0.264 0.736
#> SRR886608 4 0.0592 0.841 0.000 0.016 0.000 0.984
#> SRR886609 4 0.0592 0.841 0.000 0.016 0.000 0.984
#> SRR886610 4 0.0592 0.841 0.000 0.016 0.000 0.984
#> SRR886611 4 0.3243 0.834 0.000 0.088 0.036 0.876
#> SRR886612 4 0.3372 0.829 0.000 0.096 0.036 0.868
#> SRR886613 4 0.3176 0.836 0.000 0.084 0.036 0.880
#> SRR886614 3 0.5026 0.418 0.016 0.000 0.672 0.312
#> SRR886615 3 0.5047 0.408 0.016 0.000 0.668 0.316
#> SRR886616 3 0.5047 0.411 0.016 0.000 0.668 0.316
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.3759 0.842 0.816 0.000 0.092 NA 0.000
#> SRR886566 1 0.3759 0.841 0.816 0.000 0.092 NA 0.000
#> SRR886567 1 0.3812 0.839 0.812 0.000 0.092 NA 0.000
#> SRR886568 3 0.4737 0.631 0.016 0.004 0.640 NA 0.004
#> SRR886569 3 0.4671 0.630 0.008 0.004 0.640 NA 0.008
#> SRR886570 3 0.4737 0.631 0.016 0.004 0.640 NA 0.004
#> SRR886571 1 0.3921 0.823 0.784 0.000 0.044 NA 0.000
#> SRR886572 1 0.3844 0.828 0.792 0.000 0.044 NA 0.000
#> SRR886573 1 0.3921 0.823 0.784 0.000 0.044 NA 0.000
#> SRR886574 3 0.6718 0.345 0.248 0.000 0.384 NA 0.000
#> SRR886575 3 0.6718 0.345 0.248 0.000 0.384 NA 0.000
#> SRR886576 3 0.6728 0.337 0.252 0.000 0.380 NA 0.000
#> SRR886577 1 0.0798 0.901 0.976 0.000 0.008 NA 0.000
#> SRR886578 1 0.0451 0.901 0.988 0.000 0.008 NA 0.000
#> SRR886579 1 0.0798 0.901 0.976 0.000 0.008 NA 0.000
#> SRR886580 2 0.2646 0.708 0.000 0.868 0.004 NA 0.004
#> SRR886581 2 0.2818 0.704 0.000 0.860 0.004 NA 0.008
#> SRR886582 2 0.2741 0.704 0.000 0.860 0.004 NA 0.004
#> SRR886583 1 0.0290 0.899 0.992 0.000 0.000 NA 0.000
#> SRR886584 1 0.0290 0.899 0.992 0.000 0.000 NA 0.000
#> SRR886585 1 0.0290 0.899 0.992 0.000 0.000 NA 0.000
#> SRR886586 2 0.2592 0.753 0.000 0.892 0.000 NA 0.052
#> SRR886587 2 0.2592 0.753 0.000 0.892 0.000 NA 0.052
#> SRR886588 2 0.2592 0.753 0.000 0.892 0.000 NA 0.052
#> SRR886589 3 0.3768 0.644 0.020 0.000 0.808 NA 0.016
#> SRR886590 3 0.3685 0.644 0.020 0.000 0.816 NA 0.016
#> SRR886591 3 0.3727 0.645 0.020 0.000 0.812 NA 0.016
#> SRR886592 2 0.2352 0.737 0.000 0.896 0.004 NA 0.008
#> SRR886593 2 0.2352 0.737 0.000 0.896 0.004 NA 0.008
#> SRR886594 2 0.2352 0.737 0.000 0.896 0.004 NA 0.008
#> SRR886595 2 0.4000 0.694 0.000 0.748 0.000 NA 0.228
#> SRR886596 2 0.4000 0.694 0.000 0.748 0.000 NA 0.228
#> SRR886597 2 0.4029 0.691 0.000 0.744 0.000 NA 0.232
#> SRR886598 2 0.4383 0.477 0.000 0.572 0.000 NA 0.424
#> SRR886599 2 0.4383 0.477 0.000 0.572 0.000 NA 0.424
#> SRR886600 2 0.4383 0.477 0.000 0.572 0.000 NA 0.424
#> SRR886601 2 0.4383 0.477 0.000 0.572 0.000 NA 0.424
#> SRR886602 1 0.1168 0.889 0.960 0.000 0.000 NA 0.008
#> SRR886603 1 0.1168 0.889 0.960 0.000 0.000 NA 0.008
#> SRR886604 1 0.1168 0.889 0.960 0.000 0.000 NA 0.008
#> SRR886605 3 0.5272 0.313 0.000 0.000 0.620 NA 0.308
#> SRR886606 3 0.5218 0.316 0.000 0.000 0.624 NA 0.308
#> SRR886607 3 0.5235 0.310 0.000 0.000 0.620 NA 0.312
#> SRR886608 5 0.1282 0.944 0.000 0.000 0.044 NA 0.952
#> SRR886609 5 0.1205 0.947 0.000 0.000 0.040 NA 0.956
#> SRR886610 5 0.1205 0.947 0.000 0.000 0.040 NA 0.956
#> SRR886611 5 0.1444 0.946 0.000 0.040 0.012 NA 0.948
#> SRR886612 5 0.1444 0.946 0.000 0.040 0.012 NA 0.948
#> SRR886613 5 0.1605 0.945 0.000 0.040 0.012 NA 0.944
#> SRR886614 3 0.4212 0.584 0.000 0.000 0.776 NA 0.144
#> SRR886615 3 0.4212 0.584 0.000 0.000 0.776 NA 0.144
#> SRR886616 3 0.4212 0.584 0.000 0.000 0.776 NA 0.144
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.3047 0.849 0.848 0.000 0.084 0.004 0.000 0.064
#> SRR886566 1 0.2988 0.853 0.852 0.000 0.084 0.004 0.000 0.060
#> SRR886567 1 0.2928 0.856 0.856 0.000 0.084 0.004 0.000 0.056
#> SRR886568 3 0.5909 0.492 0.016 0.060 0.500 0.032 0.000 0.392
#> SRR886569 3 0.5909 0.493 0.016 0.060 0.500 0.032 0.000 0.392
#> SRR886570 3 0.5944 0.500 0.016 0.064 0.504 0.032 0.000 0.384
#> SRR886571 1 0.3130 0.835 0.824 0.000 0.004 0.028 0.000 0.144
#> SRR886572 1 0.2968 0.850 0.840 0.000 0.004 0.028 0.000 0.128
#> SRR886573 1 0.3164 0.836 0.824 0.000 0.004 0.032 0.000 0.140
#> SRR886574 6 0.2510 0.987 0.100 0.000 0.028 0.000 0.000 0.872
#> SRR886575 6 0.2651 0.984 0.112 0.000 0.028 0.000 0.000 0.860
#> SRR886576 6 0.2558 0.990 0.104 0.000 0.028 0.000 0.000 0.868
#> SRR886577 1 0.0865 0.914 0.964 0.000 0.000 0.000 0.000 0.036
#> SRR886578 1 0.0865 0.914 0.964 0.000 0.000 0.000 0.000 0.036
#> SRR886579 1 0.0865 0.914 0.964 0.000 0.000 0.000 0.000 0.036
#> SRR886580 4 0.4935 0.997 0.000 0.396 0.008 0.552 0.040 0.004
#> SRR886581 4 0.4935 0.997 0.000 0.396 0.008 0.552 0.040 0.004
#> SRR886582 4 0.4943 0.993 0.000 0.400 0.008 0.548 0.040 0.004
#> SRR886583 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.914 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR886586 2 0.0508 0.531 0.000 0.984 0.012 0.004 0.000 0.000
#> SRR886587 2 0.0653 0.530 0.000 0.980 0.012 0.004 0.004 0.000
#> SRR886588 2 0.0508 0.531 0.000 0.984 0.012 0.004 0.000 0.000
#> SRR886589 3 0.3975 0.697 0.004 0.000 0.744 0.048 0.000 0.204
#> SRR886590 3 0.3905 0.698 0.004 0.000 0.744 0.040 0.000 0.212
#> SRR886591 3 0.3905 0.694 0.004 0.000 0.744 0.040 0.000 0.212
#> SRR886592 2 0.4241 0.445 0.000 0.756 0.000 0.152 0.016 0.076
#> SRR886593 2 0.4189 0.448 0.000 0.760 0.000 0.152 0.016 0.072
#> SRR886594 2 0.4341 0.436 0.000 0.748 0.000 0.152 0.016 0.084
#> SRR886595 2 0.4688 0.383 0.000 0.644 0.004 0.064 0.288 0.000
#> SRR886596 2 0.4669 0.387 0.000 0.648 0.004 0.064 0.284 0.000
#> SRR886597 2 0.4669 0.387 0.000 0.648 0.004 0.064 0.284 0.000
#> SRR886598 5 0.4632 0.703 0.000 0.152 0.000 0.128 0.712 0.008
#> SRR886599 5 0.4632 0.703 0.000 0.152 0.000 0.128 0.712 0.008
#> SRR886600 5 0.4632 0.703 0.000 0.152 0.000 0.128 0.712 0.008
#> SRR886601 5 0.4628 0.701 0.000 0.156 0.000 0.124 0.712 0.008
#> SRR886602 1 0.0893 0.906 0.972 0.000 0.004 0.004 0.004 0.016
#> SRR886603 1 0.0798 0.907 0.976 0.000 0.004 0.004 0.004 0.012
#> SRR886604 1 0.0912 0.906 0.972 0.000 0.004 0.004 0.008 0.012
#> SRR886605 3 0.1176 0.726 0.000 0.000 0.956 0.020 0.024 0.000
#> SRR886606 3 0.1245 0.725 0.000 0.000 0.952 0.016 0.032 0.000
#> SRR886607 3 0.1176 0.726 0.000 0.000 0.956 0.020 0.024 0.000
#> SRR886608 5 0.1219 0.781 0.000 0.000 0.048 0.000 0.948 0.004
#> SRR886609 5 0.1219 0.781 0.000 0.000 0.048 0.000 0.948 0.004
#> SRR886610 5 0.1219 0.781 0.000 0.000 0.048 0.000 0.948 0.004
#> SRR886611 5 0.3674 0.778 0.000 0.084 0.096 0.012 0.808 0.000
#> SRR886612 5 0.3764 0.772 0.000 0.088 0.108 0.008 0.796 0.000
#> SRR886613 5 0.3771 0.776 0.000 0.088 0.100 0.012 0.800 0.000
#> SRR886614 3 0.3029 0.741 0.000 0.000 0.840 0.004 0.036 0.120
#> SRR886615 3 0.2985 0.742 0.000 0.000 0.844 0.004 0.036 0.116
#> SRR886616 3 0.3029 0.741 0.000 0.000 0.840 0.004 0.036 0.120
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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.999 0.999 0.4622 0.538 0.538
#> 3 3 0.929 0.918 0.959 0.4435 0.801 0.630
#> 4 4 1.000 0.979 0.989 0.1009 0.928 0.787
#> 5 5 1.000 0.979 0.989 0.0738 0.946 0.797
#> 6 6 0.952 0.967 0.949 0.0317 0.973 0.872
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 4 5
There is also optional best \(k\) = 2 3 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0.0000 1.000 1.000 0.000
#> SRR886566 1 0.0000 1.000 1.000 0.000
#> SRR886567 1 0.0000 1.000 1.000 0.000
#> SRR886568 2 0.0376 0.997 0.004 0.996
#> SRR886569 2 0.0376 0.997 0.004 0.996
#> SRR886570 2 0.0376 0.997 0.004 0.996
#> SRR886571 1 0.0000 1.000 1.000 0.000
#> SRR886572 1 0.0000 1.000 1.000 0.000
#> SRR886573 1 0.0000 1.000 1.000 0.000
#> SRR886574 1 0.0000 1.000 1.000 0.000
#> SRR886575 1 0.0000 1.000 1.000 0.000
#> SRR886576 1 0.0000 1.000 1.000 0.000
#> SRR886577 1 0.0000 1.000 1.000 0.000
#> SRR886578 1 0.0000 1.000 1.000 0.000
#> SRR886579 1 0.0000 1.000 1.000 0.000
#> SRR886580 2 0.0000 0.999 0.000 1.000
#> SRR886581 2 0.0000 0.999 0.000 1.000
#> SRR886582 2 0.0000 0.999 0.000 1.000
#> SRR886583 1 0.0000 1.000 1.000 0.000
#> SRR886584 1 0.0000 1.000 1.000 0.000
#> SRR886585 1 0.0000 1.000 1.000 0.000
#> SRR886586 2 0.0000 0.999 0.000 1.000
#> SRR886587 2 0.0000 0.999 0.000 1.000
#> SRR886588 2 0.0000 0.999 0.000 1.000
#> SRR886589 2 0.0376 0.997 0.004 0.996
#> SRR886590 2 0.0376 0.997 0.004 0.996
#> SRR886591 2 0.0376 0.997 0.004 0.996
#> SRR886592 2 0.0000 0.999 0.000 1.000
#> SRR886593 2 0.0000 0.999 0.000 1.000
#> SRR886594 2 0.0000 0.999 0.000 1.000
#> SRR886595 2 0.0000 0.999 0.000 1.000
#> SRR886596 2 0.0000 0.999 0.000 1.000
#> SRR886597 2 0.0000 0.999 0.000 1.000
#> SRR886598 2 0.0000 0.999 0.000 1.000
#> SRR886599 2 0.0000 0.999 0.000 1.000
#> SRR886600 2 0.0000 0.999 0.000 1.000
#> SRR886601 2 0.0000 0.999 0.000 1.000
#> SRR886602 1 0.0000 1.000 1.000 0.000
#> SRR886603 1 0.0000 1.000 1.000 0.000
#> SRR886604 1 0.0000 1.000 1.000 0.000
#> SRR886605 2 0.0000 0.999 0.000 1.000
#> SRR886606 2 0.0000 0.999 0.000 1.000
#> SRR886607 2 0.0000 0.999 0.000 1.000
#> SRR886608 2 0.0000 0.999 0.000 1.000
#> SRR886609 2 0.0000 0.999 0.000 1.000
#> SRR886610 2 0.0000 0.999 0.000 1.000
#> SRR886611 2 0.0000 0.999 0.000 1.000
#> SRR886612 2 0.0000 0.999 0.000 1.000
#> SRR886613 2 0.0000 0.999 0.000 1.000
#> SRR886614 2 0.0376 0.997 0.004 0.996
#> SRR886615 2 0.0376 0.997 0.004 0.996
#> SRR886616 2 0.0376 0.997 0.004 0.996
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 1.000 1 0.000 0.000
#> SRR886566 1 0.0000 1.000 1 0.000 0.000
#> SRR886567 1 0.0000 1.000 1 0.000 0.000
#> SRR886568 3 0.0000 0.999 0 0.000 1.000
#> SRR886569 3 0.0000 0.999 0 0.000 1.000
#> SRR886570 3 0.0000 0.999 0 0.000 1.000
#> SRR886571 1 0.0000 1.000 1 0.000 0.000
#> SRR886572 1 0.0000 1.000 1 0.000 0.000
#> SRR886573 1 0.0000 1.000 1 0.000 0.000
#> SRR886574 1 0.0000 1.000 1 0.000 0.000
#> SRR886575 1 0.0000 1.000 1 0.000 0.000
#> SRR886576 1 0.0000 1.000 1 0.000 0.000
#> SRR886577 1 0.0000 1.000 1 0.000 0.000
#> SRR886578 1 0.0000 1.000 1 0.000 0.000
#> SRR886579 1 0.0000 1.000 1 0.000 0.000
#> SRR886580 2 0.0000 0.891 0 1.000 0.000
#> SRR886581 2 0.0000 0.891 0 1.000 0.000
#> SRR886582 2 0.0000 0.891 0 1.000 0.000
#> SRR886583 1 0.0000 1.000 1 0.000 0.000
#> SRR886584 1 0.0000 1.000 1 0.000 0.000
#> SRR886585 1 0.0000 1.000 1 0.000 0.000
#> SRR886586 2 0.0000 0.891 0 1.000 0.000
#> SRR886587 2 0.0000 0.891 0 1.000 0.000
#> SRR886588 2 0.0000 0.891 0 1.000 0.000
#> SRR886589 3 0.0000 0.999 0 0.000 1.000
#> SRR886590 3 0.0000 0.999 0 0.000 1.000
#> SRR886591 3 0.0000 0.999 0 0.000 1.000
#> SRR886592 2 0.0000 0.891 0 1.000 0.000
#> SRR886593 2 0.0000 0.891 0 1.000 0.000
#> SRR886594 2 0.0000 0.891 0 1.000 0.000
#> SRR886595 2 0.0000 0.891 0 1.000 0.000
#> SRR886596 2 0.0000 0.891 0 1.000 0.000
#> SRR886597 2 0.0000 0.891 0 1.000 0.000
#> SRR886598 2 0.0000 0.891 0 1.000 0.000
#> SRR886599 2 0.0000 0.891 0 1.000 0.000
#> SRR886600 2 0.0000 0.891 0 1.000 0.000
#> SRR886601 2 0.0000 0.891 0 1.000 0.000
#> SRR886602 1 0.0000 1.000 1 0.000 0.000
#> SRR886603 1 0.0000 1.000 1 0.000 0.000
#> SRR886604 1 0.0000 1.000 1 0.000 0.000
#> SRR886605 3 0.0237 0.996 0 0.004 0.996
#> SRR886606 3 0.0237 0.996 0 0.004 0.996
#> SRR886607 3 0.0237 0.996 0 0.004 0.996
#> SRR886608 2 0.5905 0.585 0 0.648 0.352
#> SRR886609 2 0.5905 0.585 0 0.648 0.352
#> SRR886610 2 0.5905 0.585 0 0.648 0.352
#> SRR886611 2 0.5882 0.591 0 0.652 0.348
#> SRR886612 2 0.5882 0.591 0 0.652 0.348
#> SRR886613 2 0.5882 0.591 0 0.652 0.348
#> SRR886614 3 0.0000 0.999 0 0.000 1.000
#> SRR886615 3 0.0000 0.999 0 0.000 1.000
#> SRR886616 3 0.0000 0.999 0 0.000 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886566 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886567 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886568 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886569 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886570 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886571 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886572 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886573 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886574 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886575 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886576 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886577 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886578 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886579 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886580 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886581 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886582 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886583 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886584 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886585 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886586 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886587 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886588 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886589 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886590 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886591 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886592 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886593 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886594 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886595 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886596 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886597 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886598 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886599 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886600 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886601 2 0.0000 1.000 0 1.000 0.000 0.000
#> SRR886602 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886603 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886604 1 0.0000 1.000 1 0.000 0.000 0.000
#> SRR886605 3 0.3528 0.806 0 0.000 0.808 0.192
#> SRR886606 3 0.3528 0.806 0 0.000 0.808 0.192
#> SRR886607 3 0.3528 0.806 0 0.000 0.808 0.192
#> SRR886608 4 0.0000 0.997 0 0.000 0.000 1.000
#> SRR886609 4 0.0000 0.997 0 0.000 0.000 1.000
#> SRR886610 4 0.0000 0.997 0 0.000 0.000 1.000
#> SRR886611 4 0.0188 0.997 0 0.004 0.000 0.996
#> SRR886612 4 0.0188 0.997 0 0.004 0.000 0.996
#> SRR886613 4 0.0188 0.997 0 0.004 0.000 0.996
#> SRR886614 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886615 3 0.0000 0.945 0 0.000 1.000 0.000
#> SRR886616 3 0.0000 0.945 0 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886566 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886567 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886568 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886569 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886570 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886571 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886572 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886573 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886574 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886575 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886576 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886577 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886578 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886579 1 0.0000 1.000 1 0.000 0.000 0 0.000
#> SRR886580 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886581 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886582 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886583 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR886584 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR886585 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR886586 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886587 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886588 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886589 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886590 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886591 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886592 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886593 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886594 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886595 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886596 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886597 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886598 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886599 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886600 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886601 2 0.0000 1.000 0 1.000 0.000 0 0.000
#> SRR886602 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR886603 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR886604 4 0.0000 1.000 0 0.000 0.000 1 0.000
#> SRR886605 3 0.3039 0.806 0 0.000 0.808 0 0.192
#> SRR886606 3 0.3039 0.806 0 0.000 0.808 0 0.192
#> SRR886607 3 0.3039 0.806 0 0.000 0.808 0 0.192
#> SRR886608 5 0.0000 0.997 0 0.000 0.000 0 1.000
#> SRR886609 5 0.0000 0.997 0 0.000 0.000 0 1.000
#> SRR886610 5 0.0000 0.997 0 0.000 0.000 0 1.000
#> SRR886611 5 0.0162 0.997 0 0.004 0.000 0 0.996
#> SRR886612 5 0.0162 0.997 0 0.004 0.000 0 0.996
#> SRR886613 5 0.0162 0.997 0 0.004 0.000 0 0.996
#> SRR886614 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886615 3 0.0000 0.945 0 0.000 1.000 0 0.000
#> SRR886616 3 0.0000 0.945 0 0.000 1.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886566 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886567 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886568 3 0.0000 1.000 0 0.000 1.00 0 0.000 0.000
#> SRR886569 3 0.0000 1.000 0 0.000 1.00 0 0.000 0.000
#> SRR886570 3 0.0000 1.000 0 0.000 1.00 0 0.000 0.000
#> SRR886571 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886572 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886573 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886574 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886575 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886576 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886577 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886578 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886579 1 0.0000 1.000 1 0.000 0.00 0 0.000 0.000
#> SRR886580 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886581 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886582 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886583 4 0.0000 1.000 0 0.000 0.00 1 0.000 0.000
#> SRR886584 4 0.0000 1.000 0 0.000 0.00 1 0.000 0.000
#> SRR886585 4 0.0000 1.000 0 0.000 0.00 1 0.000 0.000
#> SRR886586 2 0.0146 0.972 0 0.996 0.00 0 0.004 0.000
#> SRR886587 2 0.0146 0.972 0 0.996 0.00 0 0.004 0.000
#> SRR886588 2 0.0146 0.972 0 0.996 0.00 0 0.004 0.000
#> SRR886589 3 0.0000 1.000 0 0.000 1.00 0 0.000 0.000
#> SRR886590 3 0.0000 1.000 0 0.000 1.00 0 0.000 0.000
#> SRR886591 3 0.0000 1.000 0 0.000 1.00 0 0.000 0.000
#> SRR886592 2 0.2362 0.887 0 0.860 0.00 0 0.004 0.136
#> SRR886593 2 0.2362 0.887 0 0.860 0.00 0 0.004 0.136
#> SRR886594 2 0.2362 0.887 0 0.860 0.00 0 0.004 0.136
#> SRR886595 2 0.0000 0.973 0 1.000 0.00 0 0.000 0.000
#> SRR886596 2 0.0000 0.973 0 1.000 0.00 0 0.000 0.000
#> SRR886597 2 0.0000 0.973 0 1.000 0.00 0 0.000 0.000
#> SRR886598 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886599 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886600 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886601 2 0.0146 0.973 0 0.996 0.00 0 0.000 0.004
#> SRR886602 4 0.0000 1.000 0 0.000 0.00 1 0.000 0.000
#> SRR886603 4 0.0000 1.000 0 0.000 0.00 1 0.000 0.000
#> SRR886604 4 0.0000 1.000 0 0.000 0.00 1 0.000 0.000
#> SRR886605 6 0.2260 0.846 0 0.000 0.14 0 0.000 0.860
#> SRR886606 6 0.2260 0.846 0 0.000 0.14 0 0.000 0.860
#> SRR886607 6 0.2260 0.846 0 0.000 0.14 0 0.000 0.860
#> SRR886608 5 0.0146 0.997 0 0.000 0.00 0 0.996 0.004
#> SRR886609 5 0.0146 0.997 0 0.000 0.00 0 0.996 0.004
#> SRR886610 5 0.0146 0.997 0 0.000 0.00 0 0.996 0.004
#> SRR886611 5 0.0000 0.997 0 0.000 0.00 0 1.000 0.000
#> SRR886612 5 0.0000 0.997 0 0.000 0.00 0 1.000 0.000
#> SRR886613 5 0.0000 0.997 0 0.000 0.00 0 1.000 0.000
#> SRR886614 6 0.3578 0.818 0 0.000 0.34 0 0.000 0.660
#> SRR886615 6 0.3578 0.818 0 0.000 0.34 0 0.000 0.660
#> SRR886616 6 0.3578 0.818 0 0.000 0.34 0 0.000 0.660
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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.5095 0.491 0.491
#> 3 3 0.686 0.834 0.892 0.2884 0.751 0.532
#> 4 4 0.704 0.787 0.826 0.1028 1.000 1.000
#> 5 5 0.712 0.651 0.699 0.0646 0.930 0.788
#> 6 6 0.702 0.641 0.701 0.0390 0.912 0.685
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
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.424 0.900 0.824 0.000 0.176
#> SRR886566 1 0.424 0.900 0.824 0.000 0.176
#> SRR886567 1 0.424 0.900 0.824 0.000 0.176
#> SRR886568 3 0.355 0.742 0.132 0.000 0.868
#> SRR886569 3 0.355 0.742 0.132 0.000 0.868
#> SRR886570 3 0.355 0.742 0.132 0.000 0.868
#> SRR886571 1 0.186 0.902 0.948 0.000 0.052
#> SRR886572 1 0.186 0.902 0.948 0.000 0.052
#> SRR886573 1 0.186 0.902 0.948 0.000 0.052
#> SRR886574 1 0.435 0.898 0.816 0.000 0.184
#> SRR886575 1 0.435 0.898 0.816 0.000 0.184
#> SRR886576 1 0.435 0.898 0.816 0.000 0.184
#> SRR886577 1 0.424 0.900 0.824 0.000 0.176
#> SRR886578 1 0.424 0.900 0.824 0.000 0.176
#> SRR886579 1 0.424 0.900 0.824 0.000 0.176
#> SRR886580 2 0.000 0.950 0.000 1.000 0.000
#> SRR886581 2 0.000 0.950 0.000 1.000 0.000
#> SRR886582 2 0.000 0.950 0.000 1.000 0.000
#> SRR886583 1 0.000 0.887 1.000 0.000 0.000
#> SRR886584 1 0.000 0.887 1.000 0.000 0.000
#> SRR886585 1 0.000 0.887 1.000 0.000 0.000
#> SRR886586 2 0.196 0.951 0.000 0.944 0.056
#> SRR886587 2 0.196 0.951 0.000 0.944 0.056
#> SRR886588 2 0.196 0.951 0.000 0.944 0.056
#> SRR886589 3 0.355 0.742 0.132 0.000 0.868
#> SRR886590 3 0.355 0.742 0.132 0.000 0.868
#> SRR886591 3 0.355 0.742 0.132 0.000 0.868
#> SRR886592 2 0.207 0.950 0.000 0.940 0.060
#> SRR886593 2 0.207 0.950 0.000 0.940 0.060
#> SRR886594 2 0.207 0.950 0.000 0.940 0.060
#> SRR886595 2 0.000 0.950 0.000 1.000 0.000
#> SRR886596 2 0.000 0.950 0.000 1.000 0.000
#> SRR886597 2 0.000 0.950 0.000 1.000 0.000
#> SRR886598 2 0.186 0.944 0.000 0.948 0.052
#> SRR886599 2 0.186 0.944 0.000 0.948 0.052
#> SRR886600 2 0.186 0.944 0.000 0.948 0.052
#> SRR886601 2 0.186 0.944 0.000 0.948 0.052
#> SRR886602 1 0.000 0.887 1.000 0.000 0.000
#> SRR886603 1 0.000 0.887 1.000 0.000 0.000
#> SRR886604 1 0.000 0.887 1.000 0.000 0.000
#> SRR886605 3 0.429 0.639 0.000 0.180 0.820
#> SRR886606 3 0.429 0.639 0.000 0.180 0.820
#> SRR886607 3 0.429 0.639 0.000 0.180 0.820
#> SRR886608 3 0.619 0.230 0.000 0.420 0.580
#> SRR886609 3 0.619 0.230 0.000 0.420 0.580
#> SRR886610 3 0.619 0.230 0.000 0.420 0.580
#> SRR886611 2 0.334 0.926 0.000 0.880 0.120
#> SRR886612 2 0.334 0.926 0.000 0.880 0.120
#> SRR886613 2 0.334 0.926 0.000 0.880 0.120
#> SRR886614 3 0.334 0.746 0.120 0.000 0.880
#> SRR886615 3 0.334 0.746 0.120 0.000 0.880
#> SRR886616 3 0.334 0.746 0.120 0.000 0.880
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.1888 0.855 0.940 0.000 0.044 NA
#> SRR886566 1 0.1888 0.855 0.940 0.000 0.044 NA
#> SRR886567 1 0.1888 0.855 0.940 0.000 0.044 NA
#> SRR886568 3 0.3876 0.768 0.124 0.000 0.836 NA
#> SRR886569 3 0.3876 0.768 0.124 0.000 0.836 NA
#> SRR886570 3 0.3876 0.768 0.124 0.000 0.836 NA
#> SRR886571 1 0.0817 0.863 0.976 0.000 0.000 NA
#> SRR886572 1 0.0817 0.863 0.976 0.000 0.000 NA
#> SRR886573 1 0.0817 0.863 0.976 0.000 0.000 NA
#> SRR886574 1 0.2466 0.847 0.916 0.000 0.028 NA
#> SRR886575 1 0.2466 0.847 0.916 0.000 0.028 NA
#> SRR886576 1 0.2466 0.847 0.916 0.000 0.028 NA
#> SRR886577 1 0.1209 0.862 0.964 0.000 0.032 NA
#> SRR886578 1 0.1209 0.862 0.964 0.000 0.032 NA
#> SRR886579 1 0.1209 0.862 0.964 0.000 0.032 NA
#> SRR886580 2 0.2053 0.846 0.000 0.924 0.004 NA
#> SRR886581 2 0.2053 0.846 0.000 0.924 0.004 NA
#> SRR886582 2 0.2053 0.846 0.000 0.924 0.004 NA
#> SRR886583 1 0.4632 0.771 0.688 0.000 0.004 NA
#> SRR886584 1 0.4632 0.771 0.688 0.000 0.004 NA
#> SRR886585 1 0.4632 0.771 0.688 0.000 0.004 NA
#> SRR886586 2 0.3806 0.843 0.000 0.824 0.020 NA
#> SRR886587 2 0.3806 0.843 0.000 0.824 0.020 NA
#> SRR886588 2 0.3806 0.843 0.000 0.824 0.020 NA
#> SRR886589 3 0.2704 0.778 0.124 0.000 0.876 NA
#> SRR886590 3 0.2704 0.778 0.124 0.000 0.876 NA
#> SRR886591 3 0.2704 0.778 0.124 0.000 0.876 NA
#> SRR886592 2 0.5025 0.820 0.000 0.716 0.032 NA
#> SRR886593 2 0.5025 0.820 0.000 0.716 0.032 NA
#> SRR886594 2 0.5025 0.820 0.000 0.716 0.032 NA
#> SRR886595 2 0.0336 0.854 0.000 0.992 0.000 NA
#> SRR886596 2 0.0336 0.854 0.000 0.992 0.000 NA
#> SRR886597 2 0.0336 0.854 0.000 0.992 0.000 NA
#> SRR886598 2 0.2949 0.847 0.000 0.888 0.024 NA
#> SRR886599 2 0.2949 0.847 0.000 0.888 0.024 NA
#> SRR886600 2 0.2949 0.847 0.000 0.888 0.024 NA
#> SRR886601 2 0.2949 0.847 0.000 0.888 0.024 NA
#> SRR886602 1 0.4477 0.771 0.688 0.000 0.000 NA
#> SRR886603 1 0.4477 0.771 0.688 0.000 0.000 NA
#> SRR886604 1 0.4477 0.771 0.688 0.000 0.000 NA
#> SRR886605 3 0.3672 0.761 0.000 0.012 0.824 NA
#> SRR886606 3 0.3672 0.761 0.000 0.012 0.824 NA
#> SRR886607 3 0.3672 0.761 0.000 0.012 0.824 NA
#> SRR886608 3 0.7613 0.340 0.000 0.212 0.448 NA
#> SRR886609 3 0.7613 0.340 0.000 0.212 0.448 NA
#> SRR886610 3 0.7613 0.340 0.000 0.212 0.448 NA
#> SRR886611 2 0.6153 0.743 0.000 0.604 0.068 NA
#> SRR886612 2 0.6153 0.743 0.000 0.604 0.068 NA
#> SRR886613 2 0.6153 0.743 0.000 0.604 0.068 NA
#> SRR886614 3 0.3247 0.796 0.060 0.000 0.880 NA
#> SRR886615 3 0.3247 0.796 0.060 0.000 0.880 NA
#> SRR886616 3 0.3247 0.796 0.060 0.000 0.880 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.251 0.789 0.904 0.000 0.048 NA 0.008
#> SRR886566 1 0.251 0.789 0.904 0.000 0.048 NA 0.008
#> SRR886567 1 0.251 0.789 0.904 0.000 0.048 NA 0.008
#> SRR886568 3 0.297 0.791 0.048 0.000 0.884 NA 0.020
#> SRR886569 3 0.297 0.791 0.048 0.000 0.884 NA 0.020
#> SRR886570 3 0.297 0.791 0.048 0.000 0.884 NA 0.020
#> SRR886571 1 0.184 0.801 0.932 0.000 0.000 NA 0.032
#> SRR886572 1 0.184 0.801 0.932 0.000 0.000 NA 0.032
#> SRR886573 1 0.184 0.801 0.932 0.000 0.000 NA 0.032
#> SRR886574 1 0.441 0.754 0.796 0.000 0.036 NA 0.060
#> SRR886575 1 0.441 0.754 0.796 0.000 0.036 NA 0.060
#> SRR886576 1 0.444 0.754 0.796 0.000 0.036 NA 0.068
#> SRR886577 1 0.149 0.799 0.948 0.000 0.028 NA 0.000
#> SRR886578 1 0.149 0.799 0.948 0.000 0.028 NA 0.000
#> SRR886579 1 0.149 0.799 0.948 0.000 0.028 NA 0.000
#> SRR886580 2 0.267 0.649 0.000 0.876 0.000 NA 0.020
#> SRR886581 2 0.267 0.649 0.000 0.876 0.000 NA 0.020
#> SRR886582 2 0.267 0.649 0.000 0.876 0.000 NA 0.020
#> SRR886583 1 0.425 0.680 0.568 0.000 0.000 NA 0.000
#> SRR886584 1 0.425 0.680 0.568 0.000 0.000 NA 0.000
#> SRR886585 1 0.425 0.680 0.568 0.000 0.000 NA 0.000
#> SRR886586 2 0.557 0.573 0.000 0.676 0.012 NA 0.168
#> SRR886587 2 0.557 0.573 0.000 0.676 0.012 NA 0.168
#> SRR886588 2 0.557 0.573 0.000 0.676 0.012 NA 0.168
#> SRR886589 3 0.136 0.811 0.048 0.000 0.948 NA 0.000
#> SRR886590 3 0.136 0.811 0.048 0.000 0.948 NA 0.000
#> SRR886591 3 0.136 0.811 0.048 0.000 0.948 NA 0.000
#> SRR886592 2 0.650 0.457 0.000 0.524 0.008 NA 0.284
#> SRR886593 2 0.650 0.457 0.000 0.524 0.008 NA 0.284
#> SRR886594 2 0.657 0.457 0.000 0.524 0.012 NA 0.284
#> SRR886595 2 0.136 0.666 0.000 0.952 0.000 NA 0.012
#> SRR886596 2 0.136 0.666 0.000 0.952 0.000 NA 0.012
#> SRR886597 2 0.136 0.666 0.000 0.952 0.000 NA 0.012
#> SRR886598 2 0.449 0.546 0.000 0.744 0.004 NA 0.196
#> SRR886599 2 0.449 0.546 0.000 0.744 0.004 NA 0.196
#> SRR886600 2 0.449 0.546 0.000 0.744 0.004 NA 0.196
#> SRR886601 2 0.449 0.546 0.000 0.744 0.004 NA 0.196
#> SRR886602 1 0.481 0.679 0.576 0.000 0.000 NA 0.024
#> SRR886603 1 0.481 0.679 0.576 0.000 0.000 NA 0.024
#> SRR886604 1 0.481 0.679 0.576 0.000 0.000 NA 0.024
#> SRR886605 3 0.522 0.598 0.000 0.004 0.616 NA 0.328
#> SRR886606 3 0.522 0.598 0.000 0.004 0.616 NA 0.328
#> SRR886607 3 0.522 0.598 0.000 0.004 0.616 NA 0.328
#> SRR886608 5 0.541 0.469 0.000 0.084 0.272 NA 0.640
#> SRR886609 5 0.541 0.469 0.000 0.084 0.272 NA 0.640
#> SRR886610 5 0.541 0.469 0.000 0.084 0.272 NA 0.640
#> SRR886611 5 0.548 0.257 0.000 0.372 0.008 NA 0.568
#> SRR886612 5 0.548 0.257 0.000 0.372 0.008 NA 0.568
#> SRR886613 5 0.548 0.257 0.000 0.372 0.008 NA 0.568
#> SRR886614 3 0.375 0.793 0.020 0.000 0.832 NA 0.104
#> SRR886615 3 0.375 0.793 0.020 0.000 0.832 NA 0.104
#> SRR886616 3 0.375 0.793 0.020 0.000 0.832 NA 0.104
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.2334 0.79014 0.904 0.000 0.044 0.008 0.004 NA
#> SRR886566 1 0.2334 0.79014 0.904 0.000 0.044 0.008 0.004 NA
#> SRR886567 1 0.2334 0.79014 0.904 0.000 0.044 0.008 0.004 NA
#> SRR886568 3 0.3347 0.76614 0.040 0.000 0.848 0.036 0.004 NA
#> SRR886569 3 0.3347 0.76614 0.040 0.000 0.848 0.036 0.004 NA
#> SRR886570 3 0.3347 0.76614 0.040 0.000 0.848 0.036 0.004 NA
#> SRR886571 1 0.2719 0.74313 0.876 0.000 0.000 0.072 0.012 NA
#> SRR886572 1 0.2719 0.74313 0.876 0.000 0.000 0.072 0.012 NA
#> SRR886573 1 0.2719 0.74313 0.876 0.000 0.000 0.072 0.012 NA
#> SRR886574 1 0.4785 0.69912 0.724 0.000 0.028 0.084 0.004 NA
#> SRR886575 1 0.4785 0.69912 0.724 0.000 0.028 0.084 0.004 NA
#> SRR886576 1 0.4905 0.69923 0.724 0.000 0.028 0.080 0.012 NA
#> SRR886577 1 0.0692 0.81348 0.976 0.000 0.020 0.000 0.004 NA
#> SRR886578 1 0.0692 0.81348 0.976 0.000 0.020 0.000 0.004 NA
#> SRR886579 1 0.0692 0.81348 0.976 0.000 0.020 0.000 0.004 NA
#> SRR886580 2 0.4407 0.64943 0.000 0.692 0.000 0.076 0.000 NA
#> SRR886581 2 0.4407 0.64943 0.000 0.692 0.000 0.076 0.000 NA
#> SRR886582 2 0.4431 0.64954 0.000 0.692 0.000 0.080 0.000 NA
#> SRR886583 4 0.4933 0.95647 0.404 0.000 0.004 0.536 0.000 NA
#> SRR886584 4 0.4933 0.95647 0.404 0.000 0.004 0.536 0.000 NA
#> SRR886585 4 0.4933 0.95647 0.404 0.000 0.004 0.536 0.000 NA
#> SRR886586 2 0.5049 0.63951 0.000 0.684 0.004 0.016 0.112 NA
#> SRR886587 2 0.5049 0.63951 0.000 0.684 0.004 0.016 0.112 NA
#> SRR886588 2 0.5049 0.63951 0.000 0.684 0.004 0.016 0.112 NA
#> SRR886589 3 0.2010 0.79657 0.036 0.000 0.920 0.004 0.036 NA
#> SRR886590 3 0.2010 0.79657 0.036 0.000 0.920 0.004 0.036 NA
#> SRR886591 3 0.2010 0.79657 0.036 0.000 0.920 0.004 0.036 NA
#> SRR886592 2 0.5634 0.55016 0.000 0.500 0.000 0.000 0.164 NA
#> SRR886593 2 0.5634 0.55016 0.000 0.500 0.000 0.000 0.164 NA
#> SRR886594 2 0.5755 0.55023 0.000 0.500 0.000 0.004 0.164 NA
#> SRR886595 2 0.1080 0.69334 0.000 0.960 0.000 0.032 0.004 NA
#> SRR886596 2 0.1080 0.69334 0.000 0.960 0.000 0.032 0.004 NA
#> SRR886597 2 0.1080 0.69334 0.000 0.960 0.000 0.032 0.004 NA
#> SRR886598 2 0.4660 0.61549 0.000 0.744 0.004 0.032 0.128 NA
#> SRR886599 2 0.4660 0.61549 0.000 0.744 0.004 0.032 0.128 NA
#> SRR886600 2 0.4660 0.61549 0.000 0.744 0.004 0.032 0.128 NA
#> SRR886601 2 0.4660 0.61549 0.000 0.744 0.004 0.032 0.128 NA
#> SRR886602 4 0.3756 0.95651 0.400 0.000 0.000 0.600 0.000 NA
#> SRR886603 4 0.3756 0.95651 0.400 0.000 0.000 0.600 0.000 NA
#> SRR886604 4 0.3756 0.95651 0.400 0.000 0.000 0.600 0.000 NA
#> SRR886605 5 0.6262 -0.00416 0.000 0.000 0.372 0.132 0.456 NA
#> SRR886606 5 0.6262 -0.00416 0.000 0.000 0.372 0.132 0.456 NA
#> SRR886607 5 0.6287 -0.00489 0.000 0.000 0.372 0.128 0.456 NA
#> SRR886608 5 0.2630 0.51785 0.000 0.032 0.092 0.004 0.872 NA
#> SRR886609 5 0.2630 0.51785 0.000 0.032 0.092 0.004 0.872 NA
#> SRR886610 5 0.2630 0.51785 0.000 0.032 0.092 0.004 0.872 NA
#> SRR886611 5 0.5363 0.08350 0.000 0.300 0.000 0.008 0.580 NA
#> SRR886612 5 0.5363 0.08350 0.000 0.300 0.000 0.008 0.580 NA
#> SRR886613 5 0.5363 0.08350 0.000 0.300 0.000 0.008 0.580 NA
#> SRR886614 3 0.5596 0.64100 0.008 0.000 0.668 0.076 0.172 NA
#> SRR886615 3 0.5596 0.64100 0.008 0.000 0.668 0.076 0.172 NA
#> SRR886616 3 0.5595 0.64087 0.008 0.000 0.668 0.072 0.172 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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 1.000 1.000 0.5095 0.491 0.491
#> 3 3 1.000 0.984 0.988 0.1741 0.889 0.777
#> 4 4 0.946 0.972 0.964 0.0802 0.952 0.879
#> 5 5 0.872 0.912 0.909 0.0683 0.993 0.980
#> 6 6 0.875 0.899 0.880 0.0554 0.959 0.880
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 4
#> attr(,"optional")
#> [1] 2 3
There is also optional best \(k\) = 2 3 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR886565 1 0 1 1 0
#> SRR886566 1 0 1 1 0
#> SRR886567 1 0 1 1 0
#> SRR886568 1 0 1 1 0
#> SRR886569 1 0 1 1 0
#> SRR886570 1 0 1 1 0
#> SRR886571 1 0 1 1 0
#> SRR886572 1 0 1 1 0
#> SRR886573 1 0 1 1 0
#> SRR886574 1 0 1 1 0
#> SRR886575 1 0 1 1 0
#> SRR886576 1 0 1 1 0
#> SRR886577 1 0 1 1 0
#> SRR886578 1 0 1 1 0
#> SRR886579 1 0 1 1 0
#> SRR886580 2 0 1 0 1
#> SRR886581 2 0 1 0 1
#> SRR886582 2 0 1 0 1
#> SRR886583 1 0 1 1 0
#> SRR886584 1 0 1 1 0
#> SRR886585 1 0 1 1 0
#> SRR886586 2 0 1 0 1
#> SRR886587 2 0 1 0 1
#> SRR886588 2 0 1 0 1
#> SRR886589 1 0 1 1 0
#> SRR886590 1 0 1 1 0
#> SRR886591 1 0 1 1 0
#> SRR886592 2 0 1 0 1
#> SRR886593 2 0 1 0 1
#> SRR886594 2 0 1 0 1
#> SRR886595 2 0 1 0 1
#> SRR886596 2 0 1 0 1
#> SRR886597 2 0 1 0 1
#> SRR886598 2 0 1 0 1
#> SRR886599 2 0 1 0 1
#> SRR886600 2 0 1 0 1
#> SRR886601 2 0 1 0 1
#> SRR886602 1 0 1 1 0
#> SRR886603 1 0 1 1 0
#> SRR886604 1 0 1 1 0
#> SRR886605 2 0 1 0 1
#> SRR886606 2 0 1 0 1
#> SRR886607 2 0 1 0 1
#> SRR886608 2 0 1 0 1
#> SRR886609 2 0 1 0 1
#> SRR886610 2 0 1 0 1
#> SRR886611 2 0 1 0 1
#> SRR886612 2 0 1 0 1
#> SRR886613 2 0 1 0 1
#> SRR886614 1 0 1 1 0
#> SRR886615 1 0 1 1 0
#> SRR886616 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886566 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886567 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886568 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886569 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886570 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886571 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886572 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886573 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886574 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886575 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886576 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886577 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886578 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886579 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886580 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886581 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886582 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886583 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886584 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886585 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886586 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886587 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886588 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886589 1 0.0237 0.996 0.996 0.0 0.004
#> SRR886590 1 0.0237 0.996 0.996 0.0 0.004
#> SRR886591 1 0.0237 0.996 0.996 0.0 0.004
#> SRR886592 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886593 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886594 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886595 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886596 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886597 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886598 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886599 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886600 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886601 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886602 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886603 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886604 1 0.0000 0.999 1.000 0.0 0.000
#> SRR886605 3 0.4555 0.850 0.000 0.2 0.800
#> SRR886606 3 0.4555 0.850 0.000 0.2 0.800
#> SRR886607 3 0.4555 0.850 0.000 0.2 0.800
#> SRR886608 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886609 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886610 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886611 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886612 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886613 2 0.0000 1.000 0.000 1.0 0.000
#> SRR886614 3 0.0000 0.876 0.000 0.0 1.000
#> SRR886615 3 0.0000 0.876 0.000 0.0 1.000
#> SRR886616 3 0.0000 0.876 0.000 0.0 1.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886568 4 0.3907 1.000 0.232 0.000 0.000 0.768
#> SRR886569 4 0.3907 1.000 0.232 0.000 0.000 0.768
#> SRR886570 4 0.3907 1.000 0.232 0.000 0.000 0.768
#> SRR886571 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886574 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886575 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886576 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886577 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886580 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886581 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886582 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886583 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886584 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886585 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886586 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886587 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886588 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886589 1 0.1118 0.956 0.964 0.000 0.000 0.036
#> SRR886590 1 0.1118 0.956 0.964 0.000 0.000 0.036
#> SRR886591 1 0.1118 0.956 0.964 0.000 0.000 0.036
#> SRR886592 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886593 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886594 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886595 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886596 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886597 2 0.0000 0.986 0.000 1.000 0.000 0.000
#> SRR886598 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886599 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886600 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886601 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886602 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886603 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886604 1 0.0000 0.993 1.000 0.000 0.000 0.000
#> SRR886605 3 0.1637 0.864 0.000 0.060 0.940 0.000
#> SRR886606 3 0.1637 0.864 0.000 0.060 0.940 0.000
#> SRR886607 3 0.1637 0.864 0.000 0.060 0.940 0.000
#> SRR886608 2 0.1302 0.975 0.000 0.956 0.000 0.044
#> SRR886609 2 0.1302 0.975 0.000 0.956 0.000 0.044
#> SRR886610 2 0.1302 0.975 0.000 0.956 0.000 0.044
#> SRR886611 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886612 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886613 2 0.0921 0.983 0.000 0.972 0.000 0.028
#> SRR886614 3 0.3528 0.863 0.000 0.000 0.808 0.192
#> SRR886615 3 0.3528 0.863 0.000 0.000 0.808 0.192
#> SRR886616 3 0.3528 0.863 0.000 0.000 0.808 0.192
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886566 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886567 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886568 4 0.0794 1.000 0.028 0.000 0.000 0.972 0.000
#> SRR886569 4 0.0794 1.000 0.028 0.000 0.000 0.972 0.000
#> SRR886570 4 0.0794 1.000 0.028 0.000 0.000 0.972 0.000
#> SRR886571 1 0.0162 0.959 0.996 0.000 0.004 0.000 0.000
#> SRR886572 1 0.0162 0.959 0.996 0.000 0.004 0.000 0.000
#> SRR886573 1 0.0162 0.959 0.996 0.000 0.004 0.000 0.000
#> SRR886574 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886575 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886576 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886577 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886578 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886579 1 0.0000 0.959 1.000 0.000 0.000 0.000 0.000
#> SRR886580 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886581 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886582 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886583 1 0.0290 0.958 0.992 0.000 0.008 0.000 0.000
#> SRR886584 1 0.0290 0.958 0.992 0.000 0.008 0.000 0.000
#> SRR886585 1 0.0290 0.958 0.992 0.000 0.008 0.000 0.000
#> SRR886586 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886587 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886588 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886589 1 0.4814 0.722 0.748 0.000 0.164 0.068 0.020
#> SRR886590 1 0.4814 0.722 0.748 0.000 0.164 0.068 0.020
#> SRR886591 1 0.4814 0.722 0.748 0.000 0.164 0.068 0.020
#> SRR886592 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886593 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886594 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886595 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886596 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886597 2 0.0000 0.899 0.000 1.000 0.000 0.000 0.000
#> SRR886598 2 0.2690 0.872 0.000 0.844 0.156 0.000 0.000
#> SRR886599 2 0.2690 0.872 0.000 0.844 0.156 0.000 0.000
#> SRR886600 2 0.2690 0.872 0.000 0.844 0.156 0.000 0.000
#> SRR886601 2 0.2690 0.872 0.000 0.844 0.156 0.000 0.000
#> SRR886602 1 0.0290 0.958 0.992 0.000 0.008 0.000 0.000
#> SRR886603 1 0.0290 0.958 0.992 0.000 0.008 0.000 0.000
#> SRR886604 1 0.0290 0.958 0.992 0.000 0.008 0.000 0.000
#> SRR886605 3 0.4744 1.000 0.000 0.000 0.508 0.016 0.476
#> SRR886606 3 0.4744 1.000 0.000 0.000 0.508 0.016 0.476
#> SRR886607 3 0.4744 1.000 0.000 0.000 0.508 0.016 0.476
#> SRR886608 2 0.4387 0.725 0.000 0.640 0.348 0.012 0.000
#> SRR886609 2 0.4387 0.725 0.000 0.640 0.348 0.012 0.000
#> SRR886610 2 0.4387 0.725 0.000 0.640 0.348 0.012 0.000
#> SRR886611 2 0.3074 0.856 0.000 0.804 0.196 0.000 0.000
#> SRR886612 2 0.3074 0.856 0.000 0.804 0.196 0.000 0.000
#> SRR886613 2 0.3074 0.856 0.000 0.804 0.196 0.000 0.000
#> SRR886614 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR886615 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR886616 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0146 0.982 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR886566 1 0.0146 0.982 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR886567 1 0.0146 0.982 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR886568 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886569 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886570 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR886571 1 0.0260 0.982 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR886572 1 0.0260 0.982 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR886573 1 0.0260 0.982 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR886574 1 0.0603 0.973 0.980 0.000 0.000 0.000 0.004 0.016
#> SRR886575 1 0.0603 0.973 0.980 0.000 0.000 0.000 0.004 0.016
#> SRR886576 1 0.0603 0.973 0.980 0.000 0.000 0.000 0.004 0.016
#> SRR886577 1 0.0260 0.980 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR886578 1 0.0260 0.980 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR886579 1 0.0260 0.980 0.992 0.000 0.000 0.000 0.000 0.008
#> SRR886580 2 0.3101 0.839 0.000 0.756 0.000 0.000 0.244 0.000
#> SRR886581 2 0.3101 0.839 0.000 0.756 0.000 0.000 0.244 0.000
#> SRR886582 2 0.3101 0.839 0.000 0.756 0.000 0.000 0.244 0.000
#> SRR886583 1 0.0717 0.977 0.976 0.000 0.000 0.000 0.016 0.008
#> SRR886584 1 0.0717 0.977 0.976 0.000 0.000 0.000 0.016 0.008
#> SRR886585 1 0.0717 0.977 0.976 0.000 0.000 0.000 0.016 0.008
#> SRR886586 2 0.3151 0.839 0.000 0.748 0.000 0.000 0.252 0.000
#> SRR886587 2 0.3151 0.839 0.000 0.748 0.000 0.000 0.252 0.000
#> SRR886588 2 0.3151 0.839 0.000 0.748 0.000 0.000 0.252 0.000
#> SRR886589 6 0.3457 1.000 0.232 0.000 0.000 0.016 0.000 0.752
#> SRR886590 6 0.3457 1.000 0.232 0.000 0.000 0.016 0.000 0.752
#> SRR886591 6 0.3457 1.000 0.232 0.000 0.000 0.016 0.000 0.752
#> SRR886592 2 0.3151 0.839 0.000 0.748 0.000 0.000 0.252 0.000
#> SRR886593 2 0.3151 0.839 0.000 0.748 0.000 0.000 0.252 0.000
#> SRR886594 2 0.3151 0.839 0.000 0.748 0.000 0.000 0.252 0.000
#> SRR886595 2 0.3101 0.839 0.000 0.756 0.000 0.000 0.244 0.000
#> SRR886596 2 0.3101 0.839 0.000 0.756 0.000 0.000 0.244 0.000
#> SRR886597 2 0.3101 0.839 0.000 0.756 0.000 0.000 0.244 0.000
#> SRR886598 2 0.0000 0.793 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886599 2 0.0000 0.793 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886600 2 0.0000 0.793 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886601 2 0.0000 0.793 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR886602 1 0.0717 0.977 0.976 0.000 0.000 0.000 0.016 0.008
#> SRR886603 1 0.0717 0.977 0.976 0.000 0.000 0.000 0.016 0.008
#> SRR886604 1 0.0717 0.977 0.976 0.000 0.000 0.000 0.016 0.008
#> SRR886605 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886606 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886607 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR886608 2 0.4803 0.526 0.000 0.684 0.004 0.000 0.144 0.168
#> SRR886609 2 0.4803 0.526 0.000 0.684 0.004 0.000 0.144 0.168
#> SRR886610 2 0.4803 0.526 0.000 0.684 0.004 0.000 0.144 0.168
#> SRR886611 2 0.1168 0.775 0.000 0.956 0.000 0.000 0.028 0.016
#> SRR886612 2 0.1168 0.775 0.000 0.956 0.000 0.000 0.028 0.016
#> SRR886613 2 0.1168 0.775 0.000 0.956 0.000 0.000 0.028 0.016
#> SRR886614 5 0.5044 1.000 0.000 0.000 0.320 0.000 0.584 0.096
#> SRR886615 5 0.5044 1.000 0.000 0.000 0.320 0.000 0.584 0.096
#> SRR886616 5 0.5044 1.000 0.000 0.000 0.320 0.000 0.584 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.980 0.990 0.5092 0.491 0.491
#> 3 3 1.000 1.000 1.000 0.2980 0.808 0.624
#> 4 4 0.857 0.882 0.923 0.1318 0.910 0.733
#> 5 5 0.857 0.881 0.923 0.0725 0.946 0.782
#> 6 6 0.944 0.875 0.939 0.0440 0.910 0.592
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
#> SRR886565 1 0.000 0.980 1.000 0.000
#> SRR886566 1 0.000 0.980 1.000 0.000
#> SRR886567 1 0.000 0.980 1.000 0.000
#> SRR886568 1 0.000 0.980 1.000 0.000
#> SRR886569 1 0.000 0.980 1.000 0.000
#> SRR886570 1 0.000 0.980 1.000 0.000
#> SRR886571 1 0.000 0.980 1.000 0.000
#> SRR886572 1 0.000 0.980 1.000 0.000
#> SRR886573 1 0.000 0.980 1.000 0.000
#> SRR886574 1 0.000 0.980 1.000 0.000
#> SRR886575 1 0.000 0.980 1.000 0.000
#> SRR886576 1 0.000 0.980 1.000 0.000
#> SRR886577 1 0.000 0.980 1.000 0.000
#> SRR886578 1 0.000 0.980 1.000 0.000
#> SRR886579 1 0.000 0.980 1.000 0.000
#> SRR886580 2 0.000 1.000 0.000 1.000
#> SRR886581 2 0.000 1.000 0.000 1.000
#> SRR886582 2 0.000 1.000 0.000 1.000
#> SRR886583 1 0.000 0.980 1.000 0.000
#> SRR886584 1 0.000 0.980 1.000 0.000
#> SRR886585 1 0.000 0.980 1.000 0.000
#> SRR886586 2 0.000 1.000 0.000 1.000
#> SRR886587 2 0.000 1.000 0.000 1.000
#> SRR886588 2 0.000 1.000 0.000 1.000
#> SRR886589 1 0.000 0.980 1.000 0.000
#> SRR886590 1 0.000 0.980 1.000 0.000
#> SRR886591 1 0.000 0.980 1.000 0.000
#> SRR886592 2 0.000 1.000 0.000 1.000
#> SRR886593 2 0.000 1.000 0.000 1.000
#> SRR886594 2 0.000 1.000 0.000 1.000
#> SRR886595 2 0.000 1.000 0.000 1.000
#> SRR886596 2 0.000 1.000 0.000 1.000
#> SRR886597 2 0.000 1.000 0.000 1.000
#> SRR886598 2 0.000 1.000 0.000 1.000
#> SRR886599 2 0.000 1.000 0.000 1.000
#> SRR886600 2 0.000 1.000 0.000 1.000
#> SRR886601 2 0.000 1.000 0.000 1.000
#> SRR886602 1 0.000 0.980 1.000 0.000
#> SRR886603 1 0.000 0.980 1.000 0.000
#> SRR886604 1 0.000 0.980 1.000 0.000
#> SRR886605 2 0.000 1.000 0.000 1.000
#> SRR886606 2 0.000 1.000 0.000 1.000
#> SRR886607 2 0.000 1.000 0.000 1.000
#> SRR886608 2 0.000 1.000 0.000 1.000
#> SRR886609 2 0.000 1.000 0.000 1.000
#> SRR886610 2 0.000 1.000 0.000 1.000
#> SRR886611 2 0.000 1.000 0.000 1.000
#> SRR886612 2 0.000 1.000 0.000 1.000
#> SRR886613 2 0.000 1.000 0.000 1.000
#> SRR886614 1 0.653 0.813 0.832 0.168
#> SRR886615 1 0.634 0.823 0.840 0.160
#> SRR886616 1 0.680 0.797 0.820 0.180
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0 1 1 0 0
#> SRR886566 1 0 1 1 0 0
#> SRR886567 1 0 1 1 0 0
#> SRR886568 3 0 1 0 0 1
#> SRR886569 3 0 1 0 0 1
#> SRR886570 3 0 1 0 0 1
#> SRR886571 1 0 1 1 0 0
#> SRR886572 1 0 1 1 0 0
#> SRR886573 1 0 1 1 0 0
#> SRR886574 1 0 1 1 0 0
#> SRR886575 1 0 1 1 0 0
#> SRR886576 1 0 1 1 0 0
#> SRR886577 1 0 1 1 0 0
#> SRR886578 1 0 1 1 0 0
#> SRR886579 1 0 1 1 0 0
#> SRR886580 2 0 1 0 1 0
#> SRR886581 2 0 1 0 1 0
#> SRR886582 2 0 1 0 1 0
#> SRR886583 1 0 1 1 0 0
#> SRR886584 1 0 1 1 0 0
#> SRR886585 1 0 1 1 0 0
#> SRR886586 2 0 1 0 1 0
#> SRR886587 2 0 1 0 1 0
#> SRR886588 2 0 1 0 1 0
#> SRR886589 3 0 1 0 0 1
#> SRR886590 3 0 1 0 0 1
#> SRR886591 3 0 1 0 0 1
#> SRR886592 2 0 1 0 1 0
#> SRR886593 2 0 1 0 1 0
#> SRR886594 2 0 1 0 1 0
#> SRR886595 2 0 1 0 1 0
#> SRR886596 2 0 1 0 1 0
#> SRR886597 2 0 1 0 1 0
#> SRR886598 2 0 1 0 1 0
#> SRR886599 2 0 1 0 1 0
#> SRR886600 2 0 1 0 1 0
#> SRR886601 2 0 1 0 1 0
#> SRR886602 1 0 1 1 0 0
#> SRR886603 1 0 1 1 0 0
#> SRR886604 1 0 1 1 0 0
#> SRR886605 3 0 1 0 0 1
#> SRR886606 3 0 1 0 0 1
#> SRR886607 3 0 1 0 0 1
#> SRR886608 2 0 1 0 1 0
#> SRR886609 2 0 1 0 1 0
#> SRR886610 2 0 1 0 1 0
#> SRR886611 2 0 1 0 1 0
#> SRR886612 2 0 1 0 1 0
#> SRR886613 2 0 1 0 1 0
#> SRR886614 3 0 1 0 0 1
#> SRR886615 3 0 1 0 0 1
#> SRR886616 3 0 1 0 0 1
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886566 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886567 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886568 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886569 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886570 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886571 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886572 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886573 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886574 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886575 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886576 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886577 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886578 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886579 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886580 4 0.365 0.866 0 0.204 0.0 0.796
#> SRR886581 4 0.365 0.866 0 0.204 0.0 0.796
#> SRR886582 4 0.365 0.866 0 0.204 0.0 0.796
#> SRR886583 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886584 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886585 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886586 2 0.361 0.691 0 0.800 0.0 0.200
#> SRR886587 2 0.361 0.691 0 0.800 0.0 0.200
#> SRR886588 2 0.361 0.691 0 0.800 0.0 0.200
#> SRR886589 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886590 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886591 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886592 2 0.361 0.691 0 0.800 0.0 0.200
#> SRR886593 2 0.361 0.691 0 0.800 0.0 0.200
#> SRR886594 2 0.361 0.691 0 0.800 0.0 0.200
#> SRR886595 4 0.365 0.866 0 0.204 0.0 0.796
#> SRR886596 4 0.365 0.866 0 0.204 0.0 0.796
#> SRR886597 4 0.365 0.866 0 0.204 0.0 0.796
#> SRR886598 4 0.000 0.791 0 0.000 0.0 1.000
#> SRR886599 4 0.000 0.791 0 0.000 0.0 1.000
#> SRR886600 4 0.000 0.791 0 0.000 0.0 1.000
#> SRR886601 4 0.000 0.791 0 0.000 0.0 1.000
#> SRR886602 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886603 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886604 1 0.000 1.000 1 0.000 0.0 0.000
#> SRR886605 3 0.361 0.830 0 0.200 0.8 0.000
#> SRR886606 3 0.361 0.830 0 0.200 0.8 0.000
#> SRR886607 3 0.361 0.830 0 0.200 0.8 0.000
#> SRR886608 2 0.365 0.717 0 0.796 0.0 0.204
#> SRR886609 2 0.365 0.717 0 0.796 0.0 0.204
#> SRR886610 2 0.365 0.717 0 0.796 0.0 0.204
#> SRR886611 2 0.398 0.727 0 0.760 0.0 0.240
#> SRR886612 2 0.436 0.720 0 0.708 0.0 0.292
#> SRR886613 2 0.387 0.725 0 0.772 0.0 0.228
#> SRR886614 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886615 3 0.000 0.949 0 0.000 1.0 0.000
#> SRR886616 3 0.000 0.949 0 0.000 1.0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886566 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886567 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886568 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886569 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886570 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886571 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886572 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886573 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886574 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886575 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886576 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886577 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886578 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886579 1 0.0000 1.000 1 0.000 0.0 0 0.000
#> SRR886580 2 0.0000 0.866 0 1.000 0.0 0 0.000
#> SRR886581 2 0.0000 0.866 0 1.000 0.0 0 0.000
#> SRR886582 2 0.0000 0.866 0 1.000 0.0 0 0.000
#> SRR886583 4 0.0000 1.000 0 0.000 0.0 1 0.000
#> SRR886584 4 0.0000 1.000 0 0.000 0.0 1 0.000
#> SRR886585 4 0.0000 1.000 0 0.000 0.0 1 0.000
#> SRR886586 5 0.4192 0.691 0 0.404 0.0 0 0.596
#> SRR886587 5 0.4192 0.691 0 0.404 0.0 0 0.596
#> SRR886588 5 0.4192 0.691 0 0.404 0.0 0 0.596
#> SRR886589 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886590 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886591 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886592 5 0.4192 0.691 0 0.404 0.0 0 0.596
#> SRR886593 5 0.4192 0.691 0 0.404 0.0 0 0.596
#> SRR886594 5 0.4192 0.691 0 0.404 0.0 0 0.596
#> SRR886595 2 0.0000 0.866 0 1.000 0.0 0 0.000
#> SRR886596 2 0.0000 0.866 0 1.000 0.0 0 0.000
#> SRR886597 2 0.0000 0.866 0 1.000 0.0 0 0.000
#> SRR886598 2 0.3143 0.791 0 0.796 0.0 0 0.204
#> SRR886599 2 0.3143 0.791 0 0.796 0.0 0 0.204
#> SRR886600 2 0.3143 0.791 0 0.796 0.0 0 0.204
#> SRR886601 2 0.3143 0.791 0 0.796 0.0 0 0.204
#> SRR886602 4 0.0000 1.000 0 0.000 0.0 1 0.000
#> SRR886603 4 0.0000 1.000 0 0.000 0.0 1 0.000
#> SRR886604 4 0.0000 1.000 0 0.000 0.0 1 0.000
#> SRR886605 3 0.3109 0.827 0 0.000 0.8 0 0.200
#> SRR886606 3 0.3109 0.827 0 0.000 0.8 0 0.200
#> SRR886607 3 0.3109 0.827 0 0.000 0.8 0 0.200
#> SRR886608 5 0.0000 0.717 0 0.000 0.0 0 1.000
#> SRR886609 5 0.0000 0.717 0 0.000 0.0 0 1.000
#> SRR886610 5 0.0000 0.717 0 0.000 0.0 0 1.000
#> SRR886611 5 0.0963 0.727 0 0.036 0.0 0 0.964
#> SRR886612 5 0.1851 0.720 0 0.088 0.0 0 0.912
#> SRR886613 5 0.0703 0.725 0 0.024 0.0 0 0.976
#> SRR886614 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886615 3 0.0000 0.946 0 0.000 1.0 0 0.000
#> SRR886616 3 0.0000 0.946 0 0.000 1.0 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886566 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886567 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886568 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886569 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886570 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886571 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886572 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886573 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886574 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886575 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886576 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886577 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886578 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886579 1 0.0000 1.000 1 0.000 0.000 0 0.000 0.000
#> SRR886580 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886581 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886582 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886583 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR886584 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR886585 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR886586 2 0.0000 0.817 0 1.000 0.000 0 0.000 0.000
#> SRR886587 2 0.0000 0.817 0 1.000 0.000 0 0.000 0.000
#> SRR886588 2 0.0000 0.817 0 1.000 0.000 0 0.000 0.000
#> SRR886589 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886590 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886591 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886592 2 0.0000 0.817 0 1.000 0.000 0 0.000 0.000
#> SRR886593 2 0.0000 0.817 0 1.000 0.000 0 0.000 0.000
#> SRR886594 2 0.0000 0.817 0 1.000 0.000 0 0.000 0.000
#> SRR886595 2 0.3727 0.506 0 0.612 0.000 0 0.000 0.388
#> SRR886596 2 0.3756 0.488 0 0.600 0.000 0 0.000 0.400
#> SRR886597 2 0.3756 0.488 0 0.600 0.000 0 0.000 0.400
#> SRR886598 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886599 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886600 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886601 6 0.0000 1.000 0 0.000 0.000 0 0.000 1.000
#> SRR886602 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR886603 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR886604 4 0.0000 1.000 0 0.000 0.000 1 0.000 0.000
#> SRR886605 5 0.3828 0.306 0 0.000 0.440 0 0.560 0.000
#> SRR886606 5 0.3833 0.296 0 0.000 0.444 0 0.556 0.000
#> SRR886607 5 0.3765 0.375 0 0.000 0.404 0 0.596 0.000
#> SRR886608 5 0.0865 0.725 0 0.036 0.000 0 0.964 0.000
#> SRR886609 5 0.0865 0.725 0 0.036 0.000 0 0.964 0.000
#> SRR886610 5 0.0865 0.725 0 0.036 0.000 0 0.964 0.000
#> SRR886611 5 0.3071 0.666 0 0.180 0.000 0 0.804 0.016
#> SRR886612 5 0.3189 0.619 0 0.236 0.000 0 0.760 0.004
#> SRR886613 5 0.2703 0.676 0 0.172 0.000 0 0.824 0.004
#> SRR886614 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886615 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
#> SRR886616 3 0.0000 1.000 0 0.000 1.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 0.683 0.961 0.950 0.4751 0.493 0.493
#> 3 3 0.582 0.690 0.784 0.2794 0.738 0.543
#> 4 4 0.713 0.711 0.892 0.1581 0.771 0.495
#> 5 5 0.760 0.717 0.879 0.1038 0.869 0.590
#> 6 6 0.890 0.912 0.937 0.0552 0.946 0.765
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
#> SRR886565 1 0.295 0.984 0.948 0.052
#> SRR886566 1 0.295 0.984 0.948 0.052
#> SRR886567 1 0.295 0.984 0.948 0.052
#> SRR886568 1 0.295 0.984 0.948 0.052
#> SRR886569 1 0.295 0.984 0.948 0.052
#> SRR886570 1 0.295 0.984 0.948 0.052
#> SRR886571 1 0.295 0.984 0.948 0.052
#> SRR886572 1 0.295 0.984 0.948 0.052
#> SRR886573 1 0.295 0.984 0.948 0.052
#> SRR886574 1 0.295 0.984 0.948 0.052
#> SRR886575 1 0.295 0.984 0.948 0.052
#> SRR886576 1 0.295 0.984 0.948 0.052
#> SRR886577 1 0.295 0.984 0.948 0.052
#> SRR886578 1 0.295 0.984 0.948 0.052
#> SRR886579 1 0.295 0.984 0.948 0.052
#> SRR886580 2 0.000 0.932 0.000 1.000
#> SRR886581 2 0.000 0.932 0.000 1.000
#> SRR886582 2 0.000 0.932 0.000 1.000
#> SRR886583 1 0.000 0.954 1.000 0.000
#> SRR886584 1 0.000 0.954 1.000 0.000
#> SRR886585 1 0.000 0.954 1.000 0.000
#> SRR886586 2 0.430 0.958 0.088 0.912
#> SRR886587 2 0.430 0.958 0.088 0.912
#> SRR886588 2 0.430 0.958 0.088 0.912
#> SRR886589 1 0.295 0.984 0.948 0.052
#> SRR886590 1 0.295 0.984 0.948 0.052
#> SRR886591 1 0.295 0.984 0.948 0.052
#> SRR886592 2 0.430 0.958 0.088 0.912
#> SRR886593 2 0.430 0.958 0.088 0.912
#> SRR886594 2 0.430 0.958 0.088 0.912
#> SRR886595 2 0.000 0.932 0.000 1.000
#> SRR886596 2 0.000 0.932 0.000 1.000
#> SRR886597 2 0.000 0.932 0.000 1.000
#> SRR886598 2 0.000 0.932 0.000 1.000
#> SRR886599 2 0.000 0.932 0.000 1.000
#> SRR886600 2 0.000 0.932 0.000 1.000
#> SRR886601 2 0.000 0.932 0.000 1.000
#> SRR886602 1 0.000 0.954 1.000 0.000
#> SRR886603 1 0.000 0.954 1.000 0.000
#> SRR886604 1 0.000 0.954 1.000 0.000
#> SRR886605 2 0.469 0.951 0.100 0.900
#> SRR886606 2 0.469 0.951 0.100 0.900
#> SRR886607 2 0.469 0.951 0.100 0.900
#> SRR886608 2 0.430 0.958 0.088 0.912
#> SRR886609 2 0.430 0.958 0.088 0.912
#> SRR886610 2 0.430 0.958 0.088 0.912
#> SRR886611 2 0.430 0.958 0.088 0.912
#> SRR886612 2 0.430 0.958 0.088 0.912
#> SRR886613 2 0.430 0.958 0.088 0.912
#> SRR886614 2 0.494 0.945 0.108 0.892
#> SRR886615 2 0.494 0.945 0.108 0.892
#> SRR886616 2 0.494 0.945 0.108 0.892
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.0000 0.704 1.000 0.000 0.000
#> SRR886566 1 0.0000 0.704 1.000 0.000 0.000
#> SRR886567 1 0.0000 0.704 1.000 0.000 0.000
#> SRR886568 1 0.1989 0.704 0.948 0.048 0.004
#> SRR886569 1 0.1989 0.704 0.948 0.048 0.004
#> SRR886570 1 0.1989 0.704 0.948 0.048 0.004
#> SRR886571 1 0.0237 0.700 0.996 0.000 0.004
#> SRR886572 1 0.0237 0.700 0.996 0.000 0.004
#> SRR886573 1 0.0237 0.700 0.996 0.000 0.004
#> SRR886574 1 0.2301 0.693 0.936 0.060 0.004
#> SRR886575 1 0.2301 0.693 0.936 0.060 0.004
#> SRR886576 1 0.2301 0.693 0.936 0.060 0.004
#> SRR886577 1 0.0000 0.704 1.000 0.000 0.000
#> SRR886578 1 0.0000 0.704 1.000 0.000 0.000
#> SRR886579 1 0.0000 0.704 1.000 0.000 0.000
#> SRR886580 2 0.1289 0.793 0.000 0.968 0.032
#> SRR886581 2 0.1289 0.793 0.000 0.968 0.032
#> SRR886582 2 0.1289 0.793 0.000 0.968 0.032
#> SRR886583 3 0.6713 1.000 0.416 0.012 0.572
#> SRR886584 3 0.6713 1.000 0.416 0.012 0.572
#> SRR886585 3 0.6713 1.000 0.416 0.012 0.572
#> SRR886586 2 0.1753 0.788 0.048 0.952 0.000
#> SRR886587 2 0.1753 0.788 0.048 0.952 0.000
#> SRR886588 2 0.1753 0.788 0.048 0.952 0.000
#> SRR886589 1 0.1999 0.705 0.952 0.012 0.036
#> SRR886590 1 0.1999 0.705 0.952 0.012 0.036
#> SRR886591 1 0.1999 0.705 0.952 0.012 0.036
#> SRR886592 2 0.2165 0.779 0.064 0.936 0.000
#> SRR886593 2 0.2165 0.779 0.064 0.936 0.000
#> SRR886594 2 0.2165 0.779 0.064 0.936 0.000
#> SRR886595 2 0.2448 0.785 0.000 0.924 0.076
#> SRR886596 2 0.2448 0.785 0.000 0.924 0.076
#> SRR886597 2 0.2448 0.785 0.000 0.924 0.076
#> SRR886598 2 0.0892 0.791 0.000 0.980 0.020
#> SRR886599 2 0.0747 0.790 0.000 0.984 0.016
#> SRR886600 2 0.0892 0.791 0.000 0.980 0.020
#> SRR886601 2 0.1529 0.793 0.000 0.960 0.040
#> SRR886602 3 0.6713 1.000 0.416 0.012 0.572
#> SRR886603 3 0.6713 1.000 0.416 0.012 0.572
#> SRR886604 3 0.6713 1.000 0.416 0.012 0.572
#> SRR886605 1 0.8737 0.383 0.464 0.108 0.428
#> SRR886606 1 0.8789 0.375 0.460 0.112 0.428
#> SRR886607 1 0.8789 0.375 0.460 0.112 0.428
#> SRR886608 2 0.9642 0.392 0.208 0.416 0.376
#> SRR886609 2 0.9642 0.392 0.208 0.416 0.376
#> SRR886610 2 0.9642 0.392 0.208 0.416 0.376
#> SRR886611 2 0.9645 0.389 0.208 0.412 0.380
#> SRR886612 2 0.9645 0.389 0.208 0.412 0.380
#> SRR886613 2 0.9645 0.389 0.208 0.412 0.380
#> SRR886614 1 0.8683 0.390 0.468 0.104 0.428
#> SRR886615 1 0.8683 0.390 0.468 0.104 0.428
#> SRR886616 1 0.8683 0.390 0.468 0.104 0.428
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886566 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886567 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886568 1 0.0000 0.879 1.000 0.000 0.000 0.000
#> SRR886569 1 0.0000 0.879 1.000 0.000 0.000 0.000
#> SRR886570 1 0.0000 0.879 1.000 0.000 0.000 0.000
#> SRR886571 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886572 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886573 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886574 1 0.3351 0.781 0.844 0.148 0.000 0.008
#> SRR886575 1 0.3351 0.781 0.844 0.148 0.000 0.008
#> SRR886576 1 0.3351 0.781 0.844 0.148 0.000 0.008
#> SRR886577 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886578 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886579 1 0.0336 0.880 0.992 0.000 0.000 0.008
#> SRR886580 2 0.0000 0.838 0.000 1.000 0.000 0.000
#> SRR886581 2 0.0000 0.838 0.000 1.000 0.000 0.000
#> SRR886582 2 0.0000 0.838 0.000 1.000 0.000 0.000
#> SRR886583 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886584 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886585 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886586 2 0.3311 0.701 0.172 0.828 0.000 0.000
#> SRR886587 2 0.3311 0.701 0.172 0.828 0.000 0.000
#> SRR886588 2 0.3311 0.701 0.172 0.828 0.000 0.000
#> SRR886589 1 0.1118 0.860 0.964 0.000 0.036 0.000
#> SRR886590 1 0.1118 0.860 0.964 0.000 0.036 0.000
#> SRR886591 1 0.1118 0.860 0.964 0.000 0.036 0.000
#> SRR886592 1 0.4985 0.237 0.532 0.468 0.000 0.000
#> SRR886593 1 0.4985 0.237 0.532 0.468 0.000 0.000
#> SRR886594 1 0.4985 0.237 0.532 0.468 0.000 0.000
#> SRR886595 2 0.0000 0.838 0.000 1.000 0.000 0.000
#> SRR886596 2 0.0000 0.838 0.000 1.000 0.000 0.000
#> SRR886597 2 0.0000 0.838 0.000 1.000 0.000 0.000
#> SRR886598 2 0.0469 0.835 0.000 0.988 0.012 0.000
#> SRR886599 2 0.0469 0.835 0.000 0.988 0.012 0.000
#> SRR886600 2 0.0469 0.835 0.000 0.988 0.012 0.000
#> SRR886601 2 0.0469 0.835 0.000 0.988 0.012 0.000
#> SRR886602 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886603 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886604 4 0.0000 1.000 0.000 0.000 0.000 1.000
#> SRR886605 3 0.0000 0.694 0.000 0.000 1.000 0.000
#> SRR886606 3 0.0000 0.694 0.000 0.000 1.000 0.000
#> SRR886607 3 0.0000 0.694 0.000 0.000 1.000 0.000
#> SRR886608 3 0.5000 0.201 0.000 0.500 0.500 0.000
#> SRR886609 2 0.5000 -0.329 0.000 0.500 0.500 0.000
#> SRR886610 2 0.5000 -0.329 0.000 0.500 0.500 0.000
#> SRR886611 3 0.5000 0.201 0.000 0.500 0.500 0.000
#> SRR886612 3 0.5000 0.201 0.000 0.500 0.500 0.000
#> SRR886613 3 0.5000 0.201 0.000 0.500 0.500 0.000
#> SRR886614 3 0.0000 0.694 0.000 0.000 1.000 0.000
#> SRR886615 3 0.0000 0.694 0.000 0.000 1.000 0.000
#> SRR886616 3 0.0000 0.694 0.000 0.000 1.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886566 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886567 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886568 1 0.3074 0.8303 0.804 0.196 0.000 0 0.000
#> SRR886569 1 0.3074 0.8303 0.804 0.196 0.000 0 0.000
#> SRR886570 1 0.3074 0.8303 0.804 0.196 0.000 0 0.000
#> SRR886571 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886572 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886573 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886574 2 0.0703 0.8767 0.024 0.976 0.000 0 0.000
#> SRR886575 2 0.0703 0.8767 0.024 0.976 0.000 0 0.000
#> SRR886576 2 0.0703 0.8767 0.024 0.976 0.000 0 0.000
#> SRR886577 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886578 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886579 1 0.0000 0.9086 1.000 0.000 0.000 0 0.000
#> SRR886580 5 0.2971 0.6481 0.000 0.156 0.008 0 0.836
#> SRR886581 5 0.2971 0.6481 0.000 0.156 0.008 0 0.836
#> SRR886582 5 0.2971 0.6481 0.000 0.156 0.008 0 0.836
#> SRR886583 4 0.0000 1.0000 0.000 0.000 0.000 1 0.000
#> SRR886584 4 0.0000 1.0000 0.000 0.000 0.000 1 0.000
#> SRR886585 4 0.0000 1.0000 0.000 0.000 0.000 1 0.000
#> SRR886586 5 0.3966 0.4659 0.000 0.336 0.000 0 0.664
#> SRR886587 5 0.3966 0.4659 0.000 0.336 0.000 0 0.664
#> SRR886588 5 0.3966 0.4659 0.000 0.336 0.000 0 0.664
#> SRR886589 1 0.3535 0.8427 0.808 0.164 0.028 0 0.000
#> SRR886590 1 0.3535 0.8427 0.808 0.164 0.028 0 0.000
#> SRR886591 1 0.3535 0.8427 0.808 0.164 0.028 0 0.000
#> SRR886592 2 0.2561 0.8688 0.000 0.856 0.000 0 0.144
#> SRR886593 2 0.2561 0.8688 0.000 0.856 0.000 0 0.144
#> SRR886594 2 0.2561 0.8688 0.000 0.856 0.000 0 0.144
#> SRR886595 5 0.0290 0.7187 0.000 0.000 0.008 0 0.992
#> SRR886596 5 0.0290 0.7187 0.000 0.000 0.008 0 0.992
#> SRR886597 5 0.0290 0.7187 0.000 0.000 0.008 0 0.992
#> SRR886598 5 0.0703 0.7168 0.000 0.000 0.024 0 0.976
#> SRR886599 5 0.0703 0.7168 0.000 0.000 0.024 0 0.976
#> SRR886600 5 0.0703 0.7168 0.000 0.000 0.024 0 0.976
#> SRR886601 5 0.0703 0.7168 0.000 0.000 0.024 0 0.976
#> SRR886602 4 0.0000 1.0000 0.000 0.000 0.000 1 0.000
#> SRR886603 4 0.0000 1.0000 0.000 0.000 0.000 1 0.000
#> SRR886604 4 0.0000 1.0000 0.000 0.000 0.000 1 0.000
#> SRR886605 3 0.0000 0.8106 0.000 0.000 1.000 0 0.000
#> SRR886606 3 0.0000 0.8106 0.000 0.000 1.000 0 0.000
#> SRR886607 3 0.0000 0.8106 0.000 0.000 1.000 0 0.000
#> SRR886608 3 0.4307 -0.0640 0.000 0.000 0.500 0 0.500
#> SRR886609 3 0.4307 -0.0640 0.000 0.000 0.500 0 0.500
#> SRR886610 5 0.4307 -0.1201 0.000 0.000 0.500 0 0.500
#> SRR886611 5 0.5047 -0.0448 0.000 0.032 0.472 0 0.496
#> SRR886612 5 0.5047 -0.0448 0.000 0.032 0.472 0 0.496
#> SRR886613 5 0.5047 -0.0448 0.000 0.032 0.472 0 0.496
#> SRR886614 3 0.0162 0.8102 0.004 0.000 0.996 0 0.000
#> SRR886615 3 0.0162 0.8102 0.004 0.000 0.996 0 0.000
#> SRR886616 3 0.0162 0.8102 0.004 0.000 0.996 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886566 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886567 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886568 1 0.3011 0.834 0.800 0.000 0.004 0 0.004 0.192
#> SRR886569 1 0.3011 0.834 0.800 0.000 0.004 0 0.004 0.192
#> SRR886570 1 0.3011 0.834 0.800 0.000 0.004 0 0.004 0.192
#> SRR886571 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886572 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886573 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886574 6 0.0777 0.946 0.024 0.000 0.004 0 0.000 0.972
#> SRR886575 6 0.0777 0.946 0.024 0.000 0.004 0 0.000 0.972
#> SRR886576 6 0.0777 0.946 0.024 0.000 0.004 0 0.000 0.972
#> SRR886577 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886578 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886579 1 0.0000 0.911 1.000 0.000 0.000 0 0.000 0.000
#> SRR886580 2 0.2454 0.826 0.000 0.840 0.000 0 0.000 0.160
#> SRR886581 2 0.2454 0.826 0.000 0.840 0.000 0 0.000 0.160
#> SRR886582 2 0.2454 0.826 0.000 0.840 0.000 0 0.000 0.160
#> SRR886583 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR886584 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR886585 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR886586 2 0.4408 0.660 0.000 0.656 0.000 0 0.052 0.292
#> SRR886587 2 0.4408 0.660 0.000 0.656 0.000 0 0.052 0.292
#> SRR886588 2 0.4408 0.660 0.000 0.656 0.000 0 0.052 0.292
#> SRR886589 1 0.3606 0.840 0.800 0.000 0.052 0 0.008 0.140
#> SRR886590 1 0.3606 0.840 0.800 0.000 0.052 0 0.008 0.140
#> SRR886591 1 0.3606 0.840 0.800 0.000 0.052 0 0.008 0.140
#> SRR886592 6 0.1367 0.946 0.000 0.012 0.000 0 0.044 0.944
#> SRR886593 6 0.1367 0.946 0.000 0.012 0.000 0 0.044 0.944
#> SRR886594 6 0.1367 0.946 0.000 0.012 0.000 0 0.044 0.944
#> SRR886595 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886596 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886597 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886598 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886599 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886600 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886601 2 0.0000 0.866 0.000 1.000 0.000 0 0.000 0.000
#> SRR886602 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR886603 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR886604 4 0.0000 1.000 0.000 0.000 0.000 1 0.000 0.000
#> SRR886605 3 0.0000 0.997 0.000 0.000 1.000 0 0.000 0.000
#> SRR886606 3 0.0000 0.997 0.000 0.000 1.000 0 0.000 0.000
#> SRR886607 3 0.0000 0.997 0.000 0.000 1.000 0 0.000 0.000
#> SRR886608 5 0.1075 1.000 0.000 0.000 0.048 0 0.952 0.000
#> SRR886609 5 0.1075 1.000 0.000 0.000 0.048 0 0.952 0.000
#> SRR886610 5 0.1075 1.000 0.000 0.000 0.048 0 0.952 0.000
#> SRR886611 5 0.1075 1.000 0.000 0.000 0.048 0 0.952 0.000
#> SRR886612 5 0.1075 1.000 0.000 0.000 0.048 0 0.952 0.000
#> SRR886613 5 0.1075 1.000 0.000 0.000 0.048 0 0.952 0.000
#> SRR886614 3 0.0146 0.997 0.000 0.000 0.996 0 0.004 0.000
#> SRR886615 3 0.0146 0.997 0.000 0.000 0.996 0 0.004 0.000
#> SRR886616 3 0.0146 0.997 0.000 0.000 0.996 0 0.004 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)
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 14902 rows and 52 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.967 0.985 0.5012 0.502 0.502
#> 3 3 0.776 0.850 0.911 0.3212 0.767 0.560
#> 4 4 0.817 0.779 0.891 0.0768 0.973 0.916
#> 5 5 0.764 0.715 0.831 0.0672 0.937 0.791
#> 6 6 0.788 0.806 0.854 0.0389 0.871 0.548
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
#> SRR886565 1 0.000 0.973 1.000 0.000
#> SRR886566 1 0.000 0.973 1.000 0.000
#> SRR886567 1 0.000 0.973 1.000 0.000
#> SRR886568 1 0.000 0.973 1.000 0.000
#> SRR886569 1 0.000 0.973 1.000 0.000
#> SRR886570 1 0.000 0.973 1.000 0.000
#> SRR886571 1 0.000 0.973 1.000 0.000
#> SRR886572 1 0.000 0.973 1.000 0.000
#> SRR886573 1 0.000 0.973 1.000 0.000
#> SRR886574 1 0.000 0.973 1.000 0.000
#> SRR886575 1 0.000 0.973 1.000 0.000
#> SRR886576 1 0.000 0.973 1.000 0.000
#> SRR886577 1 0.000 0.973 1.000 0.000
#> SRR886578 1 0.000 0.973 1.000 0.000
#> SRR886579 1 0.000 0.973 1.000 0.000
#> SRR886580 2 0.000 1.000 0.000 1.000
#> SRR886581 2 0.000 1.000 0.000 1.000
#> SRR886582 2 0.000 1.000 0.000 1.000
#> SRR886583 1 0.000 0.973 1.000 0.000
#> SRR886584 1 0.000 0.973 1.000 0.000
#> SRR886585 1 0.000 0.973 1.000 0.000
#> SRR886586 2 0.000 1.000 0.000 1.000
#> SRR886587 2 0.000 1.000 0.000 1.000
#> SRR886588 2 0.000 1.000 0.000 1.000
#> SRR886589 1 0.000 0.973 1.000 0.000
#> SRR886590 1 0.000 0.973 1.000 0.000
#> SRR886591 1 0.000 0.973 1.000 0.000
#> SRR886592 2 0.000 1.000 0.000 1.000
#> SRR886593 2 0.000 1.000 0.000 1.000
#> SRR886594 2 0.000 1.000 0.000 1.000
#> SRR886595 2 0.000 1.000 0.000 1.000
#> SRR886596 2 0.000 1.000 0.000 1.000
#> SRR886597 2 0.000 1.000 0.000 1.000
#> SRR886598 2 0.000 1.000 0.000 1.000
#> SRR886599 2 0.000 1.000 0.000 1.000
#> SRR886600 2 0.000 1.000 0.000 1.000
#> SRR886601 2 0.000 1.000 0.000 1.000
#> SRR886602 1 0.000 0.973 1.000 0.000
#> SRR886603 1 0.000 0.973 1.000 0.000
#> SRR886604 1 0.000 0.973 1.000 0.000
#> SRR886605 1 0.795 0.702 0.760 0.240
#> SRR886606 1 0.839 0.659 0.732 0.268
#> SRR886607 1 0.844 0.652 0.728 0.272
#> SRR886608 2 0.000 1.000 0.000 1.000
#> SRR886609 2 0.000 1.000 0.000 1.000
#> SRR886610 2 0.000 1.000 0.000 1.000
#> SRR886611 2 0.000 1.000 0.000 1.000
#> SRR886612 2 0.000 1.000 0.000 1.000
#> SRR886613 2 0.000 1.000 0.000 1.000
#> SRR886614 1 0.000 0.973 1.000 0.000
#> SRR886615 1 0.000 0.973 1.000 0.000
#> SRR886616 1 0.000 0.973 1.000 0.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR886565 1 0.1289 0.971 0.968 0.000 0.032
#> SRR886566 1 0.1289 0.971 0.968 0.000 0.032
#> SRR886567 1 0.1289 0.971 0.968 0.000 0.032
#> SRR886568 3 0.5291 0.694 0.268 0.000 0.732
#> SRR886569 3 0.5254 0.699 0.264 0.000 0.736
#> SRR886570 3 0.5327 0.694 0.272 0.000 0.728
#> SRR886571 1 0.0424 0.975 0.992 0.000 0.008
#> SRR886572 1 0.0424 0.975 0.992 0.000 0.008
#> SRR886573 1 0.0424 0.975 0.992 0.000 0.008
#> SRR886574 1 0.2165 0.957 0.936 0.000 0.064
#> SRR886575 1 0.2165 0.957 0.936 0.000 0.064
#> SRR886576 1 0.2165 0.957 0.936 0.000 0.064
#> SRR886577 1 0.0747 0.978 0.984 0.000 0.016
#> SRR886578 1 0.0747 0.978 0.984 0.000 0.016
#> SRR886579 1 0.0747 0.978 0.984 0.000 0.016
#> SRR886580 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886581 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886582 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886583 1 0.0237 0.978 0.996 0.000 0.004
#> SRR886584 1 0.0237 0.978 0.996 0.000 0.004
#> SRR886585 1 0.0237 0.978 0.996 0.000 0.004
#> SRR886586 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886587 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886588 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886589 3 0.5859 0.619 0.344 0.000 0.656
#> SRR886590 3 0.5926 0.599 0.356 0.000 0.644
#> SRR886591 3 0.5835 0.627 0.340 0.000 0.660
#> SRR886592 2 0.1529 0.900 0.000 0.960 0.040
#> SRR886593 2 0.1529 0.900 0.000 0.960 0.040
#> SRR886594 2 0.1529 0.900 0.000 0.960 0.040
#> SRR886595 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886596 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886597 2 0.0000 0.922 0.000 1.000 0.000
#> SRR886598 2 0.0424 0.920 0.000 0.992 0.008
#> SRR886599 2 0.0424 0.920 0.000 0.992 0.008
#> SRR886600 2 0.0424 0.920 0.000 0.992 0.008
#> SRR886601 2 0.0424 0.920 0.000 0.992 0.008
#> SRR886602 1 0.0237 0.978 0.996 0.000 0.004
#> SRR886603 1 0.0237 0.978 0.996 0.000 0.004
#> SRR886604 1 0.0237 0.978 0.996 0.000 0.004
#> SRR886605 3 0.2743 0.806 0.052 0.020 0.928
#> SRR886606 3 0.2743 0.806 0.052 0.020 0.928
#> SRR886607 3 0.2743 0.806 0.052 0.020 0.928
#> SRR886608 3 0.4654 0.636 0.000 0.208 0.792
#> SRR886609 3 0.4605 0.642 0.000 0.204 0.796
#> SRR886610 3 0.4605 0.642 0.000 0.204 0.796
#> SRR886611 2 0.6111 0.411 0.000 0.604 0.396
#> SRR886612 2 0.5948 0.482 0.000 0.640 0.360
#> SRR886613 2 0.6126 0.402 0.000 0.600 0.400
#> SRR886614 3 0.2796 0.812 0.092 0.000 0.908
#> SRR886615 3 0.2796 0.812 0.092 0.000 0.908
#> SRR886616 3 0.2796 0.812 0.092 0.000 0.908
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR886565 1 0.0707 0.964 0.980 0.000 0.020 0.000
#> SRR886566 1 0.0592 0.966 0.984 0.000 0.016 0.000
#> SRR886567 1 0.0592 0.966 0.984 0.000 0.016 0.000
#> SRR886568 4 0.4636 0.971 0.040 0.000 0.188 0.772
#> SRR886569 4 0.4599 0.963 0.028 0.000 0.212 0.760
#> SRR886570 4 0.4800 0.973 0.044 0.000 0.196 0.760
#> SRR886571 1 0.0000 0.968 1.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.968 1.000 0.000 0.000 0.000
#> SRR886573 1 0.0000 0.968 1.000 0.000 0.000 0.000
#> SRR886574 1 0.3215 0.882 0.876 0.000 0.032 0.092
#> SRR886575 1 0.3117 0.886 0.880 0.000 0.028 0.092
#> SRR886576 1 0.3051 0.889 0.884 0.000 0.028 0.088
#> SRR886577 1 0.0592 0.966 0.984 0.000 0.016 0.000
#> SRR886578 1 0.0592 0.966 0.984 0.000 0.016 0.000
#> SRR886579 1 0.0592 0.966 0.984 0.000 0.016 0.000
#> SRR886580 2 0.0000 0.877 0.000 1.000 0.000 0.000
#> SRR886581 2 0.0000 0.877 0.000 1.000 0.000 0.000
#> SRR886582 2 0.0000 0.877 0.000 1.000 0.000 0.000
#> SRR886583 1 0.0336 0.966 0.992 0.000 0.000 0.008
#> SRR886584 1 0.0336 0.966 0.992 0.000 0.000 0.008
#> SRR886585 1 0.0336 0.966 0.992 0.000 0.000 0.008
#> SRR886586 2 0.0817 0.873 0.000 0.976 0.000 0.024
#> SRR886587 2 0.0921 0.872 0.000 0.972 0.000 0.028
#> SRR886588 2 0.0921 0.872 0.000 0.972 0.000 0.028
#> SRR886589 3 0.7728 -0.144 0.252 0.000 0.440 0.308
#> SRR886590 3 0.7770 -0.201 0.248 0.000 0.416 0.336
#> SRR886591 3 0.7704 -0.187 0.232 0.000 0.432 0.336
#> SRR886592 2 0.3024 0.803 0.000 0.852 0.000 0.148
#> SRR886593 2 0.3024 0.803 0.000 0.852 0.000 0.148
#> SRR886594 2 0.3074 0.801 0.000 0.848 0.000 0.152
#> SRR886595 2 0.0188 0.877 0.000 0.996 0.000 0.004
#> SRR886596 2 0.0188 0.877 0.000 0.996 0.000 0.004
#> SRR886597 2 0.0188 0.877 0.000 0.996 0.000 0.004
#> SRR886598 2 0.1520 0.867 0.000 0.956 0.020 0.024
#> SRR886599 2 0.1624 0.866 0.000 0.952 0.020 0.028
#> SRR886600 2 0.1624 0.866 0.000 0.952 0.020 0.028
#> SRR886601 2 0.1624 0.866 0.000 0.952 0.020 0.028
#> SRR886602 1 0.0336 0.966 0.992 0.000 0.000 0.008
#> SRR886603 1 0.0336 0.966 0.992 0.000 0.000 0.008
#> SRR886604 1 0.0336 0.966 0.992 0.000 0.000 0.008
#> SRR886605 3 0.0524 0.708 0.004 0.000 0.988 0.008
#> SRR886606 3 0.0657 0.708 0.004 0.000 0.984 0.012
#> SRR886607 3 0.0804 0.708 0.008 0.000 0.980 0.012
#> SRR886608 3 0.3372 0.656 0.000 0.036 0.868 0.096
#> SRR886609 3 0.3372 0.656 0.000 0.036 0.868 0.096
#> SRR886610 3 0.3372 0.656 0.000 0.036 0.868 0.096
#> SRR886611 2 0.5650 0.319 0.000 0.544 0.432 0.024
#> SRR886612 2 0.5592 0.382 0.000 0.572 0.404 0.024
#> SRR886613 2 0.5636 0.337 0.000 0.552 0.424 0.024
#> SRR886614 3 0.1510 0.701 0.016 0.000 0.956 0.028
#> SRR886615 3 0.1297 0.705 0.016 0.000 0.964 0.020
#> SRR886616 3 0.1297 0.705 0.016 0.000 0.964 0.020
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR886565 1 0.1282 0.888 0.952 0.000 0.044 0.004 0.000
#> SRR886566 1 0.1121 0.890 0.956 0.000 0.044 0.000 0.000
#> SRR886567 1 0.1282 0.888 0.952 0.000 0.044 0.004 0.000
#> SRR886568 4 0.3730 0.943 0.028 0.000 0.168 0.800 0.004
#> SRR886569 4 0.4007 0.936 0.020 0.000 0.220 0.756 0.004
#> SRR886570 4 0.4230 0.954 0.036 0.000 0.192 0.764 0.008
#> SRR886571 1 0.0000 0.910 1.000 0.000 0.000 0.000 0.000
#> SRR886572 1 0.0000 0.910 1.000 0.000 0.000 0.000 0.000
#> SRR886573 1 0.0162 0.910 0.996 0.000 0.004 0.000 0.000
#> SRR886574 1 0.4975 0.410 0.584 0.000 0.016 0.388 0.012
#> SRR886575 1 0.5068 0.403 0.580 0.000 0.016 0.388 0.016
#> SRR886576 1 0.4975 0.409 0.584 0.000 0.012 0.388 0.016
#> SRR886577 1 0.0162 0.910 0.996 0.000 0.004 0.000 0.000
#> SRR886578 1 0.0324 0.910 0.992 0.000 0.004 0.000 0.004
#> SRR886579 1 0.0162 0.910 0.996 0.000 0.004 0.000 0.000
#> SRR886580 2 0.1300 0.705 0.000 0.956 0.000 0.016 0.028
#> SRR886581 2 0.1386 0.703 0.000 0.952 0.000 0.016 0.032
#> SRR886582 2 0.1386 0.703 0.000 0.952 0.000 0.016 0.032
#> SRR886583 1 0.0162 0.910 0.996 0.000 0.000 0.004 0.000
#> SRR886584 1 0.0290 0.909 0.992 0.000 0.000 0.008 0.000
#> SRR886585 1 0.0290 0.909 0.992 0.000 0.000 0.008 0.000
#> SRR886586 2 0.1195 0.711 0.000 0.960 0.000 0.028 0.012
#> SRR886587 2 0.1195 0.711 0.000 0.960 0.000 0.028 0.012
#> SRR886588 2 0.1281 0.710 0.000 0.956 0.000 0.032 0.012
#> SRR886589 3 0.3959 0.765 0.068 0.000 0.816 0.104 0.012
#> SRR886590 3 0.3950 0.757 0.068 0.000 0.812 0.112 0.008
#> SRR886591 3 0.3739 0.769 0.052 0.000 0.824 0.116 0.008
#> SRR886592 2 0.4557 0.244 0.000 0.516 0.000 0.476 0.008
#> SRR886593 2 0.4555 0.253 0.000 0.520 0.000 0.472 0.008
#> SRR886594 2 0.4560 0.232 0.000 0.508 0.000 0.484 0.008
#> SRR886595 2 0.0000 0.713 0.000 1.000 0.000 0.000 0.000
#> SRR886596 2 0.0000 0.713 0.000 1.000 0.000 0.000 0.000
#> SRR886597 2 0.0000 0.713 0.000 1.000 0.000 0.000 0.000
#> SRR886598 2 0.4201 0.204 0.000 0.592 0.000 0.000 0.408
#> SRR886599 2 0.4201 0.204 0.000 0.592 0.000 0.000 0.408
#> SRR886600 2 0.4210 0.192 0.000 0.588 0.000 0.000 0.412
#> SRR886601 2 0.4201 0.204 0.000 0.592 0.000 0.000 0.408
#> SRR886602 1 0.0324 0.910 0.992 0.000 0.004 0.004 0.000
#> SRR886603 1 0.0324 0.910 0.992 0.000 0.004 0.004 0.000
#> SRR886604 1 0.0162 0.910 0.996 0.000 0.000 0.004 0.000
#> SRR886605 3 0.1628 0.859 0.000 0.000 0.936 0.008 0.056
#> SRR886606 3 0.1670 0.860 0.000 0.000 0.936 0.012 0.052
#> SRR886607 3 0.1518 0.867 0.004 0.000 0.944 0.004 0.048
#> SRR886608 5 0.4401 0.700 0.000 0.016 0.296 0.004 0.684
#> SRR886609 5 0.4401 0.700 0.000 0.016 0.296 0.004 0.684
#> SRR886610 5 0.4380 0.701 0.000 0.016 0.292 0.004 0.688
#> SRR886611 5 0.6262 0.674 0.000 0.304 0.176 0.000 0.520
#> SRR886612 5 0.6275 0.667 0.000 0.308 0.176 0.000 0.516
#> SRR886613 5 0.6298 0.688 0.000 0.292 0.188 0.000 0.520
#> SRR886614 3 0.0771 0.878 0.004 0.000 0.976 0.000 0.020
#> SRR886615 3 0.0771 0.878 0.004 0.000 0.976 0.000 0.020
#> SRR886616 3 0.0865 0.878 0.004 0.000 0.972 0.000 0.024
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR886565 4 0.1932 0.909 0.020 0.000 0.040 0.924 0.000 NA
#> SRR886566 4 0.2001 0.906 0.020 0.000 0.044 0.920 0.000 NA
#> SRR886567 4 0.2001 0.906 0.020 0.000 0.044 0.920 0.000 NA
#> SRR886568 1 0.3736 0.601 0.812 0.012 0.124 0.032 0.000 NA
#> SRR886569 1 0.4222 0.580 0.772 0.012 0.160 0.032 0.004 NA
#> SRR886570 1 0.4082 0.580 0.776 0.012 0.160 0.032 0.000 NA
#> SRR886571 4 0.0363 0.943 0.000 0.000 0.000 0.988 0.000 NA
#> SRR886572 4 0.0363 0.943 0.000 0.000 0.000 0.988 0.000 NA
#> SRR886573 4 0.0363 0.943 0.000 0.000 0.000 0.988 0.000 NA
#> SRR886574 1 0.4172 0.345 0.564 0.000 0.004 0.424 0.000 NA
#> SRR886575 1 0.4184 0.332 0.556 0.000 0.004 0.432 0.000 NA
#> SRR886576 1 0.4178 0.337 0.560 0.000 0.004 0.428 0.000 NA
#> SRR886577 4 0.0653 0.940 0.012 0.000 0.004 0.980 0.000 NA
#> SRR886578 4 0.0748 0.939 0.016 0.000 0.004 0.976 0.000 NA
#> SRR886579 4 0.0748 0.939 0.016 0.000 0.004 0.976 0.000 NA
#> SRR886580 2 0.3020 0.805 0.000 0.844 0.000 0.000 0.076 NA
#> SRR886581 2 0.2912 0.809 0.000 0.852 0.000 0.000 0.076 NA
#> SRR886582 2 0.3072 0.802 0.000 0.840 0.000 0.000 0.076 NA
#> SRR886583 4 0.1327 0.934 0.000 0.000 0.000 0.936 0.000 NA
#> SRR886584 4 0.1327 0.934 0.000 0.000 0.000 0.936 0.000 NA
#> SRR886585 4 0.1327 0.934 0.000 0.000 0.000 0.936 0.000 NA
#> SRR886586 2 0.3002 0.866 0.048 0.848 0.000 0.000 0.100 NA
#> SRR886587 2 0.3017 0.865 0.052 0.848 0.000 0.000 0.096 NA
#> SRR886588 2 0.3039 0.862 0.060 0.848 0.000 0.000 0.088 NA
#> SRR886589 3 0.1406 0.957 0.016 0.000 0.952 0.020 0.004 NA
#> SRR886590 3 0.1346 0.952 0.016 0.000 0.952 0.024 0.000 NA
#> SRR886591 3 0.1262 0.956 0.016 0.000 0.956 0.020 0.000 NA
#> SRR886592 1 0.3972 0.473 0.732 0.232 0.000 0.000 0.016 NA
#> SRR886593 1 0.4029 0.475 0.732 0.228 0.000 0.000 0.020 NA
#> SRR886594 1 0.4055 0.471 0.728 0.232 0.000 0.000 0.020 NA
#> SRR886595 2 0.2340 0.872 0.000 0.852 0.000 0.000 0.148 NA
#> SRR886596 2 0.2340 0.872 0.000 0.852 0.000 0.000 0.148 NA
#> SRR886597 2 0.2340 0.872 0.000 0.852 0.000 0.000 0.148 NA
#> SRR886598 5 0.3122 0.738 0.000 0.176 0.000 0.000 0.804 NA
#> SRR886599 5 0.3156 0.734 0.000 0.180 0.000 0.000 0.800 NA
#> SRR886600 5 0.3088 0.741 0.000 0.172 0.000 0.000 0.808 NA
#> SRR886601 5 0.3088 0.741 0.000 0.172 0.000 0.000 0.808 NA
#> SRR886602 4 0.1444 0.932 0.000 0.000 0.000 0.928 0.000 NA
#> SRR886603 4 0.1444 0.932 0.000 0.000 0.000 0.928 0.000 NA
#> SRR886604 4 0.1444 0.932 0.000 0.000 0.000 0.928 0.000 NA
#> SRR886605 3 0.0964 0.962 0.000 0.012 0.968 0.000 0.004 NA
#> SRR886606 3 0.1138 0.958 0.000 0.012 0.960 0.000 0.004 NA
#> SRR886607 3 0.0964 0.962 0.000 0.012 0.968 0.000 0.004 NA
#> SRR886608 5 0.3943 0.713 0.000 0.004 0.184 0.000 0.756 NA
#> SRR886609 5 0.3946 0.709 0.000 0.004 0.192 0.000 0.752 NA
#> SRR886610 5 0.3911 0.714 0.000 0.004 0.180 0.000 0.760 NA
#> SRR886611 5 0.3940 0.791 0.000 0.096 0.140 0.000 0.764 NA
#> SRR886612 5 0.3908 0.791 0.000 0.100 0.132 0.000 0.768 NA
#> SRR886613 5 0.3985 0.790 0.000 0.100 0.140 0.000 0.760 NA
#> SRR886614 3 0.0146 0.970 0.004 0.000 0.996 0.000 0.000 NA
#> SRR886615 3 0.0146 0.970 0.004 0.000 0.996 0.000 0.000 NA
#> SRR886616 3 0.0146 0.970 0.004 0.000 0.996 0.000 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)
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