Date: 2019-12-26 00:21:08 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 14951 rows and 56 columns.
#> Top rows are extracted by 'SD, CV, MAD, ATC' methods.
#> Subgroups are detected by 'hclust, kmeans, skmeans, pam, mclust, NMF' method.
#> Number of partitions are tried for k = 2, 3, 4, 5, 6.
#> Performed in total 30000 partitions by row resampling.
#>
#> Following methods can be applied to this 'ConsensusPartitionList' object:
#> [1] "cola_report" "collect_classes" "collect_plots" "collect_stats"
#> [5] "colnames" "functional_enrichment" "get_anno_col" "get_anno"
#> [9] "get_classes" "get_matrix" "get_membership" "get_stats"
#> [13] "is_best_k" "is_stable_k" "ncol" "nrow"
#> [17] "rownames" "show" "suggest_best_k" "test_to_known_factors"
#> [21] "top_rows_heatmap" "top_rows_overlap"
#>
#> You can get result for a single method by, e.g. object["SD", "hclust"] or object["SD:hclust"]
#> or a subset of methods by object[c("SD", "CV")], c("hclust", "kmeans")]
The call of run_all_consensus_partition_methods()
was:
#> run_all_consensus_partition_methods(data = mat, mc.cores = 4)
Dimension of the input matrix:
mat = get_matrix(res_list)
dim(mat)
#> [1] 14951 56
The density distribution for each sample is visualized as in one column in the following heatmap. The clustering is based on the distance which is the Kolmogorov-Smirnov statistic between two distributions.
library(ComplexHeatmap)
densityHeatmap(mat, ylab = "value", cluster_columns = TRUE, show_column_names = FALSE,
mc.cores = 4)
Folowing table shows the best k
(number of partitions) for each combination
of top-value methods and partition methods. Clicking on the method name in
the table goes to the section for a single combination of methods.
The cola vignette explains the definition of the metrics used for determining the best number of partitions.
suggest_best_k(res_list)
The best k | 1-PAC | Mean silhouette | Concordance | Optional k | ||
---|---|---|---|---|---|---|
SD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:hclust | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
CV:mclust | 4 | 1.000 | 0.974 | 0.990 | ** | 2 |
CV:NMF | 2 | 1.000 | 0.995 | 0.998 | ** | |
MAD:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:kmeans | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:skmeans | 4 | 1.000 | 0.940 | 0.974 | ** | 2 |
ATC:NMF | 2 | 1.000 | 1.000 | 1.000 | ** | |
ATC:pam | 6 | 0.987 | 0.958 | 0.980 | ** | 2,4,5 |
MAD:skmeans | 6 | 0.970 | 0.949 | 0.966 | ** | 2,3,5 |
SD:NMF | 6 | 0.967 | 0.940 | 0.962 | ** | 2,5 |
SD:skmeans | 6 | 0.966 | 0.947 | 0.966 | ** | 2,3,4 |
MAD:NMF | 6 | 0.962 | 0.932 | 0.957 | ** | 2,3,4 |
SD:hclust | 5 | 0.954 | 0.973 | 0.986 | ** | 2 |
MAD:mclust | 6 | 0.946 | 0.870 | 0.956 | * | 2,3 |
ATC:hclust | 6 | 0.936 | 0.912 | 0.946 | * | 2,3,4 |
MAD:pam | 6 | 0.935 | 0.892 | 0.930 | * | 2,3,5 |
SD:mclust | 6 | 0.934 | 0.917 | 0.960 | * | 2,4 |
SD:pam | 6 | 0.934 | 0.906 | 0.908 | * | 2,5 |
CV:pam | 5 | 0.933 | 0.918 | 0.965 | * | 2,4 |
ATC:mclust | 6 | 0.933 | 0.884 | 0.930 | * | 2,3 |
MAD:hclust | 5 | 0.931 | 0.912 | 0.946 | * | 2,4 |
CV:skmeans | 6 | 0.915 | 0.889 | 0.921 | * | 2,3 |
**: 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 1.000 1.000 0.457 0.544 0.544
#> CV:NMF 2 1 0.995 0.998 0.458 0.544 0.544
#> MAD:NMF 2 1 0.997 0.998 0.458 0.544 0.544
#> ATC:NMF 2 1 1.000 1.000 0.457 0.544 0.544
#> SD:skmeans 2 1 0.965 0.986 0.465 0.544 0.544
#> CV:skmeans 2 1 0.973 0.989 0.466 0.532 0.532
#> MAD:skmeans 2 1 0.992 0.997 0.476 0.523 0.523
#> ATC:skmeans 2 1 0.976 0.991 0.471 0.532 0.532
#> SD:mclust 2 1 1.000 1.000 0.457 0.544 0.544
#> CV:mclust 2 1 1.000 1.000 0.457 0.544 0.544
#> MAD:mclust 2 1 1.000 1.000 0.457 0.544 0.544
#> ATC:mclust 2 1 1.000 1.000 0.457 0.544 0.544
#> SD:kmeans 2 1 1.000 1.000 0.457 0.544 0.544
#> CV:kmeans 2 1 1.000 1.000 0.457 0.544 0.544
#> MAD:kmeans 2 1 1.000 1.000 0.457 0.544 0.544
#> ATC:kmeans 2 1 1.000 1.000 0.457 0.544 0.544
#> SD:pam 2 1 1.000 1.000 0.457 0.544 0.544
#> CV:pam 2 1 1.000 1.000 0.457 0.544 0.544
#> MAD:pam 2 1 1.000 1.000 0.457 0.544 0.544
#> ATC:pam 2 1 1.000 1.000 0.457 0.544 0.544
#> SD:hclust 2 1 1.000 1.000 0.457 0.544 0.544
#> CV:hclust 2 1 1.000 1.000 0.457 0.544 0.544
#> MAD:hclust 2 1 1.000 1.000 0.457 0.544 0.544
#> ATC:hclust 2 1 1.000 1.000 0.457 0.544 0.544
get_stats(res_list, k = 3)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 3 0.830 0.923 0.951 0.424 0.805 0.642
#> CV:NMF 3 0.664 0.844 0.817 0.381 0.791 0.615
#> MAD:NMF 3 0.935 0.926 0.967 0.443 0.797 0.627
#> ATC:NMF 3 0.803 0.831 0.925 0.350 0.836 0.699
#> SD:skmeans 3 1.000 0.983 0.993 0.459 0.778 0.591
#> CV:skmeans 3 1.000 0.989 0.991 0.450 0.769 0.575
#> MAD:skmeans 3 1.000 0.976 0.992 0.425 0.757 0.553
#> ATC:skmeans 3 0.840 0.846 0.928 0.317 0.802 0.633
#> SD:mclust 3 0.779 0.922 0.878 0.248 0.849 0.723
#> CV:mclust 3 0.772 0.933 0.874 0.282 0.836 0.699
#> MAD:mclust 3 0.975 0.952 0.975 0.359 0.836 0.699
#> ATC:mclust 3 1.000 0.991 0.995 0.363 0.836 0.699
#> SD:kmeans 3 0.673 0.844 0.829 0.323 0.836 0.699
#> CV:kmeans 3 0.778 0.953 0.918 0.306 0.836 0.699
#> MAD:kmeans 3 0.661 0.756 0.754 0.349 1.000 1.000
#> ATC:kmeans 3 0.749 0.957 0.906 0.331 0.814 0.658
#> SD:pam 3 0.878 0.945 0.936 0.446 0.782 0.599
#> CV:pam 3 0.778 0.969 0.936 0.312 0.836 0.699
#> MAD:pam 3 0.976 0.946 0.978 0.477 0.779 0.594
#> ATC:pam 3 0.836 0.876 0.929 0.404 0.836 0.699
#> SD:hclust 3 0.825 0.932 0.964 0.188 0.934 0.878
#> CV:hclust 3 0.624 0.681 0.843 0.334 0.914 0.842
#> MAD:hclust 3 0.825 0.934 0.964 0.187 0.934 0.878
#> ATC:hclust 3 1.000 0.996 0.998 0.360 0.836 0.699
get_stats(res_list, k = 4)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 4 0.869 0.846 0.881 0.0838 0.962 0.891
#> CV:NMF 4 0.791 0.771 0.827 0.1442 0.864 0.637
#> MAD:NMF 4 0.920 0.878 0.939 0.0876 0.938 0.819
#> ATC:NMF 4 0.597 0.600 0.765 0.1131 0.896 0.746
#> SD:skmeans 4 0.902 0.925 0.894 0.0817 0.942 0.818
#> CV:skmeans 4 0.766 0.784 0.799 0.0935 0.842 0.573
#> MAD:skmeans 4 0.874 0.596 0.770 0.0771 0.953 0.855
#> ATC:skmeans 4 1.000 0.940 0.974 0.1422 0.921 0.781
#> SD:mclust 4 0.936 0.935 0.965 0.1820 0.919 0.798
#> CV:mclust 4 1.000 0.974 0.990 0.1550 0.942 0.846
#> MAD:mclust 4 0.749 0.829 0.837 0.1076 0.943 0.850
#> ATC:mclust 4 0.843 0.810 0.922 0.1501 0.905 0.749
#> SD:kmeans 4 0.707 0.513 0.654 0.1627 0.896 0.726
#> CV:kmeans 4 0.674 0.830 0.777 0.1434 0.987 0.966
#> MAD:kmeans 4 0.718 0.418 0.679 0.1491 0.774 0.584
#> ATC:kmeans 4 0.755 0.721 0.765 0.1597 0.877 0.668
#> SD:pam 4 0.761 0.930 0.928 0.1009 0.942 0.820
#> CV:pam 4 1.000 1.000 1.000 0.1323 0.942 0.846
#> MAD:pam 4 0.853 0.936 0.946 0.0976 0.936 0.801
#> ATC:pam 4 1.000 0.953 0.983 0.1632 0.873 0.667
#> SD:hclust 4 0.825 0.927 0.961 0.1086 0.942 0.878
#> CV:hclust 4 0.706 0.775 0.823 0.1393 0.896 0.779
#> MAD:hclust 4 1.000 0.992 0.996 0.2115 0.865 0.717
#> ATC:hclust 4 0.908 0.954 0.971 0.1461 0.914 0.774
get_stats(res_list, k = 5)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 5 0.915 0.929 0.949 0.0673 0.942 0.813
#> CV:NMF 5 0.778 0.691 0.854 0.0922 0.920 0.721
#> MAD:NMF 5 0.824 0.837 0.863 0.0641 0.926 0.742
#> ATC:NMF 5 0.649 0.607 0.817 0.0766 0.755 0.408
#> SD:skmeans 5 0.882 0.879 0.887 0.0685 0.964 0.862
#> CV:skmeans 5 0.773 0.820 0.858 0.0799 0.942 0.774
#> MAD:skmeans 5 0.969 0.932 0.952 0.0672 0.890 0.639
#> ATC:skmeans 5 0.875 0.872 0.890 0.0674 0.921 0.739
#> SD:mclust 5 0.825 0.807 0.885 0.1022 0.958 0.872
#> CV:mclust 5 0.779 0.686 0.855 0.1409 0.905 0.703
#> MAD:mclust 5 0.795 0.865 0.886 0.1328 0.875 0.614
#> ATC:mclust 5 0.802 0.777 0.880 0.0292 1.000 1.000
#> SD:kmeans 5 0.692 0.883 0.777 0.0809 0.825 0.465
#> CV:kmeans 5 0.716 0.687 0.721 0.0945 0.833 0.561
#> MAD:kmeans 5 0.692 0.879 0.785 0.0829 0.814 0.475
#> ATC:kmeans 5 0.716 0.586 0.657 0.0841 0.832 0.479
#> SD:pam 5 1.000 0.966 0.987 0.1009 0.896 0.634
#> CV:pam 5 0.933 0.918 0.965 0.1815 0.858 0.572
#> MAD:pam 5 0.982 0.946 0.979 0.0772 0.945 0.789
#> ATC:pam 5 0.987 0.948 0.980 0.0780 0.942 0.769
#> SD:hclust 5 0.954 0.973 0.986 0.2009 0.865 0.678
#> CV:hclust 5 0.771 0.765 0.802 0.0882 0.856 0.621
#> MAD:hclust 5 0.931 0.912 0.946 0.0627 0.955 0.867
#> ATC:hclust 5 0.893 0.921 0.960 0.0111 0.995 0.982
get_stats(res_list, k = 6)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> SD:NMF 6 0.967 0.940 0.962 0.06878 0.899 0.636
#> CV:NMF 6 0.888 0.777 0.916 0.04301 0.897 0.592
#> MAD:NMF 6 0.962 0.932 0.957 0.05385 0.937 0.737
#> ATC:NMF 6 0.711 0.645 0.824 0.04779 0.930 0.750
#> SD:skmeans 6 0.966 0.947 0.966 0.06529 0.942 0.742
#> CV:skmeans 6 0.915 0.889 0.921 0.05715 0.931 0.673
#> MAD:skmeans 6 0.970 0.949 0.966 0.07127 0.942 0.742
#> ATC:skmeans 6 0.809 0.807 0.875 0.04198 0.986 0.938
#> SD:mclust 6 0.934 0.917 0.960 0.10143 0.884 0.598
#> CV:mclust 6 0.827 0.752 0.852 0.05859 0.866 0.506
#> MAD:mclust 6 0.946 0.870 0.956 0.05060 0.970 0.853
#> ATC:mclust 6 0.933 0.884 0.930 0.05752 0.902 0.681
#> SD:kmeans 6 0.705 0.825 0.779 0.05447 0.950 0.756
#> CV:kmeans 6 0.700 0.633 0.744 0.06333 0.931 0.710
#> MAD:kmeans 6 0.782 0.846 0.798 0.04987 0.964 0.822
#> ATC:kmeans 6 0.714 0.752 0.763 0.03995 0.874 0.535
#> SD:pam 6 0.934 0.906 0.908 0.03106 0.953 0.785
#> CV:pam 6 0.866 0.830 0.885 0.04684 0.939 0.705
#> MAD:pam 6 0.935 0.892 0.930 0.03012 0.978 0.893
#> ATC:pam 6 0.987 0.958 0.980 0.02942 0.973 0.865
#> SD:hclust 6 0.954 0.956 0.982 0.00401 0.999 0.995
#> CV:hclust 6 0.835 0.788 0.836 0.04377 0.987 0.945
#> MAD:hclust 6 0.955 0.866 0.951 0.01738 0.999 0.996
#> ATC:hclust 6 0.936 0.912 0.946 0.07927 0.932 0.764
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.45704 0.544 0.544
#> 3 3 0.825 0.932 0.964 0.18808 0.934 0.878
#> 4 4 0.825 0.927 0.961 0.10858 0.942 0.878
#> 5 5 0.954 0.973 0.986 0.20088 0.865 0.678
#> 6 6 0.954 0.956 0.982 0.00401 0.999 0.995
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 1 0.46 0.785 0.796 0 0.204
#> SRR1539208 1 0.00 0.941 1.000 0 0.000
#> SRR1539211 3 0.46 0.869 0.204 0 0.796
#> SRR1539210 3 0.00 0.733 0.000 0 1.000
#> SRR1539209 2 0.00 1.000 0.000 1 0.000
#> SRR1539212 2 0.00 1.000 0.000 1 0.000
#> SRR1539214 1 0.00 0.941 1.000 0 0.000
#> SRR1539213 1 0.46 0.785 0.796 0 0.204
#> SRR1539215 2 0.00 1.000 0.000 1 0.000
#> SRR1539216 1 0.46 0.785 0.796 0 0.204
#> SRR1539217 1 0.00 0.941 1.000 0 0.000
#> SRR1539218 2 0.00 1.000 0.000 1 0.000
#> SRR1539220 1 0.00 0.941 1.000 0 0.000
#> SRR1539219 1 0.46 0.785 0.796 0 0.204
#> SRR1539221 2 0.00 1.000 0.000 1 0.000
#> SRR1539223 1 0.00 0.941 1.000 0 0.000
#> SRR1539224 2 0.00 1.000 0.000 1 0.000
#> SRR1539222 1 0.46 0.785 0.796 0 0.204
#> SRR1539225 1 0.46 0.785 0.796 0 0.204
#> SRR1539227 2 0.00 1.000 0.000 1 0.000
#> SRR1539226 1 0.00 0.941 1.000 0 0.000
#> SRR1539228 1 0.46 0.785 0.796 0 0.204
#> SRR1539229 1 0.00 0.941 1.000 0 0.000
#> SRR1539232 1 0.46 0.785 0.796 0 0.204
#> SRR1539230 2 0.00 1.000 0.000 1 0.000
#> SRR1539231 2 0.00 1.000 0.000 1 0.000
#> SRR1539234 2 0.00 1.000 0.000 1 0.000
#> SRR1539233 1 0.00 0.941 1.000 0 0.000
#> SRR1539235 1 0.00 0.941 1.000 0 0.000
#> SRR1539236 1 0.00 0.941 1.000 0 0.000
#> SRR1539237 2 0.00 1.000 0.000 1 0.000
#> SRR1539238 1 0.00 0.941 1.000 0 0.000
#> SRR1539239 1 0.00 0.941 1.000 0 0.000
#> SRR1539242 1 0.00 0.941 1.000 0 0.000
#> SRR1539240 2 0.00 1.000 0.000 1 0.000
#> SRR1539241 1 0.00 0.941 1.000 0 0.000
#> SRR1539243 2 0.00 1.000 0.000 1 0.000
#> SRR1539244 1 0.00 0.941 1.000 0 0.000
#> SRR1539245 1 0.00 0.941 1.000 0 0.000
#> SRR1539246 2 0.00 1.000 0.000 1 0.000
#> SRR1539247 1 0.00 0.941 1.000 0 0.000
#> SRR1539248 1 0.00 0.941 1.000 0 0.000
#> SRR1539249 2 0.00 1.000 0.000 1 0.000
#> SRR1539250 1 0.00 0.941 1.000 0 0.000
#> SRR1539251 1 0.00 0.941 1.000 0 0.000
#> SRR1539253 2 0.00 1.000 0.000 1 0.000
#> SRR1539252 1 0.00 0.941 1.000 0 0.000
#> SRR1539255 1 0.00 0.941 1.000 0 0.000
#> SRR1539254 1 0.00 0.941 1.000 0 0.000
#> SRR1539256 2 0.00 1.000 0.000 1 0.000
#> SRR1539257 1 0.00 0.941 1.000 0 0.000
#> SRR1539258 1 0.00 0.941 1.000 0 0.000
#> SRR1539259 2 0.00 1.000 0.000 1 0.000
#> SRR1539260 1 0.00 0.941 1.000 0 0.000
#> SRR1539262 2 0.00 1.000 0.000 1 0.000
#> SRR1539261 3 0.46 0.869 0.204 0 0.796
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539208 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539211 3 0.3791 0.828 0.200 0.000 0.796 0.004
#> SRR1539210 3 0.0000 0.641 0.000 0.000 1.000 0.000
#> SRR1539209 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539212 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539214 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539213 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539215 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539216 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539217 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539218 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539220 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539219 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539221 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539223 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539224 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539222 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539225 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539227 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539226 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539228 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539229 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539232 1 0.3972 0.777 0.788 0.000 0.204 0.008
#> SRR1539230 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539231 4 0.0469 1.000 0.000 0.012 0.000 0.988
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539233 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539235 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539236 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539238 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539239 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539241 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539244 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539245 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539247 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539248 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539250 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539251 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539254 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539257 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539258 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539260 1 0.0000 0.939 1.000 0.000 0.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539261 3 0.3791 0.828 0.200 0.000 0.796 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539208 1 0.238 0.885 0.872 0 0.000 0 0.128
#> SRR1539211 5 0.000 0.888 0.000 0 0.000 0 1.000
#> SRR1539210 5 0.314 0.727 0.000 0 0.204 0 0.796
#> SRR1539209 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539212 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539214 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539213 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539215 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539216 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539217 1 0.161 0.932 0.928 0 0.000 0 0.072
#> SRR1539218 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539220 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539219 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539221 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539223 1 0.161 0.932 0.928 0 0.000 0 0.072
#> SRR1539224 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539222 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539225 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539227 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539226 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539228 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539229 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539232 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539230 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539231 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539234 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539233 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539235 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539236 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539237 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539238 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539239 1 0.213 0.904 0.892 0 0.000 0 0.108
#> SRR1539242 1 0.213 0.904 0.892 0 0.000 0 0.108
#> SRR1539240 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539241 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539243 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539244 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539245 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539246 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539247 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539248 1 0.213 0.904 0.892 0 0.000 0 0.108
#> SRR1539249 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539250 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539251 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539253 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539252 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539255 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539254 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539256 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539257 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539258 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539259 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539260 1 0.000 0.976 1.000 0 0.000 0 0.000
#> SRR1539262 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539261 5 0.000 0.888 0.000 0 0.000 0 1.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.1141 0.969 0.000 0 0.948 0.000 0.052 0.000
#> SRR1539208 1 0.2135 0.883 0.872 0 0.000 0.000 0.000 0.128
#> SRR1539211 6 0.0000 1.000 0.000 0 0.000 0.000 0.000 1.000
#> SRR1539210 5 0.0865 0.000 0.000 0 0.000 0.000 0.964 0.036
#> SRR1539209 4 0.0865 0.978 0.000 0 0.000 0.964 0.036 0.000
#> SRR1539212 4 0.0865 0.978 0.000 0 0.000 0.964 0.036 0.000
#> SRR1539214 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539213 3 0.0000 0.969 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539215 4 0.0000 0.983 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.1141 0.969 0.000 0 0.948 0.000 0.052 0.000
#> SRR1539217 1 0.1444 0.930 0.928 0 0.000 0.000 0.000 0.072
#> SRR1539218 4 0.0865 0.978 0.000 0 0.000 0.964 0.036 0.000
#> SRR1539220 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539219 3 0.1141 0.969 0.000 0 0.948 0.000 0.052 0.000
#> SRR1539221 4 0.0000 0.983 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539223 1 0.1444 0.930 0.928 0 0.000 0.000 0.000 0.072
#> SRR1539224 4 0.0865 0.978 0.000 0 0.000 0.964 0.036 0.000
#> SRR1539222 3 0.1141 0.969 0.000 0 0.948 0.000 0.052 0.000
#> SRR1539225 3 0.0000 0.969 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539227 4 0.0000 0.983 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539226 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539228 3 0.0000 0.969 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539232 3 0.0000 0.969 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539230 4 0.0000 0.983 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539231 4 0.0000 0.983 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539233 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539235 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539236 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539238 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539239 1 0.1910 0.902 0.892 0 0.000 0.000 0.000 0.108
#> SRR1539242 1 0.1910 0.902 0.892 0 0.000 0.000 0.000 0.108
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539241 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539244 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539245 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539247 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539248 1 0.1910 0.902 0.892 0 0.000 0.000 0.000 0.108
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539250 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539251 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539254 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539257 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539258 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539260 1 0.0000 0.976 1.000 0 0.000 0.000 0.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539261 6 0.0000 1.000 0.000 0 0.000 0.000 0.000 1.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.673 0.844 0.829 0.3234 0.836 0.699
#> 4 4 0.707 0.513 0.654 0.1627 0.896 0.726
#> 5 5 0.692 0.883 0.777 0.0809 0.825 0.465
#> 6 6 0.705 0.825 0.779 0.0545 0.950 0.756
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.5465 0.993 0.288 0.000 0.712
#> SRR1539208 1 0.0424 0.846 0.992 0.000 0.008
#> SRR1539211 1 0.0747 0.839 0.984 0.000 0.016
#> SRR1539210 3 0.5465 0.993 0.288 0.000 0.712
#> SRR1539209 2 0.0424 0.867 0.000 0.992 0.008
#> SRR1539212 2 0.0424 0.867 0.000 0.992 0.008
#> SRR1539214 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539213 3 0.5529 0.993 0.296 0.000 0.704
#> SRR1539215 2 0.0000 0.869 0.000 1.000 0.000
#> SRR1539216 3 0.5465 0.993 0.288 0.000 0.712
#> SRR1539217 1 0.0237 0.848 0.996 0.000 0.004
#> SRR1539218 2 0.0424 0.867 0.000 0.992 0.008
#> SRR1539220 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539219 3 0.5497 0.993 0.292 0.000 0.708
#> SRR1539221 2 0.0000 0.869 0.000 1.000 0.000
#> SRR1539223 1 0.0424 0.846 0.992 0.000 0.008
#> SRR1539224 2 0.0424 0.867 0.000 0.992 0.008
#> SRR1539222 3 0.5465 0.993 0.288 0.000 0.712
#> SRR1539225 3 0.5529 0.993 0.296 0.000 0.704
#> SRR1539227 2 0.0000 0.869 0.000 1.000 0.000
#> SRR1539226 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539228 3 0.5529 0.993 0.296 0.000 0.704
#> SRR1539229 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539232 3 0.5529 0.993 0.296 0.000 0.704
#> SRR1539230 2 0.0000 0.869 0.000 1.000 0.000
#> SRR1539231 2 0.0000 0.869 0.000 1.000 0.000
#> SRR1539234 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539233 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539235 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539236 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539237 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539238 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539239 1 0.0237 0.848 0.996 0.000 0.004
#> SRR1539242 1 0.0237 0.848 0.996 0.000 0.004
#> SRR1539240 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539241 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539243 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539244 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539245 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539246 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539247 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539248 1 0.0237 0.848 0.996 0.000 0.004
#> SRR1539249 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539250 1 0.5138 0.640 0.748 0.000 0.252
#> SRR1539251 1 0.5138 0.640 0.748 0.000 0.252
#> SRR1539253 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539252 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539255 1 0.0000 0.849 1.000 0.000 0.000
#> SRR1539254 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539256 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539257 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539258 1 0.0237 0.848 0.996 0.000 0.004
#> SRR1539259 2 0.5397 0.884 0.000 0.720 0.280
#> SRR1539260 1 0.5058 0.646 0.756 0.000 0.244
#> SRR1539262 2 0.5465 0.881 0.000 0.712 0.288
#> SRR1539261 1 0.0747 0.839 0.984 0.000 0.016
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.5957 0.967 0.364 0.000 0.588 0.048
#> SRR1539208 4 0.7771 0.879 0.328 0.000 0.252 0.420
#> SRR1539211 4 0.7764 0.876 0.324 0.000 0.252 0.424
#> SRR1539210 3 0.6446 0.910 0.328 0.000 0.584 0.088
#> SRR1539209 2 0.5853 0.742 0.000 0.508 0.032 0.460
#> SRR1539212 2 0.5853 0.742 0.000 0.508 0.032 0.460
#> SRR1539214 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539213 3 0.4730 0.974 0.364 0.000 0.636 0.000
#> SRR1539215 2 0.4999 0.743 0.000 0.508 0.000 0.492
#> SRR1539216 3 0.5957 0.967 0.364 0.000 0.588 0.048
#> SRR1539217 4 0.7824 0.839 0.348 0.000 0.260 0.392
#> SRR1539218 2 0.5853 0.742 0.000 0.508 0.032 0.460
#> SRR1539220 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539219 3 0.4730 0.974 0.364 0.000 0.636 0.000
#> SRR1539221 2 0.4999 0.743 0.000 0.508 0.000 0.492
#> SRR1539223 4 0.7847 0.878 0.328 0.000 0.276 0.396
#> SRR1539224 2 0.5853 0.742 0.000 0.508 0.032 0.460
#> SRR1539222 3 0.5957 0.967 0.364 0.000 0.588 0.048
#> SRR1539225 3 0.4730 0.974 0.364 0.000 0.636 0.000
#> SRR1539227 2 0.4999 0.743 0.000 0.508 0.000 0.492
#> SRR1539226 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539228 3 0.4730 0.974 0.364 0.000 0.636 0.000
#> SRR1539229 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539232 3 0.4730 0.974 0.364 0.000 0.636 0.000
#> SRR1539230 2 0.4999 0.743 0.000 0.508 0.000 0.492
#> SRR1539231 2 0.4999 0.743 0.000 0.508 0.000 0.492
#> SRR1539234 2 0.0921 0.772 0.000 0.972 0.028 0.000
#> SRR1539233 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539235 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539236 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539237 2 0.0188 0.773 0.000 0.996 0.004 0.000
#> SRR1539238 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539239 4 0.7677 0.872 0.372 0.000 0.216 0.412
#> SRR1539242 4 0.7677 0.872 0.372 0.000 0.216 0.412
#> SRR1539240 2 0.0592 0.773 0.000 0.984 0.016 0.000
#> SRR1539241 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539243 2 0.0592 0.773 0.000 0.984 0.016 0.000
#> SRR1539244 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539245 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539246 2 0.0921 0.772 0.000 0.972 0.028 0.000
#> SRR1539247 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539248 4 0.7677 0.872 0.372 0.000 0.216 0.412
#> SRR1539249 2 0.0188 0.773 0.000 0.996 0.004 0.000
#> SRR1539250 1 0.1022 0.450 0.968 0.000 0.000 0.032
#> SRR1539251 1 0.1022 0.450 0.968 0.000 0.000 0.032
#> SRR1539253 2 0.0188 0.773 0.000 0.996 0.004 0.000
#> SRR1539252 1 0.7674 -0.561 0.460 0.000 0.260 0.280
#> SRR1539255 1 0.7824 -0.777 0.392 0.000 0.260 0.348
#> SRR1539254 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539256 2 0.0592 0.773 0.000 0.984 0.016 0.000
#> SRR1539257 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539258 1 0.7834 -0.825 0.372 0.000 0.260 0.368
#> SRR1539259 2 0.0188 0.773 0.000 0.996 0.004 0.000
#> SRR1539260 1 0.0000 0.485 1.000 0.000 0.000 0.000
#> SRR1539262 2 0.0188 0.773 0.000 0.996 0.004 0.000
#> SRR1539261 4 0.7764 0.876 0.324 0.000 0.252 0.424
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.4953 0.924 0.024 0.000 0.716 0.044 0.216
#> SRR1539208 1 0.6360 0.609 0.576 0.000 0.060 0.300 0.064
#> SRR1539211 1 0.6553 0.592 0.556 0.000 0.068 0.308 0.068
#> SRR1539210 3 0.6604 0.693 0.024 0.000 0.564 0.196 0.216
#> SRR1539209 4 0.6736 0.896 0.000 0.388 0.056 0.476 0.080
#> SRR1539212 4 0.6736 0.896 0.000 0.388 0.056 0.476 0.080
#> SRR1539214 1 0.2069 0.806 0.912 0.000 0.012 0.000 0.076
#> SRR1539213 3 0.3745 0.937 0.024 0.000 0.780 0.000 0.196
#> SRR1539215 4 0.4415 0.916 0.000 0.388 0.008 0.604 0.000
#> SRR1539216 3 0.4953 0.924 0.024 0.000 0.716 0.044 0.216
#> SRR1539217 1 0.2026 0.807 0.928 0.000 0.012 0.044 0.016
#> SRR1539218 4 0.6736 0.896 0.000 0.388 0.056 0.476 0.080
#> SRR1539220 1 0.2069 0.806 0.912 0.000 0.012 0.000 0.076
#> SRR1539219 3 0.3745 0.937 0.024 0.000 0.780 0.000 0.196
#> SRR1539221 4 0.4150 0.917 0.000 0.388 0.000 0.612 0.000
#> SRR1539223 1 0.6273 0.621 0.596 0.000 0.060 0.280 0.064
#> SRR1539224 4 0.6736 0.896 0.000 0.388 0.056 0.476 0.080
#> SRR1539222 3 0.5415 0.904 0.024 0.000 0.688 0.076 0.212
#> SRR1539225 3 0.3745 0.937 0.024 0.000 0.780 0.000 0.196
#> SRR1539227 4 0.4150 0.917 0.000 0.388 0.000 0.612 0.000
#> SRR1539226 1 0.2069 0.806 0.912 0.000 0.012 0.000 0.076
#> SRR1539228 3 0.3745 0.937 0.024 0.000 0.780 0.000 0.196
#> SRR1539229 1 0.2069 0.806 0.912 0.000 0.012 0.000 0.076
#> SRR1539232 3 0.3745 0.937 0.024 0.000 0.780 0.000 0.196
#> SRR1539230 4 0.4150 0.917 0.000 0.388 0.000 0.612 0.000
#> SRR1539231 4 0.4150 0.917 0.000 0.388 0.000 0.612 0.000
#> SRR1539234 2 0.1725 0.950 0.000 0.936 0.044 0.000 0.020
#> SRR1539233 1 0.2069 0.806 0.912 0.000 0.012 0.000 0.076
#> SRR1539235 5 0.3266 0.993 0.200 0.000 0.000 0.004 0.796
#> SRR1539236 1 0.2069 0.805 0.912 0.000 0.012 0.000 0.076
#> SRR1539237 2 0.0955 0.960 0.000 0.968 0.028 0.000 0.004
#> SRR1539238 5 0.3266 0.993 0.200 0.000 0.000 0.004 0.796
#> SRR1539239 1 0.2921 0.785 0.856 0.000 0.020 0.124 0.000
#> SRR1539242 1 0.2921 0.785 0.856 0.000 0.020 0.124 0.000
#> SRR1539240 2 0.1522 0.958 0.000 0.944 0.044 0.000 0.012
#> SRR1539241 5 0.3266 0.993 0.200 0.000 0.000 0.004 0.796
#> SRR1539243 2 0.1522 0.958 0.000 0.944 0.044 0.000 0.012
#> SRR1539244 5 0.3266 0.993 0.200 0.000 0.000 0.004 0.796
#> SRR1539245 1 0.1671 0.806 0.924 0.000 0.000 0.000 0.076
#> SRR1539246 2 0.1386 0.951 0.000 0.952 0.032 0.000 0.016
#> SRR1539247 5 0.3109 0.993 0.200 0.000 0.000 0.000 0.800
#> SRR1539248 1 0.2921 0.785 0.856 0.000 0.020 0.124 0.000
#> SRR1539249 2 0.0162 0.961 0.000 0.996 0.004 0.000 0.000
#> SRR1539250 5 0.2966 0.977 0.184 0.000 0.000 0.000 0.816
#> SRR1539251 5 0.2966 0.977 0.184 0.000 0.000 0.000 0.816
#> SRR1539253 2 0.0000 0.961 0.000 1.000 0.000 0.000 0.000
#> SRR1539252 1 0.1671 0.806 0.924 0.000 0.000 0.000 0.076
#> SRR1539255 1 0.1106 0.812 0.964 0.000 0.012 0.000 0.024
#> SRR1539254 5 0.3109 0.993 0.200 0.000 0.000 0.000 0.800
#> SRR1539256 2 0.1522 0.958 0.000 0.944 0.044 0.000 0.012
#> SRR1539257 5 0.3109 0.993 0.200 0.000 0.000 0.000 0.800
#> SRR1539258 1 0.1522 0.807 0.944 0.000 0.012 0.044 0.000
#> SRR1539259 2 0.0162 0.960 0.000 0.996 0.004 0.000 0.000
#> SRR1539260 5 0.3109 0.993 0.200 0.000 0.000 0.000 0.800
#> SRR1539262 2 0.0324 0.960 0.000 0.992 0.004 0.000 0.004
#> SRR1539261 1 0.6430 0.603 0.568 0.000 0.060 0.304 0.068
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.5417 0.853 0.060 0.112 0.692 0.000 0.128 0.008
#> SRR1539208 6 0.1807 0.643 0.020 0.000 0.000 0.000 0.060 0.920
#> SRR1539211 6 0.2513 0.615 0.000 0.044 0.008 0.000 0.060 0.888
#> SRR1539210 3 0.7970 0.575 0.080 0.216 0.400 0.000 0.072 0.232
#> SRR1539209 4 0.3122 0.870 0.160 0.000 0.020 0.816 0.000 0.004
#> SRR1539212 4 0.3331 0.865 0.160 0.000 0.020 0.808 0.000 0.012
#> SRR1539214 1 0.6341 0.856 0.564 0.028 0.024 0.000 0.148 0.236
#> SRR1539213 3 0.2178 0.884 0.000 0.000 0.868 0.000 0.132 0.000
#> SRR1539215 4 0.0000 0.899 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.5417 0.853 0.060 0.112 0.692 0.000 0.128 0.008
#> SRR1539217 1 0.6288 0.577 0.464 0.028 0.024 0.000 0.088 0.396
#> SRR1539218 4 0.3017 0.870 0.164 0.000 0.020 0.816 0.000 0.000
#> SRR1539220 1 0.6379 0.848 0.556 0.028 0.024 0.000 0.148 0.244
#> SRR1539219 3 0.2135 0.885 0.000 0.000 0.872 0.000 0.128 0.000
#> SRR1539221 4 0.0000 0.899 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539223 6 0.2960 0.617 0.056 0.008 0.008 0.000 0.060 0.868
#> SRR1539224 4 0.3017 0.870 0.164 0.000 0.020 0.816 0.000 0.000
#> SRR1539222 3 0.6199 0.813 0.080 0.172 0.616 0.000 0.120 0.012
#> SRR1539225 3 0.2178 0.884 0.000 0.000 0.868 0.000 0.132 0.000
#> SRR1539227 4 0.0000 0.899 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539226 1 0.6122 0.861 0.576 0.024 0.016 0.000 0.148 0.236
#> SRR1539228 3 0.2178 0.884 0.000 0.000 0.868 0.000 0.132 0.000
#> SRR1539229 1 0.6122 0.861 0.576 0.024 0.016 0.000 0.148 0.236
#> SRR1539232 3 0.2431 0.884 0.008 0.000 0.860 0.000 0.132 0.000
#> SRR1539230 4 0.0000 0.899 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539231 4 0.0000 0.899 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.5993 0.907 0.064 0.576 0.036 0.296 0.000 0.028
#> SRR1539233 1 0.6122 0.861 0.576 0.024 0.016 0.000 0.148 0.236
#> SRR1539235 5 0.0777 0.978 0.024 0.004 0.000 0.000 0.972 0.000
#> SRR1539236 1 0.6438 0.808 0.556 0.044 0.016 0.000 0.148 0.236
#> SRR1539237 2 0.5062 0.927 0.044 0.632 0.016 0.296 0.000 0.012
#> SRR1539238 5 0.0922 0.979 0.024 0.004 0.000 0.000 0.968 0.004
#> SRR1539239 6 0.6300 0.185 0.304 0.036 0.024 0.000 0.096 0.540
#> SRR1539242 6 0.6300 0.185 0.304 0.036 0.024 0.000 0.096 0.540
#> SRR1539240 2 0.5651 0.926 0.064 0.596 0.024 0.296 0.000 0.020
#> SRR1539241 5 0.0922 0.979 0.024 0.004 0.000 0.000 0.968 0.004
#> SRR1539243 2 0.5651 0.926 0.064 0.596 0.024 0.296 0.000 0.020
#> SRR1539244 5 0.0777 0.978 0.024 0.004 0.000 0.000 0.972 0.000
#> SRR1539245 1 0.5384 0.853 0.608 0.008 0.000 0.000 0.148 0.236
#> SRR1539246 2 0.5438 0.909 0.048 0.612 0.024 0.296 0.000 0.020
#> SRR1539247 5 0.0000 0.982 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539248 6 0.6300 0.185 0.304 0.036 0.024 0.000 0.096 0.540
#> SRR1539249 2 0.3528 0.928 0.004 0.700 0.000 0.296 0.000 0.000
#> SRR1539250 5 0.0837 0.970 0.004 0.004 0.000 0.000 0.972 0.020
#> SRR1539251 5 0.0837 0.970 0.004 0.004 0.000 0.000 0.972 0.020
#> SRR1539253 2 0.3528 0.928 0.004 0.700 0.000 0.296 0.000 0.000
#> SRR1539252 1 0.5384 0.853 0.608 0.008 0.000 0.000 0.148 0.236
#> SRR1539255 1 0.6340 0.775 0.556 0.044 0.016 0.000 0.120 0.264
#> SRR1539254 5 0.0146 0.982 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1539256 2 0.5651 0.926 0.064 0.596 0.024 0.296 0.000 0.020
#> SRR1539257 5 0.0000 0.982 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539258 1 0.6432 0.495 0.464 0.044 0.016 0.000 0.096 0.380
#> SRR1539259 2 0.4004 0.923 0.012 0.684 0.004 0.296 0.000 0.004
#> SRR1539260 5 0.0146 0.982 0.000 0.000 0.000 0.000 0.996 0.004
#> SRR1539262 2 0.4302 0.919 0.016 0.672 0.008 0.296 0.000 0.008
#> SRR1539261 6 0.1781 0.639 0.000 0.008 0.008 0.000 0.060 0.924
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.965 0.986 0.4650 0.544 0.544
#> 3 3 1.000 0.983 0.993 0.4590 0.778 0.591
#> 4 4 0.902 0.925 0.894 0.0817 0.942 0.818
#> 5 5 0.882 0.879 0.887 0.0685 0.964 0.862
#> 6 6 0.966 0.947 0.966 0.0653 0.942 0.742
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
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
#> SRR1539207 1 0.000 0.978 1.000 0.000
#> SRR1539208 1 0.000 0.978 1.000 0.000
#> SRR1539211 1 0.961 0.394 0.616 0.384
#> SRR1539210 1 0.000 0.978 1.000 0.000
#> SRR1539209 2 0.000 1.000 0.000 1.000
#> SRR1539212 2 0.000 1.000 0.000 1.000
#> SRR1539214 1 0.000 0.978 1.000 0.000
#> SRR1539213 1 0.000 0.978 1.000 0.000
#> SRR1539215 2 0.000 1.000 0.000 1.000
#> SRR1539216 1 0.000 0.978 1.000 0.000
#> SRR1539217 1 0.000 0.978 1.000 0.000
#> SRR1539218 2 0.000 1.000 0.000 1.000
#> SRR1539220 1 0.000 0.978 1.000 0.000
#> SRR1539219 1 0.000 0.978 1.000 0.000
#> SRR1539221 2 0.000 1.000 0.000 1.000
#> SRR1539223 1 0.000 0.978 1.000 0.000
#> SRR1539224 2 0.000 1.000 0.000 1.000
#> SRR1539222 1 0.000 0.978 1.000 0.000
#> SRR1539225 1 0.000 0.978 1.000 0.000
#> SRR1539227 2 0.000 1.000 0.000 1.000
#> SRR1539226 1 0.000 0.978 1.000 0.000
#> SRR1539228 1 0.000 0.978 1.000 0.000
#> SRR1539229 1 0.000 0.978 1.000 0.000
#> SRR1539232 1 0.000 0.978 1.000 0.000
#> SRR1539230 2 0.000 1.000 0.000 1.000
#> SRR1539231 2 0.000 1.000 0.000 1.000
#> SRR1539234 2 0.000 1.000 0.000 1.000
#> SRR1539233 1 0.000 0.978 1.000 0.000
#> SRR1539235 1 0.000 0.978 1.000 0.000
#> SRR1539236 1 0.000 0.978 1.000 0.000
#> SRR1539237 2 0.000 1.000 0.000 1.000
#> SRR1539238 1 0.000 0.978 1.000 0.000
#> SRR1539239 1 0.000 0.978 1.000 0.000
#> SRR1539242 1 0.000 0.978 1.000 0.000
#> SRR1539240 2 0.000 1.000 0.000 1.000
#> SRR1539241 1 0.000 0.978 1.000 0.000
#> SRR1539243 2 0.000 1.000 0.000 1.000
#> SRR1539244 1 0.000 0.978 1.000 0.000
#> SRR1539245 1 0.000 0.978 1.000 0.000
#> SRR1539246 2 0.000 1.000 0.000 1.000
#> SRR1539247 1 0.000 0.978 1.000 0.000
#> SRR1539248 1 0.000 0.978 1.000 0.000
#> SRR1539249 2 0.000 1.000 0.000 1.000
#> SRR1539250 1 0.000 0.978 1.000 0.000
#> SRR1539251 1 0.000 0.978 1.000 0.000
#> SRR1539253 2 0.000 1.000 0.000 1.000
#> SRR1539252 1 0.000 0.978 1.000 0.000
#> SRR1539255 1 0.000 0.978 1.000 0.000
#> SRR1539254 1 0.000 0.978 1.000 0.000
#> SRR1539256 2 0.000 1.000 0.000 1.000
#> SRR1539257 1 0.000 0.978 1.000 0.000
#> SRR1539258 1 0.000 0.978 1.000 0.000
#> SRR1539259 2 0.000 1.000 0.000 1.000
#> SRR1539260 1 0.000 0.978 1.000 0.000
#> SRR1539262 2 0.000 1.000 0.000 1.000
#> SRR1539261 1 0.961 0.394 0.616 0.384
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.000 1.000 0.000 0 1.000
#> SRR1539208 1 0.000 0.978 1.000 0 0.000
#> SRR1539211 1 0.000 0.978 1.000 0 0.000
#> SRR1539210 3 0.000 1.000 0.000 0 1.000
#> SRR1539209 2 0.000 1.000 0.000 1 0.000
#> SRR1539212 2 0.000 1.000 0.000 1 0.000
#> SRR1539214 1 0.000 0.978 1.000 0 0.000
#> SRR1539213 3 0.000 1.000 0.000 0 1.000
#> SRR1539215 2 0.000 1.000 0.000 1 0.000
#> SRR1539216 3 0.000 1.000 0.000 0 1.000
#> SRR1539217 1 0.000 0.978 1.000 0 0.000
#> SRR1539218 2 0.000 1.000 0.000 1 0.000
#> SRR1539220 1 0.597 0.428 0.636 0 0.364
#> SRR1539219 3 0.000 1.000 0.000 0 1.000
#> SRR1539221 2 0.000 1.000 0.000 1 0.000
#> SRR1539223 1 0.000 0.978 1.000 0 0.000
#> SRR1539224 2 0.000 1.000 0.000 1 0.000
#> SRR1539222 3 0.000 1.000 0.000 0 1.000
#> SRR1539225 3 0.000 1.000 0.000 0 1.000
#> SRR1539227 2 0.000 1.000 0.000 1 0.000
#> SRR1539226 1 0.000 0.978 1.000 0 0.000
#> SRR1539228 3 0.000 1.000 0.000 0 1.000
#> SRR1539229 1 0.000 0.978 1.000 0 0.000
#> SRR1539232 3 0.000 1.000 0.000 0 1.000
#> SRR1539230 2 0.000 1.000 0.000 1 0.000
#> SRR1539231 2 0.000 1.000 0.000 1 0.000
#> SRR1539234 2 0.000 1.000 0.000 1 0.000
#> SRR1539233 1 0.000 0.978 1.000 0 0.000
#> SRR1539235 3 0.000 1.000 0.000 0 1.000
#> SRR1539236 1 0.000 0.978 1.000 0 0.000
#> SRR1539237 2 0.000 1.000 0.000 1 0.000
#> SRR1539238 3 0.000 1.000 0.000 0 1.000
#> SRR1539239 1 0.000 0.978 1.000 0 0.000
#> SRR1539242 1 0.000 0.978 1.000 0 0.000
#> SRR1539240 2 0.000 1.000 0.000 1 0.000
#> SRR1539241 3 0.000 1.000 0.000 0 1.000
#> SRR1539243 2 0.000 1.000 0.000 1 0.000
#> SRR1539244 3 0.000 1.000 0.000 0 1.000
#> SRR1539245 1 0.000 0.978 1.000 0 0.000
#> SRR1539246 2 0.000 1.000 0.000 1 0.000
#> SRR1539247 3 0.000 1.000 0.000 0 1.000
#> SRR1539248 1 0.000 0.978 1.000 0 0.000
#> SRR1539249 2 0.000 1.000 0.000 1 0.000
#> SRR1539250 3 0.000 1.000 0.000 0 1.000
#> SRR1539251 3 0.000 1.000 0.000 0 1.000
#> SRR1539253 2 0.000 1.000 0.000 1 0.000
#> SRR1539252 1 0.000 0.978 1.000 0 0.000
#> SRR1539255 1 0.000 0.978 1.000 0 0.000
#> SRR1539254 3 0.000 1.000 0.000 0 1.000
#> SRR1539256 2 0.000 1.000 0.000 1 0.000
#> SRR1539257 3 0.000 1.000 0.000 0 1.000
#> SRR1539258 1 0.000 0.978 1.000 0 0.000
#> SRR1539259 2 0.000 1.000 0.000 1 0.000
#> SRR1539260 3 0.000 1.000 0.000 0 1.000
#> SRR1539262 2 0.000 1.000 0.000 1 0.000
#> SRR1539261 1 0.000 0.978 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.4406 0.785 0.700 0.000 0.000 0.300
#> SRR1539211 1 0.4406 0.785 0.700 0.000 0.000 0.300
#> SRR1539210 3 0.4304 0.560 0.000 0.000 0.716 0.284
#> SRR1539209 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539212 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539214 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539213 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539215 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539216 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.3837 0.825 0.776 0.000 0.000 0.224
#> SRR1539218 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539220 1 0.4538 0.674 0.760 0.000 0.216 0.024
#> SRR1539219 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539223 1 0.4406 0.785 0.700 0.000 0.000 0.300
#> SRR1539224 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539222 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539227 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539226 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539228 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539229 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539232 3 0.0000 0.934 0.000 0.000 1.000 0.000
#> SRR1539230 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539231 2 0.2149 0.959 0.000 0.912 0.000 0.088
#> SRR1539234 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539233 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539235 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539236 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539237 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539238 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539239 1 0.0592 0.907 0.984 0.000 0.000 0.016
#> SRR1539242 1 0.0592 0.907 0.984 0.000 0.000 0.016
#> SRR1539240 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539241 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539243 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539244 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539245 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539246 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539247 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539248 1 0.0592 0.907 0.984 0.000 0.000 0.016
#> SRR1539249 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539250 4 0.4843 0.986 0.000 0.000 0.396 0.604
#> SRR1539251 4 0.4843 0.986 0.000 0.000 0.396 0.604
#> SRR1539253 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539255 1 0.0336 0.909 0.992 0.000 0.000 0.008
#> SRR1539254 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539256 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539257 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539258 1 0.0469 0.907 0.988 0.000 0.000 0.012
#> SRR1539259 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539260 4 0.4817 0.997 0.000 0.000 0.388 0.612
#> SRR1539262 2 0.0000 0.963 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.4406 0.785 0.700 0.000 0.000 0.300
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539208 4 0.382 0.989 0.304 0.000 0.000 0.696 0.000
#> SRR1539211 4 0.382 0.989 0.304 0.000 0.000 0.696 0.000
#> SRR1539210 3 0.429 0.264 0.000 0.000 0.536 0.464 0.000
#> SRR1539209 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539212 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539214 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539213 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539215 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539216 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539217 1 0.311 0.649 0.800 0.000 0.000 0.200 0.000
#> SRR1539218 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539220 1 0.233 0.742 0.876 0.000 0.000 0.000 0.124
#> SRR1539219 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539221 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539223 4 0.391 0.967 0.324 0.000 0.000 0.676 0.000
#> SRR1539224 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539222 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539225 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539227 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539226 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539228 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539229 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539232 3 0.161 0.943 0.000 0.000 0.928 0.000 0.072
#> SRR1539230 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539231 2 0.000 0.790 0.000 1.000 0.000 0.000 0.000
#> SRR1539234 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539233 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539235 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539236 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539237 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539238 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539239 1 0.202 0.858 0.900 0.000 0.000 0.100 0.000
#> SRR1539242 1 0.202 0.858 0.900 0.000 0.000 0.100 0.000
#> SRR1539240 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539241 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539243 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539244 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539245 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539246 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539247 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539248 1 0.202 0.858 0.900 0.000 0.000 0.100 0.000
#> SRR1539249 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539250 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539251 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539253 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539252 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.000 0.921 1.000 0.000 0.000 0.000 0.000
#> SRR1539254 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539256 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539257 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539258 1 0.127 0.893 0.948 0.000 0.000 0.052 0.000
#> SRR1539259 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539260 5 0.000 1.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539262 2 0.525 0.814 0.000 0.624 0.072 0.304 0.000
#> SRR1539261 4 0.382 0.989 0.304 0.000 0.000 0.696 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0146 0.941 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539208 6 0.0146 0.979 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1539211 6 0.0146 0.979 0.004 0.000 0.000 0.000 0.000 0.996
#> SRR1539210 3 0.3828 0.216 0.000 0.000 0.560 0.000 0.000 0.440
#> SRR1539209 4 0.0935 0.998 0.000 0.032 0.000 0.964 0.000 0.004
#> SRR1539212 4 0.0935 0.998 0.000 0.032 0.000 0.964 0.000 0.004
#> SRR1539214 1 0.0260 0.920 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR1539213 3 0.0291 0.941 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1539215 4 0.0790 0.998 0.000 0.032 0.000 0.968 0.000 0.000
#> SRR1539216 3 0.0146 0.941 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539217 1 0.2772 0.809 0.816 0.000 0.000 0.004 0.000 0.180
#> SRR1539218 4 0.0935 0.998 0.000 0.032 0.000 0.964 0.000 0.004
#> SRR1539220 1 0.1462 0.882 0.936 0.000 0.000 0.008 0.056 0.000
#> SRR1539219 3 0.0146 0.941 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539221 4 0.0790 0.998 0.000 0.032 0.000 0.968 0.000 0.000
#> SRR1539223 6 0.1141 0.938 0.052 0.000 0.000 0.000 0.000 0.948
#> SRR1539224 4 0.0935 0.998 0.000 0.032 0.000 0.964 0.000 0.004
#> SRR1539222 3 0.0146 0.941 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539225 3 0.0291 0.941 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1539227 4 0.0790 0.998 0.000 0.032 0.000 0.968 0.000 0.000
#> SRR1539226 1 0.0146 0.921 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1539228 3 0.0291 0.941 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1539229 1 0.0146 0.921 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1539232 3 0.0291 0.941 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1539230 4 0.0790 0.998 0.000 0.032 0.000 0.968 0.000 0.000
#> SRR1539231 4 0.0790 0.998 0.000 0.032 0.000 0.968 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539233 1 0.0146 0.921 0.996 0.000 0.000 0.004 0.000 0.000
#> SRR1539235 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539236 1 0.0777 0.919 0.972 0.000 0.004 0.024 0.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539239 1 0.3376 0.822 0.792 0.000 0.004 0.024 0.000 0.180
#> SRR1539242 1 0.3376 0.822 0.792 0.000 0.004 0.024 0.000 0.180
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539245 1 0.0000 0.922 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539248 1 0.3376 0.822 0.792 0.000 0.004 0.024 0.000 0.180
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539251 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.0260 0.921 0.992 0.000 0.000 0.008 0.000 0.000
#> SRR1539255 1 0.0777 0.919 0.972 0.000 0.004 0.024 0.000 0.000
#> SRR1539254 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539258 1 0.2152 0.895 0.904 0.000 0.004 0.024 0.000 0.068
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 6 0.0146 0.979 0.004 0.000 0.000 0.000 0.000 0.996
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.878 0.945 0.936 0.4458 0.782 0.599
#> 4 4 0.761 0.930 0.928 0.1009 0.942 0.820
#> 5 5 1.000 0.966 0.987 0.1009 0.896 0.634
#> 6 6 0.934 0.906 0.908 0.0311 0.953 0.785
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539208 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539211 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539210 3 0.0424 0.908 0.008 0.000 0.992
#> SRR1539209 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539212 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539214 1 0.2959 0.955 0.900 0.000 0.100
#> SRR1539213 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539215 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539216 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539217 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539218 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539220 3 0.5926 0.524 0.356 0.000 0.644
#> SRR1539219 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539221 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539223 3 0.5835 0.566 0.340 0.000 0.660
#> SRR1539224 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539222 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539225 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539227 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539226 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539228 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539229 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539232 3 0.0000 0.911 0.000 0.000 1.000
#> SRR1539230 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539231 2 0.0000 0.974 0.000 1.000 0.000
#> SRR1539234 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539233 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539235 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539236 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539237 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539238 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539239 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539242 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539240 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539241 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539243 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539244 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539245 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539246 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539247 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539248 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539249 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539250 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539251 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539253 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539252 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539255 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539254 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539256 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539257 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539258 1 0.2165 0.997 0.936 0.000 0.064
#> SRR1539259 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539260 3 0.2796 0.919 0.092 0.000 0.908
#> SRR1539262 2 0.2165 0.976 0.064 0.936 0.000
#> SRR1539261 1 0.2165 0.997 0.936 0.000 0.064
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539208 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539211 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539210 3 0.267 0.841 0.008 0.000 0.892 0.100
#> SRR1539209 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539212 4 0.336 0.908 0.000 0.176 0.000 0.824
#> SRR1539214 1 0.112 0.955 0.964 0.000 0.036 0.000
#> SRR1539213 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539215 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539216 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539217 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539218 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539220 3 0.491 0.483 0.420 0.000 0.580 0.000
#> SRR1539219 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539221 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539223 3 0.480 0.568 0.384 0.000 0.616 0.000
#> SRR1539224 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539222 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539225 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539227 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539226 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539228 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539229 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539232 3 0.234 0.843 0.000 0.000 0.900 0.100
#> SRR1539230 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539231 4 0.234 0.989 0.000 0.100 0.000 0.900
#> SRR1539234 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539233 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539235 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539236 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539237 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539238 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539239 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539241 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539243 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539244 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539245 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539246 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539247 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539248 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539250 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539251 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539253 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539255 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539254 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539256 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539257 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539258 1 0.000 0.997 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539260 3 0.276 0.868 0.128 0.000 0.872 0.000
#> SRR1539262 2 0.000 1.000 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.000 0.997 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539208 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539211 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539210 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539209 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539212 4 0.167 0.918 0.000 0.076 0 0.924 0.000
#> SRR1539214 5 0.425 0.290 0.432 0.000 0 0.000 0.568
#> SRR1539213 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539215 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539216 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539217 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539218 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539220 5 0.342 0.686 0.240 0.000 0 0.000 0.760
#> SRR1539219 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539221 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539223 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539224 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539222 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539225 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539227 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539226 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539228 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539229 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539232 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539230 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539231 4 0.000 0.990 0.000 0.000 0 1.000 0.000
#> SRR1539234 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539233 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539235 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539236 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539237 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539238 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539239 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539242 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539240 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539241 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539243 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539244 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539245 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539246 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539247 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539248 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539249 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539250 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539251 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539253 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539252 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539255 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539254 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539256 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539257 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539258 1 0.000 1.000 1.000 0.000 0 0.000 0.000
#> SRR1539259 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539260 5 0.000 0.928 0.000 0.000 0 0.000 1.000
#> SRR1539262 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539261 1 0.000 1.000 1.000 0.000 0 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539208 1 0.5258 0.723 0.596 0 0 0.252 0.152 0.000
#> SRR1539211 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539210 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539209 6 0.0000 0.998 0.000 0 0 0.000 0.000 1.000
#> SRR1539212 6 0.0000 0.998 0.000 0 0 0.000 0.000 1.000
#> SRR1539214 1 0.2527 0.515 0.832 0 0 0.000 0.168 0.000
#> SRR1539213 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539215 4 0.3765 1.000 0.000 0 0 0.596 0.000 0.404
#> SRR1539216 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539217 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539218 6 0.0146 0.993 0.000 0 0 0.004 0.000 0.996
#> SRR1539220 1 0.3647 0.111 0.640 0 0 0.000 0.360 0.000
#> SRR1539219 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539221 4 0.3765 1.000 0.000 0 0 0.596 0.000 0.404
#> SRR1539223 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539224 6 0.0000 0.998 0.000 0 0 0.000 0.000 1.000
#> SRR1539222 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539227 4 0.3765 1.000 0.000 0 0 0.596 0.000 0.404
#> SRR1539226 1 0.0000 0.678 1.000 0 0 0.000 0.000 0.000
#> SRR1539228 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539229 1 0.0000 0.678 1.000 0 0 0.000 0.000 0.000
#> SRR1539232 3 0.0000 1.000 0.000 0 1 0.000 0.000 0.000
#> SRR1539230 4 0.3765 1.000 0.000 0 0 0.596 0.000 0.404
#> SRR1539231 4 0.3765 1.000 0.000 0 0 0.596 0.000 0.404
#> SRR1539234 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539233 1 0.0000 0.678 1.000 0 0 0.000 0.000 0.000
#> SRR1539235 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539236 1 0.0146 0.680 0.996 0 0 0.004 0.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539238 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539239 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539242 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539241 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539244 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539245 1 0.0000 0.678 1.000 0 0 0.000 0.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539247 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539248 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539250 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539251 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539252 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539255 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539254 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539257 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539258 1 0.3765 0.802 0.596 0 0 0.404 0.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539260 5 0.0000 1.000 0.000 0 0 0.000 1.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0 0.000 0.000 0.000
#> SRR1539261 1 0.3765 0.802 0.596 0 0 0.404 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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.457 0.544 0.544
#> 3 3 0.779 0.922 0.878 0.248 0.849 0.723
#> 4 4 0.936 0.935 0.965 0.182 0.919 0.798
#> 5 5 0.825 0.807 0.885 0.102 0.958 0.872
#> 6 6 0.934 0.917 0.960 0.101 0.884 0.598
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4
There is also optional best \(k\) = 2 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.6204 0.986 0.424 0.000 0.576
#> SRR1539208 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539211 1 0.1411 0.932 0.964 0.000 0.036
#> SRR1539210 3 0.6126 0.958 0.400 0.000 0.600
#> SRR1539209 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539212 2 0.0592 0.854 0.000 0.988 0.012
#> SRR1539214 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539213 3 0.6215 0.986 0.428 0.000 0.572
#> SRR1539215 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539216 3 0.6204 0.986 0.424 0.000 0.576
#> SRR1539217 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539218 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539220 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539219 3 0.6215 0.986 0.428 0.000 0.572
#> SRR1539221 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539223 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539224 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539222 3 0.6168 0.974 0.412 0.000 0.588
#> SRR1539225 3 0.6215 0.986 0.428 0.000 0.572
#> SRR1539227 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539226 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539228 3 0.6225 0.981 0.432 0.000 0.568
#> SRR1539229 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539232 1 0.4555 0.474 0.800 0.000 0.200
#> SRR1539230 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539231 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539234 2 0.0000 0.859 0.000 1.000 0.000
#> SRR1539233 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539235 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539236 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539237 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539238 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539239 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539242 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539240 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539241 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539243 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539244 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539245 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539246 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539247 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539248 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539249 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539250 1 0.0237 0.978 0.996 0.000 0.004
#> SRR1539251 1 0.0424 0.973 0.992 0.000 0.008
#> SRR1539253 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539252 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539255 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539254 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539256 2 0.6126 0.795 0.000 0.600 0.400
#> SRR1539257 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539258 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539259 2 0.4291 0.842 0.000 0.820 0.180
#> SRR1539260 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539262 2 0.4291 0.842 0.000 0.820 0.180
#> SRR1539261 1 0.0747 0.961 0.984 0.000 0.016
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.2216 0.848 0.092 0.000 0.908 0.000
#> SRR1539208 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539211 1 0.3486 0.852 0.864 0.000 0.092 0.044
#> SRR1539210 3 0.1022 0.888 0.000 0.000 0.968 0.032
#> SRR1539209 4 0.3123 0.856 0.000 0.156 0.000 0.844
#> SRR1539212 2 0.4643 0.440 0.000 0.656 0.000 0.344
#> SRR1539214 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539213 3 0.0000 0.902 0.000 0.000 1.000 0.000
#> SRR1539215 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539216 3 0.0000 0.902 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539218 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539220 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539219 3 0.0000 0.902 0.000 0.000 1.000 0.000
#> SRR1539221 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539223 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539224 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539222 3 0.0000 0.902 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.902 0.000 0.000 1.000 0.000
#> SRR1539227 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539226 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539228 3 0.2281 0.845 0.096 0.000 0.904 0.000
#> SRR1539229 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539232 3 0.4585 0.547 0.332 0.000 0.668 0.000
#> SRR1539230 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539231 4 0.1302 0.982 0.000 0.044 0.000 0.956
#> SRR1539234 2 0.2011 0.882 0.000 0.920 0.000 0.080
#> SRR1539233 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539235 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539236 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539238 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539239 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539241 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539243 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539244 1 0.1557 0.946 0.944 0.000 0.056 0.000
#> SRR1539245 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539247 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539248 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539250 1 0.1022 0.965 0.968 0.000 0.032 0.000
#> SRR1539251 1 0.1022 0.965 0.968 0.000 0.032 0.000
#> SRR1539253 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539254 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539256 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539257 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539258 1 0.0000 0.981 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539260 1 0.0592 0.976 0.984 0.000 0.016 0.000
#> SRR1539262 2 0.0000 0.954 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.3486 0.852 0.864 0.000 0.092 0.044
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0162 0.912 0.000 0.000 0.996 0.000 0.004
#> SRR1539208 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539211 5 0.4210 0.588 0.412 0.000 0.000 0.000 0.588
#> SRR1539210 3 0.1965 0.842 0.000 0.000 0.904 0.000 0.096
#> SRR1539209 4 0.6059 0.783 0.000 0.120 0.000 0.468 0.412
#> SRR1539212 5 0.5143 -0.285 0.000 0.368 0.000 0.048 0.584
#> SRR1539214 1 0.2929 0.755 0.820 0.000 0.000 0.180 0.000
#> SRR1539213 3 0.0000 0.914 0.000 0.000 1.000 0.000 0.000
#> SRR1539215 4 0.4126 0.970 0.000 0.000 0.000 0.620 0.380
#> SRR1539216 3 0.0000 0.914 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 1 0.0290 0.760 0.992 0.000 0.000 0.008 0.000
#> SRR1539218 4 0.4150 0.967 0.000 0.000 0.000 0.612 0.388
#> SRR1539220 1 0.3003 0.754 0.812 0.000 0.000 0.188 0.000
#> SRR1539219 3 0.0000 0.914 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 4 0.4126 0.970 0.000 0.000 0.000 0.620 0.380
#> SRR1539223 1 0.2929 0.755 0.820 0.000 0.000 0.180 0.000
#> SRR1539224 4 0.4150 0.967 0.000 0.000 0.000 0.612 0.388
#> SRR1539222 3 0.0000 0.914 0.000 0.000 1.000 0.000 0.000
#> SRR1539225 3 0.0000 0.914 0.000 0.000 1.000 0.000 0.000
#> SRR1539227 4 0.4126 0.970 0.000 0.000 0.000 0.620 0.380
#> SRR1539226 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539228 3 0.0510 0.906 0.000 0.000 0.984 0.000 0.016
#> SRR1539229 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539232 3 0.6026 0.299 0.228 0.000 0.580 0.192 0.000
#> SRR1539230 4 0.4126 0.970 0.000 0.000 0.000 0.620 0.380
#> SRR1539231 4 0.4126 0.970 0.000 0.000 0.000 0.620 0.380
#> SRR1539234 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539233 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539235 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539236 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539238 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539239 1 0.0162 0.756 0.996 0.000 0.000 0.000 0.004
#> SRR1539242 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539241 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539243 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539244 1 0.4757 0.693 0.596 0.000 0.000 0.380 0.024
#> SRR1539245 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539247 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539248 1 0.0404 0.747 0.988 0.000 0.000 0.000 0.012
#> SRR1539249 2 0.0290 0.992 0.000 0.992 0.000 0.000 0.008
#> SRR1539250 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539251 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539253 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539252 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539254 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539256 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539257 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539258 1 0.0000 0.759 1.000 0.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539260 1 0.4126 0.714 0.620 0.000 0.000 0.380 0.000
#> SRR1539262 2 0.0000 0.999 0.000 1.000 0.000 0.000 0.000
#> SRR1539261 5 0.4210 0.588 0.412 0.000 0.000 0.000 0.588
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 1 0.0146 0.938 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539211 6 0.2416 1.000 0.156 0.000 0.000 0.000 0.000 0.844
#> SRR1539210 3 0.0632 0.950 0.000 0.000 0.976 0.000 0.000 0.024
#> SRR1539209 4 0.2655 0.868 0.000 0.008 0.000 0.848 0.004 0.140
#> SRR1539212 4 0.4456 0.725 0.000 0.132 0.000 0.724 0.004 0.140
#> SRR1539214 5 0.2883 0.718 0.212 0.000 0.000 0.000 0.788 0.000
#> SRR1539213 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539215 4 0.0000 0.940 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 1 0.3797 0.164 0.580 0.000 0.000 0.000 0.420 0.000
#> SRR1539218 4 0.1075 0.929 0.000 0.000 0.000 0.952 0.000 0.048
#> SRR1539220 5 0.2823 0.729 0.204 0.000 0.000 0.000 0.796 0.000
#> SRR1539219 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 4 0.0000 0.940 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539223 5 0.2854 0.724 0.208 0.000 0.000 0.000 0.792 0.000
#> SRR1539224 4 0.1075 0.929 0.000 0.000 0.000 0.952 0.000 0.048
#> SRR1539222 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539227 4 0.0000 0.940 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539226 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539228 3 0.0000 0.967 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539232 3 0.2697 0.728 0.000 0.000 0.812 0.000 0.188 0.000
#> SRR1539230 4 0.0000 0.940 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539231 4 0.0000 0.940 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.0935 0.961 0.000 0.964 0.000 0.004 0.000 0.032
#> SRR1539233 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539235 5 0.0146 0.923 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1539236 1 0.0146 0.938 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1539237 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.0363 0.923 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1539239 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.0146 0.923 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1539243 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.0363 0.923 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1539245 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.0146 0.923 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1539248 1 0.0146 0.938 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539249 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 5 0.0291 0.922 0.004 0.000 0.004 0.000 0.992 0.000
#> SRR1539251 5 0.0291 0.922 0.004 0.000 0.004 0.000 0.992 0.000
#> SRR1539253 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.0260 0.933 0.992 0.000 0.000 0.000 0.008 0.000
#> SRR1539255 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539254 5 0.0363 0.923 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1539256 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.0146 0.923 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1539258 1 0.0000 0.941 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.0363 0.923 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1539262 2 0.0000 0.996 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 6 0.2416 1.000 0.156 0.000 0.000 0.000 0.000 0.844
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'SD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.830 0.923 0.951 0.4239 0.805 0.642
#> 4 4 0.869 0.846 0.881 0.0838 0.962 0.891
#> 5 5 0.915 0.929 0.949 0.0673 0.942 0.813
#> 6 6 0.967 0.940 0.962 0.0688 0.899 0.636
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 5
There is also optional best \(k\) = 2 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539208 1 0.1529 0.904 0.960 0.000 0.040
#> SRR1539211 1 0.0000 0.893 1.000 0.000 0.000
#> SRR1539210 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539214 1 0.3619 0.898 0.864 0.000 0.136
#> SRR1539213 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539216 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539217 1 0.3551 0.899 0.868 0.000 0.132
#> SRR1539218 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539220 1 0.3879 0.891 0.848 0.000 0.152
#> SRR1539219 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539223 1 0.3619 0.898 0.864 0.000 0.136
#> SRR1539224 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539222 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539225 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539226 1 0.3267 0.902 0.884 0.000 0.116
#> SRR1539228 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539229 1 0.1964 0.905 0.944 0.000 0.056
#> SRR1539232 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539230 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539233 1 0.0592 0.898 0.988 0.000 0.012
#> SRR1539235 1 0.3941 0.888 0.844 0.000 0.156
#> SRR1539236 1 0.0747 0.900 0.984 0.000 0.016
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539238 1 0.4002 0.886 0.840 0.000 0.160
#> SRR1539239 1 0.0000 0.893 1.000 0.000 0.000
#> SRR1539242 1 0.0000 0.893 1.000 0.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539241 1 0.3879 0.891 0.848 0.000 0.152
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539244 1 0.4842 0.821 0.776 0.000 0.224
#> SRR1539245 1 0.1031 0.902 0.976 0.000 0.024
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539247 3 0.5678 0.408 0.316 0.000 0.684
#> SRR1539248 1 0.0000 0.893 1.000 0.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539250 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539251 3 0.0000 0.965 0.000 0.000 1.000
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539252 1 0.3116 0.903 0.892 0.000 0.108
#> SRR1539255 1 0.0892 0.901 0.980 0.000 0.020
#> SRR1539254 1 0.4002 0.885 0.840 0.000 0.160
#> SRR1539256 2 0.0424 0.993 0.008 0.992 0.000
#> SRR1539257 1 0.6291 0.310 0.532 0.000 0.468
#> SRR1539258 1 0.0592 0.898 0.988 0.000 0.012
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539260 1 0.4504 0.854 0.804 0.000 0.196
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000
#> SRR1539261 1 0.0000 0.893 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.0188 0.9243 0.996 0.000 0.000 0.004
#> SRR1539211 1 0.0804 0.9161 0.980 0.000 0.012 0.008
#> SRR1539210 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539209 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539212 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539214 1 0.2760 0.7958 0.872 0.000 0.000 0.128
#> SRR1539213 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539215 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539216 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.0336 0.9237 0.992 0.000 0.008 0.000
#> SRR1539218 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539220 1 0.1305 0.9110 0.960 0.000 0.004 0.036
#> SRR1539219 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539223 1 0.0469 0.9213 0.988 0.000 0.012 0.000
#> SRR1539224 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539222 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539227 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539226 1 0.0707 0.9213 0.980 0.000 0.000 0.020
#> SRR1539228 3 0.0000 0.9881 0.000 0.000 1.000 0.000
#> SRR1539229 1 0.0921 0.9181 0.972 0.000 0.000 0.028
#> SRR1539232 3 0.1109 0.9617 0.004 0.000 0.968 0.028
#> SRR1539230 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539231 2 0.4948 0.7533 0.000 0.560 0.000 0.440
#> SRR1539234 2 0.0188 0.7811 0.000 0.996 0.000 0.004
#> SRR1539233 1 0.0817 0.9197 0.976 0.000 0.000 0.024
#> SRR1539235 1 0.4837 0.0577 0.648 0.000 0.004 0.348
#> SRR1539236 1 0.0188 0.9247 0.996 0.000 0.000 0.004
#> SRR1539237 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539238 1 0.3450 0.7362 0.836 0.000 0.008 0.156
#> SRR1539239 1 0.0188 0.9243 0.996 0.000 0.000 0.004
#> SRR1539242 1 0.0188 0.9243 0.996 0.000 0.000 0.004
#> SRR1539240 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539241 1 0.2773 0.8159 0.880 0.000 0.004 0.116
#> SRR1539243 2 0.0188 0.7788 0.000 0.996 0.000 0.004
#> SRR1539244 4 0.5815 0.6801 0.428 0.000 0.032 0.540
#> SRR1539245 1 0.0817 0.9203 0.976 0.000 0.000 0.024
#> SRR1539246 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539247 4 0.7390 0.7219 0.252 0.000 0.228 0.520
#> SRR1539248 1 0.0188 0.9243 0.996 0.000 0.000 0.004
#> SRR1539249 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539250 3 0.1042 0.9629 0.020 0.000 0.972 0.008
#> SRR1539251 3 0.1042 0.9629 0.020 0.000 0.972 0.008
#> SRR1539253 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0000 0.9247 1.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.9247 1.000 0.000 0.000 0.000
#> SRR1539254 1 0.1584 0.9039 0.952 0.000 0.012 0.036
#> SRR1539256 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539257 4 0.6887 0.8008 0.356 0.000 0.116 0.528
#> SRR1539258 1 0.0188 0.9243 0.996 0.000 0.000 0.004
#> SRR1539259 2 0.0000 0.7810 0.000 1.000 0.000 0.000
#> SRR1539260 1 0.2759 0.8474 0.904 0.000 0.044 0.052
#> SRR1539262 2 0.0188 0.7788 0.000 0.996 0.000 0.004
#> SRR1539261 1 0.0592 0.9165 0.984 0.000 0.000 0.016
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539208 1 0.1478 0.904 0.936 0.000 0.000 0.000 0.064
#> SRR1539211 1 0.0609 0.923 0.980 0.000 0.000 0.000 0.020
#> SRR1539210 3 0.0671 0.955 0.004 0.000 0.980 0.000 0.016
#> SRR1539209 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539212 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539214 1 0.2127 0.879 0.892 0.000 0.000 0.000 0.108
#> SRR1539213 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539215 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539216 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 1 0.0000 0.927 1.000 0.000 0.000 0.000 0.000
#> SRR1539218 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539220 1 0.0898 0.926 0.972 0.000 0.008 0.000 0.020
#> SRR1539219 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539223 1 0.0404 0.924 0.988 0.000 0.000 0.000 0.012
#> SRR1539224 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539222 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539225 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539227 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539226 1 0.0671 0.927 0.980 0.004 0.000 0.000 0.016
#> SRR1539228 3 0.0000 0.971 0.000 0.000 1.000 0.000 0.000
#> SRR1539229 1 0.0963 0.923 0.964 0.000 0.000 0.000 0.036
#> SRR1539232 3 0.0451 0.964 0.000 0.004 0.988 0.000 0.008
#> SRR1539230 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539231 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539234 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539233 1 0.1270 0.917 0.948 0.000 0.000 0.000 0.052
#> SRR1539235 1 0.4350 0.421 0.588 0.000 0.004 0.000 0.408
#> SRR1539236 1 0.0609 0.926 0.980 0.000 0.000 0.000 0.020
#> SRR1539237 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539238 1 0.3582 0.761 0.768 0.000 0.008 0.000 0.224
#> SRR1539239 1 0.0162 0.927 0.996 0.004 0.000 0.000 0.000
#> SRR1539242 1 0.0162 0.927 0.996 0.004 0.000 0.000 0.000
#> SRR1539240 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539241 1 0.3039 0.807 0.808 0.000 0.000 0.000 0.192
#> SRR1539243 2 0.1197 0.996 0.000 0.952 0.000 0.048 0.000
#> SRR1539244 5 0.1018 0.748 0.016 0.000 0.016 0.000 0.968
#> SRR1539245 1 0.1285 0.922 0.956 0.004 0.004 0.000 0.036
#> SRR1539246 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539247 5 0.4552 0.760 0.040 0.000 0.264 0.000 0.696
#> SRR1539248 1 0.0000 0.927 1.000 0.000 0.000 0.000 0.000
#> SRR1539249 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539250 3 0.2069 0.877 0.012 0.000 0.912 0.000 0.076
#> SRR1539251 3 0.2069 0.877 0.012 0.000 0.912 0.000 0.076
#> SRR1539253 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539252 1 0.0162 0.927 0.996 0.000 0.000 0.000 0.004
#> SRR1539255 1 0.0162 0.927 0.996 0.000 0.000 0.000 0.004
#> SRR1539254 1 0.2674 0.849 0.856 0.000 0.004 0.000 0.140
#> SRR1539256 2 0.1197 0.996 0.000 0.952 0.000 0.048 0.000
#> SRR1539257 5 0.4627 0.811 0.080 0.000 0.188 0.000 0.732
#> SRR1539258 1 0.0162 0.927 0.996 0.000 0.000 0.000 0.004
#> SRR1539259 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539260 1 0.3714 0.806 0.812 0.000 0.056 0.000 0.132
#> SRR1539262 2 0.1270 0.999 0.000 0.948 0.000 0.052 0.000
#> SRR1539261 1 0.0404 0.924 0.988 0.000 0.000 0.000 0.012
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0146 0.981 0.000 0 0.996 0.000 0.000 NA
#> SRR1539208 5 0.4561 0.105 0.428 0 0.000 0.000 0.536 NA
#> SRR1539211 1 0.3014 0.860 0.832 0 0.000 0.000 0.132 NA
#> SRR1539210 3 0.1285 0.942 0.000 0 0.944 0.000 0.052 NA
#> SRR1539209 4 0.0146 0.998 0.000 0 0.000 0.996 0.000 NA
#> SRR1539212 4 0.0146 0.998 0.000 0 0.000 0.996 0.000 NA
#> SRR1539214 1 0.1719 0.923 0.924 0 0.016 0.000 0.000 NA
#> SRR1539213 3 0.0458 0.980 0.000 0 0.984 0.000 0.000 NA
#> SRR1539215 4 0.0146 0.998 0.000 0 0.000 0.996 0.000 NA
#> SRR1539216 3 0.0146 0.981 0.000 0 0.996 0.000 0.000 NA
#> SRR1539217 1 0.0146 0.950 0.996 0 0.004 0.000 0.000 NA
#> SRR1539218 4 0.0000 0.999 0.000 0 0.000 1.000 0.000 NA
#> SRR1539220 1 0.2000 0.918 0.916 0 0.048 0.000 0.004 NA
#> SRR1539219 3 0.0000 0.982 0.000 0 1.000 0.000 0.000 NA
#> SRR1539221 4 0.0000 0.999 0.000 0 0.000 1.000 0.000 NA
#> SRR1539223 1 0.2277 0.916 0.892 0 0.000 0.000 0.076 NA
#> SRR1539224 4 0.0000 0.999 0.000 0 0.000 1.000 0.000 NA
#> SRR1539222 3 0.0291 0.980 0.000 0 0.992 0.000 0.004 NA
#> SRR1539225 3 0.0458 0.980 0.000 0 0.984 0.000 0.000 NA
#> SRR1539227 4 0.0000 0.999 0.000 0 0.000 1.000 0.000 NA
#> SRR1539226 1 0.0717 0.945 0.976 0 0.008 0.000 0.000 NA
#> SRR1539228 3 0.0458 0.980 0.000 0 0.984 0.000 0.000 NA
#> SRR1539229 1 0.0260 0.950 0.992 0 0.000 0.000 0.000 NA
#> SRR1539232 3 0.1141 0.965 0.000 0 0.948 0.000 0.000 NA
#> SRR1539230 4 0.0000 0.999 0.000 0 0.000 1.000 0.000 NA
#> SRR1539231 4 0.0000 0.999 0.000 0 0.000 1.000 0.000 NA
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539233 1 0.0260 0.951 0.992 0 0.000 0.000 0.008 NA
#> SRR1539235 5 0.1349 0.895 0.004 0 0.000 0.000 0.940 NA
#> SRR1539236 1 0.0363 0.951 0.988 0 0.000 0.000 0.012 NA
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539238 5 0.0551 0.903 0.004 0 0.004 0.000 0.984 NA
#> SRR1539239 1 0.1391 0.939 0.944 0 0.000 0.000 0.040 NA
#> SRR1539242 1 0.1829 0.929 0.920 0 0.000 0.000 0.056 NA
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539241 5 0.0291 0.903 0.004 0 0.004 0.000 0.992 NA
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539244 5 0.2442 0.854 0.004 0 0.000 0.000 0.852 NA
#> SRR1539245 1 0.0713 0.945 0.972 0 0.000 0.000 0.000 NA
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539247 5 0.1788 0.888 0.004 0 0.004 0.000 0.916 NA
#> SRR1539248 1 0.2046 0.923 0.908 0 0.000 0.000 0.060 NA
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539250 5 0.1492 0.888 0.000 0 0.036 0.000 0.940 NA
#> SRR1539251 5 0.1572 0.886 0.000 0 0.036 0.000 0.936 NA
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539252 1 0.0146 0.950 0.996 0 0.000 0.000 0.000 NA
#> SRR1539255 1 0.0000 0.950 1.000 0 0.000 0.000 0.000 NA
#> SRR1539254 5 0.1003 0.898 0.004 0 0.004 0.000 0.964 NA
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539257 5 0.1843 0.887 0.004 0 0.004 0.000 0.912 NA
#> SRR1539258 1 0.0146 0.950 0.996 0 0.000 0.000 0.000 NA
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539260 5 0.0653 0.902 0.004 0 0.004 0.000 0.980 NA
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 NA
#> SRR1539261 1 0.2509 0.903 0.876 0 0.000 0.000 0.088 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", "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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.4570 0.544 0.544
#> 3 3 0.624 0.681 0.843 0.3339 0.914 0.842
#> 4 4 0.706 0.775 0.823 0.1393 0.896 0.779
#> 5 5 0.771 0.765 0.802 0.0882 0.856 0.621
#> 6 6 0.835 0.788 0.836 0.0438 0.987 0.945
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 1 0.6192 -0.216 0.580 0.0 0.420
#> SRR1539208 1 0.0237 0.691 0.996 0.0 0.004
#> SRR1539211 1 0.0237 0.691 0.996 0.0 0.004
#> SRR1539210 1 0.6192 -0.216 0.580 0.0 0.420
#> SRR1539209 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539212 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539214 1 0.4291 0.683 0.820 0.0 0.180
#> SRR1539213 3 0.4605 1.000 0.204 0.0 0.796
#> SRR1539215 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539216 1 0.6192 -0.216 0.580 0.0 0.420
#> SRR1539217 1 0.0000 0.692 1.000 0.0 0.000
#> SRR1539218 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539220 1 0.4291 0.683 0.820 0.0 0.180
#> SRR1539219 1 0.6192 -0.228 0.580 0.0 0.420
#> SRR1539221 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539223 1 0.0000 0.692 1.000 0.0 0.000
#> SRR1539224 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539222 1 0.6192 -0.216 0.580 0.0 0.420
#> SRR1539225 3 0.4605 1.000 0.204 0.0 0.796
#> SRR1539227 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539226 1 0.4504 0.672 0.804 0.0 0.196
#> SRR1539228 3 0.4605 1.000 0.204 0.0 0.796
#> SRR1539229 1 0.4555 0.669 0.800 0.0 0.200
#> SRR1539232 3 0.4605 1.000 0.204 0.0 0.796
#> SRR1539230 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539231 2 0.4555 0.903 0.000 0.8 0.200
#> SRR1539234 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539233 1 0.4555 0.669 0.800 0.0 0.200
#> SRR1539235 1 0.6045 0.391 0.620 0.0 0.380
#> SRR1539236 1 0.6045 0.391 0.620 0.0 0.380
#> SRR1539237 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539238 1 0.3619 0.710 0.864 0.0 0.136
#> SRR1539239 1 0.0237 0.691 0.996 0.0 0.004
#> SRR1539242 1 0.0237 0.691 0.996 0.0 0.004
#> SRR1539240 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539241 1 0.3619 0.710 0.864 0.0 0.136
#> SRR1539243 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539244 1 0.6045 0.391 0.620 0.0 0.380
#> SRR1539245 1 0.6045 0.391 0.620 0.0 0.380
#> SRR1539246 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539247 1 0.3619 0.710 0.864 0.0 0.136
#> SRR1539248 1 0.0237 0.691 0.996 0.0 0.004
#> SRR1539249 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539250 1 0.2711 0.712 0.912 0.0 0.088
#> SRR1539251 1 0.2711 0.712 0.912 0.0 0.088
#> SRR1539253 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539252 1 0.3816 0.701 0.852 0.0 0.148
#> SRR1539255 1 0.6045 0.391 0.620 0.0 0.380
#> SRR1539254 1 0.3619 0.710 0.864 0.0 0.136
#> SRR1539256 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539257 1 0.3619 0.710 0.864 0.0 0.136
#> SRR1539258 1 0.0000 0.692 1.000 0.0 0.000
#> SRR1539259 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539260 1 0.3619 0.710 0.864 0.0 0.136
#> SRR1539262 2 0.0000 0.914 0.000 1.0 0.000
#> SRR1539261 1 0.0237 0.691 0.996 0.0 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.821 0.000 0.00 1.000 NA
#> SRR1539208 1 0.3688 0.775 0.792 0.00 0.000 NA
#> SRR1539211 1 0.3688 0.775 0.792 0.00 0.000 NA
#> SRR1539210 3 0.0000 0.821 0.000 0.00 1.000 NA
#> SRR1539209 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539212 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539214 1 0.1940 0.820 0.924 0.00 0.000 NA
#> SRR1539213 3 0.6501 0.771 0.116 0.00 0.616 NA
#> SRR1539215 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539216 3 0.0000 0.821 0.000 0.00 1.000 NA
#> SRR1539217 1 0.3528 0.783 0.808 0.00 0.000 NA
#> SRR1539218 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539220 1 0.1940 0.820 0.924 0.00 0.000 NA
#> SRR1539219 3 0.0376 0.822 0.004 0.00 0.992 NA
#> SRR1539221 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539223 1 0.3528 0.783 0.808 0.00 0.000 NA
#> SRR1539224 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539222 3 0.0000 0.821 0.000 0.00 1.000 NA
#> SRR1539225 3 0.6501 0.771 0.116 0.00 0.616 NA
#> SRR1539227 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539226 1 0.2216 0.815 0.908 0.00 0.000 NA
#> SRR1539228 3 0.6501 0.771 0.116 0.00 0.616 NA
#> SRR1539229 1 0.2408 0.810 0.896 0.00 0.000 NA
#> SRR1539232 3 0.6501 0.771 0.116 0.00 0.616 NA
#> SRR1539230 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539231 2 0.0000 0.755 0.000 1.00 0.000 NA
#> SRR1539234 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539233 1 0.2408 0.810 0.896 0.00 0.000 NA
#> SRR1539235 1 0.4679 0.600 0.648 0.00 0.000 NA
#> SRR1539236 1 0.4679 0.600 0.648 0.00 0.000 NA
#> SRR1539237 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539238 1 0.0921 0.834 0.972 0.00 0.000 NA
#> SRR1539239 1 0.3610 0.780 0.800 0.00 0.000 NA
#> SRR1539242 1 0.3610 0.780 0.800 0.00 0.000 NA
#> SRR1539240 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539241 1 0.0921 0.834 0.972 0.00 0.000 NA
#> SRR1539243 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539244 1 0.4679 0.600 0.648 0.00 0.000 NA
#> SRR1539245 1 0.4679 0.600 0.648 0.00 0.000 NA
#> SRR1539246 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539247 1 0.0921 0.834 0.972 0.00 0.000 NA
#> SRR1539248 1 0.3649 0.778 0.796 0.00 0.000 NA
#> SRR1539249 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539250 1 0.0817 0.830 0.976 0.00 0.000 NA
#> SRR1539251 1 0.0817 0.830 0.976 0.00 0.000 NA
#> SRR1539253 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539252 1 0.1792 0.829 0.932 0.00 0.000 NA
#> SRR1539255 1 0.4679 0.600 0.648 0.00 0.000 NA
#> SRR1539254 1 0.0921 0.834 0.972 0.00 0.000 NA
#> SRR1539256 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539257 1 0.0921 0.834 0.972 0.00 0.000 NA
#> SRR1539258 1 0.3528 0.783 0.808 0.00 0.000 NA
#> SRR1539259 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539260 1 0.0921 0.834 0.972 0.00 0.000 NA
#> SRR1539262 2 0.4948 0.783 0.000 0.56 0.000 NA
#> SRR1539261 1 0.3688 0.775 0.792 0.00 0.000 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.4138 0.838 0.000 0.384 0.616 0.000 0.000
#> SRR1539208 1 0.0000 0.659 1.000 0.000 0.000 0.000 0.000
#> SRR1539211 1 0.0000 0.659 1.000 0.000 0.000 0.000 0.000
#> SRR1539210 3 0.4150 0.837 0.000 0.388 0.612 0.000 0.000
#> SRR1539209 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539212 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539214 1 0.4088 0.574 0.632 0.000 0.000 0.000 0.368
#> SRR1539213 3 0.0609 0.795 0.000 0.000 0.980 0.000 0.020
#> SRR1539215 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539216 3 0.4138 0.838 0.000 0.384 0.616 0.000 0.000
#> SRR1539217 1 0.0510 0.667 0.984 0.000 0.000 0.000 0.016
#> SRR1539218 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539220 1 0.4088 0.574 0.632 0.000 0.000 0.000 0.368
#> SRR1539219 3 0.4101 0.839 0.000 0.372 0.628 0.000 0.000
#> SRR1539221 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539223 1 0.0510 0.667 0.984 0.000 0.000 0.000 0.016
#> SRR1539224 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539222 3 0.4138 0.838 0.000 0.384 0.616 0.000 0.000
#> SRR1539225 3 0.0609 0.795 0.000 0.000 0.980 0.000 0.020
#> SRR1539227 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539226 1 0.4138 0.557 0.616 0.000 0.000 0.000 0.384
#> SRR1539228 3 0.0609 0.795 0.000 0.000 0.980 0.000 0.020
#> SRR1539229 1 0.4201 0.525 0.592 0.000 0.000 0.000 0.408
#> SRR1539232 3 0.0609 0.795 0.000 0.000 0.980 0.000 0.020
#> SRR1539230 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539231 4 0.0000 1.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539234 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539233 1 0.4201 0.525 0.592 0.000 0.000 0.000 0.408
#> SRR1539235 5 0.0000 0.751 0.000 0.000 0.000 0.000 1.000
#> SRR1539236 5 0.0000 0.751 0.000 0.000 0.000 0.000 1.000
#> SRR1539237 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539238 1 0.4227 0.543 0.580 0.000 0.000 0.000 0.420
#> SRR1539239 1 0.0290 0.664 0.992 0.000 0.000 0.000 0.008
#> SRR1539242 1 0.0290 0.664 0.992 0.000 0.000 0.000 0.008
#> SRR1539240 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539241 1 0.4227 0.543 0.580 0.000 0.000 0.000 0.420
#> SRR1539243 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539244 5 0.1121 0.751 0.044 0.000 0.000 0.000 0.956
#> SRR1539245 5 0.2561 0.716 0.144 0.000 0.000 0.000 0.856
#> SRR1539246 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539247 1 0.4227 0.543 0.580 0.000 0.000 0.000 0.420
#> SRR1539248 1 0.0162 0.662 0.996 0.000 0.000 0.000 0.004
#> SRR1539249 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539250 1 0.4015 0.604 0.652 0.000 0.000 0.000 0.348
#> SRR1539251 1 0.4015 0.604 0.652 0.000 0.000 0.000 0.348
#> SRR1539253 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539252 1 0.3932 0.607 0.672 0.000 0.000 0.000 0.328
#> SRR1539255 5 0.2561 0.716 0.144 0.000 0.000 0.000 0.856
#> SRR1539254 5 0.4307 -0.459 0.496 0.000 0.000 0.000 0.504
#> SRR1539256 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539257 1 0.4227 0.543 0.580 0.000 0.000 0.000 0.420
#> SRR1539258 1 0.0510 0.667 0.984 0.000 0.000 0.000 0.016
#> SRR1539259 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539260 1 0.4227 0.543 0.580 0.000 0.000 0.000 0.420
#> SRR1539262 2 0.4150 1.000 0.000 0.612 0.000 0.388 0.000
#> SRR1539261 1 0.0000 0.659 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.981 0.000 0 1.000 0 0.000 0.000
#> SRR1539208 1 0.0000 0.657 1.000 0 0.000 0 0.000 0.000
#> SRR1539211 1 0.0000 0.657 1.000 0 0.000 0 0.000 0.000
#> SRR1539210 3 0.0363 0.972 0.000 0 0.988 0 0.000 0.012
#> SRR1539209 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539212 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539214 1 0.3672 0.570 0.632 0 0.000 0 0.368 0.000
#> SRR1539213 6 0.2883 1.000 0.000 0 0.212 0 0.000 0.788
#> SRR1539215 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539216 3 0.0146 0.982 0.000 0 0.996 0 0.000 0.004
#> SRR1539217 1 0.0458 0.664 0.984 0 0.000 0 0.016 0.000
#> SRR1539218 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539220 1 0.3672 0.570 0.632 0 0.000 0 0.368 0.000
#> SRR1539219 3 0.0937 0.948 0.000 0 0.960 0 0.000 0.040
#> SRR1539221 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539223 1 0.0458 0.664 0.984 0 0.000 0 0.016 0.000
#> SRR1539224 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539222 3 0.0146 0.982 0.000 0 0.996 0 0.000 0.004
#> SRR1539225 6 0.2883 1.000 0.000 0 0.212 0 0.000 0.788
#> SRR1539227 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539226 1 0.3717 0.554 0.616 0 0.000 0 0.384 0.000
#> SRR1539228 6 0.2883 1.000 0.000 0 0.212 0 0.000 0.788
#> SRR1539229 1 0.3774 0.523 0.592 0 0.000 0 0.408 0.000
#> SRR1539232 6 0.2883 1.000 0.000 0 0.212 0 0.000 0.788
#> SRR1539230 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539231 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539233 1 0.3774 0.523 0.592 0 0.000 0 0.408 0.000
#> SRR1539235 5 0.2793 0.722 0.000 0 0.000 0 0.800 0.200
#> SRR1539236 5 0.2793 0.722 0.000 0 0.000 0 0.800 0.200
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539238 1 0.3838 0.536 0.552 0 0.000 0 0.448 0.000
#> SRR1539239 1 0.0260 0.662 0.992 0 0.000 0 0.008 0.000
#> SRR1539242 1 0.0260 0.662 0.992 0 0.000 0 0.008 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539241 1 0.3838 0.536 0.552 0 0.000 0 0.448 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539244 5 0.0000 0.699 0.000 0 0.000 0 1.000 0.000
#> SRR1539245 5 0.2135 0.708 0.128 0 0.000 0 0.872 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539247 1 0.3838 0.536 0.552 0 0.000 0 0.448 0.000
#> SRR1539248 1 0.0146 0.659 0.996 0 0.000 0 0.004 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539250 1 0.3695 0.593 0.624 0 0.000 0 0.376 0.000
#> SRR1539251 1 0.3695 0.593 0.624 0 0.000 0 0.376 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539252 1 0.3531 0.601 0.672 0 0.000 0 0.328 0.000
#> SRR1539255 5 0.2135 0.708 0.128 0 0.000 0 0.872 0.000
#> SRR1539254 5 0.3847 -0.446 0.456 0 0.000 0 0.544 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539257 1 0.3838 0.536 0.552 0 0.000 0 0.448 0.000
#> SRR1539258 1 0.0458 0.664 0.984 0 0.000 0 0.016 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539260 1 0.3838 0.536 0.552 0 0.000 0 0.448 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539261 1 0.0000 0.657 1.000 0 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.778 0.953 0.918 0.3063 0.836 0.699
#> 4 4 0.674 0.830 0.777 0.1434 0.987 0.966
#> 5 5 0.716 0.687 0.721 0.0945 0.833 0.561
#> 6 6 0.700 0.633 0.744 0.0633 0.931 0.710
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539208 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539211 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539210 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539209 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539212 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539214 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539213 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539215 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539216 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539217 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539218 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539220 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539219 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539221 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539223 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539224 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539222 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539225 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539227 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539226 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539228 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539229 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539232 3 0.5016 1.000 0.240 0.000 0.760
#> SRR1539230 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539231 2 0.4974 0.887 0.000 0.764 0.236
#> SRR1539234 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539233 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539235 1 0.1411 0.969 0.964 0.000 0.036
#> SRR1539236 1 0.0237 0.981 0.996 0.000 0.004
#> SRR1539237 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539238 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539239 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539242 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539240 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539241 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539243 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539244 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539245 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539246 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539247 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539248 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539249 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539250 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539251 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539253 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539252 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539255 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539254 1 0.1163 0.972 0.972 0.000 0.028
#> SRR1539256 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539257 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539258 1 0.0000 0.984 1.000 0.000 0.000
#> SRR1539259 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539260 1 0.1289 0.970 0.968 0.000 0.032
#> SRR1539262 2 0.0000 0.899 0.000 1.000 0.000
#> SRR1539261 1 0.0000 0.984 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 4 0.6568 0.944 0.080 0.000 0.408 0.512
#> SRR1539208 1 0.3219 0.834 0.836 0.000 0.000 0.164
#> SRR1539211 1 0.3219 0.834 0.836 0.000 0.000 0.164
#> SRR1539210 4 0.6546 0.842 0.080 0.000 0.396 0.524
#> SRR1539209 2 0.0817 0.733 0.000 0.976 0.000 0.024
#> SRR1539212 2 0.0817 0.733 0.000 0.976 0.000 0.024
#> SRR1539214 1 0.0592 0.872 0.984 0.000 0.000 0.016
#> SRR1539213 3 0.6580 1.000 0.080 0.000 0.504 0.416
#> SRR1539215 2 0.0336 0.733 0.000 0.992 0.000 0.008
#> SRR1539216 4 0.6568 0.944 0.080 0.000 0.408 0.512
#> SRR1539217 1 0.3074 0.836 0.848 0.000 0.000 0.152
#> SRR1539218 2 0.0592 0.733 0.000 0.984 0.000 0.016
#> SRR1539220 1 0.0000 0.872 1.000 0.000 0.000 0.000
#> SRR1539219 3 0.6580 1.000 0.080 0.000 0.504 0.416
#> SRR1539221 2 0.0000 0.733 0.000 1.000 0.000 0.000
#> SRR1539223 1 0.3074 0.836 0.848 0.000 0.000 0.152
#> SRR1539224 2 0.0817 0.733 0.000 0.976 0.000 0.024
#> SRR1539222 4 0.6568 0.944 0.080 0.000 0.408 0.512
#> SRR1539225 3 0.6580 1.000 0.080 0.000 0.504 0.416
#> SRR1539227 2 0.0188 0.733 0.000 0.996 0.000 0.004
#> SRR1539226 1 0.1022 0.871 0.968 0.000 0.000 0.032
#> SRR1539228 3 0.6580 1.000 0.080 0.000 0.504 0.416
#> SRR1539229 1 0.1118 0.871 0.964 0.000 0.000 0.036
#> SRR1539232 3 0.6580 1.000 0.080 0.000 0.504 0.416
#> SRR1539230 2 0.0188 0.733 0.000 0.996 0.000 0.004
#> SRR1539231 2 0.0188 0.733 0.000 0.996 0.000 0.004
#> SRR1539234 2 0.5168 0.761 0.000 0.504 0.492 0.004
#> SRR1539233 1 0.1118 0.871 0.964 0.000 0.000 0.036
#> SRR1539235 1 0.4164 0.785 0.736 0.000 0.000 0.264
#> SRR1539236 1 0.3311 0.827 0.828 0.000 0.000 0.172
#> SRR1539237 2 0.5693 0.760 0.000 0.504 0.472 0.024
#> SRR1539238 1 0.2921 0.847 0.860 0.000 0.000 0.140
#> SRR1539239 1 0.3569 0.830 0.804 0.000 0.000 0.196
#> SRR1539242 1 0.3569 0.830 0.804 0.000 0.000 0.196
#> SRR1539240 2 0.5407 0.761 0.000 0.504 0.484 0.012
#> SRR1539241 1 0.2921 0.847 0.860 0.000 0.000 0.140
#> SRR1539243 2 0.5407 0.761 0.000 0.504 0.484 0.012
#> SRR1539244 1 0.3975 0.797 0.760 0.000 0.000 0.240
#> SRR1539245 1 0.3024 0.837 0.852 0.000 0.000 0.148
#> SRR1539246 2 0.5000 0.761 0.000 0.504 0.496 0.000
#> SRR1539247 1 0.2760 0.848 0.872 0.000 0.000 0.128
#> SRR1539248 1 0.3172 0.837 0.840 0.000 0.000 0.160
#> SRR1539249 2 0.5693 0.760 0.000 0.504 0.472 0.024
#> SRR1539250 1 0.2704 0.851 0.876 0.000 0.000 0.124
#> SRR1539251 1 0.2704 0.851 0.876 0.000 0.000 0.124
#> SRR1539253 2 0.5693 0.760 0.000 0.504 0.472 0.024
#> SRR1539252 1 0.1302 0.871 0.956 0.000 0.000 0.044
#> SRR1539255 1 0.2868 0.844 0.864 0.000 0.000 0.136
#> SRR1539254 1 0.2921 0.845 0.860 0.000 0.000 0.140
#> SRR1539256 2 0.5000 0.761 0.000 0.504 0.496 0.000
#> SRR1539257 1 0.2760 0.848 0.872 0.000 0.000 0.128
#> SRR1539258 1 0.3311 0.836 0.828 0.000 0.000 0.172
#> SRR1539259 2 0.5693 0.760 0.000 0.504 0.472 0.024
#> SRR1539260 1 0.2760 0.848 0.872 0.000 0.000 0.128
#> SRR1539262 2 0.5693 0.760 0.000 0.504 0.472 0.024
#> SRR1539261 1 0.3356 0.831 0.824 0.000 0.000 0.176
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.4074 0.932 0.052 0.092 0.820 0.000 0.036
#> SRR1539208 1 0.5344 0.790 0.500 0.052 0.000 0.000 0.448
#> SRR1539211 1 0.5344 0.790 0.500 0.052 0.000 0.000 0.448
#> SRR1539210 3 0.4414 0.920 0.060 0.108 0.796 0.000 0.036
#> SRR1539209 4 0.2179 0.920 0.112 0.000 0.000 0.888 0.000
#> SRR1539212 4 0.2179 0.920 0.112 0.000 0.000 0.888 0.000
#> SRR1539214 5 0.4795 0.373 0.224 0.072 0.000 0.000 0.704
#> SRR1539213 3 0.0963 0.947 0.000 0.000 0.964 0.000 0.036
#> SRR1539215 4 0.0703 0.935 0.024 0.000 0.000 0.976 0.000
#> SRR1539216 3 0.4074 0.932 0.052 0.092 0.820 0.000 0.036
#> SRR1539217 5 0.5376 -0.693 0.424 0.056 0.000 0.000 0.520
#> SRR1539218 4 0.2011 0.924 0.088 0.000 0.004 0.908 0.000
#> SRR1539220 5 0.4313 0.371 0.172 0.068 0.000 0.000 0.760
#> SRR1539219 3 0.0963 0.947 0.000 0.000 0.964 0.000 0.036
#> SRR1539221 4 0.0162 0.937 0.004 0.000 0.000 0.996 0.000
#> SRR1539223 5 0.5431 -0.693 0.424 0.060 0.000 0.000 0.516
#> SRR1539224 4 0.2233 0.922 0.104 0.000 0.004 0.892 0.000
#> SRR1539222 3 0.4074 0.932 0.052 0.092 0.820 0.000 0.036
#> SRR1539225 3 0.0963 0.947 0.000 0.000 0.964 0.000 0.036
#> SRR1539227 4 0.0162 0.937 0.004 0.000 0.000 0.996 0.000
#> SRR1539226 5 0.4755 0.358 0.244 0.060 0.000 0.000 0.696
#> SRR1539228 3 0.0963 0.947 0.000 0.000 0.964 0.000 0.036
#> SRR1539229 5 0.4755 0.367 0.244 0.060 0.000 0.000 0.696
#> SRR1539232 3 0.0963 0.947 0.000 0.000 0.964 0.000 0.036
#> SRR1539230 4 0.0162 0.937 0.000 0.000 0.004 0.996 0.000
#> SRR1539231 4 0.0162 0.937 0.000 0.000 0.004 0.996 0.000
#> SRR1539234 2 0.4749 0.945 0.020 0.620 0.004 0.356 0.000
#> SRR1539233 5 0.4755 0.367 0.244 0.060 0.000 0.000 0.696
#> SRR1539235 5 0.5426 0.392 0.160 0.160 0.004 0.000 0.676
#> SRR1539236 5 0.6491 0.219 0.336 0.200 0.000 0.000 0.464
#> SRR1539237 2 0.5649 0.919 0.060 0.572 0.012 0.356 0.000
#> SRR1539238 5 0.1686 0.543 0.028 0.020 0.008 0.000 0.944
#> SRR1539239 1 0.4470 0.811 0.616 0.012 0.000 0.000 0.372
#> SRR1539242 1 0.4470 0.811 0.616 0.012 0.000 0.000 0.372
#> SRR1539240 2 0.5307 0.933 0.044 0.592 0.008 0.356 0.000
#> SRR1539241 5 0.1686 0.543 0.028 0.020 0.008 0.000 0.944
#> SRR1539243 2 0.5370 0.932 0.048 0.588 0.008 0.356 0.000
#> SRR1539244 5 0.4446 0.470 0.116 0.100 0.008 0.000 0.776
#> SRR1539245 5 0.6068 0.263 0.328 0.140 0.000 0.000 0.532
#> SRR1539246 2 0.4347 0.948 0.004 0.636 0.004 0.356 0.000
#> SRR1539247 5 0.0579 0.555 0.000 0.008 0.008 0.000 0.984
#> SRR1539248 1 0.4718 0.841 0.540 0.016 0.000 0.000 0.444
#> SRR1539249 2 0.5274 0.941 0.036 0.596 0.012 0.356 0.000
#> SRR1539250 5 0.2178 0.522 0.024 0.048 0.008 0.000 0.920
#> SRR1539251 5 0.2178 0.522 0.024 0.048 0.008 0.000 0.920
#> SRR1539253 2 0.5274 0.941 0.036 0.596 0.012 0.356 0.000
#> SRR1539252 5 0.5008 0.245 0.300 0.056 0.000 0.000 0.644
#> SRR1539255 5 0.5996 0.149 0.388 0.116 0.000 0.000 0.496
#> SRR1539254 5 0.1299 0.553 0.020 0.012 0.008 0.000 0.960
#> SRR1539256 2 0.4347 0.948 0.004 0.636 0.004 0.356 0.000
#> SRR1539257 5 0.0451 0.555 0.000 0.004 0.008 0.000 0.988
#> SRR1539258 1 0.4201 0.816 0.592 0.000 0.000 0.000 0.408
#> SRR1539259 2 0.5274 0.941 0.036 0.596 0.012 0.356 0.000
#> SRR1539260 5 0.0579 0.555 0.000 0.008 0.008 0.000 0.984
#> SRR1539262 2 0.5274 0.941 0.036 0.596 0.012 0.356 0.000
#> SRR1539261 1 0.4867 0.843 0.544 0.024 0.000 0.000 0.432
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.3337 0.8628 0.000 0.000 0.736 0.000 0.004 0.260
#> SRR1539208 1 0.4704 0.6989 0.660 0.000 0.000 0.012 0.272 0.056
#> SRR1539211 1 0.4628 0.6999 0.668 0.000 0.000 0.012 0.268 0.052
#> SRR1539210 3 0.4139 0.8350 0.008 0.000 0.688 0.016 0.004 0.284
#> SRR1539209 4 0.5871 0.8749 0.008 0.280 0.000 0.520 0.000 0.192
#> SRR1539212 4 0.5871 0.8749 0.008 0.280 0.000 0.520 0.000 0.192
#> SRR1539214 5 0.6649 -0.0776 0.224 0.000 0.000 0.080 0.512 0.184
#> SRR1539213 3 0.0146 0.8933 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539215 4 0.4488 0.8948 0.004 0.280 0.000 0.664 0.000 0.052
#> SRR1539216 3 0.3337 0.8628 0.000 0.000 0.736 0.000 0.004 0.260
#> SRR1539217 1 0.4962 0.6547 0.608 0.000 0.000 0.012 0.320 0.060
#> SRR1539218 4 0.5657 0.8853 0.008 0.280 0.004 0.568 0.000 0.140
#> SRR1539220 5 0.6247 0.0252 0.188 0.000 0.000 0.068 0.572 0.172
#> SRR1539219 3 0.0405 0.8934 0.000 0.000 0.988 0.000 0.004 0.008
#> SRR1539221 4 0.3693 0.8974 0.008 0.280 0.004 0.708 0.000 0.000
#> SRR1539223 1 0.5156 0.6516 0.592 0.000 0.000 0.012 0.320 0.076
#> SRR1539224 4 0.5883 0.8804 0.008 0.280 0.004 0.536 0.000 0.172
#> SRR1539222 3 0.3337 0.8628 0.000 0.000 0.736 0.000 0.004 0.260
#> SRR1539225 3 0.0146 0.8933 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539227 4 0.3693 0.8938 0.008 0.280 0.000 0.708 0.000 0.004
#> SRR1539226 5 0.6702 -0.1263 0.252 0.000 0.000 0.076 0.492 0.180
#> SRR1539228 3 0.0146 0.8933 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539229 5 0.6724 -0.1363 0.252 0.000 0.000 0.076 0.488 0.184
#> SRR1539232 3 0.0291 0.8931 0.000 0.000 0.992 0.004 0.004 0.000
#> SRR1539230 4 0.4107 0.8938 0.028 0.280 0.000 0.688 0.000 0.004
#> SRR1539231 4 0.4107 0.8938 0.028 0.280 0.000 0.688 0.000 0.004
#> SRR1539234 2 0.1088 0.9288 0.024 0.960 0.000 0.000 0.000 0.016
#> SRR1539233 5 0.6724 -0.1363 0.252 0.000 0.000 0.076 0.488 0.184
#> SRR1539235 5 0.6074 -0.0250 0.052 0.000 0.000 0.156 0.580 0.212
#> SRR1539236 6 0.7694 0.6594 0.208 0.000 0.000 0.248 0.248 0.296
#> SRR1539237 2 0.2724 0.8741 0.052 0.864 0.000 0.000 0.000 0.084
#> SRR1539238 5 0.1377 0.5334 0.004 0.000 0.004 0.024 0.952 0.016
#> SRR1539239 1 0.4624 0.6457 0.724 0.000 0.000 0.064 0.180 0.032
#> SRR1539242 1 0.4624 0.6457 0.724 0.000 0.000 0.064 0.180 0.032
#> SRR1539240 2 0.1549 0.9162 0.020 0.936 0.000 0.000 0.000 0.044
#> SRR1539241 5 0.1377 0.5334 0.004 0.000 0.004 0.024 0.952 0.016
#> SRR1539243 2 0.1616 0.9157 0.020 0.932 0.000 0.000 0.000 0.048
#> SRR1539244 5 0.4982 0.2226 0.048 0.000 0.004 0.076 0.716 0.156
#> SRR1539245 6 0.7460 0.6387 0.280 0.000 0.000 0.124 0.292 0.304
#> SRR1539246 2 0.0806 0.9306 0.020 0.972 0.000 0.000 0.000 0.008
#> SRR1539247 5 0.0291 0.5475 0.000 0.000 0.004 0.004 0.992 0.000
#> SRR1539248 1 0.2883 0.7154 0.788 0.000 0.000 0.000 0.212 0.000
#> SRR1539249 2 0.1461 0.9253 0.044 0.940 0.000 0.000 0.000 0.016
#> SRR1539250 5 0.2001 0.5250 0.028 0.000 0.004 0.012 0.924 0.032
#> SRR1539251 5 0.2001 0.5250 0.028 0.000 0.004 0.012 0.924 0.032
#> SRR1539253 2 0.1461 0.9253 0.044 0.940 0.000 0.000 0.000 0.016
#> SRR1539252 5 0.6892 -0.3290 0.328 0.000 0.000 0.080 0.420 0.172
#> SRR1539255 1 0.7405 -0.7284 0.344 0.000 0.000 0.120 0.280 0.256
#> SRR1539254 5 0.0924 0.5363 0.008 0.000 0.004 0.008 0.972 0.008
#> SRR1539256 2 0.0909 0.9302 0.020 0.968 0.000 0.000 0.000 0.012
#> SRR1539257 5 0.0146 0.5475 0.000 0.000 0.004 0.000 0.996 0.000
#> SRR1539258 1 0.4214 0.6744 0.740 0.000 0.000 0.032 0.200 0.028
#> SRR1539259 2 0.1461 0.9253 0.044 0.940 0.000 0.000 0.000 0.016
#> SRR1539260 5 0.0291 0.5475 0.000 0.000 0.004 0.004 0.992 0.000
#> SRR1539262 2 0.1461 0.9253 0.044 0.940 0.000 0.000 0.000 0.016
#> SRR1539261 1 0.3374 0.7137 0.772 0.000 0.000 0.000 0.208 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["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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.973 0.989 0.4656 0.532 0.532
#> 3 3 1.000 0.989 0.991 0.4501 0.769 0.575
#> 4 4 0.766 0.784 0.799 0.0935 0.842 0.573
#> 5 5 0.773 0.820 0.858 0.0799 0.942 0.774
#> 6 6 0.915 0.889 0.921 0.0571 0.931 0.673
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
#> SRR1539207 1 0.000 0.994 1.000 0.000
#> SRR1539208 1 0.000 0.994 1.000 0.000
#> SRR1539211 1 0.714 0.748 0.804 0.196
#> SRR1539210 1 0.000 0.994 1.000 0.000
#> SRR1539209 2 0.000 0.979 0.000 1.000
#> SRR1539212 2 0.000 0.979 0.000 1.000
#> SRR1539214 1 0.000 0.994 1.000 0.000
#> SRR1539213 1 0.000 0.994 1.000 0.000
#> SRR1539215 2 0.000 0.979 0.000 1.000
#> SRR1539216 1 0.000 0.994 1.000 0.000
#> SRR1539217 1 0.000 0.994 1.000 0.000
#> SRR1539218 2 0.000 0.979 0.000 1.000
#> SRR1539220 1 0.000 0.994 1.000 0.000
#> SRR1539219 1 0.000 0.994 1.000 0.000
#> SRR1539221 2 0.000 0.979 0.000 1.000
#> SRR1539223 1 0.000 0.994 1.000 0.000
#> SRR1539224 2 0.000 0.979 0.000 1.000
#> SRR1539222 1 0.000 0.994 1.000 0.000
#> SRR1539225 1 0.000 0.994 1.000 0.000
#> SRR1539227 2 0.000 0.979 0.000 1.000
#> SRR1539226 1 0.000 0.994 1.000 0.000
#> SRR1539228 1 0.000 0.994 1.000 0.000
#> SRR1539229 1 0.000 0.994 1.000 0.000
#> SRR1539232 1 0.000 0.994 1.000 0.000
#> SRR1539230 2 0.000 0.979 0.000 1.000
#> SRR1539231 2 0.000 0.979 0.000 1.000
#> SRR1539234 2 0.000 0.979 0.000 1.000
#> SRR1539233 1 0.000 0.994 1.000 0.000
#> SRR1539235 1 0.000 0.994 1.000 0.000
#> SRR1539236 1 0.000 0.994 1.000 0.000
#> SRR1539237 2 0.000 0.979 0.000 1.000
#> SRR1539238 1 0.000 0.994 1.000 0.000
#> SRR1539239 1 0.000 0.994 1.000 0.000
#> SRR1539242 1 0.000 0.994 1.000 0.000
#> SRR1539240 2 0.000 0.979 0.000 1.000
#> SRR1539241 1 0.000 0.994 1.000 0.000
#> SRR1539243 2 0.000 0.979 0.000 1.000
#> SRR1539244 1 0.000 0.994 1.000 0.000
#> SRR1539245 1 0.000 0.994 1.000 0.000
#> SRR1539246 2 0.000 0.979 0.000 1.000
#> SRR1539247 1 0.000 0.994 1.000 0.000
#> SRR1539248 1 0.000 0.994 1.000 0.000
#> SRR1539249 2 0.000 0.979 0.000 1.000
#> SRR1539250 1 0.000 0.994 1.000 0.000
#> SRR1539251 1 0.000 0.994 1.000 0.000
#> SRR1539253 2 0.000 0.979 0.000 1.000
#> SRR1539252 1 0.000 0.994 1.000 0.000
#> SRR1539255 1 0.000 0.994 1.000 0.000
#> SRR1539254 1 0.000 0.994 1.000 0.000
#> SRR1539256 2 0.000 0.979 0.000 1.000
#> SRR1539257 1 0.000 0.994 1.000 0.000
#> SRR1539258 1 0.000 0.994 1.000 0.000
#> SRR1539259 2 0.000 0.979 0.000 1.000
#> SRR1539260 1 0.000 0.994 1.000 0.000
#> SRR1539262 2 0.000 0.979 0.000 1.000
#> SRR1539261 2 0.966 0.344 0.392 0.608
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.993 0.000 0 1.000
#> SRR1539208 1 0.0000 0.979 1.000 0 0.000
#> SRR1539211 1 0.0000 0.979 1.000 0 0.000
#> SRR1539210 3 0.0000 0.993 0.000 0 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000
#> SRR1539214 1 0.2261 0.948 0.932 0 0.068
#> SRR1539213 3 0.0000 0.993 0.000 0 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000
#> SRR1539216 3 0.0000 0.993 0.000 0 1.000
#> SRR1539217 1 0.0000 0.979 1.000 0 0.000
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000
#> SRR1539220 3 0.2261 0.931 0.068 0 0.932
#> SRR1539219 3 0.0000 0.993 0.000 0 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000
#> SRR1539223 1 0.1753 0.954 0.952 0 0.048
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000
#> SRR1539222 3 0.0000 0.993 0.000 0 1.000
#> SRR1539225 3 0.0000 0.993 0.000 0 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000
#> SRR1539226 1 0.1289 0.978 0.968 0 0.032
#> SRR1539228 3 0.0000 0.993 0.000 0 1.000
#> SRR1539229 1 0.1289 0.978 0.968 0 0.032
#> SRR1539232 3 0.0000 0.993 0.000 0 1.000
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000
#> SRR1539233 1 0.1289 0.978 0.968 0 0.032
#> SRR1539235 3 0.0424 0.992 0.008 0 0.992
#> SRR1539236 1 0.1289 0.978 0.968 0 0.032
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000
#> SRR1539238 3 0.0424 0.992 0.008 0 0.992
#> SRR1539239 1 0.0000 0.979 1.000 0 0.000
#> SRR1539242 1 0.0000 0.979 1.000 0 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000
#> SRR1539241 3 0.0424 0.992 0.008 0 0.992
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000
#> SRR1539244 3 0.0424 0.992 0.008 0 0.992
#> SRR1539245 1 0.1289 0.978 0.968 0 0.032
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000
#> SRR1539247 3 0.0424 0.992 0.008 0 0.992
#> SRR1539248 1 0.0000 0.979 1.000 0 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000
#> SRR1539250 3 0.0237 0.993 0.004 0 0.996
#> SRR1539251 3 0.0237 0.993 0.004 0 0.996
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000
#> SRR1539252 1 0.1289 0.978 0.968 0 0.032
#> SRR1539255 1 0.1289 0.978 0.968 0 0.032
#> SRR1539254 3 0.0424 0.992 0.008 0 0.992
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000
#> SRR1539257 3 0.0424 0.992 0.008 0 0.992
#> SRR1539258 1 0.0000 0.979 1.000 0 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000
#> SRR1539260 3 0.0424 0.992 0.008 0 0.992
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000
#> SRR1539261 1 0.0000 0.979 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539208 4 0.1118 0.946 0.036 0.000 0.000 0.964
#> SRR1539211 4 0.0921 0.953 0.028 0.000 0.000 0.972
#> SRR1539210 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539209 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539212 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539214 1 0.5698 0.512 0.608 0.000 0.036 0.356
#> SRR1539213 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539215 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539217 4 0.0921 0.953 0.028 0.000 0.000 0.972
#> SRR1539218 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539220 1 0.6701 0.586 0.564 0.000 0.328 0.108
#> SRR1539219 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539223 4 0.2578 0.871 0.036 0.000 0.052 0.912
#> SRR1539224 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539222 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539227 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539226 1 0.5080 0.483 0.576 0.000 0.004 0.420
#> SRR1539228 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539229 1 0.5080 0.483 0.576 0.000 0.004 0.420
#> SRR1539232 3 0.0000 0.974 0.000 0.000 1.000 0.000
#> SRR1539230 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539231 2 0.0000 0.842 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539233 1 0.5080 0.483 0.576 0.000 0.004 0.420
#> SRR1539235 1 0.4917 0.569 0.656 0.000 0.336 0.008
#> SRR1539236 1 0.5070 0.486 0.580 0.000 0.004 0.416
#> SRR1539237 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539238 1 0.5138 0.529 0.600 0.000 0.392 0.008
#> SRR1539239 4 0.0817 0.951 0.024 0.000 0.000 0.976
#> SRR1539242 4 0.0817 0.951 0.024 0.000 0.000 0.976
#> SRR1539240 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539241 1 0.5138 0.529 0.600 0.000 0.392 0.008
#> SRR1539243 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539244 1 0.4917 0.569 0.656 0.000 0.336 0.008
#> SRR1539245 1 0.5080 0.483 0.576 0.000 0.004 0.420
#> SRR1539246 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539247 1 0.5150 0.524 0.596 0.000 0.396 0.008
#> SRR1539248 4 0.0000 0.956 0.000 0.000 0.000 1.000
#> SRR1539249 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539250 3 0.2675 0.873 0.100 0.000 0.892 0.008
#> SRR1539251 3 0.2675 0.873 0.100 0.000 0.892 0.008
#> SRR1539253 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539252 1 0.5097 0.470 0.568 0.000 0.004 0.428
#> SRR1539255 1 0.5088 0.477 0.572 0.000 0.004 0.424
#> SRR1539254 1 0.5138 0.529 0.600 0.000 0.392 0.008
#> SRR1539256 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539257 1 0.5150 0.524 0.596 0.000 0.396 0.008
#> SRR1539258 4 0.0817 0.951 0.024 0.000 0.000 0.976
#> SRR1539259 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539260 1 0.5150 0.524 0.596 0.000 0.396 0.008
#> SRR1539262 2 0.4500 0.859 0.316 0.684 0.000 0.000
#> SRR1539261 4 0.0000 0.956 0.000 0.000 0.000 1.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539208 1 0.3160 0.797 0.808 0.000 0.000 0.004 0.188
#> SRR1539211 1 0.2930 0.817 0.832 0.000 0.000 0.004 0.164
#> SRR1539210 3 0.0162 0.899 0.004 0.000 0.996 0.000 0.000
#> SRR1539209 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539212 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539214 5 0.5373 0.625 0.128 0.000 0.008 0.176 0.688
#> SRR1539213 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539215 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539216 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 1 0.3053 0.814 0.828 0.000 0.000 0.008 0.164
#> SRR1539218 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539220 5 0.5783 0.652 0.076 0.000 0.088 0.136 0.700
#> SRR1539219 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539223 1 0.3864 0.779 0.784 0.000 0.020 0.008 0.188
#> SRR1539224 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539222 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539225 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539227 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539226 5 0.6034 0.593 0.256 0.000 0.000 0.172 0.572
#> SRR1539228 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539229 5 0.6034 0.593 0.256 0.000 0.000 0.172 0.572
#> SRR1539232 3 0.0000 0.903 0.000 0.000 1.000 0.000 0.000
#> SRR1539230 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539231 4 0.2891 1.000 0.000 0.176 0.000 0.824 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539233 5 0.6034 0.593 0.256 0.000 0.000 0.172 0.572
#> SRR1539235 5 0.0963 0.682 0.000 0.000 0.036 0.000 0.964
#> SRR1539236 5 0.6178 0.554 0.296 0.000 0.000 0.168 0.536
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539238 5 0.1908 0.678 0.000 0.000 0.092 0.000 0.908
#> SRR1539239 1 0.1915 0.838 0.928 0.000 0.000 0.040 0.032
#> SRR1539242 1 0.1915 0.838 0.928 0.000 0.000 0.040 0.032
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539241 5 0.1908 0.678 0.000 0.000 0.092 0.000 0.908
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539244 5 0.1357 0.685 0.000 0.000 0.048 0.004 0.948
#> SRR1539245 5 0.6221 0.556 0.300 0.000 0.000 0.172 0.528
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539247 5 0.2127 0.671 0.000 0.000 0.108 0.000 0.892
#> SRR1539248 1 0.0162 0.851 0.996 0.000 0.000 0.000 0.004
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539250 3 0.4557 0.378 0.004 0.000 0.552 0.004 0.440
#> SRR1539251 3 0.4557 0.378 0.004 0.000 0.552 0.004 0.440
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539252 5 0.6326 0.516 0.336 0.000 0.000 0.172 0.492
#> SRR1539255 5 0.6290 0.526 0.332 0.000 0.000 0.168 0.500
#> SRR1539254 5 0.1965 0.678 0.000 0.000 0.096 0.000 0.904
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539257 5 0.2074 0.674 0.000 0.000 0.104 0.000 0.896
#> SRR1539258 1 0.1725 0.832 0.936 0.000 0.000 0.044 0.020
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539260 5 0.2127 0.671 0.000 0.000 0.108 0.000 0.892
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539261 1 0.0000 0.852 1.000 0.000 0.000 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539208 1 0.3459 0.718 0.832 0.000 0.004 0.024 0.036 0.104
#> SRR1539211 1 0.3159 0.721 0.844 0.000 0.004 0.024 0.016 0.112
#> SRR1539210 3 0.0146 0.991 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539209 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539212 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539214 6 0.2039 0.799 0.016 0.000 0.000 0.004 0.072 0.908
#> SRR1539213 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539215 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539216 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539217 1 0.4882 0.619 0.684 0.000 0.004 0.028 0.052 0.232
#> SRR1539218 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539220 6 0.4540 0.562 0.016 0.000 0.040 0.004 0.244 0.696
#> SRR1539219 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539221 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539223 1 0.5090 0.616 0.680 0.000 0.012 0.028 0.056 0.224
#> SRR1539224 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539222 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539225 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539227 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539226 6 0.1411 0.818 0.004 0.000 0.000 0.000 0.060 0.936
#> SRR1539228 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539229 6 0.1349 0.819 0.004 0.000 0.000 0.000 0.056 0.940
#> SRR1539232 3 0.0146 0.999 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539230 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539231 4 0.1204 1.000 0.000 0.056 0.000 0.944 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539233 6 0.1285 0.820 0.004 0.000 0.000 0.000 0.052 0.944
#> SRR1539235 5 0.1555 0.916 0.004 0.000 0.000 0.004 0.932 0.060
#> SRR1539236 6 0.4128 0.700 0.164 0.000 0.000 0.028 0.044 0.764
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.0865 0.933 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR1539239 1 0.3688 0.589 0.724 0.000 0.000 0.020 0.000 0.256
#> SRR1539242 1 0.3688 0.589 0.724 0.000 0.000 0.020 0.000 0.256
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.0865 0.933 0.000 0.000 0.000 0.000 0.964 0.036
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.1152 0.924 0.000 0.000 0.000 0.004 0.952 0.044
#> SRR1539245 6 0.2844 0.784 0.112 0.000 0.000 0.012 0.020 0.856
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.0777 0.933 0.000 0.000 0.004 0.000 0.972 0.024
#> SRR1539248 1 0.0790 0.732 0.968 0.000 0.000 0.000 0.000 0.032
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 5 0.3379 0.826 0.020 0.000 0.132 0.004 0.824 0.020
#> SRR1539251 5 0.3379 0.826 0.020 0.000 0.132 0.004 0.824 0.020
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 6 0.2742 0.786 0.128 0.000 0.000 0.008 0.012 0.852
#> SRR1539255 6 0.3757 0.717 0.180 0.000 0.000 0.024 0.020 0.776
#> SRR1539254 5 0.0777 0.933 0.000 0.000 0.004 0.000 0.972 0.024
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.0935 0.930 0.000 0.000 0.004 0.000 0.964 0.032
#> SRR1539258 1 0.3695 0.574 0.712 0.000 0.000 0.016 0.000 0.272
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.0777 0.933 0.000 0.000 0.004 0.000 0.972 0.024
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 1 0.0713 0.732 0.972 0.000 0.000 0.000 0.000 0.028
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.4570 0.544 0.544
#> 3 3 0.778 0.969 0.936 0.3118 0.836 0.699
#> 4 4 1.000 1.000 1.000 0.1323 0.942 0.846
#> 5 5 0.933 0.918 0.965 0.1815 0.858 0.572
#> 6 6 0.866 0.830 0.885 0.0468 0.939 0.705
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 4
There is also optional best \(k\) = 2 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539208 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539211 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539210 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539209 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539212 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539214 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539213 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539215 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539216 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539217 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539218 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539220 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539219 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539221 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539223 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539224 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539222 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539225 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539227 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539226 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539228 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539229 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539232 3 0.455 1.000 0.2 0.0 0.8
#> SRR1539230 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539231 2 0.455 0.904 0.0 0.8 0.2
#> SRR1539234 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539233 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539235 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539236 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539237 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539238 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539239 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539242 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539240 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539241 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539243 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539244 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539245 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539246 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539247 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539248 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539249 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539250 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539251 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539253 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539252 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539255 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539254 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539256 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539257 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539258 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539259 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539260 1 0.000 1.000 1.0 0.0 0.0
#> SRR1539262 2 0.000 0.914 0.0 1.0 0.0
#> SRR1539261 1 0.000 1.000 1.0 0.0 0.0
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0 1 0 0 1 0
#> SRR1539208 1 0 1 1 0 0 0
#> SRR1539211 1 0 1 1 0 0 0
#> SRR1539210 3 0 1 0 0 1 0
#> SRR1539209 4 0 1 0 0 0 1
#> SRR1539212 4 0 1 0 0 0 1
#> SRR1539214 1 0 1 1 0 0 0
#> SRR1539213 3 0 1 0 0 1 0
#> SRR1539215 4 0 1 0 0 0 1
#> SRR1539216 3 0 1 0 0 1 0
#> SRR1539217 1 0 1 1 0 0 0
#> SRR1539218 4 0 1 0 0 0 1
#> SRR1539220 1 0 1 1 0 0 0
#> SRR1539219 3 0 1 0 0 1 0
#> SRR1539221 4 0 1 0 0 0 1
#> SRR1539223 1 0 1 1 0 0 0
#> SRR1539224 4 0 1 0 0 0 1
#> SRR1539222 3 0 1 0 0 1 0
#> SRR1539225 3 0 1 0 0 1 0
#> SRR1539227 4 0 1 0 0 0 1
#> SRR1539226 1 0 1 1 0 0 0
#> SRR1539228 3 0 1 0 0 1 0
#> SRR1539229 1 0 1 1 0 0 0
#> SRR1539232 3 0 1 0 0 1 0
#> SRR1539230 4 0 1 0 0 0 1
#> SRR1539231 4 0 1 0 0 0 1
#> SRR1539234 2 0 1 0 1 0 0
#> SRR1539233 1 0 1 1 0 0 0
#> SRR1539235 1 0 1 1 0 0 0
#> SRR1539236 1 0 1 1 0 0 0
#> SRR1539237 2 0 1 0 1 0 0
#> SRR1539238 1 0 1 1 0 0 0
#> SRR1539239 1 0 1 1 0 0 0
#> SRR1539242 1 0 1 1 0 0 0
#> SRR1539240 2 0 1 0 1 0 0
#> SRR1539241 1 0 1 1 0 0 0
#> SRR1539243 2 0 1 0 1 0 0
#> SRR1539244 1 0 1 1 0 0 0
#> SRR1539245 1 0 1 1 0 0 0
#> SRR1539246 2 0 1 0 1 0 0
#> SRR1539247 1 0 1 1 0 0 0
#> SRR1539248 1 0 1 1 0 0 0
#> SRR1539249 2 0 1 0 1 0 0
#> SRR1539250 1 0 1 1 0 0 0
#> SRR1539251 1 0 1 1 0 0 0
#> SRR1539253 2 0 1 0 1 0 0
#> SRR1539252 1 0 1 1 0 0 0
#> SRR1539255 1 0 1 1 0 0 0
#> SRR1539254 1 0 1 1 0 0 0
#> SRR1539256 2 0 1 0 1 0 0
#> SRR1539257 1 0 1 1 0 0 0
#> SRR1539258 1 0 1 1 0 0 0
#> SRR1539259 2 0 1 0 1 0 0
#> SRR1539260 1 0 1 1 0 0 0
#> SRR1539262 2 0 1 0 1 0 0
#> SRR1539261 1 0 1 1 0 0 0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539208 5 0.191 0.826 0.092 0 0.000 0 0.908
#> SRR1539211 5 0.377 0.602 0.296 0 0.000 0 0.704
#> SRR1539210 5 0.402 0.444 0.000 0 0.348 0 0.652
#> SRR1539209 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539212 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539214 1 0.242 0.832 0.868 0 0.000 0 0.132
#> SRR1539213 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539215 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539216 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539217 1 0.300 0.748 0.812 0 0.000 0 0.188
#> SRR1539218 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539220 5 0.366 0.595 0.276 0 0.000 0 0.724
#> SRR1539219 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539221 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539223 5 0.265 0.780 0.152 0 0.000 0 0.848
#> SRR1539224 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539222 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539225 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539227 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539226 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539228 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539229 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539232 3 0.000 1.000 0.000 0 1.000 0 0.000
#> SRR1539230 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539231 4 0.000 1.000 0.000 0 0.000 1 0.000
#> SRR1539234 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539233 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539235 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539236 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539237 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539238 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539239 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539242 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539240 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539241 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539243 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539244 5 0.429 0.115 0.464 0 0.000 0 0.536
#> SRR1539245 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539246 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539247 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539248 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539249 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539250 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539251 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539253 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539252 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539255 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539254 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539256 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539257 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539258 1 0.000 0.972 1.000 0 0.000 0 0.000
#> SRR1539259 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539260 5 0.000 0.868 0.000 0 0.000 0 1.000
#> SRR1539262 2 0.000 1.000 0.000 1 0.000 0 0.000
#> SRR1539261 1 0.000 0.972 1.000 0 0.000 0 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539208 6 0.1524 0.627 0.008 0 0.000 0.000 0.060 0.932
#> SRR1539211 6 0.3168 0.607 0.116 0 0.000 0.000 0.056 0.828
#> SRR1539210 6 0.4737 0.498 0.000 0 0.192 0.000 0.132 0.676
#> SRR1539209 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539212 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539214 1 0.4117 0.625 0.716 0 0.000 0.000 0.056 0.228
#> SRR1539213 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539215 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539216 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539217 6 0.1957 0.625 0.112 0 0.000 0.000 0.000 0.888
#> SRR1539218 4 0.0000 0.997 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539220 6 0.2812 0.595 0.048 0 0.000 0.000 0.096 0.856
#> SRR1539219 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539221 4 0.0000 0.997 0.000 0 0.000 1.000 0.000 0.000
#> SRR1539223 6 0.1219 0.631 0.004 0 0.000 0.000 0.048 0.948
#> SRR1539224 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539222 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539227 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539226 1 0.1204 0.863 0.944 0 0.000 0.000 0.000 0.056
#> SRR1539228 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.1204 0.863 0.944 0 0.000 0.000 0.000 0.056
#> SRR1539232 3 0.0000 1.000 0.000 0 1.000 0.000 0.000 0.000
#> SRR1539230 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539231 4 0.0146 0.997 0.000 0 0.000 0.996 0.004 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539233 1 0.1204 0.863 0.944 0 0.000 0.000 0.000 0.056
#> SRR1539235 5 0.0547 0.572 0.000 0 0.000 0.000 0.980 0.020
#> SRR1539236 1 0.4118 0.618 0.660 0 0.000 0.000 0.312 0.028
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.3756 0.656 0.000 0 0.000 0.000 0.600 0.400
#> SRR1539239 1 0.3416 0.773 0.804 0 0.000 0.000 0.056 0.140
#> SRR1539242 1 0.1957 0.816 0.888 0 0.000 0.000 0.000 0.112
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.3789 0.674 0.000 0 0.000 0.000 0.584 0.416
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.4281 0.562 0.136 0 0.000 0.000 0.732 0.132
#> SRR1539245 1 0.0146 0.868 0.996 0 0.000 0.000 0.000 0.004
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.3515 0.772 0.000 0 0.000 0.000 0.676 0.324
#> SRR1539248 1 0.2996 0.697 0.772 0 0.000 0.000 0.000 0.228
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539250 6 0.3309 0.364 0.000 0 0.000 0.000 0.280 0.720
#> SRR1539251 6 0.3515 0.240 0.000 0 0.000 0.000 0.324 0.676
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.0146 0.868 0.996 0 0.000 0.000 0.000 0.004
#> SRR1539255 1 0.0260 0.868 0.992 0 0.000 0.000 0.000 0.008
#> SRR1539254 5 0.3515 0.772 0.000 0 0.000 0.000 0.676 0.324
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.3515 0.772 0.000 0 0.000 0.000 0.676 0.324
#> SRR1539258 1 0.0260 0.868 0.992 0 0.000 0.000 0.000 0.008
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.3515 0.772 0.000 0 0.000 0.000 0.676 0.324
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0.000 0.000 0.000
#> SRR1539261 6 0.3765 0.210 0.404 0 0.000 0.000 0.000 0.596
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.4570 0.544 0.544
#> 3 3 0.772 0.933 0.874 0.2815 0.836 0.699
#> 4 4 1.000 0.974 0.990 0.1550 0.942 0.846
#> 5 5 0.779 0.686 0.855 0.1409 0.905 0.703
#> 6 6 0.827 0.752 0.852 0.0586 0.866 0.506
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539208 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539211 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539210 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539209 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539212 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539214 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539213 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539215 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539216 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539217 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539218 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539220 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539219 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539221 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539223 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539224 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539222 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539225 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539227 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539226 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539228 3 0.7401 0.990 0.340 0.048 0.612
#> SRR1539229 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539232 3 0.6079 0.912 0.388 0.000 0.612
#> SRR1539230 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539231 2 0.0000 0.818 0.000 1.000 0.000
#> SRR1539234 2 0.4974 0.827 0.000 0.764 0.236
#> SRR1539233 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539235 1 0.0424 0.988 0.992 0.000 0.008
#> SRR1539236 1 0.0592 0.983 0.988 0.000 0.012
#> SRR1539237 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539238 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539239 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539242 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539240 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539241 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539243 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539244 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539245 1 0.0424 0.988 0.992 0.000 0.008
#> SRR1539246 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539247 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539248 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539249 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539250 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539251 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539253 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539252 1 0.0237 0.992 0.996 0.000 0.004
#> SRR1539255 1 0.0592 0.983 0.988 0.000 0.012
#> SRR1539254 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539256 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539257 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539258 1 0.0424 0.988 0.992 0.000 0.008
#> SRR1539259 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539260 1 0.0000 0.996 1.000 0.000 0.000
#> SRR1539262 2 0.6079 0.826 0.000 0.612 0.388
#> SRR1539261 1 0.0747 0.977 0.984 0.000 0.016
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539208 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539211 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539210 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539209 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539212 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539214 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539213 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539215 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539216 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539217 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539218 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539220 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539219 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539221 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539223 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539224 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539222 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539225 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539227 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539226 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539228 3 0.000 0.966 0.000 0.00 1.000 0.000
#> SRR1539229 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539232 3 0.349 0.716 0.188 0.00 0.812 0.000
#> SRR1539230 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539231 4 0.000 1.000 0.000 0.00 0.000 1.000
#> SRR1539234 2 0.519 0.456 0.000 0.64 0.016 0.344
#> SRR1539233 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539235 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539236 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539237 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539238 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539239 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539242 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539240 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539241 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539243 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539244 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539245 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539246 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539247 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539248 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539249 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539250 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539251 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539253 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539252 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539255 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539254 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539256 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539257 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539258 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539259 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539260 1 0.000 1.000 1.000 0.00 0.000 0.000
#> SRR1539262 2 0.000 0.960 0.000 1.00 0.000 0.000
#> SRR1539261 1 0.000 1.000 1.000 0.00 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539208 5 0.1965 0.63995 0.096 0.000 0.000 0.000 0.904
#> SRR1539211 5 0.3039 0.50301 0.192 0.000 0.000 0.000 0.808
#> SRR1539210 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539209 4 0.3074 0.84048 0.000 0.196 0.000 0.804 0.000
#> SRR1539212 4 0.3074 0.84048 0.000 0.196 0.000 0.804 0.000
#> SRR1539214 5 0.0963 0.65969 0.036 0.000 0.000 0.000 0.964
#> SRR1539213 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539215 4 0.0000 0.89029 0.000 0.000 0.000 1.000 0.000
#> SRR1539216 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 5 0.0510 0.67300 0.016 0.000 0.000 0.000 0.984
#> SRR1539218 4 0.3074 0.84048 0.000 0.196 0.000 0.804 0.000
#> SRR1539220 5 0.1270 0.66105 0.052 0.000 0.000 0.000 0.948
#> SRR1539219 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 4 0.0000 0.89029 0.000 0.000 0.000 1.000 0.000
#> SRR1539223 5 0.1851 0.64347 0.088 0.000 0.000 0.000 0.912
#> SRR1539224 4 0.3074 0.84048 0.000 0.196 0.000 0.804 0.000
#> SRR1539222 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539225 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539227 4 0.0000 0.89029 0.000 0.000 0.000 1.000 0.000
#> SRR1539226 5 0.2471 0.55526 0.136 0.000 0.000 0.000 0.864
#> SRR1539228 3 0.0000 0.98939 0.000 0.000 1.000 0.000 0.000
#> SRR1539229 5 0.3966 0.21060 0.336 0.000 0.000 0.000 0.664
#> SRR1539232 3 0.1544 0.91288 0.000 0.000 0.932 0.000 0.068
#> SRR1539230 4 0.0000 0.89029 0.000 0.000 0.000 1.000 0.000
#> SRR1539231 4 0.0000 0.89029 0.000 0.000 0.000 1.000 0.000
#> SRR1539234 2 0.3874 0.67938 0.008 0.776 0.016 0.200 0.000
#> SRR1539233 5 0.4161 0.00966 0.392 0.000 0.000 0.000 0.608
#> SRR1539235 5 0.4307 -0.39220 0.496 0.000 0.000 0.000 0.504
#> SRR1539236 1 0.3730 0.68935 0.712 0.000 0.000 0.000 0.288
#> SRR1539237 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539238 5 0.0162 0.67435 0.004 0.000 0.000 0.000 0.996
#> SRR1539239 1 0.4305 0.51018 0.512 0.000 0.000 0.000 0.488
#> SRR1539242 5 0.4306 -0.58903 0.492 0.000 0.000 0.000 0.508
#> SRR1539240 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539241 5 0.0609 0.67330 0.020 0.000 0.000 0.000 0.980
#> SRR1539243 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539244 5 0.3913 0.23479 0.324 0.000 0.000 0.000 0.676
#> SRR1539245 1 0.3774 0.68737 0.704 0.000 0.000 0.000 0.296
#> SRR1539246 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539247 5 0.0290 0.67301 0.008 0.000 0.000 0.000 0.992
#> SRR1539248 1 0.4304 0.49647 0.516 0.000 0.000 0.000 0.484
#> SRR1539249 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539250 5 0.3707 0.45478 0.284 0.000 0.000 0.000 0.716
#> SRR1539251 5 0.3707 0.45478 0.284 0.000 0.000 0.000 0.716
#> SRR1539253 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539252 1 0.4126 0.62087 0.620 0.000 0.000 0.000 0.380
#> SRR1539255 1 0.3752 0.69184 0.708 0.000 0.000 0.000 0.292
#> SRR1539254 5 0.1270 0.66250 0.052 0.000 0.000 0.000 0.948
#> SRR1539256 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539257 5 0.0162 0.67435 0.004 0.000 0.000 0.000 0.996
#> SRR1539258 5 0.4307 -0.58541 0.496 0.000 0.000 0.000 0.504
#> SRR1539259 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539260 5 0.0162 0.67435 0.004 0.000 0.000 0.000 0.996
#> SRR1539262 2 0.0000 0.97235 0.000 1.000 0.000 0.000 0.000
#> SRR1539261 1 0.4302 0.49080 0.520 0.000 0.000 0.000 0.480
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 1 0.2260 0.709 0.860 0.000 0.000 0.000 0.140 0.000
#> SRR1539211 1 0.3558 0.589 0.760 0.000 0.000 0.000 0.212 0.028
#> SRR1539210 3 0.0000 0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539209 4 0.0725 0.986 0.000 0.012 0.000 0.976 0.000 0.012
#> SRR1539212 4 0.0725 0.986 0.000 0.012 0.000 0.976 0.000 0.012
#> SRR1539214 5 0.3747 0.607 0.396 0.000 0.000 0.000 0.604 0.000
#> SRR1539213 3 0.0363 0.973 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR1539215 4 0.0000 0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.0000 0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 1 0.1327 0.690 0.936 0.000 0.000 0.000 0.064 0.000
#> SRR1539218 4 0.0725 0.986 0.000 0.012 0.000 0.976 0.000 0.012
#> SRR1539220 5 0.3774 0.602 0.408 0.000 0.000 0.000 0.592 0.000
#> SRR1539219 3 0.0000 0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 4 0.0000 0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539223 1 0.1075 0.723 0.952 0.000 0.000 0.000 0.048 0.000
#> SRR1539224 4 0.0725 0.986 0.000 0.012 0.000 0.976 0.000 0.012
#> SRR1539222 3 0.0000 0.976 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0363 0.973 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR1539227 4 0.0000 0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539226 5 0.5723 0.350 0.408 0.000 0.000 0.000 0.428 0.164
#> SRR1539228 3 0.0363 0.973 0.000 0.000 0.988 0.000 0.000 0.012
#> SRR1539229 6 0.4764 0.673 0.384 0.000 0.000 0.000 0.056 0.560
#> SRR1539232 3 0.2844 0.813 0.104 0.000 0.860 0.000 0.016 0.020
#> SRR1539230 4 0.0000 0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539231 4 0.0000 0.989 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.3912 0.652 0.000 0.648 0.000 0.012 0.000 0.340
#> SRR1539233 6 0.4766 0.675 0.316 0.000 0.000 0.000 0.072 0.612
#> SRR1539235 5 0.3655 0.514 0.112 0.000 0.000 0.000 0.792 0.096
#> SRR1539236 5 0.3998 -0.368 0.004 0.000 0.000 0.000 0.504 0.492
#> SRR1539237 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.3881 0.603 0.396 0.000 0.000 0.000 0.600 0.004
#> SRR1539239 5 0.1176 0.519 0.020 0.000 0.000 0.000 0.956 0.024
#> SRR1539242 5 0.1320 0.519 0.016 0.000 0.000 0.000 0.948 0.036
#> SRR1539240 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.3747 0.607 0.396 0.000 0.000 0.000 0.604 0.000
#> SRR1539243 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 6 0.4720 0.668 0.388 0.000 0.000 0.000 0.052 0.560
#> SRR1539245 6 0.4064 0.365 0.016 0.000 0.000 0.000 0.360 0.624
#> SRR1539246 2 0.0363 0.960 0.000 0.988 0.000 0.000 0.000 0.012
#> SRR1539247 5 0.3923 0.596 0.416 0.000 0.000 0.000 0.580 0.004
#> SRR1539248 5 0.1700 0.518 0.048 0.000 0.000 0.000 0.928 0.024
#> SRR1539249 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 1 0.0993 0.730 0.964 0.000 0.000 0.000 0.024 0.012
#> SRR1539251 1 0.0993 0.730 0.964 0.000 0.000 0.000 0.024 0.012
#> SRR1539253 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 5 0.2448 0.543 0.064 0.000 0.000 0.000 0.884 0.052
#> SRR1539255 5 0.2362 0.440 0.004 0.000 0.000 0.000 0.860 0.136
#> SRR1539254 5 0.3789 0.598 0.416 0.000 0.000 0.000 0.584 0.000
#> SRR1539256 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.3747 0.607 0.396 0.000 0.000 0.000 0.604 0.000
#> SRR1539258 5 0.0790 0.533 0.032 0.000 0.000 0.000 0.968 0.000
#> SRR1539259 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.3782 0.598 0.412 0.000 0.000 0.000 0.588 0.000
#> SRR1539262 2 0.0000 0.967 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 1 0.4066 0.322 0.596 0.000 0.000 0.000 0.392 0.012
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'CV' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.995 0.998 0.4583 0.544 0.544
#> 3 3 0.664 0.844 0.817 0.3811 0.791 0.615
#> 4 4 0.791 0.771 0.827 0.1442 0.864 0.637
#> 5 5 0.778 0.691 0.854 0.0922 0.920 0.721
#> 6 6 0.888 0.777 0.916 0.0430 0.897 0.592
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
#> SRR1539207 1 0.0000 0.997 1.000 0.000
#> SRR1539208 1 0.0000 0.997 1.000 0.000
#> SRR1539211 1 0.0000 0.997 1.000 0.000
#> SRR1539210 1 0.0000 0.997 1.000 0.000
#> SRR1539209 2 0.0000 1.000 0.000 1.000
#> SRR1539212 2 0.0000 1.000 0.000 1.000
#> SRR1539214 1 0.0000 0.997 1.000 0.000
#> SRR1539213 1 0.0000 0.997 1.000 0.000
#> SRR1539215 2 0.0000 1.000 0.000 1.000
#> SRR1539216 1 0.0000 0.997 1.000 0.000
#> SRR1539217 1 0.0000 0.997 1.000 0.000
#> SRR1539218 2 0.0000 1.000 0.000 1.000
#> SRR1539220 1 0.0000 0.997 1.000 0.000
#> SRR1539219 1 0.0000 0.997 1.000 0.000
#> SRR1539221 2 0.0000 1.000 0.000 1.000
#> SRR1539223 1 0.0000 0.997 1.000 0.000
#> SRR1539224 2 0.0000 1.000 0.000 1.000
#> SRR1539222 1 0.0000 0.997 1.000 0.000
#> SRR1539225 1 0.0000 0.997 1.000 0.000
#> SRR1539227 2 0.0000 1.000 0.000 1.000
#> SRR1539226 1 0.0000 0.997 1.000 0.000
#> SRR1539228 1 0.0000 0.997 1.000 0.000
#> SRR1539229 1 0.0000 0.997 1.000 0.000
#> SRR1539232 1 0.0000 0.997 1.000 0.000
#> SRR1539230 2 0.0000 1.000 0.000 1.000
#> SRR1539231 2 0.0000 1.000 0.000 1.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000
#> SRR1539233 1 0.0000 0.997 1.000 0.000
#> SRR1539235 1 0.0000 0.997 1.000 0.000
#> SRR1539236 1 0.0000 0.997 1.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1.000
#> SRR1539238 1 0.0000 0.997 1.000 0.000
#> SRR1539239 1 0.0376 0.993 0.996 0.004
#> SRR1539242 1 0.0000 0.997 1.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1.000
#> SRR1539241 1 0.0000 0.997 1.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1.000
#> SRR1539244 1 0.0000 0.997 1.000 0.000
#> SRR1539245 1 0.0000 0.997 1.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1.000
#> SRR1539247 1 0.0000 0.997 1.000 0.000
#> SRR1539248 1 0.0000 0.997 1.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1.000
#> SRR1539250 1 0.0000 0.997 1.000 0.000
#> SRR1539251 1 0.0000 0.997 1.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1.000
#> SRR1539252 1 0.0000 0.997 1.000 0.000
#> SRR1539255 1 0.0000 0.997 1.000 0.000
#> SRR1539254 1 0.0000 0.997 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1.000
#> SRR1539257 1 0.0000 0.997 1.000 0.000
#> SRR1539258 1 0.0000 0.997 1.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1.000
#> SRR1539260 1 0.0000 0.997 1.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1.000
#> SRR1539261 1 0.5178 0.869 0.884 0.116
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539208 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539211 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539210 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539209 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539212 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539214 1 0.497 0.9311 0.764 0.000 0.236
#> SRR1539213 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539215 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539216 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539217 1 0.506 0.9242 0.756 0.000 0.244
#> SRR1539218 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539220 3 0.617 -0.0855 0.412 0.000 0.588
#> SRR1539219 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539221 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539223 3 0.484 0.5682 0.224 0.000 0.776
#> SRR1539224 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539222 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539225 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539227 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539226 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539228 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539229 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539232 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539230 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539231 2 0.000 0.8950 0.000 1.000 0.000
#> SRR1539234 2 0.440 0.9023 0.188 0.812 0.000
#> SRR1539233 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539235 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539236 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539237 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539238 1 0.497 0.9311 0.764 0.000 0.236
#> SRR1539239 1 0.312 0.8097 0.892 0.000 0.108
#> SRR1539242 1 0.319 0.8148 0.888 0.000 0.112
#> SRR1539240 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539241 1 0.506 0.9240 0.756 0.000 0.244
#> SRR1539243 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539244 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539245 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539246 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539247 3 0.630 -0.3713 0.484 0.000 0.516
#> SRR1539248 1 0.348 0.8337 0.872 0.000 0.128
#> SRR1539249 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539250 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539251 3 0.000 0.8818 0.000 0.000 1.000
#> SRR1539253 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539252 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539255 1 0.489 0.9312 0.772 0.000 0.228
#> SRR1539254 1 0.493 0.9336 0.768 0.000 0.232
#> SRR1539256 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539257 1 0.628 0.4919 0.540 0.000 0.460
#> SRR1539258 1 0.418 0.8804 0.828 0.000 0.172
#> SRR1539259 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539260 1 0.546 0.8694 0.712 0.000 0.288
#> SRR1539262 2 0.493 0.9020 0.232 0.768 0.000
#> SRR1539261 1 0.207 0.7413 0.940 0.000 0.060
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.0921 0.836 0.972 0.000 0.000 0.028
#> SRR1539211 1 0.0336 0.839 0.992 0.000 0.000 0.008
#> SRR1539210 3 0.0188 0.977 0.000 0.000 0.996 0.004
#> SRR1539209 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539212 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539214 1 0.4855 0.705 0.644 0.000 0.004 0.352
#> SRR1539213 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539215 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539216 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.0707 0.837 0.980 0.000 0.020 0.000
#> SRR1539218 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539220 1 0.7716 0.426 0.396 0.000 0.224 0.380
#> SRR1539219 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539221 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539223 1 0.4790 0.423 0.620 0.000 0.380 0.000
#> SRR1539224 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539222 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539227 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539226 1 0.4843 0.675 0.604 0.000 0.000 0.396
#> SRR1539228 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539229 1 0.4941 0.644 0.564 0.000 0.000 0.436
#> SRR1539232 3 0.3610 0.790 0.000 0.000 0.800 0.200
#> SRR1539230 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539231 4 0.4992 0.600 0.000 0.476 0.000 0.524
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539233 1 0.4134 0.763 0.740 0.000 0.000 0.260
#> SRR1539235 1 0.2530 0.833 0.888 0.000 0.000 0.112
#> SRR1539236 1 0.0817 0.837 0.976 0.000 0.000 0.024
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539238 1 0.2530 0.833 0.888 0.000 0.000 0.112
#> SRR1539239 1 0.0000 0.840 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.840 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539241 1 0.2469 0.833 0.892 0.000 0.000 0.108
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539244 1 0.4989 0.627 0.528 0.000 0.000 0.472
#> SRR1539245 1 0.4961 0.633 0.552 0.000 0.000 0.448
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539247 4 0.7400 -0.492 0.360 0.000 0.172 0.468
#> SRR1539248 1 0.0000 0.840 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539250 3 0.0000 0.980 0.000 0.000 1.000 0.000
#> SRR1539251 3 0.0188 0.977 0.000 0.000 0.996 0.004
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0000 0.840 1.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.840 1.000 0.000 0.000 0.000
#> SRR1539254 1 0.2408 0.834 0.896 0.000 0.000 0.104
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539257 4 0.6965 -0.566 0.428 0.000 0.112 0.460
#> SRR1539258 1 0.0000 0.840 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539260 1 0.3545 0.815 0.828 0.000 0.008 0.164
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.0000 0.840 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0162 0.9598 0.000 0.004 0.996 0.000 0.000
#> SRR1539208 1 0.4251 0.3709 0.672 0.012 0.000 0.000 0.316
#> SRR1539211 1 0.1478 0.6310 0.936 0.000 0.000 0.000 0.064
#> SRR1539210 3 0.0865 0.9496 0.000 0.004 0.972 0.000 0.024
#> SRR1539209 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539212 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539214 1 0.5180 0.2351 0.644 0.060 0.004 0.000 0.292
#> SRR1539213 3 0.0000 0.9608 0.000 0.000 1.000 0.000 0.000
#> SRR1539215 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539216 3 0.0000 0.9608 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 1 0.0162 0.6563 0.996 0.000 0.004 0.000 0.000
#> SRR1539218 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539220 1 0.7895 -0.1824 0.392 0.092 0.196 0.000 0.320
#> SRR1539219 3 0.0000 0.9608 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539223 1 0.3098 0.5378 0.836 0.000 0.148 0.000 0.016
#> SRR1539224 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539222 3 0.0162 0.9598 0.000 0.004 0.996 0.000 0.000
#> SRR1539225 3 0.0000 0.9608 0.000 0.000 1.000 0.000 0.000
#> SRR1539227 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539226 1 0.5357 -0.0985 0.520 0.044 0.004 0.000 0.432
#> SRR1539228 3 0.0000 0.9608 0.000 0.000 1.000 0.000 0.000
#> SRR1539229 5 0.5786 0.2463 0.380 0.096 0.000 0.000 0.524
#> SRR1539232 3 0.3865 0.7768 0.000 0.092 0.808 0.000 0.100
#> SRR1539230 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539231 4 0.0000 1.0000 0.000 0.000 0.000 1.000 0.000
#> SRR1539234 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539233 1 0.4854 0.2422 0.648 0.044 0.000 0.000 0.308
#> SRR1539235 5 0.4738 -0.1528 0.464 0.016 0.000 0.000 0.520
#> SRR1539236 1 0.4371 0.2963 0.644 0.012 0.000 0.000 0.344
#> SRR1539237 2 0.2471 0.9907 0.000 0.864 0.000 0.136 0.000
#> SRR1539238 1 0.4826 0.0874 0.508 0.020 0.000 0.000 0.472
#> SRR1539239 1 0.0000 0.6574 1.000 0.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.6574 1.000 0.000 0.000 0.000 0.000
#> SRR1539240 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539241 1 0.4658 0.0746 0.504 0.012 0.000 0.000 0.484
#> SRR1539243 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539244 5 0.1981 0.5500 0.048 0.028 0.000 0.000 0.924
#> SRR1539245 5 0.5534 0.3441 0.300 0.096 0.000 0.000 0.604
#> SRR1539246 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539247 5 0.1399 0.5442 0.020 0.000 0.028 0.000 0.952
#> SRR1539248 1 0.0000 0.6574 1.000 0.000 0.000 0.000 0.000
#> SRR1539249 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539250 3 0.1478 0.9236 0.000 0.000 0.936 0.000 0.064
#> SRR1539251 3 0.1965 0.8927 0.000 0.000 0.904 0.000 0.096
#> SRR1539253 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539252 1 0.0000 0.6574 1.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.6574 1.000 0.000 0.000 0.000 0.000
#> SRR1539254 1 0.4655 0.0629 0.512 0.012 0.000 0.000 0.476
#> SRR1539256 2 0.2516 0.9949 0.000 0.860 0.000 0.140 0.000
#> SRR1539257 5 0.3706 0.5370 0.020 0.076 0.064 0.000 0.840
#> SRR1539258 1 0.0000 0.6574 1.000 0.000 0.000 0.000 0.000
#> SRR1539259 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539260 5 0.4905 -0.1208 0.464 0.008 0.012 0.000 0.516
#> SRR1539262 2 0.2561 0.9983 0.000 0.856 0.000 0.144 0.000
#> SRR1539261 1 0.0510 0.6497 0.984 0.000 0.000 0.000 0.016
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0146 0.961 0.000 0 0.996 0 0.000 0.004
#> SRR1539208 5 0.4756 0.591 0.128 0 0.000 0 0.672 0.200
#> SRR1539211 1 0.3388 0.414 0.792 0 0.000 0 0.036 0.172
#> SRR1539210 3 0.0291 0.958 0.000 0 0.992 0 0.004 0.004
#> SRR1539209 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539212 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539214 1 0.2191 0.630 0.876 0 0.004 0 0.000 0.120
#> SRR1539213 3 0.0000 0.962 0.000 0 1.000 0 0.000 0.000
#> SRR1539215 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539216 3 0.0000 0.962 0.000 0 1.000 0 0.000 0.000
#> SRR1539217 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539218 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539220 1 0.5933 -0.379 0.460 0 0.288 0 0.000 0.252
#> SRR1539219 3 0.0000 0.962 0.000 0 1.000 0 0.000 0.000
#> SRR1539221 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539223 1 0.0865 0.742 0.964 0 0.036 0 0.000 0.000
#> SRR1539224 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539222 3 0.0146 0.961 0.000 0 0.996 0 0.000 0.004
#> SRR1539225 3 0.0000 0.962 0.000 0 1.000 0 0.000 0.000
#> SRR1539227 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539226 1 0.1814 0.667 0.900 0 0.000 0 0.000 0.100
#> SRR1539228 3 0.0000 0.962 0.000 0 1.000 0 0.000 0.000
#> SRR1539229 1 0.3727 -0.477 0.612 0 0.000 0 0.000 0.388
#> SRR1539232 3 0.3428 0.633 0.000 0 0.696 0 0.000 0.304
#> SRR1539230 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539231 4 0.0000 1.000 0.000 0 0.000 1 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539233 1 0.2320 0.602 0.864 0 0.000 0 0.004 0.132
#> SRR1539235 5 0.2092 0.753 0.000 0 0.000 0 0.876 0.124
#> SRR1539236 5 0.4614 0.615 0.108 0 0.000 0 0.684 0.208
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539238 5 0.2378 0.742 0.000 0 0.000 0 0.848 0.152
#> SRR1539239 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539242 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539241 5 0.0632 0.773 0.000 0 0.000 0 0.976 0.024
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539244 5 0.3499 0.602 0.000 0 0.000 0 0.680 0.320
#> SRR1539245 6 0.4080 0.000 0.456 0 0.000 0 0.008 0.536
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539247 5 0.0260 0.772 0.000 0 0.000 0 0.992 0.008
#> SRR1539248 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539250 5 0.3937 0.319 0.000 0 0.424 0 0.572 0.004
#> SRR1539251 5 0.3872 0.390 0.000 0 0.392 0 0.604 0.004
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539252 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539255 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539254 5 0.0000 0.773 0.000 0 0.000 0 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539257 5 0.3371 0.623 0.000 0 0.000 0 0.708 0.292
#> SRR1539258 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539260 5 0.0146 0.773 0.000 0 0.000 0 0.996 0.004
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0 0.000 0.000
#> SRR1539261 1 0.0000 0.783 1.000 0 0.000 0 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 5.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.825 0.934 0.964 0.1872 0.934 0.878
#> 4 4 1.000 0.992 0.996 0.2115 0.865 0.717
#> 5 5 0.931 0.912 0.946 0.0627 0.955 0.867
#> 6 6 0.955 0.866 0.951 0.0174 0.999 0.996
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 5
#> attr(,"optional")
#> [1] 2 4
There is also optional best \(k\) = 2 4 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 1 0.455 0.791 0.8 0 0.2
#> SRR1539208 1 0.000 0.942 1.0 0 0.0
#> SRR1539211 3 0.455 0.872 0.2 0 0.8
#> SRR1539210 3 0.000 0.738 0.0 0 1.0
#> SRR1539209 2 0.000 1.000 0.0 1 0.0
#> SRR1539212 2 0.000 1.000 0.0 1 0.0
#> SRR1539214 1 0.000 0.942 1.0 0 0.0
#> SRR1539213 1 0.455 0.791 0.8 0 0.2
#> SRR1539215 2 0.000 1.000 0.0 1 0.0
#> SRR1539216 1 0.455 0.791 0.8 0 0.2
#> SRR1539217 1 0.000 0.942 1.0 0 0.0
#> SRR1539218 2 0.000 1.000 0.0 1 0.0
#> SRR1539220 1 0.000 0.942 1.0 0 0.0
#> SRR1539219 1 0.455 0.791 0.8 0 0.2
#> SRR1539221 2 0.000 1.000 0.0 1 0.0
#> SRR1539223 1 0.000 0.942 1.0 0 0.0
#> SRR1539224 2 0.000 1.000 0.0 1 0.0
#> SRR1539222 1 0.455 0.791 0.8 0 0.2
#> SRR1539225 1 0.455 0.791 0.8 0 0.2
#> SRR1539227 2 0.000 1.000 0.0 1 0.0
#> SRR1539226 1 0.000 0.942 1.0 0 0.0
#> SRR1539228 1 0.455 0.791 0.8 0 0.2
#> SRR1539229 1 0.000 0.942 1.0 0 0.0
#> SRR1539232 1 0.455 0.791 0.8 0 0.2
#> SRR1539230 2 0.000 1.000 0.0 1 0.0
#> SRR1539231 2 0.000 1.000 0.0 1 0.0
#> SRR1539234 2 0.000 1.000 0.0 1 0.0
#> SRR1539233 1 0.000 0.942 1.0 0 0.0
#> SRR1539235 1 0.000 0.942 1.0 0 0.0
#> SRR1539236 1 0.000 0.942 1.0 0 0.0
#> SRR1539237 2 0.000 1.000 0.0 1 0.0
#> SRR1539238 1 0.000 0.942 1.0 0 0.0
#> SRR1539239 1 0.000 0.942 1.0 0 0.0
#> SRR1539242 1 0.000 0.942 1.0 0 0.0
#> SRR1539240 2 0.000 1.000 0.0 1 0.0
#> SRR1539241 1 0.000 0.942 1.0 0 0.0
#> SRR1539243 2 0.000 1.000 0.0 1 0.0
#> SRR1539244 1 0.000 0.942 1.0 0 0.0
#> SRR1539245 1 0.000 0.942 1.0 0 0.0
#> SRR1539246 2 0.000 1.000 0.0 1 0.0
#> SRR1539247 1 0.000 0.942 1.0 0 0.0
#> SRR1539248 1 0.000 0.942 1.0 0 0.0
#> SRR1539249 2 0.000 1.000 0.0 1 0.0
#> SRR1539250 1 0.000 0.942 1.0 0 0.0
#> SRR1539251 1 0.000 0.942 1.0 0 0.0
#> SRR1539253 2 0.000 1.000 0.0 1 0.0
#> SRR1539252 1 0.000 0.942 1.0 0 0.0
#> SRR1539255 1 0.000 0.942 1.0 0 0.0
#> SRR1539254 1 0.000 0.942 1.0 0 0.0
#> SRR1539256 2 0.000 1.000 0.0 1 0.0
#> SRR1539257 1 0.000 0.942 1.0 0 0.0
#> SRR1539258 1 0.000 0.942 1.0 0 0.0
#> SRR1539259 2 0.000 1.000 0.0 1 0.0
#> SRR1539260 1 0.000 0.942 1.0 0 0.0
#> SRR1539262 2 0.000 1.000 0.0 1 0.0
#> SRR1539261 3 0.455 0.872 0.2 0 0.8
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539208 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539211 4 0.000 0.897 0 0 0.0 1.0
#> SRR1539210 4 0.361 0.750 0 0 0.2 0.8
#> SRR1539209 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539212 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539214 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539213 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539215 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539216 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539217 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539218 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539220 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539219 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539221 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539223 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539224 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539222 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539225 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539227 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539226 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539228 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539229 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539232 3 0.000 1.000 0 0 1.0 0.0
#> SRR1539230 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539231 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539234 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539233 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539235 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539236 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539237 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539238 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539239 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539242 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539240 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539241 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539243 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539244 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539245 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539246 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539247 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539248 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539249 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539250 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539251 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539253 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539252 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539255 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539254 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539256 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539257 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539258 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539259 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539260 1 0.000 1.000 1 0 0.0 0.0
#> SRR1539262 2 0.000 1.000 0 1 0.0 0.0
#> SRR1539261 4 0.000 0.897 0 0 0.0 1.0
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0404 0.994 0 0.000 0.988 0.012 0.0
#> SRR1539208 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539211 5 0.0000 0.941 0 0.000 0.000 0.000 1.0
#> SRR1539210 5 0.3109 0.879 0 0.000 0.000 0.200 0.8
#> SRR1539209 4 0.3109 0.881 0 0.200 0.000 0.800 0.0
#> SRR1539212 4 0.3109 0.881 0 0.200 0.000 0.800 0.0
#> SRR1539214 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539213 3 0.0000 0.994 0 0.000 1.000 0.000 0.0
#> SRR1539215 2 0.3752 0.599 0 0.708 0.000 0.292 0.0
#> SRR1539216 3 0.0404 0.994 0 0.000 0.988 0.012 0.0
#> SRR1539217 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539218 4 0.3109 0.881 0 0.200 0.000 0.800 0.0
#> SRR1539220 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539219 3 0.0404 0.994 0 0.000 0.988 0.012 0.0
#> SRR1539221 2 0.3752 0.599 0 0.708 0.000 0.292 0.0
#> SRR1539223 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539224 4 0.3109 0.881 0 0.200 0.000 0.800 0.0
#> SRR1539222 3 0.0404 0.994 0 0.000 0.988 0.012 0.0
#> SRR1539225 3 0.0000 0.994 0 0.000 1.000 0.000 0.0
#> SRR1539227 2 0.3752 0.599 0 0.708 0.000 0.292 0.0
#> SRR1539226 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539228 3 0.0000 0.994 0 0.000 1.000 0.000 0.0
#> SRR1539229 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539232 3 0.0000 0.994 0 0.000 1.000 0.000 0.0
#> SRR1539230 2 0.3752 0.599 0 0.708 0.000 0.292 0.0
#> SRR1539231 2 0.3752 0.599 0 0.708 0.000 0.292 0.0
#> SRR1539234 2 0.0162 0.822 0 0.996 0.000 0.004 0.0
#> SRR1539233 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539235 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539236 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539237 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539238 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539239 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539242 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539240 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539241 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539243 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539244 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539245 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539246 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539247 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539248 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539249 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539250 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539251 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539253 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539252 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539255 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539254 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539256 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539257 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539258 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539259 2 0.0000 0.824 0 1.000 0.000 0.000 0.0
#> SRR1539260 1 0.0000 1.000 1 0.000 0.000 0.000 0.0
#> SRR1539262 4 0.4306 0.416 0 0.492 0.000 0.508 0.0
#> SRR1539261 5 0.0000 0.941 0 0.000 0.000 0.000 1.0
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0363 0.993 0 0.000 0.988 0.000 0 0.012
#> SRR1539208 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539211 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
#> SRR1539210 6 0.0000 0.000 0 0.000 0.000 0.000 0 1.000
#> SRR1539209 4 0.0000 0.806 0 0.000 0.000 1.000 0 0.000
#> SRR1539212 4 0.0000 0.806 0 0.000 0.000 1.000 0 0.000
#> SRR1539214 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539213 3 0.0000 0.993 0 0.000 1.000 0.000 0 0.000
#> SRR1539215 2 0.3838 0.446 0 0.552 0.000 0.448 0 0.000
#> SRR1539216 3 0.0363 0.993 0 0.000 0.988 0.000 0 0.012
#> SRR1539217 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539218 4 0.0000 0.806 0 0.000 0.000 1.000 0 0.000
#> SRR1539220 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539219 3 0.0363 0.993 0 0.000 0.988 0.000 0 0.012
#> SRR1539221 2 0.3838 0.446 0 0.552 0.000 0.448 0 0.000
#> SRR1539223 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539224 4 0.0000 0.806 0 0.000 0.000 1.000 0 0.000
#> SRR1539222 3 0.0363 0.993 0 0.000 0.988 0.000 0 0.012
#> SRR1539225 3 0.0000 0.993 0 0.000 1.000 0.000 0 0.000
#> SRR1539227 2 0.3838 0.446 0 0.552 0.000 0.448 0 0.000
#> SRR1539226 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539228 3 0.0000 0.993 0 0.000 1.000 0.000 0 0.000
#> SRR1539229 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539232 3 0.0000 0.993 0 0.000 1.000 0.000 0 0.000
#> SRR1539230 2 0.3838 0.446 0 0.552 0.000 0.448 0 0.000
#> SRR1539231 2 0.3838 0.446 0 0.552 0.000 0.448 0 0.000
#> SRR1539234 2 0.0458 0.769 0 0.984 0.000 0.016 0 0.000
#> SRR1539233 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539235 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539236 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539237 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539238 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539239 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539242 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539240 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539241 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539243 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539244 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539245 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539246 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539247 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539248 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539249 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539250 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539251 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539253 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539252 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539255 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539254 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539256 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539257 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539258 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539259 2 0.0000 0.776 0 1.000 0.000 0.000 0 0.000
#> SRR1539260 1 0.0000 1.000 1 0.000 0.000 0.000 0 0.000
#> SRR1539262 4 0.3838 0.131 0 0.448 0.000 0.552 0 0.000
#> SRR1539261 5 0.0000 1.000 0 0.000 0.000 0.000 1 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.661 0.756 0.754 0.3491 1.000 1.000
#> 4 4 0.718 0.418 0.679 0.1491 0.774 0.584
#> 5 5 0.692 0.879 0.785 0.0829 0.814 0.475
#> 6 6 0.782 0.846 0.798 0.0499 0.964 0.822
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 1 0.628 0.475 0.540 0.00 0.460
#> SRR1539208 1 0.579 0.745 0.668 0.00 0.332
#> SRR1539211 1 0.579 0.745 0.668 0.00 0.332
#> SRR1539210 1 0.628 0.475 0.540 0.00 0.460
#> SRR1539209 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539212 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539214 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539213 1 0.626 0.480 0.552 0.00 0.448
#> SRR1539215 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539216 1 0.628 0.475 0.540 0.00 0.460
#> SRR1539217 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539218 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539220 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539219 1 0.628 0.475 0.540 0.00 0.460
#> SRR1539221 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539223 1 0.579 0.745 0.668 0.00 0.332
#> SRR1539224 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539222 1 0.628 0.475 0.540 0.00 0.460
#> SRR1539225 1 0.626 0.480 0.552 0.00 0.448
#> SRR1539227 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539226 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539228 1 0.626 0.480 0.552 0.00 0.448
#> SRR1539229 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539232 1 0.626 0.480 0.552 0.00 0.448
#> SRR1539230 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539231 2 0.480 0.910 0.000 0.78 0.220
#> SRR1539234 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539233 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539235 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539236 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539237 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539238 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539239 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539242 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539240 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539241 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539243 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539244 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539245 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539246 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539247 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539248 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539249 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539250 1 0.116 0.715 0.972 0.00 0.028
#> SRR1539251 1 0.116 0.715 0.972 0.00 0.028
#> SRR1539253 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539252 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539255 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539254 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539256 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539257 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539258 1 0.571 0.748 0.680 0.00 0.320
#> SRR1539259 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539260 1 0.000 0.723 1.000 0.00 0.000
#> SRR1539262 2 0.000 0.919 0.000 1.00 0.000
#> SRR1539261 1 0.579 0.745 0.668 0.00 0.332
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.2984 0.945 0.028 0.000 0.888 0.084
#> SRR1539208 4 0.5396 1.000 0.464 0.000 0.012 0.524
#> SRR1539211 4 0.5396 1.000 0.464 0.000 0.012 0.524
#> SRR1539210 3 0.4225 0.876 0.024 0.000 0.792 0.184
#> SRR1539209 2 0.1406 0.799 0.000 0.960 0.016 0.024
#> SRR1539212 2 0.1406 0.799 0.000 0.960 0.016 0.024
#> SRR1539214 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539213 3 0.1118 0.956 0.036 0.000 0.964 0.000
#> SRR1539215 2 0.0000 0.807 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.2984 0.945 0.028 0.000 0.888 0.084
#> SRR1539217 1 0.4830 -0.623 0.608 0.000 0.000 0.392
#> SRR1539218 2 0.1406 0.799 0.000 0.960 0.016 0.024
#> SRR1539220 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539219 3 0.0921 0.954 0.028 0.000 0.972 0.000
#> SRR1539221 2 0.0000 0.807 0.000 1.000 0.000 0.000
#> SRR1539223 4 0.5396 1.000 0.464 0.000 0.012 0.524
#> SRR1539224 2 0.1406 0.799 0.000 0.960 0.016 0.024
#> SRR1539222 3 0.2949 0.942 0.024 0.000 0.888 0.088
#> SRR1539225 3 0.1118 0.956 0.036 0.000 0.964 0.000
#> SRR1539227 2 0.0000 0.807 0.000 1.000 0.000 0.000
#> SRR1539226 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539228 3 0.1118 0.956 0.036 0.000 0.964 0.000
#> SRR1539229 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539232 3 0.1118 0.956 0.036 0.000 0.964 0.000
#> SRR1539230 2 0.0000 0.807 0.000 1.000 0.000 0.000
#> SRR1539231 2 0.0000 0.807 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.4889 0.830 0.000 0.636 0.004 0.360
#> SRR1539233 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539235 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539236 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539237 2 0.4730 0.830 0.000 0.636 0.000 0.364
#> SRR1539238 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539239 1 0.4916 -0.680 0.576 0.000 0.000 0.424
#> SRR1539242 1 0.4916 -0.680 0.576 0.000 0.000 0.424
#> SRR1539240 2 0.4730 0.830 0.000 0.636 0.000 0.364
#> SRR1539241 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539243 2 0.4730 0.830 0.000 0.636 0.000 0.364
#> SRR1539244 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539245 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539246 2 0.5007 0.830 0.000 0.636 0.008 0.356
#> SRR1539247 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539248 1 0.4916 -0.680 0.576 0.000 0.000 0.424
#> SRR1539249 2 0.4889 0.830 0.000 0.636 0.004 0.360
#> SRR1539250 1 0.4868 0.313 0.684 0.000 0.304 0.012
#> SRR1539251 1 0.4868 0.313 0.684 0.000 0.304 0.012
#> SRR1539253 2 0.4889 0.830 0.000 0.636 0.004 0.360
#> SRR1539252 1 0.4643 -0.513 0.656 0.000 0.000 0.344
#> SRR1539255 1 0.4697 -0.544 0.644 0.000 0.000 0.356
#> SRR1539254 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539256 2 0.4730 0.830 0.000 0.636 0.000 0.364
#> SRR1539257 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539258 1 0.4790 -0.588 0.620 0.000 0.000 0.380
#> SRR1539259 2 0.4889 0.830 0.000 0.636 0.004 0.360
#> SRR1539260 1 0.4382 0.336 0.704 0.000 0.296 0.000
#> SRR1539262 2 0.4978 0.824 0.000 0.612 0.004 0.384
#> SRR1539261 4 0.5396 1.000 0.464 0.000 0.012 0.524
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.2850 0.893 0.016 0.000 0.880 0.088 0.016
#> SRR1539208 1 0.6749 0.608 0.512 0.000 0.020 0.292 0.176
#> SRR1539211 1 0.6789 0.600 0.504 0.000 0.020 0.296 0.180
#> SRR1539210 3 0.5656 0.647 0.000 0.000 0.624 0.236 0.140
#> SRR1539209 4 0.6007 0.859 0.000 0.396 0.000 0.488 0.116
#> SRR1539212 4 0.6007 0.859 0.000 0.396 0.000 0.488 0.116
#> SRR1539214 1 0.0880 0.841 0.968 0.000 0.000 0.000 0.032
#> SRR1539213 3 0.0609 0.914 0.020 0.000 0.980 0.000 0.000
#> SRR1539215 4 0.4273 0.883 0.000 0.448 0.000 0.552 0.000
#> SRR1539216 3 0.2850 0.893 0.016 0.000 0.880 0.088 0.016
#> SRR1539217 1 0.2514 0.834 0.896 0.000 0.000 0.060 0.044
#> SRR1539218 4 0.6007 0.859 0.000 0.396 0.000 0.488 0.116
#> SRR1539220 1 0.0880 0.841 0.968 0.000 0.000 0.000 0.032
#> SRR1539219 3 0.0510 0.913 0.016 0.000 0.984 0.000 0.000
#> SRR1539221 4 0.4273 0.883 0.000 0.448 0.000 0.552 0.000
#> SRR1539223 1 0.6749 0.608 0.512 0.000 0.020 0.292 0.176
#> SRR1539224 4 0.6007 0.859 0.000 0.396 0.000 0.488 0.116
#> SRR1539222 3 0.2707 0.876 0.000 0.000 0.876 0.100 0.024
#> SRR1539225 3 0.0609 0.914 0.020 0.000 0.980 0.000 0.000
#> SRR1539227 4 0.4273 0.883 0.000 0.448 0.000 0.552 0.000
#> SRR1539226 1 0.0880 0.841 0.968 0.000 0.000 0.000 0.032
#> SRR1539228 3 0.0609 0.914 0.020 0.000 0.980 0.000 0.000
#> SRR1539229 1 0.0880 0.841 0.968 0.000 0.000 0.000 0.032
#> SRR1539232 3 0.0609 0.914 0.020 0.000 0.980 0.000 0.000
#> SRR1539230 4 0.4273 0.883 0.000 0.448 0.000 0.552 0.000
#> SRR1539231 4 0.4273 0.883 0.000 0.448 0.000 0.552 0.000
#> SRR1539234 2 0.0609 0.961 0.000 0.980 0.000 0.000 0.020
#> SRR1539233 1 0.0880 0.841 0.968 0.000 0.000 0.000 0.032
#> SRR1539235 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539236 1 0.0703 0.841 0.976 0.000 0.000 0.000 0.024
#> SRR1539237 2 0.0290 0.972 0.000 0.992 0.000 0.000 0.008
#> SRR1539238 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539239 1 0.3035 0.818 0.856 0.000 0.000 0.112 0.032
#> SRR1539242 1 0.3035 0.818 0.856 0.000 0.000 0.112 0.032
#> SRR1539240 2 0.0000 0.972 0.000 1.000 0.000 0.000 0.000
#> SRR1539241 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539243 2 0.0000 0.972 0.000 1.000 0.000 0.000 0.000
#> SRR1539244 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539245 1 0.0609 0.841 0.980 0.000 0.000 0.000 0.020
#> SRR1539246 2 0.0880 0.962 0.000 0.968 0.000 0.000 0.032
#> SRR1539247 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539248 1 0.3035 0.818 0.856 0.000 0.000 0.112 0.032
#> SRR1539249 2 0.0703 0.970 0.000 0.976 0.000 0.000 0.024
#> SRR1539250 5 0.5691 0.945 0.132 0.000 0.212 0.008 0.648
#> SRR1539251 5 0.5691 0.945 0.132 0.000 0.212 0.008 0.648
#> SRR1539253 2 0.0609 0.971 0.000 0.980 0.000 0.000 0.020
#> SRR1539252 1 0.0404 0.843 0.988 0.000 0.000 0.000 0.012
#> SRR1539255 1 0.0162 0.844 0.996 0.000 0.000 0.000 0.004
#> SRR1539254 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539256 2 0.0000 0.972 0.000 1.000 0.000 0.000 0.000
#> SRR1539257 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539258 1 0.1809 0.836 0.928 0.000 0.000 0.060 0.012
#> SRR1539259 2 0.0609 0.971 0.000 0.980 0.000 0.000 0.020
#> SRR1539260 5 0.5687 0.987 0.164 0.000 0.208 0.000 0.628
#> SRR1539262 2 0.1872 0.895 0.000 0.928 0.000 0.052 0.020
#> SRR1539261 1 0.6749 0.608 0.512 0.000 0.020 0.292 0.176
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.5239 0.845 0.008 0.000 0.712 0.100 0.112 0.068
#> SRR1539208 6 0.3244 0.964 0.268 0.000 0.000 0.000 0.000 0.732
#> SRR1539211 6 0.4455 0.946 0.264 0.000 0.008 0.048 0.000 0.680
#> SRR1539210 3 0.7004 0.423 0.000 0.000 0.348 0.272 0.060 0.320
#> SRR1539209 4 0.6950 0.779 0.000 0.352 0.056 0.424 0.016 0.152
#> SRR1539212 4 0.6950 0.779 0.000 0.352 0.056 0.424 0.016 0.152
#> SRR1539214 1 0.1180 0.804 0.960 0.000 0.008 0.024 0.004 0.004
#> SRR1539213 3 0.2212 0.878 0.008 0.000 0.880 0.000 0.112 0.000
#> SRR1539215 4 0.3899 0.816 0.000 0.404 0.004 0.592 0.000 0.000
#> SRR1539216 3 0.5239 0.845 0.008 0.000 0.712 0.100 0.112 0.068
#> SRR1539217 1 0.3648 0.666 0.776 0.000 0.012 0.024 0.000 0.188
#> SRR1539218 4 0.6950 0.779 0.000 0.352 0.056 0.424 0.016 0.152
#> SRR1539220 1 0.1764 0.789 0.936 0.000 0.012 0.024 0.004 0.024
#> SRR1539219 3 0.2212 0.878 0.008 0.000 0.880 0.000 0.112 0.000
#> SRR1539221 4 0.3765 0.817 0.000 0.404 0.000 0.596 0.000 0.000
#> SRR1539223 6 0.3628 0.959 0.268 0.000 0.008 0.004 0.000 0.720
#> SRR1539224 4 0.6950 0.779 0.000 0.352 0.056 0.424 0.016 0.152
#> SRR1539222 3 0.6126 0.771 0.000 0.000 0.584 0.224 0.108 0.084
#> SRR1539225 3 0.2212 0.878 0.008 0.000 0.880 0.000 0.112 0.000
#> SRR1539227 4 0.3765 0.817 0.000 0.404 0.000 0.596 0.000 0.000
#> SRR1539226 1 0.0837 0.808 0.972 0.000 0.004 0.020 0.004 0.000
#> SRR1539228 3 0.2212 0.878 0.008 0.000 0.880 0.000 0.112 0.000
#> SRR1539229 1 0.0837 0.808 0.972 0.000 0.004 0.020 0.004 0.000
#> SRR1539232 3 0.2355 0.878 0.008 0.000 0.876 0.000 0.112 0.004
#> SRR1539230 4 0.3765 0.817 0.000 0.404 0.000 0.596 0.000 0.000
#> SRR1539231 4 0.3765 0.817 0.000 0.404 0.000 0.596 0.000 0.000
#> SRR1539234 2 0.1562 0.930 0.000 0.940 0.004 0.000 0.024 0.032
#> SRR1539233 1 0.0837 0.808 0.972 0.000 0.004 0.020 0.004 0.000
#> SRR1539235 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539236 1 0.1477 0.795 0.940 0.000 0.008 0.048 0.004 0.000
#> SRR1539237 2 0.0717 0.938 0.000 0.976 0.016 0.000 0.000 0.008
#> SRR1539238 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539239 1 0.4668 0.446 0.652 0.000 0.008 0.056 0.000 0.284
#> SRR1539242 1 0.4668 0.446 0.652 0.000 0.008 0.056 0.000 0.284
#> SRR1539240 2 0.1074 0.939 0.000 0.960 0.000 0.000 0.012 0.028
#> SRR1539241 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539243 2 0.1074 0.939 0.000 0.960 0.000 0.000 0.012 0.028
#> SRR1539244 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539245 1 0.0146 0.809 0.996 0.000 0.000 0.000 0.004 0.000
#> SRR1539246 2 0.1777 0.934 0.000 0.932 0.012 0.000 0.032 0.024
#> SRR1539247 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539248 1 0.4668 0.446 0.652 0.000 0.008 0.056 0.000 0.284
#> SRR1539249 2 0.1138 0.934 0.000 0.960 0.024 0.000 0.012 0.004
#> SRR1539250 5 0.1765 0.978 0.052 0.000 0.000 0.000 0.924 0.024
#> SRR1539251 5 0.1765 0.978 0.052 0.000 0.000 0.000 0.924 0.024
#> SRR1539253 2 0.0891 0.934 0.000 0.968 0.024 0.000 0.008 0.000
#> SRR1539252 1 0.0000 0.810 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.1462 0.791 0.936 0.000 0.008 0.056 0.000 0.000
#> SRR1539254 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539256 2 0.1074 0.939 0.000 0.960 0.000 0.000 0.012 0.028
#> SRR1539257 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539258 1 0.3816 0.666 0.780 0.000 0.008 0.056 0.000 0.156
#> SRR1539259 2 0.1074 0.931 0.000 0.960 0.028 0.000 0.012 0.000
#> SRR1539260 5 0.1141 0.995 0.052 0.000 0.000 0.000 0.948 0.000
#> SRR1539262 2 0.2202 0.868 0.000 0.908 0.028 0.052 0.012 0.000
#> SRR1539261 6 0.3971 0.962 0.268 0.000 0.004 0.024 0.000 0.704
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.992 0.997 0.4760 0.523 0.523
#> 3 3 1.000 0.976 0.992 0.4251 0.757 0.553
#> 4 4 0.874 0.596 0.770 0.0771 0.953 0.855
#> 5 5 0.969 0.932 0.952 0.0672 0.890 0.639
#> 6 6 0.970 0.949 0.966 0.0713 0.942 0.742
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 5
There is also optional best \(k\) = 2 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0.000 1.000 1.000 0.000
#> SRR1539208 1 0.000 1.000 1.000 0.000
#> SRR1539211 2 0.697 0.768 0.188 0.812
#> SRR1539210 1 0.000 1.000 1.000 0.000
#> SRR1539209 2 0.000 0.991 0.000 1.000
#> SRR1539212 2 0.000 0.991 0.000 1.000
#> SRR1539214 1 0.000 1.000 1.000 0.000
#> SRR1539213 1 0.000 1.000 1.000 0.000
#> SRR1539215 2 0.000 0.991 0.000 1.000
#> SRR1539216 1 0.000 1.000 1.000 0.000
#> SRR1539217 1 0.000 1.000 1.000 0.000
#> SRR1539218 2 0.000 0.991 0.000 1.000
#> SRR1539220 1 0.000 1.000 1.000 0.000
#> SRR1539219 1 0.000 1.000 1.000 0.000
#> SRR1539221 2 0.000 0.991 0.000 1.000
#> SRR1539223 1 0.000 1.000 1.000 0.000
#> SRR1539224 2 0.000 0.991 0.000 1.000
#> SRR1539222 1 0.000 1.000 1.000 0.000
#> SRR1539225 1 0.000 1.000 1.000 0.000
#> SRR1539227 2 0.000 0.991 0.000 1.000
#> SRR1539226 1 0.000 1.000 1.000 0.000
#> SRR1539228 1 0.000 1.000 1.000 0.000
#> SRR1539229 1 0.000 1.000 1.000 0.000
#> SRR1539232 1 0.000 1.000 1.000 0.000
#> SRR1539230 2 0.000 0.991 0.000 1.000
#> SRR1539231 2 0.000 0.991 0.000 1.000
#> SRR1539234 2 0.000 0.991 0.000 1.000
#> SRR1539233 1 0.000 1.000 1.000 0.000
#> SRR1539235 1 0.000 1.000 1.000 0.000
#> SRR1539236 1 0.000 1.000 1.000 0.000
#> SRR1539237 2 0.000 0.991 0.000 1.000
#> SRR1539238 1 0.000 1.000 1.000 0.000
#> SRR1539239 1 0.000 1.000 1.000 0.000
#> SRR1539242 1 0.000 1.000 1.000 0.000
#> SRR1539240 2 0.000 0.991 0.000 1.000
#> SRR1539241 1 0.000 1.000 1.000 0.000
#> SRR1539243 2 0.000 0.991 0.000 1.000
#> SRR1539244 1 0.000 1.000 1.000 0.000
#> SRR1539245 1 0.000 1.000 1.000 0.000
#> SRR1539246 2 0.000 0.991 0.000 1.000
#> SRR1539247 1 0.000 1.000 1.000 0.000
#> SRR1539248 1 0.000 1.000 1.000 0.000
#> SRR1539249 2 0.000 0.991 0.000 1.000
#> SRR1539250 1 0.000 1.000 1.000 0.000
#> SRR1539251 1 0.000 1.000 1.000 0.000
#> SRR1539253 2 0.000 0.991 0.000 1.000
#> SRR1539252 1 0.000 1.000 1.000 0.000
#> SRR1539255 1 0.000 1.000 1.000 0.000
#> SRR1539254 1 0.000 1.000 1.000 0.000
#> SRR1539256 2 0.000 0.991 0.000 1.000
#> SRR1539257 1 0.000 1.000 1.000 0.000
#> SRR1539258 1 0.000 1.000 1.000 0.000
#> SRR1539259 2 0.000 0.991 0.000 1.000
#> SRR1539260 1 0.000 1.000 1.000 0.000
#> SRR1539262 2 0.000 0.991 0.000 1.000
#> SRR1539261 2 0.000 0.991 0.000 1.000
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.000 1.000 0.00 0 1.00
#> SRR1539208 1 0.000 0.973 1.00 0 0.00
#> SRR1539211 1 0.000 0.973 1.00 0 0.00
#> SRR1539210 3 0.000 1.000 0.00 0 1.00
#> SRR1539209 2 0.000 1.000 0.00 1 0.00
#> SRR1539212 2 0.000 1.000 0.00 1 0.00
#> SRR1539214 1 0.000 0.973 1.00 0 0.00
#> SRR1539213 3 0.000 1.000 0.00 0 1.00
#> SRR1539215 2 0.000 1.000 0.00 1 0.00
#> SRR1539216 3 0.000 1.000 0.00 0 1.00
#> SRR1539217 1 0.000 0.973 1.00 0 0.00
#> SRR1539218 2 0.000 1.000 0.00 1 0.00
#> SRR1539220 1 0.628 0.148 0.54 0 0.46
#> SRR1539219 3 0.000 1.000 0.00 0 1.00
#> SRR1539221 2 0.000 1.000 0.00 1 0.00
#> SRR1539223 1 0.000 0.973 1.00 0 0.00
#> SRR1539224 2 0.000 1.000 0.00 1 0.00
#> SRR1539222 3 0.000 1.000 0.00 0 1.00
#> SRR1539225 3 0.000 1.000 0.00 0 1.00
#> SRR1539227 2 0.000 1.000 0.00 1 0.00
#> SRR1539226 1 0.000 0.973 1.00 0 0.00
#> SRR1539228 3 0.000 1.000 0.00 0 1.00
#> SRR1539229 1 0.000 0.973 1.00 0 0.00
#> SRR1539232 3 0.000 1.000 0.00 0 1.00
#> SRR1539230 2 0.000 1.000 0.00 1 0.00
#> SRR1539231 2 0.000 1.000 0.00 1 0.00
#> SRR1539234 2 0.000 1.000 0.00 1 0.00
#> SRR1539233 1 0.000 0.973 1.00 0 0.00
#> SRR1539235 3 0.000 1.000 0.00 0 1.00
#> SRR1539236 1 0.000 0.973 1.00 0 0.00
#> SRR1539237 2 0.000 1.000 0.00 1 0.00
#> SRR1539238 3 0.000 1.000 0.00 0 1.00
#> SRR1539239 1 0.000 0.973 1.00 0 0.00
#> SRR1539242 1 0.000 0.973 1.00 0 0.00
#> SRR1539240 2 0.000 1.000 0.00 1 0.00
#> SRR1539241 3 0.000 1.000 0.00 0 1.00
#> SRR1539243 2 0.000 1.000 0.00 1 0.00
#> SRR1539244 3 0.000 1.000 0.00 0 1.00
#> SRR1539245 1 0.000 0.973 1.00 0 0.00
#> SRR1539246 2 0.000 1.000 0.00 1 0.00
#> SRR1539247 3 0.000 1.000 0.00 0 1.00
#> SRR1539248 1 0.000 0.973 1.00 0 0.00
#> SRR1539249 2 0.000 1.000 0.00 1 0.00
#> SRR1539250 3 0.000 1.000 0.00 0 1.00
#> SRR1539251 3 0.000 1.000 0.00 0 1.00
#> SRR1539253 2 0.000 1.000 0.00 1 0.00
#> SRR1539252 1 0.000 0.973 1.00 0 0.00
#> SRR1539255 1 0.000 0.973 1.00 0 0.00
#> SRR1539254 3 0.000 1.000 0.00 0 1.00
#> SRR1539256 2 0.000 1.000 0.00 1 0.00
#> SRR1539257 3 0.000 1.000 0.00 0 1.00
#> SRR1539258 1 0.000 0.973 1.00 0 0.00
#> SRR1539259 2 0.000 1.000 0.00 1 0.00
#> SRR1539260 3 0.000 1.000 0.00 0 1.00
#> SRR1539262 2 0.000 1.000 0.00 1 0.00
#> SRR1539261 1 0.000 0.973 1.00 0 0.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.0000 0.3082 1.000 0.000 0.000 0.000
#> SRR1539211 1 0.0000 0.3082 1.000 0.000 0.000 0.000
#> SRR1539210 3 0.4992 0.1473 0.476 0.000 0.524 0.000
#> SRR1539209 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539212 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539214 1 0.5000 -1.0000 0.500 0.000 0.000 0.500
#> SRR1539213 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539215 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539216 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.4431 -0.2345 0.696 0.000 0.000 0.304
#> SRR1539218 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539220 1 0.7617 0.0121 0.452 0.000 0.332 0.216
#> SRR1539219 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539223 1 0.0000 0.3082 1.000 0.000 0.000 0.000
#> SRR1539224 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539222 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539227 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539226 4 0.5000 1.0000 0.500 0.000 0.000 0.500
#> SRR1539228 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539229 4 0.5000 1.0000 0.500 0.000 0.000 0.500
#> SRR1539232 3 0.0000 0.7097 0.000 0.000 1.000 0.000
#> SRR1539230 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539231 2 0.0336 0.9965 0.000 0.992 0.000 0.008
#> SRR1539234 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539233 4 0.5000 1.0000 0.500 0.000 0.000 0.500
#> SRR1539235 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539236 4 0.5000 1.0000 0.500 0.000 0.000 0.500
#> SRR1539237 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539238 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539239 1 0.5000 -0.9832 0.504 0.000 0.000 0.496
#> SRR1539242 1 0.5000 -0.9832 0.504 0.000 0.000 0.496
#> SRR1539240 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539241 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539243 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539244 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539245 1 0.5000 -1.0000 0.500 0.000 0.000 0.500
#> SRR1539246 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539247 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539248 1 0.5000 -0.9832 0.504 0.000 0.000 0.496
#> SRR1539249 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539250 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539251 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539253 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539252 4 0.5000 1.0000 0.500 0.000 0.000 0.500
#> SRR1539255 4 0.5000 1.0000 0.500 0.000 0.000 0.500
#> SRR1539254 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539256 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539257 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539258 1 0.5000 -1.0000 0.500 0.000 0.000 0.500
#> SRR1539259 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539260 3 0.4999 0.7564 0.000 0.000 0.508 0.492
#> SRR1539262 2 0.0000 0.9968 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.0000 0.3082 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539208 4 0.0963 0.995 0.036 0.00 0.000 0.964 0.000
#> SRR1539211 4 0.0963 0.995 0.036 0.00 0.000 0.964 0.000
#> SRR1539210 3 0.4211 0.446 0.000 0.00 0.636 0.360 0.004
#> SRR1539209 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539212 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539214 1 0.0000 0.912 1.000 0.00 0.000 0.000 0.000
#> SRR1539213 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539215 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539216 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539217 1 0.4074 0.442 0.636 0.00 0.000 0.364 0.000
#> SRR1539218 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539220 1 0.1792 0.841 0.916 0.00 0.000 0.000 0.084
#> SRR1539219 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539221 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539223 4 0.1197 0.985 0.048 0.00 0.000 0.952 0.000
#> SRR1539224 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539222 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539225 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539227 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539226 1 0.0000 0.912 1.000 0.00 0.000 0.000 0.000
#> SRR1539228 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539229 1 0.0000 0.912 1.000 0.00 0.000 0.000 0.000
#> SRR1539232 3 0.1197 0.954 0.000 0.00 0.952 0.000 0.048
#> SRR1539230 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539231 2 0.2074 0.959 0.000 0.92 0.044 0.036 0.000
#> SRR1539234 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539233 1 0.0000 0.912 1.000 0.00 0.000 0.000 0.000
#> SRR1539235 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539236 1 0.0162 0.911 0.996 0.00 0.004 0.000 0.000
#> SRR1539237 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539238 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539239 1 0.3048 0.809 0.820 0.00 0.004 0.176 0.000
#> SRR1539242 1 0.3048 0.809 0.820 0.00 0.004 0.176 0.000
#> SRR1539240 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539241 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539243 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539244 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539245 1 0.0000 0.912 1.000 0.00 0.000 0.000 0.000
#> SRR1539246 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539247 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539248 1 0.3048 0.809 0.820 0.00 0.004 0.176 0.000
#> SRR1539249 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539250 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539251 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539253 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539252 1 0.0000 0.912 1.000 0.00 0.000 0.000 0.000
#> SRR1539255 1 0.0162 0.911 0.996 0.00 0.004 0.000 0.000
#> SRR1539254 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539256 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539257 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539258 1 0.1502 0.888 0.940 0.00 0.004 0.056 0.000
#> SRR1539259 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539260 5 0.0000 1.000 0.000 0.00 0.000 0.000 1.000
#> SRR1539262 2 0.0000 0.963 0.000 1.00 0.000 0.000 0.000
#> SRR1539261 4 0.0963 0.995 0.036 0.00 0.000 0.964 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 6 0.0000 0.991 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539211 6 0.0000 0.991 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539210 3 0.3737 0.362 0.000 0.000 0.608 0.000 0.000 0.392
#> SRR1539209 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539212 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539214 1 0.0547 0.917 0.980 0.000 0.000 0.020 0.000 0.000
#> SRR1539213 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539215 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539216 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 1 0.3969 0.551 0.668 0.000 0.000 0.020 0.000 0.312
#> SRR1539218 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539220 1 0.1549 0.890 0.936 0.000 0.000 0.020 0.044 0.000
#> SRR1539219 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539223 6 0.0692 0.972 0.020 0.000 0.000 0.004 0.000 0.976
#> SRR1539224 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539222 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539227 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539226 1 0.0458 0.918 0.984 0.000 0.000 0.016 0.000 0.000
#> SRR1539228 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.0458 0.918 0.984 0.000 0.000 0.016 0.000 0.000
#> SRR1539232 3 0.0000 0.949 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539230 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539231 4 0.1075 1.000 0.000 0.048 0.000 0.952 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539233 1 0.0458 0.918 0.984 0.000 0.000 0.016 0.000 0.000
#> SRR1539235 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539236 1 0.0632 0.917 0.976 0.000 0.000 0.024 0.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539239 1 0.2949 0.842 0.832 0.000 0.000 0.028 0.000 0.140
#> SRR1539242 1 0.2949 0.842 0.832 0.000 0.000 0.028 0.000 0.140
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539245 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539248 1 0.2949 0.842 0.832 0.000 0.000 0.028 0.000 0.140
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539251 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.0000 0.920 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.0632 0.917 0.976 0.000 0.000 0.024 0.000 0.000
#> SRR1539254 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539258 1 0.1498 0.906 0.940 0.000 0.000 0.028 0.000 0.032
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.0000 1.000 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 6 0.0000 0.991 0.000 0.000 0.000 0.000 0.000 1.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.976 0.946 0.978 0.4768 0.779 0.594
#> 4 4 0.853 0.936 0.946 0.0976 0.936 0.801
#> 5 5 0.982 0.946 0.979 0.0772 0.945 0.789
#> 6 6 0.935 0.892 0.930 0.0301 0.978 0.893
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 3 5
There is also optional best \(k\) = 2 3 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.985 0.000 0 1.000
#> SRR1539208 1 0.4399 0.749 0.812 0 0.188
#> SRR1539211 1 0.0000 0.936 1.000 0 0.000
#> SRR1539210 3 0.0000 0.985 0.000 0 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000
#> SRR1539214 1 0.6026 0.394 0.624 0 0.376
#> SRR1539213 3 0.0000 0.985 0.000 0 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000
#> SRR1539216 3 0.0000 0.985 0.000 0 1.000
#> SRR1539217 1 0.0000 0.936 1.000 0 0.000
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000
#> SRR1539220 3 0.4796 0.690 0.220 0 0.780
#> SRR1539219 3 0.0000 0.985 0.000 0 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000
#> SRR1539223 1 0.6154 0.331 0.592 0 0.408
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000
#> SRR1539222 3 0.0000 0.985 0.000 0 1.000
#> SRR1539225 3 0.0000 0.985 0.000 0 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000
#> SRR1539226 1 0.0000 0.936 1.000 0 0.000
#> SRR1539228 3 0.0000 0.985 0.000 0 1.000
#> SRR1539229 1 0.0000 0.936 1.000 0 0.000
#> SRR1539232 3 0.0000 0.985 0.000 0 1.000
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000
#> SRR1539233 1 0.0000 0.936 1.000 0 0.000
#> SRR1539235 3 0.0237 0.985 0.004 0 0.996
#> SRR1539236 1 0.0000 0.936 1.000 0 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000
#> SRR1539238 3 0.0237 0.985 0.004 0 0.996
#> SRR1539239 1 0.0000 0.936 1.000 0 0.000
#> SRR1539242 1 0.0000 0.936 1.000 0 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000
#> SRR1539241 3 0.0237 0.985 0.004 0 0.996
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000
#> SRR1539244 3 0.0237 0.985 0.004 0 0.996
#> SRR1539245 1 0.0000 0.936 1.000 0 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000
#> SRR1539247 3 0.0237 0.985 0.004 0 0.996
#> SRR1539248 1 0.0000 0.936 1.000 0 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000
#> SRR1539250 3 0.0237 0.985 0.004 0 0.996
#> SRR1539251 3 0.0237 0.985 0.004 0 0.996
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000
#> SRR1539252 1 0.0000 0.936 1.000 0 0.000
#> SRR1539255 1 0.0000 0.936 1.000 0 0.000
#> SRR1539254 3 0.0237 0.985 0.004 0 0.996
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000
#> SRR1539257 3 0.0237 0.985 0.004 0 0.996
#> SRR1539258 1 0.0000 0.936 1.000 0 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000
#> SRR1539260 3 0.0237 0.985 0.004 0 0.996
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000
#> SRR1539261 1 0.0000 0.936 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.4780 0.711 0.788 0.000 0.116 0.096
#> SRR1539211 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539210 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539209 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539212 2 0.0817 0.953 0.000 0.976 0.000 0.024
#> SRR1539214 1 0.4888 0.269 0.588 0.000 0.000 0.412
#> SRR1539213 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539215 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539216 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539218 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539220 4 0.6366 0.651 0.240 0.000 0.120 0.640
#> SRR1539219 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539223 1 0.2647 0.822 0.880 0.000 0.120 0.000
#> SRR1539224 2 0.2589 0.940 0.000 0.884 0.000 0.116
#> SRR1539222 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539227 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539226 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539228 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539229 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539232 3 0.0000 1.000 0.000 0.000 1.000 0.000
#> SRR1539230 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539231 2 0.2647 0.939 0.000 0.880 0.000 0.120
#> SRR1539234 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539233 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539235 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539236 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539238 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539239 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539241 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539243 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539244 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539245 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539246 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539247 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539248 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539250 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539251 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539253 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539254 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539256 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539257 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539258 1 0.0000 0.948 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539260 4 0.2647 0.968 0.000 0.000 0.120 0.880
#> SRR1539262 2 0.0000 0.955 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.0000 0.948 1.000 0.000 0.000 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539208 1 0.321 0.710 0.788 0.000 0 0.000 0.212
#> SRR1539211 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539210 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539209 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539212 2 0.112 0.936 0.000 0.956 0 0.044 0.000
#> SRR1539214 1 0.422 0.253 0.584 0.000 0 0.000 0.416
#> SRR1539213 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539215 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539216 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539217 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539218 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539220 5 0.342 0.657 0.240 0.000 0 0.000 0.760
#> SRR1539219 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539221 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539223 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539224 2 0.359 0.652 0.000 0.736 0 0.264 0.000
#> SRR1539222 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539225 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539227 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539226 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539228 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539229 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539232 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539230 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539231 4 0.000 1.000 0.000 0.000 0 1.000 0.000
#> SRR1539234 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539233 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539235 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539236 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539237 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539238 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539239 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539242 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539240 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539241 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539243 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539244 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539245 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539246 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539247 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539248 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539249 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539250 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539251 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539253 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539252 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539255 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539254 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539256 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539257 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539258 1 0.000 0.957 1.000 0.000 0 0.000 0.000
#> SRR1539259 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539260 5 0.000 0.970 0.000 0.000 0 0.000 1.000
#> SRR1539262 2 0.000 0.972 0.000 1.000 0 0.000 0.000
#> SRR1539261 1 0.000 0.957 1.000 0.000 0 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539208 1 0.3489 0.623 0.708 0.000 0 0.000 0.288 0.004
#> SRR1539211 1 0.0146 0.856 0.996 0.000 0 0.000 0.000 0.004
#> SRR1539210 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539209 6 0.0146 0.832 0.000 0.000 0 0.004 0.000 0.996
#> SRR1539212 6 0.3050 0.615 0.000 0.236 0 0.000 0.000 0.764
#> SRR1539214 1 0.6078 0.219 0.388 0.000 0 0.276 0.336 0.000
#> SRR1539213 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539215 4 0.3288 1.000 0.000 0.000 0 0.724 0.000 0.276
#> SRR1539216 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539217 1 0.0000 0.857 1.000 0.000 0 0.000 0.000 0.000
#> SRR1539218 6 0.0146 0.832 0.000 0.000 0 0.004 0.000 0.996
#> SRR1539220 5 0.5805 0.203 0.228 0.000 0 0.276 0.496 0.000
#> SRR1539219 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539221 4 0.3288 1.000 0.000 0.000 0 0.724 0.000 0.276
#> SRR1539223 1 0.0146 0.856 0.996 0.000 0 0.000 0.000 0.004
#> SRR1539224 6 0.0458 0.833 0.000 0.016 0 0.000 0.000 0.984
#> SRR1539222 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539227 4 0.3288 1.000 0.000 0.000 0 0.724 0.000 0.276
#> SRR1539226 1 0.3288 0.769 0.724 0.000 0 0.276 0.000 0.000
#> SRR1539228 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539229 1 0.3288 0.769 0.724 0.000 0 0.276 0.000 0.000
#> SRR1539232 3 0.0000 1.000 0.000 0.000 1 0.000 0.000 0.000
#> SRR1539230 4 0.3288 1.000 0.000 0.000 0 0.724 0.000 0.276
#> SRR1539231 4 0.3288 1.000 0.000 0.000 0 0.724 0.000 0.276
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539233 1 0.3288 0.769 0.724 0.000 0 0.276 0.000 0.000
#> SRR1539235 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539236 1 0.3288 0.769 0.724 0.000 0 0.276 0.000 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539238 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539239 1 0.0146 0.856 0.996 0.000 0 0.000 0.000 0.004
#> SRR1539242 1 0.0000 0.857 1.000 0.000 0 0.000 0.000 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539241 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539244 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539245 1 0.3288 0.769 0.724 0.000 0 0.276 0.000 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539247 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539248 1 0.0000 0.857 1.000 0.000 0 0.000 0.000 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539250 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539251 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539252 1 0.0000 0.857 1.000 0.000 0 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.857 1.000 0.000 0 0.000 0.000 0.000
#> SRR1539254 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539257 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539258 1 0.0000 0.857 1.000 0.000 0 0.000 0.000 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539260 5 0.0000 0.942 0.000 0.000 0 0.000 1.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0 0.000 0.000 0.000
#> SRR1539261 1 0.0146 0.856 0.996 0.000 0 0.000 0.000 0.004
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.975 0.952 0.975 0.3587 0.836 0.699
#> 4 4 0.749 0.829 0.837 0.1076 0.943 0.850
#> 5 5 0.795 0.865 0.886 0.1328 0.875 0.614
#> 6 6 0.946 0.870 0.956 0.0506 0.970 0.853
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0237 0.940 0.004 0 0.996
#> SRR1539208 1 0.0000 0.959 1.000 0 0.000
#> SRR1539211 1 0.0237 0.957 0.996 0 0.004
#> SRR1539210 3 0.0000 0.942 0.000 0 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000
#> SRR1539214 1 0.0000 0.959 1.000 0 0.000
#> SRR1539213 3 0.0000 0.942 0.000 0 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000
#> SRR1539216 3 0.0000 0.942 0.000 0 1.000
#> SRR1539217 1 0.0000 0.959 1.000 0 0.000
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000
#> SRR1539220 1 0.1163 0.951 0.972 0 0.028
#> SRR1539219 3 0.0000 0.942 0.000 0 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000
#> SRR1539223 1 0.0000 0.959 1.000 0 0.000
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000
#> SRR1539222 3 0.0000 0.942 0.000 0 1.000
#> SRR1539225 3 0.0000 0.942 0.000 0 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000
#> SRR1539226 1 0.0000 0.959 1.000 0 0.000
#> SRR1539228 3 0.0237 0.940 0.004 0 0.996
#> SRR1539229 1 0.0000 0.959 1.000 0 0.000
#> SRR1539232 3 0.6095 0.281 0.392 0 0.608
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000
#> SRR1539233 1 0.0000 0.959 1.000 0 0.000
#> SRR1539235 1 0.2878 0.926 0.904 0 0.096
#> SRR1539236 1 0.0000 0.959 1.000 0 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000
#> SRR1539238 1 0.2878 0.926 0.904 0 0.096
#> SRR1539239 1 0.0000 0.959 1.000 0 0.000
#> SRR1539242 1 0.0000 0.959 1.000 0 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000
#> SRR1539241 1 0.2878 0.926 0.904 0 0.096
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000
#> SRR1539244 1 0.2959 0.924 0.900 0 0.100
#> SRR1539245 1 0.0000 0.959 1.000 0 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000
#> SRR1539247 1 0.2878 0.926 0.904 0 0.096
#> SRR1539248 1 0.0000 0.959 1.000 0 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000
#> SRR1539250 1 0.2878 0.926 0.904 0 0.096
#> SRR1539251 1 0.2878 0.926 0.904 0 0.096
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000
#> SRR1539252 1 0.0000 0.959 1.000 0 0.000
#> SRR1539255 1 0.0000 0.959 1.000 0 0.000
#> SRR1539254 1 0.2878 0.926 0.904 0 0.096
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000
#> SRR1539257 1 0.2878 0.926 0.904 0 0.096
#> SRR1539258 1 0.0000 0.959 1.000 0 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000
#> SRR1539260 1 0.2878 0.926 0.904 0 0.096
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000
#> SRR1539261 1 0.0237 0.957 0.996 0 0.004
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.3498 0.880 0.832 0.160 0.008 0.000
#> SRR1539211 1 0.7197 0.818 0.660 0.164 0.080 0.096
#> SRR1539210 3 0.1004 0.970 0.000 0.004 0.972 0.024
#> SRR1539209 2 0.3219 0.875 0.000 0.836 0.000 0.164
#> SRR1539212 2 0.3172 0.871 0.000 0.840 0.000 0.160
#> SRR1539214 1 0.0188 0.866 0.996 0.000 0.004 0.000
#> SRR1539213 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> SRR1539215 4 0.2408 0.761 0.000 0.104 0.000 0.896
#> SRR1539216 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.3355 0.880 0.836 0.160 0.004 0.000
#> SRR1539218 4 0.4916 0.287 0.000 0.424 0.000 0.576
#> SRR1539220 1 0.0469 0.865 0.988 0.000 0.012 0.000
#> SRR1539219 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> SRR1539221 4 0.2408 0.761 0.000 0.104 0.000 0.896
#> SRR1539223 1 0.1118 0.864 0.964 0.000 0.036 0.000
#> SRR1539224 4 0.4916 0.287 0.000 0.424 0.000 0.576
#> SRR1539222 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0000 0.985 0.000 0.000 1.000 0.000
#> SRR1539227 4 0.2408 0.761 0.000 0.104 0.000 0.896
#> SRR1539226 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539228 3 0.0188 0.983 0.000 0.000 0.996 0.004
#> SRR1539229 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539232 3 0.2048 0.904 0.064 0.000 0.928 0.008
#> SRR1539230 4 0.2408 0.761 0.000 0.104 0.000 0.896
#> SRR1539231 4 0.2408 0.761 0.000 0.104 0.000 0.896
#> SRR1539234 2 0.4164 0.824 0.000 0.736 0.000 0.264
#> SRR1539233 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539235 1 0.2412 0.851 0.908 0.000 0.084 0.008
#> SRR1539236 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539237 2 0.3266 0.875 0.000 0.832 0.000 0.168
#> SRR1539238 1 0.2546 0.848 0.900 0.000 0.092 0.008
#> SRR1539239 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539242 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539240 2 0.3942 0.846 0.000 0.764 0.000 0.236
#> SRR1539241 1 0.2480 0.849 0.904 0.000 0.088 0.008
#> SRR1539243 2 0.3219 0.875 0.000 0.836 0.000 0.164
#> SRR1539244 1 0.3404 0.828 0.864 0.000 0.104 0.032
#> SRR1539245 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539246 2 0.4277 0.802 0.000 0.720 0.000 0.280
#> SRR1539247 1 0.2611 0.846 0.896 0.000 0.096 0.008
#> SRR1539248 1 0.3625 0.874 0.828 0.160 0.000 0.012
#> SRR1539249 4 0.4916 0.287 0.000 0.424 0.000 0.576
#> SRR1539250 1 0.2675 0.843 0.892 0.000 0.100 0.008
#> SRR1539251 1 0.2675 0.843 0.892 0.000 0.100 0.008
#> SRR1539253 2 0.4454 0.754 0.000 0.692 0.000 0.308
#> SRR1539252 1 0.3355 0.880 0.836 0.160 0.004 0.000
#> SRR1539255 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539254 1 0.2611 0.846 0.896 0.000 0.096 0.008
#> SRR1539256 2 0.3219 0.875 0.000 0.836 0.000 0.164
#> SRR1539257 1 0.2480 0.849 0.904 0.000 0.088 0.008
#> SRR1539258 1 0.3172 0.879 0.840 0.160 0.000 0.000
#> SRR1539259 2 0.4898 0.434 0.000 0.584 0.000 0.416
#> SRR1539260 1 0.2611 0.846 0.896 0.000 0.096 0.008
#> SRR1539262 2 0.3172 0.871 0.000 0.840 0.000 0.160
#> SRR1539261 1 0.7095 0.819 0.668 0.160 0.076 0.096
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.1671 0.938 0.000 0.000 0.924 0.000 0.076
#> SRR1539208 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539211 1 0.2616 0.665 0.888 0.000 0.076 0.036 0.000
#> SRR1539210 3 0.2074 0.893 0.036 0.000 0.920 0.000 0.044
#> SRR1539209 2 0.4171 0.253 0.000 0.604 0.000 0.396 0.000
#> SRR1539212 2 0.0324 0.907 0.000 0.992 0.004 0.004 0.000
#> SRR1539214 5 0.3983 0.306 0.340 0.000 0.000 0.000 0.660
#> SRR1539213 3 0.1908 0.940 0.000 0.000 0.908 0.000 0.092
#> SRR1539215 4 0.0963 0.946 0.000 0.036 0.000 0.964 0.000
#> SRR1539216 3 0.1671 0.938 0.000 0.000 0.924 0.000 0.076
#> SRR1539217 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539218 4 0.2516 0.904 0.000 0.140 0.000 0.860 0.000
#> SRR1539220 5 0.3210 0.638 0.212 0.000 0.000 0.000 0.788
#> SRR1539219 3 0.1908 0.940 0.000 0.000 0.908 0.000 0.092
#> SRR1539221 4 0.0963 0.946 0.000 0.036 0.000 0.964 0.000
#> SRR1539223 1 0.4300 0.346 0.524 0.000 0.000 0.000 0.476
#> SRR1539224 4 0.2516 0.904 0.000 0.140 0.000 0.860 0.000
#> SRR1539222 3 0.1671 0.938 0.000 0.000 0.924 0.000 0.076
#> SRR1539225 3 0.1908 0.940 0.000 0.000 0.908 0.000 0.092
#> SRR1539227 4 0.0963 0.946 0.000 0.036 0.000 0.964 0.000
#> SRR1539226 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539228 3 0.1908 0.940 0.000 0.000 0.908 0.000 0.092
#> SRR1539229 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539232 3 0.4210 0.484 0.000 0.000 0.588 0.000 0.412
#> SRR1539230 4 0.1043 0.946 0.000 0.040 0.000 0.960 0.000
#> SRR1539231 4 0.1043 0.946 0.000 0.040 0.000 0.960 0.000
#> SRR1539234 2 0.2179 0.867 0.000 0.888 0.000 0.112 0.000
#> SRR1539233 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539235 5 0.0000 0.926 0.000 0.000 0.000 0.000 1.000
#> SRR1539236 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539237 2 0.0290 0.908 0.000 0.992 0.000 0.008 0.000
#> SRR1539238 5 0.0000 0.926 0.000 0.000 0.000 0.000 1.000
#> SRR1539239 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539242 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539240 2 0.0609 0.907 0.000 0.980 0.000 0.020 0.000
#> SRR1539241 5 0.0000 0.926 0.000 0.000 0.000 0.000 1.000
#> SRR1539243 2 0.0000 0.908 0.000 1.000 0.000 0.000 0.000
#> SRR1539244 5 0.0693 0.907 0.008 0.000 0.012 0.000 0.980
#> SRR1539245 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539246 2 0.1121 0.900 0.000 0.956 0.000 0.044 0.000
#> SRR1539247 5 0.0000 0.926 0.000 0.000 0.000 0.000 1.000
#> SRR1539248 1 0.2891 0.923 0.824 0.000 0.000 0.000 0.176
#> SRR1539249 4 0.2471 0.904 0.000 0.136 0.000 0.864 0.000
#> SRR1539250 5 0.0510 0.919 0.000 0.000 0.016 0.000 0.984
#> SRR1539251 5 0.0510 0.919 0.000 0.000 0.016 0.000 0.984
#> SRR1539253 2 0.2230 0.863 0.000 0.884 0.000 0.116 0.000
#> SRR1539252 1 0.3003 0.919 0.812 0.000 0.000 0.000 0.188
#> SRR1539255 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539254 5 0.0000 0.926 0.000 0.000 0.000 0.000 1.000
#> SRR1539256 2 0.0000 0.908 0.000 1.000 0.000 0.000 0.000
#> SRR1539257 5 0.0000 0.926 0.000 0.000 0.000 0.000 1.000
#> SRR1539258 1 0.2929 0.927 0.820 0.000 0.000 0.000 0.180
#> SRR1539259 2 0.2471 0.833 0.000 0.864 0.000 0.136 0.000
#> SRR1539260 5 0.0162 0.923 0.000 0.000 0.004 0.000 0.996
#> SRR1539262 2 0.0162 0.907 0.000 0.996 0.004 0.000 0.000
#> SRR1539261 1 0.2554 0.669 0.892 0.000 0.072 0.036 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539208 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539211 6 0.000 1.000 0.000 0.000 0.000 0.000 0.000 1
#> SRR1539210 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539209 4 0.380 0.212 0.000 0.424 0.000 0.576 0.000 0
#> SRR1539212 2 0.000 0.944 0.000 1.000 0.000 0.000 0.000 0
#> SRR1539214 5 0.383 0.202 0.444 0.000 0.000 0.000 0.556 0
#> SRR1539213 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539215 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539216 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539217 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539218 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539220 5 0.346 0.522 0.312 0.000 0.000 0.000 0.688 0
#> SRR1539219 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539221 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539223 1 0.378 0.195 0.588 0.000 0.000 0.000 0.412 0
#> SRR1539224 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539222 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539225 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539227 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539226 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539228 3 0.000 0.923 0.000 0.000 1.000 0.000 0.000 0
#> SRR1539229 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539232 3 0.384 0.222 0.000 0.000 0.548 0.000 0.452 0
#> SRR1539230 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539231 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539234 2 0.270 0.774 0.000 0.812 0.000 0.188 0.000 0
#> SRR1539233 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539235 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539236 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539237 2 0.000 0.944 0.000 1.000 0.000 0.000 0.000 0
#> SRR1539238 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539239 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539242 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539240 2 0.000 0.944 0.000 1.000 0.000 0.000 0.000 0
#> SRR1539241 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539243 2 0.000 0.944 0.000 1.000 0.000 0.000 0.000 0
#> SRR1539244 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539245 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539246 2 0.026 0.941 0.000 0.992 0.000 0.008 0.000 0
#> SRR1539247 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539248 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539249 4 0.000 0.930 0.000 0.000 0.000 1.000 0.000 0
#> SRR1539250 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539251 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539253 2 0.282 0.755 0.000 0.796 0.000 0.204 0.000 0
#> SRR1539252 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539255 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539254 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539256 2 0.000 0.944 0.000 1.000 0.000 0.000 0.000 0
#> SRR1539257 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539258 1 0.000 0.959 1.000 0.000 0.000 0.000 0.000 0
#> SRR1539259 2 0.026 0.941 0.000 0.992 0.000 0.008 0.000 0
#> SRR1539260 5 0.000 0.903 0.000 0.000 0.000 0.000 1.000 0
#> SRR1539262 2 0.000 0.944 0.000 1.000 0.000 0.000 0.000 0
#> SRR1539261 6 0.000 1.000 0.000 0.000 0.000 0.000 0.000 1
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'MAD' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 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.997 0.998 0.4580 0.544 0.544
#> 3 3 0.935 0.926 0.967 0.4428 0.797 0.627
#> 4 4 0.920 0.878 0.939 0.0876 0.938 0.819
#> 5 5 0.824 0.837 0.863 0.0641 0.926 0.742
#> 6 6 0.962 0.932 0.957 0.0538 0.937 0.737
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
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
#> SRR1539207 1 0.000 0.997 1.000 0.000
#> SRR1539208 1 0.000 0.997 1.000 0.000
#> SRR1539211 1 0.000 0.997 1.000 0.000
#> SRR1539210 1 0.000 0.997 1.000 0.000
#> SRR1539209 2 0.000 1.000 0.000 1.000
#> SRR1539212 2 0.000 1.000 0.000 1.000
#> SRR1539214 1 0.000 0.997 1.000 0.000
#> SRR1539213 1 0.000 0.997 1.000 0.000
#> SRR1539215 2 0.000 1.000 0.000 1.000
#> SRR1539216 1 0.000 0.997 1.000 0.000
#> SRR1539217 1 0.000 0.997 1.000 0.000
#> SRR1539218 2 0.000 1.000 0.000 1.000
#> SRR1539220 1 0.000 0.997 1.000 0.000
#> SRR1539219 1 0.000 0.997 1.000 0.000
#> SRR1539221 2 0.000 1.000 0.000 1.000
#> SRR1539223 1 0.000 0.997 1.000 0.000
#> SRR1539224 2 0.000 1.000 0.000 1.000
#> SRR1539222 1 0.000 0.997 1.000 0.000
#> SRR1539225 1 0.000 0.997 1.000 0.000
#> SRR1539227 2 0.000 1.000 0.000 1.000
#> SRR1539226 1 0.000 0.997 1.000 0.000
#> SRR1539228 1 0.000 0.997 1.000 0.000
#> SRR1539229 1 0.000 0.997 1.000 0.000
#> SRR1539232 1 0.000 0.997 1.000 0.000
#> SRR1539230 2 0.000 1.000 0.000 1.000
#> SRR1539231 2 0.000 1.000 0.000 1.000
#> SRR1539234 2 0.000 1.000 0.000 1.000
#> SRR1539233 1 0.000 0.997 1.000 0.000
#> SRR1539235 1 0.000 0.997 1.000 0.000
#> SRR1539236 1 0.000 0.997 1.000 0.000
#> SRR1539237 2 0.000 1.000 0.000 1.000
#> SRR1539238 1 0.000 0.997 1.000 0.000
#> SRR1539239 1 0.000 0.997 1.000 0.000
#> SRR1539242 1 0.000 0.997 1.000 0.000
#> SRR1539240 2 0.000 1.000 0.000 1.000
#> SRR1539241 1 0.000 0.997 1.000 0.000
#> SRR1539243 2 0.000 1.000 0.000 1.000
#> SRR1539244 1 0.000 0.997 1.000 0.000
#> SRR1539245 1 0.000 0.997 1.000 0.000
#> SRR1539246 2 0.000 1.000 0.000 1.000
#> SRR1539247 1 0.000 0.997 1.000 0.000
#> SRR1539248 1 0.000 0.997 1.000 0.000
#> SRR1539249 2 0.000 1.000 0.000 1.000
#> SRR1539250 1 0.000 0.997 1.000 0.000
#> SRR1539251 1 0.000 0.997 1.000 0.000
#> SRR1539253 2 0.000 1.000 0.000 1.000
#> SRR1539252 1 0.000 0.997 1.000 0.000
#> SRR1539255 1 0.000 0.997 1.000 0.000
#> SRR1539254 1 0.000 0.997 1.000 0.000
#> SRR1539256 2 0.000 1.000 0.000 1.000
#> SRR1539257 1 0.000 0.997 1.000 0.000
#> SRR1539258 1 0.000 0.997 1.000 0.000
#> SRR1539259 2 0.000 1.000 0.000 1.000
#> SRR1539260 1 0.000 0.997 1.000 0.000
#> SRR1539262 2 0.000 1.000 0.000 1.000
#> SRR1539261 1 0.443 0.899 0.908 0.092
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.951 0.000 0 1.000
#> SRR1539208 1 0.1163 0.936 0.972 0 0.028
#> SRR1539211 1 0.1529 0.931 0.960 0 0.040
#> SRR1539210 3 0.0000 0.951 0.000 0 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000
#> SRR1539214 1 0.0747 0.940 0.984 0 0.016
#> SRR1539213 3 0.0000 0.951 0.000 0 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000
#> SRR1539216 3 0.0000 0.951 0.000 0 1.000
#> SRR1539217 1 0.1031 0.940 0.976 0 0.024
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000
#> SRR1539220 1 0.1289 0.936 0.968 0 0.032
#> SRR1539219 3 0.0000 0.951 0.000 0 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000
#> SRR1539223 1 0.1753 0.930 0.952 0 0.048
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000
#> SRR1539222 3 0.0000 0.951 0.000 0 1.000
#> SRR1539225 3 0.0000 0.951 0.000 0 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000
#> SRR1539226 1 0.0424 0.941 0.992 0 0.008
#> SRR1539228 3 0.0000 0.951 0.000 0 1.000
#> SRR1539229 1 0.0237 0.942 0.996 0 0.004
#> SRR1539232 3 0.0237 0.948 0.004 0 0.996
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000
#> SRR1539233 1 0.0000 0.941 1.000 0 0.000
#> SRR1539235 1 0.1289 0.935 0.968 0 0.032
#> SRR1539236 1 0.0000 0.941 1.000 0 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000
#> SRR1539238 1 0.3482 0.862 0.872 0 0.128
#> SRR1539239 1 0.0000 0.941 1.000 0 0.000
#> SRR1539242 1 0.0000 0.941 1.000 0 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000
#> SRR1539241 1 0.2261 0.915 0.932 0 0.068
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000
#> SRR1539244 1 0.5291 0.646 0.732 0 0.268
#> SRR1539245 1 0.0000 0.941 1.000 0 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000
#> SRR1539247 3 0.3116 0.845 0.108 0 0.892
#> SRR1539248 1 0.0000 0.941 1.000 0 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000
#> SRR1539250 3 0.0000 0.951 0.000 0 1.000
#> SRR1539251 3 0.0000 0.951 0.000 0 1.000
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000
#> SRR1539252 1 0.0237 0.942 0.996 0 0.004
#> SRR1539255 1 0.0000 0.941 1.000 0 0.000
#> SRR1539254 1 0.4002 0.829 0.840 0 0.160
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000
#> SRR1539257 1 0.6215 0.283 0.572 0 0.428
#> SRR1539258 1 0.0000 0.941 1.000 0 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000
#> SRR1539260 3 0.6215 0.161 0.428 0 0.572
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000
#> SRR1539261 1 0.1163 0.936 0.972 0 0.028
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.937 0.000 0.000 1.000 0.000
#> SRR1539208 1 0.0188 0.921 0.996 0.000 0.000 0.004
#> SRR1539211 1 0.0376 0.919 0.992 0.004 0.000 0.004
#> SRR1539210 3 0.0188 0.936 0.000 0.000 0.996 0.004
#> SRR1539209 2 0.1867 0.962 0.000 0.928 0.000 0.072
#> SRR1539212 2 0.1792 0.963 0.000 0.932 0.000 0.068
#> SRR1539214 1 0.3726 0.713 0.788 0.000 0.000 0.212
#> SRR1539213 3 0.0188 0.937 0.000 0.000 0.996 0.004
#> SRR1539215 2 0.2281 0.948 0.000 0.904 0.000 0.096
#> SRR1539216 3 0.0000 0.937 0.000 0.000 1.000 0.000
#> SRR1539217 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1539218 2 0.1792 0.963 0.000 0.932 0.000 0.068
#> SRR1539220 1 0.2216 0.865 0.908 0.000 0.000 0.092
#> SRR1539219 3 0.0000 0.937 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.1867 0.962 0.000 0.928 0.000 0.072
#> SRR1539223 1 0.0376 0.921 0.992 0.000 0.004 0.004
#> SRR1539224 2 0.1792 0.963 0.000 0.932 0.000 0.068
#> SRR1539222 3 0.0000 0.937 0.000 0.000 1.000 0.000
#> SRR1539225 3 0.0188 0.937 0.000 0.000 0.996 0.004
#> SRR1539227 2 0.1867 0.962 0.000 0.928 0.000 0.072
#> SRR1539226 1 0.0707 0.918 0.980 0.000 0.000 0.020
#> SRR1539228 3 0.0188 0.937 0.000 0.000 0.996 0.004
#> SRR1539229 1 0.1211 0.908 0.960 0.000 0.000 0.040
#> SRR1539232 3 0.2081 0.859 0.000 0.000 0.916 0.084
#> SRR1539230 2 0.1867 0.962 0.000 0.928 0.000 0.072
#> SRR1539231 2 0.1867 0.962 0.000 0.928 0.000 0.072
#> SRR1539234 2 0.0188 0.968 0.000 0.996 0.000 0.004
#> SRR1539233 1 0.1022 0.913 0.968 0.000 0.000 0.032
#> SRR1539235 4 0.3450 0.801 0.156 0.000 0.008 0.836
#> SRR1539236 1 0.0469 0.921 0.988 0.000 0.000 0.012
#> SRR1539237 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539238 4 0.5322 0.572 0.312 0.000 0.028 0.660
#> SRR1539239 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539241 1 0.5296 -0.142 0.496 0.000 0.008 0.496
#> SRR1539243 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539244 4 0.2048 0.807 0.064 0.000 0.008 0.928
#> SRR1539245 1 0.2589 0.841 0.884 0.000 0.000 0.116
#> SRR1539246 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539247 4 0.4434 0.651 0.016 0.000 0.228 0.756
#> SRR1539248 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539250 3 0.0336 0.935 0.000 0.000 0.992 0.008
#> SRR1539251 3 0.0336 0.935 0.000 0.000 0.992 0.008
#> SRR1539253 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.0336 0.922 0.992 0.000 0.000 0.008
#> SRR1539255 1 0.0336 0.922 0.992 0.000 0.000 0.008
#> SRR1539254 1 0.4786 0.714 0.788 0.000 0.108 0.104
#> SRR1539256 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539257 4 0.3828 0.806 0.068 0.000 0.084 0.848
#> SRR1539258 1 0.0000 0.922 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539260 3 0.6752 0.198 0.280 0.000 0.588 0.132
#> SRR1539262 2 0.0000 0.968 0.000 1.000 0.000 0.000
#> SRR1539261 1 0.0188 0.921 0.996 0.000 0.000 0.004
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539208 1 0.2561 0.858 0.884 0.000 0.000 0.020 0.096
#> SRR1539211 1 0.2012 0.889 0.920 0.000 0.000 0.020 0.060
#> SRR1539210 3 0.0963 0.840 0.000 0.000 0.964 0.000 0.036
#> SRR1539209 4 0.4196 0.989 0.000 0.356 0.000 0.640 0.004
#> SRR1539212 4 0.4624 0.961 0.000 0.340 0.000 0.636 0.024
#> SRR1539214 1 0.4114 0.723 0.772 0.000 0.004 0.040 0.184
#> SRR1539213 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539215 4 0.4045 0.990 0.000 0.356 0.000 0.644 0.000
#> SRR1539216 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 1 0.0451 0.907 0.988 0.000 0.004 0.008 0.000
#> SRR1539218 4 0.4060 0.991 0.000 0.360 0.000 0.640 0.000
#> SRR1539220 1 0.2026 0.891 0.924 0.000 0.012 0.008 0.056
#> SRR1539219 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 4 0.4060 0.991 0.000 0.360 0.000 0.640 0.000
#> SRR1539223 1 0.1943 0.892 0.924 0.000 0.000 0.020 0.056
#> SRR1539224 4 0.4074 0.987 0.000 0.364 0.000 0.636 0.000
#> SRR1539222 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539225 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539227 4 0.4060 0.991 0.000 0.360 0.000 0.640 0.000
#> SRR1539226 1 0.1124 0.893 0.960 0.000 0.000 0.004 0.036
#> SRR1539228 3 0.0000 0.857 0.000 0.000 1.000 0.000 0.000
#> SRR1539229 1 0.1725 0.887 0.936 0.000 0.000 0.020 0.044
#> SRR1539232 3 0.2139 0.808 0.000 0.000 0.916 0.052 0.032
#> SRR1539230 4 0.4045 0.990 0.000 0.356 0.000 0.644 0.000
#> SRR1539231 4 0.4045 0.990 0.000 0.356 0.000 0.644 0.000
#> SRR1539234 2 0.1043 0.945 0.000 0.960 0.000 0.040 0.000
#> SRR1539233 1 0.1082 0.907 0.964 0.000 0.000 0.008 0.028
#> SRR1539235 5 0.2361 0.795 0.096 0.000 0.012 0.000 0.892
#> SRR1539236 1 0.0771 0.909 0.976 0.000 0.000 0.004 0.020
#> SRR1539237 2 0.0693 0.954 0.000 0.980 0.000 0.012 0.008
#> SRR1539238 5 0.5572 0.741 0.176 0.016 0.080 0.020 0.708
#> SRR1539239 1 0.0510 0.909 0.984 0.000 0.000 0.016 0.000
#> SRR1539242 1 0.0510 0.909 0.984 0.000 0.000 0.016 0.000
#> SRR1539240 2 0.0703 0.937 0.000 0.976 0.000 0.000 0.024
#> SRR1539241 5 0.5313 0.587 0.300 0.004 0.032 0.020 0.644
#> SRR1539243 2 0.0865 0.934 0.000 0.972 0.000 0.004 0.024
#> SRR1539244 5 0.1949 0.743 0.012 0.000 0.016 0.040 0.932
#> SRR1539245 1 0.3039 0.791 0.836 0.000 0.000 0.012 0.152
#> SRR1539246 2 0.0290 0.954 0.000 0.992 0.000 0.008 0.000
#> SRR1539247 5 0.4248 0.673 0.028 0.000 0.200 0.012 0.760
#> SRR1539248 1 0.0992 0.907 0.968 0.000 0.000 0.008 0.024
#> SRR1539249 2 0.0963 0.949 0.000 0.964 0.000 0.036 0.000
#> SRR1539250 3 0.4880 0.533 0.036 0.000 0.696 0.016 0.252
#> SRR1539251 3 0.4880 0.533 0.036 0.000 0.696 0.016 0.252
#> SRR1539253 2 0.0963 0.949 0.000 0.964 0.000 0.036 0.000
#> SRR1539252 1 0.0404 0.910 0.988 0.000 0.000 0.000 0.012
#> SRR1539255 1 0.0324 0.909 0.992 0.000 0.000 0.004 0.004
#> SRR1539254 1 0.6728 -0.129 0.484 0.000 0.152 0.020 0.344
#> SRR1539256 2 0.1168 0.919 0.000 0.960 0.000 0.008 0.032
#> SRR1539257 5 0.3130 0.775 0.040 0.000 0.072 0.016 0.872
#> SRR1539258 1 0.0404 0.907 0.988 0.000 0.000 0.012 0.000
#> SRR1539259 2 0.0510 0.955 0.000 0.984 0.000 0.016 0.000
#> SRR1539260 3 0.7081 -0.254 0.232 0.000 0.396 0.016 0.356
#> SRR1539262 2 0.1121 0.940 0.000 0.956 0.000 0.044 0.000
#> SRR1539261 1 0.1725 0.895 0.936 0.000 0.000 0.020 0.044
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0146 0.9801 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1539208 5 0.4739 0.0913 0.436 0.000 0.000 0.000 0.516 NA
#> SRR1539211 1 0.3293 0.8140 0.812 0.000 0.000 0.000 0.140 NA
#> SRR1539210 3 0.1528 0.9358 0.000 0.000 0.936 0.000 0.048 NA
#> SRR1539209 4 0.0260 0.9898 0.000 0.008 0.000 0.992 0.000 NA
#> SRR1539212 4 0.0622 0.9849 0.000 0.012 0.000 0.980 0.008 NA
#> SRR1539214 1 0.2605 0.8820 0.864 0.000 0.028 0.000 0.000 NA
#> SRR1539213 3 0.0146 0.9808 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1539215 4 0.0146 0.9877 0.000 0.004 0.000 0.996 0.000 NA
#> SRR1539216 3 0.0000 0.9810 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1539217 1 0.0000 0.9536 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1539218 4 0.0547 0.9929 0.000 0.020 0.000 0.980 0.000 NA
#> SRR1539220 1 0.1865 0.9197 0.920 0.000 0.040 0.000 0.000 NA
#> SRR1539219 3 0.0000 0.9810 0.000 0.000 1.000 0.000 0.000 NA
#> SRR1539221 4 0.0547 0.9929 0.000 0.020 0.000 0.980 0.000 NA
#> SRR1539223 1 0.2250 0.9037 0.896 0.000 0.000 0.000 0.064 NA
#> SRR1539224 4 0.0458 0.9931 0.000 0.016 0.000 0.984 0.000 NA
#> SRR1539222 3 0.0603 0.9724 0.000 0.000 0.980 0.000 0.004 NA
#> SRR1539225 3 0.0146 0.9808 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1539227 4 0.0547 0.9929 0.000 0.020 0.000 0.980 0.000 NA
#> SRR1539226 1 0.0603 0.9484 0.980 0.000 0.016 0.000 0.000 NA
#> SRR1539228 3 0.0146 0.9808 0.000 0.000 0.996 0.000 0.000 NA
#> SRR1539229 1 0.0146 0.9535 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1539232 3 0.1501 0.9415 0.000 0.000 0.924 0.000 0.000 NA
#> SRR1539230 4 0.0458 0.9931 0.000 0.016 0.000 0.984 0.000 NA
#> SRR1539231 4 0.0458 0.9931 0.000 0.016 0.000 0.984 0.000 NA
#> SRR1539234 2 0.0363 0.9924 0.000 0.988 0.000 0.012 0.000 NA
#> SRR1539233 1 0.0146 0.9536 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1539235 5 0.1267 0.8821 0.000 0.000 0.000 0.000 0.940 NA
#> SRR1539236 1 0.0000 0.9536 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1539237 2 0.0146 0.9961 0.000 0.996 0.000 0.004 0.000 NA
#> SRR1539238 5 0.0260 0.8899 0.000 0.000 0.000 0.000 0.992 NA
#> SRR1539239 1 0.0520 0.9512 0.984 0.000 0.000 0.000 0.008 NA
#> SRR1539242 1 0.0717 0.9488 0.976 0.000 0.000 0.000 0.016 NA
#> SRR1539240 2 0.0000 0.9951 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1539241 5 0.0000 0.8899 0.000 0.000 0.000 0.000 1.000 NA
#> SRR1539243 2 0.0000 0.9951 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1539244 5 0.3050 0.7969 0.000 0.000 0.000 0.000 0.764 NA
#> SRR1539245 1 0.1387 0.9291 0.932 0.000 0.000 0.000 0.000 NA
#> SRR1539246 2 0.0146 0.9961 0.000 0.996 0.000 0.004 0.000 NA
#> SRR1539247 5 0.1701 0.8778 0.000 0.000 0.008 0.000 0.920 NA
#> SRR1539248 1 0.1225 0.9380 0.952 0.000 0.000 0.000 0.036 NA
#> SRR1539249 2 0.0260 0.9945 0.000 0.992 0.000 0.008 0.000 NA
#> SRR1539250 5 0.2136 0.8643 0.000 0.000 0.048 0.000 0.904 NA
#> SRR1539251 5 0.2136 0.8643 0.000 0.000 0.048 0.000 0.904 NA
#> SRR1539253 2 0.0146 0.9961 0.000 0.996 0.000 0.004 0.000 NA
#> SRR1539252 1 0.0146 0.9535 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1539255 1 0.0146 0.9535 0.996 0.000 0.000 0.000 0.000 NA
#> SRR1539254 5 0.0858 0.8861 0.000 0.000 0.004 0.000 0.968 NA
#> SRR1539256 2 0.0000 0.9951 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1539257 5 0.1958 0.8723 0.004 0.000 0.000 0.000 0.896 NA
#> SRR1539258 1 0.0000 0.9536 1.000 0.000 0.000 0.000 0.000 NA
#> SRR1539259 2 0.0260 0.9949 0.000 0.992 0.000 0.008 0.000 NA
#> SRR1539260 5 0.0458 0.8890 0.000 0.000 0.000 0.000 0.984 NA
#> SRR1539262 2 0.0260 0.9930 0.000 0.992 0.000 0.008 0.000 NA
#> SRR1539261 1 0.2527 0.8960 0.884 0.004 0.000 0.000 0.064 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", "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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'hclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 1.000 0.996 0.998 0.3600 0.836 0.699
#> 4 4 0.908 0.954 0.971 0.1461 0.914 0.774
#> 5 5 0.893 0.921 0.960 0.0111 0.995 0.982
#> 6 6 0.936 0.912 0.946 0.0793 0.932 0.764
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 1.000 0.000 0 1.000
#> SRR1539208 1 0.0000 0.996 1.000 0 0.000
#> SRR1539211 1 0.0000 0.996 1.000 0 0.000
#> SRR1539210 3 0.0000 1.000 0.000 0 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000
#> SRR1539214 1 0.0000 0.996 1.000 0 0.000
#> SRR1539213 3 0.0000 1.000 0.000 0 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000
#> SRR1539216 3 0.0000 1.000 0.000 0 1.000
#> SRR1539217 1 0.0000 0.996 1.000 0 0.000
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000
#> SRR1539220 1 0.0747 0.985 0.984 0 0.016
#> SRR1539219 3 0.0000 1.000 0.000 0 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000
#> SRR1539223 1 0.0000 0.996 1.000 0 0.000
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000
#> SRR1539222 3 0.0000 1.000 0.000 0 1.000
#> SRR1539225 3 0.0000 1.000 0.000 0 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000
#> SRR1539226 1 0.0000 0.996 1.000 0 0.000
#> SRR1539228 3 0.0000 1.000 0.000 0 1.000
#> SRR1539229 1 0.0000 0.996 1.000 0 0.000
#> SRR1539232 3 0.0000 1.000 0.000 0 1.000
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000
#> SRR1539233 1 0.0000 0.996 1.000 0 0.000
#> SRR1539235 1 0.0000 0.996 1.000 0 0.000
#> SRR1539236 1 0.0000 0.996 1.000 0 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000
#> SRR1539238 1 0.0000 0.996 1.000 0 0.000
#> SRR1539239 1 0.0000 0.996 1.000 0 0.000
#> SRR1539242 1 0.0000 0.996 1.000 0 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000
#> SRR1539241 1 0.0000 0.996 1.000 0 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000
#> SRR1539244 1 0.0000 0.996 1.000 0 0.000
#> SRR1539245 1 0.0000 0.996 1.000 0 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000
#> SRR1539247 1 0.0747 0.985 0.984 0 0.016
#> SRR1539248 1 0.0000 0.996 1.000 0 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000
#> SRR1539250 1 0.1289 0.971 0.968 0 0.032
#> SRR1539251 1 0.1289 0.971 0.968 0 0.032
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000
#> SRR1539252 1 0.0000 0.996 1.000 0 0.000
#> SRR1539255 1 0.0000 0.996 1.000 0 0.000
#> SRR1539254 1 0.0237 0.993 0.996 0 0.004
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000
#> SRR1539257 1 0.0747 0.985 0.984 0 0.016
#> SRR1539258 1 0.0000 0.996 1.000 0 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000
#> SRR1539260 1 0.0000 0.996 1.000 0 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000
#> SRR1539261 1 0.0000 0.996 1.000 0 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539208 1 0.2081 0.881 0.916 0 0.000 0.084
#> SRR1539211 4 0.0000 0.936 0.000 0 0.000 1.000
#> SRR1539210 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539214 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539213 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539216 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539217 1 0.2081 0.881 0.916 0 0.000 0.084
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539220 1 0.0592 0.922 0.984 0 0.016 0.000
#> SRR1539219 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539223 1 0.2081 0.881 0.916 0 0.000 0.084
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539222 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539226 1 0.3219 0.838 0.836 0 0.000 0.164
#> SRR1539228 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539229 1 0.3219 0.838 0.836 0 0.000 0.164
#> SRR1539232 3 0.0000 1.000 0.000 0 1.000 0.000
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539233 1 0.3266 0.835 0.832 0 0.000 0.168
#> SRR1539235 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539236 1 0.3219 0.838 0.836 0 0.000 0.164
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539238 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539239 4 0.1637 0.968 0.060 0 0.000 0.940
#> SRR1539242 4 0.1637 0.968 0.060 0 0.000 0.940
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539241 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539244 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539245 1 0.3219 0.838 0.836 0 0.000 0.164
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539247 1 0.0592 0.922 0.984 0 0.016 0.000
#> SRR1539248 4 0.1637 0.968 0.060 0 0.000 0.940
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539250 1 0.1022 0.913 0.968 0 0.032 0.000
#> SRR1539251 1 0.1022 0.913 0.968 0 0.032 0.000
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539252 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539255 1 0.3219 0.838 0.836 0 0.000 0.164
#> SRR1539254 1 0.0188 0.925 0.996 0 0.004 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539257 1 0.0592 0.922 0.984 0 0.016 0.000
#> SRR1539258 4 0.1716 0.964 0.064 0 0.000 0.936
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539260 1 0.0000 0.926 1.000 0 0.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539261 4 0.0000 0.936 0.000 0 0.000 1.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539208 5 0.1851 0.877 0.088 0 0.000 0.000 0.912
#> SRR1539211 1 0.2891 0.732 0.824 0 0.000 0.176 0.000
#> SRR1539210 4 0.2891 0.000 0.000 0 0.176 0.824 0.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539214 5 0.0000 0.923 0.000 0 0.000 0.000 1.000
#> SRR1539213 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539216 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539217 5 0.1851 0.877 0.088 0 0.000 0.000 0.912
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539220 5 0.0566 0.919 0.000 0 0.012 0.004 0.984
#> SRR1539219 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539223 5 0.1851 0.877 0.088 0 0.000 0.000 0.912
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539222 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539226 5 0.2891 0.836 0.176 0 0.000 0.000 0.824
#> SRR1539228 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539229 5 0.2891 0.836 0.176 0 0.000 0.000 0.824
#> SRR1539232 3 0.0000 1.000 0.000 0 1.000 0.000 0.000
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539233 5 0.2929 0.833 0.180 0 0.000 0.000 0.820
#> SRR1539235 5 0.0000 0.923 0.000 0 0.000 0.000 1.000
#> SRR1539236 5 0.2891 0.836 0.176 0 0.000 0.000 0.824
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539238 5 0.0000 0.923 0.000 0 0.000 0.000 1.000
#> SRR1539239 1 0.1197 0.877 0.952 0 0.000 0.000 0.048
#> SRR1539242 1 0.1197 0.877 0.952 0 0.000 0.000 0.048
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539241 5 0.0000 0.923 0.000 0 0.000 0.000 1.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539244 5 0.0162 0.922 0.004 0 0.000 0.000 0.996
#> SRR1539245 5 0.2891 0.836 0.176 0 0.000 0.000 0.824
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539247 5 0.0566 0.919 0.000 0 0.012 0.004 0.984
#> SRR1539248 1 0.1197 0.877 0.952 0 0.000 0.000 0.048
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539250 5 0.0992 0.910 0.000 0 0.024 0.008 0.968
#> SRR1539251 5 0.0992 0.910 0.000 0 0.024 0.008 0.968
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539252 5 0.0000 0.923 0.000 0 0.000 0.000 1.000
#> SRR1539255 5 0.2891 0.836 0.176 0 0.000 0.000 0.824
#> SRR1539254 5 0.0162 0.922 0.000 0 0.000 0.004 0.996
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539257 5 0.0566 0.919 0.000 0 0.012 0.004 0.984
#> SRR1539258 1 0.1270 0.872 0.948 0 0.000 0.000 0.052
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539260 5 0.0000 0.923 0.000 0 0.000 0.000 1.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0.000 0.000
#> SRR1539261 1 0.2891 0.732 0.824 0 0.000 0.176 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 5 0.2309 0.889 0.084 0.000 0.000 0.028 0.888 0.000
#> SRR1539211 1 0.0000 0.733 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539210 6 0.0000 0.000 0.000 0.000 0.000 0.000 0.000 1.000
#> SRR1539209 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539212 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539214 5 0.2823 0.764 0.000 0.000 0.000 0.204 0.796 0.000
#> SRR1539213 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539215 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539216 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 5 0.2309 0.889 0.084 0.000 0.000 0.028 0.888 0.000
#> SRR1539218 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539220 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539219 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539223 5 0.2309 0.889 0.084 0.000 0.000 0.028 0.888 0.000
#> SRR1539224 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539222 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539227 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539226 4 0.1327 0.936 0.000 0.000 0.000 0.936 0.064 0.000
#> SRR1539228 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539229 4 0.1327 0.936 0.000 0.000 0.000 0.936 0.064 0.000
#> SRR1539232 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539230 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539231 2 0.1327 0.964 0.000 0.936 0.000 0.064 0.000 0.000
#> SRR1539234 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539233 4 0.1471 0.931 0.004 0.000 0.000 0.932 0.064 0.000
#> SRR1539235 5 0.0458 0.937 0.000 0.000 0.000 0.016 0.984 0.000
#> SRR1539236 4 0.1327 0.936 0.000 0.000 0.000 0.936 0.064 0.000
#> SRR1539237 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.0458 0.937 0.000 0.000 0.000 0.016 0.984 0.000
#> SRR1539239 1 0.2969 0.877 0.776 0.000 0.000 0.224 0.000 0.000
#> SRR1539242 1 0.2969 0.877 0.776 0.000 0.000 0.224 0.000 0.000
#> SRR1539240 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.0458 0.937 0.000 0.000 0.000 0.016 0.984 0.000
#> SRR1539243 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 4 0.3288 0.600 0.000 0.000 0.000 0.724 0.276 0.000
#> SRR1539245 4 0.1327 0.936 0.000 0.000 0.000 0.936 0.064 0.000
#> SRR1539246 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539248 1 0.2969 0.877 0.776 0.000 0.000 0.224 0.000 0.000
#> SRR1539249 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 5 0.0508 0.927 0.000 0.000 0.012 0.000 0.984 0.004
#> SRR1539251 5 0.0508 0.927 0.000 0.000 0.012 0.000 0.984 0.004
#> SRR1539253 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 5 0.2823 0.764 0.000 0.000 0.000 0.204 0.796 0.000
#> SRR1539255 4 0.1327 0.936 0.000 0.000 0.000 0.936 0.064 0.000
#> SRR1539254 5 0.0363 0.936 0.000 0.000 0.000 0.012 0.988 0.000
#> SRR1539256 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.0000 0.934 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539258 1 0.2996 0.873 0.772 0.000 0.000 0.228 0.000 0.000
#> SRR1539259 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.0458 0.937 0.000 0.000 0.000 0.016 0.984 0.000
#> SRR1539262 2 0.0000 0.968 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 1 0.0000 0.733 1.000 0.000 0.000 0.000 0.000 0.000
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'kmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.749 0.957 0.906 0.3313 0.814 0.658
#> 4 4 0.755 0.721 0.765 0.1597 0.877 0.668
#> 5 5 0.716 0.586 0.657 0.0841 0.832 0.479
#> 6 6 0.714 0.752 0.763 0.0400 0.874 0.535
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539208 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539211 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539210 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539209 2 0.4750 0.892 0.000 0.784 0.216
#> SRR1539212 2 0.4750 0.892 0.000 0.784 0.216
#> SRR1539214 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539213 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539215 2 0.4750 0.892 0.000 0.784 0.216
#> SRR1539216 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539217 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539218 2 0.5178 0.891 0.000 0.744 0.256
#> SRR1539220 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539219 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539221 2 0.5138 0.892 0.000 0.748 0.252
#> SRR1539223 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539224 2 0.5178 0.891 0.000 0.744 0.256
#> SRR1539222 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539225 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539227 2 0.5178 0.891 0.000 0.744 0.256
#> SRR1539226 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539228 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539229 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539232 3 0.5178 0.980 0.256 0.000 0.744
#> SRR1539230 2 0.5138 0.892 0.000 0.748 0.252
#> SRR1539231 2 0.5138 0.892 0.000 0.748 0.252
#> SRR1539234 2 0.0000 0.900 0.000 1.000 0.000
#> SRR1539233 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539235 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539236 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539237 2 0.0000 0.900 0.000 1.000 0.000
#> SRR1539238 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539239 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539242 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539240 2 0.0000 0.900 0.000 1.000 0.000
#> SRR1539241 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539243 2 0.0000 0.900 0.000 1.000 0.000
#> SRR1539244 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539245 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539246 2 0.1529 0.900 0.000 0.960 0.040
#> SRR1539247 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539248 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539249 2 0.1031 0.900 0.000 0.976 0.024
#> SRR1539250 3 0.5760 0.903 0.328 0.000 0.672
#> SRR1539251 3 0.5760 0.903 0.328 0.000 0.672
#> SRR1539253 2 0.0237 0.899 0.000 0.996 0.004
#> SRR1539252 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539255 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539254 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539256 2 0.0000 0.900 0.000 1.000 0.000
#> SRR1539257 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539258 1 0.0000 0.998 1.000 0.000 0.000
#> SRR1539259 2 0.1860 0.902 0.000 0.948 0.052
#> SRR1539260 1 0.0237 0.996 0.996 0.000 0.004
#> SRR1539262 2 0.1860 0.902 0.000 0.948 0.052
#> SRR1539261 1 0.0000 0.998 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.2053 0.9870 0.072 0.000 0.924 0.004
#> SRR1539208 1 0.0469 0.7276 0.988 0.000 0.000 0.012
#> SRR1539211 1 0.0592 0.7233 0.984 0.000 0.000 0.016
#> SRR1539210 3 0.4093 0.9312 0.072 0.000 0.832 0.096
#> SRR1539209 2 0.5167 0.8206 0.000 0.644 0.016 0.340
#> SRR1539212 2 0.5233 0.8211 0.000 0.648 0.020 0.332
#> SRR1539214 1 0.4981 -0.5209 0.536 0.000 0.000 0.464
#> SRR1539213 3 0.1867 0.9877 0.072 0.000 0.928 0.000
#> SRR1539215 2 0.4855 0.8207 0.000 0.644 0.004 0.352
#> SRR1539216 3 0.2053 0.9870 0.072 0.000 0.924 0.004
#> SRR1539217 1 0.2281 0.7295 0.904 0.000 0.000 0.096
#> SRR1539218 2 0.4776 0.8215 0.000 0.624 0.000 0.376
#> SRR1539220 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539219 3 0.1867 0.9877 0.072 0.000 0.928 0.000
#> SRR1539221 2 0.4776 0.8215 0.000 0.624 0.000 0.376
#> SRR1539223 1 0.4855 -0.2979 0.600 0.000 0.000 0.400
#> SRR1539224 2 0.5055 0.8218 0.000 0.624 0.008 0.368
#> SRR1539222 3 0.2871 0.9740 0.072 0.000 0.896 0.032
#> SRR1539225 3 0.1867 0.9877 0.072 0.000 0.928 0.000
#> SRR1539227 2 0.4776 0.8215 0.000 0.624 0.000 0.376
#> SRR1539226 1 0.3219 0.7113 0.836 0.000 0.000 0.164
#> SRR1539228 3 0.1867 0.9877 0.072 0.000 0.928 0.000
#> SRR1539229 1 0.3219 0.7113 0.836 0.000 0.000 0.164
#> SRR1539232 3 0.1867 0.9877 0.072 0.000 0.928 0.000
#> SRR1539230 2 0.4776 0.8215 0.000 0.624 0.000 0.376
#> SRR1539231 2 0.4776 0.8215 0.000 0.624 0.000 0.376
#> SRR1539234 2 0.0188 0.8289 0.000 0.996 0.004 0.000
#> SRR1539233 1 0.3219 0.7113 0.836 0.000 0.000 0.164
#> SRR1539235 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539236 1 0.3219 0.7113 0.836 0.000 0.000 0.164
#> SRR1539237 2 0.0188 0.8289 0.000 0.996 0.004 0.000
#> SRR1539238 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539239 1 0.0000 0.7343 1.000 0.000 0.000 0.000
#> SRR1539242 1 0.0000 0.7343 1.000 0.000 0.000 0.000
#> SRR1539240 2 0.0000 0.8288 0.000 1.000 0.000 0.000
#> SRR1539241 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539243 2 0.0000 0.8288 0.000 1.000 0.000 0.000
#> SRR1539244 4 0.4989 0.6988 0.472 0.000 0.000 0.528
#> SRR1539245 1 0.3219 0.7113 0.836 0.000 0.000 0.164
#> SRR1539246 2 0.2174 0.8275 0.000 0.928 0.052 0.020
#> SRR1539247 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539248 1 0.0000 0.7343 1.000 0.000 0.000 0.000
#> SRR1539249 2 0.2174 0.8275 0.000 0.928 0.052 0.020
#> SRR1539250 4 0.6980 -0.0243 0.116 0.000 0.400 0.484
#> SRR1539251 4 0.6980 -0.0243 0.116 0.000 0.400 0.484
#> SRR1539253 2 0.0000 0.8288 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.4605 0.1643 0.664 0.000 0.000 0.336
#> SRR1539255 1 0.3219 0.7113 0.836 0.000 0.000 0.164
#> SRR1539254 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539256 2 0.0188 0.8289 0.000 0.996 0.004 0.000
#> SRR1539257 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539258 1 0.0000 0.7343 1.000 0.000 0.000 0.000
#> SRR1539259 2 0.2670 0.8307 0.000 0.908 0.052 0.040
#> SRR1539260 4 0.5281 0.7225 0.464 0.000 0.008 0.528
#> SRR1539262 2 0.2670 0.8307 0.000 0.908 0.052 0.040
#> SRR1539261 1 0.0469 0.7276 0.988 0.000 0.000 0.012
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.1405 0.9675 0.008 0.016 0.956 0.000 0.020
#> SRR1539208 1 0.4678 0.8298 0.712 0.064 0.000 0.000 0.224
#> SRR1539211 1 0.4850 0.8195 0.700 0.076 0.000 0.000 0.224
#> SRR1539210 3 0.4440 0.8429 0.028 0.200 0.752 0.000 0.020
#> SRR1539209 4 0.3558 0.6817 0.108 0.036 0.016 0.840 0.000
#> SRR1539212 4 0.3558 0.6817 0.108 0.036 0.016 0.840 0.000
#> SRR1539214 5 0.4036 0.4676 0.068 0.144 0.000 0.000 0.788
#> SRR1539213 3 0.0609 0.9697 0.000 0.000 0.980 0.000 0.020
#> SRR1539215 4 0.1996 0.7275 0.032 0.036 0.004 0.928 0.000
#> SRR1539216 3 0.1405 0.9675 0.008 0.016 0.956 0.000 0.020
#> SRR1539217 1 0.6132 0.4817 0.508 0.140 0.000 0.000 0.352
#> SRR1539218 4 0.0162 0.7638 0.004 0.000 0.000 0.996 0.000
#> SRR1539220 5 0.0451 0.5972 0.000 0.004 0.008 0.000 0.988
#> SRR1539219 3 0.1059 0.9690 0.008 0.004 0.968 0.000 0.020
#> SRR1539221 4 0.0000 0.7649 0.000 0.000 0.000 1.000 0.000
#> SRR1539223 5 0.4787 0.3055 0.208 0.080 0.000 0.000 0.712
#> SRR1539224 4 0.0963 0.7550 0.036 0.000 0.000 0.964 0.000
#> SRR1539222 3 0.2541 0.9442 0.012 0.068 0.900 0.000 0.020
#> SRR1539225 3 0.0609 0.9697 0.000 0.000 0.980 0.000 0.020
#> SRR1539227 4 0.0162 0.7638 0.004 0.000 0.000 0.996 0.000
#> SRR1539226 5 0.6362 -0.1411 0.368 0.168 0.000 0.000 0.464
#> SRR1539228 3 0.0609 0.9697 0.000 0.000 0.980 0.000 0.020
#> SRR1539229 5 0.6362 -0.1411 0.368 0.168 0.000 0.000 0.464
#> SRR1539232 3 0.0609 0.9697 0.000 0.000 0.980 0.000 0.020
#> SRR1539230 4 0.0000 0.7649 0.000 0.000 0.000 1.000 0.000
#> SRR1539231 4 0.0000 0.7649 0.000 0.000 0.000 1.000 0.000
#> SRR1539234 2 0.4470 0.9330 0.004 0.596 0.004 0.396 0.000
#> SRR1539233 5 0.6362 -0.1411 0.368 0.168 0.000 0.000 0.464
#> SRR1539235 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539236 5 0.6362 -0.1411 0.368 0.168 0.000 0.000 0.464
#> SRR1539237 2 0.4321 0.9339 0.004 0.600 0.000 0.396 0.000
#> SRR1539238 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539239 1 0.3424 0.8547 0.760 0.000 0.000 0.000 0.240
#> SRR1539242 1 0.3424 0.8547 0.760 0.000 0.000 0.000 0.240
#> SRR1539240 2 0.4171 0.9352 0.000 0.604 0.000 0.396 0.000
#> SRR1539241 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539243 2 0.4171 0.9352 0.000 0.604 0.000 0.396 0.000
#> SRR1539244 5 0.1544 0.5676 0.000 0.068 0.000 0.000 0.932
#> SRR1539245 5 0.6362 -0.1411 0.368 0.168 0.000 0.000 0.464
#> SRR1539246 2 0.5854 0.7889 0.096 0.468 0.000 0.436 0.000
#> SRR1539247 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539248 1 0.3424 0.8547 0.760 0.000 0.000 0.000 0.240
#> SRR1539249 2 0.5810 0.8071 0.092 0.480 0.000 0.428 0.000
#> SRR1539250 5 0.5654 0.0803 0.012 0.064 0.340 0.000 0.584
#> SRR1539251 5 0.5654 0.0803 0.012 0.064 0.340 0.000 0.584
#> SRR1539253 2 0.4171 0.9352 0.000 0.604 0.000 0.396 0.000
#> SRR1539252 5 0.5856 0.1936 0.224 0.172 0.000 0.000 0.604
#> SRR1539255 5 0.6362 -0.1411 0.368 0.168 0.000 0.000 0.464
#> SRR1539254 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539256 2 0.4470 0.9330 0.004 0.596 0.004 0.396 0.000
#> SRR1539257 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539258 1 0.5821 0.7032 0.604 0.156 0.000 0.000 0.240
#> SRR1539259 4 0.5844 -0.7353 0.096 0.420 0.000 0.484 0.000
#> SRR1539260 5 0.0404 0.5993 0.000 0.000 0.012 0.000 0.988
#> SRR1539262 4 0.5844 -0.7353 0.096 0.420 0.000 0.484 0.000
#> SRR1539261 1 0.4617 0.8332 0.716 0.060 0.000 0.000 0.224
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.1837 0.935 0.020 0.000 0.928 0.004 0.004 NA
#> SRR1539208 1 0.4469 0.517 0.504 0.000 0.000 0.028 0.000 NA
#> SRR1539211 1 0.4591 0.510 0.500 0.000 0.000 0.036 0.000 NA
#> SRR1539210 3 0.6186 0.683 0.020 0.000 0.568 0.236 0.020 NA
#> SRR1539209 4 0.7034 0.700 0.000 0.348 0.000 0.396 0.124 NA
#> SRR1539212 4 0.7058 0.695 0.000 0.348 0.000 0.392 0.124 NA
#> SRR1539214 1 0.4929 0.028 0.556 0.000 0.000 0.028 0.392 NA
#> SRR1539213 3 0.0692 0.938 0.020 0.000 0.976 0.000 0.004 NA
#> SRR1539215 4 0.5219 0.819 0.000 0.348 0.004 0.580 0.036 NA
#> SRR1539216 3 0.1837 0.935 0.020 0.000 0.928 0.004 0.004 NA
#> SRR1539217 1 0.2941 0.690 0.868 0.000 0.000 0.024 0.060 NA
#> SRR1539218 4 0.3885 0.872 0.000 0.300 0.004 0.684 0.000 NA
#> SRR1539220 5 0.3465 0.842 0.156 0.000 0.000 0.016 0.804 NA
#> SRR1539219 3 0.1624 0.936 0.020 0.000 0.936 0.000 0.004 NA
#> SRR1539221 4 0.3409 0.876 0.000 0.300 0.000 0.700 0.000 NA
#> SRR1539223 5 0.6575 0.465 0.248 0.000 0.000 0.060 0.500 NA
#> SRR1539224 4 0.5572 0.839 0.000 0.300 0.004 0.592 0.040 NA
#> SRR1539222 3 0.3997 0.877 0.020 0.000 0.800 0.096 0.008 NA
#> SRR1539225 3 0.0692 0.938 0.020 0.000 0.976 0.000 0.004 NA
#> SRR1539227 4 0.3885 0.872 0.000 0.300 0.004 0.684 0.000 NA
#> SRR1539226 1 0.2257 0.684 0.876 0.000 0.000 0.008 0.116 NA
#> SRR1539228 3 0.0692 0.938 0.020 0.000 0.976 0.000 0.004 NA
#> SRR1539229 1 0.2257 0.687 0.876 0.000 0.000 0.008 0.116 NA
#> SRR1539232 3 0.0692 0.938 0.020 0.000 0.976 0.000 0.004 NA
#> SRR1539230 4 0.3547 0.876 0.000 0.300 0.004 0.696 0.000 NA
#> SRR1539231 4 0.3547 0.876 0.000 0.300 0.004 0.696 0.000 NA
#> SRR1539234 2 0.0508 0.837 0.000 0.984 0.012 0.000 0.000 NA
#> SRR1539233 1 0.2257 0.687 0.876 0.000 0.000 0.008 0.116 NA
#> SRR1539235 5 0.2416 0.862 0.156 0.000 0.000 0.000 0.844 NA
#> SRR1539236 1 0.2146 0.686 0.880 0.000 0.000 0.004 0.116 NA
#> SRR1539237 2 0.0146 0.839 0.000 0.996 0.000 0.000 0.000 NA
#> SRR1539238 5 0.2416 0.862 0.156 0.000 0.000 0.000 0.844 NA
#> SRR1539239 1 0.3482 0.624 0.684 0.000 0.000 0.000 0.000 NA
#> SRR1539242 1 0.3482 0.624 0.684 0.000 0.000 0.000 0.000 NA
#> SRR1539240 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1539241 5 0.2416 0.862 0.156 0.000 0.000 0.000 0.844 NA
#> SRR1539243 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1539244 5 0.3819 0.687 0.280 0.000 0.000 0.020 0.700 NA
#> SRR1539245 1 0.2450 0.686 0.868 0.000 0.000 0.016 0.116 NA
#> SRR1539246 2 0.4149 0.736 0.000 0.728 0.004 0.056 0.000 NA
#> SRR1539247 5 0.2416 0.862 0.156 0.000 0.000 0.000 0.844 NA
#> SRR1539248 1 0.3482 0.624 0.684 0.000 0.000 0.000 0.000 NA
#> SRR1539249 2 0.3810 0.751 0.000 0.752 0.004 0.036 0.000 NA
#> SRR1539250 5 0.5665 0.595 0.032 0.000 0.172 0.056 0.676 NA
#> SRR1539251 5 0.5665 0.595 0.032 0.000 0.172 0.056 0.676 NA
#> SRR1539253 2 0.0000 0.840 0.000 1.000 0.000 0.000 0.000 NA
#> SRR1539252 1 0.4207 0.485 0.720 0.000 0.000 0.028 0.232 NA
#> SRR1539255 1 0.2146 0.686 0.880 0.000 0.000 0.004 0.116 NA
#> SRR1539254 5 0.2416 0.862 0.156 0.000 0.000 0.000 0.844 NA
#> SRR1539256 2 0.0508 0.837 0.000 0.984 0.012 0.000 0.000 NA
#> SRR1539257 5 0.2558 0.861 0.156 0.000 0.000 0.000 0.840 NA
#> SRR1539258 1 0.0937 0.687 0.960 0.000 0.000 0.000 0.000 NA
#> SRR1539259 2 0.4469 0.709 0.000 0.700 0.004 0.076 0.000 NA
#> SRR1539260 5 0.2416 0.862 0.156 0.000 0.000 0.000 0.844 NA
#> SRR1539262 2 0.4469 0.709 0.000 0.700 0.004 0.076 0.000 NA
#> SRR1539261 1 0.4331 0.524 0.516 0.000 0.000 0.020 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["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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'skmeans' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 4.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 0.976 0.991 0.4708 0.532 0.532
#> 3 3 0.840 0.846 0.928 0.3168 0.802 0.633
#> 4 4 1.000 0.940 0.974 0.1422 0.921 0.781
#> 5 5 0.875 0.872 0.890 0.0674 0.921 0.739
#> 6 6 0.809 0.807 0.875 0.0420 0.986 0.938
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
#> SRR1539207 1 0.000 0.988 1.000 0.000
#> SRR1539208 1 0.000 0.988 1.000 0.000
#> SRR1539211 1 0.975 0.301 0.592 0.408
#> SRR1539210 1 0.000 0.988 1.000 0.000
#> SRR1539209 2 0.000 0.994 0.000 1.000
#> SRR1539212 2 0.000 0.994 0.000 1.000
#> SRR1539214 1 0.000 0.988 1.000 0.000
#> SRR1539213 1 0.000 0.988 1.000 0.000
#> SRR1539215 2 0.000 0.994 0.000 1.000
#> SRR1539216 1 0.000 0.988 1.000 0.000
#> SRR1539217 1 0.000 0.988 1.000 0.000
#> SRR1539218 2 0.000 0.994 0.000 1.000
#> SRR1539220 1 0.000 0.988 1.000 0.000
#> SRR1539219 1 0.000 0.988 1.000 0.000
#> SRR1539221 2 0.000 0.994 0.000 1.000
#> SRR1539223 1 0.000 0.988 1.000 0.000
#> SRR1539224 2 0.000 0.994 0.000 1.000
#> SRR1539222 1 0.000 0.988 1.000 0.000
#> SRR1539225 1 0.000 0.988 1.000 0.000
#> SRR1539227 2 0.000 0.994 0.000 1.000
#> SRR1539226 1 0.000 0.988 1.000 0.000
#> SRR1539228 1 0.000 0.988 1.000 0.000
#> SRR1539229 1 0.000 0.988 1.000 0.000
#> SRR1539232 1 0.000 0.988 1.000 0.000
#> SRR1539230 2 0.000 0.994 0.000 1.000
#> SRR1539231 2 0.000 0.994 0.000 1.000
#> SRR1539234 2 0.000 0.994 0.000 1.000
#> SRR1539233 1 0.000 0.988 1.000 0.000
#> SRR1539235 1 0.000 0.988 1.000 0.000
#> SRR1539236 1 0.000 0.988 1.000 0.000
#> SRR1539237 2 0.000 0.994 0.000 1.000
#> SRR1539238 1 0.000 0.988 1.000 0.000
#> SRR1539239 1 0.000 0.988 1.000 0.000
#> SRR1539242 1 0.000 0.988 1.000 0.000
#> SRR1539240 2 0.000 0.994 0.000 1.000
#> SRR1539241 1 0.000 0.988 1.000 0.000
#> SRR1539243 2 0.000 0.994 0.000 1.000
#> SRR1539244 1 0.000 0.988 1.000 0.000
#> SRR1539245 1 0.000 0.988 1.000 0.000
#> SRR1539246 2 0.000 0.994 0.000 1.000
#> SRR1539247 1 0.000 0.988 1.000 0.000
#> SRR1539248 1 0.000 0.988 1.000 0.000
#> SRR1539249 2 0.000 0.994 0.000 1.000
#> SRR1539250 1 0.000 0.988 1.000 0.000
#> SRR1539251 1 0.000 0.988 1.000 0.000
#> SRR1539253 2 0.000 0.994 0.000 1.000
#> SRR1539252 1 0.000 0.988 1.000 0.000
#> SRR1539255 1 0.000 0.988 1.000 0.000
#> SRR1539254 1 0.000 0.988 1.000 0.000
#> SRR1539256 2 0.000 0.994 0.000 1.000
#> SRR1539257 1 0.000 0.988 1.000 0.000
#> SRR1539258 1 0.000 0.988 1.000 0.000
#> SRR1539259 2 0.000 0.994 0.000 1.000
#> SRR1539260 1 0.000 0.988 1.000 0.000
#> SRR1539262 2 0.000 0.994 0.000 1.000
#> SRR1539261 2 0.506 0.871 0.112 0.888
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539208 3 0.2959 0.8036 0.100 0.000 0.900
#> SRR1539211 1 0.1411 0.6492 0.964 0.036 0.000
#> SRR1539210 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539209 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539212 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539214 3 0.0592 0.9318 0.012 0.000 0.988
#> SRR1539213 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539215 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539216 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539217 3 0.6026 -0.0385 0.376 0.000 0.624
#> SRR1539218 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539220 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539219 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539221 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539223 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539224 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539222 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539225 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539227 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539226 1 0.6299 0.5020 0.524 0.000 0.476
#> SRR1539228 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539229 1 0.6299 0.5020 0.524 0.000 0.476
#> SRR1539232 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539230 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539231 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539234 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539233 1 0.6299 0.5020 0.524 0.000 0.476
#> SRR1539235 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539236 1 0.6299 0.5020 0.524 0.000 0.476
#> SRR1539237 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539238 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539239 1 0.0000 0.6696 1.000 0.000 0.000
#> SRR1539242 1 0.0000 0.6696 1.000 0.000 0.000
#> SRR1539240 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539241 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539243 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539244 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539245 1 0.6299 0.5020 0.524 0.000 0.476
#> SRR1539246 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539247 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539248 1 0.0000 0.6696 1.000 0.000 0.000
#> SRR1539249 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539250 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539251 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539253 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539252 3 0.6126 -0.1418 0.400 0.000 0.600
#> SRR1539255 1 0.6299 0.5020 0.524 0.000 0.476
#> SRR1539254 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539256 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539257 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539258 1 0.4504 0.6448 0.804 0.000 0.196
#> SRR1539259 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539260 3 0.0000 0.9456 0.000 0.000 1.000
#> SRR1539262 2 0.0000 1.0000 0.000 1.000 0.000
#> SRR1539261 1 0.1411 0.6492 0.964 0.036 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR1539208 3 0.4898 0.335 0.000 0.000 0.584 0.416
#> SRR1539211 4 0.0000 0.969 0.000 0.000 0.000 1.000
#> SRR1539210 3 0.1118 0.931 0.000 0.000 0.964 0.036
#> SRR1539209 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539212 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539214 1 0.2081 0.877 0.916 0.000 0.084 0.000
#> SRR1539213 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539215 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539216 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR1539217 3 0.5742 0.358 0.368 0.000 0.596 0.036
#> SRR1539218 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539220 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539219 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539221 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539223 3 0.1118 0.931 0.000 0.000 0.964 0.036
#> SRR1539224 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539222 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR1539225 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539227 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539226 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539228 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539229 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539232 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539230 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539231 2 0.0188 0.998 0.004 0.996 0.000 0.000
#> SRR1539234 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539233 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539235 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539236 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539237 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539238 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539239 4 0.1118 0.981 0.036 0.000 0.000 0.964
#> SRR1539242 4 0.1118 0.981 0.036 0.000 0.000 0.964
#> SRR1539240 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539241 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539243 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539244 1 0.3942 0.660 0.764 0.000 0.236 0.000
#> SRR1539245 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539246 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539247 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539248 4 0.1118 0.981 0.036 0.000 0.000 0.964
#> SRR1539249 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539250 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR1539251 3 0.0188 0.955 0.000 0.000 0.996 0.004
#> SRR1539253 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539252 1 0.1302 0.914 0.956 0.000 0.044 0.000
#> SRR1539255 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539254 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539256 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539257 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539258 1 0.0188 0.944 0.996 0.000 0.004 0.000
#> SRR1539259 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539260 3 0.0000 0.956 0.000 0.000 1.000 0.000
#> SRR1539262 2 0.0000 0.998 0.000 1.000 0.000 0.000
#> SRR1539261 4 0.0188 0.972 0.004 0.000 0.000 0.996
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 0.838 0.000 0.000 1.000 0.000 0.000
#> SRR1539208 3 0.6444 0.235 0.000 0.000 0.484 0.316 0.200
#> SRR1539211 4 0.4088 0.766 0.000 0.000 0.000 0.632 0.368
#> SRR1539210 3 0.2966 0.677 0.000 0.000 0.816 0.000 0.184
#> SRR1539209 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539212 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539214 1 0.2723 0.819 0.864 0.000 0.124 0.000 0.012
#> SRR1539213 3 0.0162 0.837 0.000 0.000 0.996 0.000 0.004
#> SRR1539215 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539216 3 0.0000 0.838 0.000 0.000 1.000 0.000 0.000
#> SRR1539217 3 0.6411 0.236 0.364 0.000 0.488 0.008 0.140
#> SRR1539218 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539220 3 0.0794 0.817 0.000 0.000 0.972 0.000 0.028
#> SRR1539219 3 0.0000 0.838 0.000 0.000 1.000 0.000 0.000
#> SRR1539221 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539223 3 0.3353 0.669 0.000 0.000 0.796 0.008 0.196
#> SRR1539224 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539222 3 0.0000 0.838 0.000 0.000 1.000 0.000 0.000
#> SRR1539225 3 0.0162 0.837 0.000 0.000 0.996 0.000 0.004
#> SRR1539227 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539226 1 0.0000 0.930 1.000 0.000 0.000 0.000 0.000
#> SRR1539228 3 0.0162 0.837 0.000 0.000 0.996 0.000 0.004
#> SRR1539229 1 0.0794 0.928 0.972 0.000 0.000 0.000 0.028
#> SRR1539232 3 0.0162 0.837 0.000 0.000 0.996 0.000 0.004
#> SRR1539230 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539231 2 0.0703 0.988 0.000 0.976 0.000 0.000 0.024
#> SRR1539234 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539233 1 0.0794 0.928 0.972 0.000 0.000 0.000 0.028
#> SRR1539235 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539236 1 0.0000 0.930 1.000 0.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539238 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539239 4 0.0510 0.902 0.016 0.000 0.000 0.984 0.000
#> SRR1539242 4 0.0290 0.904 0.008 0.000 0.000 0.992 0.000
#> SRR1539240 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539241 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539243 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539244 5 0.5507 0.319 0.316 0.000 0.088 0.000 0.596
#> SRR1539245 1 0.0794 0.928 0.972 0.000 0.000 0.000 0.028
#> SRR1539246 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539247 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539248 4 0.0404 0.903 0.012 0.000 0.000 0.988 0.000
#> SRR1539249 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539250 3 0.0510 0.828 0.000 0.000 0.984 0.000 0.016
#> SRR1539251 3 0.0510 0.828 0.000 0.000 0.984 0.000 0.016
#> SRR1539253 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539252 1 0.2286 0.844 0.888 0.000 0.108 0.000 0.004
#> SRR1539255 1 0.0000 0.930 1.000 0.000 0.000 0.000 0.000
#> SRR1539254 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539256 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539257 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539258 1 0.2280 0.837 0.880 0.000 0.000 0.120 0.000
#> SRR1539259 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539260 5 0.4227 0.903 0.000 0.000 0.420 0.000 0.580
#> SRR1539262 2 0.0000 0.989 0.000 1.000 0.000 0.000 0.000
#> SRR1539261 4 0.2966 0.862 0.000 0.000 0.000 0.816 0.184
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 6 0.6054 0.2424 0.000 0.000 0.304 0.080 0.072 0.544
#> SRR1539211 6 0.2048 0.3779 0.000 0.000 0.000 0.120 0.000 0.880
#> SRR1539210 3 0.4482 0.3970 0.000 0.000 0.628 0.000 0.048 0.324
#> SRR1539209 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539212 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539214 1 0.3003 0.7084 0.812 0.000 0.172 0.000 0.016 0.000
#> SRR1539213 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539215 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539216 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 3 0.6767 -0.0583 0.368 0.000 0.392 0.000 0.060 0.180
#> SRR1539218 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539220 3 0.1007 0.8383 0.000 0.000 0.956 0.000 0.044 0.000
#> SRR1539219 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539223 3 0.4750 0.3501 0.000 0.000 0.596 0.000 0.064 0.340
#> SRR1539224 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539222 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539227 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539226 1 0.0508 0.8880 0.984 0.000 0.000 0.000 0.012 0.004
#> SRR1539228 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.1700 0.8822 0.928 0.000 0.000 0.000 0.048 0.024
#> SRR1539232 3 0.0000 0.8608 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539230 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539231 2 0.3748 0.8812 0.000 0.792 0.000 0.004 0.112 0.092
#> SRR1539234 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539233 1 0.1890 0.8778 0.916 0.000 0.000 0.000 0.060 0.024
#> SRR1539235 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539236 1 0.0000 0.8867 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539237 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539239 4 0.0146 0.9935 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1539242 4 0.0146 0.9935 0.004 0.000 0.000 0.996 0.000 0.000
#> SRR1539240 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539243 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.3083 0.6700 0.132 0.000 0.040 0.000 0.828 0.000
#> SRR1539245 1 0.1549 0.8835 0.936 0.000 0.000 0.000 0.044 0.020
#> SRR1539246 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539248 4 0.0363 0.9869 0.012 0.000 0.000 0.988 0.000 0.000
#> SRR1539249 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 3 0.1075 0.8357 0.000 0.000 0.952 0.000 0.048 0.000
#> SRR1539251 3 0.1075 0.8357 0.000 0.000 0.952 0.000 0.048 0.000
#> SRR1539253 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.1814 0.8159 0.900 0.000 0.100 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.8867 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539254 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539256 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539258 1 0.3126 0.6287 0.752 0.000 0.000 0.248 0.000 0.000
#> SRR1539259 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.2969 0.9572 0.000 0.000 0.224 0.000 0.776 0.000
#> SRR1539262 2 0.0000 0.8941 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 6 0.3860 -0.1973 0.000 0.000 0.000 0.472 0.000 0.528
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'pam' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.836 0.876 0.929 0.4036 0.836 0.699
#> 4 4 1.000 0.953 0.983 0.1632 0.873 0.667
#> 5 5 0.987 0.948 0.980 0.0780 0.942 0.769
#> 6 6 0.987 0.958 0.980 0.0294 0.973 0.865
suggest_best_k()
suggests the best \(k\) based on these statistics. The rules are as follows:
suggest_best_k(res)
#> [1] 6
#> attr(,"optional")
#> [1] 2 4 5
There is also optional best \(k\) = 2 4 5 that is worth to check.
Following shows the table of the partitions (You need to click the show/hide
code output link to see it). The membership matrix (columns with name p*
)
is inferred by
clue::cl_consensus()
function with the SE
method. Basically the value in the membership matrix
represents the probability to belong to a certain group. The finall class
label for an item is determined with the group with highest probability it
belongs to.
In get_classes()
function, the entropy is calculated from the membership
matrix and the silhouette score is calculated from the consensus matrix.
cbind(get_classes(res, k = 2), get_membership(res, k = 2))
#> class entropy silhouette p1 p2
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.000 1.000 0.00 0 1.00
#> SRR1539208 1 0.000 0.827 1.00 0 0.00
#> SRR1539211 1 0.000 0.827 1.00 0 0.00
#> SRR1539210 3 0.000 1.000 0.00 0 1.00
#> SRR1539209 2 0.000 1.000 0.00 1 0.00
#> SRR1539212 2 0.000 1.000 0.00 1 0.00
#> SRR1539214 1 0.000 0.827 1.00 0 0.00
#> SRR1539213 3 0.000 1.000 0.00 0 1.00
#> SRR1539215 2 0.000 1.000 0.00 1 0.00
#> SRR1539216 3 0.000 1.000 0.00 0 1.00
#> SRR1539217 1 0.000 0.827 1.00 0 0.00
#> SRR1539218 2 0.000 1.000 0.00 1 0.00
#> SRR1539220 1 0.595 0.642 0.64 0 0.36
#> SRR1539219 3 0.000 1.000 0.00 0 1.00
#> SRR1539221 2 0.000 1.000 0.00 1 0.00
#> SRR1539223 1 0.595 0.642 0.64 0 0.36
#> SRR1539224 2 0.000 1.000 0.00 1 0.00
#> SRR1539222 3 0.000 1.000 0.00 0 1.00
#> SRR1539225 3 0.000 1.000 0.00 0 1.00
#> SRR1539227 2 0.000 1.000 0.00 1 0.00
#> SRR1539226 1 0.000 0.827 1.00 0 0.00
#> SRR1539228 3 0.000 1.000 0.00 0 1.00
#> SRR1539229 1 0.000 0.827 1.00 0 0.00
#> SRR1539232 3 0.000 1.000 0.00 0 1.00
#> SRR1539230 2 0.000 1.000 0.00 1 0.00
#> SRR1539231 2 0.000 1.000 0.00 1 0.00
#> SRR1539234 2 0.000 1.000 0.00 1 0.00
#> SRR1539233 1 0.000 0.827 1.00 0 0.00
#> SRR1539235 1 0.595 0.642 0.64 0 0.36
#> SRR1539236 1 0.000 0.827 1.00 0 0.00
#> SRR1539237 2 0.000 1.000 0.00 1 0.00
#> SRR1539238 1 0.595 0.642 0.64 0 0.36
#> SRR1539239 1 0.000 0.827 1.00 0 0.00
#> SRR1539242 1 0.000 0.827 1.00 0 0.00
#> SRR1539240 2 0.000 1.000 0.00 1 0.00
#> SRR1539241 1 0.595 0.642 0.64 0 0.36
#> SRR1539243 2 0.000 1.000 0.00 1 0.00
#> SRR1539244 1 0.000 0.827 1.00 0 0.00
#> SRR1539245 1 0.000 0.827 1.00 0 0.00
#> SRR1539246 2 0.000 1.000 0.00 1 0.00
#> SRR1539247 1 0.595 0.642 0.64 0 0.36
#> SRR1539248 1 0.000 0.827 1.00 0 0.00
#> SRR1539249 2 0.000 1.000 0.00 1 0.00
#> SRR1539250 1 0.604 0.613 0.62 0 0.38
#> SRR1539251 1 0.604 0.613 0.62 0 0.38
#> SRR1539253 2 0.000 1.000 0.00 1 0.00
#> SRR1539252 1 0.000 0.827 1.00 0 0.00
#> SRR1539255 1 0.000 0.827 1.00 0 0.00
#> SRR1539254 1 0.595 0.642 0.64 0 0.36
#> SRR1539256 2 0.000 1.000 0.00 1 0.00
#> SRR1539257 1 0.595 0.642 0.64 0 0.36
#> SRR1539258 1 0.000 0.827 1.00 0 0.00
#> SRR1539259 2 0.000 1.000 0.00 1 0.00
#> SRR1539260 1 0.595 0.642 0.64 0 0.36
#> SRR1539262 2 0.000 1.000 0.00 1 0.00
#> SRR1539261 1 0.000 0.827 1.00 0 0.00
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539208 1 0.419 0.601 0.732 0 0 0.268
#> SRR1539211 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539210 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539209 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539212 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539214 4 0.419 0.619 0.268 0 0 0.732
#> SRR1539213 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539215 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539216 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539217 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539218 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539220 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539219 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539221 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539223 4 0.494 0.197 0.436 0 0 0.564
#> SRR1539224 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539222 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539225 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539227 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539226 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539228 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539229 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539232 3 0.000 1.000 0.000 0 1 0.000
#> SRR1539230 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539231 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539234 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539233 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539235 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539236 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539237 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539238 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539239 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539242 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539240 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539241 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539243 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539244 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539245 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539246 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539247 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539248 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539249 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539250 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539251 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539253 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539252 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539255 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539254 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539256 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539257 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539258 1 0.000 0.979 1.000 0 0 0.000
#> SRR1539259 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539260 4 0.000 0.932 0.000 0 0 1.000
#> SRR1539262 2 0.000 1.000 0.000 1 0 0.000
#> SRR1539261 1 0.000 0.979 1.000 0 0 0.000
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539208 1 0.361 0.601 0.732 0.000 0 0.000 0.268
#> SRR1539211 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539210 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539209 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539212 4 0.238 0.853 0.000 0.128 0 0.872 0.000
#> SRR1539214 5 0.361 0.619 0.268 0.000 0 0.000 0.732
#> SRR1539213 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539215 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539216 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539217 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539218 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539220 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539219 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539221 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539223 5 0.426 0.197 0.436 0.000 0 0.000 0.564
#> SRR1539224 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539222 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539225 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539227 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539226 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539228 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539229 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539232 3 0.000 1.000 0.000 0.000 1 0.000 0.000
#> SRR1539230 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539231 4 0.000 0.983 0.000 0.000 0 1.000 0.000
#> SRR1539234 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539233 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539235 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539236 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539237 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539238 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539239 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539242 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539240 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539241 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539243 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539244 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539245 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539246 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539247 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539248 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539249 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539250 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539251 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539253 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539252 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539255 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539254 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539256 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539257 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539258 1 0.000 0.979 1.000 0.000 0 0.000 0.000
#> SRR1539259 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539260 5 0.000 0.931 0.000 0.000 0 0.000 1.000
#> SRR1539262 2 0.000 1.000 0.000 1.000 0 0.000 0.000
#> SRR1539261 1 0.000 0.979 1.000 0.000 0 0.000 0.000
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 1 0.1152 0.950 0.952 0.000 0.000 0.000 0.044 0.004
#> SRR1539211 1 0.0458 0.988 0.984 0.000 0.000 0.000 0.000 0.016
#> SRR1539210 6 0.0458 0.864 0.000 0.000 0.016 0.000 0.000 0.984
#> SRR1539209 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539212 4 0.2135 0.829 0.000 0.128 0.000 0.872 0.000 0.000
#> SRR1539214 5 0.1010 0.907 0.036 0.000 0.000 0.000 0.960 0.004
#> SRR1539213 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539215 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539216 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 1 0.0146 0.989 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539218 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539220 5 0.2854 0.744 0.000 0.000 0.000 0.000 0.792 0.208
#> SRR1539219 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539223 6 0.3607 0.502 0.000 0.000 0.000 0.000 0.348 0.652
#> SRR1539224 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539222 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539227 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539226 1 0.0146 0.990 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539228 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.0146 0.990 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539232 3 0.0000 1.000 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539230 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539231 4 0.0000 0.980 0.000 0.000 0.000 1.000 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539233 1 0.0146 0.990 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539235 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539236 1 0.0146 0.990 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539237 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539238 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539239 1 0.0363 0.989 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR1539242 1 0.0363 0.989 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR1539240 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539241 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539244 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539245 1 0.0146 0.990 0.996 0.000 0.000 0.000 0.000 0.004
#> SRR1539246 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539247 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539248 1 0.0363 0.989 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR1539249 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539250 6 0.0547 0.875 0.000 0.000 0.000 0.000 0.020 0.980
#> SRR1539251 6 0.0547 0.875 0.000 0.000 0.000 0.000 0.020 0.980
#> SRR1539253 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539252 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.0000 0.990 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539254 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539257 5 0.2527 0.792 0.000 0.000 0.000 0.000 0.832 0.168
#> SRR1539258 1 0.0363 0.989 0.988 0.000 0.000 0.000 0.000 0.012
#> SRR1539259 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539260 5 0.0000 0.945 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1.000 0.000 0.000 0.000 0.000
#> SRR1539261 1 0.0363 0.989 0.988 0.000 0.000 0.000 0.000 0.012
Heatmaps for the consensus matrix. It visualizes the probability of two samples to be in a same group.
consensus_heatmap(res, k = 2)
consensus_heatmap(res, k = 3)
consensus_heatmap(res, k = 4)
consensus_heatmap(res, k = 5)
consensus_heatmap(res, k = 6)
Heatmaps for the membership of samples in all partitions to see how consistent they are:
membership_heatmap(res, k = 2)
membership_heatmap(res, k = 3)
membership_heatmap(res, k = 4)
membership_heatmap(res, k = 5)
membership_heatmap(res, k = 6)
As soon as we have had the classes for columns, we can look for signatures which are significantly different between classes which can be candidate marks for certain classes. Following are the heatmaps for signatures.
Signature heatmaps where rows are scaled:
get_signatures(res, k = 2)
get_signatures(res, k = 3)
get_signatures(res, k = 4)
get_signatures(res, k = 5)
get_signatures(res, k = 6)
Signature heatmaps where rows are not scaled:
get_signatures(res, k = 2, scale_rows = FALSE)
get_signatures(res, k = 3, scale_rows = FALSE)
get_signatures(res, k = 4, scale_rows = FALSE)
get_signatures(res, k = 5, scale_rows = FALSE)
get_signatures(res, k = 6, scale_rows = FALSE)
Compare the overlap of signatures from different k:
compare_signatures(res)
get_signature()
returns a data frame invisibly. TO get the list of signatures, the function
call should be assigned to a variable explicitly. In following code, if plot
argument is set
to FALSE
, no heatmap is plotted while only the differential analysis is performed.
# code only for demonstration
tb = get_signature(res, k = ..., plot = FALSE)
An example of the output of tb
is:
#> which_row fdr mean_1 mean_2 scaled_mean_1 scaled_mean_2 km
#> 1 38 0.042760348 8.373488 9.131774 -0.5533452 0.5164555 1
#> 2 40 0.018707592 7.106213 8.469186 -0.6173731 0.5762149 1
#> 3 55 0.019134737 10.221463 11.207825 -0.6159697 0.5749050 1
#> 4 59 0.006059896 5.921854 7.869574 -0.6899429 0.6439467 1
#> 5 60 0.018055526 8.928898 10.211722 -0.6204761 0.5791110 1
#> 6 98 0.009384629 15.714769 14.887706 0.6635654 -0.6193277 2
...
The columns in tb
are:
which_row
: row indices corresponding to the input matrix.fdr
: FDR for the differential test. mean_x
: The mean value in group x.scaled_mean_x
: The mean value in group x after rows are scaled.km
: Row groups if k-means clustering is applied to rows.UMAP plot which shows how samples are separated.
dimension_reduction(res, k = 2, method = "UMAP")
dimension_reduction(res, k = 3, method = "UMAP")
dimension_reduction(res, k = 4, method = "UMAP")
dimension_reduction(res, k = 5, method = "UMAP")
dimension_reduction(res, k = 6, method = "UMAP")
Following heatmap shows how subgroups are split when increasing k
:
collect_classes(res)
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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'mclust' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 6.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 1.000 0.991 0.995 0.3628 0.836 0.699
#> 4 4 0.843 0.810 0.922 0.1501 0.905 0.749
#> 5 5 0.802 0.777 0.880 0.0292 1.000 1.000
#> 6 6 0.933 0.884 0.930 0.0575 0.902 0.681
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 3 0.0000 0.998 0.000 0 1.000
#> SRR1539208 1 0.2356 0.929 0.928 0 0.072
#> SRR1539211 1 0.2356 0.929 0.928 0 0.072
#> SRR1539210 3 0.0000 0.998 0.000 0 1.000
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000
#> SRR1539214 1 0.0000 0.991 1.000 0 0.000
#> SRR1539213 3 0.0000 0.998 0.000 0 1.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000
#> SRR1539216 3 0.0000 0.998 0.000 0 1.000
#> SRR1539217 1 0.0000 0.991 1.000 0 0.000
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000
#> SRR1539220 1 0.0000 0.991 1.000 0 0.000
#> SRR1539219 3 0.0000 0.998 0.000 0 1.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000
#> SRR1539223 1 0.0000 0.991 1.000 0 0.000
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000
#> SRR1539222 3 0.0000 0.998 0.000 0 1.000
#> SRR1539225 3 0.0000 0.998 0.000 0 1.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000
#> SRR1539226 1 0.0000 0.991 1.000 0 0.000
#> SRR1539228 3 0.0000 0.998 0.000 0 1.000
#> SRR1539229 1 0.0000 0.991 1.000 0 0.000
#> SRR1539232 3 0.0747 0.982 0.016 0 0.984
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000
#> SRR1539233 1 0.0000 0.991 1.000 0 0.000
#> SRR1539235 1 0.0000 0.991 1.000 0 0.000
#> SRR1539236 1 0.0000 0.991 1.000 0 0.000
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000
#> SRR1539238 1 0.0000 0.991 1.000 0 0.000
#> SRR1539239 1 0.0000 0.991 1.000 0 0.000
#> SRR1539242 1 0.0000 0.991 1.000 0 0.000
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000
#> SRR1539241 1 0.0000 0.991 1.000 0 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000
#> SRR1539244 1 0.0000 0.991 1.000 0 0.000
#> SRR1539245 1 0.0000 0.991 1.000 0 0.000
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000
#> SRR1539247 1 0.0000 0.991 1.000 0 0.000
#> SRR1539248 1 0.0000 0.991 1.000 0 0.000
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000
#> SRR1539250 1 0.0747 0.979 0.984 0 0.016
#> SRR1539251 1 0.0747 0.979 0.984 0 0.016
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000
#> SRR1539252 1 0.0000 0.991 1.000 0 0.000
#> SRR1539255 1 0.0000 0.991 1.000 0 0.000
#> SRR1539254 1 0.0000 0.991 1.000 0 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000
#> SRR1539257 1 0.0000 0.991 1.000 0 0.000
#> SRR1539258 1 0.0000 0.991 1.000 0 0.000
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000
#> SRR1539260 1 0.0000 0.991 1.000 0 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000
#> SRR1539261 1 0.2356 0.929 0.928 0 0.072
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539208 4 0.3266 0.653 0.168 0 0.000 0.832
#> SRR1539211 4 0.0188 0.652 0.004 0 0.000 0.996
#> SRR1539210 3 0.0469 0.991 0.000 0 0.988 0.012
#> SRR1539209 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539212 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539214 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539213 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539215 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539216 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539217 1 0.3975 0.608 0.760 0 0.000 0.240
#> SRR1539218 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539220 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539219 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539221 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539223 1 0.4989 -0.148 0.528 0 0.000 0.472
#> SRR1539224 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539222 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539225 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539227 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539226 1 0.3486 0.675 0.812 0 0.000 0.188
#> SRR1539228 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539229 1 0.4008 0.603 0.756 0 0.000 0.244
#> SRR1539232 3 0.0000 0.999 0.000 0 1.000 0.000
#> SRR1539230 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539231 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539234 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539233 1 0.4103 0.584 0.744 0 0.000 0.256
#> SRR1539235 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539236 1 0.3764 0.645 0.784 0 0.000 0.216
#> SRR1539237 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539238 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539239 4 0.4866 0.441 0.404 0 0.000 0.596
#> SRR1539242 4 0.4989 0.292 0.472 0 0.000 0.528
#> SRR1539240 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539241 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539243 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539244 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539245 1 0.4967 0.086 0.548 0 0.000 0.452
#> SRR1539246 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539247 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539248 4 0.2589 0.677 0.116 0 0.000 0.884
#> SRR1539249 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539250 1 0.3123 0.644 0.844 0 0.000 0.156
#> SRR1539251 1 0.3123 0.644 0.844 0 0.000 0.156
#> SRR1539253 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539252 1 0.2408 0.747 0.896 0 0.000 0.104
#> SRR1539255 1 0.3486 0.675 0.812 0 0.000 0.188
#> SRR1539254 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539256 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539257 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539258 4 0.4996 0.265 0.484 0 0.000 0.516
#> SRR1539259 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539260 1 0.0000 0.800 1.000 0 0.000 0.000
#> SRR1539262 2 0.0000 1.000 0.000 1 0.000 0.000
#> SRR1539261 4 0.0336 0.655 0.008 0 0.000 0.992
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539208 1 0.3760 0.7636 0.784 0.000 0.000 NA 0.188
#> SRR1539211 1 0.4141 0.6078 0.728 0.000 0.000 NA 0.024
#> SRR1539210 3 0.4467 0.6825 0.016 0.000 0.640 NA 0.000
#> SRR1539209 2 0.3783 0.7556 0.008 0.740 0.000 NA 0.000
#> SRR1539212 2 0.3783 0.7556 0.008 0.740 0.000 NA 0.000
#> SRR1539214 5 0.0000 0.7550 0.000 0.000 0.000 NA 1.000
#> SRR1539213 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539215 2 0.0000 0.9699 0.000 1.000 0.000 NA 0.000
#> SRR1539216 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539217 5 0.4610 0.2430 0.432 0.000 0.000 NA 0.556
#> SRR1539218 2 0.0404 0.9665 0.000 0.988 0.000 NA 0.000
#> SRR1539220 5 0.0000 0.7550 0.000 0.000 0.000 NA 1.000
#> SRR1539219 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539221 2 0.0510 0.9646 0.000 0.984 0.000 NA 0.000
#> SRR1539223 5 0.5006 0.5009 0.180 0.000 0.000 NA 0.704
#> SRR1539224 2 0.0000 0.9699 0.000 1.000 0.000 NA 0.000
#> SRR1539222 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539225 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539227 2 0.0290 0.9681 0.000 0.992 0.000 NA 0.000
#> SRR1539226 5 0.4444 0.4285 0.364 0.000 0.000 NA 0.624
#> SRR1539228 3 0.0000 0.9587 0.000 0.000 1.000 NA 0.000
#> SRR1539229 5 0.4924 0.3237 0.420 0.000 0.000 NA 0.552
#> SRR1539232 3 0.1845 0.9183 0.016 0.000 0.928 NA 0.000
#> SRR1539230 2 0.0162 0.9693 0.000 0.996 0.000 NA 0.000
#> SRR1539231 2 0.0162 0.9693 0.000 0.996 0.000 NA 0.000
#> SRR1539234 2 0.0162 0.9701 0.000 0.996 0.000 NA 0.000
#> SRR1539233 5 0.5229 0.3238 0.404 0.000 0.000 NA 0.548
#> SRR1539235 5 0.0000 0.7550 0.000 0.000 0.000 NA 1.000
#> SRR1539236 5 0.4182 0.4571 0.352 0.000 0.000 NA 0.644
#> SRR1539237 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539238 5 0.0324 0.7544 0.004 0.000 0.000 NA 0.992
#> SRR1539239 1 0.3993 0.7536 0.756 0.000 0.000 NA 0.216
#> SRR1539242 1 0.4083 0.7211 0.744 0.000 0.000 NA 0.228
#> SRR1539240 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539241 5 0.0162 0.7549 0.004 0.000 0.000 NA 0.996
#> SRR1539243 2 0.0162 0.9701 0.000 0.996 0.000 NA 0.000
#> SRR1539244 5 0.4707 0.5584 0.072 0.000 0.000 NA 0.716
#> SRR1539245 5 0.6553 0.0815 0.364 0.000 0.000 NA 0.432
#> SRR1539246 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539247 5 0.0000 0.7550 0.000 0.000 0.000 NA 1.000
#> SRR1539248 1 0.3456 0.7644 0.800 0.000 0.000 NA 0.184
#> SRR1539249 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539250 5 0.2020 0.7170 0.000 0.000 0.000 NA 0.900
#> SRR1539251 5 0.2020 0.7170 0.000 0.000 0.000 NA 0.900
#> SRR1539253 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539252 5 0.2304 0.7146 0.100 0.000 0.000 NA 0.892
#> SRR1539255 5 0.4165 0.4960 0.320 0.000 0.000 NA 0.672
#> SRR1539254 5 0.0000 0.7550 0.000 0.000 0.000 NA 1.000
#> SRR1539256 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539257 5 0.0000 0.7550 0.000 0.000 0.000 NA 1.000
#> SRR1539258 1 0.4562 0.5969 0.676 0.000 0.000 NA 0.292
#> SRR1539259 2 0.0290 0.9699 0.000 0.992 0.000 NA 0.000
#> SRR1539260 5 0.0162 0.7549 0.004 0.000 0.000 NA 0.996
#> SRR1539262 2 0.0290 0.9681 0.000 0.992 0.000 NA 0.000
#> SRR1539261 1 0.4042 0.6306 0.756 0.000 0.000 NA 0.032
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 1 0.1765 0.872 0.924 0.000 0.000 0.024 0.052 0.000
#> SRR1539211 4 0.1863 0.974 0.104 0.000 0.000 0.896 0.000 0.000
#> SRR1539210 6 0.4234 0.000 0.000 0.000 0.324 0.032 0.000 0.644
#> SRR1539209 2 0.4889 0.542 0.000 0.604 0.000 0.084 0.000 0.312
#> SRR1539212 2 0.4904 0.536 0.000 0.600 0.000 0.084 0.000 0.316
#> SRR1539214 5 0.0146 0.935 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1539213 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539215 2 0.0632 0.930 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR1539216 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 1 0.1387 0.893 0.932 0.000 0.000 0.000 0.068 0.000
#> SRR1539218 2 0.1500 0.916 0.000 0.936 0.000 0.012 0.000 0.052
#> SRR1539220 5 0.0000 0.935 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539219 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539221 2 0.1625 0.912 0.000 0.928 0.000 0.012 0.000 0.060
#> SRR1539223 5 0.1523 0.911 0.044 0.000 0.000 0.008 0.940 0.008
#> SRR1539224 2 0.0146 0.931 0.000 0.996 0.000 0.000 0.000 0.004
#> SRR1539222 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539225 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539227 2 0.1124 0.925 0.000 0.956 0.000 0.008 0.000 0.036
#> SRR1539226 1 0.1141 0.903 0.948 0.000 0.000 0.000 0.052 0.000
#> SRR1539228 3 0.0000 0.992 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539229 1 0.1167 0.902 0.960 0.000 0.000 0.008 0.020 0.012
#> SRR1539232 3 0.1036 0.942 0.004 0.000 0.964 0.008 0.000 0.024
#> SRR1539230 2 0.1010 0.927 0.000 0.960 0.000 0.004 0.000 0.036
#> SRR1539231 2 0.1010 0.927 0.000 0.960 0.000 0.004 0.000 0.036
#> SRR1539234 2 0.0632 0.930 0.000 0.976 0.000 0.000 0.000 0.024
#> SRR1539233 1 0.1074 0.904 0.960 0.000 0.000 0.000 0.028 0.012
#> SRR1539235 5 0.0146 0.936 0.004 0.000 0.000 0.000 0.996 0.000
#> SRR1539236 1 0.1387 0.895 0.932 0.000 0.000 0.000 0.068 0.000
#> SRR1539237 2 0.0725 0.930 0.000 0.976 0.000 0.012 0.000 0.012
#> SRR1539238 5 0.0458 0.935 0.016 0.000 0.000 0.000 0.984 0.000
#> SRR1539239 1 0.2912 0.778 0.816 0.000 0.000 0.172 0.012 0.000
#> SRR1539242 1 0.3037 0.777 0.808 0.000 0.000 0.176 0.016 0.000
#> SRR1539240 2 0.0725 0.930 0.000 0.976 0.000 0.012 0.000 0.012
#> SRR1539241 5 0.0458 0.935 0.016 0.000 0.000 0.000 0.984 0.000
#> SRR1539243 2 0.0622 0.931 0.000 0.980 0.000 0.012 0.000 0.008
#> SRR1539244 5 0.4013 0.679 0.212 0.000 0.000 0.008 0.740 0.040
#> SRR1539245 1 0.1262 0.897 0.956 0.000 0.000 0.008 0.016 0.020
#> SRR1539246 2 0.0622 0.930 0.000 0.980 0.000 0.012 0.000 0.008
#> SRR1539247 5 0.0260 0.936 0.008 0.000 0.000 0.000 0.992 0.000
#> SRR1539248 1 0.2814 0.779 0.820 0.000 0.000 0.172 0.008 0.000
#> SRR1539249 2 0.0725 0.930 0.000 0.976 0.000 0.012 0.000 0.012
#> SRR1539250 5 0.0858 0.924 0.000 0.000 0.000 0.004 0.968 0.028
#> SRR1539251 5 0.0858 0.924 0.000 0.000 0.000 0.004 0.968 0.028
#> SRR1539253 2 0.0725 0.930 0.000 0.976 0.000 0.012 0.000 0.012
#> SRR1539252 5 0.3468 0.571 0.284 0.000 0.000 0.000 0.712 0.004
#> SRR1539255 1 0.1141 0.903 0.948 0.000 0.000 0.000 0.052 0.000
#> SRR1539254 5 0.0363 0.936 0.012 0.000 0.000 0.000 0.988 0.000
#> SRR1539256 2 0.0725 0.930 0.000 0.976 0.000 0.012 0.000 0.012
#> SRR1539257 5 0.0000 0.935 0.000 0.000 0.000 0.000 1.000 0.000
#> SRR1539258 1 0.0458 0.899 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR1539259 2 0.0725 0.930 0.000 0.976 0.000 0.012 0.000 0.012
#> SRR1539260 5 0.0458 0.935 0.016 0.000 0.000 0.000 0.984 0.000
#> SRR1539262 2 0.1151 0.926 0.000 0.956 0.000 0.012 0.000 0.032
#> SRR1539261 4 0.2048 0.975 0.120 0.000 0.000 0.880 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", "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 14951 rows and 56 columns.
#> Top rows (1000, 2000, 3000, 4000, 5000) are extracted by 'ATC' method.
#> Subgroups are detected by 'NMF' method.
#> Performed in total 1250 partitions by row resampling.
#> Best k for subgroups seems to be 2.
#>
#> Following methods can be applied to this 'ConsensusPartition' object:
#> [1] "cola_report" "collect_classes" "collect_plots"
#> [4] "collect_stats" "colnames" "compare_signatures"
#> [7] "consensus_heatmap" "dimension_reduction" "functional_enrichment"
#> [10] "get_anno_col" "get_anno" "get_classes"
#> [13] "get_consensus" "get_matrix" "get_membership"
#> [16] "get_param" "get_signatures" "get_stats"
#> [19] "is_best_k" "is_stable_k" "membership_heatmap"
#> [22] "ncol" "nrow" "plot_ecdf"
#> [25] "rownames" "select_partition_number" "show"
#> [28] "suggest_best_k" "test_to_known_factors"
collect_plots()
function collects all the plots made from res
for all k
(number of partitions)
into one single page to provide an easy and fast comparison between different k
.
collect_plots(res)
The plots are:
k
and the heatmap of
predicted classes for each k
.k
.k
.k
.All the plots in panels can be made by individual functions and they are plotted later in this section.
select_partition_number()
produces several plots showing different
statistics for choosing “optimized” k
. There are following statistics:
k
;k
, the area increased is defined as \(A_k - A_{k-1}\).The detailed explanations of these statistics can be found in the cola vignette.
Generally speaking, lower PAC score, higher mean silhouette score or higher
concordance corresponds to better partition. Rand index and Jaccard index
measure how similar the current partition is compared to partition with k-1
.
If they are too similar, we won't accept k
is better than k-1
.
select_partition_number(res)
The numeric values for all these statistics can be obtained by get_stats()
.
get_stats(res)
#> k 1-PAC mean_silhouette concordance area_increased Rand Jaccard
#> 2 2 1.000 1.000 1.000 0.4570 0.544 0.544
#> 3 3 0.803 0.831 0.925 0.3505 0.836 0.699
#> 4 4 0.597 0.600 0.765 0.1131 0.896 0.746
#> 5 5 0.649 0.607 0.817 0.0766 0.755 0.408
#> 6 6 0.711 0.645 0.824 0.0478 0.930 0.750
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
#> SRR1539207 1 0 1 1 0
#> SRR1539208 1 0 1 1 0
#> SRR1539211 1 0 1 1 0
#> SRR1539210 1 0 1 1 0
#> SRR1539209 2 0 1 0 1
#> SRR1539212 2 0 1 0 1
#> SRR1539214 1 0 1 1 0
#> SRR1539213 1 0 1 1 0
#> SRR1539215 2 0 1 0 1
#> SRR1539216 1 0 1 1 0
#> SRR1539217 1 0 1 1 0
#> SRR1539218 2 0 1 0 1
#> SRR1539220 1 0 1 1 0
#> SRR1539219 1 0 1 1 0
#> SRR1539221 2 0 1 0 1
#> SRR1539223 1 0 1 1 0
#> SRR1539224 2 0 1 0 1
#> SRR1539222 1 0 1 1 0
#> SRR1539225 1 0 1 1 0
#> SRR1539227 2 0 1 0 1
#> SRR1539226 1 0 1 1 0
#> SRR1539228 1 0 1 1 0
#> SRR1539229 1 0 1 1 0
#> SRR1539232 1 0 1 1 0
#> SRR1539230 2 0 1 0 1
#> SRR1539231 2 0 1 0 1
#> SRR1539234 2 0 1 0 1
#> SRR1539233 1 0 1 1 0
#> SRR1539235 1 0 1 1 0
#> SRR1539236 1 0 1 1 0
#> SRR1539237 2 0 1 0 1
#> SRR1539238 1 0 1 1 0
#> SRR1539239 1 0 1 1 0
#> SRR1539242 1 0 1 1 0
#> SRR1539240 2 0 1 0 1
#> SRR1539241 1 0 1 1 0
#> SRR1539243 2 0 1 0 1
#> SRR1539244 1 0 1 1 0
#> SRR1539245 1 0 1 1 0
#> SRR1539246 2 0 1 0 1
#> SRR1539247 1 0 1 1 0
#> SRR1539248 1 0 1 1 0
#> SRR1539249 2 0 1 0 1
#> SRR1539250 1 0 1 1 0
#> SRR1539251 1 0 1 1 0
#> SRR1539253 2 0 1 0 1
#> SRR1539252 1 0 1 1 0
#> SRR1539255 1 0 1 1 0
#> SRR1539254 1 0 1 1 0
#> SRR1539256 2 0 1 0 1
#> SRR1539257 1 0 1 1 0
#> SRR1539258 1 0 1 1 0
#> SRR1539259 2 0 1 0 1
#> SRR1539260 1 0 1 1 0
#> SRR1539262 2 0 1 0 1
#> SRR1539261 1 0 1 1 0
cbind(get_classes(res, k = 3), get_membership(res, k = 3))
#> class entropy silhouette p1 p2 p3
#> SRR1539207 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539208 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539211 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539210 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539209 2 0.0592 0.9932 0.000 0.988 0.012
#> SRR1539212 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539214 3 0.5178 0.7281 0.256 0.000 0.744
#> SRR1539213 1 0.0747 0.8794 0.984 0.000 0.016
#> SRR1539215 2 0.0747 0.9918 0.000 0.984 0.016
#> SRR1539216 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539217 1 0.0892 0.8782 0.980 0.000 0.020
#> SRR1539218 2 0.0592 0.9932 0.000 0.988 0.012
#> SRR1539220 1 0.2356 0.8438 0.928 0.000 0.072
#> SRR1539219 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539221 2 0.0747 0.9918 0.000 0.984 0.016
#> SRR1539223 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539224 2 0.0424 0.9941 0.000 0.992 0.008
#> SRR1539222 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539225 1 0.0747 0.8794 0.984 0.000 0.016
#> SRR1539227 2 0.0592 0.9932 0.000 0.988 0.012
#> SRR1539226 3 0.3752 0.7986 0.144 0.000 0.856
#> SRR1539228 1 0.0747 0.8794 0.984 0.000 0.016
#> SRR1539229 3 0.1289 0.8054 0.032 0.000 0.968
#> SRR1539232 1 0.4291 0.7327 0.820 0.000 0.180
#> SRR1539230 2 0.0747 0.9918 0.000 0.984 0.016
#> SRR1539231 2 0.0747 0.9918 0.000 0.984 0.016
#> SRR1539234 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539233 3 0.1411 0.8063 0.036 0.000 0.964
#> SRR1539235 1 0.3267 0.8059 0.884 0.000 0.116
#> SRR1539236 3 0.5327 0.7058 0.272 0.000 0.728
#> SRR1539237 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539238 1 0.0892 0.8782 0.980 0.000 0.020
#> SRR1539239 3 0.6307 0.0965 0.488 0.000 0.512
#> SRR1539242 1 0.6204 0.1706 0.576 0.000 0.424
#> SRR1539240 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539241 1 0.0892 0.8782 0.980 0.000 0.020
#> SRR1539243 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539244 3 0.1289 0.8054 0.032 0.000 0.968
#> SRR1539245 3 0.1289 0.8054 0.032 0.000 0.968
#> SRR1539246 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539247 1 0.3267 0.8059 0.884 0.000 0.116
#> SRR1539248 1 0.5785 0.4513 0.668 0.000 0.332
#> SRR1539249 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539250 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539251 1 0.0000 0.8791 1.000 0.000 0.000
#> SRR1539253 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539252 1 0.6215 0.1562 0.572 0.000 0.428
#> SRR1539255 3 0.4750 0.7653 0.216 0.000 0.784
#> SRR1539254 1 0.0747 0.8794 0.984 0.000 0.016
#> SRR1539256 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539257 1 0.5591 0.5164 0.696 0.000 0.304
#> SRR1539258 1 0.6225 0.1401 0.568 0.000 0.432
#> SRR1539259 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539260 1 0.0592 0.8795 0.988 0.000 0.012
#> SRR1539262 2 0.0000 0.9954 0.000 1.000 0.000
#> SRR1539261 1 0.0000 0.8791 1.000 0.000 0.000
cbind(get_classes(res, k = 4), get_membership(res, k = 4))
#> class entropy silhouette p1 p2 p3 p4
#> SRR1539207 3 0.0188 0.6550 0.000 0.000 0.996 NA
#> SRR1539208 3 0.5666 0.4061 0.348 0.000 0.616 NA
#> SRR1539211 3 0.5746 0.4045 0.348 0.000 0.612 NA
#> SRR1539210 3 0.0921 0.6495 0.000 0.000 0.972 NA
#> SRR1539209 2 0.3528 0.8832 0.000 0.808 0.000 NA
#> SRR1539212 2 0.3219 0.8880 0.000 0.836 0.000 NA
#> SRR1539214 1 0.5935 0.5247 0.664 0.000 0.080 NA
#> SRR1539213 3 0.3464 0.6176 0.108 0.000 0.860 NA
#> SRR1539215 2 0.3945 0.8755 0.004 0.780 0.000 NA
#> SRR1539216 3 0.0188 0.6550 0.000 0.000 0.996 NA
#> SRR1539217 3 0.5775 0.3337 0.408 0.000 0.560 NA
#> SRR1539218 2 0.3569 0.8824 0.000 0.804 0.000 NA
#> SRR1539220 3 0.5809 0.5282 0.216 0.000 0.692 NA
#> SRR1539219 3 0.0779 0.6528 0.004 0.000 0.980 NA
#> SRR1539221 2 0.3764 0.8769 0.000 0.784 0.000 NA
#> SRR1539223 3 0.5432 0.4592 0.316 0.000 0.652 NA
#> SRR1539224 2 0.3172 0.8881 0.000 0.840 0.000 NA
#> SRR1539222 3 0.0000 0.6553 0.000 0.000 1.000 NA
#> SRR1539225 3 0.3342 0.6231 0.100 0.000 0.868 NA
#> SRR1539227 2 0.3726 0.8782 0.000 0.788 0.000 NA
#> SRR1539226 1 0.2125 0.6167 0.920 0.000 0.076 NA
#> SRR1539228 3 0.3015 0.6310 0.092 0.000 0.884 NA
#> SRR1539229 1 0.0707 0.6065 0.980 0.000 0.000 NA
#> SRR1539232 3 0.5649 0.1316 0.392 0.000 0.580 NA
#> SRR1539230 2 0.3945 0.8755 0.004 0.780 0.000 NA
#> SRR1539231 2 0.3945 0.8755 0.004 0.780 0.000 NA
#> SRR1539234 2 0.0188 0.8922 0.000 0.996 0.000 NA
#> SRR1539233 1 0.0469 0.6066 0.988 0.000 0.000 NA
#> SRR1539235 3 0.7621 0.0987 0.296 0.000 0.468 NA
#> SRR1539236 1 0.2888 0.5933 0.872 0.000 0.124 NA
#> SRR1539237 2 0.1389 0.8807 0.000 0.952 0.000 NA
#> SRR1539238 3 0.6757 0.3549 0.308 0.000 0.572 NA
#> SRR1539239 1 0.5172 0.4316 0.704 0.000 0.260 NA
#> SRR1539242 1 0.5989 0.0607 0.556 0.000 0.400 NA
#> SRR1539240 2 0.1211 0.8840 0.000 0.960 0.000 NA
#> SRR1539241 3 0.5387 0.3770 0.400 0.000 0.584 NA
#> SRR1539243 2 0.0921 0.8878 0.000 0.972 0.000 NA
#> SRR1539244 1 0.5400 0.4232 0.608 0.000 0.020 NA
#> SRR1539245 1 0.3610 0.5413 0.800 0.000 0.000 NA
#> SRR1539246 2 0.0921 0.8878 0.000 0.972 0.000 NA
#> SRR1539247 3 0.7227 0.2348 0.256 0.000 0.544 NA
#> SRR1539248 1 0.5750 -0.0620 0.532 0.000 0.440 NA
#> SRR1539249 2 0.0817 0.8887 0.000 0.976 0.000 NA
#> SRR1539250 3 0.0336 0.6576 0.008 0.000 0.992 NA
#> SRR1539251 3 0.0336 0.6576 0.008 0.000 0.992 NA
#> SRR1539253 2 0.0921 0.8878 0.000 0.972 0.000 NA
#> SRR1539252 1 0.4406 0.3844 0.700 0.000 0.300 NA
#> SRR1539255 1 0.1902 0.6182 0.932 0.000 0.064 NA
#> SRR1539254 3 0.4343 0.5651 0.264 0.000 0.732 NA
#> SRR1539256 2 0.4730 0.6134 0.000 0.636 0.000 NA
#> SRR1539257 1 0.7874 0.1847 0.380 0.000 0.336 NA
#> SRR1539258 1 0.5339 0.2390 0.624 0.000 0.356 NA
#> SRR1539259 2 0.0188 0.8922 0.000 0.996 0.000 NA
#> SRR1539260 3 0.4857 0.5373 0.284 0.000 0.700 NA
#> SRR1539262 2 0.0000 0.8924 0.000 1.000 0.000 NA
#> SRR1539261 3 0.5746 0.4045 0.348 0.000 0.612 NA
cbind(get_classes(res, k = 5), get_membership(res, k = 5))
#> class entropy silhouette p1 p2 p3 p4 p5
#> SRR1539207 3 0.1410 0.9043 0.060 0.000 0.940 0.000 0.000
#> SRR1539208 1 0.2361 0.7794 0.892 0.000 0.012 0.000 0.096
#> SRR1539211 1 0.4146 0.7153 0.804 0.012 0.088 0.000 0.096
#> SRR1539210 3 0.2609 0.8189 0.028 0.008 0.896 0.000 0.068
#> SRR1539209 4 0.1484 0.6761 0.000 0.008 0.048 0.944 0.000
#> SRR1539212 4 0.2673 0.6268 0.000 0.028 0.072 0.892 0.008
#> SRR1539214 1 0.4294 -0.1687 0.532 0.000 0.000 0.000 0.468
#> SRR1539213 3 0.3274 0.8946 0.076 0.004 0.856 0.000 0.064
#> SRR1539215 4 0.1502 0.6673 0.000 0.004 0.000 0.940 0.056
#> SRR1539216 3 0.1410 0.9043 0.060 0.000 0.940 0.000 0.000
#> SRR1539217 1 0.1942 0.7895 0.920 0.000 0.012 0.000 0.068
#> SRR1539218 4 0.0162 0.7035 0.000 0.004 0.000 0.996 0.000
#> SRR1539220 1 0.6557 -0.2186 0.440 0.000 0.208 0.000 0.352
#> SRR1539219 3 0.1924 0.9044 0.064 0.004 0.924 0.000 0.008
#> SRR1539221 4 0.0000 0.7047 0.000 0.000 0.000 1.000 0.000
#> SRR1539223 1 0.4583 0.6468 0.756 0.004 0.144 0.000 0.096
#> SRR1539224 4 0.0404 0.6986 0.000 0.012 0.000 0.988 0.000
#> SRR1539222 3 0.2139 0.8940 0.052 0.000 0.916 0.000 0.032
#> SRR1539225 3 0.3274 0.8946 0.076 0.004 0.856 0.000 0.064
#> SRR1539227 4 0.0000 0.7047 0.000 0.000 0.000 1.000 0.000
#> SRR1539226 1 0.1043 0.7982 0.960 0.000 0.000 0.000 0.040
#> SRR1539228 3 0.3073 0.8991 0.076 0.004 0.868 0.000 0.052
#> SRR1539229 1 0.1768 0.7791 0.924 0.004 0.000 0.000 0.072
#> SRR1539232 3 0.4239 0.8429 0.080 0.004 0.784 0.000 0.132
#> SRR1539230 4 0.0404 0.7019 0.000 0.000 0.000 0.988 0.012
#> SRR1539231 4 0.0162 0.7045 0.000 0.000 0.000 0.996 0.004
#> SRR1539234 4 0.4273 -0.5658 0.000 0.448 0.000 0.552 0.000
#> SRR1539233 1 0.1270 0.7931 0.948 0.000 0.000 0.000 0.052
#> SRR1539235 5 0.5334 0.1604 0.436 0.000 0.052 0.000 0.512
#> SRR1539236 1 0.0703 0.8028 0.976 0.000 0.000 0.000 0.024
#> SRR1539237 2 0.4219 0.6892 0.000 0.584 0.000 0.416 0.000
#> SRR1539238 1 0.5246 0.5664 0.696 0.020 0.068 0.000 0.216
#> SRR1539239 1 0.0290 0.8044 0.992 0.000 0.000 0.000 0.008
#> SRR1539242 1 0.0162 0.8044 0.996 0.000 0.000 0.000 0.004
#> SRR1539240 2 0.4227 0.6944 0.000 0.580 0.000 0.420 0.000
#> SRR1539241 1 0.2628 0.7811 0.884 0.000 0.028 0.000 0.088
#> SRR1539243 2 0.4305 0.6786 0.000 0.512 0.000 0.488 0.000
#> SRR1539244 5 0.2482 0.5918 0.084 0.000 0.024 0.000 0.892
#> SRR1539245 1 0.4383 0.0278 0.572 0.004 0.000 0.000 0.424
#> SRR1539246 2 0.4307 0.6508 0.000 0.500 0.000 0.500 0.000
#> SRR1539247 5 0.5032 0.6184 0.128 0.000 0.168 0.000 0.704
#> SRR1539248 1 0.0290 0.8048 0.992 0.000 0.000 0.000 0.008
#> SRR1539249 4 0.4262 -0.5469 0.000 0.440 0.000 0.560 0.000
#> SRR1539250 3 0.3622 0.8308 0.124 0.000 0.820 0.000 0.056
#> SRR1539251 3 0.3622 0.8308 0.124 0.000 0.820 0.000 0.056
#> SRR1539253 2 0.4306 0.6723 0.000 0.508 0.000 0.492 0.000
#> SRR1539252 1 0.0703 0.8028 0.976 0.000 0.000 0.000 0.024
#> SRR1539255 1 0.1043 0.7990 0.960 0.000 0.000 0.000 0.040
#> SRR1539254 1 0.3644 0.7385 0.824 0.000 0.080 0.000 0.096
#> SRR1539256 2 0.1043 0.3455 0.000 0.960 0.000 0.040 0.000
#> SRR1539257 5 0.4317 0.6998 0.160 0.000 0.076 0.000 0.764
#> SRR1539258 1 0.0290 0.8044 0.992 0.000 0.000 0.000 0.008
#> SRR1539259 4 0.4192 -0.4290 0.000 0.404 0.000 0.596 0.000
#> SRR1539260 1 0.3648 0.7320 0.824 0.000 0.092 0.000 0.084
#> SRR1539262 4 0.4030 -0.2398 0.000 0.352 0.000 0.648 0.000
#> SRR1539261 1 0.2249 0.7814 0.896 0.000 0.008 0.000 0.096
cbind(get_classes(res, k = 6), get_membership(res, k = 6))
#> class entropy silhouette p1 p2 p3 p4 p5 p6
#> SRR1539207 3 0.0000 0.8347 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539208 1 0.2182 0.7794 0.900 0.000 0.004 0.000 0.020 0.076
#> SRR1539211 1 0.3930 0.3621 0.576 0.000 0.004 0.000 0.000 0.420
#> SRR1539210 3 0.3300 0.7130 0.016 0.000 0.812 0.000 0.016 0.156
#> SRR1539209 6 0.3828 0.6816 0.000 0.000 0.000 0.440 0.000 0.560
#> SRR1539212 6 0.4277 0.7227 0.000 0.000 0.064 0.236 0.000 0.700
#> SRR1539214 1 0.4809 0.3213 0.628 0.000 0.052 0.000 0.308 0.012
#> SRR1539213 3 0.1007 0.8327 0.000 0.000 0.956 0.000 0.044 0.000
#> SRR1539215 4 0.5166 -0.0265 0.000 0.000 0.020 0.608 0.304 0.068
#> SRR1539216 3 0.0000 0.8347 0.000 0.000 1.000 0.000 0.000 0.000
#> SRR1539217 1 0.1168 0.7921 0.956 0.000 0.000 0.000 0.016 0.028
#> SRR1539218 4 0.0363 0.6794 0.000 0.012 0.000 0.988 0.000 0.000
#> SRR1539220 3 0.5883 -0.2654 0.396 0.000 0.452 0.000 0.140 0.012
#> SRR1539219 3 0.0146 0.8354 0.000 0.000 0.996 0.000 0.004 0.000
#> SRR1539221 4 0.0508 0.6667 0.000 0.000 0.000 0.984 0.004 0.012
#> SRR1539223 1 0.2831 0.7514 0.872 0.000 0.064 0.000 0.016 0.048
#> SRR1539224 4 0.0603 0.6801 0.000 0.016 0.000 0.980 0.000 0.004
#> SRR1539222 3 0.1364 0.8226 0.012 0.000 0.952 0.000 0.016 0.020
#> SRR1539225 3 0.1075 0.8314 0.000 0.000 0.952 0.000 0.048 0.000
#> SRR1539227 4 0.0508 0.6791 0.000 0.012 0.000 0.984 0.000 0.004
#> SRR1539226 1 0.0937 0.7943 0.960 0.000 0.000 0.000 0.040 0.000
#> SRR1539228 3 0.1075 0.8314 0.000 0.000 0.952 0.000 0.048 0.000
#> SRR1539229 1 0.2146 0.7534 0.880 0.000 0.000 0.000 0.116 0.004
#> SRR1539232 3 0.1615 0.8188 0.004 0.000 0.928 0.000 0.064 0.004
#> SRR1539230 4 0.0622 0.6653 0.000 0.000 0.000 0.980 0.012 0.008
#> SRR1539231 4 0.0520 0.6678 0.000 0.000 0.000 0.984 0.008 0.008
#> SRR1539234 2 0.3445 0.7826 0.000 0.732 0.000 0.260 0.000 0.008
#> SRR1539233 1 0.2715 0.7575 0.860 0.004 0.000 0.000 0.112 0.024
#> SRR1539235 1 0.5748 0.1816 0.568 0.008 0.076 0.000 0.316 0.032
#> SRR1539236 1 0.0713 0.7967 0.972 0.000 0.000 0.000 0.028 0.000
#> SRR1539237 2 0.1910 0.8154 0.000 0.892 0.000 0.108 0.000 0.000
#> SRR1539238 1 0.7156 0.1215 0.468 0.292 0.028 0.000 0.076 0.136
#> SRR1539239 1 0.0632 0.7976 0.976 0.000 0.000 0.000 0.024 0.000
#> SRR1539242 1 0.0891 0.7986 0.968 0.000 0.000 0.000 0.024 0.008
#> SRR1539240 2 0.2053 0.8152 0.000 0.888 0.000 0.108 0.000 0.004
#> SRR1539241 1 0.5483 0.5523 0.680 0.140 0.012 0.000 0.040 0.128
#> SRR1539243 2 0.3309 0.7554 0.000 0.720 0.000 0.280 0.000 0.000
#> SRR1539244 5 0.3259 0.4039 0.072 0.024 0.028 0.004 0.860 0.012
#> SRR1539245 1 0.4515 0.3449 0.608 0.000 0.028 0.000 0.356 0.008
#> SRR1539246 4 0.3852 0.2848 0.000 0.384 0.000 0.612 0.000 0.004
#> SRR1539247 5 0.5852 0.6554 0.192 0.000 0.252 0.000 0.544 0.012
#> SRR1539248 1 0.1092 0.7989 0.960 0.000 0.000 0.000 0.020 0.020
#> SRR1539249 4 0.3872 0.2632 0.000 0.392 0.000 0.604 0.000 0.004
#> SRR1539250 3 0.3411 0.7128 0.088 0.000 0.836 0.000 0.044 0.032
#> SRR1539251 3 0.3360 0.7193 0.084 0.000 0.840 0.000 0.044 0.032
#> SRR1539253 2 0.3151 0.7908 0.000 0.748 0.000 0.252 0.000 0.000
#> SRR1539252 1 0.0000 0.7981 1.000 0.000 0.000 0.000 0.000 0.000
#> SRR1539255 1 0.0405 0.7988 0.988 0.000 0.004 0.000 0.008 0.000
#> SRR1539254 1 0.3960 0.6878 0.808 0.004 0.084 0.000 0.056 0.048
#> SRR1539256 2 0.0862 0.6998 0.000 0.972 0.000 0.004 0.016 0.008
#> SRR1539257 5 0.5916 0.6902 0.248 0.000 0.192 0.000 0.544 0.016
#> SRR1539258 1 0.0458 0.7985 0.984 0.000 0.000 0.000 0.016 0.000
#> SRR1539259 4 0.3584 0.4603 0.000 0.308 0.000 0.688 0.000 0.004
#> SRR1539260 1 0.3617 0.7298 0.828 0.004 0.032 0.000 0.048 0.088
#> SRR1539262 4 0.3584 0.4603 0.000 0.308 0.000 0.688 0.000 0.004
#> SRR1539261 1 0.1707 0.7878 0.928 0.000 0.004 0.000 0.012 0.056
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